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