2 * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
27 * Modification History
29 * June 1, 2001 Allan Nathanson <ajn@apple.com>
30 * - public API conversion
32 * March 24, 2000 Allan Nathanson <ajn@apple.com>
44 __SCDynamicStoreRemoveWatchedKey(SCDynamicStoreRef store
, CFStringRef key
, Boolean isRegex
, Boolean internal
)
46 CFNumberRef sessionNum
;
47 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
49 if (_configd_verbose
) {
50 SCLog(TRUE
, LOG_DEBUG
, CFSTR("__SCDynamicStoreRemoveWatchedKey:"));
51 SCLog(TRUE
, LOG_DEBUG
, CFSTR(" key = %@"), key
);
52 SCLog(TRUE
, LOG_DEBUG
, CFSTR(" isRegex = %s"), isRegex
? "TRUE" : "FALSE");
55 if (!store
|| (storePrivate
->server
== MACH_PORT_NULL
)) {
56 return kSCStatusNoStoreSession
; /* you must have an open session to play */
60 SCTrace(TRUE
, _configd_trace
,
61 CFSTR("%s : %5d : %s : %@\n"),
62 internal
? "*watch-" : "watch- ",
64 isRegex
? "pattern" : "key",
69 * remove key from this sessions notifier list after checking that
70 * it was previously defined.
73 if (!CFSetContainsValue(storePrivate
->patterns
, key
))
74 return kSCStatusNoKey
; /* sorry, key does not exist in notifier list */
76 /* remove key from this sessions notifier list */
77 CFSetRemoveValue(storePrivate
->patterns
, key
);
79 /* remove this session as a pattern watcher */
80 sessionNum
= CFNumberCreate(NULL
, kCFNumberIntType
, &storePrivate
->server
);
81 patternRemoveSession(key
, sessionNum
);
82 CFRelease(sessionNum
);
84 if (!CFSetContainsValue(storePrivate
->keys
, key
))
85 return kSCStatusNoKey
; /* sorry, key does not exist in notifier list */
87 /* remove key from this sessions notifier list */
88 CFSetRemoveValue(storePrivate
->keys
, key
);
91 * We are watching a specific key. As such, update the
92 * store to mark our interest in any changes.
94 sessionNum
= CFNumberCreate(NULL
, kCFNumberIntType
, &storePrivate
->server
);
95 _removeWatcher(sessionNum
, key
);
96 CFRelease(sessionNum
);
105 _notifyremove(mach_port_t server
,
106 xmlData_t keyRef
, /* raw XML bytes */
107 mach_msg_type_number_t keyLen
,
112 serverSessionRef mySession
= getSession(server
);
113 CFStringRef key
; /* key (un-serialized) */
115 if (_configd_verbose
) {
116 SCLog(TRUE
, LOG_DEBUG
, CFSTR("Remove notification key for this session."));
117 SCLog(TRUE
, LOG_DEBUG
, CFSTR(" server = %d"), server
);
120 /* un-serialize the key */
121 if (!_SCUnserializeString(&key
, NULL
, (void *)keyRef
, keyLen
)) {
122 *sc_status
= kSCStatusFailed
;
126 if (!isA_CFString(key
)) {
127 *sc_status
= kSCStatusInvalidArgument
;
133 *sc_status
= kSCStatusNoStoreSession
; /* you must have an open session to play */
138 *sc_status
= __SCDynamicStoreRemoveWatchedKey(mySession
->store
,