=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/openssl/errstr.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/openssl/errstr.c 2014/08/26 17:47:24 1.1 --- src/usr.bin/openssl/errstr.c 2015/04/13 15:02:23 1.2 *************** *** 1,4 **** ! /* $OpenBSD: errstr.c,v 1.1 2014/08/26 17:47:24 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * --- 1,4 ---- ! /* $OpenBSD: errstr.c,v 1.2 2015/04/13 15:02:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * *************** *** 67,72 **** --- 67,93 ---- #include #include + struct { + int stats; + } errstr_config; + + struct option errstr_options[] = { + { + .name = "stats", + .desc = "Print debugging statistics for the hash table", + .type = OPTION_FLAG, + .opt.flag = &errstr_config.stats, + }, + { NULL }, + }; + + static void + errstr_usage() + { + fprintf(stderr, "usage: errstr [-stats] errno ...\n"); + options_usage(errstr_options); + } + int errstr_main(int, char **); int *************** *** 75,82 **** int i, ret = 0; char buf[256]; unsigned long l; ! if ((argc > 1) && (strcmp(argv[1], "-stats") == 0)) { BIO *out = NULL; out = BIO_new(BIO_s_file()); --- 96,111 ---- int i, ret = 0; char buf[256]; unsigned long l; + int argsused; ! memset(&errstr_config, 0, sizeof(errstr_config)); ! ! if (options_parse(argc, argv, errstr_options, NULL, &argsused) != 0) { ! errstr_usage(); ! return (1); ! } ! ! if (errstr_config.stats) { BIO *out = NULL; out = BIO_new(BIO_s_file()); *************** *** 90,105 **** } if (out != NULL) BIO_free_all(out); - argc--; - argv++; } ! for (i = 1; i < argc; i++) { if (sscanf(argv[i], "%lx", &l)) { ERR_error_string_n(l, buf, sizeof buf); printf("%s\n", buf); } else { printf("%s: bad error code\n", argv[i]); ! printf("usage: errstr [-stats] ...\n"); ret++; } } --- 119,133 ---- } if (out != NULL) BIO_free_all(out); } ! ! for (i = argsused; i < argc; i++) { if (sscanf(argv[i], "%lx", &l)) { ERR_error_string_n(l, buf, sizeof buf); printf("%s\n", buf); } else { printf("%s: bad error code\n", argv[i]); ! errstr_usage(); ret++; } }