]>
git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPreferences.h
aaebc2a4b90d2911bcf461e917e1a86dd36f0ac5
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 _SCPREFERENCES_H
25 #define _SCPREFERENCES_H
28 #include <sys/cdefs.h>
29 #include <CoreFoundation/CoreFoundation.h>
30 #include <SystemConfiguration/SCDynamicStore.h>
35 The SCPreferencesXXX() APIs allow an application to load and
36 store XML configuration data in a controlled manner and provide
37 the necessary notifications to other applications that need to
38 be aware of configuration changes.
40 The stored XML configuration data is accessed using a prefsID. A
41 NULL value indicates that the default system preferences are to
43 A string which starts with a leading "/" character specifies the
44 path to the file containing te preferences to be accessed.
45 A string which does not start with a leading "/" character
46 specifies a file relative to the default system preferences
52 @typedef SCPreferencesRef
53 @discussion This is the handle to an open "session" for
54 accessing system configuration preferences.
56 typedef const struct __SCPreferences
* SCPreferencesRef
;
62 @function SCPreferencesGetTypeID
63 Returns the type identifier of all SCPreferences instances.
66 SCPreferencesGetTypeID (void);
70 @function SCPreferencesCreate
71 @discussion Initiates access to the per-system set of configuration
74 @param name A string that describes the name of the calling
76 @param prefsID A string that identifies the name of the
77 group of preferences to be accessed/updated.
78 @result prefs A pointer to memory that will be filled with an
79 SCPreferencesRef handle to be used for all subsequent requests.
80 If a session cannot be established, the contents of
81 memory pointed to by this parameter are undefined.
85 CFAllocatorRef allocator
,
91 @function SCPreferencesLock
92 @discussion Locks access to the configuration preferences.
94 This function obtains exclusive access to the configuration
95 preferences associated with this prefsID. Clients attempting
96 to obtain exclusive access to the preferences will either receive
97 an kSCStatusPrefsBusy error or block waiting for the lock to be
99 @param session An SCPreferencesRef handle that should be used for
101 @param wait A boolean flag indicating whether the calling process
102 should block waiting for another process to complete its update
103 operation and release its lock.
104 @result TRUE if the lock was obtained; FALSE if an error occurred.
108 SCPreferencesRef session
,
113 @function SCPreferencesCommitChanges
114 @discussion Commits changes made to the configuration preferences to
117 This function commits any changes to permanent storage. An
118 implicit call to SCPreferencesLock/SCPreferencesUnlock will
119 be made if exclusive access has not already been established.
121 Note: This routine commits changes to persistent storage.
122 Call SCPreferencesApplyChanges() to apply the changes
123 to the running system.
124 @param session An SCPreferencesRef handle that should be used for
126 @result TRUE if the lock was obtained; FALSE if an error occurred.
129 SCPreferencesCommitChanges (
130 SCPreferencesRef session
134 @function SCPreferencesApplyChanges
135 @discussion Requests that the currently stored configuration
136 preferences be applied to the active configuration.
137 @param session An SCPreferencesRef handle that should be used for
139 @result TRUE if the lock was obtained; FALSE if an error occurred.
142 SCPreferencesApplyChanges (
143 SCPreferencesRef session
147 @function SCPreferencesUnlock
148 @discussion Releases exclusive access to the configuration preferences.
150 This function releases the exclusive access "lock" for this prefsID.
151 Other clients will be now be able to establish exclusive access to
153 @param session An SCPreferencesRef handle that should be used for
155 @result TRUE if the lock was obtained; FALSE if an error occurred.
158 SCPreferencesUnlock (
159 SCPreferencesRef session
163 @function SCPreferencesGetSignature
164 @discussion Returns a sequence of bytes that can be used to determine
165 if the saved configuration preferences have changed.
166 @param session An SCPreferencesRef handle that should be used for
168 @param signature A pointer to a CFDataRef that will reflect
169 the signature of the configuration preferences at the time
170 of the call to SCPreferencesCreate().
171 @result A CFDataRef that reflects the signature of the configuration
172 preferences at the time of the call to SCPreferencesCreate().
175 SCPreferencesGetSignature (
176 SCPreferencesRef session
180 @function SCPreferencesCopyKeyList
181 @discussion Returns an array of currently defined preference keys.
182 @param session An SCPreferencesRef handle that should be used for
184 @result The list of keys. You must release the returned value.
187 SCPreferencesCopyKeyList (
188 SCPreferencesRef session
192 @function SCPreferencesGetValue
193 @discussion Returns the data associated with a preference key.
195 This function retrieves data associated with a key for the prefsID.
197 Note: You could read stale data and not know it, unless you
198 first call SCPreferencesLock().
199 @param session An SCPreferencesRef handle that should be used for
201 @param key The preference key to be returned.
202 @result The value associated with the specified preference key; If no
203 value was located, NULL is returned.
206 SCPreferencesGetValue (
207 SCPreferencesRef session
,
212 @function SCPreferencesAddValue
213 @discussion Adds data for a preference key.
215 This function associates new data with the specified key. In order
216 to commit these changes to permanent storage a call must be made to
217 SCPreferencesCommitChanges().
218 @param session The SCPreferencesRef handle that should be used to
219 communicate with the APIs.
220 @param key The preference key to be updated.
221 @param value The CFPropertyListRef object containing the
222 value to be associated with the specified preference key.
223 @result TRUE if the value was added; FALSE if the key already exists or
224 if an error occurred.
227 SCPreferencesAddValue (
228 SCPreferencesRef session
,
230 CFPropertyListRef value
234 @function SCPreferencesSetValue
235 @discussion Updates the data associated with a preference key.
237 This function adds or replaces the value associated with the
238 specified key. In order to commit these changes to permanent
239 storage a call must be made to SCPreferencesCommitChanges().
240 @param session The SCPreferencesRef handle that should be used to
241 communicate with the APIs.
242 @param key The preference key to be updated.
243 @param value The CFPropertyListRef object containing the
244 data to be associated with the specified preference key.
245 @result TRUE if the value was set; FALSE if an error occurred.
248 SCPreferencesSetValue (
249 SCPreferencesRef session
,
251 CFPropertyListRef value
255 @function SCPreferencesRemoveValue
256 @discussion Removes the data associated with a preference key.
258 This function removes the data associated with the specified
259 key. In order to commit these changes to permanent storage a
260 call must be made to SCPreferencesCommitChanges().
261 @param session The SCPreferencesRef handle that should be used to
262 communicate with the APIs.
263 @param key The preference key to be removed.
264 @result TRUE if the value was removed; FALSE if the key did not exist or
265 if an error occurred.
268 SCPreferencesRemoveValue (
269 SCPreferencesRef session
,
275 #endif /* _SCPREFERENCES_H */