source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/bio/bf_null.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 3.0 KB
Line 
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
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
8 */
9
10#include <stdio.h>
11#include <errno.h>
12#include "bio_lcl.h"
13#include "internal/cryptlib.h"
14
15/*
16 * BIO_put and BIO_get both add to the digest, BIO_gets returns the digest
17 */
18
19static int nullf_write(BIO *h, const char *buf, int num);
20static int nullf_read(BIO *h, char *buf, int size);
21static int nullf_puts(BIO *h, const char *str);
22static int nullf_gets(BIO *h, char *str, int size);
23static long nullf_ctrl(BIO *h, int cmd, long arg1, void *arg2);
24static int nullf_new(BIO *h);
25static int nullf_free(BIO *data);
26static long nullf_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
27static const BIO_METHOD methods_nullf = {
28 BIO_TYPE_NULL_FILTER,
29 "NULL filter",
30 nullf_write,
31 nullf_read,
32 nullf_puts,
33 nullf_gets,
34 nullf_ctrl,
35 nullf_new,
36 nullf_free,
37 nullf_callback_ctrl,
38};
39
40const BIO_METHOD *BIO_f_null(void)
41{
42 return (&methods_nullf);
43}
44
45static int nullf_new(BIO *bi)
46{
47 bi->init = 1;
48 bi->ptr = NULL;
49 bi->flags = 0;
50 return (1);
51}
52
53static int nullf_free(BIO *a)
54{
55 if (a == NULL)
56 return (0);
57 /*-
58 a->ptr=NULL;
59 a->init=0;
60 a->flags=0;
61 */
62 return (1);
63}
64
65static int nullf_read(BIO *b, char *out, int outl)
66{
67 int ret = 0;
68
69 if (out == NULL)
70 return (0);
71 if (b->next_bio == NULL)
72 return (0);
73 ret = BIO_read(b->next_bio, out, outl);
74 BIO_clear_retry_flags(b);
75 BIO_copy_next_retry(b);
76 return (ret);
77}
78
79static int nullf_write(BIO *b, const char *in, int inl)
80{
81 int ret = 0;
82
83 if ((in == NULL) || (inl <= 0))
84 return (0);
85 if (b->next_bio == NULL)
86 return (0);
87 ret = BIO_write(b->next_bio, in, inl);
88 BIO_clear_retry_flags(b);
89 BIO_copy_next_retry(b);
90 return (ret);
91}
92
93static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr)
94{
95 long ret;
96
97 if (b->next_bio == NULL)
98 return (0);
99 switch (cmd) {
100 case BIO_C_DO_STATE_MACHINE:
101 BIO_clear_retry_flags(b);
102 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
103 BIO_copy_next_retry(b);
104 break;
105 case BIO_CTRL_DUP:
106 ret = 0L;
107 break;
108 default:
109 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
110 }
111 return (ret);
112}
113
114static long nullf_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
115{
116 long ret = 1;
117
118 if (b->next_bio == NULL)
119 return (0);
120 switch (cmd) {
121 default:
122 ret = BIO_callback_ctrl(b->next_bio, cmd, fp);
123 break;
124 }
125 return (ret);
126}
127
128static int nullf_gets(BIO *bp, char *buf, int size)
129{
130 if (bp->next_bio == NULL)
131 return (0);
132 return (BIO_gets(bp->next_bio, buf, size));
133}
134
135static int nullf_puts(BIO *bp, const char *str)
136{
137 if (bp->next_bio == NULL)
138 return (0);
139 return (BIO_puts(bp->next_bio, str));
140}
Note: See TracBrowser for help on using the repository browser.