]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCLocation.c
configd-53.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / SCLocation.c
1 /*
2 * Copyright (c) 2001 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 /*
24 * Modification History
25 *
26 * Nov 28, 2001 Allan Nathanson <ajn@apple.com>
27 * - initial revision
28 */
29
30 #include <SystemConfiguration/SystemConfiguration.h>
31 #include <SystemConfiguration/SCValidation.h>
32 #include <SystemConfiguration/SCPrivate.h>
33
34 CFStringRef
35 SCDynamicStoreKeyCreateLocation(CFAllocatorRef allocator)
36 {
37 return CFRetain(kSCDynamicStoreDomainSetup);
38 }
39
40
41 CFStringRef
42 SCDynamicStoreCopyLocation(SCDynamicStoreRef store)
43 {
44 CFDictionaryRef dict = NULL;
45 CFStringRef key;
46 CFStringRef location = NULL;
47 Boolean tempSession = FALSE;
48
49 if (!store) {
50 store = SCDynamicStoreCreate(NULL,
51 CFSTR("SCDynamicStoreCopyLocation"),
52 NULL,
53 NULL);
54 if (!store) {
55 SCLog(_sc_verbose, LOG_INFO, CFSTR("SCDynamicStoreCreate() failed"));
56 return NULL;
57 }
58 tempSession = TRUE;
59 }
60
61 key = SCDynamicStoreKeyCreateLocation(NULL);
62 dict = SCDynamicStoreCopyValue(store, key);
63 CFRelease(key);
64 if (!isA_CFDictionary(dict)) {
65 _SCErrorSet(kSCStatusNoKey);
66 goto done;
67 }
68
69 location = CFDictionaryGetValue(dict, kSCDynamicStorePropSetupCurrentSet);
70 if (!isA_CFString(location)) {
71 _SCErrorSet(kSCStatusNoKey);
72 goto done;
73 }
74
75 CFRetain(location);
76
77 done :
78
79 if (tempSession) CFRelease(store);
80 if (dict) CFRelease(dict);
81
82 return location;
83 }