]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPrivate.h
1b1d0a5aa4f7cc140f9c9b34110895a7952bfb8f
[apple/configd.git] / SystemConfiguration.fproj / SCPrivate.h
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, 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/syslog.h>
29 #include <mach/message.h>
30
31 #include <CoreFoundation/CoreFoundation.h>
32
33 #include <SystemConfiguration/SCDynamicStorePrivate.h>
34 #include <SystemConfiguration/SCDynamicStoreCopySpecificPrivate.h>
35 #include <SystemConfiguration/SCDynamicStoreSetSpecificPrivate.h>
36
37 #include <SystemConfiguration/SCPreferencesPrivate.h>
38 #include <SystemConfiguration/SCPreferencesGetSpecificPrivate.h>
39 #include <SystemConfiguration/SCPreferencesSetSpecificPrivate.h>
40
41 /*!
42 @header SCPrivate
43 */
44
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 */
49
50 __BEGIN_DECLS
51
52 /*!
53 @function _SCErrorSet
54 @discussion Sets the last SystemConfiguration.framework API error code.
55 @param error The error encountered.
56 */
57 void _SCErrorSet (int error);
58
59 /*!
60 @function _SCSerialize
61 @discussion Serialize a CFPropertyList object for passing
62 to/from configd.
63 @param obj CFPropertyList object to serialize
64 @param xml A pointer to a CFDataRef, NULL if data should be
65 vm_allocated.
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
69 */
70 Boolean _SCSerialize (CFPropertyListRef obj,
71 CFDataRef *xml,
72 void **dataRef,
73 CFIndex *dataLen);
74
75 /*!
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
84
85 Specify either "xml" or "data/dataLen".
86 */
87 Boolean _SCUnserialize (CFPropertyListRef *obj,
88 CFDataRef xml,
89 void *dataRef,
90 CFIndex dataLen);
91
92 /*!
93 @function _SCSerializeString
94 @discussion Serialize a CFString object for passing
95 to/from configd.
96 @param str CFString key to serialize
97 @param data A pointer to a CFDataRef, NULL if storage should be
98 vm_allocated.
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
102 */
103 Boolean _SCSerializeString (CFStringRef str,
104 CFDataRef *data,
105 void **dataRef,
106 CFIndex *dataLen);
107
108 /*!
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
117
118 Specify either "utf8" or "data/dataLen".
119 */
120 Boolean _SCUnserializeString (CFStringRef *str,
121 CFDataRef utf8,
122 void *dataRef,
123 CFIndex dataLen);
124
125 /*!
126 @function _SCSerializeData
127 @discussion Serialize a CFData object for passing
128 to/from configd.
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
133 */
134 Boolean _SCSerializeData (CFDataRef data,
135 void **dataRef,
136 CFIndex *dataLen);
137
138 /*!
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
146 */
147 Boolean _SCUnserializeData (CFDataRef *data,
148 void *dataRef,
149 CFIndex dataLen);
150
151 /*!
152 @function _SCSerializeMultiple
153 @discussion Convert a CFDictionary containing a set of CFPropertlyList
154 values into a CFDictionary containing a set of serialized CFData
155 values.
156 @param dict The CFDictionary with CFPropertyList values.
157 @result The serialized CFDictionary with CFData values
158 */
159 CFDictionaryRef _SCSerializeMultiple (CFDictionaryRef dict);
160
161 /*!
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
168 */
169 CFDictionaryRef _SCUnserializeMultiple (CFDictionaryRef dict);
170
171 /*!
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
178 buffer.
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.
184 */
185 char * _SC_cfstring_to_cstring (CFStringRef cfstr,
186 char *buf,
187 int bufLen,
188 CFStringEncoding encoding);
189
190 /*!
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.
196 */
197 void _SC_sockaddr_to_string (const struct sockaddr *address,
198 char *buf,
199 size_t bufLen);
200
201 /*!
202 @function SCLog
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)).
209 */
210 void SCLog (Boolean condition,
211 int level,
212 CFStringRef formatString,
213 ...);
214
215 /*!
216 @function SCPrint
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
222 stream.
223 */
224 void SCPrint (Boolean condition,
225 FILE *stream,
226 CFStringRef formatString,
227 ...);
228
229 /*!
230 @function SCTrace
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
236 stream.
237 */
238 void SCTrace (Boolean condition,
239 FILE *stream,
240 CFStringRef formatString,
241 ...);
242
243 /*
244 * object / CFRunLoop management
245 */
246 void
247 _SC_signalRunLoop (CFTypeRef obj,
248 CFRunLoopSourceRef rls,
249 CFArrayRef rlList);
250
251 Boolean
252 _SC_isScheduled (CFTypeRef obj,
253 CFRunLoopRef runLoop,
254 CFStringRef runLoopMode,
255 CFMutableArrayRef rlList);
256
257 void
258 _SC_schedule (CFTypeRef obj,
259 CFRunLoopRef runLoop,
260 CFStringRef runLoopMode,
261 CFMutableArrayRef rlList);
262
263 Boolean
264 _SC_unschedule (CFTypeRef obj,
265 CFRunLoopRef runLoop,
266 CFStringRef runLoopMode,
267 CFMutableArrayRef rlList,
268 Boolean all);
269
270 __END_DECLS
271
272 #endif /* _SCPRIVATE_H */