Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / WINNT / afsusrmgr / winlist.cpp
1 extern "C" {
2 #include <afs/param.h>
3 #include <afs/stds.h>
4 }
5
6 #include "TaAfsUsrMgr.h"
7 #include "winlist.h"
8
9
10 /*
11  * DEFINITIONS ________________________________________________________________
12  *
13  */
14
15 typedef struct
16    {
17    HWND hWnd;
18    WINDOWLISTTYPE wlt;
19    ASID idObject;
20    } WINDOWLISTENTRY, *LPWINDOWLISTENTRY;
21
22 static WINDOWLISTENTRY *aWindowList = NULL;
23 static size_t cWindowList = 0;
24
25 #define cREALLOC_WINDOWLIST  4
26
27
28 /*
29  * ROUTINES ___________________________________________________________________
30  *
31  */
32
33 void WindowList_Add (HWND hWnd, WINDOWLISTTYPE wlt, ASID idObject)
34 {
35    // See if this window is already in the list
36    //
37    for (size_t ii = 0; ii < cWindowList; ++ii)
38       {
39       if (aWindowList[ ii ].hWnd == hWnd)
40          return;
41       }
42
43    // Add this window to the list
44    //
45    for (ii = 0; ii < cWindowList; ++ii)
46       {
47       if (!aWindowList[ ii ].hWnd)
48          break;
49       }
50    if (REALLOC (aWindowList, cWindowList, 1+ii, cREALLOC_WINDOWLIST))
51       {
52       aWindowList[ ii ].hWnd = hWnd;
53       aWindowList[ ii ].wlt = wlt;
54       aWindowList[ ii ].idObject = idObject;
55       AfsAppLib_RegisterModelessDialog (hWnd);
56       }
57 }
58
59
60 HWND WindowList_Search (WINDOWLISTTYPE wlt, ASID idObject)
61 {
62    for (size_t ii = 0; ii < cWindowList; ++ii)
63       {
64       if (!aWindowList[ ii ].hWnd)
65          continue;
66       if (aWindowList[ ii ].wlt != wlt)
67          continue;
68       if ((idObject != ASID_ANY) && (aWindowList[ ii ].idObject != idObject))
69          continue;
70       return aWindowList[ ii ].hWnd;
71       }
72    return NULL;
73 }
74
75
76 void WindowList_Remove (HWND hWnd)
77 {
78    for (size_t ii = 0; ii < cWindowList; ++ii)
79       {
80       if (aWindowList[ ii ].hWnd == hWnd)
81          aWindowList[ ii ].hWnd = NULL;
82       }
83 }
84