]>
git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPreferences.h
854ed87c3d8298e634afdfaef19d9f213df394c5
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@
23 #ifndef _SCPREFERENCES_H
24 #define _SCPREFERENCES_H
27 #include <sys/cdefs.h>
28 #include <CoreFoundation/CoreFoundation.h>
29 #include <SystemConfiguration/SCDynamicStore.h>
34 The SCPreferencesXXX() APIs allow an application to load and
35 store XML configuration data in a controlled manner and provide
36 the necessary notifications to other applications that need to
37 be aware of configuration changes.
39 The stored XML configuration data is accessed using a prefsID. A
40 NULL value indicates that the default system preferences are to
42 A string which starts with a leading "/" character specifies the
43 path to the file containing te preferences to be accessed.
44 A string which does not start with a leading "/" character
45 specifies a file relative to the default system preferences
48 The APIs provided by this framework communicate with the "configd"
49 daemon for any tasks requiring synchronization and/or notification.
54 @typedef SCPreferencesRef
55 @discussion This is the handle to an open "session" for
56 accessing system configuration preferences.
58 typedef const struct __SCPreferences
* SCPreferencesRef
;
64 @function SCPreferencesGetTypeID
65 Returns the type identifier of all SCPreferences instances.
68 SCPreferencesGetTypeID (void);
72 @function SCPreferencesCreate
73 @discussion Initiates access to the per-system set of configuration
76 @param name A string that describes the name of the calling
78 @param prefsID A string that identifies the name of the
79 group of preferences to be accessed/updated.
80 @result prefs A pointer to memory that will be filled with an
81 SCPreferencesRef handle to be used for all subsequent requests.
82 If a session cannot be established, the contents of
83 memory pointed to by this parameter are undefined.
87 CFAllocatorRef allocator
,
93 @function SCPreferencesLock
94 @discussion Locks access to the configuration preferences.
96 This function obtains exclusive access to the configuration
97 preferences associated with this prefsID. Clients attempting
98 to obtain exclusive access to the preferences will either receive
99 an kSCStatusPrefsBusy error or block waiting for the lock to be
101 @param session An SCPreferencesRef handle that should be used for
103 @param wait A boolean flag indicating whether the calling process
104 should block waiting for another process to complete its update
105 operation and release its lock.
106 @result TRUE if the lock was obtained; FALSE if an error occurred.
108 XXXXX: old API error codes included kSCStatusPrefsBusy, kSCStatusAccessError, and kSCStatusStale
112 SCPreferencesRef session
,
117 @function SCPreferencesCommitChanges
118 @discussion Commits changes made to the configuration preferences to
121 This function commits any changes to permanent storage. An
122 implicit call to SCPreferencesLock/SCPreferencesUnlock will
123 be made if exclusive access has not already been established.
124 @param session An SCPreferencesRef handle that should be used for
126 @result TRUE if the lock was obtained; FALSE if an error occurred.
128 XXXXX: old API error codes included kSCStatusAccessError, kSCStatusStale
131 SCPreferencesCommitChanges (
132 SCPreferencesRef session
136 @function SCPreferencesApplyChanges
137 @discussion Requests that the currently stored configuration
138 preferences be applied to the active configuration.
139 @param session An SCPreferencesRef handle that should be used for
141 @result TRUE if the lock was obtained; FALSE if an error occurred.
144 SCPreferencesApplyChanges (
145 SCPreferencesRef session
149 @function SCPreferencesUnlock
150 @discussion Releases exclusive access to the configuration preferences.
152 This function releases the exclusive access "lock" for this prefsID.
153 Other clients will be now be able to establish exclusive access to
155 @param session An SCPreferencesRef handle that should be used for
157 @result TRUE if the lock was obtained; FALSE if an error occurred.
160 SCPreferencesUnlock (
161 SCPreferencesRef session
165 @function SCPreferencesGetSignature
166 @discussion Returns a sequence of bytes that can be used to determine
167 if the saved configuration preferences have changed.
168 @param session An SCPreferencesRef handle that should be used for
170 @param signature A pointer to a CFDataRef that will reflect
171 the signature of the configuration preferences at the time
172 of the call to SCPreferencesCreate().
173 @result A CFDataRef that reflects the signature of the configuration
174 preferences at the time of the call to SCPreferencesCreate().
177 SCPreferencesGetSignature (
178 SCPreferencesRef session
182 @function SCPreferencesCopyKeyList
183 @discussion Returns an array of currently defined preference keys.
184 @param session An SCPreferencesRef handle that should be used for
186 @result The list of keys. You must release the returned value.
189 SCPreferencesCopyKeyList (
190 SCPreferencesRef session
194 @function SCPreferencesGetValue
195 @discussion Returns the data associated with a preference key.
197 This function retrieves data associated with a key for the prefsID.
199 Note: You could read stale data and not know it, unless you
200 first call SCPreferencesLock().
201 @param session An SCPreferencesRef handle that should be used for
203 @param key The preference key to be returned.
204 @result The value associated with the specified preference key; If no
205 value was located, NULL is returned.
208 SCPreferencesGetValue (
209 SCPreferencesRef session
,
214 @function SCPreferencesAddValue
215 @discussion Adds data for a preference key.
217 This function associates new data with the specified key. In order
218 to commit these changes to permanent storage a call must be made to
219 SCPreferencesCommitChanges().
220 @param session The SCPreferencesRef handle that should be used to
221 communicate with the APIs.
222 @param key The preference key to be updated.
223 @param value The CFPropertyListRef object containing the
224 value to be associated with the specified preference key.
225 @result TRUE if the value was added; FALSE if the key already exists or
226 if an error occurred.
229 SCPreferencesAddValue (
230 SCPreferencesRef session
,
232 CFPropertyListRef value
236 @function SCPreferencesSetValue
237 @discussion Updates the data associated with a preference key.
239 This function adds or replaces the value associated with the
240 specified key. In order to commit these changes to permanent
241 storage a call must be made to SCPreferencesCommitChanges().
242 @param session The SCPreferencesRef handle that should be used to
243 communicate with the APIs.
244 @param key The preference key to be updated.
245 @param value The CFPropertyListRef object containing the
246 data to be associated with the specified preference key.
247 @result TRUE if the value was set; FALSE if an error occurred.
250 SCPreferencesSetValue (
251 SCPreferencesRef session
,
253 CFPropertyListRef value
257 @function SCPreferencesRemoveValue
258 @discussion Removes the data associated with a preference key.
260 This function removes the data associated with the specified
261 key. In order to commit these changes to permanent storage a
262 call must be made to SCPreferencesCommitChanges().
263 @param session The SCPreferencesRef handle that should be used to
264 communicate with the APIs.
265 @param key The preference key to be removed.
266 @result TRUE if the value was removed; FALSE if the key did not exist or
267 if an error occurred.
270 SCPreferencesRemoveValue (
271 SCPreferencesRef session
,
277 #endif /* _SCPREFERENCES_H */