X-Git-Url: https://iam.tj/gitweb/gitweb.cgi?p=cfe_generate_password.git;a=blobdiff_plain;f=cfe_generate_password.c;h=c1378e4612236dff37050d8f52fab3ab87963e19;hp=6331dbd1a3c0266e31dc28a0f8c287e9695ad502;hb=c9491adc74fd8da84ba0be76b1fefeac5b7488d5;hpb=43b4a2bde34a377b9d4f54e781beed8a7742e1f2 diff --git a/cfe_generate_password.c b/cfe_generate_password.c index 6331dbd..c1378e4 100644 --- a/cfe_generate_password.c +++ b/cfe_generate_password.c @@ -1,6 +1,7 @@ static const char *title = \ "Generate Broadcom CFE seeds and passwords for many popular modem/router devices\n" ; +static const float VERSION = 1.3f; static const char *copyright = \ "Copyright 2015 TJ \n" @@ -67,7 +68,6 @@ static const char *help = \ #include #include -static const float VERSION = 1.3f; static const size_t TIMESTAMP_SIZE = 8; static const size_t SEED_SIZE = 12; static const size_t PASSWORD_SIZE = 8; @@ -76,9 +76,9 @@ static const size_t MAC_ADDR_SIZE = 17; static const size_t DATESTRING_SIZE = 20; static void -pr_usage() +pr_usage(int verbose) { - fprintf(stderr, "%s\n", + fprintf(stderr, "Usage:\n" " -v show version\n" " -s 00:01:02:03:04:05 create seed from MAC address\n" @@ -87,6 +87,9 @@ pr_usage() " E.g. -s 01:02:03:04:05 \n" " -s 01:02:03:04:05 -p\n" " -p 000000030405\n" + "\n" + "%s", + verbose ? help : "" ); } @@ -103,7 +106,7 @@ pr_error_exit(unsigned int usage, const char *error, ...) va_end(args); fprintf(stderr, "Error: %s\n", error_message); - if (usage) pr_usage(); + if (usage) pr_usage(usage); exit(EXIT_FAILURE); } @@ -174,7 +177,7 @@ main(int argc, char **argv, char **env) int result = 0; if (argc == 1) { - pr_usage(); + pr_usage(0); } else { unsigned int arg; @@ -226,7 +229,7 @@ main(int argc, char **argv, char **env) } } if (! opt_seed && ! opt_pass) - pr_usage(); + pr_usage(0); else if (opt_seed && opt_seed != 2) pr_error_exit(1, "seed requires MAC-ADDRESS"); else if (! opt_seed && opt_pass && opt_pass != 2)