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 <afsconfig.h>
15 #include <afs/param.h>
20 #include "propcache.h"
24 * PROPERTIES-DIALOG CACHE ____________________________________________________
36 static size_t PropCache_nEntries = 0;
37 static PropCacheEntry *PropCache_apce = NULL;
39 void PropCache_Add (PropCache pcType, PVOID pv, HWND hDialog)
41 if (!PropCache_Search (pcType, pv))
44 for (iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
46 if (!PropCache_apce[ iEntry ].fInUse)
50 if (iEntry == PropCache_nEntries)
52 if (!REALLOC (PropCache_apce, PropCache_nEntries, 1+iEntry, 16))
56 PropCache_apce[ iEntry ].fInUse = TRUE;
57 PropCache_apce[ iEntry ].pcType = pcType;
58 PropCache_apce[ iEntry ].pv = pv;
59 PropCache_apce[ iEntry ].hDialog = hDialog;
61 if (pcType != pcSERVER)
62 AfsAppLib_RegisterModelessDialog (hDialog);
67 HWND PropCache_Search (PropCache pcType, PVOID pv, HWND hwndStart)
71 if (hwndStart != NULL)
73 for ( ; iEntry < PropCache_nEntries; ++iEntry)
75 if (!PropCache_apce[ iEntry ].fInUse)
77 if (PropCache_apce[ iEntry ].hDialog == hwndStart)
85 for ( ; iEntry < PropCache_nEntries; ++iEntry)
87 if (!PropCache_apce[ iEntry ].fInUse)
90 if ( (PropCache_apce[ iEntry ].pcType == pcType) &&
91 ((pv == ANYVALUE) || (PropCache_apce[ iEntry ].pv == pv)) )
93 if (!IsWindow (PropCache_apce[ iEntry ].hDialog))
95 PropCache_apce[ iEntry ].fInUse = FALSE;
99 return PropCache_apce[ iEntry ].hDialog;
107 void PropCache_Delete (PropCache pcType, PVOID pv)
109 for (size_t iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
111 if (!PropCache_apce[ iEntry ].fInUse)
114 if ( (PropCache_apce[ iEntry ].pcType == pcType) &&
115 ((pv == ANYVALUE) || (PropCache_apce[ iEntry ].pv == pv)) )
117 PropCache_apce[ iEntry ].fInUse = FALSE;
123 void PropCache_Delete (HWND hDialog)
125 for (size_t iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
127 if (!PropCache_apce[ iEntry ].fInUse)
130 if (PropCache_apce[ iEntry ].hDialog == hDialog)
132 PropCache_apce[ iEntry ].fInUse = FALSE;