]> git.saurik.com Git - apple/configd.git/blob - scutil.tproj/session.c
configd-24.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 #include "scutil.h"
24
25 void
26 do_open(int argc, char **argv)
27 {
28 SCDStatus status;
29
30 if (session != NULL) {
31 status = SCDClose(&session);
32 switch (status) {
33 case SCD_OK :
34 case SCD_NOSESSION :
35 /*
36 * if the "close" was successful or if we had an open
37 * session but can no talk to the server
38 */
39 break;
40 default :
41 SCDLog(LOG_INFO, CFSTR("SCDClose: %s"), SCDError(status));
42 return;
43 }
44 }
45
46 status = SCDOpen(&session, CFSTR("sc"));
47 if (status != SCD_OK) {
48 SCDLog(LOG_INFO, CFSTR("SCDOpen: %s"), SCDError(status));
49 return;
50 }
51
52 return;
53 }
54
55
56 void
57 do_close(int argc, char **argv)
58 {
59 SCDStatus status;
60
61 status = SCDClose(&session);
62 if (status != SCD_OK) {
63 SCDLog(LOG_INFO, CFSTR("SCDClose: %s"), SCDError(status));
64 }
65 return;
66 }
67
68
69 void
70 do_lock(int argc, char **argv)
71 {
72 SCDStatus status;
73
74 status = SCDLock(session);
75 if (status != SCD_OK) {
76 SCDLog(LOG_INFO, CFSTR("SCDLock: %s"), SCDError(status));
77 }
78 return;
79 }
80
81
82 void
83 do_unlock(int argc, char **argv)
84 {
85 SCDStatus status;
86
87 status = SCDUnlock(session);
88 if (status != SCD_OK) {
89 SCDLog(LOG_INFO, CFSTR("SCDUnlock: %s"), SCDError(status));
90 }
91 return;
92 }