127 static void ERR_STATE_free(
ERR_STATE *s);
128 #ifndef OPENSSL_NO_ERR
172 #ifdef OPENSSL_SYS_WINDOWS
219 {
ERR_R_DISABLED ,
"called a function that was disabled at compile-time"},
242 int (*cb_get_next_lib)(
void);
247 static void int_err_del(
void);
255 static void int_thread_del_item(
const ERR_STATE *);
256 static int int_err_get_next_lib(
void);
258 static const ERR_FNS err_defaults =
274 static const ERR_FNS *err_fns = NULL;
277 #define ERRFN(a) err_fns->cb_##a
286 static int int_thread_hash_references = 0;
291 static void err_fns_check(
void)
297 err_fns = &err_defaults;
328 static unsigned long get_error_values(
int inc,
int top,
const char **
file,
int *line,
339 return(ret^ret%19*13);
346 return (
int)(a->error - b->error);
355 if (!int_error_hash && create)
362 ret = int_error_hash;
368 static void int_err_del(
void)
374 int_error_hash = NULL;
430 static unsigned long err_state_hash(
const ERR_STATE *a)
447 if (!int_thread_hash && create)
455 int_thread_hash_references++;
456 ret = int_thread_hash;
466 if (hash == NULL || *hash == NULL)
472 fprintf(stderr,
"%4d:%s\n",int_thread_hash_references,
"ERR");
478 fprintf(stderr,
"int_thread_release, bad reference count\n");
491 hash =
ERRFN(thread_get)(0);
509 hash =
ERRFN(thread_get)(1);
521 static void int_thread_del_item(
const ERR_STATE *d)
527 hash =
ERRFN(thread_get)(0);
534 if (int_thread_hash_references == 1
538 int_thread_hash = NULL;
547 static int int_err_get_next_lib(
void)
552 ret = int_err_library_number++;
559 #ifndef OPENSSL_NO_ERR
560 #define NUM_SYS_STR_REASONS 127
561 #define LEN_SYS_STR_REASON 32
573 static void build_SYS_str_reasons(
void)
599 str->
error = (
unsigned long)i;
603 char *src = strerror(i);
606 strncpy(*dest, src,
sizeof *dest);
607 (*dest)[
sizeof *dest - 1] =
'\0';
624 #define err_clear_data(p,i) \
626 if (((p)->err_data[i] != NULL) && \
627 (p)->err_data_flags[i] & ERR_TXT_MALLOCED) \
629 OPENSSL_free((p)->err_data[i]); \
630 (p)->err_data[i]=NULL; \
632 (p)->err_data_flags[i]=0; \
635 #define err_clear(p,i) \
637 (p)->err_flags[i]=0; \
638 (p)->err_buffer[i]=0; \
639 err_clear_data(p,i); \
640 (p)->err_file[i]=NULL; \
641 (p)->err_line[i]= -1; \
661 #ifndef OPENSSL_NO_ERR
662 err_load_strings(0,ERR_str_libraries);
663 err_load_strings(0,ERR_str_reasons);
665 build_SYS_str_reasons();
676 ERRFN(err_set_item)(str);
684 err_load_strings(lib, str);
693 ERRFN(err_del_item)(str);
717 if (strncmp(file,
"*POSIX(",
sizeof(
"*POSIX(")-1) == 0) {
721 file +=
sizeof(
"*POSIX(")-1;
722 end = &file[strlen(file)-1];
726 if ((end = strrchr(file,
'/')) != NULL)
758 {
return(get_error_values(1,0,NULL,NULL,NULL,NULL)); }
762 {
return(get_error_values(1,0,file,line,NULL,NULL)); }
766 {
return(get_error_values(1,0,file,line,data,flags)); }
770 {
return(get_error_values(0,0,NULL,NULL,NULL,NULL)); }
773 {
return(get_error_values(0,0,file,line,NULL,NULL)); }
777 {
return(get_error_values(0,0,file,line,data,flags)); }
781 {
return(get_error_values(0,1,NULL,NULL,NULL,NULL)); }
784 {
return(get_error_values(0,1,file,line,NULL,NULL)); }
788 {
return(get_error_values(0,1,file,line,data,flags)); }
791 static unsigned long get_error_values(
int inc,
int top,
const char **
file,
int *line,
802 if (file) *file =
"";
804 if (data) *data =
"";
805 if (flags) *flags = 0;
823 if ((file != NULL) && (line != NULL))
828 if (line != NULL) *line=0;
833 if (line != NULL) *line=es->
err_line[i];
849 if (flags != NULL) *flags=0;
862 char lsbuf[64], fsbuf[64], rsbuf[64];
863 const char *ls,*fs,*rs;
881 BIO_snprintf(buf, len,
"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf,
882 fs?fs:fsbuf, rs?rs:rsbuf);
883 if (strlen(buf) == len-1)
895 char *colon = strchr(s,
':');
896 if (colon == NULL || colon > &buf[len-1] - NUM_COLONS + i)
900 colon = &buf[len-1] - NUM_COLONS + i;
914 static char buf[256];
916 if (ret == NULL) ret=buf;
925 return ERRFN(err_get)(0);
931 return ERRFN(thread_get)(0);
948 p=
ERRFN(err_get_item)(&d);
949 return((p == NULL)?NULL:p->
string);
961 p=
ERRFN(err_get_item)(&d);
962 return((p == NULL)?NULL:p->
string);
974 p=
ERRFN(err_get_item)(&d);
978 p=
ERRFN(err_get_item)(&d);
980 return((p == NULL)?NULL:p->
string);
994 ERRFN(thread_del_item)(&tmp);
997 #ifndef OPENSSL_NO_DEPRECATED
1014 ret=
ERRFN(thread_get_item)(&tmp);
1020 if (ret == NULL)
return(&fallback);
1029 tmpp =
ERRFN(thread_set_item)(ret);
1031 if (
ERRFN(thread_get_item)(ret) != ret)
1033 ERR_STATE_free(ret);
1039 ERR_STATE_free(tmpp);
1047 return ERRFN(get_next_lib)();
1069 va_start(args, num);
1081 if (str == NULL)
return;
1085 for (i=0; i<
num; i++)
1087 a=va_arg(args,
char*);