winnt-dont-display-ibm-legal-message-20040326
[openafs.git] / src / WINNT / afsusrmgr / errdata.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
13 }
14
15 #include "TaAfsUsrMgr.h"
16
17
18 /*
19  * ROUTINES ___________________________________________________________________
20  *
21  */
22
23 LPERRORDATA ED_Create (int idsSingle, int idsMultiple)
24 {
25    LPERRORDATA ped = New (ERRORDATA);
26    memset (ped, 0x00, sizeof(ERRORDATA));
27    ped->idsSingle = idsSingle;
28    ped->idsMultiple = idsMultiple;
29    return ped;
30 }
31
32
33 void ED_Free (LPERRORDATA ped)
34 {
35    if (ped)
36       {
37       if (ped->pAsidList)
38          asc_AsidListFree (&ped->pAsidList);
39       Delete (ped);
40       }
41 }
42
43
44 void ED_RegisterStatus (LPERRORDATA ped, ASID idObject, BOOL fSuccess, ULONG status)
45 {
46    if (!fSuccess)
47       {
48       if (!ped->pAsidList)
49          asc_AsidListCreate (&ped->pAsidList);
50       if (!asc_AsidListTest (&ped->pAsidList, idObject))
51          asc_AsidListAddEntry (&ped->pAsidList, idObject, status);
52       if (!ped->status)
53          ped->status = status;
54       ped->cFailures ++;
55       }
56 }
57
58
59 ULONG ED_GetFinalStatus (LPERRORDATA ped)
60 {
61    return (ped->cFailures) ? ped->status : 0;
62 }
63
64
65 void ED_ShowErrorDialog (LPERRORDATA ped)
66 {
67    if (ped->pAsidList)
68       {
69       LPTSTR pszNames = CreateNameList (ped->pAsidList);
70
71       if (ped->pAsidList->cEntries == 1)
72          {
73          if (!pszNames)
74             ErrorDialog (ped->status, ped->idsSingle, TEXT("%m"), IDS_UNKNOWN_NAME);
75          else
76             ErrorDialog (ped->status, ped->idsSingle, TEXT("%s"), pszNames);
77          }
78       else if (ped->pAsidList->cEntries > 1)
79          {
80          if (!pszNames)
81             ErrorDialog (ped->status, ped->idsMultiple, TEXT("%m"), IDS_UNKNOWN_NAME);
82          else
83             ErrorDialog (ped->status, ped->idsMultiple, TEXT("%s"), pszNames);
84          }
85
86       FreeString (pszNames);
87       }
88 }
89