[HEADERS]
[reactos.git] / reactos / include / crt / io.h
index 552dc47..4a3f37d 100644 (file)
@@ -1,3 +1,4 @@
+
 /**
  * This file has no copyright assigned and is placed in the Public Domain.
  * This file is part of the w64 mingw-runtime package.
@@ -6,7 +7,7 @@
 #ifndef _IO_H_
 #define _IO_H_
 
-#include <_mingw.h>
+#include <crtdefs.h>
 #include <string.h>
 
 #pragma pack(push,_CRT_PACKING)
@@ -25,6 +26,15 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
 
 #ifndef _FINDDATA_T_DEFINED
 
+  struct _finddata_t {
+    unsigned attrib;
+    time_t time_create;
+    time_t time_access;
+    time_t time_write;
+    _fsize_t size;
+    char name[260];
+  };
+
   struct _finddata32_t {
     unsigned attrib;
     __time32_t time_create;
@@ -34,14 +44,23 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
     char name[260];
   };
 
-/*#if _INTEGRAL_MAX_BITS >= 64*/
+#if _INTEGRAL_MAX_BITS >= 64
+
+  struct _finddatai64_t {
+    unsigned attrib;
+    time_t time_create;
+    time_t time_access;
+    time_t time_write;
+    __MINGW_EXTENSION __int64 size;
+    char name[260];
+  };
 
   struct _finddata32i64_t {
     unsigned attrib;
     __time32_t time_create;
     __time32_t time_access;
     __time32_t time_write;
-    __int64 size;
+    __MINGW_EXTENSION __int64 size;
     char name[260];
   };
 
@@ -59,39 +78,25 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
     __time64_t time_create;
     __time64_t time_access;
     __time64_t time_write;
-    __int64 size;
+    __MINGW_EXTENSION __int64 size;
     char name[260];
   };
-/* #endif */
-
-#ifdef _USE_32BIT_TIME_T
-#define _finddata_t _finddata32_t
-#define _finddatai64_t _finddata32i64_t
-
-#ifdef _WIN64
-#define _findfirst _findfirst32
-#define _findnext _findnext32
-#else
-#define _findfirst32 _findfirst
-#define _findnext32 _findnext
-#endif
-#define _findfirsti64 _findfirst32i64
-#define _findnexti64 _findnext32i64
-#else
-#define _finddata_t _finddata64i32_t
-#define _finddatai64_t __finddata64_t
-
-#define _findfirst _findfirst64i32
-#define _findnext _findnext64i32
-#define _findfirsti64 _findfirst64
-#define _findnexti64 _findnext64
-#endif
+#endif /* _INTEGRAL_MAX_BITS >= 64 */
 
 #define _FINDDATA_T_DEFINED
 #endif
 
 #ifndef _WFINDDATA_T_DEFINED
 
+  struct _wfinddata_t {
+    unsigned attrib;
+    time_t time_create;
+    time_t time_access;
+    time_t time_write;
+    _fsize_t size;
+    wchar_t name[260];
+  };
+
   struct _wfinddata32_t {
     unsigned attrib;
     __time32_t time_create;
@@ -101,14 +106,23 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
     wchar_t name[260];
   };
 
-/* #if _INTEGRAL_MAX_BITS >= 64 */
+#if _INTEGRAL_MAX_BITS >= 64
+
+  struct _wfinddatai64_t {
+    unsigned attrib;
+    time_t time_create;
+    time_t time_access;
+    time_t time_write;
+    __MINGW_EXTENSION __int64 size;
+    wchar_t name[260];
+  };
 
   struct _wfinddata32i64_t {
     unsigned attrib;
     __time32_t time_create;
     __time32_t time_access;
     __time32_t time_write;
-    __int64 size;
+    __MINGW_EXTENSION __int64 size;
     wchar_t name[260];
   };
 
@@ -126,27 +140,9 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
     __time64_t time_create;
     __time64_t time_access;
     __time64_t time_write;
