]> git.saurik.com Git - apple/configd.git/blob - scutil.tproj/session.c
configd-53.1.tar.gz
[apple/configd.git] / scutil.tproj / session.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 /*
24 * Modification History
25 *
26 * June 1, 2001 Allan Nathanson <ajn@apple.com>
27 * - public API conversion
28 *
29 * November 9, 2000 Allan Nathanson <ajn@apple.com>
30 * - initial revision
31 */
32
33 #include "scutil.h"
34 #include "notify.h"
35
36 void
37 do_open(int argc, char **argv)
38 {
39 if (store) CFRelease(store);
40
41 store = SCDynamicStoreCreate(NULL, CFSTR("scutil"), storeCallback, NULL);
42 if (!store) {
43 SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError()));
44 return;
45 }
46
47 return;
48 }
49
50
51 void
52 do_close(int argc, char **argv)
53 {
54 if (notifyRls) {
55 CFRunLoopRemoveSource(CFRunLoopGetCurrent(), notifyRls, kCFRunLoopDefaultMode);
56 CFRelease(notifyRls);
57 notifyRls = NULL;
58 }
59
60 if (store) {
61 CFRelease(store);
62 store = NULL;
63 }
64 return;
65 }
66
67
68 void
69 do_lock(int argc, char **argv)
70 {
71 if (!SCDynamicStoreLock(store)) {
72 SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError()));
73 }
74 return;
75 }
76
77
78 void
79 do_unlock(int argc, char **argv)
80 {
81 if (!SCDynamicStoreUnlock(store)) {
82 SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError()));
83 }
84 return;
85 }