2 * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
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
15 #include <openssl/bio.h>
16 #include <openssl/err.h>
17 #include <openssl/ssl.h>
19 typedef enum OPTION_choice
{
20 OPT_ERR
= -1, OPT_EOF
= 0, OPT_HELP
23 const OPTIONS errstr_options
[] = {
24 {OPT_HELP_STR
, 1, '-', "Usage: %s [options] errnum...\n"},
26 OPT_SECTION("General"),
27 {"help", OPT_HELP
, '-', "Display this summary"},
30 {"errnum", 0, 0, "Error number(s) to decode"},
34 int errstr_main(int argc
, char **argv
)
41 prog
= opt_init(argc
, argv
, errstr_options
);
42 while ((o
= opt_next()) != OPT_EOF
) {
46 BIO_printf(bio_err
, "%s: Use -help for summary.\n", prog
);
49 opt_help(errstr_options
);
56 * We're not really an SSL application so this won't auto-init, but
57 * we're still interested in SSL error strings
59 OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS
60 | OPENSSL_INIT_LOAD_CRYPTO_STRINGS
, NULL
);
62 /* All remaining arg are error code. */
64 for (argv
= opt_rest(); *argv
!= NULL
; argv
++) {
65 if (sscanf(*argv
, "%lx", &l
) <= 0) {
68 ERR_error_string_n(l
, buf
, sizeof(buf
));
69 BIO_printf(bio_out
, "%s\n", buf
);