make action a multi-val
This commit is contained in:
+41
-33
@@ -568,6 +568,8 @@ int main(int argc, char *argv[]) {
|
||||
SCARDCONTEXT context;
|
||||
unsigned char key[KEY_LEN];
|
||||
int verbosity;
|
||||
enum enum_action action;
|
||||
unsigned int i;
|
||||
|
||||
if(cmdline_parser(argc, argv, &args_info) != 0) {
|
||||
return EXIT_FAILURE;
|
||||
@@ -591,48 +593,54 @@ int main(int argc, char *argv[]) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if(args_info.action_arg == action_arg_version) {
|
||||
print_version(&card, verbosity);
|
||||
} else if(args_info.action_arg == action_arg_generate) {
|
||||
if(args_info.slot_arg != slot__NULL) {
|
||||
generate_key(&card, args_info.slot_orig, args_info.algorithm_arg, verbosity);
|
||||
} else {
|
||||
fprintf(stderr, "The generate action needs a slot (-s) to operate on.\n");
|
||||
return EXIT_FAILURE;
|
||||
for(i = 0; i < args_info.action_given; i++) {
|
||||
action = *args_info.action_arg++;
|
||||
if(verbosity) {
|
||||
fprintf(stderr, "Now processing for action %d.\n", action);
|
||||
}
|
||||
} else if(args_info.action_arg == action_arg_setMINUS_mgmMINUS_key) {
|
||||
if(args_info.new_key_arg) {
|
||||
unsigned char new_key[KEY_LEN];
|
||||
if(parse_key(args_info.new_key_arg, new_key, verbosity) == false) {
|
||||
if(action == action_arg_version) {
|
||||
print_version(&card, verbosity);
|
||||
} else if(action == action_arg_generate) {
|
||||
if(args_info.slot_arg != slot__NULL) {
|
||||
generate_key(&card, args_info.slot_orig, args_info.algorithm_arg, verbosity);
|
||||
} else {
|
||||
fprintf(stderr, "The generate action needs a slot (-s) to operate on.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(set_mgm_key(&card, new_key, verbosity) == false) {
|
||||
} else if(action == action_arg_setMINUS_mgmMINUS_key) {
|
||||
if(args_info.new_key_arg) {
|
||||
unsigned char new_key[KEY_LEN];
|
||||
if(parse_key(args_info.new_key_arg, new_key, verbosity) == false) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(set_mgm_key(&card, new_key, verbosity) == false) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "The set-mgm-key action needs the new-key (-n) argument.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "The set-mgm-key action needs the new-key (-n) argument.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else if(args_info.action_arg == action_arg_reset) {
|
||||
if(reset(&card, verbosity) == false) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else if(args_info.action_arg == action_arg_pinMINUS_retries) {
|
||||
if(args_info.pin_retries_arg && args_info.puk_retries_arg) {
|
||||
if(set_pin_retries(&card, args_info.pin_retries_arg, args_info.puk_retries_arg, verbosity) == false) {
|
||||
} else if(action == action_arg_reset) {
|
||||
if(reset(&card, verbosity) == false) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else if(args_info.action_arg == action_arg_importMINUS_key) {
|
||||
if(args_info.slot_arg != slot__NULL) {
|
||||
if(import_key(&card, args_info.key_format_arg, args_info.input_arg, args_info.slot_orig, verbosity) == false) {
|
||||
} else if(action == action_arg_pinMINUS_retries) {
|
||||
if(args_info.pin_retries_arg && args_info.puk_retries_arg) {
|
||||
if(set_pin_retries(&card, args_info.pin_retries_arg, args_info.puk_retries_arg, verbosity) == false) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else if(action == action_arg_importMINUS_key) {
|
||||
if(args_info.slot_arg != slot__NULL) {
|
||||
if(import_key(&card, args_info.key_format_arg, args_info.input_arg, args_info.slot_orig, verbosity) == false) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "The generate action needs a slot (-s) to operate on.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "The generate action needs a slot (-s) to operate on.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user