72
72
const char *file,*data;
76
es=CRYPTO_thread_id();
77
CRYPTO_THREADID_current(&cur);
78
es=CRYPTO_THREADID_hash(&cur);
77
79
while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0)
79
81
ERR_error_string_n(l, buf, sizeof buf);
103
void ERR_error_string_n(unsigned long e, char *buf, size_t len)
105
char lsbuf[64], fsbuf[64], rsbuf[64];
106
const char *ls,*fs,*rs;
113
ls=ERR_lib_error_string(e);
114
fs=ERR_func_error_string(e);
115
rs=ERR_reason_error_string(e);
118
BIO_snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l);
120
BIO_snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f);
122
BIO_snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r);
124
BIO_snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf,
125
fs?fs:fsbuf, rs?rs:rsbuf);
126
if (strlen(buf) == len-1)
128
/* output may be truncated; make sure we always have 5
129
* colon-separated fields, i.e. 4 colons ... */
131
if (len > NUM_COLONS) /* ... if possible */
136
for (i = 0; i < NUM_COLONS; i++)
138
char *colon = strchr(s, ':');
139
if (colon == NULL || colon > &buf[len-1] - NUM_COLONS + i)
141
/* set colon no. i at last possible position
142
* (buf[len-1] is the terminating 0)*/
143
colon = &buf[len-1] - NUM_COLONS + i;
152
/* BAD for multi-threading: uses a local buffer if ret == NULL */
153
/* ERR_error_string_n should be used instead for ret != NULL
154
* as ERR_error_string cannot know how large the buffer is */
155
char *ERR_error_string(unsigned long e, char *ret)
157
static char buf[256];
159
if (ret == NULL) ret=buf;
160
ERR_error_string_n(e, ret, 256);
105
static int print_bio(const char *str, size_t len, void *bp)
107
return BIO_write((BIO *)bp, str, len);
109
void ERR_print_errors(BIO *bp)
111
ERR_print_errors_cb(print_bio, bp);