-    __int64 size;
+    __MINGW_EXTENSION __int64 size;
     wchar_t name[260];
   };
-/* #endif */
-
-#ifdef _USE_32BIT_TIME_T
-#define _wfinddata_t _wfinddata32_t
-#define _wfinddatai64_t _wfinddata32i64_t
-
-#define _wfindfirst _wfindfirst32
-#define _wfindnext _wfindnext32
-#define _wfindfirsti64 _wfindfirst32i64
-#define _wfindnexti64 _wfindnext32i64
-#else
-#define _wfinddata_t _wfinddata64i32_t
-#define _wfinddatai64_t _wfinddata64_t
-
-#define _wfindfirst _wfindfirst64i32
-#define _wfindnext _wfindnext64i32
-#define _wfindfirsti64 _wfindfirst64
-#define _wfindnexti64 _wfindnext64
 #endif
 
 #define _WFINDDATA_T_DEFINED
@@ -159,60 +155,6 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
 #define _A_SUBDIR 0x10
 #define _A_ARCH 0x20
 
-#ifndef _SIZE_T_DEFINED
-#define _SIZE_T_DEFINED
-#undef size_t
-#ifdef _WIN64
-#if defined(__GNUC__) && defined(__STRICT_ANSI__)
-  typedef unsigned int size_t __attribute__ ((mode (DI)));
-#else
-  typedef unsigned __int64 size_t;
-#endif
-#else
-  typedef unsigned int size_t;
-#endif
-#endif
-
-#ifndef _SSIZE_T_DEFINED
-#define _SSIZE_T_DEFINED
-#undef ssize_t
-#ifdef _WIN64
-#if defined(__GNUC__) && defined(__STRICT_ANSI__)
-  typedef int ssize_t __attribute__ ((mode (DI)));
-#else
-  typedef __int64 ssize_t;
-#endif
-#else
-  typedef int ssize_t;
-#endif
-#endif
-
-#ifndef _OFF_T_DEFINED
-#define _OFF_T_DEFINED
-#ifndef _OFF_T_
-#define _OFF_T_
-  typedef long _off_t;
-#if !defined(NO_OLDNAMES) || defined(_POSIX)
-  typedef long off_t;
-#endif
-#endif
-#endif
-
-#ifndef _OFF64_T_DEFINED
-#define _OFF64_T_DEFINED
-#if defined(__GNUC__) && defined(__STRICT_ANSI__)
-  typedef int _off64_t __attribute__ ((mode (DI)));
-#if !defined(NO_OLDNAMES) || defined(_POSIX)
-  typedef int off64_t __attribute__ ((mode (DI)));
-#endif
-#else
-  typedef long long _off64_t;
-#if !defined(NO_OLDNAMES) || defined(_POSIX)
-  typedef long long off64_t;
-#endif
-#endif
-#endif
-
   /* Some defines for _access nAccessMode (MS doesn't define them, but
   * it doesn't seem to hurt to add them). */
 #define        F_OK    0       /* Check for file existence */
@@ -230,13 +172,14 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
   _CRTIMP int __cdecl _dup2(int _FileHandleSrc,int _FileHandleDst);
   _CRTIMP int __cdecl _eof(int _FileHandle);
   _CRTIMP long __cdecl _filelength(int _FileHandle);
+  _CRTIMP intptr_t __cdecl _findfirst(const char *_Filename, struct _finddata_t *_FindData);
   _CRTIMP intptr_t __cdecl _findfirst32(const char *_Filename,struct _finddata32_t *_FindData);
+  _CRTIMP int __cdecl _findnext(intptr_t _FindHandle,struct _finddata_t *_FindData);
   _CRTIMP int __cdecl _findnext32(intptr_t _FindHandle,struct _finddata32_t *_FindData);
   _CRTIMP int __cdecl _findclose(intptr_t _FindHandle);
   _CRTIMP int __cdecl _isatty(int _FileHandle);
   _CRTIMP int __cdecl _locking(int _FileHandle,int _LockMode,long _NumOfBytes);
   _CRTIMP long __cdecl _lseek(int _FileHandle,long _Offset,int _Origin);
