]> git.ipfire.org Git - thirdparty/openssl.git/blame - apps/errstr.c
Don't register drbg_delete_thread_state twice
[thirdparty/openssl.git] / apps / errstr.c
CommitLineData
846e33c7 1/*
6738bf14 2 * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
d02b48c6 3 *
dffa7520 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
846e33c7
RS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
d02b48c6
RE
8 */
9
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include "apps.h"
dab2cd68 14#include "progs.h"
ec577822 15#include <openssl/bio.h>
ec577822
BM
16#include <openssl/err.h>
17#include <openssl/ssl.h>
d02b48c6 18
7e1b7485 19typedef enum OPTION_choice {
412c8507 20 OPT_ERR = -1, OPT_EOF = 0, OPT_HELP
7e1b7485 21} OPTION_CHOICE;
d02b48c6 22
44c83ebd 23const OPTIONS errstr_options[] = {
7e1b7485 24 {OPT_HELP_STR, 1, '-', "Usage: %s [options] errnum...\n"},
5388f986
RS
25
26 OPT_SECTION("General"),
7e1b7485 27 {"help", OPT_HELP, '-', "Display this summary"},
92de469f
RS
28
29 OPT_PARAMETERS(),
30 {"errnum", 0, 0, "Error number(s) to decode"},
7e1b7485
RS
31 {NULL}
32};
667ac4ec 33
7e1b7485 34int errstr_main(int argc, char **argv)
0f113f3e 35{
7e1b7485
RS
36 OPTION_CHOICE o;
37 char buf[256], *prog;
38 int ret = 1;
0f113f3e 39 unsigned long l;
d02b48c6 40
7e1b7485
RS
41 prog = opt_init(argc, argv, errstr_options);
42 while ((o = opt_next()) != OPT_EOF) {
43 switch (o) {
44 case OPT_EOF:
45 case OPT_ERR:
46 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
47 goto end;
48 case OPT_HELP:
49 opt_help(errstr_options);
50 ret = 0;
51 goto end;
0f113f3e 52 }
0f113f3e 53 }
d02b48c6 54
7e1b7485
RS
55 ret = 0;
56 for (argv = opt_rest(); *argv; argv++) {
2234212c 57 if (sscanf(*argv, "%lx", &l) == 0) {
0f113f3e 58 ret++;
2234212c 59 } else {
302f7588
MC
60 /* We're not really an SSL application so this won't auto-init, but
61 * we're still interested in SSL error strings
62 */
63 OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS
64 | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
cbe29648 65 ERR_error_string_n(l, buf, sizeof(buf));
7e1b7485 66 BIO_printf(bio_out, "%s\n", buf);
0f113f3e
MC
67 }
68 }
7e1b7485 69 end:
26a7d938 70 return ret;
0f113f3e 71}