2 * Copyright 2000, International Business Machines Corporation and others.
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
14 #include <afs/param.h>
19 #include "propcache.h"
23 * PROPERTIES-DIALOG CACHE ____________________________________________________
35 static size_t PropCache_nEntries = 0;
36 static PropCacheEntry *PropCache_apce = NULL;
38 void PropCache_Add (PropCache pcType, PVOID pv, HWND hDialog)
40 if (!PropCache_Search (pcType, pv))
43 for (iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
45 if (!PropCache_apce[ iEntry ].fInUse)
49 if (iEntry == PropCache_nEntries)
51 if (!REALLOC (PropCache_apce, PropCache_nEntries, 1+iEntry, 16))
55 PropCache_apce[ iEntry ].fInUse = TRUE;
56 PropCache_apce[ iEntry ].pcType = pcType;
57 PropCache_apce[ iEntry ].pv = pv;
58 PropCache_apce[ iEntry ].hDialog = hDialog;
60 if (pcType != pcSERVER)
61 AfsAppLib_RegisterModelessDialog (hDialog);
66 HWND PropCache_Search (PropCache pcType, PVOID pv, HWND hwndStart)
70 if (hwndStart != NULL)
72 for ( ; iEntry < PropCache_nEntries; ++iEntry)
74 if (!PropCache_apce[ iEntry ].fInUse)
76 if (PropCache_apce[ iEntry ].hDialog == hwndStart)
84 for ( ; iEntry < PropCache_nEntries; ++iEntry)
86 if (!PropCache_apce[ iEntry ].fInUse)
89 if ( (PropCache_apce[ iEntry ].pcType == pcType) &&
90 ((pv == ANYVALUE) || (PropCache_apce[ iEntry ].pv == pv)) )
92 if (!IsWindow (PropCache_apce[ iEntry ].hDialog))
94 PropCache_apce[ iEntry ].fInUse = FALSE;
98 return PropCache_apce[ iEntry ].hDialog;
106 void PropCache_Delete (PropCache pcType, PVOID pv)
108 for (size_t iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
110 if (!PropCache_apce[ iEntry ].fInUse)
113 if ( (PropCache_apce[ iEntry ].pcType == pcType) &&
114 ((pv == ANYVALUE) || (PropCache_apce[ iEntry ].pv == pv)) )
116 PropCache_apce[ iEntry ].fInUse = FALSE;
122 void PropCache_Delete (HWND hDialog)
124 for (size_t iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
126 if (!PropCache_apce[ iEntry ].fInUse)
129 if (PropCache_apce[ iEntry ].hDialog == hDialog)
131 PropCache_apce[ iEntry ].fInUse = FALSE;