diff options
Diffstat (limited to 'src/lib/libcrypto/bio/bss_file.c')
-rw-r--r-- | src/lib/libcrypto/bio/bss_file.c | 60 |
1 files changed, 15 insertions, 45 deletions
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c index 1484cf849e..52c0c39df0 100644 --- a/src/lib/libcrypto/bio/bss_file.c +++ b/src/lib/libcrypto/bio/bss_file.c | |||
@@ -68,12 +68,11 @@ | |||
68 | #include <stdio.h> | 68 | #include <stdio.h> |
69 | #include <errno.h> | 69 | #include <errno.h> |
70 | #include "cryptlib.h" | 70 | #include "cryptlib.h" |
71 | #include "bio.h" | 71 | #include <openssl/bio.h> |
72 | #include "err.h" | 72 | #include <openssl/err.h> |
73 | 73 | ||
74 | #if !defined(NO_STDIO) | 74 | #if !defined(NO_STDIO) |
75 | 75 | ||
76 | #ifndef NOPROTO | ||
77 | static int MS_CALLBACK file_write(BIO *h,char *buf,int num); | 76 | static int MS_CALLBACK file_write(BIO *h,char *buf,int num); |
78 | static int MS_CALLBACK file_read(BIO *h,char *buf,int size); | 77 | static int MS_CALLBACK file_read(BIO *h,char *buf,int size); |
79 | static int MS_CALLBACK file_puts(BIO *h,char *str); | 78 | static int MS_CALLBACK file_puts(BIO *h,char *str); |
@@ -81,16 +80,6 @@ static int MS_CALLBACK file_gets(BIO *h,char *str,int size); | |||
81 | static long MS_CALLBACK file_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 80 | static long MS_CALLBACK file_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
82 | static int MS_CALLBACK file_new(BIO *h); | 81 | static int MS_CALLBACK file_new(BIO *h); |
83 | static int MS_CALLBACK file_free(BIO *data); | 82 | static int MS_CALLBACK file_free(BIO *data); |
84 | #else | ||
85 | static int MS_CALLBACK file_write(); | ||
86 | static int MS_CALLBACK file_read(); | ||
87 | static int MS_CALLBACK file_puts(); | ||
88 | static int MS_CALLBACK file_gets(); | ||
89 | static long MS_CALLBACK file_ctrl(); | ||
90 | static int MS_CALLBACK file_new(); | ||
91 | static int MS_CALLBACK file_free(); | ||
92 | #endif | ||
93 | |||
94 | static BIO_METHOD methods_filep= | 83 | static BIO_METHOD methods_filep= |
95 | { | 84 | { |
96 | BIO_TYPE_FILE, | 85 | BIO_TYPE_FILE, |
@@ -104,9 +93,7 @@ static BIO_METHOD methods_filep= | |||
104 | file_free, | 93 | file_free, |
105 | }; | 94 | }; |
106 | 95 | ||
107 | BIO *BIO_new_file(filename,mode) | 96 | BIO *BIO_new_file(const char *filename, const char *mode) |
108 | char *filename; | ||
109 | char *mode; | ||
110 | { | 97 | { |
111 | BIO *ret; | 98 | BIO *ret; |
112 | FILE *file; | 99 | FILE *file; |
@@ -125,9 +112,7 @@ char *mode; | |||
125 | return(ret); | 112 | return(ret); |
126 | } | 113 | } |
127 | 114 | ||
128 | BIO *BIO_new_fp(stream,close_flag) | 115 | BIO *BIO_new_fp(FILE *stream, int close_flag) |
129 | FILE *stream; | ||
130 | int close_flag; | ||
131 | { | 116 | { |
132 | BIO *ret; | 117 | BIO *ret; |
133 | 118 | ||
@@ -138,13 +123,12 @@ int close_flag; | |||
138 | return(ret); | 123 | return(ret); |
139 | } | 124 | } |
140 | 125 | ||
141 | BIO_METHOD *BIO_s_file() | 126 | BIO_METHOD *BIO_s_file(void) |
142 | { | 127 | { |
143 | return(&methods_filep); | 128 | return(&methods_filep); |
144 | } | 129 | } |
145 | 130 | ||
146 | static int MS_CALLBACK file_new(bi) | 131 | static int MS_CALLBACK file_new(BIO *bi) |
147 | BIO *bi; | ||
148 | { | 132 | { |
149 | bi->init=0; | 133 | bi->init=0; |
150 | bi->num=0; | 134 | bi->num=0; |
@@ -152,8 +136,7 @@ BIO *bi; | |||
152 | return(1); | 136 | return(1); |
153 | } | 137 | } |
154 | 138 | ||
155 | static int MS_CALLBACK file_free(a) | 139 | static int MS_CALLBACK file_free(BIO *a) |
156 | BIO *a; | ||
157 | { | 140 | { |
158 | if (a == NULL) return(0); | 141 | if (a == NULL) return(0); |
159 | if (a->shutdown) | 142 | if (a->shutdown) |
@@ -168,10 +151,7 @@ BIO *a; | |||
168 | return(1); | 151 | return(1); |
169 | } | 152 | } |
170 | 153 | ||
171 | static int MS_CALLBACK file_read(b,out,outl) | 154 | static int MS_CALLBACK file_read(BIO *b, char *out, int outl) |
172 | BIO *b; | ||
173 | char *out; | ||
174 | int outl; | ||
175 | { | 155 | { |
176 | int ret=0; | 156 | int ret=0; |
177 | 157 | ||
@@ -182,10 +162,7 @@ int outl; | |||
182 | return(ret); | 162 | return(ret); |
183 | } | 163 | } |
184 | 164 | ||
185 | static int MS_CALLBACK file_write(b,in,inl) | 165 | static int MS_CALLBACK file_write(BIO *b, char *in, int inl) |
186 | BIO *b; | ||
187 | char *in; | ||
188 | int inl; | ||
189 | { | 166 | { |
190 | int ret=0; | 167 | int ret=0; |
191 | 168 | ||
@@ -201,11 +178,7 @@ int inl; | |||
201 | return(ret); | 178 | return(ret); |
202 | } | 179 | } |
203 | 180 | ||
204 | static long MS_CALLBACK file_ctrl(b,cmd,num,ptr) | 181 | static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, char *ptr) |
205 | BIO *b; | ||
206 | int cmd; | ||
207 | long num; | ||
208 | char *ptr; | ||
209 | { | 182 | { |
210 | long ret=1; | 183 | long ret=1; |
211 | FILE *fp=(FILE *)b->ptr; | 184 | FILE *fp=(FILE *)b->ptr; |
@@ -214,18 +187,20 @@ char *ptr; | |||
214 | 187 | ||
215 | switch (cmd) | 188 | switch (cmd) |
216 | { | 189 | { |
190 | case BIO_C_FILE_SEEK: | ||
217 | case BIO_CTRL_RESET: | 191 | case BIO_CTRL_RESET: |
218 | ret=(long)fseek(fp,num,0); | 192 | ret=(long)fseek(fp,num,0); |
219 | break; | 193 | break; |
220 | case BIO_CTRL_EOF: | 194 | case BIO_CTRL_EOF: |
221 | ret=(long)feof(fp); | 195 | ret=(long)feof(fp); |
222 | break; | 196 | break; |
197 | case BIO_C_FILE_TELL: | ||
223 | case BIO_CTRL_INFO: | 198 | case BIO_CTRL_INFO: |
224 | ret=ftell(fp); | 199 | ret=ftell(fp); |
225 | break; | 200 | break; |
226 | case BIO_C_SET_FILE_PTR: | 201 | case BIO_C_SET_FILE_PTR: |
227 | file_free(b); | 202 | file_free(b); |
228 | b->shutdown=(int)num; | 203 | b->shutdown=(int)num&BIO_CLOSE; |
229 | b->ptr=(char *)ptr; | 204 | b->ptr=(char *)ptr; |
230 | b->init=1; | 205 | b->init=1; |
231 | #if defined(MSDOS) || defined(WINDOWS) | 206 | #if defined(MSDOS) || defined(WINDOWS) |
@@ -307,10 +282,7 @@ char *ptr; | |||
307 | return(ret); | 282 | return(ret); |
308 | } | 283 | } |
309 | 284 | ||
310 | static int MS_CALLBACK file_gets(bp,buf,size) | 285 | static int MS_CALLBACK file_gets(BIO *bp, char *buf, int size) |
311 | BIO *bp; | ||
312 | char *buf; | ||
313 | int size; | ||
314 | { | 286 | { |
315 | int ret=0; | 287 | int ret=0; |
316 | 288 | ||
@@ -321,9 +293,7 @@ int size; | |||
321 | return(ret); | 293 | return(ret); |
322 | } | 294 | } |
323 | 295 | ||
324 | static int MS_CALLBACK file_puts(bp,str) | 296 | static int MS_CALLBACK file_puts(BIO *bp, char *str) |
325 | BIO *bp; | ||
326 | char *str; | ||
327 | { | 297 | { |
328 | int n,ret; | 298 | int n,ret; |
329 | 299 | ||