import-fs-formatting-to-windows-20031207
[openafs.git] / src / WINNT / afsusrmgr / winlist.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 #include "winlist.h"
17
18
19 /*
20  * DEFINITIONS ________________________________________________________________
21  *
22  */
23
24 typedef struct
25    {
26    HWND hWnd;
27    WINDOWLISTTYPE wlt;
28    ASID idObject;
29    } WINDOWLISTENTRY, *LPWINDOWLISTENTRY;
30
31 static WINDOWLISTENTRY *aWindowList = NULL;
32 static size_t cWindowList = 0;
33
34 #define cREALLOC_WINDOWLIST  4
35
36
37 /*
38  * ROUTINES ___________________________________________________________________
39  *
40  */
41
42 void WindowList_Add (HWND hWnd, WINDOWLISTTYPE wlt, ASID idObject)
43 {
44    // See if this window is already in the list
45    //
46    for (size_t ii = 0; ii < cWindowList; ++ii)
47       {
48       if (aWindowList[ ii ].hWnd == hWnd)
49          return;
50       }
51
52    // Add this window to the list
53    //
54    for (ii = 0; ii < cWindowList; ++ii)
55       {
56       if (!aWindowList[ ii ].hWnd)
57          break;
58       }
59    if (REALLOC (aWindowList, cWindowList, 1+ii, cREALLOC_WINDOWLIST))
60       {
61       aWindowList[ ii ].hWnd = hWnd;
62       aWindowList[ ii ].wlt = wlt;
63       aWindowList[ ii ].idObject = idObject;
64       AfsAppLib_RegisterModelessDialog (hWnd);
65       }
66 }
67
68
69 HWND WindowList_Search (WINDOWLISTTYPE wlt, ASID idObject)
70 {
71    for (size_t ii = 0; ii < cWindowList; ++ii)
72       {
73       if (!aWindowList[ ii ].hWnd)
74          continue;
75       if (aWindowList[ ii ].wlt != wlt)
76          continue;
77       if ((idObject != ASID_ANY) && (aWindowList[ ii ].idObject != idObject))
78          continue;
79       return aWindowList[ ii ].hWnd;
80       }
81    return NULL;
82 }
83
84
85 void WindowList_Remove (HWND hWnd)
86 {
87    for (size_t ii = 0; ii < cWindowList; ++ii)
88       {
89       if (aWindowList[ ii ].hWnd == hWnd)
90          aWindowList[ ii ].hWnd = NULL;
91       }
92 }
93