- if ( ( rc = calloc( 1, sizeof( FILE ) ) ) == NULL ) return rc; /* no space for another FILE */
- if ( ( rc->status = filemode( mode ) ) == -1 ) goto fail; /* invalid mode given */
- if ( ( rc->handle = _PDCLIB_open( filename, rc->status ) ) == -1 ) goto fail; /* OS "open" failed */
+ if ( ( rc = calloc( 1, sizeof( FILE ) ) ) == NULL )
+ {
+ /* no memory for another FILE */
+ return NULL;
+ }
+ if ( ( rc->status = filemode( mode ) ) == 0 ) goto fail; /* invalid mode */
+ rc->handle = _PDCLIB_open( filename, rc->status );
+ if ( rc->handle == _PDCLIB_NOHANDLE ) goto fail; /* OS open() failed */
+
+ /* Adding to list of open files */