2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
24 * Modification History
26 * June 1, 2001 Allan Nathanson <ajn@apple.com>
27 * - public API conversion
29 * March 24, 2000 Allan Nathanson <ajn@apple.com>
37 __SCDynamicStoreCopyNotifiedKeys(SCDynamicStoreRef store
, CFArrayRef
*notifierKeys
)
39 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
40 CFStringRef sessionKey
;
42 CFMutableDictionaryRef newInfo
;
44 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR("__SCDynamicStoreCopyNotifiedKeys:"));
46 if (!store
|| (storePrivate
->server
== MACH_PORT_NULL
)) {
47 return kSCStatusNoStoreSession
; /* you must have an open session to play */
50 sessionKey
= CFStringCreateWithFormat(NULL
, NULL
, CFSTR("%d"), storePrivate
->server
);
51 info
= CFDictionaryGetValue(sessionData
, sessionKey
);
53 (CFDictionaryContainsKey(info
, kSCDChangedKeys
) == FALSE
)) {
54 CFRelease(sessionKey
);
55 *notifierKeys
= CFArrayCreate(NULL
, NULL
, 0, &kCFTypeArrayCallBacks
);;
58 newInfo
= CFDictionaryCreateMutableCopy(NULL
, 0, info
);
60 *notifierKeys
= CFDictionaryGetValue(newInfo
, kSCDChangedKeys
);
61 CFRetain(*notifierKeys
);
63 CFDictionaryRemoveValue(newInfo
, kSCDChangedKeys
);
64 if (CFDictionaryGetCount(newInfo
) > 0) {
65 CFDictionarySetValue(sessionData
, sessionKey
, newInfo
);
67 CFDictionaryRemoveValue(sessionData
, sessionKey
);
70 CFRelease(sessionKey
);
77 _notifychanges(mach_port_t server
,
78 xmlDataOut_t
*listRef
, /* raw XML bytes */
79 mach_msg_type_number_t
*listLen
,
84 serverSessionRef mySession
= getSession(server
);
85 CFArrayRef notifierKeys
; /* array of CFStringRef's */
86 CFDataRef xmlList
; /* list (XML serialized) */
88 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR("List notification keys which have changed."));
89 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR(" server = %d"), server
);
91 *sc_status
= __SCDynamicStoreCopyNotifiedKeys(mySession
->store
, ¬ifierKeys
);
92 if (*sc_status
!= kSCStatusOK
) {
99 * serialize the array, copy it into an allocated buffer which will be
100 * released when it is returned as part of a Mach message.
102 xmlList
= CFPropertyListCreateXMLData(NULL
, notifierKeys
);
103 CFRelease(notifierKeys
);
104 *listLen
= CFDataGetLength(xmlList
);
105 status
= vm_allocate(mach_task_self(), (void *)listRef
, *listLen
, TRUE
);
106 if (status
!= KERN_SUCCESS
) {
107 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR("vm_allocate(): %s"), mach_error_string(status
));
111 *sc_status
= kSCStatusFailed
;
115 bcopy((char *)CFDataGetBytePtr(xmlList
), *listRef
, *listLen
);