2 * Copyright (c) 2000 Apple Computer, 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@
24 #ifndef _SCDYNAMICSTORE_H
25 #define _SCDYNAMICSTORE_H
27 #include <sys/cdefs.h>
28 #include <sys/syslog.h>
29 #include <mach/message.h>
30 #include <CoreFoundation/CoreFoundation.h>
34 @header SCDynamicStore
35 The SystemConfiguration framework provides access to the
36 data used to configure a running system. The APIs provided
37 by this framework communicate with the "configd" daemon.
39 The "configd" daemon manages a "dynamic store" reflecting the
40 desired configuration settings as well as the current state
41 of the system. The daemon provides a notification mechanism
42 for user-level processes that need to be aware of changes
43 made to the data. Lastly, the daemon loads a number of
44 bundles (or plug-ins) that monitor low-level kernel events
45 and, via a set of policy modules, keep the state data up
51 @typedef SCDynamicStoreRef
52 @discussion This is the handle to an open "dynamic store" session
53 with the system configuration daemon.
55 typedef const struct __SCDynamicStore
* SCDynamicStoreRef
;
58 @typedef SCDynamicStoreContext
63 const void *(*retain
)(const void *info
);
64 void (*release
)(const void *info
);
65 CFStringRef (*copyDescription
)(const void *info
);
66 } SCDynamicStoreContext
;
69 @typedef SCDynamicStoreCallBack
70 @discussion Type of the callback function used when a
71 dynamic store change is delivered.
72 @param store The "dynamic store" session.
73 @param changedKeys The list of changed keys.
76 typedef void (*SCDynamicStoreCallBack
) (
77 SCDynamicStoreRef store
,
78 CFArrayRef changedKeys
,
86 @function SCDynamicStoreGetTypeID
87 Returns the type identifier of all SCDynamicStore instances.
90 SCDynamicStoreGetTypeID (void);
94 @function SCDynamicStoreCreate
95 @discussion Creates a new session used to interact with the dynamic
96 store maintained by the SystemConfiguration server.
97 @param allocator The CFAllocator which should be used to allocate
98 memory for the local "dynamic store" and its storage for
100 This parameter may be NULL in which case the current
101 default CFAllocator is used. If this reference is not
102 a valid CFAllocator, the behavior is undefined.
103 @param name A string that describes the name of the calling
104 process or plug-in of the caller.
105 @param callout The function to be called when a watched value
106 in the "dynamic store" is changed.
107 A NULL value can be specified if no callouts are
109 @param context The SCDynamicStoreContext associated with the callout.
110 @result A reference to the new SCDynamicStore.
113 SCDynamicStoreCreate (
114 CFAllocatorRef allocator
,
116 SCDynamicStoreCallBack callout
,
117 SCDynamicStoreContext
*context
121 @function SCDynamicStoreCreateRunLoopSource
122 @discussion Creates a new session used to interact with the dynamic
123 store maintained by the SystemConfiguration server.
124 @param allocator The CFAllocator which should be used to allocate
125 memory for the local "dynamic store" and its storage for
127 This parameter may be NULL in which case the current
128 default CFAllocator is used. If this reference is not
129 a valid CFAllocator, the behavior is undefined.
130 @param store The "dynamic store" session.
131 @param order On platforms which support it, this parameter
132 determines the order in which the sources which are
133 ready to be processed are handled. A lower order
134 number causes processing before higher order number
135 sources. It is inadvisable to depend on the order
136 number for any architectural or design aspect of
137 code. In the absence of any reason to do otherwise,
139 @result A reference to the new CFRunLoopSource.
140 You must release the returned value.
144 SCDynamicStoreCreateRunLoopSource (
145 CFAllocatorRef allocator
,
146 SCDynamicStoreRef store
,
151 @function SCDynamicStoreCopyKeyList
152 @discussion Returns an array of CFString keys representing the
153 configuration "dynamic store" entries that match a
155 @param store The "dynamic store" session.
156 @param pattern A regex(3) regular expression pattern that
157 will be used to match the "dynamic store" keys.
158 @result The list of matching keys.
159 You must release the returned value.
160 A NULL value will be returned if the list could not be obtained.
163 SCDynamicStoreCopyKeyList (
164 SCDynamicStoreRef store
,
169 @function SCDynamicStoreAddValue
170 @discussion Adds the key-value pair to the "dynamic store" if no
171 such key already exists.
172 @param store The "dynamic store" session.
173 @param key The key of the value to add to the "dynamic store".
174 @param value The value to add to the "dynamic store".
175 @result TRUE if the key was added; FALSE if the key was already
176 present in the "dynamic store" or if an error was encountered.
179 SCDynamicStoreAddValue (
180 SCDynamicStoreRef store
,
182 CFPropertyListRef value
186 @function SCDynamicStoreAddTemporaryValue
187 @discussion Adds the key-value pair on a temporary basis to the
188 "dynamic store" if no such key already exists. This entry
189 will, unless updated by another session, automatically be
190 removed when the session is closed.
191 @param store The "dynamic store" session.
192 @param key The key of the value to add to the "dynamic store".
193 @param value The value to add to the "dynamic store".
194 @result TRUE if the key was added; FALSE if the key was already
195 present in the "dynamic store" or if an error was encountered.
198 SCDynamicStoreAddTemporaryValue (
199 SCDynamicStoreRef store
,
201 CFPropertyListRef value
205 @function SCDynamicStoreCopyValue
206 @discussion Obtains a value from the "dynamic store" for the
208 @param store The "dynamic store" session.
209 @param key The key you wish to obtain.
210 @result The value from the store that is associated with the
211 given key. The value is returned as a Core Foundation
212 Property List data type.
213 You must release the returned value.
214 If no value was located, NULL is returned.
217 SCDynamicStoreCopyValue (
218 SCDynamicStoreRef store
,
223 @function SCDynamicStoreCopyMultiple
224 @discussion Fetches multiple values in the "dynamic store".
225 @param store The "dynamic store" session.
226 @param keys The keys to be fetched; NULL if no specific keys
228 @param patterns The regex(3) pattern strings to be fetched; NULL
229 if no key patterns are requested.
230 @result A dictionary containing the specific keys which were found
231 in the "dynamic store" and any keys which matched the specified
232 patterns; NULL is returned if an error was encountered.
233 You must release the returned value.
236 SCDynamicStoreCopyMultiple (
237 SCDynamicStoreRef store
,
243 @function SCDynamicStoreSetValue
244 @discussion Adds or replaces a value in the "dynamic store" for
246 @param store The "dynamic store" session.
247 @param key The key you wish to set.
248 @param value The value to add to or replace in the "dynamic store".
249 @result TRUE if the key was updated; FALSE if an error was encountered.
252 SCDynamicStoreSetValue (
253 SCDynamicStoreRef store
,
255 CFPropertyListRef value
259 @function SCDynamicStoreSetMultiple
260 @discussion Updates multiple values in the "dynamic store".
261 @param store The "dynamic store" session.
262 @param keysToSet Key/value pairs you wish to set into the "dynamic store".
263 @param keysToRemove A list of keys you wish to remove from the "dynamic store".
264 @param keysToNotify A list of keys to flag as changed (without actually changing the data).
265 @result TRUE if the dynamic store updates were successful; FALSE if an error was encountered.
268 SCDynamicStoreSetMultiple (
269 SCDynamicStoreRef store
,
270 CFDictionaryRef keysToSet
,
271 CFArrayRef keysToRemove
,
272 CFArrayRef keysToNotify
276 @function SCDynamicStoreRemoveValue
277 @discussion Removes the value of the specified key from the
279 @param store The "dynamic store" session.
280 @param key The key of the value you wish to remove.
281 @result TRUE if the key was removed; FALSE if no value was
282 located or an error was encountered.
285 SCDynamicStoreRemoveValue (
286 SCDynamicStoreRef store
,
291 @function SCDynamicStoreNotifyValue
292 @discussion Triggers a notification to be delivered for the
293 specified key in the dynamic store.
294 @param store The "dynamic store" session.
295 @param key The key which should be flagged as changed (without actually changing the data).
296 @result TRUE if the value was updated; FALSE if an error was encountered.
299 SCDynamicStoreNotifyValue (
300 SCDynamicStoreRef store
,
305 @function SCDynamicStoreSetNotificationKeys
306 @discussion Specifies a set of specific keys and key patterns
307 which should be monitored for changes.
308 @param store The "dynamic store" session being watched.
309 @param keys The keys to be monitored; NULL if no specific keys
311 @param patterns The regex(3) pattern strings to be monitored; NULL
312 if no key patterns are to be monitored.
313 @result TRUE if the monitored keys were set; FALSE if an error
317 SCDynamicStoreSetNotificationKeys (
318 SCDynamicStoreRef store
,
324 @function SCDynamicStoreCopyNotifiedKeys
325 @discussion Returns an array of CFString keys representing the
326 "dynamic store" entries that have changed since this
327 function was last called.
328 @param store The "dynamic store" session.
329 @result The list of changed keys.
330 You must release the returned value.
331 A NULL value will be returned if the list could not be obtained.
334 SCDynamicStoreCopyNotifiedKeys (
335 SCDynamicStoreRef store
340 #endif /* _SCDYNAMICSTORE_H */