io.h 13 KB

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