2 // keychain_sync_test.c
5 // Created by Mitch Adler on 7/8/16.
9 #include "keychain_sync_test.h"
11 #include "secToolFileIO.h"
17 #import <Foundation/Foundation.h>
19 #include <Security/SecureObjectSync/SOSCloudCircle.h>
21 #import "NSFileHandle+Formatting.h"
24 keychain_sync_test(int argc, char * const *argv)
26 NSFileHandle *fhout = [NSFileHandle fileHandleWithStandardOutput];
27 NSFileHandle *fherr = [NSFileHandle fileHandleWithStandardError];
29 "Keychain Syncing test"
34 CFErrorRef cfError = NULL;
36 static int verbose_flag = 0;
37 static struct option long_options[] =
39 /* These options set a flag. */
40 {"verbose", no_argument, &verbose_flag, 1},
41 {"brief", no_argument, &verbose_flag, 0},
42 /* These options don’t set a flag.
43 We distinguish them by their indices. */
44 {"enabled-peer-views", required_argument, 0, 'p'},
47 static const char * params = "abc:d:f:";
49 /* getopt_long stores the option index here. */
52 NSArray<NSString*>* viewList = nil;
55 while (opt_result != -1) {
56 opt_result = getopt_long (argc, argv, params, long_options, &option_index);
59 NSString* parameter = [NSString stringWithCString: optarg encoding:NSUTF8StringEncoding];
61 viewList = [parameter componentsSeparatedByString:@","];
74 CFBooleanRef result = SOSCCPeersHaveViewsEnabled((__bridge CFArrayRef) viewList, &cfError);
76 [fhout writeFormat: @"Views: %@\n", viewList];
77 [fhout writeFormat: @"Enabled on other peers: %@\n", CFBooleanGetValue(result) ? @"yes" : @"no"];
81 if (cfError != NULL) {
82 [fherr writeFormat: @"Error: %@\n", cfError];
86 [fherr writeFormat: @"Error: %@\n", error];