err.c revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * All rights reserved.
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * This package is an SSL implementation written
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * by Eric Young (eay@cryptsoft.com).
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * The implementation was written so as to conform with Netscapes SSL.
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * This library is free for commercial and non-commercial use as long as
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * the following conditions are aheared to. The following conditions
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * apply to all code found in this distribution, be it the RC4, RSA,
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * lhash, DES, etc., code; not just the SSL code. The SSL documentation
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * included with this distribution is covered by the same copyright terms
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * except that the holder is Tim Hudson (tjh@cryptsoft.com).
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * Copyright remains Eric Young's, and as such any Copyright notices in
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * the code are not to be removed.
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * If this package is used in a product, Eric Young should be given attribution
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * as the author of the parts of the library used.
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * This can be in the form of a textual message at program startup or
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * in documentation (online or textual) provided with the package.
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * Redistribution and use in source and binary forms, with or without
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * modification, are permitted provided that the following conditions
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * 1. Redistributions of source code must retain the copyright
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * notice, this list of conditions and the following disclaimer.
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * 2. Redistributions in binary form must reproduce the above copyright
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * notice, this list of conditions and the following disclaimer in the
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * documentation and/or other materials provided with the distribution.
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * 3. All advertising materials mentioning features or use of this software
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * must display the following acknowledgement:
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * "This product includes cryptographic software written by
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * Eric Young (eay@cryptsoft.com)"
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * The word 'cryptographic' can be left out if the rouines from the library
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * being used are not cryptographic related :-).
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * 4. If you include any Windows specific code (or a derivative thereof) from
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * the apps directory (application code) you must include an acknowledgement:
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * SUCH DAMAGE.
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * The licence and distribution terms for any publically available version or
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * derivative of this code cannot be changed. i.e. this code cannot simply be
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * copied and put under another distribution licence
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * [including the GNU Public Licence.]
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrewsstatic unsigned long err_hash(ERR_STRING_DATA *a);
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrewsstatic int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b);
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrewsstatic int pid_cmp(ERR_STATE *a,ERR_STATE *pid);
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrewsstatic unsigned long get_error_values(int inc,const char **file,int *line,
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_METH,0,0) ,"X509 lookup 'method' routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_RSAREF,0,0) ,"RSAref routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_PROXY,0,0) ,"Proxy routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews {ERR_PACK(0,SYS_F_GETSERVBYNAME,0), "getservbyname"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews {ERR_PACK(0,SYS_F_IOCTLSOCKET,0), "ioctlsocket"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"},
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews{ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"},
{0,NULL},
static void build_SYS_str_reasons()
#define err_clear_data(p,i) \
(p)->err_data_flags[i]=0;
if(s == NULL)
for (i=0; i<ERR_NUM_ERRORS; i++)
err_clear_data(s,i);
Free(s);
void ERR_load_ERR_strings(void)
if (init)
if (init == 0)
#ifndef NO_ERR
init=0;
str++;
void ERR_free_strings(void)
int line)
#ifdef _OSD_POSIX
char *end;
void ERR_clear_error(void)
for (i=0; i<ERR_NUM_ERRORS; i++)
unsigned long ERR_get_error(void)
int *line)
unsigned long ERR_peek_error(void)
int *line)
unsigned long ret;
if (inc)
return(ret);
l=ERR_GET_LIB(e);
f=ERR_GET_FUNC(e);
r=ERR_GET_REASON(e);
return(ret);
return(error_hash);
return(thread_hash);
const char *ERR_lib_error_string(unsigned long e)
l=ERR_GET_LIB(e);
const char *ERR_func_error_string(unsigned long e)
l=ERR_GET_LIB(e);
f=ERR_GET_FUNC(e);
const char *ERR_reason_error_string(unsigned long e)
l=ERR_GET_LIB(e);
r=ERR_GET_REASON(e);
if (p == NULL)
unsigned long ret,l;
l=a->error;
if (pid == 0)
unsigned long pid;
MemCheck_off();
MemCheck_on();
for (i=0; i<ERR_NUM_ERRORS; i++)
return(ret);
int ERR_get_next_error_library(void)
return(value++);
char *str,*p,*a;
for (i=0; i<num; i++)
if (a != NULL)
n+=strlen(a);
if (p == NULL)
str=p;