1 /* $OpenBSD: bio.h,v 1.45 2018/06/02 04:41:12 tb 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 module libressl_d.openssl.bio;
59 
60 
61 private static import core.stdc.config;
62 private static import libressl_d.compat.netdb;
63 private static import libressl_d.openssl.ossl_typ;
64 private static import libressl_d.openssl.stack;
65 public import core.stdc.stdarg;
66 public import libressl_d.compat.stdio;
67 public import libressl_d.openssl.crypto;
68 public import libressl_d.openssl.opensslconf;
69 
70 enum HEADER_BIO_H = true;
71 
72 //#if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__OpenBSD__)
73 //	#define __bounded__(x, y, z)
74 //#endif
75 
76 extern (C):
77 nothrow @nogc:
78 
79 /* These are the 'types' of BIOs */
80 enum BIO_TYPE_NONE = 0;
81 enum BIO_TYPE_MEM = 1 | 0x0400;
82 enum BIO_TYPE_FILE = 2 | 0x0400;
83 
84 enum BIO_TYPE_FD = 4 | 0x0400 | 0x0100;
85 enum BIO_TYPE_SOCKET = 5 | 0x0400 | 0x0100;
86 enum BIO_TYPE_NULL = 6 | 0x0400;
87 enum BIO_TYPE_SSL = 7 | 0x0200;
88 
89 /**
90  * passive filter
91  */
92 enum BIO_TYPE_MD = 8 | 0x0200;
93 
94 /**
95  * filter
96  */
97 enum BIO_TYPE_BUFFER = 9 | 0x0200;
98 
99 ///Ditto
100 enum BIO_TYPE_CIPHER = 10 | 0x0200;
101 
102 ///Ditto
103 enum BIO_TYPE_BASE64 = 11 | 0x0200;
104 
105 /**
106  * socket - connect
107  */
108 enum BIO_TYPE_CONNECT = 12 | 0x0400 | 0x0100;
109 
110 /**
111  * socket for accept
112  */
113 enum BIO_TYPE_ACCEPT = 13 | 0x0400 | 0x0100;
114 
115 /**
116  * client proxy BIO
117  */
118 enum BIO_TYPE_PROXY_CLIENT = 14 | 0x0200;
119 
120 /**
121  * server proxy BIO
122  */
123 enum BIO_TYPE_PROXY_SERVER = 15 | 0x0200;
124 
125 ///Ditto
126 enum BIO_TYPE_NBIO_TEST = 16 | 0x0200;
127 
128 enum BIO_TYPE_NULL_FILTER = 17 | 0x0200;
129 
130 /**
131  * BER . bin filter
132  */
133 enum BIO_TYPE_BER = 18 | 0x0200;
134 
135 /**
136  * (half a) BIO pair
137  */
138 enum BIO_TYPE_BIO = 19 | 0x0400;
139 
140 /**
141  * filter
142  */
143 enum BIO_TYPE_LINEBUFFER = 20 | 0x0200;
144 
145 enum BIO_TYPE_DGRAM = 21 | 0x0400 | 0x0100;
146 
147 /**
148  * filter
149  */
150 enum BIO_TYPE_ASN1 = 22 | 0x0200;
151 
152 ///Ditto
153 enum BIO_TYPE_COMP = 23 | 0x0200;
154 
155 /**
156  * socket, fd, connect or accept
157  */
158 enum BIO_TYPE_DESCRIPTOR = 0x0100;
159 
160 enum BIO_TYPE_FILTER = 0x0200;
161 enum BIO_TYPE_SOURCE_SINK = 0x0400;
162 
163 /**
164  * BIO_TYPE_START is the first user-allocated BIO type. No pre-defined type,
165  * flag bits aside, may exceed this value.
166  */
167 enum BIO_TYPE_START = 128;
168 
169 /*
170  * BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
171  * BIO_set_fp(in_,stdin,BIO_NOCLOSE);
172  */
173 enum BIO_NOCLOSE = 0x00;
174 enum BIO_CLOSE = 0x01;
175 
176 /*
177  * These are used in the following macros and are passed to
178  * BIO_ctrl()
179  */
180 
181 /**
182  * opt - rewind/zero etc
183  */
184 enum BIO_CTRL_RESET = 1;
185 
186 /**
187  * opt - are we at the eof
188  */
189 enum BIO_CTRL_EOF = 2;
190 
191 /**
192  * opt - extra tit-bits
193  */
194 enum BIO_CTRL_INFO = 3;
195 
196 /**
197  * man - set the 'IO' type
198  */
199 enum BIO_CTRL_SET = 4;
200 
201 /**
202  * man - get the 'IO' type
203  */
204 enum BIO_CTRL_GET = 5;
205 
206 /**
207  * opt - internal, used to signify change
208  */
209 enum BIO_CTRL_PUSH = 6;
210 
211 ///Ditto
212 enum BIO_CTRL_POP = 7;
213 
214 /**
215  * man - set the 'close' on free
216  */
217 enum BIO_CTRL_GET_CLOSE = 8;
218 
219 ///Ditto
220 enum BIO_CTRL_SET_CLOSE = 9;
221 
222 /**
223  * opt - is their more data buffered
224  */
225 enum BIO_CTRL_PENDING = 10;
226 
227 /**
228  * opt - 'flush' buffered output
229  */
230 enum BIO_CTRL_FLUSH = 11;
231 
232 /**
233  * man - extra stuff for 'duped' BIO
234  */
235 enum BIO_CTRL_DUP = 12;
236 
237 /**
238  * opt - number of bytes still to write
239  */
240 enum BIO_CTRL_WPENDING = 13;
241 
242 /* callback is int cb(BIO* io,state,ret); */
243 
244 /**
245  * opt - set callback function
246  */
247 enum BIO_CTRL_SET_CALLBACK = 14;
248 
249 ///Ditto
250 enum BIO_CTRL_GET_CALLBACK = 15;
251 
252 /**
253  * BIO_s_file special
254  */
255 enum BIO_CTRL_SET_FILENAME = 30;
256 
257 /* dgram BIO stuff */
258 
259 /**
260  * BIO dgram special
261  */
262 enum BIO_CTRL_DGRAM_CONNECT = 31;
263 
264 /**
265  * allow for an externally
266  * connected socket to be
267  * passed in
268  */
269 enum BIO_CTRL_DGRAM_SET_CONNECTED = 32;
270 
271 /**
272  * setsockopt, essentially
273  */
274 enum BIO_CTRL_DGRAM_SET_RECV_TIMEOUT = 33;
275 
276 /**
277  * getsockopt, essentially
278  */
279 enum BIO_CTRL_DGRAM_GET_RECV_TIMEOUT = 34;
280 
281 /**
282  * setsockopt, essentially
283  */
284 enum BIO_CTRL_DGRAM_SET_SEND_TIMEOUT = 35;
285 
286 /**
287  * getsockopt, essentially
288  */
289 enum BIO_CTRL_DGRAM_GET_SEND_TIMEOUT = 36;
290 
291 /**
292  * flag whether the last
293  */
294 enum BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP = 37;
295 
296 /**
297  * I/O operation tiemd out
298  */
299 enum BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP = 38;
300 
301 /* #ifdef IP_MTU_DISCOVER */
302 	/**
303 	 * set DF bit on egress packets
304 	 */
305 	enum BIO_CTRL_DGRAM_MTU_DISCOVER = 39;
306 /* #endif */
307 
308 /**
309  * as kernel for current MTU
310  */
311 enum BIO_CTRL_DGRAM_QUERY_MTU = 40;
312 
313 enum BIO_CTRL_DGRAM_GET_FALLBACK_MTU = 47;
314 
315 /**
316  * get cached value for MTU
317  */
318 enum BIO_CTRL_DGRAM_GET_MTU = 41;
319 
320 /**
321  * set cached value for
322  * MTU. want to use this
323  * if asking the kernel
324  * fails
325  */
326 enum BIO_CTRL_DGRAM_SET_MTU = 42;
327 
328 /**
329  * check whether the MTU
330  * was exceed in the
331  * previous write
332  * operation
333  */
334 enum BIO_CTRL_DGRAM_MTU_EXCEEDED = 43;
335 
336 enum BIO_CTRL_DGRAM_GET_PEER = 46;
337 
338 /**
339  * Destination for the data
340  */
341 enum BIO_CTRL_DGRAM_SET_PEER = 44;
342 
343 /**
344  * Next DTLS handshake timeout to
345  * adjust socket timeouts
346  */
347 enum BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT = 45;
348 
349 /* modifiers */
350 enum BIO_FP_READ = 0x02;
351 enum BIO_FP_WRITE = 0x04;
352 enum BIO_FP_APPEND = 0x08;
353 enum BIO_FP_TEXT = 0x10;
354 
355 enum BIO_FLAGS_READ = 0x01;
356 enum BIO_FLAGS_WRITE = 0x02;
357 enum BIO_FLAGS_IO_SPECIAL = 0x04;
358 enum BIO_FLAGS_RWS = .BIO_FLAGS_READ | .BIO_FLAGS_WRITE | .BIO_FLAGS_IO_SPECIAL;
359 enum BIO_FLAGS_SHOULD_RETRY = 0x08;
360 
361 /* Used in BIO_gethostbyname() */
362 enum BIO_GHBN_CTRL_HITS = 1;
363 enum BIO_GHBN_CTRL_MISSES = 2;
364 enum BIO_GHBN_CTRL_CACHE_SIZE = 3;
365 enum BIO_GHBN_CTRL_GET_ENTRY = 4;
366 enum BIO_GHBN_CTRL_FLUSH = 5;
367 
368 /* Mostly used in the SSL BIO */
369 /*
370  * Not used anymore
371  */
372 @disable
373 {
374 	enum BIO_FLAGS_PROTOCOL_DELAYED_READ = 0x10;
375 	enum BIO_FLAGS_PROTOCOL_DELAYED_WRITE = 0x20;
376 	enum BIO_FLAGS_PROTOCOL_STARTUP = 0x40;
377 }
378 
379 enum BIO_FLAGS_BASE64_NO_NL = 0x0100;
380 
381 /**
382  * This is used with memory BIOs: it means we shouldn't free up or change the
383  * data in any way.
384  */
385 enum BIO_FLAGS_MEM_RDONLY = 0x0200;
386 
387 alias BIO = .bio_st;
388 
389 void BIO_set_flags(.BIO* b, int flags);
390 int BIO_test_flags(const (.BIO)* b, int flags);
391 void BIO_clear_flags(.BIO* b, int flags);
392 
393 pragma(inline, true)
394 int BIO_get_flags(const (.BIO)* b)
395 
396 	do
397 	{
398 		return .BIO_test_flags(b, ~0x00);
399 	}
400 
401 pragma(inline, true)
402 void BIO_set_retry_special(.BIO* b)
403 
404 	do
405 	{
406 		.BIO_set_flags(b, .BIO_FLAGS_IO_SPECIAL | .BIO_FLAGS_SHOULD_RETRY);
407 	}
408 
409 pragma(inline, true)
410 void BIO_set_retry_read(.BIO* b)
411 
412 	do
413 	{
414 		.BIO_set_flags(b, .BIO_FLAGS_READ | .BIO_FLAGS_SHOULD_RETRY);
415 	}
416 
417 pragma(inline, true)
418 void BIO_set_retry_write(.BIO* b)
419 
420 	do
421 	{
422 		.BIO_set_flags(b, .BIO_FLAGS_WRITE | .BIO_FLAGS_SHOULD_RETRY);
423 	}
424 
425 /* These are normally used internally in BIOs */
426 pragma(inline, true)
427 void BIO_clear_retry_flags(.BIO* b)
428 
429 	do
430 	{
431 		.BIO_clear_flags(b, .BIO_FLAGS_RWS | .BIO_FLAGS_SHOULD_RETRY);
432 	}
433 
434 pragma(inline, true)
435 int BIO_get_retry_flags(const (.BIO)* b)
436 
437 	do
438 	{
439 		return .BIO_test_flags(b, .BIO_FLAGS_RWS | .BIO_FLAGS_SHOULD_RETRY);
440 	}
441 
442 /* These should be used by the application to tell why we should retry */
443 pragma(inline, true)
444 int BIO_should_read(const (.BIO)* a)
445 
446 	do
447 	{
448 		return .BIO_test_flags(a, .BIO_FLAGS_READ);
449 	}
450 
451 pragma(inline, true)
452 int BIO_should_write(const (.BIO)* a)
453 
454 	do
455 	{
456 		return .BIO_test_flags(a, .BIO_FLAGS_WRITE);
457 	}
458 
459 pragma(inline, true)
460 int BIO_should_io_special(const (.BIO)* a)
461 
462 	do
463 	{
464 		return .BIO_test_flags(a, .BIO_FLAGS_IO_SPECIAL);
465 	}
466 
467 pragma(inline, true)
468 int BIO_retry_type(const (.BIO)* a)
469 
470 	do
471 	{
472 		return .BIO_test_flags(a, .BIO_FLAGS_RWS);
473 	}
474 
475 pragma(inline, true)
476 int BIO_should_retry(const (.BIO)* a)
477 
478 	do
479 	{
480 		return .BIO_test_flags(a, .BIO_FLAGS_SHOULD_RETRY);
481 	}
482 
483 /*
484  * The next three are used in conjunction with the
485  * BIO_should_io_special() condition.  After this returns true,
486  * .BIO* IO_get_retry_BIO(.BIO* io, int* eason); will walk the BIO
487  * stack and return the 'reason' for the special and the offending BIO.
488  * Given a BIO, BIO_get_retry_reason(bio) will return the code.
489  */
490 /**
491  * Returned from the SSL bio when the certificate retrieval code had an error
492  */
493 enum BIO_RR_SSL_X509_LOOKUP = 0x01;
494 
495 /**
496  * Returned from the connect BIO when a connect would have blocked
497  */
498 enum BIO_RR_CONNECT = 0x02;
499 
500 /**
501  * Returned from the accept BIO when an accept would have blocked
502  */
503 enum BIO_RR_ACCEPT = 0x03;
504 
505 /* These are passed by the BIO callback */
506 enum BIO_CB_FREE = 0x01;
507 enum BIO_CB_READ = 0x02;
508 enum BIO_CB_WRITE = 0x03;
509 enum BIO_CB_PUTS = 0x04;
510 enum BIO_CB_GETS = 0x05;
511 enum BIO_CB_CTRL = 0x06;
512 
513 /**
514  * The callback is called before and after the underling operation,
515  * The BIO_CB_RETURN flag indicates if it is after the call
516  */
517 enum BIO_CB_RETURN = 0x80;
518 
519 pragma(inline, true)
520 A BIO_CB_return(A)(A a)
521 
522 	do
523 	{
524 		return a | .BIO_CB_RETURN;
525 	}
526 
527 pragma(inline, true)
528 A BIO_cb_pre(A)(A a)
529 
530 	do
531 	{
532 		return !(a & .BIO_CB_RETURN);
533 	}
534 
535 pragma(inline, true)
536 A BIO_cb_post(A)(A a)
537 
538 	do
539 	{
540 		return a & .BIO_CB_RETURN;
541 	}
542 
543 //core.stdc.config.c_long (*BIO_get_callback(const (.BIO)* b))(.bio_st*, int, const (char)*, int, core.stdc.config.c_long, core.stdc.config.c_long);
544 void BIO_set_callback(.BIO* b, core.stdc.config.c_long function(.bio_st*, int, const (char)*, int, core.stdc.config.c_long, core.stdc.config.c_long) callback);
545 char* BIO_get_callback_arg(const (.BIO)* b);
546 void BIO_set_callback_arg(.BIO* b, char* arg);
547 
548 const (char)* BIO_method_name(const (.BIO)* b);
549 int BIO_method_type(const (.BIO)* b);
550 
551 alias bio_info_cb = extern (C) nothrow @nogc void function(.bio_st*, int, const (char)*, int, core.stdc.config.c_long, core.stdc.config.c_long);
552 alias BIO_info_cb = extern (C) nothrow @nogc int function(.BIO*, int, int);
553 
554 struct bio_method_st
555 {
556 	int type;
557 	const (char)* name;
558 	int function(.BIO*, const (char)*, int) bwrite;
559 	int function(.BIO*, char*, int) bread;
560 	int function(.BIO*, const (char)*) bputs;
561 	int function(.BIO*, char*, int) bgets;
562 	core.stdc.config.c_long function(.BIO*, int, core.stdc.config.c_long, void*) ctrl;
563 	int function(.BIO*) create;
564 	int function(.BIO*) destroy;
565 	core.stdc.config.c_long function(.BIO*, int, .bio_info_cb*) callback_ctrl;
566 }
567 
568 alias BIO_METHOD = .bio_method_st;
569 
570 struct bio_st
571 {
572 	const (.BIO_METHOD)* method;
573 
574 	/**
575 	 * bio, mode, argp, argi, argl, ret
576 	 */
577 	core.stdc.config.c_long function(.bio_st*, int, const (char)*, int, core.stdc.config.c_long, core.stdc.config.c_long) callback;
578 
579 	/**
580 	 * first argument for the callback
581 	 */
582 	char* cb_arg;
583 
584 	int init;
585 	int shutdown;
586 
587 	/**
588 	 * extra storage
589 	 */
590 	int flags;
591 
592 	int retry_reason;
593 	int num;
594 	void* ptr_;
595 
596 	/**
597 	 * used by filter BIOs
598 	 */
599 	.bio_st* next_bio;
600 
601 	///Ditto
602 	.bio_st* prev_bio;
603 
604 	int references;
605 	core.stdc.config.c_ulong num_read;
606 	core.stdc.config.c_ulong num_write;
607 
608 	libressl_d.openssl.ossl_typ.CRYPTO_EX_DATA ex_data;
609 }
610 
611 //DECLARE_STACK_OF(BIO)
612 struct stack_st_BIO
613 {
614 	libressl_d.openssl.stack._STACK stack;
615 }
616 
617 struct bio_f_buffer_ctx_struct
618 {
619 	/*
620 	 * Buffers are setup like this:
621 	 *
622 	 * <---------------------- size ----------------------.
623 	 * +---------------------------------------------------+
624 	 * | consumed | remaining          | free space        |
625 	 * +---------------------------------------------------+
626 	 * <-- off -.<------- len ------.
627 	 */
628 
629 	/* .BIO* io; */ /* this is now in the BIO struct */
630 
631 	/**
632 	 * how big is the input buffer
633 	 */
634 	int ibuf_size;
635 
636 	/**
637 	 * how big is the output buffer
638 	 */
639 	int obuf_size;
640 
641 	/**
642 	 * the char array
643 	 */
644 	char* ibuf;
645 
646 	/**
647 	 * how many bytes are in it
648 	 */
649 	int ibuf_len;
650 
651 	/**
652 	 * write/read offset
653 	 */
654 	int ibuf_off;
655 
656 	/**
657 	 * the char array
658 	 */
659 	char* obuf;
660 
661 	/**
662 	 * how many bytes are in it
663 	 */
664 	int obuf_len;
665 
666 	/**
667 	 * write/read offset
668 	 */
669 	int obuf_off;
670 }
671 
672 alias BIO_F_BUFFER_CTX = .bio_f_buffer_ctx_struct;
673 
674 /**
675  * Prefix and suffix callback in ASN1 BIO
676  */
677 alias asn1_ps_func = extern (C) nothrow @nogc int function(.BIO* b, ubyte** pbuf, int* plen, void* parg);
678 
679 /* BIO_METHOD accessors */
680 .BIO_METHOD* BIO_meth_new(int type, const (char)* name);
681 void BIO_meth_free(.BIO_METHOD* biom);
682 //int (*BIO_meth_get_write(const (.BIO_METHOD)* biom))(.BIO*, const (char)*, int);
683 int BIO_meth_set_write(.BIO_METHOD* biom, int function(.BIO*, const (char)*, int) write);
684 //int (*BIO_meth_get_read(const (.BIO_METHOD)* biom))(.BIO*, char*, int);
685 int BIO_meth_set_read(.BIO_METHOD* biom, int function(.BIO*, char*, int) read);
686 //int (*BIO_meth_get_puts(const (.BIO_METHOD)* biom))(.BIO*, const (char)*);
687 int BIO_meth_set_puts(.BIO_METHOD* biom, int function(.BIO*, const (char)*) puts);
688 //int (*BIO_meth_get_gets(const (.BIO_METHOD)* biom))(.BIO*, char*, int);
689 int BIO_meth_set_gets(.BIO_METHOD* biom, int function(.BIO*, char*, int) gets);
690 //core.stdc.config.c_long (*BIO_meth_get_ctrl(const (.BIO_METHOD)* biom))(.BIO*, int, core.stdc.config.c_long, void*);
691 int BIO_meth_set_ctrl(.BIO_METHOD* biom, core.stdc.config.c_long function(.BIO*, int, core.stdc.config.c_long, void*) ctrl);
692 //int (*BIO_meth_get_create(const (.BIO_METHOD)* biom))(.BIO*);
693 int BIO_meth_set_create(.BIO_METHOD* biom, int function(.BIO*) create);
694 //int (*BIO_meth_get_destroy(const (.BIO_METHOD)* biom))(.BIO*);
695 int BIO_meth_set_destroy(.BIO_METHOD* biom, int function(.BIO*) destroy);
696 //core.stdc.config.c_long (*BIO_meth_get_callback_ctrl(const (.BIO_METHOD)* biom))(.BIO*, int, .BIO_info_cb*);
697 int BIO_meth_set_callback_ctrl(.BIO_METHOD* biom, core.stdc.config.c_long function(.BIO*, int, .BIO_info_cb*) callback_ctrl);
698 
699 /* connect BIO stuff */
700 enum BIO_CONN_S_BEFORE = 1;
701 enum BIO_CONN_S_GET_IP = 2;
702 enum BIO_CONN_S_GET_PORT = 3;
703 enum BIO_CONN_S_CREATE_SOCKET = 4;
704 enum BIO_CONN_S_CONNECT = 5;
705 enum BIO_CONN_S_OK = 6;
706 enum BIO_CONN_S_BLOCKED_CONNECT = 7;
707 enum BIO_CONN_S_NBIO = 8;
708 /*alias BIO_CONN_get_param_hostname = BIO_ctrl; */
709 
710 enum BIO_C_SET_CONNECT = 100;
711 enum BIO_C_DO_STATE_MACHINE = 101;
712 enum BIO_C_SET_NBIO = 102;
713 enum BIO_C_SET_PROXY_PARAM = 103;
714 enum BIO_C_SET_FD = 104;
715 enum BIO_C_GET_FD = 105;
716 enum BIO_C_SET_FILE_PTR = 106;
717 enum BIO_C_GET_FILE_PTR = 107;
718 enum BIO_C_SET_FILENAME = 108;
719 enum BIO_C_SET_SSL = 109;
720 enum BIO_C_GET_SSL = 110;
721 enum BIO_C_SET_MD = 111;
722 enum BIO_C_GET_MD = 112;
723 enum BIO_C_GET_CIPHER_STATUS = 113;
724 enum BIO_C_SET_BUF_MEM = 114;
725 enum BIO_C_GET_BUF_MEM_PTR = 115;
726 enum BIO_C_GET_BUFF_NUM_LINES = 116;
727 enum BIO_C_SET_BUFF_SIZE = 117;
728 enum BIO_C_SET_ACCEPT = 118;
729 enum BIO_C_SSL_MODE = 119;
730 enum BIO_C_GET_MD_CTX = 120;
731 enum BIO_C_GET_PROXY_PARAM = 121;
732 
733 /**
734  * data to read first
735  */
736 enum BIO_C_SET_BUFF_READ_DATA = 122;
737 
738 enum BIO_C_GET_CONNECT = 123;
739 enum BIO_C_GET_ACCEPT = 124;
740 enum BIO_C_SET_SSL_RENEGOTIATE_BYTES = 125;
741 enum BIO_C_GET_SSL_NUM_RENEGOTIATES = 126;
742 enum BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT = 127;
743 enum BIO_C_FILE_SEEK = 128;
744 enum BIO_C_GET_CIPHER_CTX = 129;
745 
746 /**
747  * return end of input value
748  */
749 enum BIO_C_SET_BUF_MEM_EOF_RETURN = 130;
750 
751 enum BIO_C_SET_BIND_MODE = 131;
752 enum BIO_C_GET_BIND_MODE = 132;
753 enum BIO_C_FILE_TELL = 133;
754 enum BIO_C_GET_SOCKS = 134;
755 enum BIO_C_SET_SOCKS = 135;
756 
757 /**
758  * for BIO_s_bio
759  */
760 enum BIO_C_SET_WRITE_BUF_SIZE = 136;
761 
762 enum BIO_C_GET_WRITE_BUF_SIZE = 137;
763 enum BIO_C_MAKE_BIO_PAIR = 138;
764 enum BIO_C_DESTROY_BIO_PAIR = 139;
765 enum BIO_C_GET_WRITE_GUARANTEE = 140;
766 enum BIO_C_GET_READ_REQUEST = 141;
767 enum BIO_C_SHUTDOWN_WR = 142;
768 enum BIO_C_NREAD0 = 143;
769 enum BIO_C_NREAD = 144;
770 enum BIO_C_NWRITE0 = 145;
771 enum BIO_C_NWRITE = 146;
772 enum BIO_C_RESET_READ_REQUEST = 147;
773 enum BIO_C_SET_MD_CTX = 148;
774 
775 enum BIO_C_SET_PREFIX = 149;
776 enum BIO_C_GET_PREFIX = 150;
777 enum BIO_C_SET_SUFFIX = 151;
778 enum BIO_C_GET_SUFFIX = 152;
779 
780 enum BIO_C_SET_EX_ARG = 153;
781 enum BIO_C_GET_EX_ARG = 154;
782 
783 pragma(inline, true)
784 int BIO_set_app_data(.BIO* s, void* arg)
785 
786 	do
787 	{
788 		return .BIO_set_ex_data(s, 0, arg);
789 	}
790 
791 pragma(inline, true)
792 void* BIO_get_app_data(.BIO* s)
793 
794 	do
795 	{
796 		return .BIO_get_ex_data(s, 0);
797 	}
798 
799 /* BIO_s_connect() and BIO_s_socks4a_connect() */
800 pragma(inline, true)
801 core.stdc.config.c_long BIO_set_conn_hostname(.BIO* b, char* name)
802 
803 	do
804 	{
805 		return .BIO_ctrl(b, .BIO_C_SET_CONNECT, 0, name);
806 	}
807 
808 pragma(inline, true)
809 core.stdc.config.c_long BIO_set_conn_port(.BIO* b, char* port)
810 
811 	do
812 	{
813 		return .BIO_ctrl(b, .BIO_C_SET_CONNECT, 1, port);
814 	}
815 
816 pragma(inline, true)
817 core.stdc.config.c_long BIO_set_conn_ip(.BIO* b, char* ip)
818 
819 	do
820 	{
821 		return .BIO_ctrl(b, .BIO_C_SET_CONNECT, 2, ip);
822 	}
823 
824 pragma(inline, true)
825 core.stdc.config.c_long BIO_set_conn_int_port(.BIO* b, char* port)
826 
827 	do
828 	{
829 		return .BIO_ctrl(b, .BIO_C_SET_CONNECT, 3, port);
830 	}
831 
832 pragma(inline, true)
833 char* BIO_get_conn_hostname(.BIO* b)
834 
835 	do
836 	{
837 		return .BIO_ptr_ctrl(b, .BIO_C_GET_CONNECT, 0);
838 	}
839 
840 pragma(inline, true)
841 char* BIO_get_conn_port(.BIO* b)
842 
843 	do
844 	{
845 		return .BIO_ptr_ctrl(b, .BIO_C_GET_CONNECT, 1);
846 	}
847 
848 pragma(inline, true)
849 char* BIO_get_conn_ip(.BIO* b)
850 
851 	do
852 	{
853 		return .BIO_ptr_ctrl(b, .BIO_C_GET_CONNECT, 2);
854 	}
855 
856 pragma(inline, true)
857 core.stdc.config.c_long BIO_get_conn_int_port(.BIO* b)
858 
859 	do
860 	{
861 		return .BIO_int_ctrl(b, .BIO_C_GET_CONNECT, 3, 0);
862 	}
863 
864 pragma(inline, true)
865 core.stdc.config.c_long BIO_set_nbio(.BIO* b, core.stdc.config.c_long n)
866 
867 	do
868 	{
869 		return .BIO_ctrl(b, .BIO_C_SET_NBIO, n, null);
870 	}
871 
872 /* BIO_s_accept_socket() */
873 pragma(inline, true)
874 core.stdc.config.c_long BIO_set_accept_port(.BIO* b, char* name)
875 
876 	do
877 	{
878 		return .BIO_ctrl(b, .BIO_C_SET_ACCEPT, 0, name);
879 	}
880 
881 pragma(inline, true)
882 char* BIO_get_accept_port(.BIO* b)
883 
884 	do
885 	{
886 		return .BIO_ptr_ctrl(b, .BIO_C_GET_ACCEPT, 0);
887 	}
888 
889 /*
890 pragma(inline, true)
891 core.stdc.config.c_long BIO_set_nbio(.BIO* b, core.stdc.config.c_long n)
892 
893 	do
894 	{
895 		return .BIO_ctrl(b, .BIO_C_SET_NBIO, n, null);
896 	}
897 */
898 
899 pragma(inline, true)
900 core.stdc.config.c_long BIO_set_nbio_accept(.BIO* b, core.stdc.config.c_long n)
901 
902 	do
903 	{
904 		return .BIO_ctrl(b, .BIO_C_SET_ACCEPT, 1, (n) ? (cast(void*)(&("a\0"[0]))) : (null));
905 	}
906 
907 pragma(inline, true)
908 core.stdc.config.c_long BIO_set_accept_bios(.BIO* b, char* bio)
909 
910 	do
911 	{
912 		return .BIO_ctrl(b, .BIO_C_SET_ACCEPT, 2, bio);
913 	}
914 
915 enum BIO_BIND_NORMAL = 0;
916 enum BIO_BIND_REUSEADDR_IF_UNUSED = 1;
917 enum BIO_BIND_REUSEADDR = 2;
918 
919 pragma(inline, true)
920 core.stdc.config.c_long BIO_set_bind_mode(.BIO* b, core.stdc.config.c_long mode)
921 
922 	do
923 	{
924 		return .BIO_ctrl(b, .BIO_C_SET_BIND_MODE, mode, null);
925 	}
926 
927 pragma(inline, true)
928 core.stdc.config.c_long BIO_get_bind_mode(.BIO* b, core.stdc.config.c_long mode)
929 
930 	do
931 	{
932 		return .BIO_ctrl(b, .BIO_C_GET_BIND_MODE, 0, null);
933 	}
934 
935 alias BIO_do_connect = .BIO_do_handshake;
936 alias BIO_do_accept = .BIO_do_handshake;
937 
938 pragma(inline, true)
939 core.stdc.config.c_long BIO_do_handshake(.BIO* b)
940 
941 	do
942 	{
943 		return .BIO_ctrl(b, .BIO_C_DO_STATE_MACHINE, 0, null);
944 	}
945 
946 /* BIO_s_proxy_client() */
947 pragma(inline, true)
948 core.stdc.config.c_long BIO_set_url(.BIO* b, char* url)
949 
950 	do
951 	{
952 		return .BIO_ctrl(b, .BIO_C_SET_PROXY_PARAM, 0, url);
953 	}
954 
955 pragma(inline, true)
956 core.stdc.config.c_long BIO_set_proxies(.BIO* b, char* p)
957 
958 	do
959 	{
960 		return .BIO_ctrl(b, .BIO_C_SET_PROXY_PARAM, 1, p);
961 	}
962 
963 /* BIO_set_nbio(b,n) */
964 pragma(inline, true)
965 core.stdc.config.c_long BIO_set_filter_bio(.BIO* b, char* s)
966 
967 	do
968 	{
969 		return .BIO_ctrl(b, .BIO_C_SET_PROXY_PARAM, 2, s);
970 	}
971 
972 /* .BIO* IO_get_filter_bio(.BIO* io); */
973 //#define BIO_set_proxy_cb(b, cb) .BIO_callback_ctrl(b, .BIO_C_SET_PROXY_PARAM, 3, (void* function() cb))
974 
975 pragma(inline, true)
976 core.stdc.config.c_long BIO_set_proxy_header(.BIO* b, char* sk)
977 
978 	do
979 	{
980 		return .BIO_ctrl(b, .BIO_C_SET_PROXY_PARAM, 4, sk);
981 	}
982 
983 pragma(inline, true)
984 core.stdc.config.c_long BIO_set_no_connect_return(.BIO* b, int bool_)
985 
986 	do
987 	{
988 		return .BIO_int_ctrl(b, .BIO_C_SET_PROXY_PARAM, 5, bool_);
989 	}
990 
991 pragma(inline, true)
992 core.stdc.config.c_long BIO_get_proxy_header(.BIO* b, char* skp)
993 
994 	do
995 	{
996 		return .BIO_ctrl(b, .BIO_C_GET_PROXY_PARAM, 0, skp);
997 	}
998 
999 pragma(inline, true)
1000 core.stdc.config.c_long BIO_get_proxies(.BIO* b, char* pxy_p)
1001 
1002 	do
1003 	{
1004 		return .BIO_ctrl(b, .BIO_C_GET_PROXY_PARAM, 1, pxy_p);
1005 	}
1006 
1007 pragma(inline, true)
1008 core.stdc.config.c_long BIO_get_url(.BIO* b, char* url)
1009 
1010 	do
1011 	{
1012 		return .BIO_ctrl(b, .BIO_C_GET_PROXY_PARAM, 2, url);
1013 	}
1014 
1015 pragma(inline, true)
1016 core.stdc.config.c_long BIO_get_no_connect_return(.BIO* b)
1017 
1018 	do
1019 	{
1020 		return .BIO_ctrl(b, .BIO_C_GET_PROXY_PARAM, 5, null);
1021 	}
1022 
1023 pragma(inline, true)
1024 core.stdc.config.c_long BIO_set_fd(.BIO* b, int fd, core.stdc.config.c_long c)
1025 
1026 	do
1027 	{
1028 		return .BIO_int_ctrl(b, .BIO_C_SET_FD, c, fd);
1029 	}
1030 
1031 pragma(inline, true)
1032 core.stdc.config.c_long BIO_get_fd(.BIO* b, char* c)
1033 
1034 	do
1035 	{
1036 		return .BIO_ctrl(b, .BIO_C_GET_FD, 0, c);
1037 	}
1038 
1039 pragma(inline, true)
1040 core.stdc.config.c_long BIO_set_fp(.BIO* b, char* fp, core.stdc.config.c_long c)
1041 
1042 	do
1043 	{
1044 		return .BIO_ctrl(b, .BIO_C_SET_FILE_PTR, c, fp);
1045 	}
1046 
1047 pragma(inline, true)
1048 core.stdc.config.c_long BIO_get_fp(.BIO* b, char* fpp)
1049 
1050 	do
1051 	{
1052 		return .BIO_ctrl(b, .BIO_C_GET_FILE_PTR, 0, fpp);
1053 	}
1054 
1055 pragma(inline, true)
1056 int BIO_seek(.BIO* b, core.stdc.config.c_long ofs)
1057 
1058 	do
1059 	{
1060 		return cast(int)(.BIO_ctrl(b, .BIO_C_FILE_SEEK, ofs, null));
1061 	}
1062 
1063 pragma(inline, true)
1064 int BIO_tell(.BIO* b)
1065 
1066 	do
1067 	{
1068 		return cast(int)(.BIO_ctrl(b, .BIO_C_FILE_TELL, 0, null));
1069 	}
1070 
1071 /*
1072  * name is cast to lose const, but might be better to route through a function
1073  * so we can do it safely
1074  */
1075 pragma(inline, true)
1076 core.stdc.config.c_long BIO_read_filename(.BIO* b, char* name)
1077 
1078 	do
1079 	{
1080 		return .BIO_ctrl(b, .BIO_C_SET_FILENAME, .BIO_CLOSE | .BIO_FP_READ, name);
1081 	}
1082 
1083 pragma(inline, true)
1084 core.stdc.config.c_long BIO_write_filename(.BIO* b, void* name)
1085 
1086 	do
1087 	{
1088 		return .BIO_ctrl(b, .BIO_C_SET_FILENAME, .BIO_CLOSE | .BIO_FP_WRITE, name);
1089 	}
1090 
1091 pragma(inline, true)
1092 core.stdc.config.c_long BIO_append_filename(.BIO* b, void* name)
1093 
1094 	do
1095 	{
1096 		return .BIO_ctrl(b, .BIO_C_SET_FILENAME, .BIO_CLOSE | .BIO_FP_APPEND, name);
1097 	}
1098 
1099 pragma(inline, true)
1100 core.stdc.config.c_long BIO_rw_filename(.BIO* b, void* name)
1101 
1102 	do
1103 	{
1104 		return .BIO_ctrl(b, .BIO_C_SET_FILENAME, .BIO_CLOSE | .BIO_FP_READ | .BIO_FP_WRITE, name);
1105 	}
1106 
1107 /*
1108  * WARNING WARNING, this ups the reference count on the read bio of the
1109  * SSL structure.  This is because the ssl read BIO is now pointed to by
1110  * the next_bio field in the bio.  So when you free the BIO, make sure
1111  * you are doing a BIO_free_all() to catch the underlying BIO.
1112  */
1113 pragma(inline, true)
1114 core.stdc.config.c_long BIO_set_ssl(.BIO* b, char* ssl, core.stdc.config.c_long c)
1115 
1116 	do
1117 	{
1118 		return .BIO_ctrl(b, .BIO_C_SET_SSL, c, ssl);
1119 	}
1120 
1121 pragma(inline, true)
1122 core.stdc.config.c_long BIO_get_ssl(.BIO* b, char* sslp)
1123 
1124 	do
1125 	{
1126 		return .BIO_ctrl(b, .BIO_C_GET_SSL, 0, sslp);
1127 	}
1128 
1129 pragma(inline, true)
1130 core.stdc.config.c_long BIO_set_ssl_mode(.BIO* b, core.stdc.config.c_long client)
1131 
1132 	do
1133 	{
1134 		return .BIO_ctrl(b, .BIO_C_SSL_MODE, client, null);
1135 	}
1136 
1137 pragma(inline, true)
1138 core.stdc.config.c_long BIO_set_ssl_renegotiate_bytes(.BIO* b, core.stdc.config.c_long num)
1139 
1140 	do
1141 	{
1142 		return .BIO_ctrl(b, .BIO_C_SET_SSL_RENEGOTIATE_BYTES, num, null);
1143 	}
1144 
1145 pragma(inline, true)
1146 core.stdc.config.c_long BIO_get_num_renegotiates(.BIO* b)
1147 
1148 	do
1149 	{
1150 		return .BIO_ctrl(b, .BIO_C_GET_SSL_NUM_RENEGOTIATES, 0, null);
1151 	}
1152 
1153 pragma(inline, true)
1154 core.stdc.config.c_long BIO_set_ssl_renegotiate_timeout(.BIO* b, core.stdc.config.c_long seconds)
1155 
1156 	do
1157 	{
1158 		return .BIO_ctrl(b, .BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT, seconds, null);
1159 	}
1160 
1161 /* defined in evp.h */
1162 /*
1163 pragma(inline, true)
1164 core.stdc.config.c_long BIO_set_md(.BIO* b, char* md)
1165 
1166 	do
1167 	{
1168 		return .BIO_ctrl(b, .BIO_C_SET_MD, 1, md);
1169 	}
1170 */
1171 
1172 pragma(inline, true)
1173 core.stdc.config.c_long BIO_get_mem_data(.BIO* b, char* pp)
1174 
1175 	do
1176 	{
1177 		return .BIO_ctrl(b, .BIO_CTRL_INFO, 0, pp);
1178 	}
1179 
1180 pragma(inline, true)
1181 core.stdc.config.c_long BIO_set_mem_buf(.BIO* b, char* bm, core.stdc.config.c_long c)
1182 
1183 	do
1184 	{
1185 		return .BIO_ctrl(b, .BIO_C_SET_BUF_MEM, c, bm);
1186 	}
1187 
1188 pragma(inline, true)
1189 core.stdc.config.c_long BIO_get_mem_ptr(.BIO* b, char* pp)
1190 
1191 	do
1192 	{
1193 		return .BIO_ctrl(b, .BIO_C_GET_BUF_MEM_PTR, 0, pp);
1194 	}
1195 
1196 pragma(inline, true)
1197 core.stdc.config.c_long BIO_set_mem_eof_return(.BIO* b, core.stdc.config.c_long v)
1198 
1199 	do
1200 	{
1201 		return .BIO_ctrl(b, .BIO_C_SET_BUF_MEM_EOF_RETURN, v, null);
1202 	}
1203 
1204 /* For the BIO_f_buffer() type */
1205 pragma(inline, true)
1206 core.stdc.config.c_long BIO_get_buffer_num_lines(.BIO* b)
1207 
1208 	do
1209 	{
1210 		return .BIO_ctrl(b, .BIO_C_GET_BUFF_NUM_LINES, 0, null);
1211 	}
1212 
1213 pragma(inline, true)
1214 core.stdc.config.c_long BIO_set_buffer_size(.BIO* b, core.stdc.config.c_long size)
1215 
1216 	do
1217 	{
1218 		return .BIO_ctrl(b, .BIO_C_SET_BUFF_SIZE, size, null);
1219 	}
1220 
1221 pragma(inline, true)
1222 core.stdc.config.c_long BIO_set_read_buffer_size(.BIO* b, core.stdc.config.c_long size)
1223 
1224 	do
1225 	{
1226 		return .BIO_int_ctrl(b, .BIO_C_SET_BUFF_SIZE, size, 0);
1227 	}
1228 
1229 pragma(inline, true)
1230 core.stdc.config.c_long BIO_set_write_buffer_size(.BIO* b, core.stdc.config.c_long size)
1231 
1232 	do
1233 	{
1234 		return .BIO_int_ctrl(b, .BIO_C_SET_BUFF_SIZE, size, 1);
1235 	}
1236 
1237 pragma(inline, true)
1238 core.stdc.config.c_long BIO_set_buffer_read_data(.BIO* b, void* buf, core.stdc.config.c_long num)
1239 
1240 	do
1241 	{
1242 		return .BIO_ctrl(b, .BIO_C_SET_BUFF_READ_DATA, num, buf);
1243 	}
1244 
1245 /* Don't use the next one unless you know what you are doing :-) */
1246 pragma(inline, true)
1247 core.stdc.config.c_long BIO_dup_state(.BIO* b, char* ret)
1248 
1249 	do
1250 	{
1251 		return .BIO_ctrl(b, .BIO_CTRL_DUP, 0, ret);
1252 	}
1253 
1254 pragma(inline, true)
1255 int BIO_reset(.BIO* b)
1256 
1257 	do
1258 	{
1259 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_RESET, 0, null));
1260 	}
1261 
1262 pragma(inline, true)
1263 int BIO_eof(.BIO* b)
1264 
1265 	do
1266 	{
1267 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_EOF, 0, null));
1268 	}
1269 
1270 pragma(inline, true)
1271 int BIO_set_close(.BIO* b, core.stdc.config.c_long c)
1272 
1273 	do
1274 	{
1275 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_SET_CLOSE, c, null));
1276 	}
1277 
1278 pragma(inline, true)
1279 int BIO_get_close(.BIO* b)
1280 
1281 	do
1282 	{
1283 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_GET_CLOSE, 0, null));
1284 	}
1285 
1286 pragma(inline, true)
1287 int BIO_pending(.BIO* b)
1288 
1289 	do
1290 	{
1291 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_PENDING, 0, null));
1292 	}
1293 
1294 pragma(inline, true)
1295 int BIO_wpending(.BIO* b)
1296 
1297 	do
1298 	{
1299 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_WPENDING, 0, null));
1300 	}
1301 
1302 /* ...pending macros have inappropriate return type */
1303 size_t BIO_ctrl_pending(.BIO* b);
1304 size_t BIO_ctrl_wpending(.BIO* b);
1305 
1306 pragma(inline, true)
1307 int BIO_flush(.BIO* b)
1308 
1309 	do
1310 	{
1311 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_FLUSH, 0, null));
1312 	}
1313 
1314 pragma(inline, true)
1315 int BIO_get_info_callback(.BIO* b, void* cbp)
1316 
1317 	do
1318 	{
1319 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_GET_CALLBACK, 0, cbp));
1320 	}
1321 
1322 pragma(inline, true)
1323 int BIO_set_info_callback(.BIO* b, void function(.bio_st*, int, const (char)*, int, core.stdc.config.c_long, core.stdc.config.c_long) cb)
1324 
1325 	do
1326 	{
1327 		return cast(int)(.BIO_callback_ctrl(b, .BIO_CTRL_SET_CALLBACK, cb));
1328 	}
1329 
1330 /* For the BIO_f_buffer() type */
1331 pragma(inline, true)
1332 core.stdc.config.c_long BIO_buffer_get_num_lines(.BIO* b)
1333 
1334 	do
1335 	{
1336 		return .BIO_ctrl(b, .BIO_CTRL_GET, 0, null);
1337 	}
1338 
1339 /* For BIO_s_bio() */
1340 pragma(inline, true)
1341 int BIO_set_write_buf_size(.BIO* b, core.stdc.config.c_long size)
1342 
1343 	do
1344 	{
1345 		return cast(int)(.BIO_ctrl(b, .BIO_C_SET_WRITE_BUF_SIZE, size, null));
1346 	}
1347 
1348 pragma(inline, true)
1349 size_t BIO_get_write_buf_size(.BIO* b, core.stdc.config.c_long size)
1350 
1351 	do
1352 	{
1353 		return cast(size_t)(.BIO_ctrl(b, .BIO_C_GET_WRITE_BUF_SIZE, size, null));
1354 	}
1355 
1356 pragma(inline, true)
1357 int BIO_make_bio_pair(.BIO* b1, void* b2)
1358 
1359 	do
1360 	{
1361 		return cast(int)(.BIO_ctrl(b1, .BIO_C_MAKE_BIO_PAIR, 0, b2));
1362 	}
1363 
1364 pragma(inline, true)
1365 int BIO_destroy_bio_pair(.BIO* b)
1366 
1367 	do
1368 	{
1369 		return cast(int)(.BIO_ctrl(b, .BIO_C_DESTROY_BIO_PAIR, 0, null));
1370 	}
1371 
1372 pragma(inline, true)
1373 int BIO_shutdown_wr(.BIO* b)
1374 
1375 	do
1376 	{
1377 		return cast(int)(.BIO_ctrl(b, .BIO_C_SHUTDOWN_WR, 0, null));
1378 	}
1379 
1380 /* macros with inappropriate type -- but ...pending macros use int too: */
1381 pragma(inline, true)
1382 int BIO_get_write_guarantee(.BIO* b)
1383 
1384 	do
1385 	{
1386 		return cast(int)(.BIO_ctrl(b, .BIO_C_GET_WRITE_GUARANTEE, 0, null));
1387 	}
1388 
1389 pragma(inline, true)
1390 int BIO_get_read_request(.BIO* b)
1391 
1392 	do
1393 	{
1394 		return cast(int)(.BIO_ctrl(b, .BIO_C_GET_READ_REQUEST, 0, null));
1395 	}
1396 
1397 size_t BIO_ctrl_get_write_guarantee(.BIO* b);
1398 size_t BIO_ctrl_get_read_request(.BIO* b);
1399 int BIO_ctrl_reset_read_request(.BIO* b);
1400 
1401 /* ctrl macros for dgram */
1402 pragma(inline, true)
1403 int BIO_ctrl_dgram_connect(.BIO* b, char* peer)
1404 
1405 	do
1406 	{
1407 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_DGRAM_CONNECT, 0, peer));
1408 	}
1409 
1410 pragma(inline, true)
1411 int BIO_ctrl_set_connected(.BIO* b, core.stdc.config.c_long state, char* peer)
1412 
1413 	do
1414 	{
1415 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_DGRAM_SET_CONNECTED, state, peer));
1416 	}
1417 
1418 pragma(inline, true)
1419 int BIO_dgram_recv_timedout(.BIO* b)
1420 
1421 	do
1422 	{
1423 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, null));
1424 	}
1425 
1426 pragma(inline, true)
1427 int BIO_dgram_send_timedout(.BIO* b)
1428 
1429 	do
1430 	{
1431 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, null));
1432 	}
1433 
1434 pragma(inline, true)
1435 int BIO_dgram_get_peer(.BIO* b, char* peer)
1436 
1437 	do
1438 	{
1439 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_DGRAM_GET_PEER, 0, peer));
1440 	}
1441 
1442 pragma(inline, true)
1443 int BIO_dgram_set_peer(.BIO* b, char* peer)
1444 
1445 	do
1446 	{
1447 		return cast(int)(.BIO_ctrl(b, .BIO_CTRL_DGRAM_SET_PEER, 0, peer));
1448 	}
1449 
1450 /* These two aren't currently implemented */
1451 /* int BIO_get_ex_num(.BIO* io); */
1452 /* void BIO_set_ex_free_func(.BIO* io,int idx,void function() cb); */
1453 int BIO_set_ex_data(.BIO* bio, int idx, void* data);
1454 void* BIO_get_ex_data(.BIO* bio, int idx);
1455 int BIO_get_ex_new_index(core.stdc.config.c_long argl, void* argp, libressl_d.openssl.ossl_typ.CRYPTO_EX_new* new_func, libressl_d.openssl.ossl_typ.CRYPTO_EX_dup* dup_func, libressl_d.openssl.ossl_typ.CRYPTO_EX_free* free_func);
1456 core.stdc.config.c_ulong BIO_number_read(.BIO* bio);
1457 core.stdc.config.c_ulong BIO_number_written(.BIO* bio);
1458 
1459 /* For BIO_f_asn1() */
1460 int BIO_asn1_set_prefix(.BIO* b, .asn1_ps_func* prefix, .asn1_ps_func* prefix_free);
1461 int BIO_asn1_get_prefix(.BIO* b, .asn1_ps_func** pprefix, .asn1_ps_func** pprefix_free);
1462 int BIO_asn1_set_suffix(.BIO* b, .asn1_ps_func* suffix, .asn1_ps_func* suffix_free);
1463 int BIO_asn1_get_suffix(.BIO* b, .asn1_ps_func** psuffix, .asn1_ps_func** psuffix_free);
1464 
1465 int BIO_get_new_index();
1466 const (.BIO_METHOD)* BIO_s_file();
1467 .BIO* BIO_new_file(const (char)* filename, const (char)* mode);
1468 .BIO* BIO_new_fp(libressl_d.compat.stdio.FILE* stream, int close_flag);
1469 alias BIO_s_file_internal = .BIO_s_file;
1470 .BIO* BIO_new(const (.BIO_METHOD)* type);
1471 int BIO_set(.BIO* a, const (.BIO_METHOD)* type);
1472 int BIO_free(.BIO* a);
1473 int BIO_up_ref(.BIO* bio);
1474 void* BIO_get_data(.BIO* a);
1475 void BIO_set_data(.BIO* a, void* ptr_);
1476 void BIO_set_init(.BIO* a, int init);
1477 int BIO_get_shutdown(.BIO* a);
1478 void BIO_set_shutdown(.BIO* a, int shut);
1479 void BIO_vfree(.BIO* a);
1480 
1481 //__attribute__((__bounded__(__buffer__, 2, 3)));
1482 int BIO_read(.BIO* b, void* data, int len);
1483 
1484 //__attribute__((__bounded__(__string__, 2, 3)));
1485 int BIO_gets(.BIO* bp, char* buf, int size);
1486 
1487 //__attribute__((__bounded__(__buffer__, 2, 3)));
1488 int BIO_write(.BIO* b, const (void)* data, int len);
1489 
1490 int BIO_puts(.BIO* bp, const (char)* buf);
1491 int BIO_indent(.BIO* b, int indent, int max);
1492 core.stdc.config.c_long BIO_ctrl(.BIO* bp, int cmd, core.stdc.config.c_long larg, void* parg);
1493 core.stdc.config.c_long BIO_callback_ctrl(.BIO* b, int cmd, void function(.bio_st*, int, const (char)*, int, core.stdc.config.c_long, core.stdc.config.c_long) fp);
1494 char* BIO_ptr_ctrl(.BIO* bp, int cmd, core.stdc.config.c_long larg);
1495 core.stdc.config.c_long BIO_int_ctrl(.BIO* bp, int cmd, core.stdc.config.c_long larg, int iarg);
1496 .BIO* BIO_push(.BIO* b, .BIO* append);
1497 .BIO* BIO_pop(.BIO* b);
1498 void BIO_free_all(.BIO* a);
1499 .BIO* BIO_find_type(.BIO* b, int bio_type);
1500 .BIO* BIO_next(.BIO* b);
1501 .BIO* BIO_get_retry_BIO(.BIO* bio, int* reason);
1502 int BIO_get_retry_reason(.BIO* bio);
1503 .BIO* BIO_dup_chain(.BIO* in_);
1504 
1505 int BIO_nread0(.BIO* bio, char** buf);
1506 int BIO_nread(.BIO* bio, char** buf, int num);
1507 int BIO_nwrite0(.BIO* bio, char** buf);
1508 int BIO_nwrite(.BIO* bio, char** buf, int num);
1509 
1510 core.stdc.config.c_long BIO_debug_callback(.BIO* bio, int cmd, const (char)* argp, int argi, core.stdc.config.c_long argl, core.stdc.config.c_long ret);
1511 
1512 const (.BIO_METHOD)* BIO_s_mem();
1513 .BIO* BIO_new_mem_buf(const (void)* buf, int len);
1514 const (.BIO_METHOD)* BIO_s_socket();
1515 const (.BIO_METHOD)* BIO_s_connect();
1516 const (.BIO_METHOD)* BIO_s_accept();
1517 const (.BIO_METHOD)* BIO_s_fd();
1518 const (.BIO_METHOD)* BIO_s_log();
1519 const (.BIO_METHOD)* BIO_s_bio();
1520 const (.BIO_METHOD)* BIO_s_null();
1521 const (.BIO_METHOD)* BIO_f_null();
1522 const (.BIO_METHOD)* BIO_f_buffer();
1523 const (.BIO_METHOD)* BIO_f_nbio_test();
1524 
1525 version (OPENSSL_NO_DGRAM) {
1526 } else {
1527 	const (.BIO_METHOD)* BIO_s_datagram();
1528 }
1529 
1530 /* BIO_METHOD* IO_f_ber(); */
1531 
1532 int BIO_sock_should_retry(int i);
1533 int BIO_sock_non_fatal_error(int _error);
1534 int BIO_dgram_non_fatal_error(int _error);
1535 
1536 int BIO_fd_should_retry(int i);
1537 int BIO_fd_non_fatal_error(int _error);
1538 int BIO_dump_cb(int function(const (void)* data, size_t len, void* u) cb, void* u, const (char)* s, int len);
1539 int BIO_dump_indent_cb(int function(const (void)* data, size_t len, void* u) cb, void* u, const (char)* s, int len, int indent);
1540 int BIO_dump(.BIO* b, const (char)* bytes, int len);
1541 int BIO_dump_indent(.BIO* b, const (char)* bytes, int len, int indent);
1542 int BIO_dump_fp(libressl_d.compat.stdio.FILE* fp, const (char)* s, int len);
1543 int BIO_dump_indent_fp(libressl_d.compat.stdio.FILE* fp, const (char)* s, int len, int indent);
1544 libressl_d.compat.netdb.hostent* BIO_gethostbyname(const (char)* name);
1545 /*
1546  * We might want a thread-safe interface too:
1547  * hostent* IO_gethostbyname_r(const (char)* name, hostent* esult, void* uffer, size_t buflen);
1548  * or something similar (caller allocates a struct hostent,
1549  * pointed to by "result", and additional buffer space for the various
1550  * substructures; if the buffer does not suffice, null is returned
1551  * and an appropriate error code is set).
1552  */
1553 int BIO_sock_error(int sock);
1554 int BIO_socket_ioctl(int fd, core.stdc.config.c_long type, void* arg);
1555 int BIO_socket_nbio(int fd, int mode);
1556 int BIO_get_port(const (char)* str, ushort* port_ptr);
1557 int BIO_get_host_ip(const (char)* str, ubyte* ip);
1558 int BIO_get_accept_socket(char* host_port, int mode);
1559 int BIO_accept(int sock, char** ip_port);
1560 int BIO_sock_init();
1561 void BIO_sock_cleanup();
1562 int BIO_set_tcp_ndelay(int sock, int turn_on);
1563 
1564 .BIO* BIO_new_socket(int sock, int close_flag);
1565 .BIO* BIO_new_dgram(int fd, int close_flag);
1566 .BIO* BIO_new_fd(int fd, int close_flag);
1567 .BIO* BIO_new_connect(const (char)* host_port);
1568 .BIO* BIO_new_accept(const (char)* host_port);
1569 
1570 int BIO_new_bio_pair(.BIO** bio1, size_t writebuf1, .BIO** bio2, size_t writebuf2);
1571 /*
1572  * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
1573  * Otherwise returns 0 and sets *bio1 and *bio2 to null.
1574  * Size 0 uses default value.
1575  */
1576 
1577 void BIO_copy_next_retry(.BIO* b);
1578 
1579 /*core.stdc.config.c_long BIO_ghbn_ctrl(int cmd, int iarg, char* arg); */
1580 
1581 version (__MINGW_PRINTF_FORMAT) {
1582 	//__attribute__((__format__(__MINGW_PRINTF_FORMAT, 2, 3), __nonnull__(2)));
1583 	int BIO_printf(.BIO* bio, const (char)* format, ...);
1584 
1585 	//__attribute__((__format__(__MINGW_PRINTF_FORMAT, 2, 0), __nonnull__(2)));
1586 	int BIO_vprintf(.BIO* bio, const (char)* format, core.stdc.stdarg.va_list args);
1587 
1588 	//__attribute__((__deprecated__, __format__(__MINGW_PRINTF_FORMAT, 3, 4), __nonnull__(3)));
1589 	int BIO_snprintf(char* buf, size_t n, const (char)* format, ...);
1590 
1591 	//__attribute__((__deprecated__, __format__(__MINGW_PRINTF_FORMAT, 3, 0), __nonnull__(3)));
1592 	int BIO_vsnprintf(char* buf, size_t n, const (char)* format, core.stdc.stdarg.va_list args);
1593 } else {
1594 	//__attribute__((__format__(__printf__, 2, 3), __nonnull__(2)));
1595 	int BIO_printf(.BIO* bio, const (char)* format, ...);
1596 
1597 	//__attribute__((__format__(__printf__, 2, 0), __nonnull__(2)));
1598 	int BIO_vprintf(.BIO* bio, const (char)* format, core.stdc.stdarg.va_list args);
1599 
1600 	//__attribute__((__deprecated__, __format__(__printf__, 3, 4), __nonnull__(3)));
1601 	int BIO_snprintf(char* buf, size_t n, const (char)* format, ...);
1602 
1603 	//__attribute__((__deprecated__, __format__(__printf__, 3, 0), __nonnull__(3)));
1604 	int BIO_vsnprintf(char* buf, size_t n, const (char)* format, core.stdc.stdarg.va_list args);
1605 }
1606 
1607 /* BEGIN ERROR CODES */
1608 /**
1609  * The following lines are auto generated by the script mkerr.pl. Any changes
1610  * made after this point may be overwritten when the script is next run.
1611  */
1612 void ERR_load_BIO_strings();
1613 
1614 /* Error codes for the BIO functions. */
1615 
1616 /* Function codes. */
1617 enum BIO_F_ACPT_STATE = 100;
1618 enum BIO_F_BIO_ACCEPT = 101;
1619 enum BIO_F_BIO_BER_GET_HEADER = 102;
1620 enum BIO_F_BIO_CALLBACK_CTRL = 131;
1621 enum BIO_F_BIO_CTRL = 103;
1622 enum BIO_F_BIO_GETHOSTBYNAME = 120;
1623 enum BIO_F_BIO_GETS = 104;
1624 enum BIO_F_BIO_GET_ACCEPT_SOCKET = 105;
1625 enum BIO_F_BIO_GET_HOST_IP = 106;
1626 enum BIO_F_BIO_GET_PORT = 107;
1627 enum BIO_F_BIO_MAKE_PAIR = 121;
1628 enum BIO_F_BIO_NEW = 108;
1629 enum BIO_F_BIO_NEW_FILE = 109;
1630 enum BIO_F_BIO_NEW_MEM_BUF = 126;
1631 enum BIO_F_BIO_NREAD = 123;
1632 enum BIO_F_BIO_NREAD0 = 124;
1633 enum BIO_F_BIO_NWRITE = 125;
1634 enum BIO_F_BIO_NWRITE0 = 122;
1635 enum BIO_F_BIO_PUTS = 110;
1636 enum BIO_F_BIO_READ = 111;
1637 enum BIO_F_BIO_SOCK_INIT = 112;
1638 enum BIO_F_BIO_WRITE = 113;
1639 enum BIO_F_BUFFER_CTRL = 114;
1640 enum BIO_F_CONN_CTRL = 127;
1641 enum BIO_F_CONN_STATE = 115;
1642 enum BIO_F_DGRAM_SCTP_READ = 132;
1643 enum BIO_F_FILE_CTRL = 116;
1644 enum BIO_F_FILE_READ = 130;
1645 enum BIO_F_LINEBUFFER_CTRL = 129;
1646 enum BIO_F_MEM_READ = 128;
1647 enum BIO_F_MEM_WRITE = 117;
1648 enum BIO_F_SSL_NEW = 118;
1649 enum BIO_F_WSASTARTUP = 119;
1650 
1651 /* Reason codes. */
1652 enum BIO_R_ACCEPT_ERROR = 100;
1653 enum BIO_R_BAD_FOPEN_MODE = 101;
1654 enum BIO_R_BAD_HOSTNAME_LOOKUP = 102;
1655 enum BIO_R_BROKEN_PIPE = 124;
1656 enum BIO_R_CONNECT_ERROR = 103;
1657 enum BIO_R_EOF_ON_MEMORY_BIO = 127;
1658 enum BIO_R_ERROR_SETTING_NBIO = 104;
1659 enum BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET = 105;
1660 enum BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET = 106;
1661 enum BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET = 107;
1662 enum BIO_R_INVALID_ARGUMENT = 125;
1663 enum BIO_R_INVALID_IP_ADDRESS = 108;
1664 enum BIO_R_INVALID_PORT_NUMBER = 129;
1665 enum BIO_R_IN_USE = 123;
1666 enum BIO_R_KEEPALIVE = 109;
1667 enum BIO_R_NBIO_CONNECT_ERROR = 110;
1668 enum BIO_R_NO_ACCEPT_PORT_SPECIFIED = 111;
1669 enum BIO_R_NO_HOSTNAME_SPECIFIED = 112;
1670 enum BIO_R_NO_PORT_DEFINED = 113;
1671 enum BIO_R_NO_PORT_SPECIFIED = 114;
1672 enum BIO_R_NO_SUCH_FILE = 128;
1673 enum BIO_R_NULL_PARAMETER = 115;
1674 enum BIO_R_TAG_MISMATCH = 116;
1675 enum BIO_R_UNABLE_TO_BIND_SOCKET = 117;
1676 enum BIO_R_UNABLE_TO_CREATE_SOCKET = 118;
1677 enum BIO_R_UNABLE_TO_LISTEN_SOCKET = 119;
1678 enum BIO_R_UNINITIALIZED = 120;
1679 enum BIO_R_UNSUPPORTED_METHOD = 121;
1680 enum BIO_R_WRITE_TO_READ_ONLY_BIO = 126;
1681 enum BIO_R_WSASTARTUP = 122;