diff options
Diffstat (limited to 'apps/lib/opt.c')
-rw-r--r-- | apps/lib/opt.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/apps/lib/opt.c b/apps/lib/opt.c index 2b9c922135..2a80e7ebf4 100644 --- a/apps/lib/opt.c +++ b/apps/lib/opt.c @@ -26,9 +26,10 @@ #include <openssl/x509v3.h> #define MAX_OPT_HELP_WIDTH 30 -const char OPT_HELP_STR[] = "--"; -const char OPT_MORE_STR[] = "---"; -const char OPT_SECTION_STR[] = "----"; +const char OPT_HELP_STR[] = "-H"; +const char OPT_MORE_STR[] = "-M"; +const char OPT_SECTION_STR[] = "-S"; +const char OPT_PARAM_STR[] = "-P"; /* Our state */ static char **argv; @@ -128,7 +129,8 @@ char *opt_init(int ac, char **av, const OPTIONS *o) opt_progname(av[0]); unknown = NULL; - for (; o->name; ++o) { + /* Check all options up until the PARAM marker (if present) */ + for (; o->name != NULL && o->name != OPT_PARAM_STR; ++o) { #ifndef NDEBUG const OPTIONS *next; int duplicated, i; @@ -838,7 +840,7 @@ static const char *valtype2param(const OPTIONS *o) return "parm"; } -void opt_print(const OPTIONS *o, int width) +void opt_print(const OPTIONS *o, int doingparams, int width) { const char* help; char start[80 + 1]; @@ -854,6 +856,10 @@ void opt_print(const OPTIONS *o, int width) opt_printf_stderr(help, prog); return; } + if (o->name == OPT_PARAM_STR) { + opt_printf_stderr("\nParameters:\n"); + return; + } /* Pad out prefix */ memset(start, ' ', sizeof(start) - 1); @@ -869,7 +875,8 @@ void opt_print(const OPTIONS *o, int width) /* Build up the "-flag [param]" part. */ p = start; *p++ = ' '; - *p++ = '-'; + if (!doingparams) + *p++ = '-'; if (o->name[0]) p += strlen(strcpy(p, o->name)); else @@ -891,9 +898,8 @@ void opt_print(const OPTIONS *o, int width) void opt_help(const OPTIONS *list) { const OPTIONS *o; - int i; + int i, sawparams = 0, width = 5; int standard_prolog; - int width = 5; char start[80 + 1]; /* Starts with its own help message? */ @@ -919,7 +925,9 @@ void opt_help(const OPTIONS *list) /* Now let's print. */ for (o = list; o->name; o++) { - opt_print(o, width); + if (o->name == OPT_PARAM_STR) + sawparams = 1; + opt_print(o, sawparams, width); } } |