Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / WINNT / afsusrmgr / errdata.cpp
1 extern "C" {
2 #include <afs/param.h>
3 #include <afs/stds.h>
4 }
5
6 #include "TaAfsUsrMgr.h"
7
8
9 /*
10  * ROUTINES ___________________________________________________________________
11  *
12  */
13
14 LPERRORDATA ED_Create (int idsSingle, int idsMultiple)
15 {
16    LPERRORDATA ped = New (ERRORDATA);
17    memset (ped, 0x00, sizeof(ERRORDATA));
18    ped->idsSingle = idsSingle;
19    ped->idsMultiple = idsMultiple;
20    return ped;
21 }
22
23
24 void ED_Free (LPERRORDATA ped)
25 {
26    if (ped)
27       {
28       if (ped->pAsidList)
29          asc_AsidListFree (&ped->pAsidList);
30       Delete (ped);
31       }
32 }
33
34
35 void ED_RegisterStatus (LPERRORDATA ped, ASID idObject, BOOL fSuccess, ULONG status)
36 {
37    if (!fSuccess)
38       {
39       if (!ped->pAsidList)
40          asc_AsidListCreate (&ped->pAsidList);
41       if (!asc_AsidListTest (&ped->pAsidList, idObject))
42          asc_AsidListAddEntry (&ped->pAsidList, idObject, status);
43       if (!ped->status)
44          ped->status = status;
45       ped->cFailures ++;
46       }
47 }
48
49
50 ULONG ED_GetFinalStatus (LPERRORDATA ped)
51 {
52    return (ped->cFailures) ? ped->status : 0;
53 }
54
55
56 void ED_ShowErrorDialog (LPERRORDATA ped)
57 {
58    if (ped->pAsidList)
59       {
60       LPTSTR pszNames = CreateNameList (ped->pAsidList);
61
62       if (ped->pAsidList->cEntries == 1)
63          {
64          if (!pszNames)
65             ErrorDialog (ped->status, ped->idsSingle, TEXT("%m"), IDS_UNKNOWN_NAME);
66          else
67             ErrorDialog (ped->status, ped->idsSingle, TEXT("%s"), pszNames);
68          }
69       else if (ped->pAsidList->cEntries > 1)
70          {
71          if (!pszNames)
72             ErrorDialog (ped->status, ped->idsMultiple, TEXT("%m"), IDS_UNKNOWN_NAME);
73          else
74             ErrorDialog (ped->status, ped->idsMultiple, TEXT("%s"), pszNames);
75          }
76
77       FreeString (pszNames);
78       }
79 }
80