diff options
author | beck <> | 1999-09-29 04:37:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 04:37:45 +0000 |
commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/bio/bss_mem.c | |
parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/bio/bss_mem.c')
-rw-r--r-- | src/lib/libcrypto/bio/bss_mem.c | 59 |
1 files changed, 19 insertions, 40 deletions
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c index 40c4e39f02..7e749a503e 100644 --- a/src/lib/libcrypto/bio/bss_mem.c +++ b/src/lib/libcrypto/bio/bss_mem.c | |||
@@ -59,9 +59,8 @@ | |||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <errno.h> | 60 | #include <errno.h> |
61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
62 | #include "bio.h" | 62 | #include <openssl/bio.h> |
63 | 63 | ||
64 | #ifndef NOPROTO | ||
65 | static int mem_write(BIO *h,char *buf,int num); | 64 | static int mem_write(BIO *h,char *buf,int num); |
66 | static int mem_read(BIO *h,char *buf,int size); | 65 | static int mem_read(BIO *h,char *buf,int size); |
67 | static int mem_puts(BIO *h,char *str); | 66 | static int mem_puts(BIO *h,char *str); |
@@ -69,16 +68,6 @@ static int mem_gets(BIO *h,char *str,int size); | |||
69 | static long mem_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 68 | static long mem_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
70 | static int mem_new(BIO *h); | 69 | static int mem_new(BIO *h); |
71 | static int mem_free(BIO *data); | 70 | static int mem_free(BIO *data); |
72 | #else | ||
73 | static int mem_write(); | ||
74 | static int mem_read(); | ||
75 | static int mem_puts(); | ||
76 | static int mem_gets(); | ||
77 | static long mem_ctrl(); | ||
78 | static int mem_new(); | ||
79 | static int mem_free(); | ||
80 | #endif | ||
81 | |||
82 | static BIO_METHOD mem_method= | 71 | static BIO_METHOD mem_method= |
83 | { | 72 | { |
84 | BIO_TYPE_MEM, | 73 | BIO_TYPE_MEM, |
@@ -92,13 +81,15 @@ static BIO_METHOD mem_method= | |||
92 | mem_free, | 81 | mem_free, |
93 | }; | 82 | }; |
94 | 83 | ||
95 | BIO_METHOD *BIO_s_mem() | 84 | /* bio->num is used to hold the value to return on 'empty', if it is |
85 | * 0, should_retry is not set */ | ||
86 | |||
87 | BIO_METHOD *BIO_s_mem(void) | ||
96 | { | 88 | { |
97 | return(&mem_method); | 89 | return(&mem_method); |
98 | } | 90 | } |
99 | 91 | ||
100 | static int mem_new(bi) | 92 | static int mem_new(BIO *bi) |
101 | BIO *bi; | ||
102 | { | 93 | { |
103 | BUF_MEM *b; | 94 | BUF_MEM *b; |
104 | 95 | ||
@@ -106,13 +97,12 @@ BIO *bi; | |||
106 | return(0); | 97 | return(0); |
107 | bi->shutdown=1; | 98 | bi->shutdown=1; |
108 | bi->init=1; | 99 | bi->init=1; |
109 | bi->num=0; | 100 | bi->num= -1; |
110 | bi->ptr=(char *)b; | 101 | bi->ptr=(char *)b; |
111 | return(1); | 102 | return(1); |
112 | } | 103 | } |
113 | 104 | ||
114 | static int mem_free(a) | 105 | static int mem_free(BIO *a) |
115 | BIO *a; | ||
116 | { | 106 | { |
117 | if (a == NULL) return(0); | 107 | if (a == NULL) return(0); |
118 | if (a->shutdown) | 108 | if (a->shutdown) |
@@ -126,10 +116,7 @@ BIO *a; | |||
126 | return(1); | 116 | return(1); |
127 | } | 117 | } |
128 | 118 | ||
129 | static int mem_read(b,out,outl) | 119 | static int mem_read(BIO *b, char *out, int outl) |
130 | BIO *b; | ||
131 | char *out; | ||
132 | int outl; | ||
133 | { | 120 | { |
134 | int ret= -1; | 121 | int ret= -1; |
135 | BUF_MEM *bm; | 122 | BUF_MEM *bm; |
@@ -151,16 +138,14 @@ int outl; | |||
151 | } | 138 | } |
152 | else if (bm->length == 0) | 139 | else if (bm->length == 0) |
153 | { | 140 | { |
154 | BIO_set_retry_read(b); | 141 | if (b->num != 0) |
155 | ret= -1; | 142 | BIO_set_retry_read(b); |
143 | ret= b->num; | ||
156 | } | 144 | } |
157 | return(ret); | 145 | return(ret); |
158 | } | 146 | } |
159 | 147 | ||
160 | static int mem_write(b,in,inl) | 148 | static int mem_write(BIO *b, char *in, int inl) |
161 | BIO *b; | ||
162 | char *in; | ||
163 | int inl; | ||
164 | { | 149 | { |
165 | int ret= -1; | 150 | int ret= -1; |
166 | int blen; | 151 | int blen; |
@@ -183,11 +168,7 @@ end: | |||
183 | return(ret); | 168 | return(ret); |
184 | } | 169 | } |
185 | 170 | ||
186 | static long mem_ctrl(b,cmd,num,ptr) | 171 | static long mem_ctrl(BIO *b, int cmd, long num, char *ptr) |
187 | BIO *b; | ||
188 | int cmd; | ||
189 | long num; | ||
190 | char *ptr; | ||
191 | { | 172 | { |
192 | long ret=1; | 173 | long ret=1; |
193 | char **pptr; | 174 | char **pptr; |
@@ -204,6 +185,9 @@ char *ptr; | |||
204 | case BIO_CTRL_EOF: | 185 | case BIO_CTRL_EOF: |
205 | ret=(long)(bm->length == 0); | 186 | ret=(long)(bm->length == 0); |
206 | break; | 187 | break; |
188 | case BIO_C_SET_BUF_MEM_EOF_RETURN: | ||
189 | b->num=(int)num; | ||
190 | break; | ||
207 | case BIO_CTRL_INFO: | 191 | case BIO_CTRL_INFO: |
208 | ret=(long)bm->length; | 192 | ret=(long)bm->length; |
209 | if (ptr != NULL) | 193 | if (ptr != NULL) |
@@ -250,10 +234,7 @@ char *ptr; | |||
250 | return(ret); | 234 | return(ret); |
251 | } | 235 | } |
252 | 236 | ||
253 | static int mem_gets(bp,buf,size) | 237 | static int mem_gets(BIO *bp, char *buf, int size) |
254 | BIO *bp; | ||
255 | char *buf; | ||
256 | int size; | ||
257 | { | 238 | { |
258 | int i,j; | 239 | int i,j; |
259 | int ret= -1; | 240 | int ret= -1; |
@@ -283,9 +264,7 @@ int size; | |||
283 | return(ret); | 264 | return(ret); |
284 | } | 265 | } |
285 | 266 | ||
286 | static int mem_puts(bp,str) | 267 | static int mem_puts(BIO *bp, char *str) |
287 | BIO *bp; | ||
288 | char *str; | ||
289 | { | 268 | { |
290 | int n,ret; | 269 | int n,ret; |
291 | 270 | ||