]>
git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPreferences.h
5db981e2bb51be0773687283063df6e70d0181d5
2 * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 #ifndef _SCPREFERENCES_H
27 #define _SCPREFERENCES_H
30 #include <sys/cdefs.h>
31 #include <CoreFoundation/CoreFoundation.h>
32 #include <SystemConfiguration/SCDynamicStore.h>
37 The SCPreferencesXXX() APIs allow an application to load and
38 store XML configuration data in a controlled manner and provide
39 the necessary notifications to other applications that need to
40 be aware of configuration changes.
42 The stored XML configuration data is accessed using a prefsID. A
43 NULL value indicates that the default system preferences are to
45 A string which starts with a leading "/" character specifies the
46 path to the file containing te preferences to be accessed.
47 A string which does not start with a leading "/" character
48 specifies a file relative to the default system preferences
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.
110 SCPreferencesRef session
,
115 @function SCPreferencesCommitChanges
116 @discussion Commits changes made to the configuration preferences to
119 This function commits any changes to permanent storage. An
120 implicit call to SCPreferencesLock/SCPreferencesUnlock will
121 be made if exclusive access has not already been established.
123 Note: This routine commits changes to persistent storage.
124 Call SCPreferencesApplyChanges() to apply the changes
125 to the running system.
126 @param session An SCPreferencesRef handle that should be used for
128 @result TRUE if the lock was obtained; FALSE if an error occurred.
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 */