version 1.2, 2015/04/13 15:02:23 |
version 1.3, 2015/04/14 10:54:40 |
|
|
* [including the GNU Public Licence.] |
* [including the GNU Public Licence.] |
*/ |
*/ |
|
|
|
#include <limits.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
int |
int |
errstr_main(int argc, char **argv) |
errstr_main(int argc, char **argv) |
{ |
{ |
int i, ret = 0; |
unsigned long ulval; |
|
char *ularg, *ep; |
|
int argsused, i; |
char buf[256]; |
char buf[256]; |
unsigned long l; |
int ret = 0; |
int argsused; |
|
|
|
memset(&errstr_config, 0, sizeof(errstr_config)); |
memset(&errstr_config, 0, sizeof(errstr_config)); |
|
|
|
|
} |
} |
|
|
if (errstr_config.stats) { |
if (errstr_config.stats) { |
BIO *out = NULL; |
BIO *out; |
|
|
out = BIO_new(BIO_s_file()); |
if ((out = BIO_new_fp(stdout, BIO_NOCLOSE)) == NULL) { |
if ((out != NULL) && BIO_set_fp(out, stdout, BIO_NOCLOSE)) { |
fprintf(stderr, "Out of memory"); |
lh_ERR_STRING_DATA_node_stats_bio( |
return (1); |
ERR_get_string_table(), out); |
|
lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(), |
|
out); |
|
lh_ERR_STRING_DATA_node_usage_stats_bio( |
|
ERR_get_string_table(), out); |
|
} |
} |
if (out != NULL) |
|
BIO_free_all(out); |
lh_ERR_STRING_DATA_node_stats_bio(ERR_get_string_table(), out); |
|
lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(), out); |
|
lh_ERR_STRING_DATA_node_usage_stats_bio( |
|
ERR_get_string_table(), out); |
|
|
|
BIO_free_all(out); |
} |
} |
|
|
for (i = argsused; i < argc; i++) { |
for (i = argsused; i < argc; i++) { |
if (sscanf(argv[i], "%lx", &l)) { |
errno = 0; |
ERR_error_string_n(l, buf, sizeof buf); |
ularg = argv[i]; |
printf("%s\n", buf); |
ulval = strtoul(ularg, &ep, 16); |
} else { |
if (strchr(ularg, '-') != NULL || |
printf("%s: bad error code\n", argv[i]); |
(ularg[0] == '\0' || *ep != '\0') || |
errstr_usage(); |
(errno == ERANGE && ulval == ULONG_MAX)) { |
|
printf("%s: bad error code\n", ularg); |
ret++; |
ret++; |
|
continue; |
} |
} |
|
|
|
ERR_error_string_n(ulval, buf, sizeof(buf)); |
|
printf("%s\n", buf); |
} |
} |
|
|
return (ret); |
return (ret); |