Kai Tietz | 9d937a7 | 2007-08-10 10:41:48 +0000 | [diff] [blame] | 1 | /** |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. |
Rafaël Carré | 8a67ab4 | 2012-06-28 15:40:59 +0000 | [diff] [blame] | 3 | * This file is part of the mingw-w64 runtime package. |
Kai Tietz | d42ac88 | 2010-01-15 20:17:42 +0000 | [diff] [blame] | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
Kai Tietz | 9d937a7 | 2007-08-10 10:41:48 +0000 | [diff] [blame] | 5 | */ |
NightStrike | f273f68 | 2008-01-23 18:11:39 +0000 | [diff] [blame] | 6 | #ifndef _IO_H_ |
| 7 | #define _IO_H_ |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 8 | |
Jacek Caban | b33bcd6 | 2012-07-04 13:06:41 +0000 | [diff] [blame] | 9 | #include <crtdefs.h> |
Kai Tietz | 7750267 | 2007-11-23 10:26:28 +0000 | [diff] [blame] | 10 | #include <string.h> |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 11 | |
David Wohlferd | 6172d2f | 2016-08-26 17:31:14 -0700 | [diff] [blame] | 12 | #if defined(__LIBMSVCRT__) |
| 13 | /* When building mingw-w64, this should be blank. */ |
| 14 | #define _SECIMP |
| 15 | #else |
| 16 | #ifndef _SECIMP |
| 17 | #define _SECIMP __declspec(dllimport) |
| 18 | #endif /* _SECIMP */ |
| 19 | #endif /* defined(_CRTBLD) || defined(__LIBMSVCRT__) */ |
| 20 | |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 21 | #pragma pack(push,_CRT_PACKING) |
| 22 | |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
Kai Tietz | dd2ce97 | 2007-11-08 14:23:36 +0000 | [diff] [blame] | 27 | _CRTIMP char* __cdecl _getcwd (char*, int); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 28 | #ifndef _FSIZE_T_DEFINED |
| 29 | typedef unsigned long _fsize_t; |
| 30 | #define _FSIZE_T_DEFINED |
| 31 | #endif |
| 32 | |
| 33 | #ifndef _FINDDATA_T_DEFINED |
| 34 | |
| 35 | struct _finddata32_t { |
| 36 | unsigned attrib; |
| 37 | __time32_t time_create; |
| 38 | __time32_t time_access; |
| 39 | __time32_t time_write; |
| 40 | _fsize_t size; |
| 41 | char name[260]; |
| 42 | }; |
| 43 | |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 44 | struct _finddata32i64_t { |
| 45 | unsigned attrib; |
| 46 | __time32_t time_create; |
| 47 | __time32_t time_access; |
| 48 | __time32_t time_write; |
Kai Tietz | 12cda48 | 2009-09-06 12:02:08 +0000 | [diff] [blame] | 49 | __MINGW_EXTENSION __int64 size; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 50 | char name[260]; |
| 51 | }; |
| 52 | |
| 53 | struct _finddata64i32_t { |
| 54 | unsigned attrib; |
| 55 | __time64_t time_create; |
| 56 | __time64_t time_access; |
| 57 | __time64_t time_write; |
| 58 | _fsize_t size; |
| 59 | char name[260]; |
| 60 | }; |
| 61 | |
| 62 | struct __finddata64_t { |
| 63 | unsigned attrib; |
| 64 | __time64_t time_create; |
| 65 | __time64_t time_access; |
| 66 | __time64_t time_write; |
Kai Tietz | 12cda48 | 2009-09-06 12:02:08 +0000 | [diff] [blame] | 67 | __MINGW_EXTENSION __int64 size; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 68 | char name[260]; |
| 69 | }; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 70 | |
| 71 | #ifdef _USE_32BIT_TIME_T |
| 72 | #define _finddata_t _finddata32_t |
| 73 | #define _finddatai64_t _finddata32i64_t |
| 74 | |
Martin Storsjö | eadcb62 | 2017-11-13 16:11:44 +0200 | [diff] [blame] | 75 | #define _findfirst _findfirst32 |
| 76 | #define _findnext _findnext32 |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 77 | #define _findfirsti64 _findfirst32i64 |
| 78 | #define _findnexti64 _findnext32i64 |
| 79 | #else |
| 80 | #define _finddata_t _finddata64i32_t |
| 81 | #define _finddatai64_t __finddata64_t |
| 82 | |
| 83 | #define _findfirst _findfirst64i32 |
| 84 | #define _findnext _findnext64i32 |
| 85 | #define _findfirsti64 _findfirst64 |
| 86 | #define _findnexti64 _findnext64 |
Ozkan Sezer | 1cd69a7 | 2009-07-27 05:43:24 +0000 | [diff] [blame] | 87 | #endif /* _USE_32BIT_TIME_T */ |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 88 | |
| 89 | #define _FINDDATA_T_DEFINED |
Ozkan Sezer | 1cd69a7 | 2009-07-27 05:43:24 +0000 | [diff] [blame] | 90 | #endif /* _FINDDATA_T_DEFINED */ |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 91 | |
| 92 | #ifndef _WFINDDATA_T_DEFINED |
| 93 | |
| 94 | struct _wfinddata32_t { |
| 95 | unsigned attrib; |
| 96 | __time32_t time_create; |
| 97 | __time32_t time_access; |
| 98 | __time32_t time_write; |
| 99 | _fsize_t size; |
| 100 | wchar_t name[260]; |
| 101 | }; |
| 102 | |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 103 | struct _wfinddata32i64_t { |
| 104 | unsigned attrib; |
| 105 | __time32_t time_create; |
| 106 | __time32_t time_access; |
| 107 | __time32_t time_write; |
Kai Tietz | 12cda48 | 2009-09-06 12:02:08 +0000 | [diff] [blame] | 108 | __MINGW_EXTENSION __int64 size; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 109 | wchar_t name[260]; |
| 110 | }; |
| 111 | |
| 112 | struct _wfinddata64i32_t { |
| 113 | unsigned attrib; |
| 114 | __time64_t time_create; |
| 115 | __time64_t time_access; |
| 116 | __time64_t time_write; |
| 117 | _fsize_t size; |
| 118 | wchar_t name[260]; |
| 119 | }; |
| 120 | |
| 121 | struct _wfinddata64_t { |
| 122 | unsigned attrib; |
| 123 | __time64_t time_create; |
| 124 | __time64_t time_access; |
| 125 | __time64_t time_write; |
Kai Tietz | 12cda48 | 2009-09-06 12:02:08 +0000 | [diff] [blame] | 126 | __MINGW_EXTENSION __int64 size; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 127 | wchar_t name[260]; |
| 128 | }; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 129 | |
| 130 | #ifdef _USE_32BIT_TIME_T |
| 131 | #define _wfinddata_t _wfinddata32_t |
| 132 | #define _wfinddatai64_t _wfinddata32i64_t |
| 133 | |
Martin Storsjö | eadcb62 | 2017-11-13 16:11:44 +0200 | [diff] [blame] | 134 | #define _wfindfirst _wfindfirst32 |
| 135 | #define _wfindnext _wfindnext32 |
Kai Tietz | 58e7c81 | 2009-08-27 07:13:57 +0000 | [diff] [blame] | 136 | #define _wfindfirst32i64 _wfindfirsti64 |
| 137 | #define _wfindnext32i64 _wfindnexti64 |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 138 | #else |
| 139 | #define _wfinddata_t _wfinddata64i32_t |
| 140 | #define _wfinddatai64_t _wfinddata64_t |
| 141 | |
| 142 | #define _wfindfirst _wfindfirst64i32 |
| 143 | #define _wfindnext _wfindnext64i32 |
| 144 | #define _wfindfirsti64 _wfindfirst64 |
| 145 | #define _wfindnexti64 _wfindnext64 |
Ozkan Sezer | 1cd69a7 | 2009-07-27 05:43:24 +0000 | [diff] [blame] | 146 | #endif /* _USE_32BIT_TIME_T */ |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 147 | |
| 148 | #define _WFINDDATA_T_DEFINED |
Ozkan Sezer | 1cd69a7 | 2009-07-27 05:43:24 +0000 | [diff] [blame] | 149 | #endif /* _WFINDDATA_T_DEFINED */ |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 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 | #ifndef _SIZE_T_DEFINED |
| 159 | #define _SIZE_T_DEFINED |
Kai Tietz | 9c7feae | 2008-03-27 15:28:02 +0000 | [diff] [blame] | 160 | #undef size_t |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 161 | #ifdef _WIN64 |
Kai Tietz | 12cda48 | 2009-09-06 12:02:08 +0000 | [diff] [blame] | 162 | __MINGW_EXTENSION typedef unsigned __int64 size_t; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 163 | #else |
Kai Tietz | 9c7feae | 2008-03-27 15:28:02 +0000 | [diff] [blame] | 164 | typedef unsigned int size_t; |
Ozkan Sezer | 1cd69a7 | 2009-07-27 05:43:24 +0000 | [diff] [blame] | 165 | #endif /* _WIN64 */ |
| 166 | #endif /* _SIZE_T_DEFINED */ |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 167 | |
| 168 | #ifndef _SSIZE_T_DEFINED |
| 169 | #define _SSIZE_T_DEFINED |
Kai Tietz | 9c7feae | 2008-03-27 15:28:02 +0000 | [diff] [blame] | 170 | #undef ssize_t |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 171 | #ifdef _WIN64 |
Kai Tietz | 12cda48 | 2009-09-06 12:02:08 +0000 | [diff] [blame] | 172 | __MINGW_EXTENSION typedef __int64 ssize_t; |
Kai Tietz | 69bc954 | 2008-01-17 19:17:53 +0000 | [diff] [blame] | 173 | #else |
Ozkan Sezer | 1379fef | 2011-08-21 13:12:30 +0000 | [diff] [blame] | 174 | typedef int ssize_t; |
Ozkan Sezer | 1cd69a7 | 2009-07-27 05:43:24 +0000 | [diff] [blame] | 175 | #endif /* _WIN64 */ |
| 176 | #endif /* _SSIZE_T_DEFINED */ |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 177 | |
Jonathan Yong | 4d3b28a | 2011-02-19 15:34:22 +0000 | [diff] [blame] | 178 | #include <_mingw_off_t.h> |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 179 | |
| 180 | /* Some defines for _access nAccessMode (MS doesn't define them, but |
| 181 | * it doesn't seem to hurt to add them). */ |
| 182 | #define F_OK 0 /* Check for file existence */ |
| 183 | #define X_OK 1 /* Check for execute permission. */ |
| 184 | #define W_OK 2 /* Check for write permission */ |
| 185 | #define R_OK 4 /* Check for read permission */ |
| 186 | |
| 187 | _CRTIMP int __cdecl _access(const char *_Filename,int _AccessMode); |
David Wohlferd | 6172d2f | 2016-08-26 17:31:14 -0700 | [diff] [blame] | 188 | _SECIMP errno_t __cdecl _access_s(const char *_Filename,int _AccessMode); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 189 | _CRTIMP int __cdecl _chmod(const char *_Filename,int _Mode); |
Jonathan Yong | 116470f | 2009-12-03 08:43:40 +0000 | [diff] [blame] | 190 | _CRTIMP int __cdecl _chsize(int _FileHandle,long _Size) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; |
David Wohlferd | 6172d2f | 2016-08-26 17:31:14 -0700 | [diff] [blame] | 191 | _SECIMP errno_t __cdecl _chsize_s (int _FileHandle,__int64 _Size); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 192 | _CRTIMP int __cdecl _close(int _FileHandle); |
| 193 | _CRTIMP int __cdecl _commit(int _FileHandle); |
Jonathan Yong | 116470f | 2009-12-03 08:43:40 +0000 | [diff] [blame] | 194 | _CRTIMP int __cdecl _creat(const char *_Filename,int _PermissionMode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 195 | _CRTIMP int __cdecl _dup(int _FileHandle); |
| 196 | _CRTIMP int __cdecl _dup2(int _FileHandleSrc,int _FileHandleDst); |
| 197 | _CRTIMP int __cdecl _eof(int _FileHandle); |
| 198 | _CRTIMP long __cdecl _filelength(int _FileHandle); |
| 199 | _CRTIMP intptr_t __cdecl _findfirst32(const char *_Filename,struct _finddata32_t *_FindData); |
| 200 | _CRTIMP int __cdecl _findnext32(intptr_t _FindHandle,struct _finddata32_t *_FindData); |
| 201 | _CRTIMP int __cdecl _findclose(intptr_t _FindHandle); |
| 202 | _CRTIMP int __cdecl _isatty(int _FileHandle); |
| 203 | _CRTIMP int __cdecl _locking(int _FileHandle,int _LockMode,long _NumOfBytes); |
| 204 | _CRTIMP long __cdecl _lseek(int _FileHandle,long _Offset,int _Origin); |
| 205 | _off64_t lseek64(int fd,_off64_t offset, int whence); |
Jonathan Yong | 116470f | 2009-12-03 08:43:40 +0000 | [diff] [blame] | 206 | _CRTIMP char *__cdecl _mktemp(char *_TemplateName) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; |
David Wohlferd | 6172d2f | 2016-08-26 17:31:14 -0700 | [diff] [blame] | 207 | _SECIMP errno_t __cdecl _mktemp_s (char *_TemplateName,size_t _Size); |
Steve Lhomme | 44e8e71 | 2020-04-20 08:46:04 +0200 | [diff] [blame] | 208 | #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 209 | _CRTIMP int __cdecl _pipe(int *_PtHandles,unsigned int _PipeSize,int _TextMode); |
Steve Lhomme | 44e8e71 | 2020-04-20 08:46:04 +0200 | [diff] [blame] | 210 | #endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 211 | _CRTIMP int __cdecl _read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount); |
| 212 | |
| 213 | #ifndef _CRT_DIRECTORY_DEFINED |
| 214 | #define _CRT_DIRECTORY_DEFINED |
Kai Tietz | 7fbd8c7 | 2007-10-16 14:38:02 +0000 | [diff] [blame] | 215 | int __cdecl remove(const char *_Filename); |
| 216 | int __cdecl rename(const char *_OldFilename,const char *_NewFilename); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 217 | _CRTIMP int __cdecl _unlink(const char *_Filename); |
| 218 | #ifndef NO_OLDNAMES |
Jonathan Yong | ff428b3 | 2009-10-16 12:19:21 +0000 | [diff] [blame] | 219 | int __cdecl unlink(const char *_Filename) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 220 | #endif |
| 221 | #endif |
| 222 | |
| 223 | _CRTIMP int __cdecl _setmode(int _FileHandle,int _Mode); |
| 224 | _CRTIMP long __cdecl _tell(int _FileHandle); |
Jonathan Yong | 116470f | 2009-12-03 08:43:40 +0000 | [diff] [blame] | 225 | _CRTIMP int __cdecl _umask(int _Mode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; |
David Wohlferd | 6172d2f | 2016-08-26 17:31:14 -0700 | [diff] [blame] | 226 | _SECIMP errno_t __cdecl _umask_s (int _NewMode,int *_OldMode); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 227 | _CRTIMP int __cdecl _write(int _FileHandle,const void *_Buf,unsigned int _MaxCharCount); |
| 228 | |
Kai Tietz | 12cda48 | 2009-09-06 12:02:08 +0000 | [diff] [blame] | 229 | __MINGW_EXTENSION _CRTIMP __int64 __cdecl _filelengthi64(int _FileHandle); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 230 | _CRTIMP intptr_t __cdecl _findfirst32i64(const char *_Filename,struct _finddata32i64_t *_FindData); |
| 231 | _CRTIMP intptr_t __cdecl _findfirst64(const char *_Filename,struct __finddata64_t *_FindData); |
| 232 | #ifdef __cplusplus |
| 233 | #include <string.h> |
| 234 | #endif |
Kai Tietz | e487611 | 2007-09-26 10:36:25 +0000 | [diff] [blame] | 235 | intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t *_FindData); |
Ozkan Sezer | 7a183a0 | 2009-07-27 06:04:37 +0000 | [diff] [blame] | 236 | #ifndef __CRT__NO_INLINE |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 237 | __CRT_INLINE intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t *_FindData) |
| 238 | { |
| 239 | struct __finddata64_t fd; |
| 240 | intptr_t ret = _findfirst64(_Filename,&fd); |
Ozkan Sezer | 45bf2cc | 2009-09-05 08:20:31 +0000 | [diff] [blame] | 241 | if (ret == -1) { |
| 242 | memset(_FindData,0,sizeof(struct _finddata64i32_t)); |
Ozkan Sezer | 54780dd | 2009-08-22 09:15:28 +0000 | [diff] [blame] | 243 | return -1; |
Ozkan Sezer | 45bf2cc | 2009-09-05 08:20:31 +0000 | [diff] [blame] | 244 | } |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 245 | _FindData->attrib=fd.attrib; |
| 246 | _FindData->time_create=fd.time_create; |
| 247 | _FindData->time_access=fd.time_access; |
| 248 | _FindData->time_write=fd.time_write; |
| 249 | _FindData->size=(_fsize_t) fd.size; |
| 250 | strncpy(_FindData->name,fd.name,260); |
| 251 | return ret; |
| 252 | } |
Ozkan Sezer | 7a183a0 | 2009-07-27 06:04:37 +0000 | [diff] [blame] | 253 | #endif /* __CRT__NO_INLINE */ |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 254 | _CRTIMP int __cdecl _findnext32i64(intptr_t _FindHandle,struct _finddata32i64_t *_FindData); |
| 255 | _CRTIMP int __cdecl _findnext64(intptr_t _FindHandle,struct __finddata64_t *_FindData); |
Kai Tietz | e487611 | 2007-09-26 10:36:25 +0000 | [diff] [blame] | 256 | int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindData); |
Ozkan Sezer | 7a183a0 | 2009-07-27 06:04:37 +0000 | [diff] [blame] | 257 | #ifndef __CRT__NO_INLINE |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 258 | __CRT_INLINE int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindData) |
| 259 | { |
| 260 | struct __finddata64_t fd; |
Martin Storsjö | d42a2cf | 2020-03-10 14:19:46 +0200 | [diff] [blame] | 261 | int __ret = _findnext64(_FindHandle,&fd); |
| 262 | if (__ret == -1) { |
Ozkan Sezer | 45bf2cc | 2009-09-05 08:20:31 +0000 | [diff] [blame] | 263 | memset(_FindData,0,sizeof(struct _finddata64i32_t)); |
Ozkan Sezer | 54780dd | 2009-08-22 09:15:28 +0000 | [diff] [blame] | 264 | return -1; |
Ozkan Sezer | 45bf2cc | 2009-09-05 08:20:31 +0000 | [diff] [blame] | 265 | } |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 266 | _FindData->attrib=fd.attrib; |
| 267 | _FindData->time_create=fd.time_create; |
| 268 | _FindData->time_access=fd.time_access; |
| 269 | _FindData->time_write=fd.time_write; |
| 270 | _FindData->size=(_fsize_t) fd.size; |
| 271 | strncpy(_FindData->name,fd.name,260); |
Martin Storsjö | d42a2cf | 2020-03-10 14:19:46 +0200 | [diff] [blame] | 272 | return __ret; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 273 | } |
Ozkan Sezer | 7a183a0 | 2009-07-27 06:04:37 +0000 | [diff] [blame] | 274 | #endif /* __CRT__NO_INLINE */ |
Kai Tietz | 12cda48 | 2009-09-06 12:02:08 +0000 | [diff] [blame] | 275 | __MINGW_EXTENSION __int64 __cdecl _lseeki64(int _FileHandle,__int64 _Offset,int _Origin); |
| 276 | __MINGW_EXTENSION __int64 __cdecl _telli64(int _FileHandle); |
Ozkan Sezer | 7a183a0 | 2009-07-27 06:04:37 +0000 | [diff] [blame] | 277 | |
Kai Tietz | 1bca2c5 | 2007-10-16 12:17:03 +0000 | [diff] [blame] | 278 | #ifndef NO_OLDNAMES |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 279 | #ifndef _UWIN |
Jonathan Yong | ff428b3 | 2009-10-16 12:19:21 +0000 | [diff] [blame] | 280 | int __cdecl chdir (const char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 281 | char *__cdecl getcwd (char *, int) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 282 | int __cdecl mkdir (const char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 283 | char *__cdecl mktemp(char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 284 | int __cdecl rmdir (const char*) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 285 | int __cdecl chmod (const char *, int) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 286 | #endif /* _UWIN */ |
Kai Tietz | 1bca2c5 | 2007-10-16 12:17:03 +0000 | [diff] [blame] | 287 | #endif /* Not NO_OLDNAMES */ |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 288 | |
David Wohlferd | 6172d2f | 2016-08-26 17:31:14 -0700 | [diff] [blame] | 289 | _SECIMP errno_t __cdecl _sopen_s(int *_FileHandle,const char *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionMode); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 290 | |
Jonathan Yong | 116470f | 2009-12-03 08:43:40 +0000 | [diff] [blame] | 291 | _CRTIMP int __cdecl _open(const char *_Filename,int _OpenFlag,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; |
| 292 | _CRTIMP int __cdecl _sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 293 | |
| 294 | #ifndef _WIO_DEFINED |
Kai Tietz | a5a95fc | 2007-10-16 11:43:57 +0000 | [diff] [blame] | 295 | #define _WIO_DEFINED |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 296 | _CRTIMP int __cdecl _waccess(const wchar_t *_Filename,int _AccessMode); |
David Wohlferd | 6172d2f | 2016-08-26 17:31:14 -0700 | [diff] [blame] | 297 | _SECIMP errno_t __cdecl _waccess_s (const wchar_t *_Filename,int _AccessMode); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 298 | _CRTIMP int __cdecl _wchmod(const wchar_t *_Filename,int _Mode); |
Jonathan Yong | 116470f | 2009-12-03 08:43:40 +0000 | [diff] [blame] | 299 | _CRTIMP int __cdecl _wcreat(const wchar_t *_Filename,int _PermissionMode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 300 | _CRTIMP intptr_t __cdecl _wfindfirst32(const wchar_t *_Filename,struct _wfinddata32_t *_FindData); |
| 301 | _CRTIMP int __cdecl _wfindnext32(intptr_t _FindHandle,struct _wfinddata32_t *_FindData); |
| 302 | _CRTIMP int __cdecl _wunlink(const wchar_t *_Filename); |
Kai Tietz | 1693b16 | 2011-11-23 10:31:21 +0000 | [diff] [blame] | 303 | _CRTIMP int __cdecl _wrename(const wchar_t *_OldFilename,const wchar_t *_NewFilename); |
Jonathan Yong | 116470f | 2009-12-03 08:43:40 +0000 | [diff] [blame] | 304 | _CRTIMP wchar_t *__cdecl _wmktemp(wchar_t *_TemplateName) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; |
David Wohlferd | 6172d2f | 2016-08-26 17:31:14 -0700 | [diff] [blame] | 305 | _SECIMP errno_t __cdecl _wmktemp_s (wchar_t *_TemplateName, size_t _SizeInWords); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 306 | |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 307 | _CRTIMP intptr_t __cdecl _wfindfirst32i64(const wchar_t *_Filename,struct _wfinddata32i64_t *_FindData); |
Kai Tietz | 0502984 | 2007-11-19 15:18:40 +0000 | [diff] [blame] | 308 | intptr_t __cdecl _wfindfirst64i32(const wchar_t *_Filename,struct _wfinddata64i32_t *_FindData); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 309 | _CRTIMP intptr_t __cdecl _wfindfirst64(const wchar_t *_Filename,struct _wfinddata64_t *_FindData); |
| 310 | _CRTIMP int __cdecl _wfindnext32i64(intptr_t _FindHandle,struct _wfinddata32i64_t *_FindData); |
Kai Tietz | 0502984 | 2007-11-19 15:18:40 +0000 | [diff] [blame] | 311 | int __cdecl _wfindnext64i32(intptr_t _FindHandle,struct _wfinddata64i32_t *_FindData); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 312 | _CRTIMP int __cdecl _wfindnext64(intptr_t _FindHandle,struct _wfinddata64_t *_FindData); |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 313 | |
| 314 | _CRTIMP errno_t __cdecl _wsopen_s(int *_FileHandle,const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionFlag); |
| 315 | |
Jonathan Yong | 116470f | 2009-12-03 08:43:40 +0000 | [diff] [blame] | 316 | _CRTIMP int __cdecl _wopen(const wchar_t *_Filename,int _OpenFlag,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; |
| 317 | _CRTIMP int __cdecl _wsopen(const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 318 | |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 319 | #endif |
| 320 | |
| 321 | int __cdecl __lock_fhandle(int _Filehandle); |
| 322 | void __cdecl _unlock_fhandle(int _Filehandle); |
| 323 | _CRTIMP intptr_t __cdecl _get_osfhandle(int _FileHandle); |
| 324 | _CRTIMP int __cdecl _open_osfhandle(intptr_t _OSFileHandle,int _Flags); |
| 325 | |
Jonathan Yong | 4d3b28a | 2011-02-19 15:34:22 +0000 | [diff] [blame] | 326 | #ifndef NO_OLDNAMES |
Jonathan Yong | ff428b3 | 2009-10-16 12:19:21 +0000 | [diff] [blame] | 327 | int __cdecl access(const char *_Filename,int _AccessMode) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 328 | int __cdecl chmod(const char *_Filename,int _AccessMode) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 329 | int __cdecl chsize(int _FileHandle,long _Size) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 330 | int __cdecl close(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 331 | int __cdecl creat(const char *_Filename,int _PermissionMode) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 332 | int __cdecl dup(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 333 | int __cdecl dup2(int _FileHandleSrc,int _FileHandleDst) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 334 | int __cdecl eof(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 335 | long __cdecl filelength(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 336 | int __cdecl isatty(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 337 | int __cdecl locking(int _FileHandle,int _LockMode,long _NumOfBytes) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 338 | long __cdecl lseek(int _FileHandle,long _Offset,int _Origin) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 339 | char *__cdecl mktemp(char *_TemplateName) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 340 | int __cdecl open(const char *_Filename,int _OpenFlag,...) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 341 | int __cdecl read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 342 | int __cdecl setmode(int _FileHandle,int _Mode) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 343 | int __cdecl sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 344 | long __cdecl tell(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 345 | int __cdecl umask(int _Mode) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
| 346 | int __cdecl write(int _Filehandle,const void *_Buf,unsigned int _MaxCharCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005; |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 347 | #endif |
Kai Tietz | 69bc954 | 2008-01-17 19:17:53 +0000 | [diff] [blame] | 348 | |
Jonathan Yong | 4d3b28a | 2011-02-19 15:34:22 +0000 | [diff] [blame] | 349 | #ifndef _FILE_OFFSET_BITS_SET_LSEEK |
| 350 | #define _FILE_OFFSET_BITS_SET_LSEEK |
| 351 | #if (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)) |
Jonathan Yong | 4d3b28a | 2011-02-19 15:34:22 +0000 | [diff] [blame] | 352 | #define lseek lseek64 |
| 353 | #endif /* (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)) */ |
| 354 | #endif /* _FILE_OFFSET_BITS_SET_LSEEK */ |
| 355 | |
Kai Tietz | 32233d6 | 2009-08-17 08:23:16 +0000 | [diff] [blame] | 356 | #ifdef _POSIX |
Kai Tietz | 69bc954 | 2008-01-17 19:17:53 +0000 | [diff] [blame] | 357 | |
| 358 | /* Misc stuff */ |
| 359 | char *getlogin(void); |
Kai Tietz | 3e7bcab | 2008-10-21 09:41:39 +0000 | [diff] [blame] | 360 | #ifdef __USE_MINGW_ALARM |
Kai Tietz | 69bc954 | 2008-01-17 19:17:53 +0000 | [diff] [blame] | 361 | unsigned int alarm(unsigned int seconds); |
Kai Tietz | 3e7bcab | 2008-10-21 09:41:39 +0000 | [diff] [blame] | 362 | #endif |
Kai Tietz | 4865741 | 2008-01-02 11:09:23 +0000 | [diff] [blame] | 363 | |
Kai Tietz | 32233d6 | 2009-08-17 08:23:16 +0000 | [diff] [blame] | 364 | #endif |
| 365 | |
Kai Tietz | 4865741 | 2008-01-02 11:09:23 +0000 | [diff] [blame] | 366 | #ifdef __USE_MINGW_ACCESS |
| 367 | /* Old versions of MSVCRT access() just ignored X_OK, while the version |
| 368 | shipped with Vista, returns an error code. This will restore the |
| 369 | old behaviour */ |
Mateusz | df15931 | 2019-01-07 18:50:31 +0100 | [diff] [blame] | 370 | int __cdecl __mingw_access (const char *__fname, int __mode); |
Kai Tietz | 4865741 | 2008-01-02 11:09:23 +0000 | [diff] [blame] | 371 | |
| 372 | #define access(__f,__m) __mingw_access (__f, __m) |
| 373 | #endif |
| 374 | |
Christian Franke | 802f866 | 2019-09-04 22:53:36 +0200 | [diff] [blame] | 375 | #if __MINGW_FORTIFY_LEVEL > 0 |
| 376 | |
| 377 | _CRTIMP int __cdecl __mingw_call__read(int, void *, unsigned int) __MINGW_ASM_CRT_CALL(_read); |
| 378 | |
| 379 | __mingw_bos_extern_ovr |
| 380 | int _read(int __fh, void * __dst, unsigned int __n) |
| 381 | { |
Christian Franke | 775df06 | 2019-10-09 21:57:50 +0200 | [diff] [blame] | 382 | __mingw_bos_ptr_chk_warn(__dst, __n, 0); |
Christian Franke | 802f866 | 2019-09-04 22:53:36 +0200 | [diff] [blame] | 383 | return __mingw_call__read(__fh, __dst, __n); |
| 384 | } |
| 385 | |
| 386 | #ifndef NO_OLDNAMES |
| 387 | __mingw_bos_extern_ovr |
| 388 | int read(int __fh, void * __dst, unsigned int __n) |
| 389 | { |
| 390 | return _read(__fh, __dst, __n); |
| 391 | } |
| 392 | #endif |
| 393 | |
Christian Franke | 0983b5e | 2019-09-29 15:45:50 +0200 | [diff] [blame] | 394 | #if __MINGW_FORTIFY_VA_ARG |
| 395 | |
| 396 | #define _O_CREAT 0x0100 |
| 397 | |
| 398 | _CRTIMP int __cdecl __mingw_call__open(const char *, int, ...) __MINGW_ASM_CRT_CALL(_open); |
| 399 | _CRTIMP int __cdecl __mingw_call__open_warn_toomany(const char *, int, ...) __MINGW_ASM_CRT_CALL(_open) |
| 400 | __attribute__((__warning__("_open(): too many arguments"))); |
| 401 | _CRTIMP int __cdecl __mingw_call__open_warn_missing(const char *, int, ...) __MINGW_ASM_CRT_CALL(_open) |
| 402 | __attribute__((__warning__("_open(..._O_CREAT...): missing argument"))); |
| 403 | |
| 404 | __mingw_bos_extern_ovr |
| 405 | int _open(const char * __filename, int __flags, ...) |
| 406 | { |
| 407 | if (__builtin_va_arg_pack_len() > 1) |
| 408 | return __mingw_call__open_warn_toomany(__filename, __flags, __builtin_va_arg_pack()); |
| 409 | if (__builtin_va_arg_pack_len() < 1 && __builtin_constant_p(__flags) && (__flags & _O_CREAT)) |
| 410 | return __mingw_call__open_warn_missing(__filename, __flags, 0); |
| 411 | if (__builtin_va_arg_pack_len() < 1) |
| 412 | return __mingw_call__open(__filename, __flags, 0); |
| 413 | return __mingw_call__open(__filename, __flags, __builtin_va_arg_pack()); |
| 414 | } |
| 415 | |
| 416 | _CRTIMP int __cdecl __mingw_call__sopen(const char *, int, int, ...) __MINGW_ASM_CRT_CALL(_sopen); |
| 417 | _CRTIMP int __cdecl __mingw_call__sopen_warn_toomany(const char *, int, int, ...) __MINGW_ASM_CRT_CALL(_sopen) |
| 418 | __attribute__((__warning__("_sopen(): too many arguments"))); |
| 419 | _CRTIMP int __cdecl __mingw_call__sopen_warn_missing(const char *, int, int, ...) __MINGW_ASM_CRT_CALL(_sopen) |
| 420 | __attribute__((__warning__("_sopen(..._O_CREAT...): missing argument"))); |
| 421 | |
| 422 | __mingw_bos_extern_ovr |
| 423 | int _sopen(const char * __filename, int __flags, int __share, ...) |
| 424 | { |
| 425 | if (__builtin_va_arg_pack_len() > 1) |
| 426 | return __mingw_call__sopen_warn_toomany(__filename, __flags, __share, __builtin_va_arg_pack()); |
| 427 | if (__builtin_va_arg_pack_len() < 1 && __builtin_constant_p(__flags) && (__flags & _O_CREAT)) |
| 428 | return __mingw_call__sopen_warn_missing(__filename, __flags, __share, 0); |
| 429 | if (__builtin_va_arg_pack_len() < 1) |
| 430 | return __mingw_call__sopen(__filename, __flags, __share, 0); |
| 431 | return __mingw_call__sopen(__filename, __flags, __share, __builtin_va_arg_pack()); |
| 432 | } |
| 433 | |
| 434 | _CRTIMP int __cdecl __mingw_call__wopen(const wchar_t *, int, ...) __MINGW_ASM_CRT_CALL(_wopen); |
| 435 | _CRTIMP int __cdecl __mingw_call__wopen_warn_toomany(const wchar_t *, int, ...) __MINGW_ASM_CRT_CALL(_wopen) |
| 436 | __attribute__((__warning__("_wopen(): too many arguments"))); |
| 437 | _CRTIMP int __cdecl __mingw_call__wopen_warn_missing(const wchar_t *, int, ...) __MINGW_ASM_CRT_CALL(_wopen) |
| 438 | __attribute__((__warning__("_wopen(..._O_CREAT...): missing argument"))); |
| 439 | |
| 440 | __mingw_bos_extern_ovr |
| 441 | int _wopen(const wchar_t * __filename, int __flags, ...) |
| 442 | { |
| 443 | if (__builtin_va_arg_pack_len() > 1) |
| 444 | return __mingw_call__wopen_warn_toomany(__filename, __flags, __builtin_va_arg_pack()); |
| 445 | if (__builtin_va_arg_pack_len() < 1 && __builtin_constant_p(__flags) && (__flags & _O_CREAT)) |
| 446 | return __mingw_call__wopen_warn_missing(__filename, __flags, 0); |
| 447 | if (__builtin_va_arg_pack_len() < 1) |
| 448 | return __mingw_call__wopen(__filename, __flags, 0); |
| 449 | return __mingw_call__wopen(__filename, __flags, __builtin_va_arg_pack()); |
| 450 | } |
| 451 | |
| 452 | _CRTIMP int __cdecl __mingw_call__wsopen(const wchar_t *, int, int, ...) __MINGW_ASM_CRT_CALL(_wsopen); |
| 453 | _CRTIMP int __cdecl __mingw_call__wsopen_warn_toomany(const wchar_t *, int, int, ...) __MINGW_ASM_CRT_CALL(_wsopen) |
| 454 | __attribute__((__warning__("_wsopen(): too many arguments"))); |
| 455 | _CRTIMP int __cdecl __mingw_call__wsopen_warn_missing(const wchar_t *, int, int, ...) __MINGW_ASM_CRT_CALL(_wsopen) |
| 456 | __attribute__((__warning__("_wsopen(..._O_CREAT...): missing argument"))); |
| 457 | |
| 458 | __mingw_bos_extern_ovr |
| 459 | int _wsopen(const wchar_t * __filename, int __flags, int __share, ...) |
| 460 | { |
| 461 | if (__builtin_va_arg_pack_len() > 1) |
| 462 | return __mingw_call__wsopen_warn_toomany(__filename, __flags, __share, __builtin_va_arg_pack()); |
| 463 | if (__builtin_va_arg_pack_len() < 1 && __builtin_constant_p(__flags) && (__flags & _O_CREAT)) |
| 464 | return __mingw_call__wsopen_warn_missing(__filename, __flags, __share, 0); |
| 465 | if (__builtin_va_arg_pack_len() < 1) |
| 466 | return __mingw_call__wsopen(__filename, __flags, __share, 0); |
| 467 | return __mingw_call__wsopen(__filename, __flags, __share, __builtin_va_arg_pack()); |
| 468 | } |
| 469 | |
| 470 | #ifndef NO_OLDNAMES |
| 471 | __mingw_bos_extern_ovr |
| 472 | int open(const char * __filename, int __flags, ...) |
| 473 | { |
| 474 | return _open(__filename, __flags, __builtin_va_arg_pack()); |
| 475 | } |
| 476 | |
| 477 | __mingw_bos_extern_ovr |
| 478 | int sopen(const char * __filename, int __flags, int __share, ...) |
| 479 | { |
| 480 | return _sopen(__filename, __flags, __share, __builtin_va_arg_pack()); |
| 481 | } |
| 482 | #endif |
| 483 | |
| 484 | #endif /* __MINGW_FORTIFY_VA_ARG */ |
Christian Franke | 802f866 | 2019-09-04 22:53:36 +0200 | [diff] [blame] | 485 | #endif /* __MINGW_FORTIFY_LEVEL > 0 */ |
Kai Tietz | 69bc954 | 2008-01-17 19:17:53 +0000 | [diff] [blame] | 486 | |
| 487 | #ifdef __cplusplus |
| 488 | } |
| 489 | #endif |
| 490 | |
| 491 | |
Kai Tietz | edaa25e | 2007-08-23 09:28:16 +0000 | [diff] [blame] | 492 | #pragma pack(pop) |
Kai Tietz | a5a95fc | 2007-10-16 11:43:57 +0000 | [diff] [blame] | 493 | |
NightStrike | f273f68 | 2008-01-23 18:11:39 +0000 | [diff] [blame] | 494 | #endif /* End _IO_H_ */ |
| 495 | |