]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPrivate.h
configd-204.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / SCPrivate.h
1 /*
2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef _SCPRIVATE_H
25 #define _SCPRIVATE_H
26
27 #include <sys/cdefs.h>
28 #include <sys/socket.h>
29 #include <sys/syslog.h>
30 #include <mach/message.h>
31
32 #include <CoreFoundation/CoreFoundation.h>
33
34 /* SCDynamicStore SPIs */
35 #include <SystemConfiguration/SCDynamicStorePrivate.h>
36 #include <SystemConfiguration/SCDynamicStoreCopySpecificPrivate.h>
37 #include <SystemConfiguration/SCDynamicStoreSetSpecificPrivate.h>
38
39 /* SCPreferences SPIs */
40 #include <SystemConfiguration/SCPreferencesPrivate.h>
41 #include <SystemConfiguration/SCPreferencesGetSpecificPrivate.h>
42 #include <SystemConfiguration/SCPreferencesSetSpecificPrivate.h>
43
44 /* [private] Schema Definitions (for SCDynamicStore and SCPreferences) */
45 #include <SystemConfiguration/SCSchemaDefinitionsPrivate.h>
46
47 /* SCNetworkConfiguration SPIs */
48 #include <SystemConfiguration/SCNetworkConfigurationPrivate.h>
49
50 /* SCNetworkConnection SPIs */
51 #include <SystemConfiguration/SCNetworkConnectionPrivate.h>
52
53 /* Keychain SPIs */
54 #include <SystemConfiguration/SCPreferencesKeychainPrivate.h>
55
56 /*!
57 @header SCPrivate
58 */
59
60 /* framework variables */
61 extern Boolean _sc_debug; /* TRUE if debugging enabled */
62 extern Boolean _sc_verbose; /* TRUE if verbose logging enabled */
63 extern Boolean _sc_log; /* TRUE if SCLog() output goes to syslog */
64
65 __BEGIN_DECLS
66
67 /*!
68 @function _SCErrorSet
69 @discussion Sets the last SystemConfiguration.framework API error code.
70 @param error The error encountered.
71 */
72 void _SCErrorSet (int error);
73
74 /*!
75 @function _SCSerialize
76 @discussion Serialize a CFPropertyList object for passing
77 to/from configd.
78 @param obj CFPropertyList object to serialize
79 @param xml A pointer to a CFDataRef, NULL if data should be
80 vm_allocated.
81 @param dataRef A pointer to the newly allocated/serialized data
82 @param dataLen A pointer to the length in bytes of the newly
83 allocated/serialized data
84 */
85 Boolean _SCSerialize (CFPropertyListRef obj,
86 CFDataRef *xml,
87 void **dataRef,
88 CFIndex *dataLen);
89
90 /*!
91 @function _SCUnserialize
92 @discussion Unserialize a stream of bytes passed from/to configd
93 into a CFPropertyList object.
94 @param obj A pointer to memory that will be filled with the CFPropertyList
95 associated with the stream of bytes.
96 @param xml CFDataRef with the serialized data
97 @param dataRef A pointer to the serialized data
98 @param dataLen A pointer to the length of the serialized data
99
100 Specify either "xml" or "data/dataLen".
101 */
102 Boolean _SCUnserialize (CFPropertyListRef *obj,
103 CFDataRef xml,
104 void *dataRef,
105 CFIndex dataLen);
106
107 /*!
108 @function _SCSerializeString
109 @discussion Serialize a CFString object for passing
110 to/from configd.
111 @param str CFString key to serialize
112 @param data A pointer to a CFDataRef, NULL if storage should be
113 vm_allocated.
114 @param dataRef A pointer to the newly allocated/serialized data
115 @param dataLen A pointer to the length in bytes of the newly
116 allocated/serialized data
117 */
118 Boolean _SCSerializeString (CFStringRef str,
119 CFDataRef *data,
120 void **dataRef,
121 CFIndex *dataLen);
122
123 /*!
124 @function _SCUnserializeString
125 @discussion Unserialize a stream of bytes passed from/to configd
126 into a CFString object.
127 @param str A pointer to memory that will be filled with the CFString
128 associated with the stream of bytes.
129 @param utf8 CFDataRef with the serialized data
130 @param dataRef A pointer to the serialized data
131 @param dataLen A pointer to the length of the serialized data
132
133 Specify either "utf8" or "data/dataLen".
134 */
135 Boolean _SCUnserializeString (CFStringRef *str,
136 CFDataRef utf8,
137 void *dataRef,
138 CFIndex dataLen);
139
140 /*!
141 @function _SCSerializeData
142 @discussion Serialize a CFData object for passing
143 to/from configd.
144 @param data CFData key to serialize
145 @param dataRef A pointer to the newly allocated/serialized data
146 @param dataLen A pointer to the length in bytes of the newly
147 allocated/serialized data
148 */
149 Boolean _SCSerializeData (CFDataRef data,
150 void **dataRef,
151 CFIndex *dataLen);
152
153 /*!
154 @function _SCUnserializeData
155 @discussion Unserialize a stream of bytes passed from/to configd
156 into a CFData object.
157 @param data A pointer to memory that will be filled with the CFData
158 associated with the stream of bytes.
159 @param dataRef A pointer to the serialized data
160 @param dataLen A pointer to the length of the serialized data
161 */
162 Boolean _SCUnserializeData (CFDataRef *data,
163 void *dataRef,
164 CFIndex dataLen);
165
166 /*!
167 @function _SCSerializeMultiple
168 @discussion Convert a CFDictionary containing a set of CFPropertlyList
169 values into a CFDictionary containing a set of serialized CFData
170 values.
171 @param dict The CFDictionary with CFPropertyList values.
172 @result The serialized CFDictionary with CFData values
173 */
174 CFDictionaryRef _SCSerializeMultiple (CFDictionaryRef dict);
175
176 /*!
177 @function _SCUnserializeMultiple
178 @discussion Convert a CFDictionary containing a set of CFData
179 values into a CFDictionary containing a set of serialized
180 CFPropertlyList values.
181 @param dict The CFDictionary with CFData values.
182 @result The serialized CFDictionary with CFPropertyList values
183 */
184 CFDictionaryRef _SCUnserializeMultiple (CFDictionaryRef dict);
185
186 /*!
187 @function _SC_cfstring_to_cstring
188 @discussion Extracts a C-string from a CFString.
189 @param cfstr The CFString to extract the data from.
190 @param buf A user provided buffer of the specified length. If NULL,
191 a new buffer will be allocated to contain the C-string. It
192 is the responsiblity of the caller to free an allocated
193 buffer.
194 @param bufLen The size of the user provided buffer.
195 @param encoding The string encoding
196 @result If the extraction (conversion) is successful then a pointer
197 to the user provided (or allocated) buffer is returned, NULL
198 if the string could not be extracted.
199 */
200 char * _SC_cfstring_to_cstring (CFStringRef cfstr,
201 char *buf,
202 CFIndex bufLen,
203 CFStringEncoding encoding);
204
205 /*!
206 * @function _SC_sockaddr_to_string
207 * @discussion Formats a "struct sockaddr" for reporting
208 * @param address The address to format
209 * @param buf A user provided buffer of the specified length.
210 * @param bufLen The size of the user provided buffer.
211 */
212 void _SC_sockaddr_to_string (const struct sockaddr *address,
213 char *buf,
214 size_t bufLen);
215
216 /*!
217 @function _SC_sendMachMessage
218 @discussion Sends a trivial mach message (one with just a
219 message ID) to the specified port.
220 @param port The mach port.
221 @param msg_id The message id.
222 */
223 void _SC_sendMachMessage (mach_port_t port,
224 mach_msg_id_t msg_id);
225
226
227 /*!
228 @function SCLog
229 @discussion Conditionally issue a log message.
230 @param condition A boolean value indicating if the message should be logged
231 @param level A syslog(3) logging priority.
232 @param formatString The format string
233 @result The specified message will be written to the system message
234 logger (See syslogd(8)).
235 */
236 void SCLog (Boolean condition,
237 int level,
238 CFStringRef formatString,
239 ...);
240
241 /*!
242 @function SCPrint
243 @discussion Conditionally issue a debug message.
244 @param condition A boolean value indicating if the message should be written
245 @param stream The output stream for the log message.
246 @param formatString The format string
247 @result The message will be written to the specified stream
248 stream.
249 */
250 void SCPrint (Boolean condition,
251 FILE *stream,
252 CFStringRef formatString,
253 ...);
254
255 /*!
256 @function SCTrace
257 @discussion Conditionally issue a debug message with a time stamp.
258 @param condition A boolean value indicating if the message should be written
259 @param stream The output stream for the log message.
260 @param formatString The format string
261 @result The message will be written to the specified stream
262 stream.
263 */
264 void SCTrace (Boolean condition,
265 FILE *stream,
266 CFStringRef formatString,
267 ...);
268
269 /*
270 * DOS encoding/codepage
271 */
272 void
273 _SC_dos_encoding_and_codepage (CFStringEncoding macEncoding,
274 UInt32 macRegion,
275 CFStringEncoding *dosEncoding,
276 UInt32 *dosCodepage);
277
278 CFDataRef
279 _SC_dos_copy_string (CFStringRef str,
280 CFStringEncoding dosEncoding,
281 UInt32 dosCodepage);
282
283 /*
284 * object / CFRunLoop management
285 */
286 void
287 _SC_signalRunLoop (CFTypeRef obj,
288 CFRunLoopSourceRef rls,
289 CFArrayRef rlList);
290
291 Boolean
292 _SC_isScheduled (CFTypeRef obj,
293 CFRunLoopRef runLoop,
294 CFStringRef runLoopMode,
295 CFMutableArrayRef rlList);
296
297 void
298 _SC_schedule (CFTypeRef obj,
299 CFRunLoopRef runLoop,
300 CFStringRef runLoopMode,
301 CFMutableArrayRef rlList);
302
303 Boolean
304 _SC_unschedule (CFTypeRef obj,
305 CFRunLoopRef runLoop,
306 CFStringRef runLoopMode,
307 CFMutableArrayRef rlList,
308 Boolean all);
309
310 /*
311 * bundle access
312 */
313 CFBundleRef
314 _SC_CFBundleGet (void);
315
316 CFStringRef
317 _SC_CFBundleCopyNonLocalizedString (CFBundleRef bundle,
318 CFStringRef key,
319 CFStringRef value,
320 CFStringRef tableName);
321
322 /*
323 * misc
324 */
325 static __inline__ Boolean
326 _SC_CFEqual(CFTypeRef val1, CFTypeRef val2)
327 {
328 if (val1 == val2) {
329 return TRUE;
330 }
331 if (val1 != NULL && val2 != NULL) {
332 return CFEqual(val1, val2);
333 }
334 return FALSE;
335 }
336
337 __END_DECLS
338
339 #endif /* _SCPRIVATE_H */