/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include #include #include #include #include #include #include #include #include int _close(int handle) { __dpmi_regs r = {0}; __FSEXT_Function *func = __FSEXT_get_function(handle); if (func) { int rv; if (__FSEXT_func_wrapper(func, __FSEXT_close, &rv, handle)) { /* So that we don't try to use it later! The extension *should* do this itself! */ __FSEXT_set_function(handle, 0); return rv; } /* same here */ __FSEXT_set_function(handle, 0); } r.h.ah = 0x3e; r.x.bx = handle; __dpmi_int(0x21, &r); if (r.x.flags & 1) { errno = EBADF; return -1; } if (__has_fd_properties(handle)) __clear_fd_properties(handle); return 0; }