/src/openssl32/crypto/bio/bss_null.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
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 |
8 | | */ |
9 | | |
10 | | #include <stdio.h> |
11 | | #include <errno.h> |
12 | | #include "bio_local.h" |
13 | | #include "internal/cryptlib.h" |
14 | | |
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); |
20 | | static const BIO_METHOD null_method = { |
21 | | BIO_TYPE_NULL, |
22 | | "NULL", |
23 | | bwrite_conv, |
24 | | null_write, |
25 | | bread_conv, |
26 | | null_read, |
27 | | null_puts, |
28 | | null_gets, |
29 | | null_ctrl, |
30 | | NULL, |
31 | | NULL, |
32 | | NULL, /* null_callback_ctrl */ |
33 | | }; |
34 | | |
35 | | const BIO_METHOD *BIO_s_null(void) |
36 | 345k | { |
37 | 345k | return &null_method; |
38 | 345k | } |
39 | | |
40 | | static int null_read(BIO *b, char *out, int outl) |
41 | 0 | { |
42 | 0 | return 0; |
43 | 0 | } |
44 | | |
45 | | static int null_write(BIO *b, const char *in, int inl) |
46 | 311M | { |
47 | 311M | return inl; |
48 | 311M | } |
49 | | |
50 | | static long null_ctrl(BIO *b, int cmd, long num, void *ptr) |
51 | 25.4M | { |
52 | 25.4M | long ret = 1; |
53 | | |
54 | 25.4M | switch (cmd) { |
55 | 0 | case BIO_CTRL_RESET: |
56 | 0 | case BIO_CTRL_EOF: |
57 | 0 | case BIO_CTRL_SET: |
58 | 0 | case BIO_CTRL_SET_CLOSE: |
59 | 32.4k | case BIO_CTRL_FLUSH: |
60 | 32.4k | case BIO_CTRL_DUP: |
61 | 32.4k | ret = 1; |
62 | 32.4k | break; |
63 | 0 | case BIO_CTRL_GET_CLOSE: |
64 | 0 | case BIO_CTRL_INFO: |
65 | 0 | case BIO_CTRL_GET: |
66 | 0 | case BIO_CTRL_PENDING: |
67 | 0 | case BIO_CTRL_WPENDING: |
68 | 25.4M | default: |
69 | 25.4M | ret = 0; |
70 | 25.4M | break; |
71 | 25.4M | } |
72 | 25.4M | return ret; |
73 | 25.4M | } |
74 | | |
75 | | static int null_gets(BIO *bp, char *buf, int size) |
76 | 0 | { |
77 | 0 | return 0; |
78 | 0 | } |
79 | | |
80 | | static int null_puts(BIO *bp, const char *str) |
81 | 47.1M | { |
82 | 47.1M | if (str == NULL) |
83 | 0 | return 0; |
84 | 47.1M | return strlen(str); |
85 | 47.1M | } |