4 * System level I/O functions and types.
6 * This file is part of the Mingw32 package.
9 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26 /* Appropriated for Reactos Crtdll by Ariadne */
28 /* changed get_osfhandle and open_osfhandle */
29 /* added fileno as macro */
33 #ifndef __STRICT_ANSI__
35 #include <crtdll/sys/types.h>
37 #include <crtdll/sys/stat.h>
40 /* We need the definition of FILE anyway... */
41 #include <crtdll/stdio.h>
43 /* MSVC's io.h contains the stuff from dir.h, so I will too.
44 * NOTE: This also defines off_t, the file offset type, through
45 * and inclusion of sys/types.h */
46 #include <crtdll/dir.h>
48 /* TODO: Maximum number of open handles has not been tested, I just set
49 * it the same as FOPEN_MAX. */
50 #define HANDLE_MAX FOPEN_MAX
53 /* Some defines for _access nAccessMode (MS doesn't define them, but
54 * it doesn't seem to hurt to add them). */
55 #define F_OK 0 /* Check for file existence */
56 #define W_OK 2 /* Check for write permission */
57 #define R_OK 4 /* Check for read permission */
58 /* TODO: Is this safe? X_OK not supported directly... */
59 #define X_OK R_OK /* Check for execute permission */
68 int _access (const char* szFileName, int nAccessMode);
69 int _chsize (int nHandle, long lnNewSize);
70 int _close (int nHandle);
72 int _creat (const char* szFileName, int nAccessMode);
73 int _dup (int nHandle);
74 int _dup2 (int nOldHandle, int nNewHandle);
75 long _filelength (int nHandle);
76 int _fileno (FILE* fileGetHandle);
77 void* _get_osfhandle (int nHandle);
78 int _isatty (int nHandle);
80 /* In a very odd turn of events this function is excluded from those
81 * files which define _STREAM_COMPAT. This is required in order to
82 * build GNU libio because of a conflict with _eof in streambuf.h
83 * line 107. Actually I might just be able to change the name of
84 * the enum member in streambuf.h... we'll see. TODO */
85 #ifndef _STREAM_COMPAT
86 int _eof (int nHandle);
89 /* LK_... locking commands defined in sys/locking.h. */
90 int _locking (int nHandle, int nCmd, long lnLockRegionLength);
92 off_t _lseek(int _fd, off_t _offset, int _whence);
93 int _open (const char* szFileName, int nFlags, ...);
94 int _open_osfhandle (void *lnOSHandle, int nFlags);
95 int _pipe (int *naHandles, unsigned int unSize, int nMode);
96 size_t _read(int _fd, void *_buf, size_t _nbyte);
98 /* SH_... flags for nFlag defined in share.h */
99 int _sopen (char* szFileName, int nAccess, int nFlag, int nMode);
101 long _tell (int nHandle);
102 unsigned _umask (unsigned unMode);
103 int _unlink (const char* szFileName);
104 size_t _write(int _fd, const void *_buf, size_t _nbyte);
108 * Non-underscored versions of non-ANSI functions to improve portability.
109 * These functions live in libmoldname.a.
112 #define access _access
113 #define chsize _chsize
119 #define filelength _filelength
120 #define fileno(f) ((f)->_file)
121 #define isatty _isatty
125 #define sopen(path,access,shflag,mode) _open((path), (access)|(shflag), (mode))
126 #define tell(file) _lseek(_file, 0, SEEK_CUR)
128 #define unlink _unlink
132 #endif /* Not _NO_OLDNAMES */
138 #endif /* Not strict ANSI */
140 #endif /* _IO_H_ not defined */