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 * May 19, 2001 Allan Nathanson <ajn@apple.com>
38 __SCDynamicStoreNotifyValue(SCDynamicStoreRef store
, CFStringRef key
, Boolean internal
)
40 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
41 int sc_status
= kSCStatusOK
;
43 Boolean newValue
= FALSE
;
46 if (_configd_verbose
) {
47 SCLog(TRUE
, LOG_DEBUG
, CFSTR("__SCDynamicStoreNotifyValue:"));
48 SCLog(TRUE
, LOG_DEBUG
, CFSTR(" key = %@"), key
);
51 if (!store
|| (storePrivate
->server
== MACH_PORT_NULL
)) {
52 return kSCStatusNoStoreSession
; /* you must have an open session to play */
56 SCTrace(TRUE
, _configd_trace
,
57 CFSTR("%s : %5d : %@\n"),
58 internal
? "*notify" : "notify ",
64 * 1. Ensure that we hold the lock.
66 sc_status
= __SCDynamicStoreLock(store
, TRUE
);
67 if (sc_status
!= kSCStatusOK
) {
72 * 2. Tickle the value in the dynamic store
74 dict
= CFDictionaryGetValue(storeData
, key
);
75 if (!dict
|| !CFDictionaryGetValueIfPresent(dict
, kSCDData
, (const void **)&value
)) {
76 /* key doesn't exist (or data never defined) */
77 (void)_SCSerialize(kCFBooleanTrue
, &value
, NULL
, NULL
);
81 /* replace or store initial/temporary existing value */
82 __SCDynamicStoreSetValue(store
, key
, value
, TRUE
);
85 /* remove the value we just created */
86 __SCDynamicStoreRemoveValue(store
, key
, TRUE
);
91 * 3. Release our lock.
93 __SCDynamicStoreUnlock(store
, TRUE
);
101 _confignotify(mach_port_t server
,
102 xmlData_t keyRef
, /* raw XML bytes */
103 mach_msg_type_number_t keyLen
,
107 serverSessionRef mySession
= getSession(server
);
108 CFStringRef key
; /* key (un-serialized) */
110 if (_configd_verbose
) {
111 SCLog(TRUE
, LOG_DEBUG
, CFSTR("Notify key in configuration database."));
112 SCLog(TRUE
, LOG_DEBUG
, CFSTR(" server = %d"), server
);
115 /* un-serialize the key */
116 if (!_SCUnserializeString(&key
, NULL
, (void *)keyRef
, keyLen
)) {
117 *sc_status
= kSCStatusFailed
;
121 if (!isA_CFString(key
)) {
122 *sc_status
= kSCStatusInvalidArgument
;
128 *sc_status
= kSCStatusNoStoreSession
; /* you must have an open session to play */
133 *sc_status
= __SCDynamicStoreNotifyValue(mySession
->store
, key
, FALSE
);