2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
13 #include "internal/cryptlib.h"
16 * BIO_put and BIO_get both add to the digest, BIO_gets returns the digest
19 static int nullf_write(BIO *h, const char *buf, int num);
20 static int nullf_read(BIO *h, char *buf, int size);
21 static int nullf_puts(BIO *h, const char *str);
22 static int nullf_gets(BIO *h, char *str, int size);
23 static long nullf_ctrl(BIO *h, int cmd, long arg1, void *arg2);
24 static int nullf_new(BIO *h);
25 static int nullf_free(BIO *data);
26 static long nullf_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
27 static const BIO_METHOD methods_nullf = {
30 /* TODO: Convert to new style write function */
33 /* TODO: Convert to new style read function */
44 const BIO_METHOD *BIO_f_null(void)
46 return (&methods_nullf);
49 static int nullf_new(BIO *bi)
57 static int nullf_free(BIO *a)
69 static int nullf_read(BIO *b, char *out, int outl)
75 if (b->next_bio == NULL)
77 ret = BIO_read(b->next_bio, out, outl);
78 BIO_clear_retry_flags(b);
79 BIO_copy_next_retry(b);
83 static int nullf_write(BIO *b, const char *in, int inl)
87 if ((in == NULL) || (inl <= 0))
89 if (b->next_bio == NULL)
91 ret = BIO_write(b->next_bio, in, inl);
92 BIO_clear_retry_flags(b);
93 BIO_copy_next_retry(b);
97 static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr)
101 if (b->next_bio == NULL)
104 case BIO_C_DO_STATE_MACHINE:
105 BIO_clear_retry_flags(b);
106 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
107 BIO_copy_next_retry(b);
113 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
118 static long nullf_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
122 if (b->next_bio == NULL)
126 ret = BIO_callback_ctrl(b->next_bio, cmd, fp);
132 static int nullf_gets(BIO *bp, char *buf, int size)
134 if (bp->next_bio == NULL)
136 return (BIO_gets(bp->next_bio, buf, size));
139 static int nullf_puts(BIO *bp, const char *str)
141 if (bp->next_bio == NULL)
143 return (BIO_puts(bp->next_bio, str));