]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPrivate.h
5ee8e130d804a938daba05a74aa23b3dd78c6407
[apple/configd.git] / SystemConfiguration.fproj / SCPrivate.h
1 /*
2 * Copyright (c) 2000-2003 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
29 #include <CoreFoundation/CoreFoundation.h>
30
31 #include <SystemConfiguration/SCDynamicStorePrivate.h>
32 #include <SystemConfiguration/SCDynamicStoreCopySpecificPrivate.h>
33 #include <SystemConfiguration/SCDynamicStoreSetSpecificPrivate.h>
34
35 #include <SystemConfiguration/SCPreferencesPrivate.h>
36
37 /* framework variables */
38 extern Boolean _sc_debug; /* TRUE if debugging enabled */
39 extern Boolean _sc_verbose; /* TRUE if verbose logging enabled */
40 extern Boolean _sc_log; /* TRUE if SCLog() output goes to syslog */
41
42 __BEGIN_DECLS
43
44 /*!
45 @function _SCErrorSet
46 @discussion Returns a last SystemConfiguration.framework API error code.
47 @result The last error encountered.
48 */
49 void _SCErrorSet (int error);
50
51 /*
52 @function _SCSerialize
53 @discussion Serialize a CFPropertyList object for passing
54 to/from configd.
55 @param obj CFPropertyList object to serialize
56 @param xml A pointer to a CFDataRef, NULL if data should be
57 vm_allocated.
58 @param data A pointer to the newly allocated/serialized data
59 @param dataLen A pointer to the length in bytes of the newly
60 allocated/serialized data
61 */
62 Boolean _SCSerialize (CFPropertyListRef obj,
63 CFDataRef *xml,
64 void **dataRef,
65 CFIndex *dataLen);
66
67 /*
68 @function _SCUnserialize
69 @discussion Unserialize a stream of bytes passed from/to configd
70 into a CFPropertyList object.
71 @param obj A pointer to memory that will be filled with the CFPropertyList
72 associated with the stream of bytes.
73 @param xml CFDataRef with the serialized data
74 @param data A pointer to the serialized data
75 @param dataLen A pointer to the length of the serialized data
76
77 Specify either "xml" or "data/dataLen".
78 */
79 Boolean _SCUnserialize (CFPropertyListRef *obj,
80 CFDataRef xml,
81 void *dataRef,
82 CFIndex dataLen);
83
84 /*
85 @function _SCSerializeString
86 @discussion Serialize a CFString object for passing
87 to/from configd.
88 @param str CFString key to serialize
89 @param data A pointer to a CFDataRef, NULL if storage should be
90 vm_allocated.
91 @param data A pointer to the newly allocated/serialized data
92 @param dataLen A pointer to the length in bytes of the newly
93 allocated/serialized data
94 */
95 Boolean _SCSerializeString (CFStringRef str,
96 CFDataRef *data,
97 void **dataRef,
98 CFIndex *dataLen);
99
100 /*
101 @function _SCUnserializeString
102 @discussion Unserialize a stream of bytes passed from/to configd
103 into a CFString object.
104 @param str A pointer to memory that will be filled with the CFPropertyList
105 associated with the stream of bytes.
106 @param utf8 CFDataRef with the serialized data
107 @param data A pointer to the serialized data
108 @param dataLen A pointer to the length of the serialized data
109
110 Specify either "utf8" or "data/dataLen".
111 */
112 Boolean _SCUnserializeString (CFStringRef *str,
113 CFDataRef utf8,
114 void *dataRef,
115 CFIndex dataLen);
116
117 /*
118 @function _SCSerializeData
119 @discussion Serialize a CFData object for passing
120 to/from configd.
121 @param data CFData key to serialize
122 @param data A pointer to the newly allocated/serialized data
123 @param dataLen A pointer to the length in bytes of the newly
124 allocated/serialized data
125 */
126 Boolean _SCSerializeData (CFDataRef data,
127 void **dataRef,
128 CFIndex *dataLen);
129
130 /*
131 @function _SCUnserializeData
132 @discussion Unserialize a stream of bytes passed from/to configd
133 into a CFData object.
134 @param data A pointer to memory that will be filled with the CFPropertyList
135 associated with the stream of bytes.
136 @param data A pointer to the serialized data
137 @param dataLen A pointer to the length of the serialized data
138 */
139 Boolean _SCUnserializeData (CFDataRef *data,
140 void *dataRef,
141 CFIndex dataLen);
142
143 /*
144 @function _SCSerializeMultiple
145 @discussion Convert a CFDictionary containing a set of CFPropertlyList
146 values into a CFDictionary containing a set of serialized CFData
147 values.
148 @param dict The CFDictionary with CFPropertyList values.
149 @result The serialized CFDictionary with CFData values
150 */
151 CFDictionaryRef _SCSerializeMultiple (CFDictionaryRef dict);
152
153 /*
154 @function _SCUnserializeMultiple
155 @discussion Convert a CFDictionary containing a set of CFData
156 values into a CFDictionary containing a set of serialized
157 CFPropertlyList values.
158 @param dict The CFDictionary with CFData values.
159 @result The serialized CFDictionary with CFPropertyList values
160 */
161 CFDictionaryRef _SCUnserializeMultiple (CFDictionaryRef dict);
162
163 /*
164 @function _SC_cfstring_to_cstring
165 @discussion Extracts a C-string from a CFString.
166 @param cfstr The CFString to extract the data from.
167 @param buf A user provided buffer of the specefied length. If NULL,
168 a new buffer will be allocated to contain the C-string. It
169 is the responsiblity of the caller to free an allocated
170 buffer.
171 @param bufLen The size of the user provided buffer.
172 @param encoding The string encoding
173 @result If the extraction (conversion) is successful then a pointer
174 to the user provided (or allocated) buffer is returned, NULL
175 if the string could not be extracted.
176 */
177 char * _SC_cfstring_to_cstring (CFStringRef cfstr,
178 char *buf,
179 int bufLen,
180 CFStringEncoding encoding);
181
182 /*
183 @function SCLog
184 @discussion Conditionally issue a log message.
185 @param condition A boolean value indicating if the message should be logged
186 @param level A syslog(3) logging priority.
187 @param formatString The format string
188 @result The specified message will be written to the system message
189 logger (See syslogd(8)).
190 */
191 void SCLog (Boolean condition,
192 int level,
193 CFStringRef formatString,
194 ...);
195
196 /*
197 @function SCPrint
198 @discussion Conditionally issue a debug message.
199 @param condition A boolean value indicating if the message should be written
200 @param stream The output stream for the log message.
201 @param formatString The format string
202 @result The message will be written to the specified stream
203 stream.
204 */
205 void SCPrint (Boolean condition,
206 FILE *stream,
207 CFStringRef formatString,
208 ...);
209
210 /*
211 @function SCTrace
212 @discussion Conditionally issue a debug message with a time stamp.
213 @param condition A boolean value indicating if the message should be written
214 @param stream The output stream for the log message.
215 @param formatString The format string
216 @result The message will be written to the specified stream
217 stream.
218 */
219 void SCTrace (Boolean condition,
220 FILE *stream,
221 CFStringRef formatString,
222 ...);
223
224 __END_DECLS
225
226 #endif /* _SCPRIVATE_H */