:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[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  *  DISCLAMED. 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 #ifndef _IO_H_
31 #define _IO_H_
32
33 #ifndef __STRICT_ANSI__
34
35 #include <msvcrt/sys/types.h>
36
37 #include <msvcrt/sys/stat.h>
38
39
40 /* We need the definition of FILE anyway... */
41 #include <msvcrt/stdio.h>
42
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 <msvcrt/dir.h>
47
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
51
52
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 */
60 #define D_OK    0x10
61
62
63
64 #ifdef  __cplusplus
65 extern "C" {
66 #endif
67
68 int             _access (const char* szFileName, int nAccessMode);
69 int             _chmod (const char* szPath, int nMode);
70 int             _chsize (int nHandle, long lnNewSize);
71 int             _close (int nHandle);
72 int             _commit(int _fd);
73 int             _creat (const char* szFileName, int nAccessMode);
74 int             _dup (int nHandle);
75 int             _dup2 (int nOldHandle, int nNewHandle);
76 long            _filelength (int nHandle);
77 __int64         _filelengthi64(int nHandle);
78 int             _fileno (FILE* fileGetHandle);
79 void*           _get_osfhandle (int nHandle);
80 int             _isatty (int nHandle);
81
82 /* In a very odd turn of events this function is excluded from those
83  * files which define _STREAM_COMPAT. This is required in order to
84  * build GNU libio because of a conflict with _eof in streambuf.h
85  * line 107. Actually I might just be able to change the name of
86  * the enum member in streambuf.h... we'll see. TODO */
87 #ifndef _STREAM_COMPAT
88 int             _eof (int nHandle);
89 #endif
90
91 /* LK_... locking commands defined in sys/locking.h. */
92 int             _locking (int nHandle, int nCmd, long lnLockRegionLength);
93
94 off_t           _lseek(int _fd, off_t _offset, int _whence);
95 __int64         _lseeki64(int _fildes, __int64 _offset, int _whence);
96 int             _open (const char* szFileName, int nFlags, ...);
97 int             _open_osfhandle (void *lnOSHandle, int nFlags);
98 int             _pipe (int *naHandles, unsigned int unSize, int nMode);
99 size_t          _read(int _fd, void *_buf, size_t _nbyte);
100
101 /* SH_... flags for nFlag defined in share.h */
102 int             _sopen (char* szFileName, int nAccess, int nFlag, int nMode);
103
104 long            _tell(int nHandle);
105 __int64         _telli64(int nHandle);
106 unsigned        _umask(unsigned unMode);
107 int             _unlink(const char* szFileName);
108 size_t          _write(int _fd, const void *_buf, size_t _nbyte);
109
110
111 /* wide character functions */
112 int             _waccess(const wchar_t *_path, int _amode);
113 int             _wchmod(const wchar_t *filename, int mode);
114 int             _wcreat(const wchar_t *filename, int mode);
115
116 int             _wopen(const wchar_t *_path, int _oflag,...);
117 int             _wsopen(wchar_t *path, int access, int shflag, int mode);
118 int             _wunlink(const wchar_t *filename);
119
120
121 #ifndef _NO_OLDNAMES
122 /*
123  * Non-underscored versions of non-ANSI functions to improve portability.
124  * These functions live in libmoldname.a.
125  */
126
127 #define access          _access
128 #define chmod           _chmod
129 #define chsize          _chsize
130 #define close           _close
131 #define creat           _creat
132 #define dup             _dup
133 #define dup2            _dup2
134 #define eof             _eof
135 #define filelength      _filelength
136 #define fileno(f)       ((f)->_file)
137 #define isatty          _isatty
138 #define lseek           _lseek
139 #define open            _open
140 #define read            _read
141 #define sopen(path,access,shflag,mode)  _open((path), (access)|(shflag), (mode))
142 #define tell(file)                      _lseek(_file, 0, SEEK_CUR)
143 #define umask           _umask
144 #define unlink          _unlink
145 #define write           _write
146
147 #endif  /* Not _NO_OLDNAMES */
148
149 #ifdef  __cplusplus
150 }
151 #endif
152
153 #endif  /* Not strict ANSI */
154
155 #endif  /* _IO_H_ not defined */