65 #ifndef HEADER_BSS_FILE_C
66 #define HEADER_BSS_FILE_C
68 #if defined(__linux) || defined(__sun) || defined(__hpux)
81 #ifndef _FILE_OFFSET_BITS
82 #define _FILE_OFFSET_BITS 64
92 #if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
96 #if !defined(OPENSSL_NO_STDIO)
102 static long MS_CALLBACK file_ctrl(
BIO *
h,
int cmd,
long arg1,
void *arg2);
124 #if defined(_WIN32) && defined(CP_UTF8)
125 int sz, len_0 = (int)strlen(filename)+1;
140 if ((sz=MultiByteToWideChar(CP_UTF8,(flags=MB_ERR_INVALID_CHARS),
141 filename,len_0,NULL,0))>0 ||
142 (GetLastError()==ERROR_INVALID_FLAGS &&
143 (sz=MultiByteToWideChar(CP_UTF8,(flags=0),
144 filename,len_0,NULL,0))>0)
148 WCHAR *wfilename = _alloca(sz*
sizeof(WCHAR));
150 if (MultiByteToWideChar(CP_UTF8,flags,
151 filename,len_0,wfilename,sz) &&
152 MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1,
153 wmode,
sizeof(wmode)/
sizeof(wmode[0])) &&
154 (file=_wfopen(wfilename,wmode))==NULL &&
158 file = fopen(filename,mode);
160 else if (GetLastError()==ERROR_NO_UNICODE_TRANSLATION)
162 file = fopen(filename,mode);
165 file=fopen(filename,mode);
202 return(&methods_filep);
216 if (a == NULL)
return(0);
219 if ((a->
init) && (a->
ptr != NULL))
237 if (b->
init && (out != NULL))
242 ret=fread(out,1,(
int)outl,(FILE *)b->
ptr);
253 static int MS_CALLBACK file_write(
BIO *b,
const char *in,
int inl)
257 if (b->
init && (in != NULL))
262 ret=fwrite(in,(
int)inl,1,(FILE *)b->
ptr);
276 FILE *
fp=(FILE *)b->
ptr;
287 ret=(long)fseek(fp,num,0);
307 #if BIO_FLAGS_UPLINK!=0
308 #if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)
309 #define _IOB_ENTRIES 20
311 #if defined(_IOB_ENTRIES)
313 if ((
size_t)ptr >= (size_t)stdin &&
314 (
size_t)ptr < (size_t)(stdin+_IOB_ENTRIES))
324 #if defined(OPENSSL_SYS_WINDOWS)
325 int fd = _fileno((FILE*)ptr);
327 _setmode(fd,_O_TEXT);
329 _setmode(fd,_O_BINARY);
330 #elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
331 int fd = fileno((FILE*)ptr);
333 if (num & BIO_FP_TEXT)
337 #elif defined(OPENSSL_SYS_MSDOS)
338 int fd = fileno((FILE*)ptr);
340 if (num & BIO_FP_TEXT)
341 _setmode(fd,_O_TEXT);
345 if (fd == STDIN_FILENO || fd == STDOUT_FILENO)
348 _setmode(fd,_O_BINARY);
351 _setmode(fd,_O_BINARY);
353 #elif defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN)
354 int fd = fileno((FILE*)ptr);
355 if (num & BIO_FP_TEXT)
373 else if (num & BIO_FP_WRITE)
375 else if (num & BIO_FP_READ)
383 #if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN)
384 if (!(num & BIO_FP_TEXT))
389 #if defined(OPENSSL_SYS_NETWARE)
390 if (!(num & BIO_FP_TEXT))
426 fflush((FILE *)b->
ptr);
455 if (!fgets(buf,size,(FILE *)bp->
ptr))
469 ret=file_write(bp,str,n);