]>
Commit | Line | Data |
---|---|---|
b1322259 | 1 | /* |
6738bf14 | 2 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. |
d02b48c6 | 3 | * |
09abbca1 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
b1322259 RS |
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> | |
706457b7 | 12 | #include "bio_local.h" |
b39fc560 | 13 | #include "internal/cryptlib.h" |
d02b48c6 | 14 | |
0e1c0612 UM |
15 | static int null_write(BIO *h, const char *buf, int num); |
16 | static int null_read(BIO *h, char *buf, int size); | |
17 | static int null_puts(BIO *h, const char *str); | |
18 | static int null_gets(BIO *h, char *str, int size); | |
19 | static long null_ctrl(BIO *h, int cmd, long arg1, void *arg2); | |
04f6b0fd | 20 | static const BIO_METHOD null_method = { |
0f113f3e MC |
21 | BIO_TYPE_NULL, |
22 | "NULL", | |
3befffa3 MC |
23 | /* TODO: Convert to new style write function */ |
24 | bwrite_conv, | |
0f113f3e | 25 | null_write, |
d07aee2c MC |
26 | /* TODO: Convert to new style read function */ |
27 | bread_conv, | |
0f113f3e MC |
28 | null_read, |
29 | null_puts, | |
30 | null_gets, | |
31 | null_ctrl, | |
94f1c937 RL |
32 | NULL, |
33 | NULL, | |
b4ff6622 | 34 | NULL, /* null_callback_ctrl */ |
0f113f3e | 35 | }; |
d02b48c6 | 36 | |
04f6b0fd | 37 | const BIO_METHOD *BIO_s_null(void) |
0f113f3e | 38 | { |
26a7d938 | 39 | return &null_method; |
0f113f3e | 40 | } |
d02b48c6 | 41 | |
6b691a5c | 42 | static int null_read(BIO *b, char *out, int outl) |
0f113f3e | 43 | { |
26a7d938 | 44 | return 0; |
0f113f3e | 45 | } |
d02b48c6 | 46 | |
0e1c0612 | 47 | static int null_write(BIO *b, const char *in, int inl) |
0f113f3e | 48 | { |
26a7d938 | 49 | return inl; |
0f113f3e | 50 | } |
d02b48c6 | 51 | |
0e1c0612 | 52 | static long null_ctrl(BIO *b, int cmd, long num, void *ptr) |
0f113f3e MC |
53 | { |
54 | long ret = 1; | |
d02b48c6 | 55 | |
0f113f3e MC |
56 | switch (cmd) { |
57 | case BIO_CTRL_RESET: | |
58 | case BIO_CTRL_EOF: | |
59 | case BIO_CTRL_SET: | |
60 | case BIO_CTRL_SET_CLOSE: | |
61 | case BIO_CTRL_FLUSH: | |
62 | case BIO_CTRL_DUP: | |
63 | ret = 1; | |
64 | break; | |
65 | case BIO_CTRL_GET_CLOSE: | |
66 | case BIO_CTRL_INFO: | |
67 | case BIO_CTRL_GET: | |
68 | case BIO_CTRL_PENDING: | |
69 | case BIO_CTRL_WPENDING: | |
70 | default: | |
71 | ret = 0; | |
72 | break; | |
73 | } | |
26a7d938 | 74 | return ret; |
0f113f3e | 75 | } |
d02b48c6 | 76 | |
6b691a5c | 77 | static int null_gets(BIO *bp, char *buf, int size) |
0f113f3e | 78 | { |
26a7d938 | 79 | return 0; |
0f113f3e | 80 | } |
d02b48c6 | 81 | |
0e1c0612 | 82 | static int null_puts(BIO *bp, const char *str) |
0f113f3e MC |
83 | { |
84 | if (str == NULL) | |
26a7d938 K |
85 | return 0; |
86 | return strlen(str); | |
0f113f3e | 87 | } |