86
86
#ifndef OPENSSL_NO_FP_API
87
87
static int print_fp(const char *str, size_t len, void *fp)
91
BIO_set(&bio,BIO_s_file());
92
BIO_set_fp(&bio,fp,BIO_NOCLOSE);
94
return BIO_printf(&bio, "%s", str);
89
return fwrite(str, 1, len, fp);
96
91
void ERR_print_errors_fp(FILE *fp)
102
static int print_bio(const char *str, size_t len, void *bp)
104
return BIO_write((BIO *)bp, str, len);
106
void ERR_print_errors(BIO *bp)
108
ERR_print_errors_cb(print_bio, bp);
97
void ERR_error_string_n(unsigned long e, char *buf, size_t len)
99
char lsbuf[64], fsbuf[64], rsbuf[64];
100
const char *ls,*fs,*rs;
107
ls=ERR_lib_error_string(e);
108
fs=ERR_func_error_string(e);
109
rs=ERR_reason_error_string(e);
112
BIO_snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l);
114
BIO_snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f);
116
BIO_snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r);
118
BIO_snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf,
119
fs?fs:fsbuf, rs?rs:rsbuf);
120
if (strlen(buf) == len-1)
122
/* output may be truncated; make sure we always have 5
123
* colon-separated fields, i.e. 4 colons ... */
125
if (len > NUM_COLONS) /* ... if possible */
130
for (i = 0; i < NUM_COLONS; i++)
132
char *colon = strchr(s, ':');
133
if (colon == NULL || colon > &buf[len-1] - NUM_COLONS + i)
135
/* set colon no. i at last possible position
136
* (buf[len-1] is the terminating 0)*/
137
colon = &buf[len-1] - NUM_COLONS + i;
146
/* BAD for multi-threading: uses a local buffer if ret == NULL */
147
/* ERR_error_string_n should be used instead for ret != NULL
148
* as ERR_error_string cannot know how large the buffer is */
149
char *ERR_error_string(unsigned long e, char *ret)
151
static char buf[256];
153
if (ret == NULL) ret=buf;
154
ERR_error_string_n(e, ret, 256);