2 * Copyright (c) 2000-2005 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@
27 #include <sys/cdefs.h>
28 #include <sys/syslog.h>
29 #include <mach/message.h>
31 #include <CoreFoundation/CoreFoundation.h>
33 #include <SystemConfiguration/SCDynamicStorePrivate.h>
34 #include <SystemConfiguration/SCDynamicStoreCopySpecificPrivate.h>
35 #include <SystemConfiguration/SCDynamicStoreSetSpecificPrivate.h>
37 #include <SystemConfiguration/SCPreferencesPrivate.h>
38 #include <SystemConfiguration/SCPreferencesGetSpecificPrivate.h>
39 #include <SystemConfiguration/SCPreferencesSetSpecificPrivate.h>
45 /* framework variables */
46 extern Boolean _sc_debug
; /* TRUE if debugging enabled */
47 extern Boolean _sc_verbose
; /* TRUE if verbose logging enabled */
48 extern Boolean _sc_log
; /* TRUE if SCLog() output goes to syslog */
54 @discussion Sets the last SystemConfiguration.framework API error code.
55 @param error The error encountered.
57 void _SCErrorSet (int error
);
60 @function _SCSerialize
61 @discussion Serialize a CFPropertyList object for passing
63 @param obj CFPropertyList object to serialize
64 @param xml A pointer to a CFDataRef, NULL if data should be
66 @param dataRef A pointer to the newly allocated/serialized data
67 @param dataLen A pointer to the length in bytes of the newly
68 allocated/serialized data
70 Boolean
_SCSerialize (CFPropertyListRef obj
,
76 @function _SCUnserialize
77 @discussion Unserialize a stream of bytes passed from/to configd
78 into a CFPropertyList object.
79 @param obj A pointer to memory that will be filled with the CFPropertyList
80 associated with the stream of bytes.
81 @param xml CFDataRef with the serialized data
82 @param dataRef A pointer to the serialized data
83 @param dataLen A pointer to the length of the serialized data
85 Specify either "xml" or "data/dataLen".
87 Boolean
_SCUnserialize (CFPropertyListRef
*obj
,
93 @function _SCSerializeString
94 @discussion Serialize a CFString object for passing
96 @param str CFString key to serialize
97 @param data A pointer to a CFDataRef, NULL if storage should be
99 @param dataRef A pointer to the newly allocated/serialized data
100 @param dataLen A pointer to the length in bytes of the newly
101 allocated/serialized data
103 Boolean
_SCSerializeString (CFStringRef str
,
109 @function _SCUnserializeString
110 @discussion Unserialize a stream of bytes passed from/to configd
111 into a CFString object.
112 @param str A pointer to memory that will be filled with the CFPropertyList
113 associated with the stream of bytes.
114 @param utf8 CFDataRef with the serialized data
115 @param dataRef A pointer to the serialized data
116 @param dataLen A pointer to the length of the serialized data
118 Specify either "utf8" or "data/dataLen".
120 Boolean
_SCUnserializeString (CFStringRef
*str
,
126 @function _SCSerializeData
127 @discussion Serialize a CFData object for passing
129 @param data CFData key to serialize
130 @param dataRef A pointer to the newly allocated/serialized data
131 @param dataLen A pointer to the length in bytes of the newly
132 allocated/serialized data
134 Boolean
_SCSerializeData (CFDataRef data
,
139 @function _SCUnserializeData
140 @discussion Unserialize a stream of bytes passed from/to configd
141 into a CFData object.
142 @param data A pointer to memory that will be filled with the CFPropertyList
143 associated with the stream of bytes.
144 @param dataRef A pointer to the serialized data
145 @param dataLen A pointer to the length of the serialized data
147 Boolean
_SCUnserializeData (CFDataRef
*data
,
152 @function _SCSerializeMultiple
153 @discussion Convert a CFDictionary containing a set of CFPropertlyList
154 values into a CFDictionary containing a set of serialized CFData
156 @param dict The CFDictionary with CFPropertyList values.
157 @result The serialized CFDictionary with CFData values
159 CFDictionaryRef
_SCSerializeMultiple (CFDictionaryRef dict
);
162 @function _SCUnserializeMultiple
163 @discussion Convert a CFDictionary containing a set of CFData
164 values into a CFDictionary containing a set of serialized
165 CFPropertlyList values.
166 @param dict The CFDictionary with CFData values.
167 @result The serialized CFDictionary with CFPropertyList values
169 CFDictionaryRef
_SCUnserializeMultiple (CFDictionaryRef dict
);
172 @function _SC_cfstring_to_cstring
173 @discussion Extracts a C-string from a CFString.
174 @param cfstr The CFString to extract the data from.
175 @param buf A user provided buffer of the specified length. If NULL,
176 a new buffer will be allocated to contain the C-string. It
177 is the responsiblity of the caller to free an allocated
179 @param bufLen The size of the user provided buffer.
180 @param encoding The string encoding
181 @result If the extraction (conversion) is successful then a pointer
182 to the user provided (or allocated) buffer is returned, NULL
183 if the string could not be extracted.
185 char * _SC_cfstring_to_cstring (CFStringRef cfstr
,
188 CFStringEncoding encoding
);
191 * @function _SC_sockaddr_to_string
192 * @discussion Formats a "struct sockaddr" for reporting
193 * @param address The address to format
194 * @param buf A user provided buffer of the specified length.
195 * @param bufLen The size of the user provided buffer.
197 void _SC_sockaddr_to_string (const struct sockaddr
*address
,
203 @discussion Conditionally issue a log message.
204 @param condition A boolean value indicating if the message should be logged
205 @param level A syslog(3) logging priority.
206 @param formatString The format string
207 @result The specified message will be written to the system message
208 logger (See syslogd(8)).
210 void SCLog (Boolean condition
,
212 CFStringRef formatString
,
217 @discussion Conditionally issue a debug message.
218 @param condition A boolean value indicating if the message should be written
219 @param stream The output stream for the log message.
220 @param formatString The format string
221 @result The message will be written to the specified stream
224 void SCPrint (Boolean condition
,
226 CFStringRef formatString
,
231 @discussion Conditionally issue a debug message with a time stamp.
232 @param condition A boolean value indicating if the message should be written
233 @param stream The output stream for the log message.
234 @param formatString The format string
235 @result The message will be written to the specified stream
238 void SCTrace (Boolean condition
,
240 CFStringRef formatString
,
244 * object / CFRunLoop management
247 _SC_signalRunLoop (CFTypeRef obj
,
248 CFRunLoopSourceRef rls
,
252 _SC_isScheduled (CFTypeRef obj
,
253 CFRunLoopRef runLoop
,
254 CFStringRef runLoopMode
,
255 CFMutableArrayRef rlList
);
258 _SC_schedule (CFTypeRef obj
,
259 CFRunLoopRef runLoop
,
260 CFStringRef runLoopMode
,
261 CFMutableArrayRef rlList
);
264 _SC_unschedule (CFTypeRef obj
,
265 CFRunLoopRef runLoop
,
266 CFStringRef runLoopMode
,
267 CFMutableArrayRef rlList
,
272 #endif /* _SCPRIVATE_H */