]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/bio/bss_null.c
Since return is inconsistent, I removed unnecessary parentheses and
[thirdparty/openssl.git] / crypto / bio / bss_null.c
CommitLineData
b1322259
RS
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
d02b48c6 3 *
b1322259
RS
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
d02b48c6
RE
8 */
9
10#include <stdio.h>
11#include <errno.h>
a146ae55 12#include "bio_lcl.h"
b39fc560 13#include "internal/cryptlib.h"
d02b48c6 14
0e1c0612
UM
15static int null_write(BIO *h, const char *buf, int num);
16static int null_read(BIO *h, char *buf, int size);
17static int null_puts(BIO *h, const char *str);
18static int null_gets(BIO *h, char *str, int size);
19static long null_ctrl(BIO *h, int cmd, long arg1, void *arg2);
d02b48c6
RE
20static int null_new(BIO *h);
21static int null_free(BIO *data);
04f6b0fd 22static const BIO_METHOD null_method = {
0f113f3e
MC
23 BIO_TYPE_NULL,
24 "NULL",
3befffa3
MC
25 /* TODO: Convert to new style write function */
26 bwrite_conv,
0f113f3e 27 null_write,
d07aee2c
MC
28 /* TODO: Convert to new style read function */
29 bread_conv,
0f113f3e
MC
30 null_read,
31 null_puts,
32 null_gets,
33 null_ctrl,
34 null_new,
35 null_free,
36 NULL,
37};
d02b48c6 38
04f6b0fd 39const BIO_METHOD *BIO_s_null(void)
0f113f3e
MC
40{
41 return (&null_method);
42}
d02b48c6 43
6b691a5c 44static int null_new(BIO *bi)
0f113f3e
MC
45{
46 bi->init = 1;
47 bi->num = 0;
48 bi->ptr = (NULL);
208fb891 49 return 1;
0f113f3e 50}
d02b48c6 51
6b691a5c 52static int null_free(BIO *a)
0f113f3e
MC
53{
54 if (a == NULL)
55 return (0);
208fb891 56 return 1;
0f113f3e
MC
57}
58
6b691a5c 59static int null_read(BIO *b, char *out, int outl)
0f113f3e
MC
60{
61 return (0);
62}
d02b48c6 63
0e1c0612 64static int null_write(BIO *b, const char *in, int inl)
0f113f3e
MC
65{
66 return (inl);
67}
d02b48c6 68
0e1c0612 69static long null_ctrl(BIO *b, int cmd, long num, void *ptr)
0f113f3e
MC
70{
71 long ret = 1;
d02b48c6 72
0f113f3e
MC
73 switch (cmd) {
74 case BIO_CTRL_RESET:
75 case BIO_CTRL_EOF:
76 case BIO_CTRL_SET:
77 case BIO_CTRL_SET_CLOSE:
78 case BIO_CTRL_FLUSH:
79 case BIO_CTRL_DUP:
80 ret = 1;
81 break;
82 case BIO_CTRL_GET_CLOSE:
83 case BIO_CTRL_INFO:
84 case BIO_CTRL_GET:
85 case BIO_CTRL_PENDING:
86 case BIO_CTRL_WPENDING:
87 default:
88 ret = 0;
89 break;
90 }
91 return (ret);
92}
d02b48c6 93
6b691a5c 94static int null_gets(BIO *bp, char *buf, int size)
0f113f3e
MC
95{
96 return (0);
97}
d02b48c6 98
0e1c0612 99static int null_puts(BIO *bp, const char *str)
0f113f3e
MC
100{
101 if (str == NULL)
102 return (0);
103 return (strlen(str));
104}