[HEADERS]
[reactos.git] / reactos / include / crt / io.h
1
2 /**
3 * This file has no copyright assigned and is placed in the Public Domain.
4 * This file is part of the w64 mingw-runtime package.
5 * No warranty is given; refer to the file DISCLAIMER within this package.
6 */
7 #ifndef _IO_H_
8 #define _IO_H_
9
10 #include <crtdefs.h>
11 #include <string.h>
12
13 #pragma pack(push,_CRT_PACKING)
14
15 #ifndef _POSIX_
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 _CRTIMP char* __cdecl _getcwd (char*, int);
22 #ifndef _FSIZE_T_DEFINED
23 typedef unsigned long _fsize_t;
24 #define _FSIZE_T_DEFINED
25 #endif
26
27 #ifndef _FINDDATA_T_DEFINED
28
29 struct _finddata_t {
30 unsigned attrib;
31 time_t time_create;
32 time_t time_access;
33 time_t time_write;
34 _fsize_t size;
35 char name[260];
36 };
37
38 struct _finddata32_t {
39 unsigned attrib;
40 __time32_t time_create;
41 __time32_t time_access;
42 __time32_t time_write;
43 _fsize_t size;
44 char name[260];
45 };
46
47 #if _INTEGRAL_MAX_BITS >= 64
48
49 struct _finddatai64_t {
50 unsigned attrib;
51 time_t time_create;
52 time_t time_access;
53 time_t time_write;
54 __MINGW_EXTENSION __int64 size;
55 char name[260];
56 };
57
58 struct _finddata32i64_t {
59 unsigned attrib;
60 __time32_t time_create;
61 __time32_t time_access;
62 __time32_t time_write;
63 __MINGW_EXTENSION __int64 size;
64 char name[260];
65 };
66
67 struct _finddata64i32_t {
68 unsigned attrib;
69 __time64_t time_create;
70 __time64_t time_access;
71 __time64_t time_write;
72 _fsize_t size;
73 char name[260];
74 };
75
76 struct __finddata64_t {
77 unsigned attrib;
78 __time64_t time_create;
79 __time64_t time_access;
80 __time64_t time_write;
81 __MINGW_EXTENSION __int64 size;
82 char name[260];
83 };
84 #endif /* _INTEGRAL_MAX_BITS >= 64 */
85
86 #define _FINDDATA_T_DEFINED
87 #endif
88
89 #ifndef _WFINDDATA_T_DEFINED
90
91 struct _wfinddata_t {
92 unsigned attrib;
93 time_t time_create;
94 time_t time_access;
95 time_t time_write;
96 _fsize_t size;
97 wchar_t name[260];
98 };
99
100 struct _wfinddata32_t {
101 unsigned attrib;
102 __time32_t time_create;
103 __time32_t time_access;
104 __time32_t time_write;
105 _fsize_t size;
106 wchar_t name[260];
107 };
108
109 #if _INTEGRAL_MAX_BITS >= 64
110
111 struct _wfinddatai64_t {
112 unsigned attrib;
113 time_t time_create;
114 time_t time_access;
115 time_t time_write;
116 __MINGW_EXTENSION __int64 size;
117 wchar_t name[260];
118 };
119
120 struct _wfinddata32i64_t {
121 unsigned attrib;
122 __time32_t time_create;
123 __time32_t time_access;
124 __time32_t time_write;
125 __MINGW_EXTENSION __int64 size;
126 wchar_t name[260];
127 };
128
129 struct _wfinddata64i32_t {
130 unsigned attrib;
131 __time64_t time_create;
132 __time64_t time_access;
133 __time64_t time_write;
134 _fsize_t size;
135 wchar_t name[260];
136 };
137
138 struct _wfinddata64_t {
139 unsigned attrib;
140 __time64_t time_create;
141 __time64_t time_access;
142 __time64_t time_write;
143 __MINGW_EXTENSION __int64 size;
144 wchar_t name[260];
145 };
146 #endif
147
148 #define _WFINDDATA_T_DEFINED
149 #endif
150
151 #define _A_NORMAL 0x00
152 #define _A_RDONLY 0x01
153 #define _A_HIDDEN 0x02
154 #define _A_SYSTEM 0x04
155 #define _A_SUBDIR 0x10
156 #define _A_ARCH 0x20
157
158 /* Some defines for _access nAccessMode (MS doesn't define them, but
159 * it doesn't seem to hurt to add them). */
160 #define F_OK 0 /* Check for file existence */
161 #define X_OK 1 /* Check for execute permission. */
162 #define W_OK 2 /* Check for write permission */
163 #define R_OK 4 /* Check for read permission */
164
165 _CRTIMP int __cdecl _access(const char *_Filename,int _AccessMode);
166 _CRTIMP int __cdecl _chmod(const char *_Filename,int _Mode);
167 _CRTIMP int __cdecl _chsize(int _FileHandle,long _Size);
168 _CRTIMP int __cdecl _close(int _FileHandle);
169 _CRTIMP int __cdecl _commit(int _FileHandle);
170 _CRTIMP int __cdecl _creat(const char *_Filename,int _PermissionMode);
171 _CRTIMP int __cdecl _dup(int _FileHandle);
172 _CRTIMP int __cdecl _dup2(int _FileHandleSrc,int _FileHandleDst);
173 _CRTIMP int __cdecl _eof(int _FileHandle);
174 _CRTIMP long __cdecl _filelength(int _FileHandle);
175 _CRTIMP intptr_t __cdecl _findfirst(const char *_Filename, struct _finddata_t *_FindData);
176 _CRTIMP intptr_t __cdecl _findfirst32(const char *_Filename,struct _finddata32_t *_FindData);
177 _CRTIMP int __cdecl _findnext(intptr_t _FindHandle,struct _finddata_t *_FindData);
178 _CRTIMP int __cdecl _findnext32(intptr_t _FindHandle,struct _finddata32_t *_FindData);
179 _CRTIMP int __cdecl _findclose(intptr_t _FindHandle);
180 _CRTIMP int __cdecl _isatty(int _FileHandle);
181 _CRTIMP int __cdecl _locking(int _FileHandle,int _LockMode,long _NumOfBytes);
182 _CRTIMP long __cdecl _lseek(int _FileHandle,long _Offset,int _Origin);
183 _CRTIMP char *__cdecl _mktemp(char *_TemplateName);
184 _CRTIMP int __cdecl _pipe(int *_PtHandles,unsigned int _PipeSize,int _TextMode);
185 _CRTIMP int __cdecl _read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount);
186
187 #ifndef _CRT_DIRECTORY_DEFINED
188 #define _CRT_DIRECTORY_DEFINED
189 int __cdecl remove(const char *_Filename);
190 int __cdecl rename(const char *_OldFilename,const char *_NewFilename);
191 _CRTIMP int __cdecl _unlink(const char *_Filename);
192 #ifndef NO_OLDNAMES
193 _CRTIMP int __cdecl unlink(const char *_Filename);
194 #endif
195 #endif
196
197 _CRTIMP int __cdecl _setmode(int _FileHandle,int _Mode);
198 _CRTIMP long __cdecl _tell(int _FileHandle);
199 _CRTIMP int __cdecl _umask(int _Mode);
200 _CRTIMP int __cdecl _write(int _FileHandle,const void *_Buf,unsigned int _MaxCharCount);
201
202 #if _INTEGRAL_MAX_BITS >= 64
203 __MINGW_EXTENSION _CRTIMP __int64 __cdecl _filelengthi64(int _FileHandle);
204 _CRTIMP intptr_t __cdecl _findfirst32i64(const char *_Filename,struct _finddata32i64_t *_FindData);
205 _CRTIMP intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t *_FindData);
206 _CRTIMP intptr_t __cdecl _findfirst64(const char *_Filename,struct __finddata64_t *_FindData);
207 _CRTIMP int __cdecl _findnext32i64(intptr_t _FindHandle,struct _finddata32i64_t *_FindData);
208 _CRTIMP int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindData);
209 _CRTIMP int __cdecl _findnext64(intptr_t _FindHandle,struct __finddata64_t *_FindData);
210 __MINGW_EXTENSION _CRTIMP __int64 __cdecl _lseeki64(int _FileHandle,__int64 _Offset,int _Origin);
211 __MINGW_EXTENSION _CRTIMP __int64 __cdecl _telli64(int _FileHandle);
212 #ifdef __cplusplus
213 #include <string.h>
214 #endif
215 __CRT_INLINE intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t *_FindData)
216 {
217 struct __finddata64_t fd;
218 intptr_t ret = _findfirst64(_Filename,&fd);
219 _FindData->attrib=fd.attrib;
220 _FindData->time_create=fd.time_create;
221 _FindData->time_access=fd.time_access;
222 _FindData->time_write=fd.time_write;
223 _FindData->size=(_fsize_t) fd.size;
224 strncpy(_FindData->name,fd.name,260);
225 return ret;
226 }
227 __CRT_INLINE int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindData)
228 {
229 struct __finddata64_t fd;
230 int ret = _findnext64(_FindHandle,&fd);
231 _FindData->attrib=fd.attrib;
232 _FindData->time_create=fd.time_create;
233 _FindData->time_access=fd.time_access;
234 _FindData->time_write=fd.time_write;
235 _FindData->size=(_fsize_t) fd.size;
236 strncpy(_FindData->name,fd.name,260);
237 return ret;
238 }
239 #endif
240
241 #ifndef NO_OLDNAMES
242 #ifndef _UWIN
243 _CRTIMP int __cdecl chdir (const char *);
244 _CRTIMP char *__cdecl getcwd (char *, int);
245 _CRTIMP int __cdecl mkdir (const char *);
246 _CRTIMP char *__cdecl mktemp(char *);
247 _CRTIMP int __cdecl rmdir (const char*);
248 _CRTIMP int __cdecl chmod (const char *, int);
249 #endif /* _UWIN */
250 #endif /* Not NO_OLDNAMES */
251
252 _CRTIMP errno_t __cdecl _sopen_s(int *_FileHandle,const char *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionMode);
253
254 #ifndef __cplusplus
255 _CRTIMP int __cdecl _open(const char *_Filename,int _OpenFlag,...);
256 _CRTIMP int __cdecl _sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...);
257 #else
258 extern "C++" _CRTIMP int __cdecl _open(const char *_Filename,int _Openflag,int _PermissionMode = 0);
259 extern "C++" _CRTIMP int __cdecl _sopen(const char *_Filename,int _Openflag,int _ShareFlag,int _PermissionMode = 0);
260 #endif
261
262 #ifndef _WIO_DEFINED
263 #define _WIO_DEFINED
264 _CRTIMP int __cdecl _waccess(const wchar_t *_Filename,int _AccessMode);
265 _CRTIMP int __cdecl _wchmod(const wchar_t *_Filename,int _Mode);
266 _CRTIMP int __cdecl _wcreat(const wchar_t *_Filename,int _PermissionMode);
267 _CRTIMP intptr_t __cdecl _wfindfirst32(const wchar_t *_Filename,struct _wfinddata32_t *_FindData);
268 _CRTIMP int __cdecl _wfindnext32(intptr_t _FindHandle,struct _wfinddata32_t *_FindData);
269 _CRTIMP int __cdecl _wunlink(const wchar_t *_Filename);
270 _CRTIMP int __cdecl _wrename(const wchar_t *_NewFilename,const wchar_t *_OldFilename);
271 _CRTIMP wchar_t *__cdecl _wmktemp(wchar_t *_TemplateName);
272
273 #if _INTEGRAL_MAX_BITS >= 64
274 _CRTIMP intptr_t __cdecl _wfindfirst32i64(const wchar_t *_Filename,struct _wfinddata32i64_t *_FindData);
275 intptr_t __cdecl _wfindfirst64i32(const wchar_t *_Filename,struct _wfinddata64i32_t *_FindData);
276 _CRTIMP intptr_t __cdecl _wfindfirst64(const wchar_t *_Filename,struct _wfinddata64_t *_FindData);
277 _CRTIMP int __cdecl _wfindnext32i64(intptr_t _FindHandle,struct _wfinddata32i64_t *_FindData);
278 int __cdecl _wfindnext64i32(intptr_t _FindHandle,struct _wfinddata64i32_t *_FindData);
279 _CRTIMP int __cdecl _wfindnext64(intptr_t _FindHandle,struct _wfinddata64_t *_FindData);
280 #endif
281
282 _CRTIMP errno_t __cdecl _wsopen_s(int *_FileHandle,const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionFlag);
283
284 #if !defined(__cplusplus) || !(defined(_X86_) && !defined(__x86_64))
285 _CRTIMP int __cdecl _wopen(const wchar_t *_Filename,int _OpenFlag,...);
286 _CRTIMP int __cdecl _wsopen(const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,...);
287 #else
288 extern "C++" _CRTIMP int __cdecl _wopen(const wchar_t *_Filename,int _OpenFlag,int _PermissionMode = 0);
289 extern "C++" _CRTIMP int __cdecl _wsopen(const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionMode = 0);
290 #endif
291
292 #endif /* !_WIO_DEFINED */
293
294 int __cdecl __lock_fhandle(int _Filehandle);
295 void __cdecl _unlock_fhandle(int _Filehandle);
296 _CRTIMP intptr_t __cdecl _get_osfhandle(int _FileHandle);
297 _CRTIMP int __cdecl _open_osfhandle(intptr_t _OSFileHandle,int _Flags);
298
299 #ifndef NO_OLDNAMES
300 _CRTIMP int __cdecl access(const char *_Filename,int _AccessMode);
301 _CRTIMP int __cdecl chmod(const char *_Filename,int _AccessMode);
302 _CRTIMP int __cdecl chsize(int _FileHandle,long _Size);
303 _CRTIMP int __cdecl close(int _FileHandle);
304 _CRTIMP int __cdecl creat(const char *_Filename,int _PermissionMode);
305 _CRTIMP int __cdecl dup(int _FileHandle);
306 _CRTIMP int __cdecl dup2(int _FileHandleSrc,int _FileHandleDst);
307 _CRTIMP int __cdecl eof(int _FileHandle);
308 _CRTIMP long __cdecl filelength(int _FileHandle);
309 _CRTIMP int __cdecl isatty(int _FileHandle);
310 _CRTIMP int __cdecl locking(int _FileHandle,int _LockMode,long _NumOfBytes);
311 _CRTIMP long __cdecl lseek(int _FileHandle,long _Offset,int _Origin);
312 _CRTIMP char *__cdecl mktemp(char *_TemplateName);
313 _CRTIMP int __cdecl open(const char *_Filename,int _OpenFlag,...);
314 _CRTIMP int __cdecl read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount);
315 _CRTIMP int __cdecl setmode(int _FileHandle,int _Mode);
316 _CRTIMP int __cdecl sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...);
317 _CRTIMP long __cdecl tell(int _FileHandle);
318 _CRTIMP int __cdecl umask(int _Mode);
319 _CRTIMP int __cdecl write(int _Filehandle,const void *_Buf,unsigned int _MaxCharCount);
320 #endif
321
322 #ifdef __cplusplus
323 }
324 #endif
325 #endif
326
327 #ifdef __cplusplus
328 extern "C" {
329 #endif
330
331 /* Misc stuff */
332 char *getlogin(void);
333 #ifdef __USE_MINGW_ALARM
334 unsigned int alarm(unsigned int seconds);
335 #endif
336
337 #ifdef __USE_MINGW_ACCESS
338 /* Old versions of MSVCRT access() just ignored X_OK, while the version
339 shipped with Vista, returns an error code. This will restore the
340 old behaviour */
341 static inline int __mingw_access (const char *__fname, int __mode) {
342 return _access (__fname, __mode & ~X_OK);
343 }
344
345 #define access(__f,__m) __mingw_access (__f, __m)
346 #endif
347
348
349 #ifdef __cplusplus
350 }
351 #endif
352
353
354 #pragma pack(pop)
355
356 #include <sec_api/io_s.h>
357
358 #endif /* End _IO_H_ */
359