2 * Copyright (c) 2000-2006, 2008-2015 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 = 0x%x"), 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
) {
140 * Remove our send right to the SCDynamicStore server.
142 * In the case of a "real" session this will result in our
143 * session being closed.
145 * In the case of a "NULL" session, we just remove the
146 * the send right reference we are holding.
148 __MACH_PORT_DEBUG(TRUE
, "*** __SCDynamicStoreDeallocate", storePrivate
->server
);
149 (void) mach_port_deallocate(mach_task_self(), storePrivate
->server
);
150 storePrivate
->server
= MACH_PORT_NULL
;
153 (void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS
, &oldThreadState
);
154 pthread_testcancel();
156 /* release any callback context info */
157 if (storePrivate
->rlsContext
.release
!= NULL
) {
158 (*storePrivate
->rlsContext
.release
)(storePrivate
->rlsContext
.info
);
161 /* release any keys being watched */
162 if (storePrivate
->keys
!= NULL
) CFRelease(storePrivate
->keys
);
163 if (storePrivate
->patterns
!= NULL
) CFRelease(storePrivate
->patterns
);
165 /* release any client info */
166 if (storePrivate
->name
!= NULL
) CFRelease(storePrivate
->name
);
167 if (storePrivate
->options
!= NULL
) CFRelease(storePrivate
->options
);
173 static CFTypeID __kSCDynamicStoreTypeID
= _kCFRuntimeNotATypeID
;
176 static const CFRuntimeClass __SCDynamicStoreClass
= {
178 "SCDynamicStore", // className
181 __SCDynamicStoreDeallocate
, // dealloc
184 NULL
, // copyFormattingDesc
185 __SCDynamicStoreCopyDescription
// copyDebugDesc
192 /* the process has forked (and we are the child process) */
194 _sc_server
= MACH_PORT_NULL
;
199 static pthread_once_t initialized
= PTHREAD_ONCE_INIT
;
202 __SCDynamicStoreInitialize(void)
206 /* register with CoreFoundation */
207 __kSCDynamicStoreTypeID
= _CFRuntimeRegisterClass(&__SCDynamicStoreClass
);
209 /* add handler to cleanup after fork() */
210 (void) pthread_atfork(NULL
, NULL
, childForkHandler
);
212 /* get the application/executable/bundle name */
213 bundle
= CFBundleGetMainBundle();
214 if (bundle
!= NULL
) {
215 _sc_bundleID
= CFBundleGetIdentifier(bundle
);
216 if (_sc_bundleID
!= NULL
) {
217 CFRetain(_sc_bundleID
);
221 url
= CFBundleCopyExecutableURL(bundle
);
223 _sc_bundleID
= CFURLCopyPath(url
);
228 if (_sc_bundleID
!= NULL
) {
229 if (CFEqual(_sc_bundleID
, CFSTR("/"))) {
230 CFRelease(_sc_bundleID
);
231 _sc_bundleID
= CFStringCreateWithFormat(NULL
, NULL
, CFSTR("(%d)"), getpid());
241 __SCDynamicStoreServerPort(SCDynamicStorePrivateRef storePrivate
, kern_return_t
*status
)
243 mach_port_t server
= MACH_PORT_NULL
;
246 server_name
= getenv("SCD_SERVER");
249 if (server_name
== NULL
) {
250 server_name
= SCD_SERVER
;
253 #if defined(BOOTSTRAP_PRIVILEGED_SERVER) && !TARGET_IPHONE_SIMULATOR
254 *status
= bootstrap_look_up2(bootstrap_port
,
258 BOOTSTRAP_PRIVILEGED_SERVER
);
259 #else // defined(BOOTSTRAP_PRIVILEGED_SERVER) && !TARGET_IPHONE_SIMULATOR
260 *status
= bootstrap_look_up(bootstrap_port
, server_name
, &server
);
261 #endif // defined(BOOTSTRAP_PRIVILEGED_SERVER) && !TARGET_IPHONE_SIMULATOR
264 case BOOTSTRAP_SUCCESS
:
265 /* service currently registered, "a good thing" (tm) */
267 case BOOTSTRAP_NOT_PRIVILEGED
:
268 /* the service is not privileged */
270 case BOOTSTRAP_UNKNOWN_SERVICE
:
271 /* service not currently registered, try again later */
275 SC_log(LOG_INFO
, "bootstrap_look_up() failed: status=%s",
276 bootstrap_strerror(*status
));
281 return MACH_PORT_NULL
;
285 SCDynamicStorePrivateRef
286 __SCDynamicStoreCreatePrivate(CFAllocatorRef allocator
,
287 const CFStringRef name
,
288 SCDynamicStoreCallBack callout
,
289 SCDynamicStoreContext
*context
)
292 SCDynamicStorePrivateRef storePrivate
;
294 /* initialize runtime */
295 pthread_once(&initialized
, __SCDynamicStoreInitialize
);
298 /* allocate session */
299 size
= sizeof(SCDynamicStorePrivate
) - sizeof(CFRuntimeBase
);
300 storePrivate
= (SCDynamicStorePrivateRef
)_CFRuntimeCreateInstance(allocator
,
301 __kSCDynamicStoreTypeID
,
304 if (storePrivate
== NULL
) {
305 _SCErrorSet(kSCStatusFailed
);
309 /* client side of the "configd" session */
310 storePrivate
->name
= (name
!= NULL
) ? CFRetain(name
) : NULL
;
311 storePrivate
->options
= NULL
;
313 /* server side of the "configd" session */
314 storePrivate
->server
= MACH_PORT_NULL
;
315 storePrivate
->serverNullSession
= FALSE
;
318 storePrivate
->useSessionKeys
= FALSE
;
320 /* Notification status */
321 storePrivate
->notifyStatus
= NotifierNotRegistered
;
323 /* "client" information associated with SCDynamicStoreCreateRunLoopSource() */
324 storePrivate
->rlList
= NULL
;
325 storePrivate
->rls
= NULL
;
326 storePrivate
->rlsFunction
= callout
;
327 storePrivate
->rlsContext
.info
= NULL
;
328 storePrivate
->rlsContext
.retain
= NULL
;
329 storePrivate
->rlsContext
.release
= NULL
;
330 storePrivate
->rlsContext
.copyDescription
= NULL
;
332 bcopy(context
, &storePrivate
->rlsContext
, sizeof(SCDynamicStoreContext
));
333 if (context
->retain
!= NULL
) {
334 storePrivate
->rlsContext
.info
= (void *)(*context
->retain
)(context
->info
);
337 storePrivate
->rlsNotifyPort
= NULL
;
338 storePrivate
->rlsNotifyRLS
= NULL
;
340 /* "client" information associated with SCDynamicStoreSetDispatchQueue() */
341 storePrivate
->dispatchGroup
= NULL
;
342 storePrivate
->dispatchQueue
= NULL
;
343 storePrivate
->dispatchSource
= NULL
;
345 /* "client" information associated with SCDynamicStoreSetDisconnectCallBack() */
346 storePrivate
->disconnectFunction
= NULL
;
347 storePrivate
->disconnectForceCallBack
= FALSE
;
349 /* "server" information associated with SCDynamicStoreSetNotificationKeys() */
350 storePrivate
->keys
= NULL
;
351 storePrivate
->patterns
= NULL
;
353 /* "server" information associated with SCDynamicStoreNotifyMachPort(); */
354 storePrivate
->notifyPort
= MACH_PORT_NULL
;
355 storePrivate
->notifyPortIdentifier
= 0;
357 /* "server" information associated with SCDynamicStoreNotifyFileDescriptor(); */
358 storePrivate
->notifyFile
= -1;
359 storePrivate
->notifyFileIdentifier
= 0;
361 /* "server" information associated with SCDynamicStoreNotifySignal(); */
362 storePrivate
->notifySignal
= 0;
363 storePrivate
->notifySignalTask
= TASK_NULL
;
370 updateServerPort(SCDynamicStorePrivateRef storePrivate
, mach_port_t
*server
, int *sc_status_p
)
372 pthread_mutex_lock(&_sc_lock
);
373 if (_sc_server
!= MACH_PORT_NULL
) {
374 if (*server
== _sc_server
) {
375 mach_port_t old_port
;
377 // if the server we tried returned the error, save the old port,
378 // [re-]lookup the name to the server, and deallocate the original
379 // send [or dead name] right
381 old_port
= _sc_server
;
382 _sc_server
= __SCDynamicStoreServerPort(storePrivate
, sc_status_p
);
383 (void)mach_port_deallocate(mach_task_self(), old_port
);
385 // another thread has refreshed the [main] SCDynamicStore server port
388 _sc_server
= __SCDynamicStoreServerPort(storePrivate
, sc_status_p
);
390 *server
= _sc_server
;
391 pthread_mutex_unlock(&_sc_lock
);
398 __SCDynamicStoreAddSession(SCDynamicStorePrivateRef storePrivate
)
400 kern_return_t kr
= KERN_SUCCESS
;
401 CFDataRef myName
; /* serialized name */
404 CFDataRef myOptions
= NULL
; /* serialized options */
405 xmlData_t myOptionsRef
= NULL
;
406 CFIndex myOptionsLen
= 0;
407 int sc_status
= kSCStatusFailed
;
410 if (!_SCSerializeString(storePrivate
->name
, &myName
, (void **)&myNameRef
, &myNameLen
)) {
414 /* serialize the options */
415 if (storePrivate
->options
!= NULL
) {
416 if (!_SCSerialize(storePrivate
->options
, &myOptions
, (void **)&myOptionsRef
, &myOptionsLen
)) {
422 /* open a new session with the server */
423 server
= MACH_PORT_NULL
;
426 updateServerPort(storePrivate
, &server
, &sc_status
);
429 while (server
!= MACH_PORT_NULL
) {
430 // if SCDynamicStore server available
432 if (!storePrivate
->serverNullSession
) {
433 // if SCDynamicStore session
434 kr
= configopen(server
,
436 (mach_msg_type_number_t
)myNameLen
,
438 (mach_msg_type_number_t
)myOptionsLen
,
439 &storePrivate
->server
,
443 if (storePrivate
->server
== MACH_PORT_NULL
) {
444 // use the [main] SCDynamicStore server port
445 kr
= mach_port_mod_refs(mach_task_self(), server
, MACH_PORT_RIGHT_SEND
, +1);
446 if (kr
== KERN_SUCCESS
) {
447 storePrivate
->server
= server
;
448 sc_status
= kSCStatusOK
;
450 storePrivate
->server
= MACH_PORT_NULL
;
453 // if the server port we used returned an error
454 storePrivate
->server
= MACH_PORT_NULL
;
455 kr
= MACH_SEND_INVALID_DEST
;
459 if (kr
== KERN_SUCCESS
) {
463 // our [cached] server port is not valid
464 if ((kr
!= MACH_SEND_INVALID_DEST
) && (kr
!= MIG_SERVER_DIED
)) {
465 // if we got an unexpected error, don't retry
471 updateServerPort(storePrivate
, &server
, &sc_status
);
473 __MACH_PORT_DEBUG(TRUE
, "*** SCDynamicStoreAddSession", storePrivate
->server
);
477 if (myOptions
!= NULL
) CFRelease(myOptions
);
484 case BOOTSTRAP_UNKNOWN_SERVICE
:
485 SC_log((kr
== KERN_SUCCESS
) ? LOG_INFO
: LOG_ERR
, "SCDynamicStore server not available");
486 sc_status
= kSCStatusNoStoreServer
;
489 SC_log((kr
== KERN_SUCCESS
) ? LOG_INFO
: LOG_ERR
, "configopen() failed: %s",
490 SCErrorString(sc_status
));
494 _SCErrorSet(sc_status
);
501 __SCDynamicStoreNullSession(void)
503 SCDynamicStorePrivateRef storePrivate
;
505 __SCThreadSpecificDataRef tsd
;
507 tsd
= __SCGetThreadSpecificData();
508 if (tsd
->_sc_store
== NULL
) {
509 storePrivate
= __SCDynamicStoreCreatePrivate(NULL
,
510 CFSTR("NULL session"),
513 assert(storePrivate
!= NULL
);
514 storePrivate
->serverNullSession
= TRUE
;
515 tsd
->_sc_store
= (SCDynamicStoreRef
)storePrivate
;
518 storePrivate
= (SCDynamicStorePrivateRef
)tsd
->_sc_store
;
519 if (storePrivate
->server
== MACH_PORT_NULL
) {
520 ok
= __SCDynamicStoreAddSession(storePrivate
);
523 return ok
? tsd
->_sc_store
: NULL
;
528 __SCDynamicStoreReconnect(SCDynamicStoreRef store
)
531 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
533 ok
= __SCDynamicStoreAddSession(storePrivate
);
540 __SCDynamicStoreCheckRetryAndHandleError(SCDynamicStoreRef store
,
541 kern_return_t status
,
545 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
547 if (status
== KERN_SUCCESS
) {
552 if ((status
== MACH_SEND_INVALID_DEST
) || (status
== MIG_SERVER_DIED
)) {
553 /* the server's gone, remove the session's dead name right */
554 (void) mach_port_deallocate(mach_task_self(), storePrivate
->server
);
555 storePrivate
->server
= MACH_PORT_NULL
;
558 if (__SCDynamicStoreReconnect(store
)) {
563 /* an unexpected error, leave the [session] port alone */
564 SC_log(LOG_NOTICE
, "%s: %s", log_str
, mach_error_string(status
));
565 storePrivate
->server
= MACH_PORT_NULL
;
574 pushDisconnect(SCDynamicStoreRef store
)
577 void (*context_release
)(const void *);
578 SCDynamicStoreDisconnectCallBack disconnectFunction
;
579 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
581 disconnectFunction
= storePrivate
->disconnectFunction
;
582 if (disconnectFunction
== NULL
) {
583 // if no reconnect callout, push empty notification
584 storePrivate
->disconnectForceCallBack
= TRUE
;
588 if (storePrivate
->rlsContext
.retain
!= NULL
) {
589 context_info
= (void *)storePrivate
->rlsContext
.retain(storePrivate
->rlsContext
.info
);
590 context_release
= storePrivate
->rlsContext
.release
;
592 context_info
= storePrivate
->rlsContext
.info
;
593 context_release
= NULL
;
595 (*disconnectFunction
)(store
, context_info
);
596 if (context_release
) {
597 context_release(context_info
);
606 __SCDynamicStoreReconnectNotifications(SCDynamicStoreRef store
)
608 dispatch_queue_t dispatchQueue
= NULL
;
609 __SCDynamicStoreNotificationStatus notifyStatus
;
611 CFArrayRef rlList
= NULL
;
612 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
614 // save old SCDynamicStore [notification] state
615 notifyStatus
= storePrivate
->notifyStatus
;
617 // before tearing down our [old] notifications, make sure we've
618 // retained any information that will be lost when we cancel the
619 // current no-longer-valid handler
620 switch (notifyStatus
) {
621 case Using_NotifierInformViaRunLoop
:
622 if (storePrivate
->rlList
!= NULL
) {
623 rlList
= CFArrayCreateCopy(NULL
, storePrivate
->rlList
);
625 case Using_NotifierInformViaDispatch
:
626 dispatchQueue
= storePrivate
->dispatchQueue
;
627 if (dispatchQueue
!= NULL
) dispatch_retain(dispatchQueue
);
633 // cancel [old] notifications
634 if (!SCDynamicStoreNotifyCancel(store
)) {
635 // if we could not cancel / reconnect
636 SC_log(LOG_NOTICE
, "SCDynamicStoreNotifyCancel() failed: %s", SCErrorString(SCError()));
639 // set notification keys & patterns
640 if ((storePrivate
->keys
!= NULL
) || (storePrivate
->patterns
)) {
641 ok
= SCDynamicStoreSetNotificationKeys(store
,
643 storePrivate
->patterns
);
645 if (SCError() != BOOTSTRAP_UNKNOWN_SERVICE
) {
646 SC_log(LOG_NOTICE
, "SCDynamicStoreSetNotificationKeys() failed");
652 switch (notifyStatus
) {
653 case Using_NotifierInformViaRunLoop
: {
656 CFRunLoopSourceRef rls
;
658 rls
= SCDynamicStoreCreateRunLoopSource(NULL
, store
, 0);
660 if (SCError() != BOOTSTRAP_UNKNOWN_SERVICE
) {
661 SC_log(LOG_NOTICE
, "SCDynamicStoreCreateRunLoopSource() failed");
667 n
= (rlList
!= NULL
) ? CFArrayGetCount(rlList
) : 0;
668 for (i
= 0; i
< n
; i
+= 3) {
669 CFRunLoopRef rl
= (CFRunLoopRef
)CFArrayGetValueAtIndex(rlList
, i
+1);
670 CFStringRef rlMode
= (CFStringRef
) CFArrayGetValueAtIndex(rlList
, i
+2);
672 CFRunLoopAddSource(rl
, rls
, rlMode
);
678 case Using_NotifierInformViaDispatch
:
679 ok
= SCDynamicStoreSetDispatchQueue(store
, dispatchQueue
);
681 if (SCError() != BOOTSTRAP_UNKNOWN_SERVICE
) {
682 SC_log(LOG_NOTICE
, "SCDynamicStoreSetDispatchQueue() failed");
689 _SCErrorSet(kSCStatusFailed
);
697 switch (notifyStatus
) {
698 case Using_NotifierInformViaRunLoop
:
699 if (rlList
!= NULL
) CFRelease(rlList
);
701 case Using_NotifierInformViaDispatch
:
702 if (dispatchQueue
!= NULL
) dispatch_release(dispatchQueue
);
709 SC_log(LOG_NOTICE
, "SCDynamicStore server %s, notification (%s) not restored",
710 (SCError() == BOOTSTRAP_UNKNOWN_SERVICE
) ? "shutdown" : "failed",
711 notifyType
[notifyStatus
]);
715 pushDisconnect(store
);
721 const CFStringRef kSCDynamicStoreUseSessionKeys
= CFSTR("UseSessionKeys"); /* CFBoolean */
726 SCDynamicStoreCreateWithOptions(CFAllocatorRef allocator
,
728 CFDictionaryRef storeOptions
,
729 SCDynamicStoreCallBack callout
,
730 SCDynamicStoreContext
*context
)
733 SCDynamicStorePrivateRef storePrivate
;
735 // allocate and initialize a new session
736 storePrivate
= __SCDynamicStoreCreatePrivate(allocator
, NULL
, callout
, context
);
737 if (storePrivate
== NULL
) {
742 if (_sc_bundleID
!= NULL
) {
743 storePrivate
->name
= CFStringCreateWithFormat(NULL
, NULL
, CFSTR("%@:%@"), _sc_bundleID
, name
);
745 storePrivate
->name
= CFRetain(name
);
750 if (storeOptions
!= NULL
) {
751 storePrivate
->options
= CFRetain(storeOptions
);
754 // establish SCDynamicStore session
755 ok
= __SCDynamicStoreAddSession(storePrivate
);
757 CFRelease(storePrivate
);
761 return (SCDynamicStoreRef
)storePrivate
;
766 SCDynamicStoreCreate(CFAllocatorRef allocator
,
768 SCDynamicStoreCallBack callout
,
769 SCDynamicStoreContext
*context
)
771 return SCDynamicStoreCreateWithOptions(allocator
, name
, NULL
, callout
, context
);
776 SCDynamicStoreGetTypeID(void) {
777 pthread_once(&initialized
, __SCDynamicStoreInitialize
); /* initialize runtime */
778 return __kSCDynamicStoreTypeID
;
782 SCDynamicStoreSetDisconnectCallBack(SCDynamicStoreRef store
,
783 SCDynamicStoreDisconnectCallBack callout
)
785 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
788 /* sorry, you must provide a session */
789 _SCErrorSet(kSCStatusNoStoreSession
);
793 storePrivate
->disconnectFunction
= callout
;