diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-03-15 09:39:46 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-03-15 11:14:58 +0100 |
commit | 30eb0faa8d4894659cc90c76cc634148df86eab9 (patch) | |
tree | b6cfb44c28bf018c575f11720e28cda06d346063 /src/util/gnunet-ecc.c | |
parent | cd475225e4fd83fcc16b77ea1294c11428447209 (diff) | |
download | gnunet-30eb0faa8d4894659cc90c76cc634148df86eab9.tar.gz gnunet-30eb0faa8d4894659cc90c76cc634148df86eab9.zip |
getopt major style fix, remove macro-mania with nicer typed functions
Diffstat (limited to 'src/util/gnunet-ecc.c')
-rw-r--r-- | src/util/gnunet-ecc.c | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c index ddfd9b1c3..732228b52 100644 --- a/src/util/gnunet-ecc.c +++ b/src/util/gnunet-ecc.c | |||
@@ -41,7 +41,7 @@ static int list_keys; | |||
41 | /** | 41 | /** |
42 | * Flag for listing public key. | 42 | * Flag for listing public key. |
43 | */ | 43 | */ |
44 | static int list_keys_count; | 44 | static unsigned int list_keys_count; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Flag for printing public key. | 47 | * Flag for printing public key. |
@@ -406,36 +406,50 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
406 | * @return 0 ok, 1 on error | 406 | * @return 0 ok, 1 on error |
407 | */ | 407 | */ |
408 | int | 408 | int |
409 | main (int argc, char *const *argv) | 409 | main (int argc, |
410 | char *const *argv) | ||
410 | { | 411 | { |
411 | list_keys_count = UINT32_MAX; | 412 | list_keys_count = UINT32_MAX; |
412 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 413 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
413 | { 'i', "iterate", "FILE", | 414 | GNUNET_GETOPT_OPTION_SET_ONE ('i', |
414 | gettext_noop ("list keys included in a file (for testing)"), | 415 | "iterate", |
415 | 0, &GNUNET_GETOPT_set_one, &list_keys }, | 416 | gettext_noop ("list keys included in a file (for testing)"), |
416 | { 'e', "end=", "COUNT", | 417 | &list_keys), |
417 | gettext_noop ("number of keys to list included in a file (for testing)"), | 418 | GNUNET_GETOPT_OPTION_SET_UINT ('e', |
418 | 1, &GNUNET_GETOPT_set_uint, &list_keys_count }, | 419 | "end=", |
419 | { 'g', "generate-keys", "COUNT", | 420 | "COUNT", |
420 | gettext_noop ("create COUNT public-private key pairs (for testing)"), | 421 | gettext_noop ("number of keys to list included in a file (for testing)"), |
421 | 1, &GNUNET_GETOPT_set_uint, &make_keys }, | 422 | &list_keys_count), |
422 | { 'p', "print-public-key", NULL, | 423 | GNUNET_GETOPT_OPTION_SET_UINT ('g', |
423 | gettext_noop ("print the public key in ASCII format"), | 424 | "generate-keys", |
424 | 0, &GNUNET_GETOPT_set_one, &print_public_key }, | 425 | "COUNT", |
425 | { 'E', "examples", NULL, | 426 | gettext_noop ("create COUNT public-private key pairs (for testing)"), |
426 | gettext_noop ("print examples of ECC operations (used for compatibility testing)"), | 427 | &make_keys), |
427 | 0, &GNUNET_GETOPT_set_one, &print_examples_flag }, | 428 | GNUNET_GETOPT_OPTION_SET_ONE ('p', |
429 | "print-public-key", | ||
430 | gettext_noop ("print the public key in ASCII format"), | ||
431 | &print_public_key), | ||
432 | GNUNET_GETOPT_OPTION_SET_ONE ('E', | ||
433 | "examples", | ||
434 | gettext_noop ("print examples of ECC operations (used for compatibility testing)"), | ||
435 | &print_examples_flag), | ||
428 | GNUNET_GETOPT_OPTION_END | 436 | GNUNET_GETOPT_OPTION_END |
429 | }; | 437 | }; |
430 | int ret; | 438 | int ret; |
431 | 439 | ||
432 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 440 | if (GNUNET_OK != |
441 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
442 | &argc, &argv)) | ||
433 | return 2; | 443 | return 2; |
434 | 444 | ||
435 | ret = (GNUNET_OK == | 445 | ret = (GNUNET_OK == |
436 | GNUNET_PROGRAM_run (argc, argv, "gnunet-ecc [OPTIONS] keyfile [VANITY_PREFIX]", | 446 | GNUNET_PROGRAM_run (argc, |
447 | argv, | ||
448 | "gnunet-ecc [OPTIONS] keyfile [VANITY_PREFIX]", | ||
437 | gettext_noop ("Manipulate GNUnet private ECC key files"), | 449 | gettext_noop ("Manipulate GNUnet private ECC key files"), |
438 | options, &run, NULL)) ? 0 : 1; | 450 | options, |
451 | &run, | ||
452 | NULL)) ? 0 : 1; | ||
439 | GNUNET_free ((void*) argv); | 453 | GNUNET_free ((void*) argv); |
440 | return ret; | 454 | return ret; |
441 | } | 455 | } |