]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/genSCPreferences.c
configd-42.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / genSCPreferences.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 /*
24 * genSCPreferences.c
25 * - generates System Configuration header/cfile
26 * - invoke with "header" to generate the header
27 * - invoke with "cfile" to generate the cfile
28 */
29
30 /*
31 * Modification History
32 *
33 * June 1, 2001 Allan Nathanson <ajn@apple.com>
34 * - public API conversion
35 *
36 * 27 Apr 2001 Allan Nathanson (ajn@apple.com)
37 * - switch from "extern const CFStringRef ..." to "#define ..."
38 *
39 * 3 Nov 2000 Dieter Siegmund (dieter@apple)
40 * - created
41 */
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <unistd.h>
45 #include <mach/boolean.h>
46
47 char copyright_string[] =
48 "/*\n"
49 " * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.\n"
50 " *\n"
51 " * @APPLE_LICENSE_HEADER_START@\n"
52 " * \n"
53 " * The contents of this file constitute Original Code as defined in and\n"
54 " * are subject to the Apple Public Source License Version 1.1 (the\n"
55 " * \"License\"). You may not use this file except in compliance with the\n"
56 " * License. Please obtain a copy of the License at\n"
57 " * http://www.apple.com/publicsource and read it before using this file.\n"
58 " * \n"
59 " * This Original Code and all software distributed under the License are\n"
60 " * distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, EITHER\n"
61 " * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,\n"
62 " * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,\n"
63 " * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the\n"
64 " * License for the specific language governing rights and limitations\n"
65 " * under the License.\n"
66 " * \n"
67 " * @APPLE_LICENSE_HEADER_END@\n"
68 " */\n";
69
70
71 typedef enum {
72 COMMENT,
73 OBSOLETE,
74 REGULAR,
75 DEFINE ,
76 FUTURE,
77 END
78 } controlType;
79
80 #define KEY_PREFIX "kSC"
81
82 #define COMP "Comp"
83 #define DYNAMICSTORE "DynamicStore"
84 #define PREF "Pref"
85 #define PROP "Prop"
86 #define PATH "Path"
87 #define NETENT "EntNet"
88 #define NETPROP "PropNet"
89 #define NETVAL "ValNet"
90 #define SETUPENT "EntSetup"
91 #define SETUPPROP "PropSetup"
92 #define SYSTEMENT "EntSystem"
93 #define SYSTEMPROP "PropSystem"
94 #define RESV "Resv"
95 #define USERSENT "EntUsers"
96 #define USERSPROP "PropUsers"
97 #define VERSION "Version"
98
99 #define CFARRAY_CFNUMBER "CFArray[CFNumber]"
100 #define CFARRAY_CFSTRING "CFArray[CFString]"
101 #define CFBOOLEAN "CFBoolean"
102 #define CFDICTIONARY "CFDictionary"
103 #define CFNUMBER "CFNumber"
104 #define CFNUMBER_BOOL "CFNumber (0 or 1)"
105 #define CFSTRING "CFString"
106
107 #define ACTIVE "Active"
108 #define ADDRESSES "Addresses"
109 #define AIRPORT "AirPort"
110 #define ALERT "Alert"
111 #define ALTERNATEREMOTEADDRESS "AlternateRemoteAddress"
112 #define ANYREGEX "AnyRegex"
113 #define APPLETALK "AppleTalk"
114 #define AUTH "Auth"
115 #define AUTOMATIC "Automatic"
116 #define BINDINGMETHODS "BindingMethods"
117 #define BOOTP "BOOTP"
118 #define BROADCAST "Broadcast"
119 #define BROADCASTADDRESSES "BroadcastAddresses"
120 #define BROADCASTSERVERTAG "BroadcastServerTag"
121 #define CHAP "CHAP"
122 #define COMM "Comm"
123 #define COMPRESSIONACFIELD "CompressionACField"
124 #define COMPRESSIONPFIELD "CompressionPField"
125 #define COMPRESSIONVJ "CompressionVJ"
126 #define COMPUTERNAME "ComputerName"
127 #define CONFIGMETHOD "ConfigMethod"
128 #define CONNECTDELAY "ConnectDelay"
129 #define CONNECTIONSCRIPT "ConnectionScript"
130 #define CONSOLEUSER "ConsoleUser"
131 #define CURRENTSET "CurrentSet"
132 #define DATACOMPRESSION "DataCompression"
133 #define DEFAULTSERVERTAG "DefaultServerTag"
134 #define DEFAULTZONE "DefaultZone"
135 #define DESTADDRESSES "DestAddresses"
136 #define DEVICENAME "DeviceName"
137 #define DHCP "DHCP"
138 #define DHCPCLIENTID "DHCPClientID"
139 #define DIALMODE "DialMode"
140 #define DIALONDEMAND "DialOnDemand"
141 #define DISCONNECTONIDLE "DisconnectOnIdle"
142 #define DISCONNECTONIDLETIMER "DisconnectOnIdleTimer"
143 #define DISCONNECTONLOGOUT "DisconnectOnLogout"
144 #define DISPLAYTERMINALWINDOW "DisplayTerminalWindow"
145 #define DNS "DNS"
146 #define DOMAIN "Domain"
147 #define DOMAINNAME "DomainName"
148 #define DOMAINSEPARATOR "DomainSeparator"
149 #define ECHOENABLED "EchoEnabled"
150 #define ECHOFAILURE "EchoFailure"
151 #define ECHOINTERVAL "EchoInterval"
152 #define ENCODING "Encoding"
153 #define ENCRYPTION "Encryption"
154 #define ERRORCORRECTION "ErrorCorrection"
155 #define ETHERNET "Ethernet"
156 #define EXCEPTIONSLIST "ExceptionsList"
157 #define FILE "File"
158 #define FTPENABLE "FTPEnable"
159 #define FTPPASSIVE "FTPPassive"
160 #define FTPPORT "FTPPort"
161 #define FTPPROXY "FTPProxy"
162 #define GID "GID"
163 #define GLOBAL "Global"
164 #define GOPHERENABLE "GopherEnable"
165 #define GOPHERPORT "GopherPort"
166 #define GOPHERPROXY "GopherProxy"
167 #define HARDWARE "Hardware"
168 #define HTTPENABLE "HTTPEnable"
169 #define HTTPPORT "HTTPPort"
170 #define HTTPPROXY "HTTPProxy"
171 #define HTTPSENABLE "HTTPSEnable"
172 #define HTTPSPORT "HTTPSPort"
173 #define HTTPSPROXY "HTTPSProxy"
174 #define IDLEREMINDER "IdleReminder"
175 #define IDLEREMINDERTIMER "IdleReminderTimer"
176 #define IGNOREDIALTONE "IgnoreDialTone"
177 #define INACTIVE "Inactive"
178 #define INFORM "INFORM"
179 #define INTERFACE "Interface"
180 #define INTERFACENAME "InterfaceName"
181 #define INTERFACES "Interfaces"
182 #define IPCP "IPCP"
183 #define IPV4 "IPv4"
184 #define IPV6 "IPv6"
185 #define LASTUPDATED "LastUpdated"
186 #define LCP "LCP"
187 #define LINK "Link"
188 #define LOGFILE "Logfile"
189 #define MACADDRESS "MACAddress"
190 #define MANUAL "Manual"
191 #define MEDIA "Media"
192 #define MODEM "Modem"
193 #define MRU "MRU"
194 #define MTU "MTU"
195 #define NAME "Name"
196 #define NETINFO "NetInfo"
197 #define NETWORK "Network"
198 #define NETWORKID "NetworkID"
199 #define NETWORKSERVICES "NetworkServices"
200 #define NIS "NIS"
201 #define NODE "Node"
202 #define NODEID "NodeID"
203 #define PAP "PAP"
204 #define PASSWORD "Password"
205 #define PLUGIN "Plugin"
206 #define POWERENABLED "PowerEnabled"
207 #define PPP "PPP"
208 #define PPPOE "PPPoE"
209 #define PPPOVERRIDEPRIMARY "PPPOverridePrimary"
210 #define PPPSERIAL "PPPSerial"
211 #define PREFERREDNETWORK "PreferredNetwork"
212 #define PREFS "Prefs"
213 #define PRIMARYINTERFACE "PrimaryInterface"
214 #define PRIMARYSERVICE "PrimaryService"
215 #define PROTOCOL "Protocol"
216 #define PROXIES "Proxies"
217 #define PULSEDIAL "PulseDial"
218 #define RECEIVEACCM "ReceiveACCM"
219 #define REDIALCOUNT "RedialCount"
220 #define REDIALENABLED "RedialEnabled"
221 #define REDIALINTERVAL "RedialInterval"
222 #define REMOTEADDRESS "RemoteAddress"
223 #define ROOTSEPARATOR "RootSeparator"
224 #define ROUTER "Router"
225 #define RTSPENABLE "RTSPEnable"
226 #define RTSPPORT "RTSPPort"
227 #define RTSPPROXY "RTSPProxy"
228 #define SEARCHDOMAINS "SearchDomains"
229 #define SEEDNETWORKRANGE "SeedNetworkRange"
230 #define SEEDROUTER "SeedRouter"
231 #define SEEDZONES "SeedZones"
232 #define SERVERADDRESSES "ServerAddresses"
233 #define SERVERTAGS "ServerTags"
234 #define SERVICE "Service"
235 #define SERVICEIDS "ServiceIDs"
236 #define SERVICEORDER "ServiceOrder"
237 #define SESSIONTIMER "SessionTimer"
238 #define SETS "Sets"
239 #define SETUP "Setup"
240 #define SOCKSENABLE "SOCKSEnable"
241 #define SOCKSPORT "SOCKSPort"
242 #define SOCKSPROXY "SOCKSProxy"
243 #define SORTLIST "SortList"
244 #define SPEAKER "Speaker"
245 #define SPEED "Speed"
246 #define STATE "State"
247 #define SUBNETMASKS "SubnetMasks"
248 #define SUBTYPE "SubType"
249 #define SYSTEM "System"
250 #define TERMINALSCRIPT "TerminalScript"
251 #define TRANSMITACCM "TransmitACCM"
252 #define TYPE "Type"
253 #define UID "UID"
254 #define USERDEFINEDNAME "UserDefinedName"
255 #define USERS "Users"
256 #define VERBOSELOGGING "VerboseLogging"
257 #define WAITFORDIALTONE "WaitForDialTone"
258
259 struct {
260 int control;
261 unsigned char * prefix;
262 unsigned char * key;
263 unsigned char * value;
264 unsigned char * type;
265 } names[] = {
266 { COMMENT, "/*\n * Reserved Keys\n */", NULL, NULL },
267 { REGULAR, RESV, LINK, "__LINK__", CFSTRING },
268 { REGULAR, RESV, INACTIVE, "__INACTIVE__", NULL },
269 { COMMENT, "", NULL, NULL, NULL },
270
271 { COMMENT, "/*\n * Generic Keys\n */", NULL },
272 { DEFINE , PROP, INTERFACENAME, NULL, CFSTRING },
273 { REGULAR, PROP, MACADDRESS, NULL, CFSTRING },
274 { REGULAR, PROP, USERDEFINEDNAME, NULL, CFSTRING },
275 { DEFINE , PROP, VERSION, NULL, CFSTRING },
276 { COMMENT, "", NULL, NULL, NULL },
277
278 { COMMENT, "/*\n * Preference Keys\n */", NULL },
279 { REGULAR, PREF, CURRENTSET, NULL, CFSTRING },
280 { REGULAR, PREF, NETWORKSERVICES, NULL, CFDICTIONARY },
281 { REGULAR, PREF, SETS, NULL, CFDICTIONARY },
282 { REGULAR, PREF, SYSTEM, NULL, CFDICTIONARY },
283 { COMMENT, "", NULL, NULL, NULL },
284
285 { COMMENT, "/*\n * Component Keys\n */", NULL },
286 { REGULAR, COMP, NETWORK, NULL, NULL },
287 { REGULAR, COMP, SERVICE, NULL, NULL },
288 { REGULAR, COMP, GLOBAL, NULL, NULL },
289 { REGULAR, COMP, INTERFACE, NULL, NULL },
290 { REGULAR, COMP, SYSTEM, NULL, NULL },
291 { REGULAR, COMP, USERS, NULL, NULL },
292 { COMMENT, "", NULL, NULL, NULL },
293
294 { COMMENT, "/*\n * Regex key which matches any component\n */", NULL },
295 { REGULAR, COMP, ANYREGEX, "[^/]+", NULL },
296 { COMMENT, "", NULL, NULL, NULL },
297
298 { COMMENT, "/*\n * Network Entity Keys\n */", NULL },
299 { REGULAR, NETENT, AIRPORT, NULL, CFDICTIONARY },
300 { REGULAR, NETENT, APPLETALK, NULL, CFDICTIONARY },
301 { DEFINE , NETENT, DHCP, NULL, CFDICTIONARY },
302 { REGULAR, NETENT, DNS, NULL, CFDICTIONARY },
303 { REGULAR, NETENT, ETHERNET, NULL, CFDICTIONARY },
304 { REGULAR, NETENT, INTERFACE, NULL, CFDICTIONARY },
305 { REGULAR, NETENT, IPV4, NULL, CFDICTIONARY },
306 { REGULAR, NETENT, IPV6, NULL, CFDICTIONARY },
307 { REGULAR, NETENT, LINK, NULL, CFDICTIONARY },
308 { REGULAR, NETENT, MODEM, NULL, CFDICTIONARY },
309 { REGULAR, NETENT, NETINFO, NULL, CFDICTIONARY },
310 { FUTURE , NETENT, NIS, NULL, CFDICTIONARY },
311 { REGULAR, NETENT, PPP, NULL, CFDICTIONARY },
312 { REGULAR, NETENT, PPPOE, NULL, CFDICTIONARY },
313 { REGULAR, NETENT, PROXIES, NULL, CFDICTIONARY },
314 { COMMENT, "", NULL, NULL, NULL },
315
316 { COMMENT, "/*\n * " KEY_PREFIX COMP NETWORK " Properties\n */", NULL },
317 { REGULAR, NETPROP, SERVICEORDER, NULL, CFARRAY_CFSTRING },
318 { REGULAR, NETPROP, PPPOVERRIDEPRIMARY, NULL, CFNUMBER_BOOL },
319 { COMMENT, "", NULL, NULL, NULL },
320
321 { COMMENT, "/*\n * " KEY_PREFIX NETENT AIRPORT " (Hardware) Entity Keys\n */", NULL, NULL, NULL },
322 { REGULAR, NETPROP AIRPORT, POWERENABLED, NULL, CFNUMBER_BOOL },
323 { REGULAR, NETPROP AIRPORT, AUTH PASSWORD, NULL, CFSTRING },
324 { REGULAR, NETPROP AIRPORT, AUTH PASSWORD ENCRYPTION, NULL, CFSTRING },
325 { REGULAR, NETPROP AIRPORT, PREFERREDNETWORK, NULL, CFSTRING },
326 { COMMENT, "", NULL, NULL, NULL },
327
328 { COMMENT, "/*\n * " KEY_PREFIX NETENT APPLETALK " Entity Keys\n */", NULL, NULL, NULL },
329 { REGULAR, NETPROP APPLETALK, COMPUTERNAME, NULL, CFSTRING },
330 { REGULAR, NETPROP APPLETALK, COMPUTERNAME ENCODING, NULL, CFNUMBER },
331 { REGULAR, NETPROP APPLETALK, CONFIGMETHOD, NULL, CFSTRING },
332 { REGULAR, NETPROP APPLETALK, DEFAULTZONE, NULL, CFSTRING },
333 { REGULAR, NETPROP APPLETALK, NETWORKID, NULL, CFNUMBER },
334 { REGULAR, NETPROP APPLETALK, NODEID, NULL, CFNUMBER },
335 { REGULAR, NETPROP APPLETALK, SEEDNETWORKRANGE, NULL, CFARRAY_CFNUMBER },
336 { REGULAR, NETPROP APPLETALK, SEEDZONES, NULL, CFARRAY_CFSTRING },
337 { COMMENT, "", NULL, NULL, NULL },
338 { COMMENT, "/* " KEY_PREFIX NETPROP APPLETALK CONFIGMETHOD " values */", NULL, NULL, NULL },
339 { REGULAR, NETVAL APPLETALK CONFIGMETHOD, NODE, NULL, NULL },
340 { REGULAR, NETVAL APPLETALK CONFIGMETHOD, ROUTER, NULL, NULL },
341 { REGULAR, NETVAL APPLETALK CONFIGMETHOD, SEEDROUTER, NULL, NULL },
342 { COMMENT, "", NULL, NULL, NULL },
343
344 { COMMENT, "/*\n * " KEY_PREFIX NETENT DNS " Entity Keys\n */", NULL, NULL, NULL },
345 { REGULAR, NETPROP DNS, DOMAINNAME, NULL, CFSTRING },
346 { REGULAR, NETPROP DNS, SEARCHDOMAINS, NULL, CFARRAY_CFSTRING},
347 { REGULAR, NETPROP DNS, SERVERADDRESSES, NULL, CFARRAY_CFSTRING },
348 { DEFINE , NETPROP DNS, SORTLIST, NULL, CFARRAY_CFSTRING },
349 { COMMENT, "", NULL, NULL, NULL },
350
351 { COMMENT, "/*\n * " KEY_PREFIX NETENT ETHERNET " (Hardware) Entity Keys\n */", NULL, NULL, NULL },
352 { COMMENT, "", NULL, NULL, NULL },
353
354 { COMMENT, "/*\n * " KEY_PREFIX NETENT INTERFACE " Entity Keys\n */", NULL },
355 { REGULAR, NETPROP INTERFACE, DEVICENAME, NULL, CFSTRING },
356 { REGULAR, NETPROP INTERFACE, HARDWARE, NULL, CFSTRING },
357 { REGULAR, NETPROP INTERFACE, TYPE, NULL, CFSTRING },
358 { REGULAR, NETPROP INTERFACE, SUBTYPE, NULL, CFSTRING },
359 { COMMENT, "", NULL, NULL, NULL },
360 { COMMENT, "/* " KEY_PREFIX NETPROP INTERFACE TYPE " values */", NULL, NULL, NULL },
361 { REGULAR, NETVAL INTERFACE TYPE, ETHERNET, NULL, NULL },
362 { REGULAR, NETVAL INTERFACE TYPE, PPP, NULL, NULL },
363 { COMMENT, "", NULL, NULL, NULL },
364 { COMMENT, "/* " KEY_PREFIX NETPROP SERVICE SUBTYPE " values (for " PPP ") */", NULL, NULL, NULL },
365 { REGULAR, NETVAL INTERFACE SUBTYPE, PPPOE, NULL, NULL },
366 { REGULAR, NETVAL INTERFACE SUBTYPE, PPPSERIAL, NULL, NULL },
367 { COMMENT, "", NULL, NULL, NULL },
368
369 { COMMENT, "/*\n * " KEY_PREFIX NETENT IPV4 " Entity Keys\n */", NULL, NULL, NULL },
370 { REGULAR, NETPROP IPV4, ADDRESSES, NULL, CFARRAY_CFSTRING },
371 { REGULAR, NETPROP IPV4, CONFIGMETHOD, NULL, CFSTRING },
372 { REGULAR, NETPROP IPV4, DHCPCLIENTID, NULL, CFSTRING },
373 { REGULAR, NETPROP IPV4, ROUTER, NULL, CFSTRING },
374 { REGULAR, NETPROP IPV4, SUBNETMASKS, NULL, CFARRAY_CFSTRING },
375 { REGULAR, NETPROP IPV4, DESTADDRESSES, NULL, CFARRAY_CFSTRING },
376 { REGULAR, NETPROP IPV4, BROADCASTADDRESSES, NULL, CFARRAY_CFSTRING },
377 { COMMENT, "", NULL, NULL, NULL },
378 { COMMENT, "/* " KEY_PREFIX NETPROP IPV4 CONFIGMETHOD " values */", NULL, NULL, NULL },
379 { REGULAR, NETVAL IPV4 CONFIGMETHOD, BOOTP, NULL, NULL },
380 { REGULAR, NETVAL IPV4 CONFIGMETHOD, DHCP, NULL, NULL },
381 { REGULAR, NETVAL IPV4 CONFIGMETHOD, INFORM, NULL, NULL },
382 { REGULAR, NETVAL IPV4 CONFIGMETHOD, MANUAL, NULL, NULL },
383 { REGULAR, NETVAL IPV4 CONFIGMETHOD, PPP, NULL, NULL },
384 { COMMENT, "", NULL, NULL, NULL },
385
386 { COMMENT, "/*\n * " KEY_PREFIX NETENT IPV6 " Entity Keys\n */", NULL, NULL, NULL },
387 { REGULAR, NETPROP IPV6, ADDRESSES, NULL, CFARRAY_CFSTRING },
388 { REGULAR, NETPROP IPV6, CONFIGMETHOD, NULL, CFSTRING },
389 { COMMENT, "", NULL, NULL, NULL },
390
391 { COMMENT, "/*\n * " KEY_PREFIX NETENT LINK " Entity Keys\n */", NULL, NULL, NULL },
392 { REGULAR, NETPROP LINK, ACTIVE, NULL, CFBOOLEAN },
393 { COMMENT, "", NULL, NULL, NULL },
394
395 { COMMENT, "/*\n * " KEY_PREFIX NETENT MODEM " (Hardware) Entity Keys\n */", NULL, NULL, NULL },
396 { REGULAR, NETPROP MODEM, CONNECTIONSCRIPT, NULL, CFSTRING },
397 { DEFINE , NETPROP MODEM, DATACOMPRESSION, NULL, CFNUMBER_BOOL },
398 { REGULAR, NETPROP MODEM, DIALMODE, NULL, CFSTRING },
399 { DEFINE , NETPROP MODEM, ERRORCORRECTION, NULL, CFNUMBER_BOOL },
400 { REGULAR, NETPROP MODEM, PULSEDIAL, NULL, CFNUMBER_BOOL },
401 { REGULAR, NETPROP MODEM, SPEAKER, NULL, CFNUMBER_BOOL },
402 { REGULAR, NETPROP MODEM, SPEED, NULL, CFNUMBER },
403 { COMMENT, "", NULL, NULL, NULL },
404 { COMMENT, "/* " KEY_PREFIX NETPROP MODEM DIALMODE " values */", NULL, NULL, NULL },
405 { REGULAR, NETVAL MODEM DIALMODE, IGNOREDIALTONE, NULL, NULL },
406 { REGULAR, NETVAL MODEM DIALMODE, MANUAL, NULL, NULL },
407 { REGULAR, NETVAL MODEM DIALMODE, WAITFORDIALTONE, NULL, NULL },
408 { COMMENT, "", NULL, NULL, NULL },
409
410 { COMMENT, "/*\n * " KEY_PREFIX NETENT NETINFO " Entity Keys\n */", NULL, NULL, NULL },
411 { REGULAR, NETPROP NETINFO, BINDINGMETHODS, NULL, CFSTRING },
412 { REGULAR, NETPROP NETINFO, SERVERADDRESSES, NULL, CFARRAY_CFSTRING },
413 { REGULAR, NETPROP NETINFO, SERVERTAGS, NULL, CFARRAY_CFSTRING },
414 { REGULAR, NETPROP NETINFO, BROADCASTSERVERTAG, NULL, CFSTRING },
415 { COMMENT, "", NULL, NULL, NULL },
416 { COMMENT, "/* " KEY_PREFIX NETPROP NETINFO BINDINGMETHODS " values */", NULL, NULL, NULL },
417 { REGULAR, NETVAL NETINFO BINDINGMETHODS, BROADCAST, NULL, NULL },
418 { REGULAR, NETVAL NETINFO BINDINGMETHODS, DHCP, NULL, NULL },
419 { REGULAR, NETVAL NETINFO BINDINGMETHODS, MANUAL, NULL, NULL },
420 { COMMENT, "", NULL, NULL, NULL },
421 { COMMENT, "/* " KEY_PREFIX NETPROP NETINFO BROADCASTSERVERTAG " default value */", NULL, NULL, NULL },
422 { REGULAR, NETVAL NETINFO, DEFAULTSERVERTAG, "network", NULL },
423 { COMMENT, "", NULL, NULL, NULL },
424
425 { COMMENT, "/*\n * " KEY_PREFIX NETENT NIS " Entity Keys\n */", NULL, NULL, NULL },
426 { COMMENT, "/* RESERVED FOR FUTURE USE */", NULL, NULL, NULL },
427 { COMMENT, "", NULL, NULL, NULL },
428
429 { COMMENT, "/*\n * " KEY_PREFIX NETENT PPP " Entity Keys\n */", NULL, NULL, NULL },
430 { REGULAR, NETPROP PPP, DIALONDEMAND, NULL, CFNUMBER_BOOL },
431 { REGULAR, NETPROP PPP, DISCONNECTONIDLE, NULL, CFNUMBER_BOOL },
432 { REGULAR, NETPROP PPP, DISCONNECTONIDLETIMER, NULL, CFNUMBER },
433 { REGULAR, NETPROP PPP, DISCONNECTONLOGOUT, NULL, CFNUMBER_BOOL },
434 { REGULAR, NETPROP PPP, IDLEREMINDERTIMER, NULL, CFNUMBER },
435 { REGULAR, NETPROP PPP, IDLEREMINDER, NULL, CFNUMBER_BOOL },
436 { REGULAR, NETPROP PPP, LOGFILE, NULL, CFSTRING },
437 { DEFINE , NETPROP PPP, SESSIONTIMER, NULL, CFNUMBER },
438 { REGULAR, NETPROP PPP, VERBOSELOGGING, NULL, CFNUMBER_BOOL },
439 { COMMENT, "", NULL, NULL, NULL },
440
441 { COMMENT, "/* " AUTH ": */", NULL, NULL, NULL },
442 { REGULAR, NETPROP PPP, AUTH NAME, NULL, CFSTRING },
443 { REGULAR, NETPROP PPP, AUTH PASSWORD, NULL, CFSTRING },
444 { REGULAR, NETPROP PPP, AUTH PASSWORD ENCRYPTION, NULL, CFSTRING },
445 { REGULAR, NETPROP PPP, AUTH PROTOCOL, NULL, CFARRAY_CFSTRING },
446 { COMMENT, "", NULL, NULL, NULL },
447 { COMMENT, "/* " KEY_PREFIX NETPROP PPP AUTH PROTOCOL " values */", NULL, NULL, NULL },
448 { REGULAR, NETVAL PPP AUTH PROTOCOL, CHAP, NULL, CFSTRING },
449 { REGULAR, NETVAL PPP AUTH PROTOCOL, PAP, NULL, CFSTRING },
450
451 { COMMENT, "\n/* " COMM ": */", NULL, NULL, NULL },
452 { REGULAR, NETPROP PPP, COMM ALTERNATEREMOTEADDRESS, NULL, CFSTRING },
453 { REGULAR, NETPROP PPP, COMM CONNECTDELAY, NULL, CFNUMBER },
454 { REGULAR, NETPROP PPP, COMM DISPLAYTERMINALWINDOW, NULL, CFNUMBER_BOOL },
455 { REGULAR, NETPROP PPP, COMM REDIALCOUNT, NULL, CFNUMBER },
456 { REGULAR, NETPROP PPP, COMM REDIALENABLED, NULL, CFNUMBER_BOOL },
457 { REGULAR, NETPROP PPP, COMM REDIALINTERVAL, NULL, CFNUMBER },
458 { REGULAR, NETPROP PPP, COMM REMOTEADDRESS, NULL, CFSTRING },
459 { REGULAR, NETPROP PPP, COMM TERMINALSCRIPT, NULL, CFSTRING },
460
461 { COMMENT, "\n/* " IPCP ": */", NULL, NULL, NULL },
462 { REGULAR, NETPROP PPP, IPCP COMPRESSIONVJ, NULL, CFNUMBER_BOOL },
463
464 { COMMENT, "\n/* " LCP ": */", NULL, NULL, NULL },
465 { REGULAR, NETPROP PPP, LCP ECHOENABLED, NULL, CFNUMBER_BOOL },
466 { REGULAR, NETPROP PPP, LCP ECHOFAILURE, NULL, CFNUMBER },
467 { REGULAR, NETPROP PPP, LCP ECHOINTERVAL, NULL, CFNUMBER },
468 { REGULAR, NETPROP PPP, LCP COMPRESSIONACFIELD, NULL, CFNUMBER_BOOL },
469 { REGULAR, NETPROP PPP, LCP COMPRESSIONPFIELD, NULL, CFNUMBER_BOOL },
470 { REGULAR, NETPROP PPP, LCP MRU, NULL, CFNUMBER },
471 { REGULAR, NETPROP PPP, LCP MTU, NULL, CFNUMBER },
472 { REGULAR, NETPROP PPP, LCP RECEIVEACCM, NULL, CFNUMBER },
473 { REGULAR, NETPROP PPP, LCP TRANSMITACCM, NULL, CFNUMBER },
474 { COMMENT, "", NULL, NULL, NULL },
475
476 { COMMENT, "/*\n * " KEY_PREFIX NETENT PPPOE " Entity Keys\n */", NULL, NULL, NULL },
477 { COMMENT, "/* RESERVED FOR FUTURE USE */", NULL, NULL, NULL },
478 { COMMENT, "", NULL, NULL, NULL },
479
480 { COMMENT, "/*\n * " KEY_PREFIX NETENT PPPSERIAL " Entity Keys\n */", NULL, NULL, NULL },
481 { COMMENT, "/* RESERVED FOR FUTURE USE */", NULL, NULL, NULL },
482 { COMMENT, "", NULL, NULL, NULL },
483
484 { COMMENT, "/*\n * " KEY_PREFIX NETENT PROXIES " Entity Keys\n */", NULL, NULL, NULL },
485 { REGULAR, NETPROP PROXIES, EXCEPTIONSLIST, NULL, CFARRAY_CFSTRING },
486 { REGULAR, NETPROP PROXIES, FTPENABLE, NULL, CFNUMBER_BOOL },
487 { REGULAR, NETPROP PROXIES, FTPPASSIVE, NULL, CFNUMBER_BOOL },
488 { REGULAR, NETPROP PROXIES, FTPPORT, NULL, CFNUMBER },
489 { REGULAR, NETPROP PROXIES, FTPPROXY, NULL, CFSTRING },
490 { REGULAR, NETPROP PROXIES, GOPHERENABLE, NULL, CFNUMBER_BOOL },
491 { REGULAR, NETPROP PROXIES, GOPHERPORT, NULL, CFNUMBER },
492 { REGULAR, NETPROP PROXIES, GOPHERPROXY, NULL, CFSTRING },
493 { REGULAR, NETPROP PROXIES, HTTPENABLE, NULL, CFNUMBER_BOOL },
494 { REGULAR, NETPROP PROXIES, HTTPPORT, NULL, CFNUMBER },
495 { REGULAR, NETPROP PROXIES, HTTPPROXY, NULL, CFSTRING },
496 { DEFINE , NETPROP PROXIES, HTTPSENABLE, NULL, CFNUMBER_BOOL },
497 { DEFINE , NETPROP PROXIES, HTTPSPORT, NULL, CFNUMBER },
498 { DEFINE , NETPROP PROXIES, HTTPSPROXY, NULL, CFSTRING },
499 { REGULAR, NETPROP PROXIES, RTSPENABLE, NULL, CFNUMBER_BOOL },
500 { REGULAR, NETPROP PROXIES, RTSPPORT, NULL, CFNUMBER },
501 { REGULAR, NETPROP PROXIES, RTSPPROXY, NULL, CFSTRING },
502 { REGULAR, NETPROP PROXIES, SOCKSENABLE, NULL, CFNUMBER_BOOL },
503 { REGULAR, NETPROP PROXIES, SOCKSPORT, NULL, CFNUMBER },
504 { REGULAR, NETPROP PROXIES, SOCKSPROXY, NULL, CFSTRING },
505 { COMMENT, "", NULL, NULL, NULL },
506
507 { COMMENT, "/*\n " KEY_PREFIX COMP USERS " Entity Keys\n */", NULL, NULL, NULL },
508 { REGULAR, USERSENT, CONSOLEUSER, NULL, NULL },
509 { COMMENT, "", NULL, NULL, NULL },
510
511 { COMMENT, "/*\n " KEY_PREFIX USERSPROP CONSOLEUSER " Properties\n */", NULL, NULL, NULL },
512 { REGULAR, USERSPROP CONSOLEUSER, NAME, NULL, CFSTRING },
513 { REGULAR, USERSPROP CONSOLEUSER, UID, NULL, CFSTRING },
514 { REGULAR, USERSPROP CONSOLEUSER, GID, NULL, CFSTRING },
515 { COMMENT, "", NULL, NULL, NULL },
516
517 { COMMENT, "/*\n * " KEY_PREFIX COMP SYSTEM " Properties\n */", NULL, NULL, NULL },
518 { REGULAR, SYSTEMPROP, COMPUTERNAME, NULL, CFSTRING },
519 { REGULAR, SYSTEMPROP, COMPUTERNAME ENCODING, NULL, CFNUMBER },
520 { COMMENT, "", NULL, NULL, NULL },
521
522 { COMMENT, "/*\n * Configuration Store Definitions\n */", NULL },
523 { COMMENT, "/* domain prefixes */", NULL },
524 { DEFINE , DYNAMICSTORE DOMAIN, FILE, "File:", NULL },
525 { DEFINE , DYNAMICSTORE DOMAIN, PLUGIN, "Plugin:", NULL },
526 { DEFINE , DYNAMICSTORE DOMAIN, SETUP, "Setup:", NULL },
527 { DEFINE , DYNAMICSTORE DOMAIN, STATE, "State:", NULL },
528 { DEFINE , DYNAMICSTORE DOMAIN, PREFS, "Prefs:", NULL },
529 { COMMENT, "", NULL, NULL, NULL },
530
531 { COMMENT, "/* " KEY_PREFIX DYNAMICSTORE DOMAIN SETUP " Properties */", NULL },
532 { DEFINE , DYNAMICSTORE SETUPPROP, CURRENTSET, NULL, CFSTRING },
533 { DEFINE , DYNAMICSTORE SETUPPROP, LASTUPDATED, NULL, NULL },
534 { COMMENT, "", NULL, NULL, NULL },
535
536 { COMMENT, "/* Properties */", NULL },
537 { DEFINE , DYNAMICSTORE NETPROP, INTERFACES, NULL, CFARRAY_CFSTRING },
538 { DEFINE , DYNAMICSTORE NETPROP, PRIMARYINTERFACE, NULL, CFSTRING },
539 { DEFINE , DYNAMICSTORE NETPROP, PRIMARYSERVICE, NULL, CFSTRING },
540 { DEFINE , DYNAMICSTORE NETPROP, SERVICEIDS, NULL, CFARRAY_CFSTRING },
541 { COMMENT, "", NULL, NULL, NULL },
542
543 /* obsolete keys */
544 { OBSOLETE, "Cache" DOMAIN, FILE, "File:", NULL },
545 { OBSOLETE, "Cache" DOMAIN, PLUGIN, "Plugin:", NULL },
546 { OBSOLETE, "Cache" DOMAIN, SETUP, "Setup:", NULL },
547 { OBSOLETE, "Cache" DOMAIN, STATE, "State:", NULL },
548 { OBSOLETE, "Cache" DOMAIN, PREFS, "Prefs:", NULL },
549 { OBSOLETE, "Cache" SETUPPROP, CURRENTSET, NULL, CFSTRING },
550 { OBSOLETE, "Cache" SETUPPROP, LASTUPDATED, NULL, NULL },
551 { OBSOLETE, "Cache" NETPROP, INTERFACES, NULL, CFARRAY_CFSTRING },
552 { OBSOLETE, "Cache" NETPROP, PRIMARYINTERFACE, NULL, CFSTRING },
553 { OBSOLETE, "Cache" NETPROP, SERVICEIDS, NULL, CFARRAY_CFSTRING },
554
555 { END, NULL, NULL, NULL, NULL },
556 };
557
558 enum {
559 gen_extern_e,
560 gen_init_e,
561 gen_header_e,
562 };
563
564 void
565 dump_names(int type)
566 {
567 int i;
568
569 for (i = 0; TRUE; i++) {
570 switch (names[i].control) {
571 case END: {
572 goto done;
573 break;
574 }
575 case COMMENT: {
576 if (type != gen_extern_e && type != gen_init_e) {
577 if (names[i].prefix)
578 printf("%s\n", names[i].prefix);
579 }
580 break;
581 }
582 case DEFINE: {
583 char kbuf[256];
584 char vbuf[256];
585
586 switch (type) {
587 case gen_header_e:
588 snprintf(kbuf, sizeof(kbuf), KEY_PREFIX "%s%s",
589 names[i].prefix, names[i].key);
590
591 if (names[i].value)
592 snprintf(vbuf, sizeof(vbuf), "SCSTR(\"%s\")",
593 names[i].value);
594 else
595 snprintf(vbuf, sizeof(vbuf), "SCSTR(\"%s\")",
596 names[i].key);
597
598 if (names[i].type)
599 printf("#define %-40s %-40s /* %s */\n",
600 kbuf, vbuf, names[i].type);
601 else
602 printf("#define %-40s %-40s\n",
603 kbuf, vbuf);
604 break;
605 default:
606 break;
607 }
608 break;
609 }
610 case REGULAR: {
611 char kbuf[256];
612 char vbuf[256];
613
614 switch (type) {
615 case gen_header_e:
616 snprintf(kbuf, sizeof(kbuf), KEY_PREFIX "%s%s",
617 names[i].prefix, names[i].key);
618
619 if (names[i].value)
620 snprintf(vbuf, sizeof(vbuf), "SCSTR(\"%s\")",
621 names[i].value);
622 else
623 snprintf(vbuf, sizeof(vbuf), "SCSTR(\"%s\")",
624 names[i].key);
625
626 if (names[i].type)
627 printf("#define %-40s %-40s /* %s */\n",
628 kbuf, vbuf, names[i].type);
629 else
630 printf("#define %-40s %-40s\n",
631 kbuf, vbuf);
632 break;
633 case gen_extern_e:
634 snprintf(kbuf, sizeof(kbuf), KEY_PREFIX "%s%s",
635 names[i].prefix, names[i].key);
636
637 printf("volatile CFStringRef " KEY_PREFIX "%s%s = NULL;\n",
638 names[i].prefix, names[i].key);
639 break;
640 case gen_init_e:
641 snprintf(kbuf, sizeof(kbuf), KEY_PREFIX "%s%s",
642 names[i].prefix, names[i].key);
643 if (names[i].value)
644 printf(" *((void **)&%s) = (void *)CFSTR(\"%s\");\n",
645 kbuf, names[i].value);
646 else
647 printf(" *((void **)&%s) = (void *)CFSTR(\"%s\");\n",
648 kbuf, names[i].key);
649 break;
650 default:
651 break;
652 }
653 break;
654 }
655 case OBSOLETE: {
656 char kbuf[256];
657
658 switch (type) {
659 case gen_extern_e:
660 snprintf(kbuf, sizeof(kbuf), KEY_PREFIX "%s%s",
661 names[i].prefix, names[i].key);
662
663 printf("volatile CFStringRef " KEY_PREFIX "%s%s = NULL;\n",
664 names[i].prefix, names[i].key);
665 break;
666 case gen_init_e:
667 snprintf(kbuf, sizeof(kbuf), KEY_PREFIX "%s%s",
668 names[i].prefix, names[i].key);
669 if (names[i].value)
670 printf(" *((void **)&%s) = (void *)CFSTR(\"%s\");\n",
671 kbuf, names[i].value);
672 else
673 printf(" *((void **)&%s) = (void *)CFSTR(\"%s\");\n",
674 kbuf, names[i].key);
675 break;
676 default:
677 break;
678 }
679 break;
680 }
681 case FUTURE: {
682 char kbuf[256];
683
684 if (type == gen_header_e) {
685 snprintf(kbuf, sizeof(kbuf), KEY_PREFIX "%s%s",
686 names[i].prefix, names[i].key);
687
688 printf("/* #define %-37s %-40s /* %s */\n",
689 kbuf,
690 "SCSTR(\"???\") */",
691 "RESERVED FOR FUTURE USE");
692 }
693 break;
694 }
695 default: {
696 break;
697 }
698 }
699 }
700 done:
701 return;
702 }
703
704 int
705 main(int argc, char * argv[])
706 {
707 char * type = "";
708
709 if (argc >= 2)
710 type = argv[1];
711
712 if (strcmp(type, "header") == 0) {
713 printf("%s\n", copyright_string);
714 printf("/*\n * This file is automatically generated\n * DO NOT EDIT!\n */\n\n");
715
716 printf("/*\n");
717 printf(" * Note: For Cocoa/Obj-C/Foundation programs accessing these preference\n");
718 printf(" * keys you may want to consider the following:\n");
719 printf(" *\n");
720 printf(" * #define SCSTR(s) (NSString *)CFSTR(s)\n");
721 printf(" * #import <SystemConfiguration/SystemConfiguration.h>\n");
722 printf(" */\n\n");
723
724 printf("#ifndef _SCSCHEMADEFINITIONS_H\n#define _SCSCHEMADEFINITIONS_H\n\n");
725
726 printf("#ifndef SCSTR\n");
727 printf("#include <CoreFoundation/CFString.h>\n");
728 printf("#define SCSTR(s) CFSTR(s)\n");
729 printf("#endif\n");
730
731 printf("\n");
732 dump_names(gen_header_e);
733 printf("#endif /* _SCSCHEMADEFINITIONS_H */\n");
734 }
735 else if (strcmp(type, "cfile") == 0) {
736 printf("/*\n");
737 printf(" * This file is automatically generated\n");
738 printf(" * DO NOT EDIT!\n");
739 printf(" */\n");
740 printf("\n");
741 printf("#include <CoreFoundation/CFString.h>\n");
742 printf("\n");
743 dump_names(gen_extern_e);
744 printf("\n");
745 printf("__private_extern__\nvoid\n__Initialize(void)\n");
746 printf("{\n");
747 printf(" static Boolean initialized = FALSE;\n");
748 printf("\n");
749 printf(" if (initialized)\n");
750 printf(" return;\n");
751 printf("\n");
752 dump_names(gen_init_e);
753 printf("\n");
754 printf(" initialized = TRUE;\n");
755 printf(" return;\n");
756 printf("}\n");
757 }
758 exit(0);
759 return (0);
760 }
761