int __close( int hid ) { int is_closed; int rc; HANDLE h; #ifdef DEFAULT_WINDOWING LPWDATA res; #endif __handle_check( hid, -1 ); is_closed = 0; rc = 0; h = __getOSHandle( hid ); #ifdef DEFAULT_WINDOWING if( _WindowsCloseWindow != 0 ) { res = _WindowsIsWindowedHandle( hid ); if( res != NULL ) { _WindowsRemoveWindowedHandle( hid ); _WindowsCloseWindow( res ); is_closed = 1; } } #endif if( !is_closed && !CloseHandle( h ) ) { rc = __set_errno_nt(); } __freePOSIXHandle( hid ); __SetIOMode_nogrow( hid, 0 ); return( rc ); }
_WCRTLINK FILE *__F_NAME(freopen,_wfreopen)( const CHAR_TYPE *name, const CHAR_TYPE *access_mode, FILE *fp ) { int hdl; int file_flags; int extflags; _ValidFile( fp, 0 ); /* validate access_mode */ file_flags = __F_NAME(__open_flags,__wopen_flags)( access_mode, &extflags ); if( file_flags == 0 ) { return( NULL ); } hdl = fileno( fp ); _AccessFileH( hdl ); #ifdef DEFAULT_WINDOWING if( _WindowsRemoveWindowedHandle != 0 ) { _WindowsRemoveWindowedHandle( hdl ); } #endif fp = close_file( fp ); if( fp != NULL ) { fp->_flag &= _DYNAMIC; /* 24-jul-92 */ fp = __F_NAME(__doopen,__wdoopen)( name, *access_mode, file_flags, extflags, 0, fp ); } _ReleaseFileH( hdl ); return( fp ); }
int __close( int handle ) { tiny_ret_t rc; #ifdef DEFAULT_WINDOWING LPWDATA res; #endif int rv; __handle_check( handle, -1 ); rv = 0; rc = TinyClose( handle ); if( TINY_OK(rc) ) { #ifdef DEFAULT_WINDOWING if( _WindowsCloseWindow != 0 ) { res = _WindowsIsWindowedHandle( handle ); if( res != NULL ) { _WindowsRemoveWindowedHandle( handle ); _WindowsCloseWindow( res ); } } #endif } else { __set_errno( EBADF ); rv = -1; } __SetIOMode_nogrow( handle, 0 ); return( rv ); }