-  _off64_t lseek64(int fd,_off64_t offset, int whence);
   _CRTIMP char *__cdecl _mktemp(char *_TemplateName);
   _CRTIMP int __cdecl _pipe(int *_PtHandles,unsigned int _PipeSize,int _TextMode);
   _CRTIMP int __cdecl _read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount);
@@ -247,7 +190,7 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
   int __cdecl rename(const char *_OldFilename,const char *_NewFilename);
   _CRTIMP int __cdecl _unlink(const char *_Filename);
 #ifndef        NO_OLDNAMES
-  int __cdecl unlink(const char *_Filename);
+  _CRTIMP int __cdecl unlink(const char *_Filename);
 #endif
 #endif
 
@@ -257,13 +200,18 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
   _CRTIMP int __cdecl _write(int _FileHandle,const void *_Buf,unsigned int _MaxCharCount);
 
 #if _INTEGRAL_MAX_BITS >= 64
-  _CRTIMP __int64 __cdecl _filelengthi64(int _FileHandle);
+  __MINGW_EXTENSION _CRTIMP __int64 __cdecl _filelengthi64(int _FileHandle);
   _CRTIMP intptr_t __cdecl _findfirst32i64(const char *_Filename,struct _finddata32i64_t *_FindData);
+  _CRTIMP intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t *_FindData);
   _CRTIMP intptr_t __cdecl _findfirst64(const char *_Filename,struct __finddata64_t *_FindData);
+  _CRTIMP int __cdecl _findnext32i64(intptr_t _FindHandle,struct _finddata32i64_t *_FindData);
+  _CRTIMP int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindData);
+  _CRTIMP int __cdecl _findnext64(intptr_t _FindHandle,struct __finddata64_t *_FindData);
+  __MINGW_EXTENSION _CRTIMP __int64 __cdecl _lseeki64(int _FileHandle,__int64 _Offset,int _Origin);
+  __MINGW_EXTENSION _CRTIMP __int64 __cdecl _telli64(int _FileHandle);
 #ifdef __cplusplus
 #include <string.h>
 #endif
-  intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t *_FindData);
   __CRT_INLINE intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t *_FindData)
   {
     struct __finddata64_t fd;
@@ -276,9 +224,6 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
     strncpy(_FindData->name,fd.name,260);
     return ret;
   }
-  _CRTIMP int __cdecl _findnext32i64(intptr_t _FindHandle,struct _finddata32i64_t *_FindData);
-  _CRTIMP int __cdecl _findnext64(intptr_t _FindHandle,struct __finddata64_t *_FindData);
-  int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindData);
   __CRT_INLINE int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindData)
   {
     struct __finddata64_t fd;
@@ -291,20 +236,17 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
     strncpy(_FindData->name,fd.name,260);
     return ret;
   }
-  __int64 __cdecl _lseeki64(int _FileHandle,__int64 _Offset,int _Origin);
-  __int64 __cdecl _telli64(int _FileHandle);
 #endif
-#ifndef NO_OLDNAMES
 
+#ifndef NO_OLDNAMES
 #ifndef _UWIN
-  int __cdecl chdir (const char *);
-  char *__cdecl getcwd (char *, int);
-  int __cdecl mkdir (const char *);
-  char *__cdecl mktemp(char *);
-  int __cdecl rmdir (const char*);
-  int __cdecl chmod (const char *, int);
+  _CRTIMP int __cdecl chdir (const char *);
+  _CRTIMP char *__cdecl getcwd (char *, int);
+  _CRTIMP int __cdecl mkdir (const char *);
+  _CRTIMP char *__cdecl mktemp(char *);
+  _CRTIMP int __cdecl rmdir (const char*);
+  _CRTIMP int __cdecl chmod (const char *, int);
 #endif /* _UWIN */
-
 #endif /* Not NO_OLDNAMES */
 
   _CRTIMP errno_t __cdecl _sopen_s(int *_FileHandle,const char *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionMode);
