]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/Tool/syncbackup.c
Security-57740.31.2.tar.gz
[apple/security.git] / OSX / sec / SOSCircle / Tool / syncbackup.c
1
2 /*
3 * Copyright (c) 2003-2007,2009-2010,2013-2016 Apple Inc. All Rights Reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 *
24 */
25
26 //
27 // syncbackup.c
28 // sec
29 //
30 //
31 //
32
33 #include "syncbackup.h"
34
35
36 #include <stdio.h>
37 #include <CoreFoundation/CoreFoundation.h>
38
39 #include <Security/SecureObjectSync/SOSCloudCircle.h>
40 #include <Security/SecureObjectSync/SOSCloudCircleInternal.h>
41
42 #include <utilities/SecCFWrappers.h>
43
44 #include <SecurityTool/readline.h>
45 #include "secToolFileIO.h"
46
47
48 static bool dumpBackupInfo(CFErrorRef *error) {
49 CFReleaseNull(*error);
50 bool isLast = SOSCCIsThisDeviceLastBackup(error);
51
52 printmsg(CFSTR("This %s the last backup peer.\n"), (isLast) ? "is": "isn't");
53 return *error != NULL;
54 }
55
56
57 int
58 syncbackup(int argc, char * const *argv)
59 {
60 /*
61 "Circle Backup Information"
62 " -i info (current status)"
63
64 */
65 setOutputTo(NULL, NULL);
66
67 int ch, result = 0;
68 CFErrorRef error = NULL;
69 bool hadError = false;
70
71 while ((ch = getopt(argc, argv, "i")) != -1)
72 switch (ch) {
73
74 case 'i':
75 hadError = dumpBackupInfo(&error);
76 break;
77
78 case '?':
79 default:
80 return 2; /* Return 2 triggers usage message. */
81 }
82
83 if (hadError)
84 printerr(CFSTR("Error: %@\n"), error);
85
86 return result;
87 }