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