#include <openssl/objects.h>
#include <openssl/x509.h>
+static char *prog;
static char *opt_config = NULL;
#define CMP_SECTION "cmp"
#define SECTION_NAME_MAX 40 /* max length of section name */
static char *opt_section = CMP_SECTION;
static int opt_verbosity = OSSL_CMP_LOG_INFO;
-#undef PROG
-#define PROG cmp_main
-static char *prog = "cmp";
-
static int read_config(void);
static CONF *conf = NULL; /* OpenSSL config file context structure */
int ret = 0; /* default: failure */
if (argc <= 1) {
+ prog = opt_appname(argv[0]);
opt_help(cmp_options);
goto err;
}
int engine_impl = 0;
struct doall_dgst_digests dec;
- prog = opt_progname(argv[0]);
buf = app_malloc(BUFSIZE, "I/O buffer");
- md = EVP_get_digestbyname(prog);
+ md = EVP_get_digestbyname(argv[0]);
prog = opt_init(argc, argv, dgst_options);
while ((o = opt_next()) != OPT_EOF) {
const EVP_CIPHER *cipher = NULL, *c;
const EVP_MD *dgst = NULL;
char *hkey = NULL, *hiv = NULL, *hsalt = NULL, *p;
- char *infile = NULL, *outfile = NULL, *prog;
+ char *infile = NULL, *outfile = NULL, *prog, *arg0;
char *str = NULL, *passarg = NULL, *pass = NULL, *strbuf = NULL;
char mbuf[sizeof(magic) - 1];
OPTION_CHOICE o;
BIO *bzl = NULL;
#endif
- /* first check the program name */
- prog = opt_progname(argv[0]);
- if (strcmp(prog, "base64") == 0) {
+ /* first check the command name */
+ arg0 = argv[0];
+ if (strcmp(arg0, "base64") == 0) {
base64 = 1;
#ifdef ZLIB
- } else if (strcmp(prog, "zlib") == 0) {
+ } else if (strcmp(arg0, "zlib") == 0) {
do_zlib = 1;
#endif
} else {
- cipher = EVP_get_cipherbyname(prog);
- if (cipher == NULL && strcmp(prog, "enc") != 0) {
- BIO_printf(bio_err, "%s is not a known cipher\n", prog);
+ cipher = EVP_get_cipherbyname(arg0);
+ if (cipher == NULL && strcmp(arg0, "enc") != 0) {
+ BIO_printf(bio_err, "%s is not a known cipher\n", arg0);
goto end;
}
}
const char *opt_path_end(const char *filename);
char *opt_progname(const char *argv0);
+char *opt_appname(const char *arg0);
char *opt_getprog(void);
char *opt_init(int ac, char **av, const OPTIONS * o);
int opt_next(void);
}
#endif
+char *opt_appname(const char *arg0)
+{
+ size_t len = strlen(prog);
+
+ if (arg0 != NULL)
+ snprintf(prog + len, sizeof(prog) - len - 1, " %s", arg0);
+ return prog;
+}
+
char *opt_getprog(void)
{
return prog;
argv = av;
opt_begin();
opts = o;
- opt_progname(av[0]);
unknown = NULL;
/* Check all options up until the PARAM marker (if present) */
FUNCTION f, *fp;
LHASH_OF(FUNCTION) *prog = NULL;
char *pname;
+ const char *fname;
ARGS arg;
int ret = 0;
#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
argv = copy_argv(&argc, argv);
#elif defined(_WIN32)
- /*
- * Replace argv[] with UTF-8 encoded strings.
- */
+ /* Replace argv[] with UTF-8 encoded strings. */
win32_utf8argv(&argc, &argv);
#endif
setup_trace(getenv("OPENSSL_TRACE"));
#endif
- if (!apps_startup()) {
- BIO_printf(bio_err,
- "FATAL: Startup failure (dev note: apps_startup() failed)\n");
- ERR_print_errors(bio_err);
- ret = 1;
- goto end;
- }
-
- prog = prog_init();
- if (prog == NULL) {
+ if ((fname = "apps_startup", !apps_startup())
+ || (fname = "prog_init", (prog = prog_init()) == NULL)) {
BIO_printf(bio_err,
- "FATAL: Startup failure (dev note: prog_init() failed)\n");
+ "FATAL: Startup failure (dev note: %s()) for %s\n",
+ fname, argv[0]);
ERR_print_errors(bio_err);
ret = 1;
goto end;
/* We assume we've been called as 'openssl cmd' */
argc--;
argv++;
+ opt_appname(argv[0]);
+ } else {
+ argv[0] = pname;
}
/* If there's a command, run with that, otherwise "help". */
}
calculate_columns(functions, &dc);
- BIO_printf(bio_err, "Standard commands");
+ BIO_printf(bio_err, "%s:\n\nStandard commands", prog);
i = 0;
tp = FT_none;
for (fp = functions; fp->name != NULL; fp++) {
# endif
#endif
- prog = opt_progname(argv[0]);
c_quiet = 0;
c_debug = 0;
c_showcerts = 0;
cctx = SSL_CONF_CTX_new();
if (vpm == NULL || cctx == NULL) {
- BIO_printf(bio_err, "%s: out of memory\n", prog);
+ BIO_printf(bio_err, "%s: out of memory\n", opt_getprog());
goto end;
}