@@ -347,7 +289,7 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
   extern "C++" _CRTIMP int __cdecl _wsopen(const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionMode = 0);
 #endif
 
-#endif
+#endif /* !_WIO_DEFINED */
 
   int __cdecl __lock_fhandle(int _Filehandle);
   void __cdecl _unlock_fhandle(int _Filehandle);
@@ -355,26 +297,26 @@ _CRTIMP char* __cdecl _getcwd (char*, int);
   _CRTIMP int __cdecl _open_osfhandle(intptr_t _OSFileHandle,int _Flags);
 
 #ifndef        NO_OLDNAMES
-  int __cdecl access(const char *_Filename,int _AccessMode);
-  int __cdecl chmod(const char *_Filename,int _AccessMode);
-  int __cdecl chsize(int _FileHandle,long _Size);
-  int __cdecl close(int _FileHandle);
-  int __cdecl creat(const char *_Filename,int _PermissionMode);
-  int __cdecl dup(int _FileHandle);
-  int __cdecl dup2(int _FileHandleSrc,int _FileHandleDst);
-  int __cdecl eof(int _FileHandle);
-  long __cdecl filelength(int _FileHandle);
-  int __cdecl isatty(int _FileHandle);
-  int __cdecl locking(int _FileHandle,int _LockMode,long _NumOfBytes);
-  long __cdecl lseek(int _FileHandle,long _Offset,int _Origin);
-  char *__cdecl mktemp(char *_TemplateName);
-  int __cdecl open(const char *_Filename,int _OpenFlag,...);
-  int __cdecl read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount);
-  int __cdecl setmode(int _FileHandle,int _Mode);
-  int __cdecl sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...);
-  long __cdecl tell(int _FileHandle);
-  int __cdecl umask(int _Mode);
-  int __cdecl write(int _Filehandle,const void *_Buf,unsigned int _MaxCharCount);
+  _CRTIMP int __cdecl access(const char *_Filename,int _AccessMode);
+  _CRTIMP int __cdecl chmod(const char *_Filename,int _AccessMode);
+  _CRTIMP int __cdecl chsize(int _FileHandle,long _Size);
+  _CRTIMP int __cdecl close(int _FileHandle);
+  _CRTIMP int __cdecl creat(const char *_Filename,int _PermissionMode);
+  _CRTIMP int __cdecl dup(int _FileHandle);
+  _CRTIMP int __cdecl dup2(int _FileHandleSrc,int _FileHandleDst);
+  _CRTIMP int __cdecl eof(int _FileHandle);
+  _CRTIMP long __cdecl filelength(int _FileHandle);
+  _CRTIMP int __cdecl isatty(int _FileHandle);
+  _CRTIMP int __cdecl locking(int _FileHandle,int _LockMode,long _NumOfBytes);
+  _CRTIMP long __cdecl lseek(int _FileHandle,long _Offset,int _Origin);
+  _CRTIMP char *__cdecl mktemp(char *_TemplateName);
+  _CRTIMP int __cdecl open(const char *_Filename,int _OpenFlag,...);
+  _CRTIMP int __cdecl read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount);
+  _CRTIMP int __cdecl setmode(int _FileHandle,int _Mode);
+  _CRTIMP int __cdecl sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...);
+  _CRTIMP long __cdecl tell(int _FileHandle);
+  _CRTIMP int __cdecl umask(int _Mode);
+  _CRTIMP int __cdecl write(int _Filehandle,const void *_Buf,unsigned int _MaxCharCount);
 #endif
 
 #ifdef __cplusplus
@@ -388,7 +330,9 @@ extern "C" {
 
 /* Misc stuff */
 char *getlogin(void);
+#ifdef __USE_MINGW_ALARM
 unsigned int alarm(unsigned int seconds);
+#endif
 
 #ifdef __USE_MINGW_ACCESS
 /*  Old versions of MSVCRT access() just ignored X_OK, while the version