]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCDKeys.c
configd-24.1.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 * 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 #include <SystemConfiguration/SystemConfiguration.h>
24
25 #include <stdarg.h>
26
27 /*
28 * SCDKeyCreate*
29 * - convenience routines that create a CFString key for an item in the cache
30 */
31
32 /*
33 * Function: SCDKeyCreate
34 * Purpose:
35 * Creates a cache key using the given format.
36 */
37 CFStringRef
38 SCDKeyCreate(CFStringRef fmt, ...)
39 {
40 va_list args;
41 va_start(args, fmt);
42 return (CFStringCreateWithFormatAndArguments(NULL,
43 NULL,
44 fmt,
45 args));
46 }
47
48 CFStringRef
49 SCDKeyCreateNetworkGlobalEntity(CFStringRef domain, CFStringRef entity)
50 {
51 return (CFStringCreateWithFormat(NULL,
52 NULL,
53 CFSTR("%@/%@/%@/%@"),
54 domain,
55 kSCCompNetwork,
56 kSCCompGlobal,
57 entity));
58 }
59
60 CFStringRef
61 SCDKeyCreateNetworkInterface(CFStringRef domain)
62 {
63 return (CFStringCreateWithFormat(NULL,
64 NULL,
65 CFSTR("%@/%@/%@"),
66 domain,
67 kSCCompNetwork,
68 kSCCompInterface));
69 }
70
71 CFStringRef
72 SCDKeyCreateNetworkInterfaceEntity(CFStringRef domain,
73 CFStringRef ifname,
74 CFStringRef entity)
75 {
76 if (entity == NULL) {
77 return (CFStringCreateWithFormat(NULL,
78 NULL,
79 CFSTR("%@/%@/%@/%@"),
80 domain,
81 kSCCompNetwork,
82 kSCCompInterface,
83 ifname));
84 } else {
85 return (CFStringCreateWithFormat(NULL,
86 NULL,
87 CFSTR("%@/%@/%@/%@/%@"),
88 domain,
89 kSCCompNetwork,
90 kSCCompInterface,
91 ifname,
92 entity));
93 }
94 }
95
96 CFStringRef
97 SCDKeyCreateNetworkServiceEntity(CFStringRef domain,
98 CFStringRef serviceID,
99 CFStringRef entity)
100 {
101 if (entity == NULL) {
102 return (CFStringCreateWithFormat(NULL,
103 NULL,
104 CFSTR("%@/%@/%@/%@"),
105 domain,
106 kSCCompNetwork,
107 kSCCompService,
108 serviceID));
109 } else {
110 return (CFStringCreateWithFormat(NULL,
111 NULL,
112 CFSTR("%@/%@/%@/%@/%@"),
113 domain,
114 kSCCompNetwork,
115 kSCCompService,
116 serviceID,
117 entity));
118 }
119 }