]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCDKeys.c
configd-293.5.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / SCDKeys.c
1 /*
2 * Copyright (c) 2000, 2001, 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 * June 1, 2001 Allan Nathanson <ajn@apple.com>
28 * - public API conversion
29 *
30 * December 11, 2000 Allan Nathanson <ajn@apple.com>
31 * - initial revision
32 */
33
34 #include <SystemConfiguration/SystemConfiguration.h>
35
36 #include <stdarg.h>
37
38 /*
39 * SCDynamicStoreKeyCreate*
40 * - convenience routines that create a CFString key for an item in the store
41 */
42
43 /*
44 * Function: SCDynamicStoreKeyCreate
45 * Purpose:
46 * Creates a store key using the given format.
47 */
48 CFStringRef
49 SCDynamicStoreKeyCreate(CFAllocatorRef allocator,
50 CFStringRef fmt,
51 ...)
52 {
53 va_list args;
54 va_start(args, fmt);
55 return (CFStringCreateWithFormatAndArguments(allocator,
56 NULL,
57 fmt,
58 args));
59 }
60
61 CFStringRef
62 SCDynamicStoreKeyCreateNetworkGlobalEntity(CFAllocatorRef allocator,
63 CFStringRef domain,
64 CFStringRef entity)
65 {
66 return (CFStringCreateWithFormat(allocator,
67 NULL,
68 CFSTR("%@/%@/%@/%@"),
69 domain,
70 kSCCompNetwork,
71 kSCCompGlobal,
72 entity));
73 }
74
75 CFStringRef
76 SCDynamicStoreKeyCreateNetworkInterface(CFAllocatorRef allocator,
77 CFStringRef domain)
78 {
79 return (CFStringCreateWithFormat(allocator,
80 NULL,
81 CFSTR("%@/%@/%@"),
82 domain,
83 kSCCompNetwork,
84 kSCCompInterface));
85 }
86
87 CFStringRef
88 SCDynamicStoreKeyCreateNetworkInterfaceEntity(CFAllocatorRef allocator,
89 CFStringRef domain,
90 CFStringRef ifname,
91 CFStringRef entity)
92 {
93 if (entity == NULL) {
94 return (CFStringCreateWithFormat(allocator,
95 NULL,
96 CFSTR("%@/%@/%@/%@"),
97 domain,
98 kSCCompNetwork,
99 kSCCompInterface,
100 ifname));
101 } else {
102 return (CFStringCreateWithFormat(allocator,
103 NULL,
104 CFSTR("%@/%@/%@/%@/%@"),
105 domain,
106 kSCCompNetwork,
107 kSCCompInterface,
108 ifname,
109 entity));
110 }
111 }
112
113 CFStringRef
114 SCDynamicStoreKeyCreateNetworkServiceEntity(CFAllocatorRef allocator,
115 CFStringRef domain,
116 CFStringRef serviceID,
117 CFStringRef entity)
118 {
119 if (entity == NULL) {
120 return (CFStringCreateWithFormat(allocator,
121 NULL,
122 CFSTR("%@/%@/%@/%@"),
123 domain,
124 kSCCompNetwork,
125 kSCCompService,
126 serviceID));
127 } else {
128 return (CFStringCreateWithFormat(allocator,
129 NULL,
130 CFSTR("%@/%@/%@/%@/%@"),
131 domain,
132 kSCCompNetwork,
133 kSCCompService,
134 serviceID,
135 entity));
136 }
137 }