2 * Copyright (c) 2000-2003 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 _SCDYNAMICSTOREPRIVATE_H
25 #define _SCDYNAMICSTOREPRIVATE_H
27 #include <sys/cdefs.h>
28 #include <sys/types.h>
30 #include <CoreFoundation/CoreFoundation.h>
31 #include <SystemConfiguration/SCDynamicStore.h>
34 @typedef SCDynamicStoreCallBack
35 @discussion Type of the callback function used when a
36 dynamic store change is delivered.
37 @param store The "dynamic store" session.
38 @param changedKeys The list of changed keys.
41 typedef boolean_t (*SCDynamicStoreCallBack_v1
) (
42 SCDynamicStoreRef store
,
50 @function SCDynamicStoreLock
51 @discussion Locks access to the configuration "dynamic store". All
52 other clients attempting to access the "dynamic store" will
53 block. All change notifications will be deferred until the
55 @param store The "dynamic store" session that should be locked.
56 @result TRUE if the lock was obtained; FALSE if an error was encountered.
59 SCDynamicStoreLock (SCDynamicStoreRef store
);
62 @function SCDynamicStoreUnlock
63 @discussion Unlocks access to the configuration "dynamic store". Other
64 clients will be able to access the "dynamic store". Any change
65 notifications will be delivered.
66 @param store The "dynamic store" session that should be unlocked.
67 @result TRUE if the lock was released; FALSE if an error was encountered.
70 SCDynamicStoreUnlock (SCDynamicStoreRef store
);
73 @function SCDynamicStoreTouchValue
74 @discussion Updates the value of the specified key in the
76 If the value does not exist then a CFDate object
77 will be associated with the key.
78 If the associated data is already a CFDate object
79 then it will be updated with the current time.
80 @param store The "dynamic store" session.
81 @param key The key of the value to updated.
82 @result TRUE if the value was updated; FALSE if an error was encountered.
85 SCDynamicStoreTouchValue (SCDynamicStoreRef store
,
89 @function SCDynamicStoreAddWatchedKey
90 @discussion Adds the specified key to the list of "dynamic store"
91 values that are being monitored for changes.
92 @param store The "dynamic store" session being watched.
93 @param key The key to be monitored.
94 @param isRegex A booolean indicating whether a specific key should
95 be monitored or if it consists of a regex(3) pattern string
97 @result TRUE if the key was successfully added to the "watch"
98 list; FALSE if an error was encountered.
101 SCDynamicStoreAddWatchedKey (SCDynamicStoreRef store
,
106 @function SCDynamicStoreRemoveWatchedKey
107 @discussion Removes the specified key from the list of "dynamic store"
108 values that are being monitored for changes.
109 @param store The "dynamic store" session being watched.
110 @param key The key that should no longer be monitored.
111 @param isRegex A booolean indicating whether a specific key should
112 be monitored or if it consists of a regex(3) pattern string
114 @result TRUE if the key was successfully removed from the "watch"
115 list; FALSE if an error was encountered.
118 SCDynamicStoreRemoveWatchedKey (SCDynamicStoreRef store
,
123 @function SCDynamicStoreNotifyCallback
124 @discussion Requests that the specified function be called whenever a
125 change has been detected to one of the "dynamic store" values
128 The callback function will be called with two arguments, store and
129 context, that correspond to the current "dynamic store" session and
130 the provided context argument.
132 The callback function should return a Boolean value indicating
133 whether an error occurred during execution of the callback.
135 Note: An additional run loop source will be added for the notification.
136 This additional source will be removed if the notification is cancelled
137 or if the callback indicates that an error was detected.
139 @param store The "dynamic store" session.
140 @param runLoop A pointer to the run loop.
141 @param funct The callback function to call for each notification.
142 If this parameter is not a pointer to a function of the
143 correct prototype, the behavior is undefined.
144 @param context A pointer-sized user-defined value, that is passed as
145 the second parameter to the notification callback function,
146 but is otherwise unused by this function. If the context
147 is not what is expected by the notification function, the
148 behavior is undefined.
149 @result TRUE if the notification callback runloop source was
150 successfully added; FALSE if an error was encountered.
153 SCDynamicStoreNotifyCallback (SCDynamicStoreRef store
,
154 CFRunLoopRef runLoop
,
155 SCDynamicStoreCallBack_v1 func
,
159 @function SCDynamicStoreNotifyMachPort
160 @discussion Allocates a mach port that can be used to detect changes to
161 one of the system configuration data entries associated with the
162 current session's notifier keys. When a change is detected, an
163 empty (no data) mach message with the specified identifier will
164 be delivered to the calling application via the allocated port.
166 @param store An SCDynamicStoreRef that should be used for communication with the server.
167 @param msgid A mach message ID to be included with any notifications.
168 @param port A pointer to a mach port. Upon return, port will be filled
169 with the mach port that will be used for any notifications.
170 @result A boolean indicating the success (or failure) of the call.
173 SCDynamicStoreNotifyMachPort (SCDynamicStoreRef store
,
178 @function SCDynamicStoreNotifyFileDescriptor
179 @discussion Allocates a file descriptor that can be used to detect changes
180 to one of the system configuration data entries associated with the
181 current session's notifier keys. When a change is detected, the
182 specified identifier (4 bytes) will be delivered to the calling
183 application via the allocated file descriptor.
185 @param store An SCDynamicStoreRef that should be used for communication with the server.
186 @param identifier A (4 byte) integer that can be used to identify this
188 @param fd A pointer to a file descriptor. Upon return, fd will
189 contain the file descriptor that will be used for any notifications.
190 @result A boolean indicating the success (or failure) of the call.
193 SCDynamicStoreNotifyFileDescriptor (SCDynamicStoreRef store
,
198 @function SCDynamicStoreNotifySignal
199 @discussion Requests that the specified BSD signal be sent to the process
200 with the indicated process id whenever a change has been detected
201 to one of the system configuration data entries associated with the
202 current session's notifier keys.
204 Note: this function is not valid for "configd" plug-ins.
206 @param store An SCDynamicStoreRef that should be used for communication with the server.
207 @param pid A UNIX process ID that should be signalled for any notifications.
208 @param sig A signal number to be used.
209 @result A boolean indicating the success (or failure) of the call.
212 SCDynamicStoreNotifySignal (SCDynamicStoreRef store
,
217 @function SCDynamicStoreNotifyWait
218 @discussion Waits for a change to be made to a value in the
219 "dynamic store" that is being monitored.
220 @param store The "dynamic store" session.
221 @result TRUE if a change has been detected; FALSE if an error was encountered.
224 SCDynamicStoreNotifyWait (SCDynamicStoreRef store
);
227 @function SCDynamicStoreNotifyCancel
228 @discussion Cancels any outstanding notification requests for
229 this "dynamic store" session.
231 @param store The "dynamic store" session.
232 @result TRUE if all notifications have been cancelled; FALSE if an
233 error was encountered.
236 SCDynamicStoreNotifyCancel (SCDynamicStoreRef store
);
239 SCDynamicStoreSnapshot (SCDynamicStoreRef store
);
243 #endif /* _SCDYNAMICSTOREPRIVATE_H */