-
-static __inline__ void
-my_CFSetApplyFunction(CFSetRef theSet,
- CFSetApplierFunction applier,
- void *context)
-{
- CFAllocatorRef myAllocator;
- CFSetRef mySet;
-
- myAllocator = CFGetAllocator(theSet);
- mySet = CFSetCreateCopy(myAllocator, theSet);
- CFSetApplyFunction(mySet, applier, context);
- CFRelease(mySet);
- return;
-}
-
-
-/*
- * "context" argument for removeOldKey() and addNewKey()
- */
-typedef struct {
- SCDynamicStoreRef store;
- CFArrayRef newKeys; /* for removeOldKey */
- Boolean isRegex;
- Boolean ok;
-} updateKeysContext, *updateKeysContextRef;
-
-
-static void
-removeOldKey(const void *value, void *context)
-{
- CFStringRef oldKey = (CFStringRef)value;
- updateKeysContextRef myContextRef = (updateKeysContextRef)context;
-
- if (!myContextRef->ok) {
- return;
- }
-
- if (!myContextRef->newKeys ||
- !CFArrayContainsValue(myContextRef->newKeys,
- CFRangeMake(0, CFArrayGetCount(myContextRef->newKeys)),
- oldKey)) {
- /* the old notification key is not being retained, remove it */
- myContextRef->ok = SCDynamicStoreRemoveWatchedKey(myContextRef->store,
- oldKey,
- myContextRef->isRegex);
- }
-
- return;
-}
-
-
-static void
-addNewKey(const void *value, void *context)
-{
- CFStringRef newKey = (CFStringRef)value;
- updateKeysContextRef myContextRef = (updateKeysContextRef)context;
- SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)myContextRef->store;
-
- if (!myContextRef->ok) {
- return;
- }
-
- if (myContextRef->isRegex) {
- if (!CFSetContainsValue(storePrivate->reKeys, newKey)) {
- /* add pattern to this sessions notifier list */
- myContextRef->ok = SCDynamicStoreAddWatchedKey(myContextRef->store, newKey, TRUE);
- }
- } else {
- if (!CFSetContainsValue(storePrivate->keys, newKey)) {
- /* add key to this sessions notifier list */
- myContextRef->ok = SCDynamicStoreAddWatchedKey(myContextRef->store, newKey, FALSE);
- }
- }
-
- return;
-}
-