]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPrivate.h
configd-84.tar.gz
[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 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26 #ifndef _SCPRIVATE_H
27 #define _SCPRIVATE_H
28
29 #include <sys/cdefs.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
39 /* framework variables */
40 extern Boolean _sc_debug; /* TRUE if debugging enabled */
41 extern Boolean _sc_verbose; /* TRUE if verbose logging enabled */
42 extern Boolean _sc_log; /* TRUE if SCLog() output goes to syslog */
43
44 __BEGIN_DECLS
45
46 /*!
47 @function _SCErrorSet
48 @discussion Returns a last SystemConfiguration.framework API error code.
49 @result The last error encountered.
50 */
51 void _SCErrorSet (int error);
52
53 /*
54 @function _SCSerialize
55 @discussion Serialize a CFPropertyList object for passing
56 to/from configd.
57 @param obj CFPropertyList object to serialize
58 @param xml A pointer to a CFDataRef, NULL if data should be
59 vm_allocated.
60 @param data A pointer to the newly allocated/serialized data
61 @param dataLen A pointer to the length in bytes of the newly
62 allocated/serialized data
63 */
64 Boolean _SCSerialize (CFPropertyListRef obj,
65 CFDataRef *xml,
66 void **dataRef,
67 CFIndex *dataLen);
68
69 /*
70 @function _SCUnserialize
71 @discussion Unserialize a stream of bytes passed from/to configd
72 into a CFPropertyList object.
73 @param obj A pointer to memory that will be filled with the CFPropertyList
74 associated with the stream of bytes.
75 @param xml CFDataRef with the serialized data
76 @param data A pointer to the serialized data
77 @param dataLen A pointer to the length of the serialized data
78
79 Specify either "xml" or "data/dataLen".
80 */
81 Boolean _SCUnserialize (CFPropertyListRef *obj,
82 CFDataRef xml,
83 void *dataRef,
84 CFIndex dataLen);
85
86 /*
87 @function _SCSerializeString
88 @discussion Serialize a CFString object for passing
89 to/from configd.
90 @param str CFString key to serialize
91 @param data A pointer to a CFDataRef, NULL if storage should be
92 vm_allocated.
93 @param data A pointer to the newly allocated/serialized data
94 @param dataLen A pointer to the length in bytes of the newly
95 allocated/serialized data
96 */
97 Boolean _SCSerializeString (CFStringRef str,
98 CFDataRef *data,
99 void **dataRef,
100 CFIndex *dataLen);
101
102 /*
103 @function _SCUnserializeString
104 @discussion Unserialize a stream of bytes passed from/to configd
105 into a CFString object.
106 @param str A pointer to memory that will be filled with the CFPropertyList
107 associated with the stream of bytes.
108 @param utf8 CFDataRef with the serialized data
109 @param data A pointer to the serialized data
110 @param dataLen A pointer to the length of the serialized data
111
112 Specify either "utf8" or "data/dataLen".
113 */
114 Boolean _SCUnserializeString (CFStringRef *str,
115 CFDataRef utf8,
116 void *dataRef,
117 CFIndex dataLen);
118
119 /*
120 @function _SCSerializeData
121 @discussion Serialize a CFData object for passing
122 to/from configd.
123 @param data CFData key to serialize
124 @param data A pointer to the newly allocated/serialized data
125 @param dataLen A pointer to the length in bytes of the newly
126 allocated/serialized data
127 */
128 Boolean _SCSerializeData (CFDataRef data,
129 void **dataRef,
130 CFIndex *dataLen);
131
132 /*
133 @function _SCUnserializeData
134 @discussion Unserialize a stream of bytes passed from/to configd
135 into a CFData object.
136 @param data A pointer to memory that will be filled with the CFPropertyList
137 associated with the stream of bytes.
138 @param data A pointer to the serialized data
139 @param dataLen A pointer to the length of the serialized data
140 */
141 Boolean _SCUnserializeData (CFDataRef *data,
142 void *dataRef,
143 CFIndex dataLen);
144
145 /*
146 @function _SCSerializeMultiple
147 @discussion Convert a CFDictionary containing a set of CFPropertlyList
148 values into a CFDictionary containing a set of serialized CFData
149 values.
150 @param dict The CFDictionary with CFPropertyList values.
151 @result The serialized CFDictionary with CFData values
152 */
153 CFDictionaryRef _SCSerializeMultiple (CFDictionaryRef dict);
154
155 /*
156 @function _SCUnserializeMultiple
157 @discussion Convert a CFDictionary containing a set of CFData
158 values into a CFDictionary containing a set of serialized
159 CFPropertlyList values.
160 @param dict The CFDictionary with CFData values.
161 @result The serialized CFDictionary with CFPropertyList values
162 */
163 CFDictionaryRef _SCUnserializeMultiple (CFDictionaryRef dict);
164
165 /*
166 @function _SC_cfstring_to_cstring
167 @discussion Extracts a C-string from a CFString.
168 @param cfstr The CFString to extract the data from.
169 @param buf A user provided buffer of the specefied length. If NULL,
170 a new buffer will be allocated to contain the C-string. It
171 is the responsiblity of the caller to free an allocated
172 buffer.
173 @param bufLen The size of the user provided buffer.
174 @param encoding The string encoding
175 @result If the extraction (conversion) is successful then a pointer
176 to the user provided (or allocated) buffer is returned, NULL
177 if the string could not be extracted.
178 */
179 char * _SC_cfstring_to_cstring (CFStringRef cfstr,
180 char *buf,
181 int bufLen,
182 CFStringEncoding encoding);
183
184 /*
185 @function SCLog
186 @discussion Conditionally issue a log message.
187 @param condition A boolean value indicating if the message should be logged
188 @param level A syslog(3) logging priority.
189 @param formatString The format string
190 @result The specified message will be written to the system message
191 logger (See syslogd(8)).
192 */
193 void SCLog (Boolean condition,
194 int level,
195 CFStringRef formatString,
196 ...);
197
198 /*
199 @function SCPrint
200 @discussion Conditionally issue a debug message.
201 @param condition A boolean value indicating if the message should be written
202 @param stream The output stream for the log message.
203 @param formatString The format string
204 @result The message will be written to the specified stream
205 stream.
206 */
207 void SCPrint (Boolean condition,
208 FILE *stream,
209 CFStringRef formatString,
210 ...);
211
212 /*
213 @function SCTrace
214 @discussion Conditionally issue a debug message with a time stamp.
215 @param condition A boolean value indicating if the message should be written
216 @param stream The output stream for the log message.
217 @param formatString The format string
218 @result The message will be written to the specified stream
219 stream.
220 */
221 void SCTrace (Boolean condition,
222 FILE *stream,
223 CFStringRef formatString,
224 ...);
225
226 __END_DECLS
227
228 #endif /* _SCPRIVATE_H */