2 * Copyright (c) 2000-2006, 2008-2012 Apple 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>
34 #include <TargetConditionals.h>
37 #include <sys/types.h>
38 #include <mach/mach.h>
39 #include <mach/mach_error.h>
40 #include <servers/bootstrap.h>
41 #include <bootstrap_priv.h>
43 #include <SystemConfiguration/SystemConfiguration.h>
44 #include <SystemConfiguration/SCPrivate.h>
46 #include "SCDynamicStoreInternal.h"
47 #include "config.h" /* MiG generated file */
50 static CFStringRef _sc_bundleID
= NULL
;
51 static pthread_mutex_t _sc_lock
= PTHREAD_MUTEX_INITIALIZER
;
52 static mach_port_t _sc_server
= MACH_PORT_NULL
;
55 static const char *notifyType
[] = {
68 __SCDynamicStoreCopyDescription(CFTypeRef cf
) {
69 CFAllocatorRef allocator
= CFGetAllocator(cf
);
70 CFMutableStringRef result
;
71 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)cf
;
73 result
= CFStringCreateMutable(allocator
, 0);
74 CFStringAppendFormat(result
, NULL
, CFSTR("<SCDynamicStore %p [%p]> {"), cf
, allocator
);
75 if (storePrivate
->server
!= MACH_PORT_NULL
) {
76 CFStringAppendFormat(result
, NULL
, CFSTR("server port = %p"), storePrivate
->server
);
78 CFStringAppendFormat(result
, NULL
, CFSTR("server not (no longer) available"));
80 if (storePrivate
->disconnectFunction
!= NULL
) {
81 CFStringAppendFormat(result
, NULL
, CFSTR(", disconnect = %p"), storePrivate
->disconnectFunction
);
83 switch (storePrivate
->notifyStatus
) {
84 case Using_NotifierWait
:
85 CFStringAppendFormat(result
, NULL
, CFSTR(", waiting for a notification"));
87 case Using_NotifierInformViaMachPort
:
88 CFStringAppendFormat(result
, NULL
, CFSTR(", mach port notifications"));
90 case Using_NotifierInformViaFD
:
91 CFStringAppendFormat(result
, NULL
, CFSTR(", FD notifications"));
93 case Using_NotifierInformViaSignal
:
94 CFStringAppendFormat(result
, NULL
, CFSTR(", BSD signal notifications"));
96 case Using_NotifierInformViaRunLoop
:
97 case Using_NotifierInformViaDispatch
:
98 if (storePrivate
->notifyStatus
== Using_NotifierInformViaRunLoop
) {
99 CFStringAppendFormat(result
, NULL
, CFSTR(", runloop notifications"));
100 CFStringAppendFormat(result
, NULL
, CFSTR(" {callout = %p"), storePrivate
->rlsFunction
);
101 CFStringAppendFormat(result
, NULL
, CFSTR(", info = %p"), storePrivate
->rlsContext
.info
);
102 CFStringAppendFormat(result
, NULL
, CFSTR(", rls = %p"), storePrivate
->rls
);
103 } else if (storePrivate
->notifyStatus
== Using_NotifierInformViaDispatch
) {
104 CFStringAppendFormat(result
, NULL
, CFSTR(", dispatch notifications"));
105 CFStringAppendFormat(result
, NULL
, CFSTR(" {callout = %p"), storePrivate
->rlsFunction
);
106 CFStringAppendFormat(result
, NULL
, CFSTR(", info = %p"), storePrivate
->rlsContext
.info
);
107 CFStringAppendFormat(result
, NULL
, CFSTR(", queue = %p"), storePrivate
->dispatchQueue
);
108 CFStringAppendFormat(result
, NULL
, CFSTR(", source = %p"), storePrivate
->dispatchSource
);
110 if (storePrivate
->rlsNotifyRLS
!= NULL
) {
111 CFStringAppendFormat(result
, NULL
, CFSTR(", notify rls = %@" ), storePrivate
->rlsNotifyRLS
);
113 CFStringAppendFormat(result
, NULL
, CFSTR("}"));
116 CFStringAppendFormat(result
, NULL
, CFSTR(", notification delivery not requested%s"),
117 storePrivate
->rlsFunction
? " (yet)" : "");
120 CFStringAppendFormat(result
, NULL
, CFSTR("}"));
127 __SCDynamicStoreDeallocate(CFTypeRef cf
)
130 SCDynamicStoreRef store
= (SCDynamicStoreRef
)cf
;
131 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
133 (void) pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED
, &oldThreadState
);
135 /* Remove/cancel any outstanding notification requests. */
136 (void) SCDynamicStoreNotifyCancel(store
);
138 if (storePrivate
->server
!= MACH_PORT_NULL
) {
139 if (!storePrivate
->serverNullSession
) {
141 * Remove our send right to the SCDynamicStore server (and that will
142 * result in our session being closed).
144 __MACH_PORT_DEBUG(TRUE
, "*** __SCDynamicStoreDeallocate", storePrivate
->server
);
145 (void) mach_port_deallocate(mach_task_self(), storePrivate
->server
);
148 storePrivate
->server
= MACH_PORT_NULL
;
151 (void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS
, &oldThreadState
);
152 pthread_testcancel();
154 /* release any callback context info */
155 if (storePrivate
->rlsContext
.release
!= NULL
) {
156 (*storePrivate
->rlsContext
.release
)(storePrivate
->rlsContext
.info
);
159 /* release any keys being watched */
160 if (storePrivate
->keys
!= NULL
) CFRelease(storePrivate
->keys
);
161 if (storePrivate
->patterns
!= NULL
) CFRelease(storePrivate
->patterns
);
163 /* release any client info */
164 if (storePrivate
->name
!= NULL
) CFRelease(storePrivate
->name
);
165 if (storePrivate
->options
!= NULL
) CFRelease(storePrivate
->options
);
171 static CFTypeID __kSCDynamicStoreTypeID
= _kCFRuntimeNotATypeID
;
174 static const CFRuntimeClass __SCDynamicStoreClass
= {
176 "SCDynamicStore", // className
179 __SCDynamicStoreDeallocate
, // dealloc
182 NULL
, // copyFormattingDesc
183 __SCDynamicStoreCopyDescription
// copyDebugDesc
190 /* the process has forked (and we are the child process) */
192 _sc_server
= MACH_PORT_NULL
;
197 static pthread_once_t initialized
= PTHREAD_ONCE_INIT
;
200 __SCDynamicStoreInitialize(void)
204 /* register with CoreFoundation */
205 __kSCDynamicStoreTypeID
= _CFRuntimeRegisterClass(&__SCDynamicStoreClass
);
207 /* add handler to cleanup after fork() */
208 (void) pthread_atfork(NULL
, NULL
, childForkHandler
);
210 /* get the application/executable/bundle name */
211 bundle
= CFBundleGetMainBundle();
212 if (bundle
!= NULL
) {
213 _sc_bundleID
= CFBundleGetIdentifier(bundle
);
214 if (_sc_bundleID
!= NULL
) {
215 CFRetain(_sc_bundleID
);
219 url
= CFBundleCopyExecutableURL(bundle
);
221 _sc_bundleID
= CFURLCopyPath(url
);
226 if (_sc_bundleID
!= NULL
) {
227 if (CFEqual(_sc_bundleID
, CFSTR("/"))) {
228 CFRelease(_sc_bundleID
);
229 _sc_bundleID
= CFStringCreateWithFormat(NULL
, NULL
, CFSTR("(%d)"), getpid());
239 __SCDynamicStoreServerPort(kern_return_t
*status
)
241 mach_port_t server
= MACH_PORT_NULL
;
244 server_name
= getenv("SCD_SERVER");
246 server_name
= SCD_SERVER
;
249 #ifdef BOOTSTRAP_PRIVILEGED_SERVER
250 *status
= bootstrap_look_up2(bootstrap_port
,
254 BOOTSTRAP_PRIVILEGED_SERVER
);
255 #else // BOOTSTRAP_PRIVILEGED_SERVER
256 *status
= bootstrap_look_up(bootstrap_port
, server_name
, &server
);
257 #endif // BOOTSTRAP_PRIVILEGED_SERVER
260 case BOOTSTRAP_SUCCESS
:
261 /* service currently registered, "a good thing" (tm) */
263 case BOOTSTRAP_NOT_PRIVILEGED
:
264 /* the service is not privileged */
266 case BOOTSTRAP_UNKNOWN_SERVICE
:
267 /* service not currently registered, try again later */
271 SCLog(_sc_verbose
, LOG_DEBUG
,
272 CFSTR("SCDynamicStoreCreate[WithOptions] bootstrap_look_up() failed: status=%s"),
273 bootstrap_strerror(*status
));
278 return MACH_PORT_NULL
;
282 SCDynamicStorePrivateRef
283 __SCDynamicStoreCreatePrivate(CFAllocatorRef allocator
,
284 const CFStringRef name
,
285 SCDynamicStoreCallBack callout
,
286 SCDynamicStoreContext
*context
)
289 SCDynamicStorePrivateRef storePrivate
;
291 /* initialize runtime */
292 pthread_once(&initialized
, __SCDynamicStoreInitialize
);
295 /* allocate session */
296 size
= sizeof(SCDynamicStorePrivate
) - sizeof(CFRuntimeBase
);
297 storePrivate
= (SCDynamicStorePrivateRef
)_CFRuntimeCreateInstance(allocator
,
298 __kSCDynamicStoreTypeID
,
301 if (storePrivate
== NULL
) {
302 _SCErrorSet(kSCStatusFailed
);
306 /* client side of the "configd" session */
307 storePrivate
->name
= (name
!= NULL
) ? CFRetain(name
) : NULL
;
308 storePrivate
->options
= NULL
;
310 /* server side of the "configd" session */
311 storePrivate
->server
= MACH_PORT_NULL
;
312 storePrivate
->serverNullSession
= FALSE
;
315 storePrivate
->useSessionKeys
= FALSE
;
317 /* Notification status */
318 storePrivate
->notifyStatus
= NotifierNotRegistered
;
320 /* "client" information associated with SCDynamicStoreCreateRunLoopSource() */
321 storePrivate
->rlList
= NULL
;
322 storePrivate
->rls
= NULL
;
323 storePrivate
->rlsFunction
= callout
;
324 storePrivate
->rlsContext
.info
= NULL
;
325 storePrivate
->rlsContext
.retain
= NULL
;
326 storePrivate
->rlsContext
.release
= NULL
;
327 storePrivate
->rlsContext
.copyDescription
= NULL
;
329 bcopy(context
, &storePrivate
->rlsContext
, sizeof(SCDynamicStoreContext
));
330 if (context
->retain
!= NULL
) {
331 storePrivate
->rlsContext
.info
= (void *)(*context
->retain
)(context
->info
);
334 storePrivate
->rlsNotifyPort
= NULL
;
335 storePrivate
->rlsNotifyRLS
= NULL
;
337 /* "client" information associated with SCDynamicStoreSetDispatchQueue() */
338 storePrivate
->dispatchGroup
= NULL
;
339 storePrivate
->dispatchQueue
= NULL
;
340 storePrivate
->dispatchSource
= NULL
;
342 /* "client" information associated with SCDynamicStoreSetDisconnectCallBack() */
343 storePrivate
->disconnectFunction
= NULL
;
344 storePrivate
->disconnectForceCallBack
= FALSE
;
346 /* "server" information associated with SCDynamicStoreSetNotificationKeys() */
347 storePrivate
->keys
= NULL
;
348 storePrivate
->patterns
= NULL
;
350 /* "server" information associated with SCDynamicStoreNotifyMachPort(); */
351 storePrivate
->notifyPort
= MACH_PORT_NULL
;
352 storePrivate
->notifyPortIdentifier
= 0;
354 /* "server" information associated with SCDynamicStoreNotifyFileDescriptor(); */
355 storePrivate
->notifyFile
= -1;
356 storePrivate
->notifyFileIdentifier
= 0;
358 /* "server" information associated with SCDynamicStoreNotifySignal(); */
359 storePrivate
->notifySignal
= 0;
360 storePrivate
->notifySignalTask
= TASK_NULL
;
367 __SCDynamicStoreAddSession(SCDynamicStorePrivateRef storePrivate
)
369 CFDataRef myName
; /* serialized name */
372 CFDataRef myOptions
= NULL
; /* serialized options */
373 xmlData_t myOptionsRef
= NULL
;
374 CFIndex myOptionsLen
= 0;
375 int sc_status
= kSCStatusFailed
;
377 kern_return_t status
= KERN_SUCCESS
;
379 if (!_SCSerializeString(storePrivate
->name
, &myName
, (void **)&myNameRef
, &myNameLen
)) {
383 /* serialize the options */
384 if (storePrivate
->options
!= NULL
) {
385 if (!_SCSerialize(storePrivate
->options
, &myOptions
, (void **)&myOptionsRef
, &myOptionsLen
)) {
391 /* open a new session with the server */
394 if (server
!= MACH_PORT_NULL
) {
395 if (!storePrivate
->serverNullSession
) {
396 // if SCDynamicStore session
397 status
= configopen(server
,
402 &storePrivate
->server
,
406 if (storePrivate
->server
== MACH_PORT_NULL
) {
407 // use the [main] SCDynamicStore server port
408 storePrivate
->server
= server
;
409 sc_status
= kSCStatusOK
;
410 status
= KERN_SUCCESS
;
412 // if the server port we used returned an error
413 storePrivate
->server
= MACH_PORT_NULL
;
414 status
= MACH_SEND_INVALID_DEST
;
418 if (status
== KERN_SUCCESS
) {
422 // our [cached] server port is not valid
423 if ((status
!= MACH_SEND_INVALID_DEST
) && (status
!= MIG_SERVER_DIED
)) {
424 // if we got an unexpected error, don't retry
430 pthread_mutex_lock(&_sc_lock
);
431 if (_sc_server
!= MACH_PORT_NULL
) {
432 if (server
== _sc_server
) {
433 // if the server we tried returned the error, deallocate
434 // our send [or dead name] right
435 (void)mach_port_deallocate(mach_task_self(), _sc_server
);
437 // and [re-]lookup the name to the server
438 _sc_server
= __SCDynamicStoreServerPort(&sc_status
);
440 // another thread has refreshed the SCDynamicStore server port
443 _sc_server
= __SCDynamicStoreServerPort(&sc_status
);
446 pthread_mutex_unlock(&_sc_lock
);
448 if (server
== MACH_PORT_NULL
) {
449 // if SCDynamicStore server not available
453 __MACH_PORT_DEBUG(TRUE
, "*** SCDynamicStoreAddSession", storePrivate
->server
);
457 if (myOptions
!= NULL
) CFRelease(myOptions
);
464 case BOOTSTRAP_UNKNOWN_SERVICE
:
466 (status
== KERN_SUCCESS
) ? LOG_DEBUG
: LOG_ERR
,
467 CFSTR("SCDynamicStore server not available"));
468 sc_status
= kSCStatusNoStoreServer
;
472 (status
== KERN_SUCCESS
) ? LOG_DEBUG
: LOG_ERR
,
473 CFSTR("SCDynamicStoreAddSession configopen(): %s"),
474 SCErrorString(sc_status
));
478 _SCErrorSet(sc_status
);
485 __SCDynamicStoreNullSession(void)
487 SCDynamicStorePrivateRef storePrivate
;
489 __SCThreadSpecificDataRef tsd
;
491 tsd
= __SCGetThreadSpecificData();
492 if (tsd
->_sc_store
== NULL
) {
493 #if !TARGET_IPHONE_SIMULATOR
494 storePrivate
= __SCDynamicStoreCreatePrivate(NULL
,
495 CFSTR("NULL session"),
498 storePrivate
->server
= _sc_server
;
499 storePrivate
->serverNullSession
= TRUE
;
502 * In the simulator, this code may be talking to an older version of
503 * configd that still requires a valid session. Instead of using a
504 * "NULL" session that uses the server mach port, set up a "normal"
505 * session in thread-local storage.
507 storePrivate
= __SCDynamicStoreCreatePrivate(NULL
,
508 CFSTR("Thread local session"),
512 * Use MACH_PORT_NULL here to trigger the call to
513 * __SCDynamicStoreAddSession below.
515 storePrivate
->server
= MACH_PORT_NULL
;
516 #endif /* TARGET_IPHONE_SIMULATOR */
517 tsd
->_sc_store
= (SCDynamicStoreRef
)storePrivate
;
520 storePrivate
= (SCDynamicStorePrivateRef
)tsd
->_sc_store
;
521 if (storePrivate
->server
== MACH_PORT_NULL
) {
522 ok
= __SCDynamicStoreAddSession(storePrivate
);
525 return ok
? tsd
->_sc_store
: NULL
;
530 __SCDynamicStoreReconnect(SCDynamicStoreRef store
)
533 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
535 ok
= __SCDynamicStoreAddSession(storePrivate
);
542 __SCDynamicStoreCheckRetryAndHandleError(SCDynamicStoreRef store
,
543 kern_return_t status
,
547 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
549 if (status
== KERN_SUCCESS
) {
554 if ((status
== MACH_SEND_INVALID_DEST
) || (status
== MIG_SERVER_DIED
)) {
555 /* the server's gone */
556 if (!storePrivate
->serverNullSession
) {
558 * remove the session's dead name right (and not the
559 * not the "server" port)
561 (void) mach_port_deallocate(mach_task_self(), storePrivate
->server
);
563 storePrivate
->server
= MACH_PORT_NULL
;
566 if (__SCDynamicStoreReconnect(store
)) {
571 /* an unexpected error, leave the [session] port alone */
572 SCLog(TRUE
, LOG_ERR
, CFSTR("%s: %s"), log_str
, mach_error_string(status
));
573 storePrivate
->server
= MACH_PORT_NULL
;
582 pushDisconnect(SCDynamicStoreRef store
)
585 void (*context_release
)(const void *);
586 SCDynamicStoreDisconnectCallBack disconnectFunction
;
587 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
589 disconnectFunction
= storePrivate
->disconnectFunction
;
590 if (disconnectFunction
== NULL
) {
591 // if no reconnect callout, push empty notification
592 storePrivate
->disconnectForceCallBack
= TRUE
;
596 if (storePrivate
->rlsContext
.retain
!= NULL
) {
597 context_info
= (void *)storePrivate
->rlsContext
.retain(storePrivate
->rlsContext
.info
);
598 context_release
= storePrivate
->rlsContext
.release
;
600 context_info
= storePrivate
->rlsContext
.info
;
601 context_release
= NULL
;
603 (*disconnectFunction
)(store
, context_info
);
604 if (context_release
) {
605 context_release(context_info
);
614 __SCDynamicStoreReconnectNotifications(SCDynamicStoreRef store
)
616 dispatch_queue_t dispatchQueue
= NULL
;
617 __SCDynamicStoreNotificationStatus notifyStatus
;
619 CFArrayRef rlList
= NULL
;
620 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
622 // save old SCDynamicStore [notification] state
623 notifyStatus
= storePrivate
->notifyStatus
;
625 // before tearing down our [old] notifications, make sure we've
626 // retained any information that will be lost when we cancel the
627 // current no-longer-valid handler
628 switch (notifyStatus
) {
629 case Using_NotifierInformViaRunLoop
:
630 if (storePrivate
->rlList
!= NULL
) {
631 rlList
= CFArrayCreateCopy(NULL
, storePrivate
->rlList
);
633 case Using_NotifierInformViaDispatch
:
634 dispatchQueue
= storePrivate
->dispatchQueue
;
635 if (dispatchQueue
!= NULL
) dispatch_retain(dispatchQueue
);
641 // cancel [old] notifications
642 if (!SCDynamicStoreNotifyCancel(store
)) {
643 // if we could not cancel / reconnect
644 SCLog(TRUE
, LOG_DEBUG
,
645 CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreNotifyCancel() failed: %s"),
646 SCErrorString(SCError()));
649 // set notification keys & patterns
650 if ((storePrivate
->keys
!= NULL
) || (storePrivate
->patterns
)) {
651 ok
= SCDynamicStoreSetNotificationKeys(store
,
653 storePrivate
->patterns
);
655 SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE
),
657 CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreSetNotificationKeys() failed"));
662 switch (notifyStatus
) {
663 case Using_NotifierInformViaRunLoop
: {
666 CFRunLoopSourceRef rls
;
668 rls
= SCDynamicStoreCreateRunLoopSource(NULL
, store
, 0);
670 SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE
),
672 CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreCreateRunLoopSource() failed"));
677 n
= (rlList
!= NULL
) ? CFArrayGetCount(rlList
) : 0;
678 for (i
= 0; i
< n
; i
+= 3) {
679 CFRunLoopRef rl
= (CFRunLoopRef
)CFArrayGetValueAtIndex(rlList
, i
+1);
680 CFStringRef rlMode
= (CFStringRef
) CFArrayGetValueAtIndex(rlList
, i
+2);
682 CFRunLoopAddSource(rl
, rls
, rlMode
);
688 case Using_NotifierInformViaDispatch
:
689 ok
= SCDynamicStoreSetDispatchQueue(store
, dispatchQueue
);
691 SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE
),
693 CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreSetDispatchQueue() failed"));
699 _SCErrorSet(kSCStatusFailed
);
707 switch (notifyStatus
) {
708 case Using_NotifierInformViaRunLoop
:
709 if (rlList
!= NULL
) CFRelease(rlList
);
711 case Using_NotifierInformViaDispatch
:
712 if (dispatchQueue
!= NULL
) dispatch_release(dispatchQueue
);
720 CFSTR("SCDynamicStore server %s, notification (%s) not restored"),
721 (SCError() == BOOTSTRAP_UNKNOWN_SERVICE
) ? "shutdown" : "failed",
722 notifyType
[notifyStatus
]);
726 pushDisconnect(store
);
732 const CFStringRef kSCDynamicStoreUseSessionKeys
= CFSTR("UseSessionKeys"); /* CFBoolean */
736 SCDynamicStoreCreateWithOptions(CFAllocatorRef allocator
,
738 CFDictionaryRef storeOptions
,
739 SCDynamicStoreCallBack callout
,
740 SCDynamicStoreContext
*context
)
743 SCDynamicStorePrivateRef storePrivate
;
745 // allocate and initialize a new session
746 storePrivate
= __SCDynamicStoreCreatePrivate(allocator
, NULL
, callout
, context
);
747 if (storePrivate
== NULL
) {
752 if (_sc_bundleID
!= NULL
) {
753 storePrivate
->name
= CFStringCreateWithFormat(NULL
, NULL
, CFSTR("%@:%@"), _sc_bundleID
, name
);
755 storePrivate
->name
= CFRetain(name
);
759 storePrivate
->options
= (storeOptions
!= NULL
) ? CFRetain(storeOptions
) : NULL
;
761 // establish SCDynamicStore session
762 ok
= __SCDynamicStoreAddSession(storePrivate
);
764 CFRelease(storePrivate
);
768 return (SCDynamicStoreRef
)storePrivate
;
773 SCDynamicStoreCreate(CFAllocatorRef allocator
,
775 SCDynamicStoreCallBack callout
,
776 SCDynamicStoreContext
*context
)
778 return SCDynamicStoreCreateWithOptions(allocator
, name
, NULL
, callout
, context
);
783 SCDynamicStoreGetTypeID(void) {
784 pthread_once(&initialized
, __SCDynamicStoreInitialize
); /* initialize runtime */
785 return __kSCDynamicStoreTypeID
;
789 SCDynamicStoreSetDisconnectCallBack(SCDynamicStoreRef store
,
790 SCDynamicStoreDisconnectCallBack callout
)
792 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
795 /* sorry, you must provide a session */
796 _SCErrorSet(kSCStatusNoStoreSession
);
800 storePrivate
->disconnectFunction
= callout
;