LTKCPP-- LLRP Toolkit C Plus Plus Library
err.h
00001 /* crypto/err/err.h */
00002 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
00003  * All rights reserved.
00004  *
00005  * This package is an SSL implementation written
00006  * by Eric Young (eay@cryptsoft.com).
00007  * The implementation was written so as to conform with Netscapes SSL.
00008  *
00009  * This library is free for commercial and non-commercial use as long as
00010  * the following conditions are aheared to.  The following conditions
00011  * apply to all code found in this distribution, be it the RC4, RSA,
00012  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
00013  * included with this distribution is covered by the same copyright terms
00014  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
00015  *
00016  * Copyright remains Eric Young's, and as such any Copyright notices in
00017  * the code are not to be removed.
00018  * If this package is used in a product, Eric Young should be given attribution
00019  * as the author of the parts of the library used.
00020  * This can be in the form of a textual message at program startup or
00021  * in documentation (online or textual) provided with the package.
00022  *
00023  * Redistribution and use in source and binary forms, with or without
00024  * modification, are permitted provided that the following conditions
00025  * are met:
00026  * 1. Redistributions of source code must retain the copyright
00027  *    notice, this list of conditions and the following disclaimer.
00028  * 2. Redistributions in binary form must reproduce the above copyright
00029  *    notice, this list of conditions and the following disclaimer in the
00030  *    documentation and/or other materials provided with the distribution.
00031  * 3. All advertising materials mentioning features or use of this software
00032  *    must display the following acknowledgement:
00033  *    "This product includes cryptographic software written by
00034  *     Eric Young (eay@cryptsoft.com)"
00035  *    The word 'cryptographic' can be left out if the rouines from the library
00036  *    being used are not cryptographic related :-).
00037  * 4. If you include any Windows specific code (or a derivative thereof) from
00038  *    the apps directory (application code) you must include an acknowledgement:
00039  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
00040  *
00041  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
00042  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00043  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00044  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00045  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00046  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00047  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00048  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00049  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00050  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00051  * SUCH DAMAGE.
00052  *
00053  * The licence and distribution terms for any publically available version or
00054  * derivative of this code cannot be changed.  i.e. this code cannot simply be
00055  * copied and put under another distribution licence
00056  * [including the GNU Public Licence.]
00057  */
00058 /* ====================================================================
00059  * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.
00060  *
00061  * Redistribution and use in source and binary forms, with or without
00062  * modification, are permitted provided that the following conditions
00063  * are met:
00064  *
00065  * 1. Redistributions of source code must retain the above copyright
00066  *    notice, this list of conditions and the following disclaimer.
00067  *
00068  * 2. Redistributions in binary form must reproduce the above copyright
00069  *    notice, this list of conditions and the following disclaimer in
00070  *    the documentation and/or other materials provided with the
00071  *    distribution.
00072  *
00073  * 3. All advertising materials mentioning features or use of this
00074  *    software must display the following acknowledgment:
00075  *    "This product includes software developed by the OpenSSL Project
00076  *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
00077  *
00078  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
00079  *    endorse or promote products derived from this software without
00080  *    prior written permission. For written permission, please contact
00081  *    openssl-core@openssl.org.
00082  *
00083  * 5. Products derived from this software may not be called "OpenSSL"
00084  *    nor may "OpenSSL" appear in their names without prior written
00085  *    permission of the OpenSSL Project.
00086  *
00087  * 6. Redistributions of any form whatsoever must retain the following
00088  *    acknowledgment:
00089  *    "This product includes software developed by the OpenSSL Project
00090  *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
00091  *
00092  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
00093  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00094  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00095  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
00096  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00097  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00098  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00099  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00100  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00101  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00102  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00103  * OF THE POSSIBILITY OF SUCH DAMAGE.
00104  * ====================================================================
00105  *
00106  * This product includes cryptographic software written by Eric Young
00107  * (eay@cryptsoft.com).  This product includes software written by Tim
00108  * Hudson (tjh@cryptsoft.com).
00109  *
00110  */
00111 
00112 #ifndef HEADER_ERR_H
00113 # define HEADER_ERR_H
00114 
00115 # include <openssl/e_os2.h>
00116 
00117 # ifndef OPENSSL_NO_FP_API
00118 #  include <stdio.h>
00119 #  include <stdlib.h>
00120 # endif
00121 
00122 # include <openssl/ossl_typ.h>
00123 # ifndef OPENSSL_NO_BIO
00124 #  include <openssl/bio.h>
00125 # endif
00126 # ifndef OPENSSL_NO_LHASH
00127 #  include <openssl/lhash.h>
00128 # endif
00129 
00130 #ifdef  __cplusplus
00131 extern "C" {
00132 #endif
00133 
00134 # ifndef OPENSSL_NO_ERR
00135 #  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)
00136 # else
00137 #  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,NULL,0)
00138 # endif
00139 
00140 # include <errno.h>
00141 
00142 # define ERR_TXT_MALLOCED        0x01
00143 # define ERR_TXT_STRING          0x02
00144 
00145 # define ERR_FLAG_MARK           0x01
00146 
00147 # define ERR_NUM_ERRORS  16
00148 typedef struct err_state_st {
00149     CRYPTO_THREADID tid;
00150     int err_flags[ERR_NUM_ERRORS];
00151     unsigned long err_buffer[ERR_NUM_ERRORS];
00152     char *err_data[ERR_NUM_ERRORS];
00153     int err_data_flags[ERR_NUM_ERRORS];
00154     const char *err_file[ERR_NUM_ERRORS];
00155     int err_line[ERR_NUM_ERRORS];
00156     int top, bottom;
00157 } ERR_STATE;
00158 
00159 /* library */
00160 # define ERR_LIB_NONE            1
00161 # define ERR_LIB_SYS             2
00162 # define ERR_LIB_BN              3
00163 # define ERR_LIB_RSA             4
00164 # define ERR_LIB_DH              5
00165 # define ERR_LIB_EVP             6
00166 # define ERR_LIB_BUF             7
00167 # define ERR_LIB_OBJ             8
00168 # define ERR_LIB_PEM             9
00169 # define ERR_LIB_DSA             10
00170 # define ERR_LIB_X509            11
00171 /* #define ERR_LIB_METH         12 */
00172 # define ERR_LIB_ASN1            13
00173 # define ERR_LIB_CONF            14
00174 # define ERR_LIB_CRYPTO          15
00175 # define ERR_LIB_EC              16
00176 # define ERR_LIB_SSL             20
00177 /* #define ERR_LIB_SSL23        21 */
00178 /* #define ERR_LIB_SSL2         22 */
00179 /* #define ERR_LIB_SSL3         23 */
00180 /* #define ERR_LIB_RSAREF       30 */
00181 /* #define ERR_LIB_PROXY        31 */
00182 # define ERR_LIB_BIO             32
00183 # define ERR_LIB_PKCS7           33
00184 # define ERR_LIB_X509V3          34
00185 # define ERR_LIB_PKCS12          35
00186 # define ERR_LIB_RAND            36
00187 # define ERR_LIB_DSO             37
00188 # define ERR_LIB_ENGINE          38
00189 # define ERR_LIB_OCSP            39
00190 # define ERR_LIB_UI              40
00191 # define ERR_LIB_COMP            41
00192 # define ERR_LIB_ECDSA           42
00193 # define ERR_LIB_ECDH            43
00194 # define ERR_LIB_STORE           44
00195 # define ERR_LIB_FIPS            45
00196 # define ERR_LIB_CMS             46
00197 # define ERR_LIB_TS              47
00198 # define ERR_LIB_HMAC            48
00199 # define ERR_LIB_JPAKE           49
00200 
00201 # define ERR_LIB_USER            128
00202 
00203 # define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)
00204 # define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)
00205 # define RSAerr(f,r)  ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)
00206 # define DHerr(f,r)   ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)
00207 # define EVPerr(f,r)  ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)
00208 # define BUFerr(f,r)  ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)
00209 # define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)
00210 # define PEMerr(f,r)  ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)
00211 # define DSAerr(f,r)  ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)
00212 # define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)
00213 # define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)
00214 # define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)
00215 # define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)
00216 # define ECerr(f,r)   ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)
00217 # define SSLerr(f,r)  ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)
00218 # define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)
00219 # define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)
00220 # define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)
00221 # define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)
00222 # define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)
00223 # define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)
00224 # define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)
00225 # define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)
00226 # define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)
00227 # define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)
00228 # define ECDSAerr(f,r)  ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__)
00229 # define ECDHerr(f,r)  ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)
00230 # define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)
00231 # define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)
00232 # define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)
00233 # define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)
00234 # define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)
00235 # define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)
00236 
00237 /*
00238  * Borland C seems too stupid to be able to shift and do longs in the
00239  * pre-processor :-(
00240  */
00241 # define ERR_PACK(l,f,r)         (((((unsigned long)l)&0xffL)*0x1000000)| \
00242                                 ((((unsigned long)f)&0xfffL)*0x1000)| \
00243                                 ((((unsigned long)r)&0xfffL)))
00244 # define ERR_GET_LIB(l)          (int)((((unsigned long)l)>>24L)&0xffL)
00245 # define ERR_GET_FUNC(l)         (int)((((unsigned long)l)>>12L)&0xfffL)
00246 # define ERR_GET_REASON(l)       (int)((l)&0xfffL)
00247 # define ERR_FATAL_ERROR(l)      (int)((l)&ERR_R_FATAL)
00248 
00249 /* OS functions */
00250 # define SYS_F_FOPEN             1
00251 # define SYS_F_CONNECT           2
00252 # define SYS_F_GETSERVBYNAME     3
00253 # define SYS_F_SOCKET            4
00254 # define SYS_F_IOCTLSOCKET       5
00255 # define SYS_F_BIND              6
00256 # define SYS_F_LISTEN            7
00257 # define SYS_F_ACCEPT            8
00258 # define SYS_F_WSASTARTUP        9/* Winsock stuff */
00259 # define SYS_F_OPENDIR           10
00260 # define SYS_F_FREAD             11
00261 
00262 /* reasons */
00263 # define ERR_R_SYS_LIB   ERR_LIB_SYS/* 2 */
00264 # define ERR_R_BN_LIB    ERR_LIB_BN/* 3 */
00265 # define ERR_R_RSA_LIB   ERR_LIB_RSA/* 4 */
00266 # define ERR_R_DH_LIB    ERR_LIB_DH/* 5 */
00267 # define ERR_R_EVP_LIB   ERR_LIB_EVP/* 6 */
00268 # define ERR_R_BUF_LIB   ERR_LIB_BUF/* 7 */
00269 # define ERR_R_OBJ_LIB   ERR_LIB_OBJ/* 8 */
00270 # define ERR_R_PEM_LIB   ERR_LIB_PEM/* 9 */
00271 # define ERR_R_DSA_LIB   ERR_LIB_DSA/* 10 */
00272 # define ERR_R_X509_LIB  ERR_LIB_X509/* 11 */
00273 # define ERR_R_ASN1_LIB  ERR_LIB_ASN1/* 13 */
00274 # define ERR_R_CONF_LIB  ERR_LIB_CONF/* 14 */
00275 # define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO/* 15 */
00276 # define ERR_R_EC_LIB    ERR_LIB_EC/* 16 */
00277 # define ERR_R_SSL_LIB   ERR_LIB_SSL/* 20 */
00278 # define ERR_R_BIO_LIB   ERR_LIB_BIO/* 32 */
00279 # define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */
00280 # define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */
00281 # define ERR_R_PKCS12_LIB ERR_LIB_PKCS12/* 35 */
00282 # define ERR_R_RAND_LIB  ERR_LIB_RAND/* 36 */
00283 # define ERR_R_DSO_LIB   ERR_LIB_DSO/* 37 */
00284 # define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */
00285 # define ERR_R_OCSP_LIB  ERR_LIB_OCSP/* 39 */
00286 # define ERR_R_UI_LIB    ERR_LIB_UI/* 40 */
00287 # define ERR_R_COMP_LIB  ERR_LIB_COMP/* 41 */
00288 # define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */
00289 # define ERR_R_ECDH_LIB  ERR_LIB_ECDH/* 43 */
00290 # define ERR_R_STORE_LIB ERR_LIB_STORE/* 44 */
00291 # define ERR_R_TS_LIB    ERR_LIB_TS/* 45 */
00292 
00293 # define ERR_R_NESTED_ASN1_ERROR                 58
00294 # define ERR_R_BAD_ASN1_OBJECT_HEADER            59
00295 # define ERR_R_BAD_GET_ASN1_OBJECT_CALL          60
00296 # define ERR_R_EXPECTING_AN_ASN1_SEQUENCE        61
00297 # define ERR_R_ASN1_LENGTH_MISMATCH              62
00298 # define ERR_R_MISSING_ASN1_EOS                  63
00299 
00300 /* fatal error */
00301 # define ERR_R_FATAL                             64
00302 # define ERR_R_MALLOC_FAILURE                    (1|ERR_R_FATAL)
00303 # define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED       (2|ERR_R_FATAL)
00304 # define ERR_R_PASSED_NULL_PARAMETER             (3|ERR_R_FATAL)
00305 # define ERR_R_INTERNAL_ERROR                    (4|ERR_R_FATAL)
00306 # define ERR_R_DISABLED                          (5|ERR_R_FATAL)
00307 
00308 /*
00309  * 99 is the maximum possible ERR_R_... code, higher values are reserved for
00310  * the individual libraries
00311  */
00312 
00313 typedef struct ERR_string_data_st {
00314     unsigned long error;
00315     const char *string;
00316 } ERR_STRING_DATA;
00317 
00318 void ERR_put_error(int lib, int func, int reason, const char *file, int line);
00319 void ERR_set_error_data(char *data, int flags);
00320 
00321 unsigned long ERR_get_error(void);
00322 unsigned long ERR_get_error_line(const char **file, int *line);
00323 unsigned long ERR_get_error_line_data(const char **file, int *line,
00324                                       const char **data, int *flags);
00325 unsigned long ERR_peek_error(void);
00326 unsigned long ERR_peek_error_line(const char **file, int *line);
00327 unsigned long ERR_peek_error_line_data(const char **file, int *line,
00328                                        const char **data, int *flags);
00329 unsigned long ERR_peek_last_error(void);
00330 unsigned long ERR_peek_last_error_line(const char **file, int *line);
00331 unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
00332                                             const char **data, int *flags);
00333 void ERR_clear_error(void);
00334 char *ERR_error_string(unsigned long e, char *buf);
00335 void ERR_error_string_n(unsigned long e, char *buf, size_t len);
00336 const char *ERR_lib_error_string(unsigned long e);
00337 const char *ERR_func_error_string(unsigned long e);
00338 const char *ERR_reason_error_string(unsigned long e);
00339 void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
00340                          void *u);
00341 # ifndef OPENSSL_NO_FP_API
00342 void ERR_print_errors_fp(FILE *fp);
00343 # endif
00344 # ifndef OPENSSL_NO_BIO
00345 void ERR_print_errors(BIO *bp);
00346 # endif
00347 void ERR_add_error_data(int num, ...);
00348 void ERR_add_error_vdata(int num, va_list args);
00349 void ERR_load_strings(int lib, ERR_STRING_DATA str[]);
00350 void ERR_unload_strings(int lib, ERR_STRING_DATA str[]);
00351 void ERR_load_ERR_strings(void);
00352 void ERR_load_crypto_strings(void);
00353 void ERR_free_strings(void);
00354 
00355 void ERR_remove_thread_state(const CRYPTO_THREADID *tid);
00356 # ifndef OPENSSL_NO_DEPRECATED
00357 void ERR_remove_state(unsigned long pid); /* if zero we look it up */
00358 # endif
00359 ERR_STATE *ERR_get_state(void);
00360 
00361 # ifndef OPENSSL_NO_LHASH
00362 LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void);
00363 LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void);
00364 void ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash);
00365 # endif
00366 
00367 int ERR_get_next_error_library(void);
00368 
00369 int ERR_set_mark(void);
00370 int ERR_pop_to_mark(void);
00371 
00372 /* Already defined in ossl_typ.h */
00373 /* typedef struct st_ERR_FNS ERR_FNS; */
00374 /*
00375  * An application can use this function and provide the return value to
00376  * loaded modules that should use the application's ERR state/functionality
00377  */
00378 const ERR_FNS *ERR_get_implementation(void);
00379 /*
00380  * A loaded module should call this function prior to any ERR operations
00381  * using the application's "ERR_FNS".
00382  */
00383 int ERR_set_implementation(const ERR_FNS *fns);
00384 
00385 #ifdef  __cplusplus
00386 }
00387 #endif
00388 
00389 #endif