[openssl] master update
dev at ddvo.net
dev at ddvo.net
Wed May 5 18:49:00 UTC 2021
The branch master has been updated
via b0f960189b8696f878b163d7123afdb99dfdb738 (commit)
via 284076982de7529585c4c13a663203588bff8b12 (commit)
from 6c0ac9b99f2b7278a5ec60ef0c29c71e9eb4f40d (commit)
- Log -----------------------------------------------------------------
commit b0f960189b8696f878b163d7123afdb99dfdb738
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date: Sat May 1 15:29:00 2021 +0200
APPS: Replace 'OPT_ERR = -1, OPT_EOF = 0, OPT_HELP' by OPT_COMMON macro
Reviewed-by: Tomas Mraz <tomas at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15111)
commit 284076982de7529585c4c13a663203588bff8b12
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date: Sat May 1 14:35:21 2021 +0200
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 at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15111)
-----------------------------------------------------------------------
Summary of changes:
apps/asn1pars.c | 2 +-
apps/ca.c | 2 +-
apps/ciphers.c | 2 +-
apps/cmp.c | 6 +--
apps/cms.c | 2 +-
apps/crl.c | 2 +-
apps/crl2p7.c | 2 +-
apps/dgst.c | 3 +-
apps/dhparam.c | 2 +-
apps/dsa.c | 2 +-
apps/dsaparam.c | 2 +-
apps/ec.c | 2 +-
apps/ecparam.c | 2 +-
apps/enc.c | 2 +-
apps/engine.c | 2 +-
apps/fipsinstall.c | 2 +-
apps/gendsa.c | 2 +-
apps/genpkey.c | 2 +-
apps/genrsa.c | 2 +-
apps/include/opt.h | 54 ++++++++++++-----------
apps/info.c | 2 +-
apps/kdf.c | 2 +-
apps/lib/apps.c | 1 +
apps/lib/opt.c | 29 +++++--------
apps/list.c | 3 +-
apps/mac.c | 2 +-
apps/nseq.c | 2 +-
apps/ocsp.c | 2 +-
apps/passwd.c | 2 +-
apps/pkcs12.c | 2 +-
apps/pkcs7.c | 2 +-
apps/pkcs8.c | 2 +-
apps/pkey.c | 2 +-
apps/pkeyparam.c | 2 +-
apps/pkeyutl.c | 2 +-
apps/prime.c | 2 +-
apps/rand.c | 2 +-
apps/rehash.c | 2 +-
apps/req.c | 2 +-
apps/rsa.c | 2 +-
apps/rsautl.c | 2 +-
apps/s_client.c | 2 +-
apps/s_server.c | 3 +-
apps/s_time.c | 2 +-
apps/sess_id.c | 2 +-
apps/smime.c | 2 +-
apps/speed.c | 2 +-
apps/spkac.c | 2 +-
apps/srp.c | 2 +-
apps/storeutl.c | 3 +-
apps/ts.c | 2 +-
apps/verify.c | 2 +-
apps/version.c | 2 +-
apps/x509.c | 4 +-
doc/internal/man3/OPTIONS.pod | 99 +++++++++++++++++++++++++++----------------
test/ecstresstest.c | 4 +-
56 files changed, 165 insertions(+), 134 deletions(-)
diff --git a/apps/asn1pars.c b/apps/asn1pars.c
index 798e8d1668..95a21a04f4 100644
--- a/apps/asn1pars.c
+++ b/apps/asn1pars.c
@@ -19,7 +19,7 @@
#include <openssl/asn1t.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_IN, OPT_OUT, OPT_INDENT, OPT_NOOUT,
OPT_OID, OPT_OFFSET, OPT_LENGTH, OPT_DUMP, OPT_DLIMIT,
OPT_STRPARSE, OPT_GENSTR, OPT_GENCONF, OPT_STRICTPEM,
diff --git a/apps/ca.c b/apps/ca.c
index 4f125b22a9..9dd46e4f5c 100755
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -143,7 +143,7 @@ static int preserve = 0;
static int msie_hack = 0;
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_ENGINE, OPT_VERBOSE, OPT_CONFIG, OPT_NAME, OPT_SUBJ, OPT_UTF8,
OPT_CREATE_SERIAL, OPT_MULTIVALUE_RDN, OPT_STARTDATE, OPT_ENDDATE,
OPT_DAYS, OPT_MD, OPT_POLICY, OPT_KEYFILE, OPT_KEYFORM, OPT_PASSIN,
diff --git a/apps/ciphers.c b/apps/ciphers.c
index dd70f0c632..6e4fedd9a7 100644
--- a/apps/ciphers.c
+++ b/apps/ciphers.c
@@ -17,7 +17,7 @@
#include "s_apps.h"
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_STDNAME,
OPT_CONVERT,
OPT_SSL3,
diff --git a/apps/cmp.c b/apps/cmp.c
index 51dd971162..fdd0043311 100644
--- a/apps/cmp.c
+++ b/apps/cmp.c
@@ -188,7 +188,7 @@ static int opt_accept_raverified = 0;
static X509_VERIFY_PARAM *vpm = NULL;
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_CONFIG, OPT_SECTION, OPT_VERBOSITY,
OPT_CMD, OPT_INFOTYPE, OPT_GENINFO,
@@ -2188,10 +2188,10 @@ static char *opt_str(void)
if (arg[0] == '\0') {
CMP_warn1("%s option argument is empty string, resetting option",
- opt_name());
+ opt_flag());
arg = NULL;
} else if (arg[0] == '-') {
- CMP_warn1("%s option argument starts with hyphen", opt_name());
+ CMP_warn1("%s option argument starts with hyphen", opt_flag());
}
return arg;
}
diff --git a/apps/cms.c b/apps/cms.c
index 88b70fc67f..e512f1d3e8 100644
--- a/apps/cms.c
+++ b/apps/cms.c
@@ -61,7 +61,7 @@ struct cms_key_param_st {
};
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_ENCRYPT,
OPT_DECRYPT, OPT_SIGN, OPT_CADES, OPT_SIGN_RECEIPT, OPT_RESIGN,
OPT_VERIFY, OPT_VERIFY_RETCODE, OPT_VERIFY_RECEIPT,
diff --git a/apps/crl.c b/apps/crl.c
index 8a0dc3605d..8f1babde6f 100644
--- a/apps/crl.c
+++ b/apps/crl.c
@@ -19,7 +19,7 @@
#include <openssl/pem.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_IN, OPT_OUTFORM, OPT_OUT, OPT_KEYFORM, OPT_KEY,
OPT_ISSUER, OPT_LASTUPDATE, OPT_NEXTUPDATE, OPT_FINGERPRINT,
OPT_CRLNUMBER, OPT_BADSIG, OPT_GENDELTA, OPT_CAPATH, OPT_CAFILE, OPT_CASTORE,
diff --git a/apps/crl2p7.c b/apps/crl2p7.c
index 42c18555bb..fe59e65427 100644
--- a/apps/crl2p7.c
+++ b/apps/crl2p7.c
@@ -22,7 +22,7 @@
static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_NOCRL, OPT_CERTFILE,
OPT_PROV_ENUM
} OPTION_CHOICE;
diff --git a/apps/dgst.c b/apps/dgst.c
index 13a4e0773b..fcc7fc8679 100644
--- a/apps/dgst.c
+++ b/apps/dgst.c
@@ -36,7 +36,8 @@ struct doall_dgst_digests {
};
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_LIST,
+ OPT_COMMON,
+ OPT_LIST,
OPT_C, OPT_R, OPT_OUT, OPT_SIGN, OPT_PASSIN, OPT_VERIFY,
OPT_PRVERIFY, OPT_SIGNATURE, OPT_KEYFORM, OPT_ENGINE, OPT_ENGINE_IMPL,
OPT_HEX, OPT_BINARY, OPT_DEBUG, OPT_FIPS_FINGERPRINT,
diff --git a/apps/dhparam.c b/apps/dhparam.c
index b43935eb7f..5bb4b7f04a 100644
--- a/apps/dhparam.c
+++ b/apps/dhparam.c
@@ -34,7 +34,7 @@ static EVP_PKEY *dsa_to_dh(EVP_PKEY *dh);
static int gendh_cb(EVP_PKEY_CTX *ctx);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT,
OPT_ENGINE, OPT_CHECK, OPT_TEXT, OPT_NOOUT,
OPT_DSAPARAM, OPT_2, OPT_3, OPT_5,
diff --git a/apps/dsa.c b/apps/dsa.c
index 9a7bf04adb..c00673a8ac 100644
--- a/apps/dsa.c
+++ b/apps/dsa.c
@@ -33,7 +33,7 @@
#endif
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_ENGINE,
/* Do not change the order here; see case statements below */
OPT_PVK_NONE, OPT_PVK_WEAK, OPT_PVK_STRONG,
diff --git a/apps/dsaparam.c b/apps/dsaparam.c
index a38dceb255..c78d28ecb1 100644
--- a/apps/dsaparam.c
+++ b/apps/dsaparam.c
@@ -27,7 +27,7 @@ static int verbose = 0;
static int gendsa_cb(EVP_PKEY_CTX *ctx);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT,
OPT_NOOUT, OPT_GENKEY, OPT_ENGINE, OPT_VERBOSE,
OPT_R_ENUM, OPT_PROV_ENUM
diff --git a/apps/ec.c b/apps/ec.c
index f8f77dd492..379c6b6132 100644
--- a/apps/ec.c
+++ b/apps/ec.c
@@ -22,7 +22,7 @@
#include "ec_common.h"
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_IN, OPT_OUT,
OPT_NOOUT, OPT_TEXT, OPT_PARAM_OUT, OPT_PUBIN, OPT_PUBOUT,
OPT_PASSIN, OPT_PASSOUT, OPT_PARAM_ENC, OPT_CONV_FORM, OPT_CIPHER,
diff --git a/apps/ecparam.c b/apps/ecparam.c
index c99b8cc909..e9e36d1d8b 100644
--- a/apps/ecparam.c
+++ b/apps/ecparam.c
@@ -22,7 +22,7 @@
#include "ec_common.h"
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT,
OPT_CHECK, OPT_LIST_CURVES, OPT_NO_SEED, OPT_NOOUT, OPT_NAME,
OPT_CONV_FORM, OPT_PARAM_ENC, OPT_GENKEY, OPT_ENGINE, OPT_CHECK_NAMED,
diff --git a/apps/enc.c b/apps/enc.c
index 217526f450..4339ba4114 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -39,7 +39,7 @@ struct doall_enc_ciphers {
};
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_LIST,
OPT_E, OPT_IN, OPT_OUT, OPT_PASS, OPT_ENGINE, OPT_D, OPT_P, OPT_V,
OPT_NOPAD, OPT_SALT, OPT_NOSALT, OPT_DEBUG, OPT_UPPER_P, OPT_UPPER_A,
diff --git a/apps/engine.c b/apps/engine.c
index b494a79447..b132bb7608 100644
--- a/apps/engine.c
+++ b/apps/engine.c
@@ -23,7 +23,7 @@
#include <openssl/store.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_C, OPT_T, OPT_TT, OPT_PRE, OPT_POST,
OPT_V = 100, OPT_VV, OPT_VVV, OPT_VVVV
} OPTION_CHOICE;
diff --git a/apps/fipsinstall.c b/apps/fipsinstall.c
index 651df6250f..6a104e60aa 100644
--- a/apps/fipsinstall.c
+++ b/apps/fipsinstall.c
@@ -33,7 +33,7 @@ static int self_test_log = 1;
static int quiet = 0;
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_IN, OPT_OUT, OPT_MODULE,
OPT_PROV_NAME, OPT_SECTION_NAME, OPT_MAC_NAME, OPT_MACOPT, OPT_VERIFY,
OPT_NO_LOG, OPT_CORRUPT_DESC, OPT_CORRUPT_TYPE, OPT_QUIET, OPT_CONFIG,
diff --git a/apps/gendsa.c b/apps/gendsa.c
index 38d7b4a3eb..6d1c91d230 100644
--- a/apps/gendsa.c
+++ b/apps/gendsa.c
@@ -23,7 +23,7 @@
#include <openssl/pem.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_CIPHER, OPT_VERBOSE,
OPT_R_ENUM, OPT_PROV_ENUM
} OPTION_CHOICE;
diff --git a/apps/genpkey.c b/apps/genpkey.c
index 746cd5902f..f10390e1ba 100644
--- a/apps/genpkey.c
+++ b/apps/genpkey.c
@@ -20,7 +20,7 @@ static int init_keygen_file(EVP_PKEY_CTX **pctx, const char *file, ENGINE *e,
static int genpkey_cb(EVP_PKEY_CTX *ctx);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_ENGINE, OPT_OUTFORM, OPT_OUT, OPT_PASS, OPT_PARAMFILE,
OPT_ALGORITHM, OPT_PKEYOPT, OPT_GENPARAM, OPT_TEXT, OPT_CIPHER,
OPT_CONFIG,
diff --git a/apps/genrsa.c b/apps/genrsa.c
index e5118d4902..0e84687b32 100644
--- a/apps/genrsa.c
+++ b/apps/genrsa.c
@@ -32,7 +32,7 @@ static int verbose = 0;
static int genrsa_cb(EVP_PKEY_CTX *ctx);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
#ifndef OPENSSL_NO_DEPRECATED_3_0
OPT_3,
#endif
diff --git a/apps/include/opt.h b/apps/include/opt.h
index f22e9af05e..c6ec09f882 100644
--- a/apps/include/opt.h
+++ b/apps/include/opt.h
@@ -14,6 +14,8 @@
#include <openssl/types.h>
#include <stdarg.h>
+#define OPT_COMMON OPT_ERR = -1, OPT_EOF = 0, OPT_HELP
+
/*
* Common verification options.
*/
@@ -342,46 +344,50 @@ typedef struct string_int_pair_st {
#define OPT_PARAMETERS() { OPT_PARAM_STR, 1, '-', "Parameters:\n" }
const char *opt_path_end(const char *filename);
+char *opt_init(int ac, char **av, const OPTIONS * o);
char *opt_progname(const char *argv0);
-char *opt_appname(const char *arg0);
+char *opt_appname(const char *argv0);
char *opt_getprog(void);
-char *opt_init(int ac, char **av, const OPTIONS * o);
-int opt_next(void);
+void opt_help(const OPTIONS * list);
+
void opt_begin(void);
-int opt_format(const char *s, unsigned long flags, int *result);
+int opt_next(void);
+char *opt_flag(void);
+char *opt_arg(void);
+char *opt_unknown(void);
+int opt_cipher(const char *name, EVP_CIPHER **cipherp);
+int opt_cipher_silent(const char *name, EVP_CIPHER **cipherp);
+int opt_md(const char *name, EVP_MD **mdp);
+int opt_md_silent(const char *name, EVP_MD **mdp);
+
int opt_int(const char *arg, int *result);
int opt_int_arg(void);
-int opt_ulong(const char *arg, unsigned long *result);
int opt_long(const char *arg, long *result);
+int opt_ulong(const char *arg, unsigned long *result);
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \
defined(INTMAX_MAX) && defined(UINTMAX_MAX) && \
!defined(OPENSSL_NO_INTTYPES_H)
-int opt_imax(const char *arg, intmax_t *result);
-int opt_umax(const char *arg, uintmax_t *result);
+int opt_intmax(const char *arg, intmax_t *result);
+int opt_uintmax(const char *arg, uintmax_t *result);
#else
-# define opt_imax opt_long
-# define opt_umax opt_ulong
+# define opt_intmax opt_long
+# define opt_uintmax opt_ulong
# define intmax_t long
# define uintmax_t unsigned long
#endif
-int opt_pair(const char *arg, const OPT_PAIR * pairs, int *result);
+
+int opt_isdir(const char *name);
+int opt_format(const char *s, unsigned long flags, int *result);
+void print_format_error(int format, unsigned long flags);
+int opt_printf_stderr(const char *fmt, ...);
int opt_string(const char *name, const char **options);
-int opt_cipher(const char *name, EVP_CIPHER **cipherp);
-int opt_cipher_silent(const char *name, EVP_CIPHER **cipherp);
-int opt_md(const char *name, EVP_MD **mdp);
-int opt_md_silent(const char *name, EVP_MD **mdp);
-char *opt_name(void);
-char *opt_arg(void);
-char *opt_flag(void);
-char *opt_unknown(void);
-char **opt_rest(void);
-int opt_num_rest(void);
+int opt_pair(const char *arg, const OPT_PAIR * pairs, int *result);
+
int opt_verify(int i, X509_VERIFY_PARAM *vpm);
int opt_rand(int i);
int opt_provider(int i);
-void opt_help(const OPTIONS * list);
-void print_format_error(int format, unsigned long flags);
-int opt_isdir(const char *name);
-int opt_printf_stderr(const char *fmt, ...);
+
+char **opt_rest(void);
+int opt_num_rest(void);
#endif /* OSSL_APPS_OPT_H */
diff --git a/apps/info.c b/apps/info.c
index 5099853494..e432be46d5 100644
--- a/apps/info.c
+++ b/apps/info.c
@@ -12,7 +12,7 @@
#include "progs.h"
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_CONFIGDIR, OPT_ENGINESDIR, OPT_MODULESDIR, OPT_DSOEXT, OPT_DIRNAMESEP,
OPT_LISTSEP, OPT_SEEDS, OPT_CPUSETTINGS
} OPTION_CHOICE;
diff --git a/apps/kdf.c b/apps/kdf.c
index c036a1bf47..b3865d9e87 100644
--- a/apps/kdf.c
+++ b/apps/kdf.c
@@ -18,7 +18,7 @@
#include <openssl/params.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_KDFOPT, OPT_BIN, OPT_KEYLEN, OPT_OUT,
OPT_PROV_ENUM
} OPTION_CHOICE;
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;
diff --git a/apps/list.c b/apps/list.c
index af6ae3f1a0..a8646addb1 100644
--- a/apps/list.c
+++ b/apps/list.c
@@ -1374,7 +1374,8 @@ static void list_disabled(void)
/* Unified enum for help and list commands. */
typedef enum HELPLIST_CHOICE {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE, OPT_VERBOSE,
+ OPT_COMMON,
+ OPT_ONE, OPT_VERBOSE,
OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_DISABLED,
diff --git a/apps/mac.c b/apps/mac.c
index 8f8dcde318..c722be3102 100644
--- a/apps/mac.c
+++ b/apps/mac.c
@@ -20,7 +20,7 @@
#define BUFSIZE 1024*8
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_MACOPT, OPT_BIN, OPT_IN, OPT_OUT,
OPT_PROV_ENUM
} OPTION_CHOICE;
diff --git a/apps/nseq.c b/apps/nseq.c
index 706ca58f65..8848e895ae 100644
--- a/apps/nseq.c
+++ b/apps/nseq.c
@@ -15,7 +15,7 @@
#include <openssl/err.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_TOSEQ, OPT_IN, OPT_OUT,
OPT_PROV_ENUM
} OPTION_CHOICE;
diff --git a/apps/ocsp.c b/apps/ocsp.c
index 35a328bc69..d59cd1eb59 100644
--- a/apps/ocsp.c
+++ b/apps/ocsp.c
@@ -85,7 +85,7 @@ static int index_changed(CA_DB *);
#endif
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_OUTFILE, OPT_TIMEOUT, OPT_URL, OPT_HOST, OPT_PORT,
OPT_IGNORE_ERR, OPT_NOVERIFY, OPT_NONCE, OPT_NO_NONCE,
OPT_RESP_NO_CERTS, OPT_RESP_KEY_ID, OPT_NO_CERTS,
diff --git a/apps/passwd.c b/apps/passwd.c
index 1203b7443e..65cbd9e493 100644
--- a/apps/passwd.c
+++ b/apps/passwd.c
@@ -50,7 +50,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
int reverse, size_t pw_maxlen, passwd_modes mode);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_IN,
OPT_NOVERIFY, OPT_QUIET, OPT_TABLE, OPT_REVERSE, OPT_APR1,
OPT_1, OPT_5, OPT_6, OPT_AIXMD5, OPT_SALT, OPT_STDIN,
diff --git a/apps/pkcs12.c b/apps/pkcs12.c
index c2508163f0..90550b1f44 100644
--- a/apps/pkcs12.c
+++ b/apps/pkcs12.c
@@ -55,7 +55,7 @@ int cert_load(BIO *in, STACK_OF(X509) *sk);
static int set_pbe(int *ppbe, const char *str);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_CIPHER, OPT_NOKEYS, OPT_KEYEX, OPT_KEYSIG, OPT_NOCERTS, OPT_CLCERTS,
OPT_CACERTS, OPT_NOOUT, OPT_INFO, OPT_CHAIN, OPT_TWOPASS, OPT_NOMACVER,
#ifndef OPENSSL_NO_DES
diff --git a/apps/pkcs7.c b/apps/pkcs7.c
index fea9eadf65..ba11e8151a 100644
--- a/apps/pkcs7.c
+++ b/apps/pkcs7.c
@@ -21,7 +21,7 @@
#include <openssl/pem.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_NOOUT,
OPT_TEXT, OPT_PRINT, OPT_PRINT_CERTS, OPT_ENGINE,
OPT_PROV_ENUM
diff --git a/apps/pkcs8.c b/apps/pkcs8.c
index 1c4dd1220b..d7cb2d6672 100644
--- a/apps/pkcs8.c
+++ b/apps/pkcs8.c
@@ -18,7 +18,7 @@
#include <openssl/pkcs12.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_IN, OPT_OUT,
OPT_TOPK8, OPT_NOITER, OPT_NOCRYPT,
#ifndef OPENSSL_NO_SCRYPT
diff --git a/apps/pkey.c b/apps/pkey.c
index 0587aacc30..d7e32b6e58 100644
--- a/apps/pkey.c
+++ b/apps/pkey.c
@@ -18,7 +18,7 @@
#include <openssl/core_names.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_PASSIN, OPT_PASSOUT, OPT_ENGINE,
OPT_IN, OPT_OUT, OPT_PUBIN, OPT_PUBOUT, OPT_TEXT_PUB,
OPT_TEXT, OPT_NOOUT, OPT_CIPHER, OPT_TRADITIONAL, OPT_CHECK, OPT_PUB_CHECK,
diff --git a/apps/pkeyparam.c b/apps/pkeyparam.c
index 8b4ac1d222..45647341ce 100644
--- a/apps/pkeyparam.c
+++ b/apps/pkeyparam.c
@@ -17,7 +17,7 @@
#include <openssl/evp.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_IN, OPT_OUT, OPT_TEXT, OPT_NOOUT,
OPT_ENGINE, OPT_CHECK,
OPT_PROV_ENUM
diff --git a/apps/pkeyutl.c b/apps/pkeyutl.c
index a9571b5f63..3a26ec5ca7 100644
--- a/apps/pkeyutl.c
+++ b/apps/pkeyutl.c
@@ -40,7 +40,7 @@ static int do_raw_keyop(int pkey_op, EVP_MD_CTX *mctx,
unsigned char **out, size_t *poutlen);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_ENGINE, OPT_ENGINE_IMPL, OPT_IN, OPT_OUT,
OPT_PUBIN, OPT_CERTIN, OPT_ASN1PARSE, OPT_HEXDUMP, OPT_SIGN,
OPT_VERIFY, OPT_VERIFYRECOVER, OPT_REV, OPT_ENCRYPT, OPT_DECRYPT,
diff --git a/apps/prime.c b/apps/prime.c
index 1879d14111..20b26cddad 100644
--- a/apps/prime.c
+++ b/apps/prime.c
@@ -14,7 +14,7 @@
#include <openssl/bn.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_HEX, OPT_GENERATE, OPT_BITS, OPT_SAFE, OPT_CHECKS,
OPT_PROV_ENUM
} OPTION_CHOICE;
diff --git a/apps/rand.c b/apps/rand.c
index 24f8c64d43..cbf495d5bc 100644
--- a/apps/rand.c
+++ b/apps/rand.c
@@ -19,7 +19,7 @@
#include <openssl/rand.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_OUT, OPT_ENGINE, OPT_BASE64, OPT_HEX,
OPT_R_ENUM, OPT_PROV_ENUM
} OPTION_CHOICE;
diff --git a/apps/rehash.c b/apps/rehash.c
index 36e8e0fda2..65ccacc0a8 100644
--- a/apps/rehash.c
+++ b/apps/rehash.c
@@ -466,7 +466,7 @@ static int do_dir(const char *dirname, enum Hash h)
}
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_COMPAT, OPT_OLD, OPT_N, OPT_VERBOSE,
OPT_PROV_ENUM
} OPTION_CHOICE;
diff --git a/apps/req.c b/apps/req.c
index 5408dc7505..6817a8bd54 100644
--- a/apps/req.c
+++ b/apps/req.c
@@ -79,7 +79,7 @@ static CONF *addext_conf = NULL;
static int batch = 0;
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_KEYGEN_ENGINE, OPT_KEY,
OPT_PUBKEY, OPT_NEW, OPT_CONFIG, OPT_KEYFORM, OPT_IN, OPT_OUT,
OPT_KEYOUT, OPT_PASSIN, OPT_PASSOUT, OPT_NEWKEY,
diff --git a/apps/rsa.c b/apps/rsa.c
index 47316757d5..0ff6cf3266 100644
--- a/apps/rsa.c
+++ b/apps/rsa.c
@@ -37,7 +37,7 @@
#endif
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_IN, OPT_OUT,
OPT_PUBIN, OPT_PUBOUT, OPT_PASSOUT, OPT_PASSIN,
OPT_RSAPUBKEY_IN, OPT_RSAPUBKEY_OUT,
diff --git a/apps/rsautl.c b/apps/rsautl.c
index 57a3f8b4fc..a8911ff206 100644
--- a/apps/rsautl.c
+++ b/apps/rsautl.c
@@ -26,7 +26,7 @@
#define KEY_CERT 3
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_ENGINE, OPT_IN, OPT_OUT, OPT_ASN1PARSE, OPT_HEXDUMP,
OPT_RSA_RAW, OPT_OAEP, OPT_PKCS, OPT_X931,
OPT_SIGN, OPT_VERIFY, OPT_REV, OPT_ENCRYPT, OPT_DECRYPT,
diff --git a/apps/s_client.c b/apps/s_client.c
index dfc38b6659..3c62739698 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -429,7 +429,7 @@ static int tlsa_import_rrset(SSL *con, STACK_OF(OPENSSL_STRING) *rrset)
}
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_4, OPT_6, OPT_HOST, OPT_PORT, OPT_CONNECT, OPT_BIND, OPT_UNIX,
OPT_XMPPHOST, OPT_VERIFY, OPT_NAMEOPT,
OPT_CERT, OPT_CRL, OPT_CRL_DOWNLOAD, OPT_SESS_OUT, OPT_SESS_IN,
diff --git a/apps/s_server.c b/apps/s_server.c
index 9ffd499a0a..6adee7ec6d 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -672,7 +672,8 @@ static int not_resumable_sess_cb(SSL *s, int is_forward_secure)
}
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ENGINE,
+ OPT_COMMON,
+ OPT_ENGINE,
OPT_4, OPT_6, OPT_ACCEPT, OPT_PORT, OPT_UNIX, OPT_UNLINK, OPT_NACCEPT,
OPT_VERIFY, OPT_NAMEOPT, OPT_UPPER_V_VERIFY, OPT_CONTEXT, OPT_CERT, OPT_CRL,
OPT_CRL_DOWNLOAD, OPT_SERVERINFO, OPT_CERTFORM, OPT_KEY, OPT_KEYFORM,
diff --git a/apps/s_time.c b/apps/s_time.c
index bda61176e3..8c43db952e 100644
--- a/apps/s_time.c
+++ b/apps/s_time.c
@@ -43,7 +43,7 @@ static const char fmt_http_get_cmd[] = "GET %s HTTP/1.0\r\n\r\n";
static const size_t fmt_http_get_cmd_size = sizeof(fmt_http_get_cmd) - 2;
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_CONNECT, OPT_CIPHER, OPT_CIPHERSUITES, OPT_CERT, OPT_NAMEOPT, OPT_KEY,
OPT_CAPATH, OPT_CAFILE, OPT_CASTORE,
OPT_NOCAPATH, OPT_NOCAFILE, OPT_NOCASTORE,
diff --git a/apps/sess_id.c b/apps/sess_id.c
index de25cea156..a1e5415cc4 100644
--- a/apps/sess_id.c
+++ b/apps/sess_id.c
@@ -19,7 +19,7 @@
#include <openssl/ssl.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT,
OPT_TEXT, OPT_CERT, OPT_NOOUT, OPT_CONTEXT
} OPTION_CHOICE;
diff --git a/apps/smime.c b/apps/smime.c
index ed12b92193..011dc99c4b 100644
--- a/apps/smime.c
+++ b/apps/smime.c
@@ -33,7 +33,7 @@ static int smime_cb(int ok, X509_STORE_CTX *ctx);
#define SMIME_RESIGN (6 | SMIME_IP | SMIME_OP | SMIME_SIGNERS)
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_ENCRYPT, OPT_DECRYPT, OPT_SIGN, OPT_RESIGN, OPT_VERIFY,
OPT_PK7OUT, OPT_TEXT, OPT_NOINTERN, OPT_NOVERIFY, OPT_NOCHAIN,
OPT_NOCERTS, OPT_NOATTR, OPT_NODETACH, OPT_NOSMIMECAP,
diff --git a/apps/speed.c b/apps/speed.c
index 5363b0d7f8..0892b60369 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -207,7 +207,7 @@ static int opt_found(const char *name, unsigned int *result,
opt_found(value, result, pairs, OSSL_NELEM(pairs))
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_ELAPSED, OPT_EVP, OPT_HMAC, OPT_DECRYPT, OPT_ENGINE, OPT_MULTI,
OPT_MR, OPT_MB, OPT_MISALIGN, OPT_ASYNCJOBS, OPT_R_ENUM, OPT_PROV_ENUM,
OPT_PRIMES, OPT_SECONDS, OPT_BYTES, OPT_AEAD, OPT_CMAC
diff --git a/apps/spkac.c b/apps/spkac.c
index cfbbc41e18..9c12504b90 100644
--- a/apps/spkac.c
+++ b/apps/spkac.c
@@ -21,7 +21,7 @@
#include <openssl/pem.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_NOOUT, OPT_PUBKEY, OPT_VERIFY, OPT_IN, OPT_OUT,
OPT_ENGINE, OPT_KEY, OPT_CHALLENGE, OPT_PASSIN, OPT_SPKAC,
OPT_SPKSECT, OPT_KEYFORM,
diff --git a/apps/srp.c b/apps/srp.c
index af62e7e200..aad08fb229 100644
--- a/apps/srp.c
+++ b/apps/srp.c
@@ -190,7 +190,7 @@ static char *srp_create_user(char *user, char **srp_verifier,
}
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_VERBOSE, OPT_CONFIG, OPT_NAME, OPT_SRPVFILE, OPT_ADD,
OPT_DELETE, OPT_MODIFY, OPT_LIST, OPT_GN, OPT_USERINFO,
OPT_PASSIN, OPT_PASSOUT, OPT_ENGINE, OPT_R_ENUM, OPT_PROV_ENUM
diff --git a/apps/storeutl.c b/apps/storeutl.c
index 7fec56c9ea..3e7ab32b7a 100644
--- a/apps/storeutl.c
+++ b/apps/storeutl.c
@@ -22,7 +22,8 @@ static int process(const char *uri, const UI_METHOD *uimeth, PW_CB_DATA *uidata,
const char *prog, OSSL_LIB_CTX *libctx);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ENGINE, OPT_OUT, OPT_PASSIN,
+ OPT_COMMON,
+ OPT_ENGINE, OPT_OUT, OPT_PASSIN,
OPT_NOOUT, OPT_TEXT, OPT_RECURSIVE,
OPT_SEARCHFOR_CERTS, OPT_SEARCHFOR_KEYS, OPT_SEARCHFOR_CRLS,
OPT_CRITERION_SUBJECT, OPT_CRITERION_ISSUER, OPT_CRITERION_SERIAL,
diff --git a/apps/ts.c b/apps/ts.c
index ad6a3d382b..db5ecb32c2 100644
--- a/apps/ts.c
+++ b/apps/ts.c
@@ -77,7 +77,7 @@ static X509_STORE *create_cert_store(const char *CApath, const char *CAfile,
static int verify_cb(int ok, X509_STORE_CTX *ctx);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_ENGINE, OPT_CONFIG, OPT_SECTION, OPT_QUERY, OPT_DATA,
OPT_DIGEST, OPT_TSPOLICY, OPT_NO_NONCE, OPT_CERT,
OPT_IN, OPT_TOKEN_IN, OPT_OUT, OPT_TOKEN_OUT, OPT_TEXT,
diff --git a/apps/verify.c b/apps/verify.c
index 718174a83d..d66f137258 100644
--- a/apps/verify.c
+++ b/apps/verify.c
@@ -26,7 +26,7 @@ static int check(X509_STORE *ctx, const char *file,
static int v_verbose = 0, vflags = 0;
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_ENGINE, OPT_CAPATH, OPT_CAFILE, OPT_CASTORE,
OPT_NOCAPATH, OPT_NOCAFILE, OPT_NOCASTORE,
OPT_UNTRUSTED, OPT_TRUSTED, OPT_CRLFILE, OPT_CRL_DOWNLOAD, OPT_SHOW_CHAIN,
diff --git a/apps/version.c b/apps/version.c
index cb00f55d89..b4cc2e04a1 100644
--- a/apps/version.c
+++ b/apps/version.c
@@ -17,7 +17,7 @@
#include <openssl/bn.h>
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_B, OPT_D, OPT_E, OPT_M, OPT_F, OPT_O, OPT_P, OPT_V, OPT_A, OPT_R, OPT_C
} OPTION_CHOICE;
diff --git a/apps/x509.c b/apps/x509.c
index 50453c4b7c..a9c5d41096 100644
--- a/apps/x509.c
+++ b/apps/x509.c
@@ -39,7 +39,7 @@ static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt);
static int print_x509v3_exts(BIO *bio, X509 *x, const char *ext_names);
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_KEYFORM, OPT_REQ, OPT_CAFORM,
OPT_CAKEYFORM, OPT_VFYOPT, OPT_SIGOPT, OPT_DAYS, OPT_PASSIN, OPT_EXTFILE,
OPT_EXTENSIONS, OPT_IN, OPT_OUT, OPT_KEY, OPT_SIGNKEY, OPT_CA, OPT_CAKEY,
@@ -544,7 +544,7 @@ int x509_main(int argc, char **argv)
checkend = 1;
{
intmax_t temp = 0;
- if (!opt_imax(opt_arg(), &temp))
+ if (!opt_intmax(opt_arg(), &temp))
goto opthelp;
checkoffset = (time_t)temp;
if ((intmax_t)checkoffset != temp) {
diff --git a/doc/internal/man3/OPTIONS.pod b/doc/internal/man3/OPTIONS.pod
index 3c0fcdaf80..29151b3761 100644
--- a/doc/internal/man3/OPTIONS.pod
+++ b/doc/internal/man3/OPTIONS.pod
@@ -2,11 +2,12 @@
=head1 NAME
-OPTIONS, OPT_PAIR,
-opt_progname, opt_appname, opt_getprog, opt_init, opt_format,
-opt_int, opt_long, opt_imax, opt_umax, opt_ulong, opt_pair,
-opt_string, opt_cipher, opt_md, opt_next, opt_arg, opt_flag, opt_unknown,
-opt_num_rest, opt_rest, opt_help, opt_isdir
+OPTIONS, OPT_PAIR, OPT_COMMON, OPT_ERR, OPT_EOF, OPT_HELP,
+opt_init, opt_progname, opt_appname, opt_getprog, opt_help,
+opt_begin, opt_next, opt_flag, opt_arg, opt_unknown, opt_cipher, opt_md,
+opt_int, opt_int_arg, opt_long, opt_ulong, opt_intmax, opt_uintmax,
+opt_format, opt_isdir, opt_string, opt_pair,
+opt_num_rest, opt_rest
- Option parsing for commands and tests
=head1 SYNOPSIS
@@ -15,29 +16,34 @@ opt_num_rest, opt_rest, opt_help, opt_isdir
typedef struct { ... } OPTIONS;
typedef struct { ... } OPT_PAIR;
+ #define OPT_COMMON
+ #define OPT_ERR
+ #define OPT_EOF
+ #define OPT_HELP
+ char *opt_init(int argc, char **argv, const OPTIONS *o);
char *opt_progname(const char *argv0);
- char *opt_appname(const char *arg0);
+ char *opt_appname(const char *argv0);
char *opt_getprog(void);
- char *opt_init(int argc, char **argv, const OPTIONS *o);
+ void opt_help(const OPTIONS *list);
+ void opt_begin(void);
int opt_next(void);
- void opt_help(const OPTIONS *list);
- char *opt_arg(void);
char *opt_flag(void);
+ char *opt_arg(void);
char *opt_unknown(void);
int opt_cipher(const char *name, EVP_CIPHER **cipherp);
int opt_md(const char *name, EVP_MD **mdp);
int opt_int(const char *value, int *result);
+ int opt_int_arg(void);
int opt_long(const char *value, long *result);
- int opt_imax(const char *value, intmax_t *result);
- int opt_umax(const char *value, uintmax_t *result);
int opt_ulong(const char *value, unsigned long *result);
-
- int opt_isdir(const char *name);
+ int opt_intmax(const char *value, intmax_t *result);
+ int opt_uintmax(const char *value, uintmax_t *result);
int opt_format(const char *s, unsigned long flags, int *result);
+ int opt_isdir(const char *name);
int opt_string(const char *name, const char **options);
int opt_pair(const char *name, const OPT_PAIR* pairs, int *result);
@@ -65,14 +71,15 @@ Each program should define, near the main() routine, an enumeration
that is the set of options the program accepts. For example:
typedef enum OPTION_choice {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
+ OPT_COMMON,
OPT_YES, OPT_NAME, OPT_COUNT, OPT_OFILE,
...
} OPTION_CHOICE;
-The first two lines must appear exactly as shown. In addition to
-defining symbolic names for the constants that opt_next() returns,
-it also helps guarantee that every command has a C<-help> option.
+The first two lines must appear exactly as shown.
+OPT_COMMON is a macro that expands to C<OPT_ERR = -1, OPT_EOF = 0, OPT_HELP>.
+In addition to defining symbolic names for the constants that opt_next()
+returns, it also helps guarantee that every command has a C<-help> option.
The third line is a sample
set of flags, and the closing C<typedef> name is used for error-checking
as discussed below.
@@ -184,19 +191,30 @@ the help string:
=head2 Functions
-The opt_init() function takes the "argc, argv" arguments given to main() and
-a pointer to the list of options. It returns the simple program
+The opt_init() function takes the I<argc> and I<argv> arguments given to main()
+and a pointer I<o> to the list of options. It returns the simple program
name, as defined by opt_progname().
-The opt_progname() function takes the full pathname, C<argv[0]>, and returns
+The opt_progname() function takes the full pathname C<argv[0]> in its I<arg0>
+parameter and returns
the simple short name of the executable, to be used for error messages and
-the like. The opt_appname() functions takes the "application" name (such
+the like.
+
+The opt_appname() function takes in its I<argv0> parameter
+the "application" name (such
as the specific command from L<openssl(1)> and appends it to the program
-name. This function should only be called once. Once set, opt_getprog()
-also returns the value.
+name. This function should only be called once.
+
+The opt_getprog() function returns the value set by opt_appname().
+
+The opt_help() function takes a list of option definitions and prints a
+nicely-formatted output.
+
+The opt_begin() function, which is called automatically by opt_init(),
+can be used to reset the option parsing loop.
-Once opt_init() has been called, opt_next() can be called in a loop to
-fetch each option in turn. It returns -1, or OPT_EOF when the
+The opt_next() function is called, once opt_init() has been called,
+in a loop to fetch each option in turn. It returns -1, or B<OPT_EOF> when the
end of arguments has been reached. This is typically done like this:
prog = opt_init(argc, argv, my_options);
@@ -214,13 +232,14 @@ end of arguments has been reached. This is typically done like this:
}
}
-The opt_help() function takes a list of option definitions and prints a
-nicely-formatted output.
+Within the option parsing loop, the following functions may be called.
+
+The opt_flag() function returns the most recent option name
+including the preceding C<->.
-Within the option parsing loop, opt_flag() returns the option,
-without any leading hyphens. The opt_arg() function returns
-the option's value, if there is one.
+The opt_arg() function returns the option's argument value, if there is one.
+The opt_unknown() function returns the unknown option.
In an option list, there can be at most one option with the empty string.
This is a "wildcard" or "unknown" option. For example, it allows an
option to be be taken as digest algorithm, like C<-sha1>. The
@@ -229,7 +248,7 @@ the cipher into I<cipherp>. The function opt_md() does the same
thing for message digest.
There are a several useful functions for parsing numbers. These are
-opt_int(), opt_long(), opt_ulong(), opt_imax(), and opt_umax(). They all
+opt_int(), opt_long(), opt_ulong(), opt_intmax(), and opt_uintmax(). They all
take C<0x> to mean hexadecimal and C<0> to mean octal, and will do the
necessary range-checking. They return 1 if successful and fill in the
C<result> pointer with the value, or 0 on error. Note that opt_next()
@@ -237,11 +256,16 @@ will also do range-check on the argument if the appropriate B<valtype>
field is specified for the option. This means that error-checking inside
the C<switch> C<case> can often be elided.
-The opt_isdir() function returns 1 if the specified I<name> is
-a directory, or 0 if not. The opt_format() function takes a string value,
+The opt_int_arg() function is a convenience abbreviation to opt_int().
+It parses and returns an integer, assuming its range has been checked before.
+
+The opt_format() function takes a string value,
such as used with the B<-informat> or similar option, and fills
the value from the constants in F<fmt.h> file.
+The opt_isdir() function returns 1 if the specified I<name> is
+a directory, or 0 if not.
+
The opt_string() function checks that I<name> appears in the
NULL-terminated array of strings. It returns 1 if found,
or prints a diagnostic and returns 0 if not.
@@ -251,10 +275,13 @@ has a text name and an integer. The specified I<name> is
found on the list, it puts the index in I<*result>, and returns
1. If not found, it returns 0.
-After processing all the options, the opt_num_rest() returns what is
-left, and opt_rest() returns a pointer to the first non-option.
+The following functions can be used after processing all the options.
+
+The opt_num_rest() function returns what is left.
+
+The opt_rest() function returns a pointer to the first non-option.
If there were no parameters, it will point to the NULL that is
-at the end of the standard B<argv> array.
+at the end of the standard I<argv> array.
=head2 Common Options
diff --git a/test/ecstresstest.c b/test/ecstresstest.c
index 5a831e338a..f6adc4235e 100644
--- a/test/ecstresstest.c
+++ b/test/ecstresstest.c
@@ -127,7 +127,7 @@ int setup_tests(void)
{
OPTION_CHOICE o;
- if (!opt_imax(NUM_REPEATS, &num_repeats)) {
+ if (!opt_intmax(NUM_REPEATS, &num_repeats)) {
TEST_error("Cannot parse " NUM_REPEATS);
return 0;
}
@@ -135,7 +135,7 @@ int setup_tests(void)
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_NUM_REPEATS:
- if (!opt_imax(opt_arg(), &num_repeats)
+ if (!opt_intmax(opt_arg(), &num_repeats)
|| num_repeats < 0)
return 0;
print_mode = 1;
More information about the openssl-commits
mailing list