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
11 #include <afs/param.h>
16 #include "propcache.h"
20 * PROPERTIES-DIALOG CACHE ____________________________________________________
32 static size_t PropCache_nEntries = 0;
33 static PropCacheEntry *PropCache_apce = NULL;
35 void PropCache_Add (PropCache pcType, PVOID pv, HWND hDialog)
37 if (!PropCache_Search (pcType, pv))
40 for (iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
42 if (!PropCache_apce[ iEntry ].fInUse)
46 if (iEntry == PropCache_nEntries)
48 if (!REALLOC (PropCache_apce, PropCache_nEntries, 1+iEntry, 16))
52 PropCache_apce[ iEntry ].fInUse = TRUE;
53 PropCache_apce[ iEntry ].pcType = pcType;
54 PropCache_apce[ iEntry ].pv = pv;
55 PropCache_apce[ iEntry ].hDialog = hDialog;
57 if (pcType != pcSERVER)
58 AfsAppLib_RegisterModelessDialog (hDialog);
63 HWND PropCache_Search (PropCache pcType, PVOID pv, HWND hwndStart)
67 if (hwndStart != NULL)
69 for ( ; iEntry < PropCache_nEntries; ++iEntry)
71 if (!PropCache_apce[ iEntry ].fInUse)
73 if (PropCache_apce[ iEntry ].hDialog == hwndStart)
81 for ( ; iEntry < PropCache_nEntries; ++iEntry)
83 if (!PropCache_apce[ iEntry ].fInUse)
86 if ( (PropCache_apce[ iEntry ].pcType == pcType) &&
87 ((pv == ANYVALUE) || (PropCache_apce[ iEntry ].pv == pv)) )
89 if (!IsWindow (PropCache_apce[ iEntry ].hDialog))
91 PropCache_apce[ iEntry ].fInUse = FALSE;
95 return PropCache_apce[ iEntry ].hDialog;
103 void PropCache_Delete (PropCache pcType, PVOID pv)
105 for (size_t iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
107 if (!PropCache_apce[ iEntry ].fInUse)
110 if ( (PropCache_apce[ iEntry ].pcType == pcType) &&
111 ((pv == ANYVALUE) || (PropCache_apce[ iEntry ].pv == pv)) )
113 PropCache_apce[ iEntry ].fInUse = FALSE;
119 void PropCache_Delete (HWND hDialog)
121 for (size_t iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
123 if (!PropCache_apce[ iEntry ].fInUse)
126 if (PropCache_apce[ iEntry ].hDialog == hDialog)
128 PropCache_apce[ iEntry ].fInUse = FALSE;