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))
39 for (size_t iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
41 if (!PropCache_apce[ iEntry ].fInUse)
45 if (iEntry == PropCache_nEntries)
47 if (!REALLOC (PropCache_apce, PropCache_nEntries, 1+iEntry, 16))
51 PropCache_apce[ iEntry ].fInUse = TRUE;
52 PropCache_apce[ iEntry ].pcType = pcType;
53 PropCache_apce[ iEntry ].pv = pv;
54 PropCache_apce[ iEntry ].hDialog = hDialog;
56 if (pcType != pcSERVER)
57 AfsAppLib_RegisterModelessDialog (hDialog);
62 HWND PropCache_Search (PropCache pcType, PVOID pv, HWND hwndStart)
66 if (hwndStart != NULL)
68 for ( ; iEntry < PropCache_nEntries; ++iEntry)
70 if (!PropCache_apce[ iEntry ].fInUse)
72 if (PropCache_apce[ iEntry ].hDialog == hwndStart)
80 for ( ; iEntry < PropCache_nEntries; ++iEntry)
82 if (!PropCache_apce[ iEntry ].fInUse)
85 if ( (PropCache_apce[ iEntry ].pcType == pcType) &&
86 ((pv == ANYVALUE) || (PropCache_apce[ iEntry ].pv == pv)) )
88 if (!IsWindow (PropCache_apce[ iEntry ].hDialog))
90 PropCache_apce[ iEntry ].fInUse = FALSE;
94 return PropCache_apce[ iEntry ].hDialog;
102 void PropCache_Delete (PropCache pcType, PVOID pv)
104 for (size_t iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
106 if (!PropCache_apce[ iEntry ].fInUse)
109 if ( (PropCache_apce[ iEntry ].pcType == pcType) &&
110 ((pv == ANYVALUE) || (PropCache_apce[ iEntry ].pv == pv)) )
112 PropCache_apce[ iEntry ].fInUse = FALSE;
118 void PropCache_Delete (HWND hDialog)
120 for (size_t iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
122 if (!PropCache_apce[ iEntry ].fInUse)
125 if (PropCache_apce[ iEntry ].hDialog == hDialog)
127 PropCache_apce[ iEntry ].fInUse = FALSE;