diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-04-03 16:03:21 +0200 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-05-20 16:31:22 +0200 |
commit | 601fe8e0d78d4344445cbfa83dbe9bc4ad1287f1 (patch) | |
tree | 30c37069498aa84f8ae4f5bb75ea5ab7c6fb6bb1 /apps | |
parent | 41d331b6f02267dbaa24cf35b9810994199431f4 (diff) |
APPS: Allow non-option parameters appear anywhere in list, marking them OPT_PARAM
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15126)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/include/opt.h | 2 | ||||
-rw-r--r-- | apps/lib/opt.c | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/apps/include/opt.h b/apps/include/opt.h index 5d85877301..213e41b83b 100644 --- a/apps/include/opt.h +++ b/apps/include/opt.h @@ -316,6 +316,8 @@ typedef struct options_st { int valtype; const char *helpstr; } OPTIONS; +/* Special retval values: */ +#define OPT_PARAM 0 /* same as OPT_EOF usually defined in apps */ /* * A string/int pairing; widely use for option value lookup, hence the diff --git a/apps/lib/opt.c b/apps/lib/opt.c index 4b75b46681..b0ec265aa9 100644 --- a/apps/lib/opt.c +++ b/apps/lib/opt.c @@ -184,9 +184,13 @@ char *opt_init(int ac, char **av, const OPTIONS *o) /* Make sure options are legit. */ OPENSSL_assert(o->name[0] != '-'); - OPENSSL_assert(o->retval > 0); + if (o->valtype == '.') + OPENSSL_assert(o->retval == OPT_PARAM); + else + OPENSSL_assert(o->retval > OPT_PARAM); switch (i) { - case 0: case '-': case '/': case '<': case '>': case 'E': case 'F': + case 0: case '-': case '.': + case '/': case '<': case '>': case 'E': case 'F': case 'M': case 'U': case 'f': case 'l': case 'n': case 'p': case 's': case 'u': case 'c': case ':': case 'N': break; @@ -821,6 +825,9 @@ int opt_next(void) case ':': /* Just a string. */ break; + case '.': + /* Parameters */ + break; case '/': if (opt_isdir(arg) > 0) break; |