void parse_args( int argc, char** argv ) { int i; for( i = 1; i < argc; i++ ) if( !strcmp(argv[i], "-h") || !strcmp(argv[i], "--help") ) { printf("%s", usage); exit(0); } else if( !strcmp(argv[i], "-v") || !strcmp(argv[i], "--version") ) { printf(CPABE_VERSION, "-enc"); exit(0); } else if( !strcmp(argv[i], "-k") || !strcmp(argv[i], "--keep-input-file") ) { keep = 1; } else if( !strcmp(argv[i], "-o") || !strcmp(argv[i], "--output") ) { if( ++i >= argc ) die(usage); else out_file = argv[i]; } else if( !strcmp(argv[i], "-d") || !strcmp(argv[i], "--deterministic") ) { pbc_random_set_deterministic(0); } else if( !pub_file ) { pub_file = argv[i]; } else if( !in_file ) { in_file = argv[i]; } else if( !policy ) { policy = parse_policy_lang(argv[i]); } else die(usage); if( !pub_file || !in_file ) die(usage); if( !out_file ) out_file = g_strdup_printf("%s.cpabe", in_file); if( !policy ) policy = parse_policy_lang(suck_stdin()); }
void parse_args( int argc, char** argv ) { int i; for( i = 1; i < argc; i++ ) if( !strcmp(argv[i], "-h") || !strcmp(argv[i], "--help") ) { printf("%s", usage); exit(0); } else if( !strcmp(argv[i], "-v") || !strcmp(argv[i], "--version") ) { printf(KPABE_VERSION, "-keygen"); exit(0); } else if( !strcmp(argv[i], "-o") || !strcmp(argv[i], "--output") ) { if( ++i >= argc ) die(usage); else out_file = argv[i]; } else if( !strcmp(argv[i], "-d") || !strcmp(argv[i], "--deterministic") ) { pbc_random_set_deterministic(0); } else if( !pub_file ) { pub_file = argv[i]; } else if( !msk_file ) { msk_file = argv[i]; } else if( !policy ) { policy = parse_policy_lang(argv[i]); } else die(usage); if( !pub_file || !msk_file ) die(usage); if( !policy ) policy = parse_policy_lang(suck_stdin()); }
void parse_args( int argc, char** argv ) { int i; for( i = 1; i < argc; i++ ) if( !strcmp(argv[i], "-h") || !strcmp(argv[i], "--help") ) { printf("%s", usage); exit(0); } else if( !strcmp(argv[i], "-v") || !strcmp(argv[i], "--version") ) { printf(CPABE_VERSION, "-setup"); exit(0); } else if( !strcmp(argv[i], "-p") || !strcmp(argv[i], "--output-public-key") ) { if( ++i >= argc ) die(usage); else pub_file = argv[i]; } else if( !strcmp(argv[i], "-m") || !strcmp(argv[i], "--output-master-key") ) { if( ++i >= argc ) die(usage); else msk_file = argv[i]; } else if( !strcmp(argv[i], "-d") || !strcmp(argv[i], "--deterministic") ) { pbc_random_set_deterministic(0); } else die(usage); }
void parse_args( int argc, char** argv ) { int i; for( i = 1; i < argc; i++ ) if( !strcmp(argv[i], "-h") || !strcmp(argv[i], "--help") ) { printf("%s", usage); exit(0); } else if( !strcmp(argv[i], "-v") || !strcmp(argv[i], "--version") ) { printf(CPABE_VERSION, "-dec"); exit(0); } else if( !strcmp(argv[i], "-k") || !strcmp(argv[i], "--keep-input-file") ) { keep = 1; } else if( !strcmp(argv[i], "-o") || !strcmp(argv[i], "--output") ) { if( ++i >= argc ) die(usage); else out_file = argv[i]; } else if( !strcmp(argv[i], "-d") || !strcmp(argv[i], "--deterministic") ) { pbc_random_set_deterministic(0); } /* else if( !strcmp(argv[i], "-s") || !strcmp(argv[i], "--no-opt-sat") ) */ /* { */ /* no_opt_sat = 1; */ /* } */ /* else if( !strcmp(argv[i], "-n") || !strcmp(argv[i], "--naive-dec") ) */ /* { */ /* dec_strategy = DEC_NAIVE; */ /* } */ /* else if( !strcmp(argv[i], "-f") || !strcmp(argv[i], "--flatten") ) */ /* { */ /* dec_strategy = DEC_FLATTEN; */ /* } */ /* else if( !strcmp(argv[i], "-r") || !strcmp(argv[i], "--report-ops") ) */ /* { */ /* report_ops = 1; */ /* } */ else if( !pub_file ) { pub_file = argv[i]; } else if( !prv_file ) { prv_file = argv[i]; } else if( !in_file ) { in_file = argv[i]; } else die(usage); if( !pub_file || !prv_file || !in_file ) die(usage); if( !out_file ) { if( strlen(in_file) > 6 && !strcmp(in_file + strlen(in_file) - 6, ".cpabe") ) out_file = g_strndup(in_file, strlen(in_file) - 6); else out_file = strdup(in_file); } if( keep && !strcmp(in_file, out_file) ) die("cannot keep input file when decrypting file in place (try -o)\n"); }
void parse_args( int argc, char** argv ) { int i; GSList* alist; GSList* ap; int n; alist = 0; for( i = 1; i < argc; i++ ) if( !strcmp(argv[i], "-h") || !strcmp(argv[i], "--help") ) { printf("%s", usage); exit(0); } else if( !strcmp(argv[i], "-v") || !strcmp(argv[i], "--version") ) { printf(KPABE_VERSION, "-enc"); exit(0); } else if( !strcmp(argv[i], "-k") || !strcmp(argv[i], "--keep-input-file") ) { keep = 1; } else if( !strcmp(argv[i], "-o") || !strcmp(argv[i], "--output") ) { if( ++i >= argc ) die(usage); else out_file = argv[i]; } else if( !strcmp(argv[i], "-d") || !strcmp(argv[i], "--deterministic") ) { pbc_random_set_deterministic(0); } else if( !pub_file ) { pub_file = argv[i]; } else if( !in_file ) { in_file = argv[i]; } else { parse_attribute(&alist, argv[i]); } if( !pub_file || !in_file || !alist ) die(usage); if( !out_file ) out_file = g_strdup_printf("%s.kpabe", in_file); alist = g_slist_sort(alist, comp_string); n = g_slist_length(alist); attrs = malloc((n + 1) * sizeof(char*)); i = 0; for( ap = alist; ap; ap = ap->next ) attrs[i++] = ap->data; attrs[i] = 0; }