Fix DSA to skip EOL test when parsing mod line.
[openssl.git] / crypto / err / err_prn.c
index b5895a4c6f9d2ba5420198055f5e811b1aac7fc0..a0168ac8ed628fd4d511059d68b0bffaebad92ed 100644 (file)
  */
 
 #include <stdio.h>
+#include "cryptlib.h"
 #include <openssl/lhash.h>
 #include <openssl/crypto.h>
-#include "cryptlib.h"
 #include <openssl/buffer.h>
 #include <openssl/err.h>
-#include <openssl/crypto.h>
 
 void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
                         void *u)
@@ -73,39 +72,43 @@ void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
        const char *file,*data;
        int line,flags;
        unsigned long es;
+       CRYPTO_THREADID cur;
 
-       es=CRYPTO_thread_id();
+       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 : "");
-               cb(buf2, strlen(buf2), u);
+               if (cb(buf2, strlen(buf2), u) <= 0)
+                       break; /* abort outputting the error report */
                }
        }
 
 #ifndef OPENSSL_NO_FP_API
-static int print_fp(const char *str, size_t len, FILE *fp)
+static int print_fp(const char *str, size_t len, void *fp)
        {
-       return fprintf(fp, "%s", str);
+       BIO bio;
+
+       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(
-               (int (*)(const char *, size_t, void *))print_fp,
-               (void *)fp);
+       ERR_print_errors_cb(print_fp, fp);
        }
 #endif
 
-static int print_bio(const char *str, size_t len, BIO *bp)
+static int print_bio(const char *str, size_t len, void *bp)
        {
-       return BIO_write(bp, str, len);
+       return BIO_write((BIO *)bp, str, len);
        }
 void ERR_print_errors(BIO *bp)
        {
-       ERR_print_errors_cb(
-               (int (*)(const char *, size_t, void *))print_bio,
-               (void *)bp);
+       ERR_print_errors_cb(print_bio, bp);
        }