[SDK] One step further towards ReactOS source code tree restructure: the sdk folder...
[reactos.git] / reactos / sdk / 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 _Check_return_
22 _Ret_opt_z_
23 _CRTIMP
24 char*
25 __cdecl
26 _getcwd(
27 _Out_writes_opt_(_SizeInBytes) char *_DstBuf,
28 _In_ int _SizeInBytes);
29
30 #ifndef _FSIZE_T_DEFINED
31 typedef unsigned long _fsize_t;
32 #define _FSIZE_T_DEFINED
33 #endif
34
35 #ifndef _FINDDATA_T_DEFINED
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 struct _finddata32_t {
47 unsigned attrib;
48 __time32_t time_create;
49 __time32_t time_access;
50 __time32_t time_write;
51 _fsize_t size;
52 char name[260];
53 };
54
55 #if _INTEGRAL_MAX_BITS >= 64
56
57 struct _finddatai64_t {
58 unsigned attrib;
59 time_t time_create;
60 time_t time_access;
61 time_t time_write;
62 __MINGW_EXTENSION __int64 size;
63 char name[260];
64 };
65
66 struct _finddata32i64_t {
67 unsigned attrib;
68 __time32_t time_create;
69 __time32_t time_access;
70 __time32_t time_write;
71 __MINGW_EXTENSION __int64 size;
72 char name[260];
73 };
74
75 struct _finddata64i32_t {
76 unsigned attrib;
77 __time64_t time_create;
78 __time64_t time_access;
79 __time64_t time_write;
80 _fsize_t size;
81 char name[260];
82 };
83
84 struct __finddata64_t {
85 unsigned attrib;
86 __time64_t time_create;
87 __time64_t time_access;
88 __time64_t time_write;
89 __MINGW_EXTENSION __int64 size;
90 char name[260];
91 };
92 #endif /* _INTEGRAL_MAX_BITS >= 64 */
93
94 #define _FINDDATA_T_DEFINED
95 #endif
96
97 #ifndef _WFINDDATA_T_DEFINED
98
99 struct _wfinddata_t {
100 unsigned attrib;
101 time_t time_create;
102 time_t time_access;
103 time_t time_write;
104 _fsize_t size;
105 wchar_t name[260];
106 };
107
108 struct _wfinddata32_t {
109 unsigned attrib;
110 __time32_t time_create;
111 __time32_t time_access;
112 __time32_t time_write;
113 _fsize_t size;
114 wchar_t name[260];
115 };
116
117 #if _INTEGRAL_MAX_BITS >= 64
118
119 struct _wfinddatai64_t {
120 unsigned attrib;
121 time_t time_create;
122 time_t time_access;
123 time_t time_write;
124 __MINGW_EXTENSION __int64 size;
125 wchar_t name[260];
126 };
127
128 struct _wfinddata32i64_t {
129 unsigned attrib;
130 __time32_t time_create;
131 __time32_t time_access;
132 __time32_t time_write;
133 __MINGW_EXTENSION __int64 size;
134 wchar_t name[260];
135 };
136
137 struct _wfinddata64i32_t {
138 unsigned attrib;
139 __time64_t time_create;
140 __time64_t time_access;
141 __time64_t time_write;
142 _fsize_t size;
143 wchar_t name[260];
144 };
145
146 struct _wfinddata64_t {
147 unsigned attrib;
148 __time64_t time_create;
149 __time64_t time_access;
150 __time64_t time_write;
151 __MINGW_EXTENSION __int64 size;
152 wchar_t name[260];
153 };
154 #endif
155
156 #define _WFINDDATA_T_DEFINED
157 #endif
158
159 #define _A_NORMAL 0x00
160 #define _A_RDONLY 0x01
161 #define _A_HIDDEN 0x02
162 #define _A_SYSTEM 0x04
163 #define _A_SUBDIR 0x10
164 #define _A_ARCH 0x20
165
166 /* Some defines for _access nAccessMode (MS doesn't define them, but
167 * it doesn't seem to hurt to add them). */
168 #define F_OK 0 /* Check for file existence */
169 #define X_OK 1 /* Check for execute permission. */
170 #define W_OK 2 /* Check for write permission */
171 #define R_OK 4 /* Check for read permission */
172
173 _Check_return_
174 _CRTIMP
175 int
176 __cdecl
177 _access(
178 _In_z_ const char *_Filename,
179 _In_ int _AccessMode);
180
181 _Check_return_
182 _CRTIMP
183 int
184 __cdecl
185 _chmod(
186 _In_z_ const char *_Filename,
187 _In_ int _Mode);
188
189 _Check_return_
190 _CRTIMP
191 int
192 __cdecl
193 _chsize(
194 _In_ int _FileHandle,
195 _In_ long _Size);
196
197 _Check_return_opt_
198 _CRTIMP
199 int
200 __cdecl
201 _close(
202 _In_ int _FileHandle);
203
204 _Check_return_opt_
205 _CRTIMP
206 int
207 __cdecl
208 _commit(
209 _In_ int _FileHandle);
210
211 _Check_return_
212 _CRTIMP
213 int
214 __cdecl
215 _creat(
216 _In_z_ const char *_Filename,
217 _In_ int _PermissionMode);
218
219 _Check_return_
220 _CRTIMP
221 int
222 __cdecl
223 _dup(
224 _In_ int _FileHandle);
225
226 _Check_return_
227 _CRTIMP
228 int
229 __cdecl
230 _dup2(
231 _In_ int _FileHandleSrc,
232 _In_ int _FileHandleDst);
233
234 _Check_return_
235 _CRTIMP
236 int
237 __cdecl
238 _eof(
239 _In_ int _FileHandle);
240
241 _Check_return_
242 _CRTIMP
243 long
244 __cdecl
245 _filelength(
246 _In_ int _FileHandle);
247
248 _CRTIMP
249 intptr_t
250 __cdecl
251 _findfirst(
252 const char *_Filename,
253 struct _finddata_t *_FindData);
254
255 _Check_return_
256 _CRTIMP
257 intptr_t
258 __cdecl
259 _findfirst32(
260 _In_z_ const char *_Filename,
261 _Out_ struct _finddata32_t *_FindData);
262
263 _CRTIMP
264 int
265 __cdecl
266 _findnext(
267 intptr_t _FindHandle,
268 struct _finddata_t *_FindData);
269
270 _Check_return_
271 _CRTIMP
272 int
273 __cdecl
274 _findnext32(
275 _In_ intptr_t _FindHandle,
276 _Out_ struct _finddata32_t *_FindData);
277
278 _Check_return_opt_
279 _CRTIMP
280 int
281 __cdecl
282 _findclose(
283 _In_ intptr_t _FindHandle);
284
285 _Check_return_
286 _CRTIMP
287 int
288 __cdecl
289 _isatty(
290 _In_ int _FileHandle);
291
292 _CRTIMP
293 int
294 __cdecl
295 _locking(
296 _In_ int _FileHandle,
297 _In_ int _LockMode,
298 _In_ long _NumOfBytes);
299
300 _Check_return_opt_
301 _CRTIMP
302 long
303 __cdecl
304 _lseek(
305 _In_ int _FileHandle,
306 _In_ long _Offset,
307 _In_ int _Origin);
308
309 _Check_return_
310 _CRTIMP
311 char*
312 __cdecl
313 _mktemp(
314 _Inout_z_ char *_TemplateName);
315
316 _Check_return_
317 _CRTIMP
318 int
319 __cdecl
320 _pipe(
321 _Inout_updates_(2) int *_PtHandles,
322 _In_ unsigned int _PipeSize,
323 _In_ int _TextMode);
324
325 _Check_return_
326 _CRTIMP
327 int
328 __cdecl
329 _read(
330 _In_ int _FileHandle,
331 _Out_writes_bytes_(_MaxCharCount) void *_DstBuf,
332 _In_ unsigned int _MaxCharCount);
333
334 #ifndef _CRT_DIRECTORY_DEFINED
335 #define _CRT_DIRECTORY_DEFINED
336
337 _Check_return_
338 int
339 __cdecl
340 remove(
341 _In_z_ const char *_Filename);
342
343 _Check_return_
344 int
345 __cdecl
346 rename(
347 _In_z_ const char *_OldFilename,
348 _In_z_ const char *_NewFilename);
349
350 _Check_return_
351 _CRTIMP
352 int
353 __cdecl
354 _unlink(
355 _In_z_ const char *_Filename);
356
357 #ifndef NO_OLDNAMES
358 _Check_return_
359 _CRTIMP
360 int
361 __cdecl
362 unlink(
363 _In_z_ const char *_Filename);
364 #endif
365
366 #endif /* _CRT_DIRECTORY_DEFINED */
367
368 _Check_return_
369 _CRTIMP
370 int
371 __cdecl
372 _setmode(
373 _In_ int _FileHandle,
374 _In_ int _Mode);
375
376 _Check_return_
377 _CRTIMP
378 long
379 __cdecl
380 _tell(
381 _In_ int _FileHandle);
382
383 _CRTIMP
384 int
385 __cdecl
386 _umask(
387 _In_ int _Mode);
388
389 _CRTIMP
390 int
391 __cdecl
392 _write(
393 _In_ int _FileHandle,
394 _In_reads_bytes_(_MaxCharCount) const void *_Buf,
395 _In_ unsigned int _MaxCharCount);
396
397 #if _INTEGRAL_MAX_BITS >= 64
398
399 _Check_return_
400 __MINGW_EXTENSION
401 _CRTIMP
402 __int64
403 __cdecl
404 _filelengthi64(
405 _In_ int _FileHandle);
406
407 _Check_return_
408 _CRTIMP
409 intptr_t
410 __cdecl
411 _findfirst32i64(
412 _In_z_ const char *_Filename,
413 _Out_ struct _finddata32i64_t *_FindData);
414
415 _Check_return_
416 _CRTIMP
417 intptr_t
418 __cdecl
419 _findfirst64i32(
420 _In_z_ const char *_Filename,
421 _Out_ struct _finddata64i32_t *_FindData);
422
423 _Check_return_
424 _CRTIMP
425 intptr_t
426 __cdecl
427 _findfirst64(
428 _In_z_ const char *_Filename,
429 _Out_ struct __finddata64_t *_FindData);
430
431 _Check_return_
432 _CRTIMP
433 int
434 __cdecl
435 _findnext32i64(
436 _In_ intptr_t _FindHandle,
437 _Out_ struct _finddata32i64_t *_FindData);
438
439 _Check_return_
440 _CRTIMP
441 int
442 __cdecl
443 _findnext64i32(
444 _In_ intptr_t _FindHandle,
445 _Out_ struct _finddata64i32_t *_FindData);
446
447 _Check_return_
448 _CRTIMP
449 int
450 __cdecl
451 _findnext64(
452 _In_ intptr_t _FindHandle,
453 _Out_ struct __finddata64_t *_FindData);
454
455 _Check_return_opt_
456 __MINGW_EXTENSION
457 _CRTIMP
458 __int64
459 __cdecl
460 _lseeki64(
461 _In_ int _FileHandle,
462 _In_ __int64 _Offset,
463 _In_ int _Origin);
464
465 _Check_return_
466 __MINGW_EXTENSION
467 _CRTIMP
468 __int64
469 __cdecl
470 _telli64(
471 _In_ int _FileHandle);
472
473 #ifdef __cplusplus
474 #include <string.h>
475 #endif
476
477 __CRT_INLINE
478 intptr_t
479 __cdecl
480 _findfirst64i32(
481 const char *_Filename,
482 struct _finddata64i32_t *_FindData)
483 {
484 struct __finddata64_t fd;
485 intptr_t ret = _findfirst64(_Filename,&fd);
486 _FindData->attrib=fd.attrib;
487 _FindData->time_create=fd.time_create;
488 _FindData->time_access=fd.time_access;
489 _FindData->time_write=fd.time_write;
490 _FindData->size=(_fsize_t) fd.size;
491 strncpy(_FindData->name,fd.name,260);
492 return ret;
493 }
494
495 __CRT_INLINE
496 int
497 __cdecl
498 _findnext64i32(
499 intptr_t _FindHandle,
500 struct _finddata64i32_t *_FindData)
501 {
502 struct __finddata64_t fd;
503 int ret = _findnext64(_FindHandle,&fd);
504 _FindData->attrib=fd.attrib;
505 _FindData->time_create=fd.time_create;
506 _FindData->time_access=fd.time_access;
507 _FindData->time_write=fd.time_write;
508 _FindData->size=(_fsize_t) fd.size;
509 strncpy(_FindData->name,fd.name,260);
510 return ret;
511 }
512
513 #endif /* _INTEGRAL_MAX_BITS >= 64 */
514
515 #ifndef NO_OLDNAMES
516 #ifndef _UWIN
517
518 _Check_return_
519 _CRTIMP
520 int
521 __cdecl
522 chdir(
523 _In_z_ const char *_Path);
524
525 _Check_return_
526 _Ret_opt_z_
527 _CRTIMP
528 char*
529 __cdecl
530 getcwd(
531 _Out_writes_opt_(_SizeInBytes) char *_DstBuf,
532 _In_ int _SizeInBytes);
533
534 _Check_return_
535 _CRTIMP
536 int
537 __cdecl
538 mkdir(
539 _In_z_ const char *_Path);
540
541 _CRTIMP
542 char*
543 __cdecl
544 mktemp(
545 _Inout_z_ char *_TemplateName);
546
547 _Check_return_
548 _CRTIMP
549 int
550 __cdecl
551 rmdir(
552 _In_z_ const char *_Path);
553
554 _Check_return_
555 _CRTIMP
556 int
557 __cdecl
558 chmod(
559 _In_z_ const char *_Filename,
560 _In_ int _AccessMode);
561
562 #endif /* _UWIN */
563 #endif /* Not NO_OLDNAMES */
564
565 _Check_return_wat_
566 _CRTIMP
567 errno_t
568 __cdecl
569 _sopen_s(
570 _Out_ int *_FileHandle,
571 _In_z_ const char *_Filename,
572 _In_ int _OpenFlag,
573 _In_ int _ShareFlag,
574 _In_ int _PermissionMode);
575
576 #ifndef __cplusplus
577 _CRTIMP int __cdecl _open(const char *_Filename,int _OpenFlag,...);
578 _CRTIMP int __cdecl _sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...);
579 #else
580 extern "C++" _CRTIMP int __cdecl _open(const char *_Filename,int _Openflag,int _PermissionMode = 0);
581 extern "C++" _CRTIMP int __cdecl _sopen(const char *_Filename,int _Openflag,int _ShareFlag,int _PermissionMode = 0);
582 #endif
583
584 #ifndef _WIO_DEFINED
585 #define _WIO_DEFINED
586
587 _Check_return_
588 _CRTIMP
589 int
590 __cdecl
591 _waccess(
592 _In_z_ const wchar_t *_Filename,
593 _In_ int _AccessMode);
594
595 _Check_return_
596 _CRTIMP
597 int
598 __cdecl
599 _wchmod(
600 _In_z_ const wchar_t *_Filename,
601 _In_ int _Mode);
602
603 _Check_return_
604 _CRTIMP
605 int
606 __cdecl
607 _wcreat(
608 _In_z_ const wchar_t *_Filename,
609 _In_ int _PermissionMode);
610
611 _Check_return_
612 _CRTIMP
613 intptr_t
614 __cdecl
615 _wfindfirst32(
616 _In_z_ const wchar_t *_Filename,
617 _Out_ struct _wfinddata32_t *_FindData);
618
619 _Check_return_
620 _CRTIMP
621 int
622 __cdecl
623 _wfindnext32(
624 _In_ intptr_t _FindHandle,
625 _Out_ struct _wfinddata32_t *_FindData);
626
627 _Check_return_
628 _CRTIMP
629 int
630 __cdecl
631 _wunlink(
632 _In_z_ const wchar_t *_Filename);
633
634 _Check_return_
635 _CRTIMP
636 int
637 __cdecl
638 _wrename(
639 _In_z_ const wchar_t *_NewFilename,
640 _In_z_ const wchar_t *_OldFilename);
641
642 _CRTIMP
643 wchar_t*
644 __cdecl
645 _wmktemp(
646 _Inout_z_ wchar_t *_TemplateName);
647
648 #if _INTEGRAL_MAX_BITS >= 64
649
650 _Check_return_
651 _CRTIMP
652 intptr_t
653 __cdecl
654 _wfindfirst32i64(
655 _In_z_ const wchar_t *_Filename,
656 _Out_ struct _wfinddata32i64_t *_FindData);
657
658 _Check_return_
659 _CRTIMP
660 intptr_t
661 __cdecl
662 _wfindfirst64i32(
663 _In_z_ const wchar_t *_Filename,
664 _Out_ struct _wfinddata64i32_t *_FindData);
665
666 _Check_return_
667 _CRTIMP
668 intptr_t
669 __cdecl
670 _wfindfirst64(
671 _In_z_ const wchar_t *_Filename,
672 _Out_ struct _wfinddata64_t *_FindData);
673
674 _Check_return_
675 _CRTIMP
676 int
677 __cdecl
678 _wfindnext32i64(
679 _In_ intptr_t _FindHandle,
680 _Out_ struct _wfinddata32i64_t *_FindData);
681
682 _Check_return_
683 _CRTIMP
684 int
685 __cdecl
686 _wfindnext64i32(
687 _In_ intptr_t _FindHandle,
688 _Out_ struct _wfinddata64i32_t *_FindData);
689
690 _Check_return_
691 _CRTIMP
692 int
693 __cdecl
694 _wfindnext64(
695 _In_ intptr_t _FindHandle,
696 _Out_ struct _wfinddata64_t *_FindData);
697
698 #endif /* _INTEGRAL_MAX_BITS >= 64 */
699
700 _Check_return_wat_
701 _CRTIMP
702 errno_t
703 __cdecl
704 _wsopen_s(
705 _Out_ int *_FileHandle,
706 _In_z_ const wchar_t *_Filename,
707 _In_ int _OpenFlag,
708 _In_ int _ShareFlag,
709 _In_ int _PermissionFlag);
710
711 #if !defined(__cplusplus) || !(defined(_X86_) && !defined(__x86_64))
712 _CRTIMP int __cdecl _wopen(const wchar_t *_Filename,int _OpenFlag,...);
713 _CRTIMP int __cdecl _wsopen(const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,...);
714 #else
715 extern "C++" _CRTIMP int __cdecl _wopen(const wchar_t *_Filename,int _OpenFlag,int _PermissionMode = 0);
716 extern "C++" _CRTIMP int __cdecl _wsopen(const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionMode = 0);
717 #endif
718
719 #endif /* !_WIO_DEFINED */
720
721 int
722 __cdecl
723 __lock_fhandle(
724 _In_ int _Filehandle);
725
726 void
727 __cdecl
728 _unlock_fhandle(
729 _In_ int _Filehandle);
730
731 _CRTIMP
732 intptr_t
733 __cdecl
734 _get_osfhandle(
735 _In_ int _FileHandle);
736
737 _CRTIMP
738 int
739 __cdecl
740 _open_osfhandle(
741 _In_ intptr_t _OSFileHandle,
742 _In_ int _Flags);
743
744 #ifndef NO_OLDNAMES
745
746 _Check_return_
747 _CRTIMP
748 int
749 __cdecl
750 access(
751 _In_z_ const char *_Filename,
752 _In_ int _AccessMode);
753
754 _Check_return_
755 _CRTIMP
756 int
757 __cdecl
758 chmod(
759 _In_z_ const char *_Filename,
760 _In_ int _AccessMode);
761
762 _Check_return_
763 _CRTIMP
764 int
765 __cdecl
766 chsize(
767 _In_ int _FileHandle,
768 _In_ long _Size);
769
770 _Check_return_opt_
771 _CRTIMP
772 int
773 __cdecl
774 close(
775 _In_ int _FileHandle);
776
777 _Check_return_
778 _CRTIMP
779 int
780 __cdecl
781 creat(
782 _In_z_ const char *_Filename,
783 _In_ int _PermissionMode);
784
785 _Check_return_
786 _CRTIMP
787 int
788 __cdecl
789 dup(
790 _In_ int _FileHandle);
791
792 _Check_return_
793 _CRTIMP
794 int
795 __cdecl
796 dup2(
797 _In_ int _FileHandleSrc,
798 _In_ int _FileHandleDst);
799
800 _Check_return_
801 _CRTIMP
802 int
803 __cdecl
804 __cdecl eof(
805 _In_ int _FileHandle);
806
807 _Check_return_
808 _CRTIMP
809 long
810 __cdecl
811 filelength(
812 _In_ int _FileHandle);
813
814 _Check_return_
815 _CRTIMP
816 int
817 __cdecl
818 isatty(
819 _In_ int _FileHandle);
820
821 _Check_return_
822 _CRTIMP
823 int
824 __cdecl
825 locking(
826 _In_ int _FileHandle,
827 _In_ int _LockMode,
828 _In_ long _NumOfBytes);
829
830 _Check_return_opt_
831 _CRTIMP
832 long
833 __cdecl
834 lseek(
835 _In_ int _FileHandle,
836 _In_ long _Offset,
837 _In_ int _Origin);
838
839 _CRTIMP
840 char*
841 __cdecl
842 mktemp(
843 _Inout_z_ char *_TemplateName);
844
845 _Check_return_
846 _CRTIMP
847 int
848 __cdecl
849 open(
850 _In_z_ const char *_Filename,
851 _In_ int _OpenFlag,
852 ...);
853
854 _CRTIMP
855 int
856 __cdecl
857 read(
858 _In_ int _FileHandle,
859 _Out_writes_bytes_(_MaxCharCount) void *_DstBuf,
860 _In_ unsigned int _MaxCharCount);
861
862 _Check_return_
863 _CRTIMP
864 int
865 __cdecl
866 setmode(
867 _In_ int _FileHandle,
868 _In_ int _Mode);
869
870 _CRTIMP
871 int
872 __cdecl
873 sopen(
874 const char *_Filename,
875 int _OpenFlag,
876 int _ShareFlag,
877 ...);
878
879 _Check_return_
880 _CRTIMP
881 long
882 __cdecl
883 tell(
884 _In_ int _FileHandle);
885
886 _CRTIMP
887 int
888 __cdecl
889 umask(
890 _In_ int _Mode);
891
892 _Check_return_
893 _CRTIMP
894 int
895 __cdecl
896 write(
897 _In_ int _Filehandle,
898 _In_reads_bytes_(_MaxCharCount) const void *_Buf,
899 _In_ unsigned int _MaxCharCount);
900
901 #endif /* NO_OLDNAMES */
902
903 #ifdef __cplusplus
904 }
905 #endif
906 #endif
907
908 #ifdef __cplusplus
909 extern "C" {
910 #endif
911
912 /* Misc stuff */
913 char *getlogin(void);
914 #ifdef __USE_MINGW_ALARM
915 unsigned int alarm(unsigned int seconds);
916 #endif
917
918 #ifdef __USE_MINGW_ACCESS
919 /* Old versions of MSVCRT access() just ignored X_OK, while the version
920 shipped with Vista, returns an error code. This will restore the
921 old behaviour */
922 static inline int __mingw_access (const char *__fname, int __mode) {
923 return _access (__fname, __mode & ~X_OK);
924 }
925
926 #define access(__f,__m) __mingw_access (__f, __m)
927 #endif
928
929 #ifdef __cplusplus
930 }
931 #endif
932
933 #pragma pack(pop)
934
935 #include <sec_api/io_s.h>
936
937 #endif /* End _IO_H_ */
938