From b0f960189b8696f878b163d7123afdb99dfdb738 Mon Sep 17 00:00:00 2001 From: "Dr. David von Oheimb" Date: Sat, 1 May 2021 15:29:00 +0200 Subject: [PATCH] APPS: Replace 'OPT_ERR = -1, OPT_EOF = 0, OPT_HELP' by OPT_COMMON macro Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15111) --- apps/asn1pars.c | 2 +- apps/ca.c | 2 +- apps/ciphers.c | 2 +- apps/cmp.c | 2 +- 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 | 2 ++ apps/info.c | 2 +- apps/kdf.c | 2 +- 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 | 2 +- doc/internal/man3/OPTIONS.pod | 17 +++++++++++------ 53 files changed, 68 insertions(+), 57 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 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 14c3a73866..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, 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 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 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 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 a80b6ee43a..c6ec09f882 100644 --- a/apps/include/opt.h +++ b/apps/include/opt.h @@ -14,6 +14,8 @@ #include #include +#define OPT_COMMON OPT_ERR = -1, OPT_EOF = 0, OPT_HELP + /* * Common verification options. */ 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 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/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 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 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 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 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 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 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 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 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 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 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 8dffdb47c1..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, diff --git a/doc/internal/man3/OPTIONS.pod b/doc/internal/man3/OPTIONS.pod index cbe0ccd883..29151b3761 100644 --- a/doc/internal/man3/OPTIONS.pod +++ b/doc/internal/man3/OPTIONS.pod @@ -2,7 +2,7 @@ =head1 NAME -OPTIONS, OPT_PAIR, +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, @@ -16,6 +16,10 @@ opt_num_rest, opt_rest 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); @@ -67,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. +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 name is used for error-checking as discussed below. @@ -209,7 +214,7 @@ The opt_begin() function, which is called automatically by opt_init(), can be used to reset the option parsing loop. 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 OPT_EOF when the +in a loop to fetch each option in turn. It returns -1, or B when the end of arguments has been reached. This is typically done like this: prog = opt_init(argc, argv, my_options); -- 2.39.5