diff options
author | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:56:39 +0000 |
---|---|---|
committer | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:56:39 +0000 |
commit | 58964a492275ca9a59a0cd9c8155cb2491b4b909 (patch) | |
tree | c7b16876a5789463bbbb468ef4829c8129b3d718 /crypto/bio/bss_file.c | |
parent | d02b48c63a58ea4367a0e905979f140b7d090f86 (diff) |
Import of old SSLeay release: SSLeay 0.9.0b
Diffstat (limited to 'crypto/bio/bss_file.c')
-rw-r--r-- | crypto/bio/bss_file.c | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c index 33c18e744b..1484cf849e 100644 --- a/crypto/bio/bss_file.c +++ b/crypto/bio/bss_file.c @@ -1,5 +1,5 @@ /* crypto/bio/bss_file.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written @@ -56,12 +56,23 @@ * [including the GNU Public Licence.] */ +/* + * 03-Dec-1997 rdenny@dc3.com Fix bug preventing use of stdin/stdout + * with binary data (e.g. asn1parse -inform DER < xxx) under + * Windows + */ + +#ifndef HEADER_BSS_FILE_C +#define HEADER_BSS_FILE_C + #include <stdio.h> #include <errno.h> #include "cryptlib.h" #include "bio.h" #include "err.h" +#if !defined(NO_STDIO) + #ifndef NOPROTO static int MS_CALLBACK file_write(BIO *h,char *buf,int num); static int MS_CALLBACK file_read(BIO *h,char *buf,int size); @@ -82,7 +93,8 @@ static int MS_CALLBACK file_free(); static BIO_METHOD methods_filep= { - BIO_TYPE_FILE,"FILE pointer", + BIO_TYPE_FILE, + "FILE pointer", file_write, file_read, file_puts, @@ -92,7 +104,6 @@ static BIO_METHOD methods_filep= file_free, }; -#if !defined(WIN16) || defined(APPS_WIN16) BIO *BIO_new_file(filename,mode) char *filename; char *mode; @@ -102,17 +113,13 @@ char *mode; if ((file=fopen(filename,mode)) == NULL) { - SYSerr(SYS_F_FOPEN,errno); + SYSerr(SYS_F_FOPEN,get_last_sys_error()); + ERR_add_error_data(5,"fopen('",filename,"','",mode,"')"); BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB); return(NULL); } - - if ((ret=BIO_new(BIO_s_file())) == NULL) + if ((ret=BIO_new(BIO_s_file_internal())) == NULL) return(NULL); -#if 0 - if ((ret=BIO_new(BIO_s_file_internal_w16())) == NULL) - return(NULL); -#endif BIO_set_fp(ret,file,BIO_CLOSE); return(ret); @@ -126,31 +133,16 @@ int close_flag; if ((ret=BIO_new(BIO_s_file())) == NULL) return(NULL); -#if 0 - if ((ret=BIO_new(BIO_s_file_internal_w16())) == NULL) -#endif BIO_set_fp(ret,stream,close_flag); return(ret); } -#endif /* !APPS_WIN16 */ - -#if !defined(WIN16) || defined(APPS_WIN16) BIO_METHOD *BIO_s_file() { return(&methods_filep); } -#else - -BIO_METHOD *BIO_s_file_internal_w16() - { - return(&methods_filep); - } - -#endif - static int MS_CALLBACK file_new(bi) BIO *bi; { @@ -236,6 +228,13 @@ char *ptr; b->shutdown=(int)num; b->ptr=(char *)ptr; b->init=1; +#if defined(MSDOS) || defined(WINDOWS) + /* Set correct text/binary mode */ + if (num & BIO_FP_TEXT) + _setmode(fileno((FILE *)ptr),_O_TEXT); + else + _setmode(fileno((FILE *)ptr),_O_BINARY); +#endif break; case BIO_C_SET_FILENAME: file_free(b); @@ -267,7 +266,8 @@ char *ptr; fp=fopen(ptr,p); if (fp == NULL) { - SYSerr(SYS_F_FOPEN,errno); + SYSerr(SYS_F_FOPEN,get_last_sys_error()); + ERR_add_error_data(5,"fopen('",ptr,"','",p,"')"); BIOerr(BIO_F_FILE_CTRL,ERR_R_SYS_LIB); ret=0; break; @@ -332,3 +332,8 @@ char *str; return(ret); } +#endif /* NO_STDIO */ + +#endif /* HEADER_BSS_FILE_C */ + + |