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