]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPreferencesPathKey.c
configd-293.4.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / SCPreferencesPathKey.c
1 /*
2 * Copyright (c) 2001, 2004, 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 /*
25 * Modification History
26 *
27 * October 29, 2001 Allan Nathanson <ajn@apple.com>
28 * - initial revision
29 */
30
31 #include <SystemConfiguration/SystemConfiguration.h>
32
33 #include <stdarg.h>
34
35 __private_extern__ CFStringRef
36 SCPreferencesPathKeyCreate(CFAllocatorRef allocator,
37 CFStringRef fmt,
38 ...)
39 {
40 va_list args;
41 va_start(args, fmt);
42 return (CFStringCreateWithFormatAndArguments(allocator,
43 NULL,
44 fmt,
45 args));
46 }
47
48
49 __private_extern__ CFStringRef
50 SCPreferencesPathKeyCreateNetworkServices(CFAllocatorRef allocator)
51 {
52 /*
53 * create "/NetworkServices"
54 */
55 return CFStringCreateWithFormat(allocator,
56 NULL,
57 CFSTR("/%@"),
58 kSCPrefNetworkServices);
59 }
60
61
62 __private_extern__ CFStringRef
63 SCPreferencesPathKeyCreateNetworkServiceEntity(CFAllocatorRef allocator,
64 CFStringRef service,
65 CFStringRef entity)
66 {
67 CFStringRef path;
68
69 if (entity == NULL) {
70 /*
71 * create "/NetworkServices/service-id"
72 */
73 path = CFStringCreateWithFormat(allocator,
74 NULL,
75 CFSTR("/%@/%@"),
76 kSCPrefNetworkServices,
77 service);
78 } else {
79 /*
80 * create "/NetworkServices/service-id/entity"
81 */
82 path = CFStringCreateWithFormat(allocator,
83 NULL,
84 CFSTR("/%@/%@/%@"),
85 kSCPrefNetworkServices,
86 service,
87 entity);
88 }
89
90 return path;
91 }
92
93
94 __private_extern__ CFStringRef
95 SCPreferencesPathKeyCreateSets(CFAllocatorRef allocator)
96 {
97 /*
98 * create "/Sets"
99 */
100 return (CFStringCreateWithFormat(allocator,
101 NULL,
102 CFSTR("/%@"),
103 kSCPrefSets));
104 }
105
106
107 __private_extern__ CFStringRef
108 SCPreferencesPathKeyCreateSet(CFAllocatorRef allocator,
109 CFStringRef set)
110 {
111 /*
112 * create "/Sets/set-id"
113 */
114 return (CFStringCreateWithFormat(allocator,
115 NULL,
116 CFSTR("/%@/%@"),
117 kSCPrefSets,
118 set));
119 }
120
121
122 __private_extern__ CFStringRef
123 SCPreferencesPathKeyCreateSetNetworkGlobalEntity(CFAllocatorRef allocator,
124 CFStringRef set,
125 CFStringRef entity)
126 {
127 /*
128 * create "/Sets/set-id/Network/Global/entity"
129 */
130 return CFStringCreateWithFormat(allocator,
131 NULL,
132 CFSTR("/%@/%@/%@/%@/%@"),
133 kSCPrefSets,
134 set,
135 kSCCompNetwork,
136 kSCCompGlobal,
137 entity);
138 }
139
140
141 __private_extern__ CFStringRef
142 SCPreferencesPathKeyCreateSetNetworkInterfaceEntity(CFAllocatorRef allocator,
143 CFStringRef set,
144 CFStringRef ifname,
145 CFStringRef entity)
146 {
147 /*
148 * create "/Sets/set-id/Network/Interface/interface-name/entity"
149 */
150 return CFStringCreateWithFormat(allocator,
151 NULL,
152 CFSTR("/%@/%@/%@/%@/%@/%@"),
153 kSCPrefSets,
154 set,
155 kSCCompNetwork,
156 kSCCompInterface,
157 ifname,
158 entity);
159 }
160
161
162 __private_extern__ CFStringRef
163 SCPreferencesPathKeyCreateSetNetworkService(CFAllocatorRef allocator,
164 CFStringRef set,
165 CFStringRef service)
166 {
167 CFStringRef path;
168
169 if (service == NULL) {
170 /*
171 * create "/Sets/set-id/Network/Service"
172 */
173 path = CFStringCreateWithFormat(allocator,
174 NULL,
175 CFSTR("/%@/%@/%@/%@"),
176 kSCPrefSets,
177 set,
178 kSCCompNetwork,
179 kSCCompService);
180 } else {
181 /*
182 * create "/Sets/set-id/Network/Service/service-id"
183 */
184 path = CFStringCreateWithFormat(allocator,
185 NULL,
186 CFSTR("/%@/%@/%@/%@/%@"),
187 kSCPrefSets,
188 set,
189 kSCCompNetwork,
190 kSCCompService,
191 service);
192 }
193
194 return path;
195 }
196
197
198 __private_extern__ CFStringRef
199 SCPreferencesPathKeyCreateSetNetworkServiceEntity(CFAllocatorRef allocator,
200 CFStringRef set,
201 CFStringRef service,
202 CFStringRef entity)
203 {
204 CFStringRef path;
205
206 if (entity == NULL) {
207 /*
208 * create "/Sets/set-id/Network/Service/service-id"
209 */
210 path = CFStringCreateWithFormat(allocator,
211 NULL,
212 CFSTR("/%@/%@/%@/%@/%@"),
213 kSCPrefSets,
214 set,
215 kSCCompNetwork,
216 kSCCompService,
217 service);
218 } else {
219 /*
220 * create "/Sets/set-id/Network/Service/service-id/entity"
221 */
222 path = CFStringCreateWithFormat(allocator,
223 NULL,
224 CFSTR("/%@/%@/%@/%@/%@/%@"),
225 kSCPrefSets,
226 set,
227 kSCCompNetwork,
228 kSCCompService,
229 service,
230 entity);
231 }
232
233 return path;
234 }