#include <stdlib.h>
#ifndef REGTEST
+#include <_PDCLIB_io.h>
#include <_PDCLIB_glue.h>
#include <string.h>
#include <errno.h>
-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;