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