diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-05-01 14:35:21 +0200 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-05-05 20:48:20 +0200 |
commit | 284076982de7529585c4c13a663203588bff8b12 (patch) | |
tree | 07afe26cf4c823f0f20d24b6d95ec32dd5c90820 /apps/lib | |
parent | 6c0ac9b99f2b7278a5ec60ef0c29c71e9eb4f40d (diff) |
APPS: Slightly extend and improve documentation of the opt_ API
Also remove redundant opt_name() and make names of opt_{i,u}ntmax() consistent.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15111)
Diffstat (limited to 'apps/lib')
-rw-r--r-- | apps/lib/apps.c | 1 | ||||
-rw-r--r-- | apps/lib/opt.c | 29 |
2 files changed, 12 insertions, 18 deletions
diff --git a/apps/lib/apps.c b/apps/lib/apps.c index 81b543ec68..bfd938b555 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -3152,6 +3152,7 @@ void make_uppercase(char *string) string[i] = toupper((unsigned char)string[i]); } +/* This function is defined here due to visibility of bio_err */ int opt_printf_stderr(const char *fmt, ...) { va_list ap; diff --git a/apps/lib/opt.c b/apps/lib/opt.c index a6b6f7ce4f..4b75b46681 100644 --- a/apps/lib/opt.c +++ b/apps/lib/opt.c @@ -36,7 +36,6 @@ const char OPT_PARAM_STR[] = "-P"; static char **argv; static int argc; static int opt_index; -static char *param_name; static char *arg; static char *flag; static char *dunno; @@ -142,12 +141,12 @@ char *opt_progname(const char *argv0) } #endif -char *opt_appname(const char *arg0) +char *opt_appname(const char *argv0) { size_t len = strlen(prog); - if (arg0 != NULL) - BIO_snprintf(prog + len, sizeof(prog) - len - 1, " %s", arg0); + if (argv0 != NULL) + BIO_snprintf(prog + len, sizeof(prog) - len - 1, " %s", argv0); return prog; } @@ -456,7 +455,7 @@ int opt_int(const char *value, int *result) return 1; } -/* Parse and return a natural number, assuming range has been checked before. */ +/* Parse and return an integer, assuming range has been checked before. */ int opt_int_arg(void) { int result = -1; @@ -515,7 +514,7 @@ int opt_long(const char *value, long *result) !defined(OPENSSL_NO_INTTYPES_H) /* Parse an intmax_t, put it into *result; return 0 on failure, else 1. */ -int opt_imax(const char *value, intmax_t *result) +int opt_intmax(const char *value, intmax_t *result) { int oerrno = errno; intmax_t m; @@ -537,7 +536,7 @@ int opt_imax(const char *value, intmax_t *result) } /* Parse a uintmax_t, put it into *result; return 0 on failure, else 1. */ -int opt_umax(const char *value, uintmax_t *result) +int opt_uintmax(const char *value, uintmax_t *result) { int oerrno = errno; uintmax_t m; @@ -654,7 +653,7 @@ int opt_verify(int opt, X509_VERIFY_PARAM *vpm) X509_VERIFY_PARAM_set_auth_level(vpm, i); break; case OPT_V_ATTIME: - if (!opt_imax(opt_arg(), &t)) + if (!opt_intmax(opt_arg(), &t)) return 0; if (t != (time_t)t) { opt_printf_stderr("%s: epoch time out of range %s\n", @@ -768,7 +767,7 @@ int opt_next(void) /* Look at current arg; at end of the list? */ arg = NULL; - p = param_name = argv[opt_index]; + p = argv[opt_index]; if (p == NULL) return 0; @@ -850,11 +849,11 @@ int opt_next(void) } break; case 'M': - if (!opt_imax(arg, &imval)) + if (!opt_intmax(arg, &imval)) return -1; break; case 'U': - if (!opt_umax(arg, &umval)) + if (!opt_uintmax(arg, &umval)) return -1; break; case 'l': @@ -891,19 +890,13 @@ int opt_next(void) return -1; } -/* Return the name of the most recent flag parameter. */ -char *opt_name(void) -{ - return param_name; -} - /* Return the most recent flag parameter. */ char *opt_arg(void) { return arg; } -/* Return the most recent flag. */ +/* Return the most recent flag (option name including the preceding '-'). */ char *opt_flag(void) { return flag; |