2 * Copyright (c) 2000-2004, 2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 * Modification History
27 * June 1, 2001 Allan Nathanson <ajn@apple.com>
28 * - public API conversion
30 * March 24, 2000 Allan Nathanson <ajn@apple.com>
42 __SCDynamicStoreRemoveWatchedKey(SCDynamicStoreRef store
, CFStringRef key
, Boolean isRegex
, Boolean internal
)
44 CFNumberRef sessionNum
;
45 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
47 if ((store
== NULL
) || (storePrivate
->server
== MACH_PORT_NULL
)) {
48 return kSCStatusNoStoreSession
; /* you must have an open session to play */
52 SCTrace(TRUE
, _configd_trace
,
53 CFSTR("%s : %5d : %s : %@\n"),
54 internal
? "*watch-" : "watch- ",
56 isRegex
? "pattern" : "key",
61 * remove key from this sessions notifier list after checking that
62 * it was previously defined.
65 if (!CFSetContainsValue(storePrivate
->patterns
, key
))
66 return kSCStatusNoKey
; /* sorry, key does not exist in notifier list */
68 /* remove key from this sessions notifier list */
69 CFSetRemoveValue(storePrivate
->patterns
, key
);
71 /* remove this session as a pattern watcher */
72 sessionNum
= CFNumberCreate(NULL
, kCFNumberIntType
, &storePrivate
->server
);
73 patternRemoveSession(key
, sessionNum
);
74 CFRelease(sessionNum
);
76 if (!CFSetContainsValue(storePrivate
->keys
, key
))
77 return kSCStatusNoKey
; /* sorry, key does not exist in notifier list */
79 /* remove key from this sessions notifier list */
80 CFSetRemoveValue(storePrivate
->keys
, key
);
83 * We are watching a specific key. As such, update the
84 * store to mark our interest in any changes.
86 sessionNum
= CFNumberCreate(NULL
, kCFNumberIntType
, &storePrivate
->server
);
87 _removeWatcher(sessionNum
, key
);
88 CFRelease(sessionNum
);
97 _notifyremove(mach_port_t server
,
98 xmlData_t keyRef
, /* raw XML bytes */
99 mach_msg_type_number_t keyLen
,
104 CFStringRef key
= NULL
; /* key (un-serialized) */
105 serverSessionRef mySession
= getSession(server
);
107 /* un-serialize the key */
108 if (!_SCUnserializeString(&key
, NULL
, (void *)keyRef
, keyLen
)) {
109 *sc_status
= kSCStatusFailed
;
113 if (!isA_CFString(key
)) {
114 *sc_status
= kSCStatusInvalidArgument
;
118 if (mySession
== NULL
) {
119 *sc_status
= kSCStatusNoStoreSession
; /* you must have an open session to play */
123 *sc_status
= __SCDynamicStoreRemoveWatchedKey(mySession
->store
,
130 if (key
) CFRelease(key
);