1 /* $OpenBSD: err.h,v 1.25 2017/02/20 23:21:19 beck Exp $ */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3  * All rights reserved.
4  *
5  * This package is an SSL implementation written
6  * by Eric Young (eay@cryptsoft.com).
7  * The implementation was written so as to conform with Netscapes SSL.
8  *
9  * This library is free for commercial and non-commercial use as core.stdc.config.c_long as
10  * the following conditions are aheared to.  The following conditions
11  * apply to all code found in this distribution, be it the RC4, RSA,
12  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13  * included with this distribution is covered by the same copyright terms
14  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15  *
16  * Copyright remains Eric Young's, and as such any Copyright notices in
17  * the code are not to be removed.
18  * If this package is used in a product, Eric Young should be given attribution
19  * as the author of the parts of the library used.
20  * This can be in the form of a textual message at program startup or
21  * in documentation (online or textual) provided with the package.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26  * 1. Redistributions of source code must retain the copyright
27  *    notice, this list of conditions and the following disclaimer.
28  * 2. Redistributions in binary form must reproduce the above copyright
29  *    notice, this list of conditions and the following disclaimer in the
30  *    documentation and/or other materials provided with the distribution.
31  * 3. All advertising materials mentioning features or use of this software
32  *    must display the following acknowledgement:
33  *    "This product includes cryptographic software written by
34  *     Eric Young (eay@cryptsoft.com)"
35  *    The word 'cryptographic' can be left out if the rouines from the library
36  *    being used are not cryptographic related :-).
37  * 4. If you include any Windows specific code (or a derivative thereof) from
38  *    the apps directory (application code) you must include an acknowledgement:
39  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40  *
41  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  *
53  * The licence and distribution terms for any publically available version or
54  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55  * copied and put under another distribution licence
56  * [including the GNU Public Licence.]
57  */
58 /* ====================================================================
59  * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.
60  *
61  * Redistribution and use in source and binary forms, with or without
62  * modification, are permitted provided that the following conditions
63  * are met:
64  *
65  * 1. Redistributions of source code must retain the above copyright
66  *    notice, this list of conditions and the following disclaimer.
67  *
68  * 2. Redistributions in binary form must reproduce the above copyright
69  *    notice, this list of conditions and the following disclaimer in
70  *    the documentation and/or other materials provided with the
71  *    distribution.
72  *
73  * 3. All advertising materials mentioning features or use of this
74  *    software must display the following acknowledgment:
75  *    "This product includes software developed by the OpenSSL Project
76  *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77  *
78  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79  *    endorse or promote products derived from this software without
80  *    prior written permission. For written permission, please contact
81  *    openssl-core@openssl.org.
82  *
83  * 5. Products derived from this software may not be called "OpenSSL"
84  *    nor may "OpenSSL" appear in their names without prior written
85  *    permission of the OpenSSL Project.
86  *
87  * 6. Redistributions of any form whatsoever must retain the following
88  *    acknowledgment:
89  *    "This product includes software developed by the OpenSSL Project
90  *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91  *
92  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
96  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103  * OF THE POSSIBILITY OF SUCH DAMAGE.
104  * ====================================================================
105  *
106  * This product includes cryptographic software written by Eric Young
107  * (eay@cryptsoft.com).  This product includes software written by Tim
108  * Hudson (tjh@cryptsoft.com).
109  *
110  */
111 module libressl_d.openssl.err;
112 
113 
114 private static import core.stdc.config;
115 private static import core.stdc.stdarg;
116 private static import libressl_d.openssl.crypto;
117 public import core.stdc.errno;
118 public import libressl_d.compat.stdio;
119 public import libressl_d.compat.stdlib;
120 public import libressl_d.openssl.bio;
121 public import libressl_d.openssl.opensslconf;
122 public import libressl_d.openssl.ossl_typ;
123 
124 version (OPENSSL_NO_BIO) {
125 } else {
126 	public import libressl_d.openssl.bio;
127 }
128 
129 version (OPENSSL_NO_LHASH) {
130 } else {
131 	public import libressl_d.openssl.lhash;
132 }
133 
134 extern (C):
135 nothrow @nogc:
136 
137 version (OPENSSL_NO_ERR) {
138 	pragma(inline, true)
139 	void ERR_PUT_error(int a, int b, int c, const (char)* d, int e)
140 
141 		do
142 		{
143 			.ERR_put_error(a, b, c, null, 0);
144 		}
145 } else {
146 	pragma(inline, true)
147 	void ERR_PUT_error(int a, int b, int c, const (char)* d, int e)
148 
149 		do
150 		{
151 			.ERR_put_error(a, b, c, d, e);
152 		}
153 }
154 
155 enum ERR_TXT_MALLOCED = 0x01;
156 enum ERR_TXT_STRING = 0x02;
157 
158 enum ERR_FLAG_MARK = 0x01;
159 
160 enum ERR_NUM_ERRORS = 16;
161 
162 struct err_state_st
163 {
164 	libressl_d.openssl.crypto.CRYPTO_THREADID tid;
165 	int[.ERR_NUM_ERRORS] err_flags;
166 	core.stdc.config.c_ulong[.ERR_NUM_ERRORS] err_buffer;
167 	char*[.ERR_NUM_ERRORS] err_data;
168 	int[.ERR_NUM_ERRORS] err_data_flags;
169 	const (char)*[.ERR_NUM_ERRORS] err_file;
170 	int[.ERR_NUM_ERRORS] err_line;
171 	int top;
172 	int bottom;
173 }
174 
175 alias ERR_STATE = .err_state_st;
176 
177 /* library */
178 enum ERR_LIB_NONE = 1;
179 enum ERR_LIB_SYS = 2;
180 enum ERR_LIB_BN = 3;
181 enum ERR_LIB_RSA = 4;
182 enum ERR_LIB_DH = 5;
183 enum ERR_LIB_EVP = 6;
184 enum ERR_LIB_BUF = 7;
185 enum ERR_LIB_OBJ = 8;
186 enum ERR_LIB_PEM = 9;
187 enum ERR_LIB_DSA = 10;
188 enum ERR_LIB_X509 = 11;
189 /* enum ERR_LIB_METH = 12; */
190 enum ERR_LIB_ASN1 = 13;
191 enum ERR_LIB_CONF = 14;
192 enum ERR_LIB_CRYPTO = 15;
193 enum ERR_LIB_EC = 16;
194 enum ERR_LIB_SSL = 20;
195 /* enum ERR_LIB_SSL23 = 21; */
196 /* enum ERR_LIB_SSL2 = 22; */
197 /* enum ERR_LIB_SSL3 = 23; */
198 /* enum ERR_LIB_RSAREF = 30; */
199 /* enum ERR_LIB_PROXY = 31; */
200 enum ERR_LIB_BIO = 32;
201 enum ERR_LIB_PKCS7 = 33;
202 enum ERR_LIB_X509V3 = 34;
203 enum ERR_LIB_PKCS12 = 35;
204 enum ERR_LIB_RAND = 36;
205 enum ERR_LIB_DSO = 37;
206 enum ERR_LIB_ENGINE = 38;
207 enum ERR_LIB_OCSP = 39;
208 enum ERR_LIB_UI = 40;
209 enum ERR_LIB_COMP = 41;
210 enum ERR_LIB_ECDSA = 42;
211 enum ERR_LIB_ECDH = 43;
212 enum ERR_LIB_STORE = 44;
213 enum ERR_LIB_FIPS = 45;
214 enum ERR_LIB_CMS = 46;
215 enum ERR_LIB_TS = 47;
216 enum ERR_LIB_HMAC = 48;
217 enum ERR_LIB_JPAKE = 49;
218 enum ERR_LIB_GOST = 50;
219 
220 enum ERR_LIB_USER = 128;
221 
222 version (LIBRESSL_INTERNAL) {
223 } else {
224 	template SYSerr(string f, string r)
225 	{
226 		enum SYSerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_SYS, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
227 	}
228 
229 	template BNerr(string f, string r)
230 	{
231 		enum BNerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_BN, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
232 	}
233 
234 	template RSAerr(string f, string r)
235 	{
236 		enum RSAerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_RSA, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
237 	}
238 
239 	template DHerr(string f, string r)
240 	{
241 		enum DHerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_DH, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
242 	}
243 
244 	template EVPerr(string f, string r)
245 	{
246 		enum EVPerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_EVP, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
247 	}
248 
249 	template BUFerr(string f, string r)
250 	{
251 		enum BUFerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_BUF, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
252 	}
253 
254 	template OBJerr(string f, string r)
255 	{
256 		enum OBJerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_OBJ, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
257 	}
258 
259 	template PEMerr(string f, string r)
260 	{
261 		enum PEMerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_PEM, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
262 	}
263 
264 	template DSAerr(string f, string r)
265 	{
266 		enum DSAerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_DSA, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
267 	}
268 
269 	template X509err(string f, string r)
270 	{
271 		enum X509err = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_X509, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
272 	}
273 
274 	template ASN1err(string f, string r)
275 	{
276 		enum ASN1err = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_ASN1, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
277 	}
278 
279 	template CONFerr(string f, string r)
280 	{
281 		enum CONFerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_CONF, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
282 	}
283 
284 	template CRYPTOerr(string f, string r)
285 	{
286 		enum CRYPTOerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_CRYPTO, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
287 	}
288 
289 	template ECerr(string f, string r)
290 	{
291 		enum ECerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_EC, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
292 	}
293 
294 	template BIOerr(string f, string r)
295 	{
296 		enum BIOerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_BIO, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
297 	}
298 
299 	template PKCS7err(string f, string r)
300 	{
301 		enum PKCS7err = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_PKCS7, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
302 	}
303 
304 	template X509V3err(string f, string r)
305 	{
306 		enum X509V3err = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_X509V3, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
307 	}
308 
309 	template PKCS12err(string f, string r)
310 	{
311 		enum PKCS12err = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_PKCS12, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
312 	}
313 
314 	template RANDerr(string f, string r)
315 	{
316 		enum RANDerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_RAND, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
317 	}
318 
319 	template DSOerr(string f, string r)
320 	{
321 		enum DSOerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_DSO, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
322 	}
323 
324 	template ENGINEerr(string f, string r)
325 	{
326 		enum ENGINEerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_ENGINE, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
327 	}
328 
329 	template OCSPerr(string f, string r)
330 	{
331 		enum OCSPerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_OCSP, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
332 	}
333 
334 	template UIerr(string f, string r)
335 	{
336 		enum UIerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_UI, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
337 	}
338 
339 	template COMPerr(string f, string r)
340 	{
341 		enum COMPerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_COMP, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
342 	}
343 
344 	template ECDSAerr(string f, string r)
345 	{
346 		enum ECDSAerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_ECDSA, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
347 	}
348 
349 	template ECDHerr(string f, string r)
350 	{
351 		enum ECDHerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_ECDH, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
352 	}
353 
354 	template STOREerr(string f, string r)
355 	{
356 		enum STOREerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_STORE, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
357 	}
358 
359 	template FIPSerr(string f, string r)
360 	{
361 		enum FIPSerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_FIPS, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
362 	}
363 
364 	template CMSerr(string f, string r)
365 	{
366 		enum CMSerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_CMS, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
367 	}
368 
369 	template TSerr(string f, string r)
370 	{
371 		enum TSerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_TS, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
372 	}
373 
374 	template HMACerr(string f, string r)
375 	{
376 		enum HMACerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_HMAC, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
377 	}
378 
379 	template JPAKEerr(string f, string r)
380 	{
381 		enum JPAKEerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_JPAKE, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
382 	}
383 
384 	template GOSTerr(string f, string r)
385 	{
386 		enum GOSTerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_GOST, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
387 	}
388 
389 	template SSLerr(string f, string r)
390 	{
391 		enum SSLerr = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_SSL, " ~ f ~ ", " ~ r ~ ", __FILE__, __LINE__);";
392 	}
393 }
394 
395 version (LIBRESSL_INTERNAL) {
396 	template SYSerror(string r)
397 	{
398 		enum SYSerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_SYS, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
399 	}
400 
401 	template BNerror(string r)
402 	{
403 		enum BNerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_BN, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
404 	}
405 
406 	template RSAerror(string r)
407 	{
408 		enum RSAerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_RSA, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
409 	}
410 
411 	template DHerror(string r)
412 	{
413 		enum DHerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_DH, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
414 	}
415 
416 	template EVPerror(string r)
417 	{
418 		enum EVPerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_EVP, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
419 	}
420 
421 	template BUFerror(string r)
422 	{
423 		enum BUFerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_BUF, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
424 	}
425 
426 	template OBJerror(string r)
427 	{
428 		enum OBJerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_OBJ, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
429 	}
430 
431 	template PEMerror(string r)
432 	{
433 		enum PEMerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_PEM, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
434 	}
435 
436 	template DSAerror(string r)
437 	{
438 		enum DSAerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_DSA, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
439 	}
440 
441 	template X509error(string r)
442 	{
443 		enum X509error = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_X509, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
444 	}
445 
446 	template ASN1error(string r)
447 	{
448 		enum ASN1error = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_ASN1, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
449 	}
450 
451 	template CONFerror(string r)
452 	{
453 		enum CONFerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_CONF, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
454 	}
455 
456 	template CRYPTOerror(string r)
457 	{
458 		enum CRYPTOerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_CRYPTO, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
459 	}
460 
461 	template ECerror(string r)
462 	{
463 		enum ECerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_EC, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
464 	}
465 
466 	template BIOerror(string r)
467 	{
468 		enum BIOerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_BIO, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
469 	}
470 
471 	template PKCS7error(string r)
472 	{
473 		enum PKCS7error = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_PKCS7, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
474 	}
475 
476 	template X509V3error(string r)
477 	{
478 		enum X509V3error = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_X509V3, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
479 	}
480 
481 	template PKCS12error(string r)
482 	{
483 		enum PKCS12error = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_PKCS12, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
484 	}
485 
486 	template RANDerror(string r)
487 	{
488 		enum RANDerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_RAND, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
489 	}
490 
491 	template DSOerror(string r)
492 	{
493 		enum DSOerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_DSO, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
494 	}
495 
496 	template ENGINEerror(string r)
497 	{
498 		enum ENGINEerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_ENGINE, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
499 	}
500 
501 	template OCSPerror(string r)
502 	{
503 		enum OCSPerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_OCSP, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
504 	}
505 
506 	template UIerror(string r)
507 	{
508 		enum UIerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_UI, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
509 	}
510 
511 	template COMPerror(string r)
512 	{
513 		enum COMPerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_COMP, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
514 	}
515 
516 	template ECDSAerror(string r)
517 	{
518 		enum ECDSAerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_ECDSA, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
519 	}
520 
521 	template ECDHerror(string r)
522 	{
523 		enum ECDHerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_ECDH, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
524 	}
525 
526 	template STOREerror(string r)
527 	{
528 		enum STOREerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_STORE, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
529 	}
530 
531 	template FIPSerror(string r)
532 	{
533 		enum FIPSerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_FIPS, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
534 	}
535 
536 	template CMSerror(string r)
537 	{
538 		enum CMSerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_CMS, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
539 	}
540 
541 	template TSerror(string r)
542 	{
543 		enum TSerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_TS, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
544 	}
545 
546 	template HMACerror(string r)
547 	{
548 		enum HMACerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_HMAC, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
549 	}
550 
551 	template JPAKEerror(string r)
552 	{
553 		enum JPAKEerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_JPAKE, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
554 	}
555 
556 	template GOSTerror(string r)
557 	{
558 		enum GOSTerror = "libressl_d.openssl.err.ERR_PUT_error(libressl_d.openssl.err.ERR_LIB_GOST, 0x0FFF, " ~ r ~", __FILE__, __LINE__);";
559 	}
560 }
561 
562 pragma(inline, true)
563 core.stdc.config.c_ulong ERR_PACK(core.stdc.config.c_ulong l, core.stdc.config.c_ulong f, core.stdc.config.c_ulong r)
564 
565 	do
566 	{
567 		return ((l & 0xFFL) << 24L) | ((f & 0x0FFFL) << 12L) | (r & 0x0FFFL);
568 	}
569 
570 pragma(inline, true)
571 int ERR_GET_LIB(core.stdc.config.c_ulong l)
572 
573 	do
574 	{
575 		return cast(int)((l >> 24L) & 0xFFL);
576 	}
577 
578 pragma(inline, true)
579 int ERR_GET_FUNC(core.stdc.config.c_ulong l)
580 
581 	do
582 	{
583 		return cast(int)((l >> 12L) & 0x0FFFL);
584 	}
585 
586 pragma(inline, true)
587 int ERR_GET_REASON(L)(L l)
588 
589 	do
590 	{
591 		return cast(int)(l & 0x0FFFL);
592 	}
593 
594 pragma(inline, true)
595 int ERR_FATAL_ERROR(L)(L l)
596 
597 	do
598 	{
599 		return cast(int)(l & .ERR_R_FATAL);
600 	}
601 
602 /* OS functions */
603 enum SYS_F_FOPEN = 1;
604 enum SYS_F_CONNECT = 2;
605 enum SYS_F_GETSERVBYNAME = 3;
606 enum SYS_F_SOCKET = 4;
607 enum SYS_F_IOCTLSOCKET = 5;
608 enum SYS_F_BIND = 6;
609 enum SYS_F_LISTEN = 7;
610 enum SYS_F_ACCEPT = 8;
611 
612 /**
613  * Winsock stuff
614  */
615 enum SYS_F_WSASTARTUP = 9;
616 
617 enum SYS_F_OPENDIR = 10;
618 enum SYS_F_FREAD = 11;
619 
620 /* reasons */
621 
622 /**
623  * 2
624  */
625 enum ERR_R_SYS_LIB = .ERR_LIB_SYS;
626 
627 /**
628  * 3
629  */
630 enum ERR_R_BN_LIB = .ERR_LIB_BN;
631 
632 /**
633  * 4
634  */
635 enum ERR_R_RSA_LIB = .ERR_LIB_RSA;
636 
637 /**
638  * 5
639  */
640 enum ERR_R_DH_LIB = .ERR_LIB_DH;
641 
642 /**
643  * 6
644  */
645 enum ERR_R_EVP_LIB = .ERR_LIB_EVP;
646 
647 /**
648  * 7
649  */
650 enum ERR_R_BUF_LIB = .ERR_LIB_BUF;
651 
652 /**
653  * 8
654  */
655 enum ERR_R_OBJ_LIB = .ERR_LIB_OBJ;
656 
657 /**
658  * 9
659  */
660 enum ERR_R_PEM_LIB = .ERR_LIB_PEM;
661 
662 /**
663  * 10
664  */
665 enum ERR_R_DSA_LIB = .ERR_LIB_DSA;
666 
667 /**
668  * 11
669  */
670 enum ERR_R_X509_LIB = .ERR_LIB_X509;
671 
672 /**
673  * 13
674  */
675 enum ERR_R_ASN1_LIB = .ERR_LIB_ASN1;
676 
677 /**
678  * 14
679  */
680 enum ERR_R_CONF_LIB = .ERR_LIB_CONF;
681 
682 /**
683  * 15
684  */
685 enum ERR_R_CRYPTO_LIB = .ERR_LIB_CRYPTO;
686 
687 /**
688  * 16
689  */
690 enum ERR_R_EC_LIB = .ERR_LIB_EC;
691 
692 /**
693  * 20
694  */
695 enum ERR_R_SSL_LIB = .ERR_LIB_SSL;
696 
697 /**
698  * 32
699  */
700 enum ERR_R_BIO_LIB = .ERR_LIB_BIO;
701 
702 /**
703  * 33
704  */
705 enum ERR_R_PKCS7_LIB = .ERR_LIB_PKCS7;
706 
707 /**
708  * 34
709  */
710 enum ERR_R_X509V3_LIB = .ERR_LIB_X509V3;
711 
712 /**
713  * 35
714  */
715 enum ERR_R_PKCS12_LIB = .ERR_LIB_PKCS12;
716 
717 /**
718  * 36
719  */
720 enum ERR_R_RAND_LIB = .ERR_LIB_RAND;
721 
722 /**
723  * 37
724  */
725 enum ERR_R_DSO_LIB = .ERR_LIB_DSO;
726 
727 /**
728  * 38
729  */
730 enum ERR_R_ENGINE_LIB = .ERR_LIB_ENGINE;
731 
732 /**
733  * 39
734  */
735 enum ERR_R_OCSP_LIB = .ERR_LIB_OCSP;
736 
737 /**
738  * 40
739  */
740 enum ERR_R_UI_LIB = .ERR_LIB_UI;
741 
742 /**
743  * 41
744  */
745 enum ERR_R_COMP_LIB = .ERR_LIB_COMP;
746 
747 /**
748  * 42
749  */
750 enum ERR_R_ECDSA_LIB = .ERR_LIB_ECDSA;
751 
752 /**
753  * 43
754  */
755 enum ERR_R_ECDH_LIB = .ERR_LIB_ECDH;
756 
757 /**
758  * 44
759  */
760 enum ERR_R_STORE_LIB = .ERR_LIB_STORE;
761 
762 /**
763  * 45
764  */
765 enum ERR_R_TS_LIB = .ERR_LIB_TS;
766 
767 enum ERR_R_NESTED_ASN1_ERROR = 58;
768 enum ERR_R_BAD_ASN1_OBJECT_HEADER = 59;
769 enum ERR_R_BAD_GET_ASN1_OBJECT_CALL = 60;
770 enum ERR_R_EXPECTING_AN_ASN1_SEQUENCE = 61;
771 enum ERR_R_ASN1_LENGTH_MISMATCH = 62;
772 enum ERR_R_MISSING_ASN1_EOS = 63;
773 
774 /* fatal error */
775 enum ERR_R_FATAL = 64;
776 enum ERR_R_MALLOC_FAILURE = 1 | .ERR_R_FATAL;
777 enum ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED = 2 | .ERR_R_FATAL;
778 enum ERR_R_PASSED_NULL_PARAMETER = 3 | .ERR_R_FATAL;
779 enum ERR_R_INTERNAL_ERROR = 4 | .ERR_R_FATAL;
780 enum ERR_R_DISABLED = 5 | .ERR_R_FATAL;
781 
782 /*
783  * 99 is the maximum possible ERR_R_... code, higher values
784  * are reserved for the individual libraries
785  */
786 
787 struct ERR_string_data_st
788 {
789 	core.stdc.config.c_ulong error;
790 	const (char)* string_;
791 }
792 
793 alias ERR_STRING_DATA = .ERR_string_data_st;
794 
795 void ERR_put_error(int lib, int func, int reason, const (char)* file, int line);
796 void ERR_set_error_data(char* data, int flags);
797 
798 core.stdc.config.c_ulong ERR_get_error();
799 core.stdc.config.c_ulong ERR_get_error_line(const (char)** file, int* line);
800 core.stdc.config.c_ulong ERR_get_error_line_data(const (char)** file, int* line, const (char)** data, int* flags);
801 core.stdc.config.c_ulong ERR_peek_error();
802 core.stdc.config.c_ulong ERR_peek_error_line(const (char)** file, int* line);
803 core.stdc.config.c_ulong ERR_peek_error_line_data(const (char)** file, int* line, const (char)** data, int* flags);
804 core.stdc.config.c_ulong ERR_peek_last_error();
805 core.stdc.config.c_ulong ERR_peek_last_error_line(const (char)** file, int* line);
806 core.stdc.config.c_ulong ERR_peek_last_error_line_data(const (char)** file, int* line, const (char)** data, int* flags);
807 void ERR_clear_error();
808 char* ERR_error_string(core.stdc.config.c_ulong e, char* buf);
809 void ERR_error_string_n(core.stdc.config.c_ulong e, char* buf, size_t len);
810 const (char)* ERR_lib_error_string(core.stdc.config.c_ulong e);
811 const (char)* ERR_func_error_string(core.stdc.config.c_ulong e);
812 const (char)* ERR_reason_error_string(core.stdc.config.c_ulong e);
813 void ERR_print_errors_cb(int function(const (char)* str, size_t len, void* u) cb, void* u);
814 void ERR_print_errors_fp(libressl_d.compat.stdio.FILE* fp);
815 
816 version (OPENSSL_NO_BIO) {
817 } else {
818 	void ERR_print_errors(libressl_d.openssl.bio.BIO* bp);
819 }
820 
821 void ERR_asprintf_error_data(char* format, ...);
822 
823 version (LIBRESSL_INTERNAL) {
824 } else {
825 	void ERR_add_error_data(int num, ...);
826 	void ERR_add_error_vdata(int num, core.stdc.stdarg.va_list args);
827 }
828 
829 void ERR_load_strings(int lib, .ERR_STRING_DATA* str);
830 void ERR_unload_strings(int lib, .ERR_STRING_DATA* str);
831 void ERR_load_ERR_strings();
832 void ERR_load_crypto_strings();
833 void ERR_free_strings();
834 
835 void ERR_remove_thread_state(const (libressl_d.openssl.crypto.CRYPTO_THREADID)* tid);
836 
837 version (OPENSSL_NO_DEPRECATED) {
838 } else {
839 	/**
840 	 * if zero we look it up
841 	 */
842 	void ERR_remove_state(core.stdc.config.c_ulong pid);
843 }
844 
845 .ERR_STATE* ERR_get_state();
846 
847 version (OPENSSL_NO_LHASH) {
848 } else {
849 	struct lhash_st_ERR_STRING_DATA;
850 	struct lhash_st_ERR_STATE;
851 	.lhash_st_ERR_STRING_DATA* ERR_get_string_table();
852 	.lhash_st_ERR_STATE* ERR_get_err_state_table();
853 	void ERR_release_err_state_table(.lhash_st_ERR_STATE** hash);
854 }
855 
856 int ERR_get_next_error_library();
857 
858 int ERR_set_mark();
859 int ERR_pop_to_mark();
860 
861 /* Already defined in ossl_typ.h */
862 /* alias ERR_FNS = .st_ERR_FNS; */
863 
864 /**
865  * An application can use this function and provide the return value to loaded
866  * modules that should use the application's ERR state/functionality
867  */
868 const (libressl_d.openssl.ossl_typ.ERR_FNS)* ERR_get_implementation();
869 
870 /**
871  * A loaded module should call this function prior to any ERR operations using
872  * the application's "ERR_FNS".
873  */
874 int ERR_set_implementation(const (libressl_d.openssl.ossl_typ.ERR_FNS)* fns);