X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstdio%2Ffopen.c;h=3d9f95ab1a205917d4ec2b0424b6866a248bc99d;hp=18b7b3ae4df8e2cf5646bb87fc88fc20bedc8eba;hb=da0f3f353d417fed71f358a48d5d5394145e460d;hpb=219271fd548949abce8bd75c34dd42e519418fc4 diff --git a/functions/stdio/fopen.c b/functions/stdio/fopen.c index 18b7b3a..3d9f95a 100644 --- a/functions/stdio/fopen.c +++ b/functions/stdio/fopen.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* fopen( const char *, const char * ) This file is part of the Public Domain C Library (PDCLib). @@ -10,25 +8,31 @@ #include #ifndef REGTEST -#include <_PDCLIB_glue.h> +#include "_PDCLIB_io.h" +#include "_PDCLIB_glue.h" #include #include -extern struct _PDCLIB_file_t * _PDCLIB_filelist; +extern FILE * _PDCLIB_filelist; FILE * fopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode ) { int imode = _PDCLIB_filemode( mode ); - _PDCLIB_fd_t fd = _PDCLIB_open( filename, imode ); - if(fd == _PDCLIB_NOHANDLE) { + + if( imode == 0 || filename == NULL ) + return NULL; + + _PDCLIB_fd_t fd; + const _PDCLIB_fileops_t * ops; + if(!_PDCLIB_open( &fd, &ops, filename, imode )) { return NULL; } - FILE * f = _PDCLIB_fdopen( fd, imode, filename ); + FILE * f = _PDCLIB_fvopen( fd, ops, imode, filename ); if(!f) { int saveErrno = errno; - _PDCLIB_close( fd ); + ops->close(fd); errno = saveErrno; } return f; @@ -37,7 +41,7 @@ FILE * fopen( const char * _PDCLIB_restrict filename, #endif #ifdef TEST -#include <_PDCLIB_test.h> +#include "_PDCLIB_test.h" int main( void ) {