]> git.saurik.com Git - apple/security.git/blame - OSX/libsecurity_apple_csp/open_ssl/openssl/err.h
Security-57740.31.2.tar.gz
[apple/security.git] / OSX / libsecurity_apple_csp / open_ssl / openssl / err.h
CommitLineData
b1ab9ed8 1/*
d8f41ccd 2 * Copyright (c) 2000-2001,2011,2014 Apple Inc. All Rights Reserved.
b1ab9ed8
A
3 *
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
8 * using this file.
9 *
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
16 */
17
18
19/* crypto/err/err.h */
20/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
21 * All rights reserved.
22 *
23 * This package is an SSL implementation written
24 * by Eric Young (eay@cryptsoft.com).
25 * The implementation was written so as to conform with Netscapes SSL.
26 *
27 * This library is free for commercial and non-commercial use as long as
28 * the following conditions are aheared to. The following conditions
29 * apply to all code found in this distribution, be it the RC4, RSA,
30 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
31 * included with this distribution is covered by the same copyright terms
32 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
33 *
34 * Copyright remains Eric Young's, and as such any Copyright notices in
35 * the code are not to be removed.
36 * If this package is used in a product, Eric Young should be given attribution
37 * as the author of the parts of the library used.
38 * This can be in the form of a textual message at program startup or
39 * in documentation (online or textual) provided with the package.
40 *
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
43 * are met:
44 * 1. Redistributions of source code must retain the copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. All advertising materials mentioning features or use of this software
50 * must display the following acknowledgement:
51 * "This product includes cryptographic software written by
52 * Eric Young (eay@cryptsoft.com)"
53 * The word 'cryptographic' can be left out if the rouines from the library
54 * being used are not cryptographic related :-).
55 * 4. If you include any Windows specific code (or a derivative thereof) from
56 * the apps directory (application code) you must include an acknowledgement:
57 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
58 *
59 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE.
70 *
71 * The licence and distribution terms for any publically available version or
72 * derivative of this code cannot be changed. i.e. this code cannot simply be
73 * copied and put under another distribution licence
74 * [including the GNU Public Licence.]
75 */
76
77#ifndef HEADER_ERR_H
78#define HEADER_ERR_H
79
80#ifdef __cplusplus
81extern "C" {
82#endif
83
84#include <openssl/opensslconf.h>
85
86#ifndef NO_FP_API
87#include <stdio.h>
88#endif
89
90/* The following is a bit of a trick to help the object files only contain
91 * the 'name of the file' string once. Since 'err.h' is protected by the
92 * HEADER_ERR_H stuff, this should be included only once per file. */
93
94#define ERR_file_name __FILE__
95
96#ifndef NO_ERR
97#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e)
98#else
99#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0)
100#endif
101
102#include <errno.h>
103
104#define ERR_TXT_MALLOCED 0x01
105#define ERR_TXT_STRING 0x02
106
107#define ERR_NUM_ERRORS 16
108typedef struct err_state_st
109 {
110 unsigned long pid;
111 unsigned long err_buffer[ERR_NUM_ERRORS];
112 char *err_data[ERR_NUM_ERRORS];
113 int err_data_flags[ERR_NUM_ERRORS];
114 const char *err_file[ERR_NUM_ERRORS];
115 int err_line[ERR_NUM_ERRORS];
116 int top,bottom;
117 } ERR_STATE;
118
119/* library */
120#define ERR_LIB_NONE 1
121#define ERR_LIB_SYS 2
122#define ERR_LIB_BN 3
123#define ERR_LIB_RSA 4
124#define ERR_LIB_DH 5
125#define ERR_LIB_EVP 6
126#define ERR_LIB_BUF 7
127#define ERR_LIB_OBJ 8
128#define ERR_LIB_PEM 9
129#define ERR_LIB_DSA 10
130#define ERR_LIB_X509 11
131#define ERR_LIB_METH 12
132#define ERR_LIB_ASN1 13
133#define ERR_LIB_CONF 14
134#define ERR_LIB_CRYPTO 15
135#define ERR_LIB_SSL 20
136#define ERR_LIB_SSL23 21
137#define ERR_LIB_SSL2 22
138#define ERR_LIB_SSL3 23
139#define ERR_LIB_RSAREF 30
140#define ERR_LIB_PROXY 31
141#define ERR_LIB_BIO 32
142#define ERR_LIB_PKCS7 33
143#define ERR_LIB_X509V3 34
144#define ERR_LIB_PKCS12 35
145#define ERR_LIB_RAND 36
146
147#define ERR_LIB_USER 128
148
149#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),ERR_file_name,__LINE__)
150#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),ERR_file_name,__LINE__)
151#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),ERR_file_name,__LINE__)
152#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),ERR_file_name,__LINE__)
153#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),ERR_file_name,__LINE__)
154#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),ERR_file_name,__LINE__)
155#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),ERR_file_name,__LINE__)
156#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),ERR_file_name,__LINE__)
157#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),ERR_file_name,__LINE__)
158#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),ERR_file_name,__LINE__)
159#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),ERR_file_name,__LINE__)
160#define METHerr(f,r) ERR_PUT_error(ERR_LIB_METH,(f),(r),ERR_file_name,__LINE__)
161#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),ERR_file_name,__LINE__)
162#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),ERR_file_name,__LINE__)
163#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),ERR_file_name,__LINE__)
164#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),ERR_file_name,__LINE__)
165#define SSL23err(f,r) ERR_PUT_error(ERR_LIB_SSL23,(f),(r),ERR_file_name,__LINE__)
166#define SSL2err(f,r) ERR_PUT_error(ERR_LIB_SSL2,(f),(r),ERR_file_name,__LINE__)
167#define SSL3err(f,r) ERR_PUT_error(ERR_LIB_SSL3,(f),(r),ERR_file_name,__LINE__)
168#define RSAREFerr(f,r) ERR_PUT_error(ERR_LIB_RSAREF,(f),(r),ERR_file_name,__LINE__)
169#define PROXYerr(f,r) ERR_PUT_error(ERR_LIB_PROXY,(f),(r),ERR_file_name,__LINE__)
170#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),ERR_file_name,__LINE__)
171#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),ERR_file_name,__LINE__)
172#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),ERR_file_name,__LINE__)
173#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),ERR_file_name,__LINE__)
174
175/* Borland C seems too stupid to be able to shift and do longs in
176 * the pre-processor :-( */
177#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)*0x1000000)| \
178 ((((unsigned long)f)&0xfffL)*0x1000)| \
179 ((((unsigned long)r)&0xfffL)))
180#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL)
181#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL)
182#define ERR_GET_REASON(l) (int)((l)&0xfffL)
183#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL)
184
185/* OS functions */
186#define SYS_F_FOPEN 1
187#define SYS_F_CONNECT 2
188#define SYS_F_GETSERVBYNAME 3
189#define SYS_F_SOCKET 4
190#define SYS_F_IOCTLSOCKET 5
191#define SYS_F_BIND 6
192#define SYS_F_LISTEN 7
193#define SYS_F_ACCEPT 8
194#define SYS_F_WSASTARTUP 9 /* Winsock stuff */
195#define SYS_F_OPENDIR 10
196
197#define ERR_R_FATAL 32
198/* reasons */
199#define ERR_R_SYS_LIB ERR_LIB_SYS
200#define ERR_R_BN_LIB ERR_LIB_BN
201#define ERR_R_RSA_LIB ERR_LIB_RSA
202#define ERR_R_DSA_LIB ERR_LIB_DSA
203#define ERR_R_DH_LIB ERR_LIB_DH
204#define ERR_R_EVP_LIB ERR_LIB_EVP
205#define ERR_R_BUF_LIB ERR_LIB_BUF
206#define ERR_R_BIO_LIB ERR_LIB_BIO
207#define ERR_R_OBJ_LIB ERR_LIB_OBJ
208#define ERR_R_PEM_LIB ERR_LIB_PEM
209#define ERR_R_X509_LIB ERR_LIB_X509
210#define ERR_R_METH_LIB ERR_LIB_METH
211#define ERR_R_ASN1_LIB ERR_LIB_ASN1
212#define ERR_R_CONF_LIB ERR_LIB_CONF
213#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO
214#define ERR_R_SSL_LIB ERR_LIB_SSL
215#define ERR_R_SSL23_LIB ERR_LIB_SSL23
216#define ERR_R_SSL2_LIB ERR_LIB_SSL2
217#define ERR_R_SSL3_LIB ERR_LIB_SSL3
218#define ERR_R_PROXY_LIB ERR_LIB_PROXY
219#define ERR_R_BIO_LIB ERR_LIB_BIO
220#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7
221#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12
222
223/* fatal error */
224#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL)
225#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL)
226#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL)
227#define ERR_R_NESTED_ASN1_ERROR (4)
228#define ERR_R_BAD_ASN1_OBJECT_HEADER (5)
229#define ERR_R_BAD_GET_ASN1_OBJECT_CALL (6)
230#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE (7)
231#define ERR_R_ASN1_LENGTH_MISMATCH (8)
232#define ERR_R_MISSING_ASN1_EOS (9)
233
234typedef struct ERR_string_data_st
235 {
236 unsigned long error;
237 const char *string;
238 } ERR_STRING_DATA;
239
240void ERR_put_error(int lib, int func,int reason,const char *file,int line);
241void ERR_set_error_data(char *data,int flags);
242
243unsigned long ERR_get_error(void );
244unsigned long ERR_get_error_line(const char **file,int *line);
245unsigned long ERR_get_error_line_data(const char **file,int *line,
246 const char **data, int *flags);
247unsigned long ERR_peek_error(void );
248unsigned long ERR_peek_error_line(const char **file,int *line);
249unsigned long ERR_peek_error_line_data(const char **file,int *line,
250 const char **data,int *flags);
251void ERR_clear_error(void );
252char *ERR_error_string(unsigned long e,char *buf);
253const char *ERR_lib_error_string(unsigned long e);
254const char *ERR_func_error_string(unsigned long e);
255const char *ERR_reason_error_string(unsigned long e);
256#ifndef NO_FP_API
257void ERR_print_errors_fp(FILE *fp);
258#endif
259#ifdef HEADER_BIO_H
260void ERR_print_errors(BIO *bp);
261void ERR_add_error_data(int num, ...);
262#endif
263void ERR_load_strings(int lib,ERR_STRING_DATA str[]);
264void ERR_load_ERR_strings(void);
265void ERR_load_crypto_strings(void);
266void ERR_free_strings(void);
267
268void ERR_remove_state(unsigned long pid); /* if zero we look it up */
269ERR_STATE *ERR_get_state(void);
270
271#ifdef HEADER_LHASH_H
272LHASH *ERR_get_string_table(void );
273LHASH *ERR_get_err_state_table(void );
274#else
275char *ERR_get_string_table(void );
276char *ERR_get_err_state_table(void );
277#endif
278
279int ERR_get_next_error_library(void );
280
281#ifdef __cplusplus
282}
283#endif
284
285#endif