From b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 Mon Sep 17 00:00:00 2001 From: beck <> Date: Wed, 15 May 2002 02:29:21 +0000 Subject: OpenSSL 0.9.7 stable 2002 05 08 merge --- src/lib/libcrypto/err/err_prn.c | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/lib/libcrypto/err/err_prn.c') diff --git a/src/lib/libcrypto/err/err_prn.c b/src/lib/libcrypto/err/err_prn.c index 6f60b016c3..c156663f0e 100644 --- a/src/lib/libcrypto/err/err_prn.c +++ b/src/lib/libcrypto/err/err_prn.c @@ -64,11 +64,12 @@ #include #include -#ifndef NO_FP_API -void ERR_print_errors_fp(FILE *fp) +void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), + void *u) { unsigned long l; - char buf[200]; + char buf[256]; + char buf2[4096]; const char *file,*data; int line,flags; unsigned long es; @@ -77,31 +78,30 @@ void ERR_print_errors_fp(FILE *fp) while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) { ERR_error_string_n(l, buf, sizeof buf); - fprintf(fp,"%lu:%s:%s:%d:%s\n",es,buf, - file,line,(flags&ERR_TXT_STRING)?data:""); + BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf, + file, line, (flags & ERR_TXT_STRING) ? data : ""); + cb(buf2, strlen(buf2), u); } } + +#ifndef OPENSSL_NO_FP_API +static int print_fp(const char *str, size_t len, void *fp) + { + return fprintf((FILE *)fp, "%s", str); + } +void ERR_print_errors_fp(FILE *fp) + { + ERR_print_errors_cb(print_fp, fp); + } #endif +static int print_bio(const char *str, size_t len, void *bp) + { + return BIO_write((BIO *)bp, str, len); + } void ERR_print_errors(BIO *bp) { - unsigned long l; - char buf[256]; - char buf2[256]; - const char *file,*data; - int line,flags; - unsigned long es; - - es=CRYPTO_thread_id(); - while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) - { - ERR_error_string_n(l, buf, sizeof buf); - sprintf(buf2,"%lu:%s:%s:%d:",es,buf, - file,line); - BIO_write(bp,buf2,strlen(buf2)); - if (flags & ERR_TXT_STRING) - BIO_write(bp,data,strlen(data)); - BIO_write(bp,"\n",1); - } + ERR_print_errors_cb(print_bio, bp); } + -- cgit v1.2.3-55-g6feb