X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Ferr%2Ferr_prn.c;h=a0168ac8ed628fd4d511059d68b0bffaebad92ed;hb=cd91fd7c32428c0deb503f19b8061e0980476876;hp=16e313879d63aeef3f8da85c660e2fd6ab9ae788;hpb=eda1f21f1af8b6f77327e7b37573af9c1ba73726;p=oweals%2Fopenssl.git diff --git a/crypto/err/err_prn.c b/crypto/err/err_prn.c index 16e313879d..a0168ac8ed 100644 --- a/crypto/err/err_prn.c +++ b/crypto/err/err_prn.c @@ -1,5 +1,5 @@ /* crypto/err/err_prn.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written @@ -57,46 +57,58 @@ */ #include -#include "lhash.h" -#include "crypto.h" #include "cryptlib.h" -#include "buffer.h" -#include "err.h" -#include "crypto.h" +#include +#include +#include +#include -#ifndef WIN16 -void ERR_print_errors_fp(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 *file; - int line; + char buf[256]; + char buf2[4096]; + const char *file,*data; + int line,flags; unsigned long es; + CRYPTO_THREADID cur; - es=CRYPTO_thread_id(); - while ((l=ERR_get_error_line(&file,&line)) != 0) - fprintf(fp,"%lu:%s:%s:%d\n",es,ERR_error_string(l,buf), - file,line); + CRYPTO_THREADID_current(&cur); + es=CRYPTO_THREADID_hash(&cur); + while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) + { + ERR_error_string_n(l, buf, sizeof buf); + BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf, + file, line, (flags & ERR_TXT_STRING) ? data : ""); + if (cb(buf2, strlen(buf2), u) <= 0) + break; /* abort outputting the error report */ + } } -#endif -void ERR_print_errors(bp) -BIO *bp; +#ifndef OPENSSL_NO_FP_API +static int print_fp(const char *str, size_t len, void *fp) { - unsigned long l; - char buf[256]; - char buf2[256]; - char *file; - int line; - unsigned long es; + BIO bio; - es=CRYPTO_thread_id(); - while ((l=ERR_get_error_line(&file,&line)) != 0) - { - sprintf(buf2,"%lu:%s:%s:%d\n",es,ERR_error_string(l,buf), - file,line); - BIO_write(bp,buf2,strlen(buf2)); - } + BIO_set(&bio,BIO_s_file()); + BIO_set_fp(&bio,fp,BIO_NOCLOSE); + + return BIO_printf(&bio, "%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) + { + ERR_print_errors_cb(print_bio, bp); } +