]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/bio/bf_null.c
2 * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (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
12 #include "bio_local.h"
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 long nullf_callback_ctrl(BIO
*h
, int cmd
, BIO_info_cb
*fp
);
25 static const BIO_METHOD methods_nullf
= {
40 const BIO_METHOD
*BIO_f_null(void)
42 return &methods_nullf
;
45 static int nullf_read(BIO
*b
, char *out
, int outl
)
51 if (b
->next_bio
== NULL
)
53 ret
= BIO_read(b
->next_bio
, out
, outl
);
54 BIO_clear_retry_flags(b
);
55 BIO_copy_next_retry(b
);
59 static int nullf_write(BIO
*b
, const char *in
, int inl
)
63 if ((in
== NULL
) || (inl
<= 0))
65 if (b
->next_bio
== NULL
)
67 ret
= BIO_write(b
->next_bio
, in
, inl
);
68 BIO_clear_retry_flags(b
);
69 BIO_copy_next_retry(b
);
73 static long nullf_ctrl(BIO
*b
, int cmd
, long num
, void *ptr
)
77 if (b
->next_bio
== NULL
)
80 case BIO_C_DO_STATE_MACHINE
:
81 BIO_clear_retry_flags(b
);
82 ret
= BIO_ctrl(b
->next_bio
, cmd
, num
, ptr
);
83 BIO_copy_next_retry(b
);
89 ret
= BIO_ctrl(b
->next_bio
, cmd
, num
, ptr
);
94 static long nullf_callback_ctrl(BIO
*b
, int cmd
, BIO_info_cb
*fp
)
96 if (b
->next_bio
== NULL
)
98 return BIO_callback_ctrl(b
->next_bio
, cmd
, fp
);
101 static int nullf_gets(BIO
*bp
, char *buf
, int size
)
103 if (bp
->next_bio
== NULL
)
105 return BIO_gets(bp
->next_bio
, buf
, size
);
108 static int nullf_puts(BIO
*bp
, const char *str
)
110 if (bp
->next_bio
== NULL
)
112 return BIO_puts(bp
->next_bio
, str
);