update for HEAD-2003021201
[reactos.git] / include / msvcrt / io.h
1 /* 
2  * io.h
3  *
4  * System level I/O functions and types.
5  *
6  * This file is part of the Mingw32 package.
7  *
8  * Contributors:
9  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
10  *
11  *  THIS SOFTWARE IS NOT COPYRIGHTED
12  *
13  *  This source code is offered for use in the public domain. You may
14  *  use, modify or distribute it freely.
15  *
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  *  DISCLAIMED. This includes but is not limited to warranties of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * $Revision$
22  * $Author$
23  * $Date$
24  *
25  */
26 /* Appropriated for Reactos Crtdll by Ariadne */
27 /* added D_OK */
28 /* changed get_osfhandle and open_osfhandle */
29 /* added fileno as macro */
30
31 #ifndef __STRICT_ANSI__
32
33 #ifndef _IO_H_
34 #define _IO_H_
35
36 #include <msvcrt/sys/types.h>
37
38 #include <msvcrt/sys/stat.h>
39
40
41 /* We need the definition of FILE anyway... */
42 #include <msvcrt/stdio.h>
43
44 /* MSVC's io.h contains the stuff from dir.h, so I will too.
45  * NOTE: This also defines off_t, the file offset type, through
46  * and inclusion of sys/types.h */
47 #include <msvcrt/dir.h>
48
49 /* TODO: Maximum number of open handles has not been tested, I just set
50  * it the same as FOPEN_MAX. */
51 #define HANDLE_MAX      FOPEN_MAX
52
53
54 /* Some defines for _access nAccessMode (MS doesn't define them, but
55  * it doesn't seem to hurt to add them). */
56 #define F_OK    0       /* Check for file existence */
57 #define W_OK    2       /* Check for write permission */
58 #define R_OK    4       /* Check for read permission */
59 /* TODO: Is this safe? X_OK not supported directly... */
60 #define X_OK    R_OK    /* Check for execute permission */
61 #define D_OK    0x10
62
63
64
65 #ifdef  __cplusplus
66 extern "C" {
67 #endif
68
69 int             _access (const char*, int);
70 int             _chsize (int, long);
71 int             _close (int);
72 int             _commit(int);
73
74 /* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
75  *       the "owner write permission" bit (on FAT). */
76 int             _creat (const char*, int);
77 int             _dup (int);
78 int             _dup2 (int, int);
79 long            _filelength (int);
80 int             _fileno (FILE*);
81 void*           _get_osfhandle (int);
82 int             _isatty (int);
83
84 int             _chmod (const char* szPath, int nMode);
85 __int64         _filelengthi64(int nHandle);
86
87 /* In a very odd turn of events this function is excluded from those
88  * files which define _STREAM_COMPAT. This is required in order to
89  * build GNU libio because of a conflict with _eof in streambuf.h
90  * line 107. Actually I might just be able to change the name of
91  * the enum member in streambuf.h... we'll see. TODO */
92 #ifndef _STREAM_COMPAT
93 int             _eof (int);
94 #endif
95
96 /* LK_... locking commands defined in sys/locking.h. */
97 int             _locking (int, int, long);
98
99 off_t           _lseek(int, off_t, int);
100
101 /* Optional third argument is unsigned unPermissions. */
102 int             _open (const char*, int, ...);
103
104 int             _open_osfhandle (void*, int);
105 int             _pipe (int*, unsigned int, int);
106 size_t          _read(int, void*, size_t);
107
108 /* SH_... flags for nShFlags defined in share.h
109  * Optional fourth argument is unsigned unPermissions */
110 int             _sopen (char*, int, int, int);
111
112 long            _tell(int);
113 /* Should umask be in sys/stat.h and/or sys/types.h instead? */
114 unsigned        _umask(unsigned);
115 int             _unlink(const char*);
116 size_t          _write(int, const void*, size_t);
117
118 __int64         _lseeki64(int _fildes, __int64 _offset, int _whence);
119 __int64         _telli64(int nHandle);
120
121 /* Wide character versions. Also declared in wchar.h. */
122 /* Not in crtdll.dll */
123 int             _waccess(const wchar_t*, int);
124 int             _wchmod(const wchar_t*, int);
125 int             _wcreat(const wchar_t*, int);
126
127 int             _wunlink(const wchar_t*);
128 int             _wopen(const wchar_t*, int, ...);
129 int             _wsopen(wchar_t*, int, int, int);
130
131
132 #ifndef _NO_OLDNAMES
133 /*
134  * Non-underscored versions of non-ANSI functions to improve portability.
135  * These functions live in libmoldname.a.
136  */
137
138 #define access          _access
139 #define chmod           _chmod
140 #define chsize          _chsize
141 #define close           _close
142 #define creat           _creat
143 #define dup             _dup
144 #define dup2            _dup2
145 #define eof             _eof
146 #define filelength      _filelength
147 #define fileno(f)       ((f)->_file)
148 #define isatty          _isatty
149 #define lseek           _lseek
150 #define open            _open
151 #define read            _read
152 #define sopen(path,access,shflag,mode)  _open((path), (access)|(shflag), (mode))
153 #define tell(file)                      _lseek(_file, 0, SEEK_CUR)
154 #define umask           _umask
155 #define unlink          _unlink
156 #define write           _write
157
158
159 #endif  /* Not _NO_OLDNAMES */
160
161 #ifdef  __cplusplus
162 }
163 #endif
164
165 #endif  /* _IO_H_ not defined */
166
167 #endif  /* Not strict ANSI */
168