do not use global variables app_name, options and option_help so they
can be static git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3188 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
b0bc6df80c
commit
be309330e5
|
@ -353,7 +353,7 @@ int main(int argc, char *const argv[])
|
|||
switch (c) {
|
||||
case 'h':
|
||||
case '?':
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
case 'r':
|
||||
opt_reader = atoi(optarg);
|
||||
break;
|
||||
|
|
|
@ -1099,7 +1099,7 @@ int main(int argc, char * const argv[])
|
|||
if (c == -1)
|
||||
break;
|
||||
if (c == '?')
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
switch (c) {
|
||||
case 'l':
|
||||
do_list_keys = 1;
|
||||
|
@ -1161,7 +1161,7 @@ int main(int argc, char * const argv[])
|
|||
}
|
||||
}
|
||||
if (action_count == 0)
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
|
||||
memset(&ctx_param, 0, sizeof(ctx_param));
|
||||
ctx_param.ver = 0;
|
||||
|
|
|
@ -1543,7 +1543,7 @@ int main(int argc, char * const argv[])
|
|||
if (c == -1)
|
||||
break;
|
||||
if (c == '?')
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
switch (c) {
|
||||
case 'r':
|
||||
opt_reader = atoi(optarg);
|
||||
|
|
|
@ -392,7 +392,7 @@ int main(int argc, char * const argv[])
|
|||
if (c == -1)
|
||||
break;
|
||||
if (c == '?')
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
switch (c) {
|
||||
case 'l':
|
||||
do_list_readers = 1;
|
||||
|
@ -446,7 +446,7 @@ int main(int argc, char * const argv[])
|
|||
}
|
||||
}
|
||||
if (action_count == 0)
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
|
||||
memset(&ctx_param, 0, sizeof(ctx_param));
|
||||
ctx_param.ver = 0;
|
||||
|
|
|
@ -378,7 +378,7 @@ int main(int argc, char * const argv[])
|
|||
if (c == -1)
|
||||
break;
|
||||
if (c == '?')
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
switch (c) {
|
||||
case OPT_SERIAL:
|
||||
do_print_serial = 1;
|
||||
|
@ -439,7 +439,7 @@ int main(int argc, char * const argv[])
|
|||
}
|
||||
}
|
||||
if (action_count == 0)
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
|
||||
CRYPTO_malloc_init();
|
||||
ERR_load_crypto_strings();
|
||||
|
|
|
@ -337,7 +337,7 @@ int main(int argc, char * argv[])
|
|||
new_object_id_len = sizeof(new_object_id);
|
||||
if (!hex_to_bin(optarg, new_object_id, &new_object_id_len)) {
|
||||
printf("Invalid ID \"%s\"\n", optarg);
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
action_count++;
|
||||
break;
|
||||
|
@ -356,14 +356,14 @@ int main(int argc, char * argv[])
|
|||
opt_object_class = CKO_DATA;
|
||||
else {
|
||||
printf("Unsupported object type \"%s\"\n", optarg);
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
opt_object_id_len = sizeof(opt_object_id);
|
||||
if (!hex_to_bin(optarg, opt_object_id, &opt_object_id_len)) {
|
||||
printf("Invalid ID \"%s\"\n", optarg);
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
|
@ -444,11 +444,11 @@ int main(int argc, char * argv[])
|
|||
opt_is_private = 1;
|
||||
break;
|
||||
default:
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
}
|
||||
if (action_count == 0)
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
/* ERR_load_crypto_strings(); */
|
||||
|
|
|
@ -493,7 +493,7 @@ int main(int argc, char * const argv[])
|
|||
if (c == -1)
|
||||
break;
|
||||
if (c == '?')
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
switch (c) {
|
||||
case 's':
|
||||
do_sign++;
|
||||
|
@ -552,7 +552,7 @@ int main(int argc, char * const argv[])
|
|||
}
|
||||
}
|
||||
if (action_count == 0)
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
|
||||
memset(&ctx_param, 0, sizeof(ctx_param));
|
||||
ctx_param.ver = 0;
|
||||
|
|
|
@ -349,14 +349,14 @@ main(int argc, char **argv)
|
|||
parse_commandline(argc, argv);
|
||||
|
||||
if (optind != argc)
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
if (opt_actions == 0) {
|
||||
fprintf(stderr, "No action specified.\n");
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
if (!opt_profile) {
|
||||
fprintf(stderr, "No profile specified.\n");
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
|
||||
/* Connect to the card */
|
||||
|
@ -2371,7 +2371,7 @@ handle_option(const struct option *opt)
|
|||
opt_format = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
case 'i':
|
||||
opt_objectid = optarg;
|
||||
break;
|
||||
|
@ -2457,7 +2457,7 @@ handle_option(const struct option *opt)
|
|||
opt_cert_label = optarg;
|
||||
break;
|
||||
default:
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
|
||||
if ((opt_actions & (1 << this_action)) && opt->has_arg != no_argument) {
|
||||
|
@ -2467,7 +2467,7 @@ handle_option(const struct option *opt)
|
|||
if (isprint(opt->val))
|
||||
fprintf(stderr, " -%c", opt->val);
|
||||
fprintf(stderr, " more than once.\n");
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
if (this_action)
|
||||
opt_actions |= (1 << this_action);
|
||||
|
@ -2476,7 +2476,7 @@ handle_option(const struct option *opt)
|
|||
fprintf(stderr, "Error: "
|
||||
"The --no-so-pin option and --so-pin/--so-puk are mutually\n"
|
||||
"exclusive.\n");
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2550,7 +2550,7 @@ read_options_file(const char *filename)
|
|||
break;
|
||||
if (!o->name) {
|
||||
error("Unknown option \"%s\"\n", name);
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
if (o->has_arg != no_argument) {
|
||||
optarg = strtok(NULL, "");
|
||||
|
@ -2563,7 +2563,7 @@ read_options_file(const char *filename)
|
|||
if (o->has_arg == required_argument
|
||||
&& (!optarg || !*optarg)) {
|
||||
error("Option %s: missing argument\n", name);
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
}
|
||||
handle_option(o);
|
||||
name = strtok(NULL, " \t");
|
||||
|
|
|
@ -1201,7 +1201,7 @@ int main(int argc, char * const argv[])
|
|||
if (c == -1)
|
||||
break;
|
||||
if (c == '?')
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
switch (c) {
|
||||
case 'r':
|
||||
opt_cert = optarg;
|
||||
|
@ -1291,7 +1291,7 @@ int main(int argc, char * const argv[])
|
|||
}
|
||||
}
|
||||
if (action_count == 0)
|
||||
print_usage_and_die();
|
||||
print_usage_and_die(app_name, options, option_help);
|
||||
|
||||
memset(&ctx_param, 0, sizeof(ctx_param));
|
||||
ctx_param.ver = 0;
|
||||
|
|
|
@ -148,7 +148,8 @@ void hex_dump_asc(FILE *f, const u8 *in, size_t count, int addr)
|
|||
}
|
||||
}
|
||||
|
||||
void print_usage_and_die(void)
|
||||
void print_usage_and_die(const char *app_name, const struct option options[],
|
||||
const char *option_help[])
|
||||
{
|
||||
int i = 0;
|
||||
printf("Usage: %s [OPTIONS]\nOptions:\n", app_name);
|
||||
|
|
|
@ -23,14 +23,11 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const struct option options[];
|
||||
extern const char *option_help[];
|
||||
extern const char *app_name;
|
||||
|
||||
void print_binary(FILE *f, const u8 *buf, int count);
|
||||
void hex_dump(FILE *f, const u8 *in, int len, const char *sep);
|
||||
void hex_dump_asc(FILE *f, const u8 *in, size_t count, int addr);
|
||||
void print_usage_and_die(void);
|
||||
void print_usage_and_die(const char *app_name, const struct option options[],
|
||||
const char *option_help[]);
|
||||
const char * acl_to_str(const struct sc_acl_entry *e);
|
||||
void warn(const char *fmt, ...);
|
||||
void error(const char *fmt, ...);
|
||||
|
|
Loading…
Reference in New Issue