diff options
author | beck <> | 2002-05-15 02:29:21 +0000 |
---|---|---|
committer | beck <> | 2002-05-15 02:29:21 +0000 |
commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/err/err_prn.c | |
parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/err/err_prn.c')
-rw-r--r-- | src/lib/libcrypto/err/err_prn.c | 46 |
1 files changed, 23 insertions, 23 deletions
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 @@ | |||
64 | #include <openssl/err.h> | 64 | #include <openssl/err.h> |
65 | #include <openssl/crypto.h> | 65 | #include <openssl/crypto.h> |
66 | 66 | ||
67 | #ifndef NO_FP_API | 67 | void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), |
68 | void ERR_print_errors_fp(FILE *fp) | 68 | void *u) |
69 | { | 69 | { |
70 | unsigned long l; | 70 | unsigned long l; |
71 | char buf[200]; | 71 | char buf[256]; |
72 | char buf2[4096]; | ||
72 | const char *file,*data; | 73 | const char *file,*data; |
73 | int line,flags; | 74 | int line,flags; |
74 | unsigned long es; | 75 | unsigned long es; |
@@ -77,31 +78,30 @@ void ERR_print_errors_fp(FILE *fp) | |||
77 | while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) | 78 | while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) |
78 | { | 79 | { |
79 | ERR_error_string_n(l, buf, sizeof buf); | 80 | ERR_error_string_n(l, buf, sizeof buf); |
80 | fprintf(fp,"%lu:%s:%s:%d:%s\n",es,buf, | 81 | BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf, |
81 | file,line,(flags&ERR_TXT_STRING)?data:""); | 82 | file, line, (flags & ERR_TXT_STRING) ? data : ""); |
83 | cb(buf2, strlen(buf2), u); | ||
82 | } | 84 | } |
83 | } | 85 | } |
86 | |||
87 | #ifndef OPENSSL_NO_FP_API | ||
88 | static int print_fp(const char *str, size_t len, void *fp) | ||
89 | { | ||
90 | return fprintf((FILE *)fp, "%s", str); | ||
91 | } | ||
92 | void ERR_print_errors_fp(FILE *fp) | ||
93 | { | ||
94 | ERR_print_errors_cb(print_fp, fp); | ||
95 | } | ||
84 | #endif | 96 | #endif |
85 | 97 | ||
98 | static int print_bio(const char *str, size_t len, void *bp) | ||
99 | { | ||
100 | return BIO_write((BIO *)bp, str, len); | ||
101 | } | ||
86 | void ERR_print_errors(BIO *bp) | 102 | void ERR_print_errors(BIO *bp) |
87 | { | 103 | { |
88 | unsigned long l; | 104 | ERR_print_errors_cb(print_bio, bp); |
89 | char buf[256]; | ||
90 | char buf2[256]; | ||
91 | const char *file,*data; | ||
92 | int line,flags; | ||
93 | unsigned long es; | ||
94 | |||
95 | es=CRYPTO_thread_id(); | ||
96 | while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) | ||
97 | { | ||
98 | ERR_error_string_n(l, buf, sizeof buf); | ||
99 | sprintf(buf2,"%lu:%s:%s:%d:",es,buf, | ||
100 | file,line); | ||
101 | BIO_write(bp,buf2,strlen(buf2)); | ||
102 | if (flags & ERR_TXT_STRING) | ||
103 | BIO_write(bp,data,strlen(data)); | ||
104 | BIO_write(bp,"\n",1); | ||
105 | } | ||
106 | } | 105 | } |
107 | 106 | ||
107 | |||