Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

399 lines
14 KiB

  1. /***
  2. *io.h - declarations for low-level file handling and I/O functions
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file contains the function declarations for the low-level
  8. * file handling and I/O functions.
  9. *
  10. * [Public]
  11. *
  12. *Revision History:
  13. * 10/20/87 JCR Removed "MSC40_ONLY" entries
  14. * 11/09/87 JCR Multi-thread support
  15. * 12-11-87 JCR Added "_loadds" functionality
  16. * 12-17-87 JCR Added _MTHREAD_ONLY comments
  17. * 12-18-87 JCR Added _FAR_ to declarations
  18. * 02-10-88 JCR Cleaned up white space
  19. * 08-19-88 GJF Modified to also work for the 386 (small model only)
  20. * 05-03-89 JCR Added _INTERNAL_IFSTRIP for relinc usage
  21. * 08-03-89 GJF Cleanup, now specific to OS/2 2.0 (i.e., 386 flat model)
  22. * 08-14-89 GJF Added prototype for _pipe()
  23. * 10-30-89 GJF Fixed copyright
  24. * 11-02-89 JCR Changed "DLL" to "_DLL"
  25. * 11-17-89 GJF read() should take "void *" not "char *", write()
  26. * should take "const void *" not "char *". Also,
  27. * added const to appropriate arg types for access(),
  28. * chmod(), creat(), open() and sopen()
  29. * 03-01-90 GJF Added #ifndef _INC_IO and #include <cruntime.h>
  30. * stuff. Also, removed some (now) useless preprocessor
  31. * directives.
  32. * 03-21-90 GJF Replaced _cdecl with _CALLTYPE1 or _CALLTYPE2 in
  33. * prototypes.
  34. * 05-28-90 SBM Added _commit()
  35. * 01-18-91 GJF ANSI naming.
  36. * 02-25-91 SRW Exposed _get_osfhandle and _open_osfhandle [_WIN32_]
  37. * 08-01-91 GJF No _pipe for Dosx32.
  38. * 08-20-91 JCR C++ and ANSI naming
  39. * 08-26-91 BWM Added _findfirst, etc.
  40. * 09-16-91 BWM Changed find handle type to long.
  41. * 09-28-91 JCR ANSI names: DOSX32=prototypes, WIN32=#defines for now
  42. * 03-30-92 DJM POSIX support.
  43. * 06-23-92 GJF // is non-ANSI comment delimiter.
  44. * 08-06-92 GJF Function calling type and variable type macros.
  45. * 08-25-92 GJF For POSIX build, #ifdef-ed out all but some internally
  46. * used macros (and these are stripped out on release).
  47. * 09-03-92 GJF Merge two changes above.
  48. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  49. * 03-29-93 JWM Increased name buffer in finddata structure to 260 bytes.
  50. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  51. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  52. * Use link-time aliases for old names, not #define's
  53. * 05-17-93 SKS #if for old names no longer checks for _cplusplus.
  54. * It used to do so past because #define-ing names like
  55. * open, read, write, etc. created problems for users
  56. * 09-01-93 GJF Merged NT SDK and Cuda versions.
  57. * 12-07-93 CFW Add wide char version protos.
  58. * 11-03-94 GJF Ensure 8 byte alignment.
  59. * 11-18-94 GJF Added prototypes for _lseeki64, _filelengthi64 and
  60. * _telli64.
  61. * 12-07-94 SKS Add comment for ifstrip utility (src release process)
  62. * 12-15-94 XY merged with mac header
  63. * 12-29-94 GJF Added _[w]findfilei64 and _[w]findnexti64. Also removed
  64. * obsolete _CALLTYPE* macro.
  65. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  66. * 02-14-95 CFW Clean up Mac merge.
  67. * 02-24-95 SKS Replace _MTHREAD_ONLY comments (stripped by source
  68. * cleansing) with #ifdef _NOT_CRTL_BUILD_
  69. * 10-06-95 SKS Add "const" to "char *" in prototypes for *findfirst().
  70. * 12-14-95 JWM Add "#pragma once".
  71. * 02-20-97 GJF Cleaned out obsolete support for _CRTAPI* and _NTSDK.
  72. * Also, detab-ed.
  73. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  74. * 10-07-97 RDL Added IA64.
  75. * 02-10-98 GJF Changes for Win64: made time_t __int64, and changed
  76. * arg and return types to intptr_t where appropriate
  77. * 05-04-98 GJF Added __time64_t support.
  78. * 05-13-99 PML Remove _CRTAPI1
  79. * 05-17-99 PML Remove all Macintosh support.
  80. * 10-06-99 PML Add _W64 modifier to types which are 32 bits in Win32,
  81. * 64 bits in Win64.
  82. * 11-12-99 PML Wrap __time64_t in its own #ifndef.
  83. *
  84. ****/
  85. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  86. #pragma once
  87. #endif
  88. #ifndef _INC_IO
  89. #define _INC_IO
  90. #if !defined(_WIN32)
  91. #error ERROR: Only Win32 target supported!
  92. #endif
  93. #ifndef _CRTBLD
  94. /* This version of the header files is NOT for user programs.
  95. * It is intended for use when building the C runtimes ONLY.
  96. * The version intended for public use will not have this message.
  97. */
  98. #error ERROR: Use of C runtime library internal header file.
  99. #endif /* _CRTBLD */
  100. #ifdef _MSC_VER
  101. /*
  102. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  103. * alignment.
  104. */
  105. #pragma pack(push,8)
  106. #endif /* _MSC_VER */
  107. #ifndef _POSIX_
  108. #ifdef __cplusplus
  109. extern "C" {
  110. #endif
  111. #ifndef _INTERNAL_IFSTRIP_
  112. #include <cruntime.h>
  113. #endif /* _INTERNAL_IFSTRIP_ */
  114. #if !defined(_W64)
  115. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  116. #define _W64 __w64
  117. #else
  118. #define _W64
  119. #endif
  120. #endif
  121. /* Define _CRTIMP */
  122. #ifndef _CRTIMP
  123. #ifdef CRTDLL
  124. #define _CRTIMP __declspec(dllexport)
  125. #else /* ndef CRTDLL */
  126. #ifdef _DLL
  127. #define _CRTIMP __declspec(dllimport)
  128. #else /* ndef _DLL */
  129. #define _CRTIMP
  130. #endif /* _DLL */
  131. #endif /* CRTDLL */
  132. #endif /* _CRTIMP */
  133. /* Define __cdecl for non-Microsoft compilers */
  134. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  135. #define __cdecl
  136. #endif
  137. #ifndef _INTPTR_T_DEFINED
  138. #ifdef _WIN64
  139. typedef __int64 intptr_t;
  140. #else
  141. typedef _W64 int intptr_t;
  142. #endif
  143. #define _INTPTR_T_DEFINED
  144. #endif
  145. #ifndef _WCHAR_T_DEFINED
  146. typedef unsigned short wchar_t;
  147. #define _WCHAR_T_DEFINED
  148. #endif
  149. #ifndef _TIME_T_DEFINED
  150. #ifdef _WIN64
  151. typedef __int64 time_t; /* time value */
  152. #else
  153. typedef _W64 long time_t; /* time value */
  154. #endif
  155. #define _TIME_T_DEFINED /* avoid multiple def's of time_t */
  156. #endif
  157. #ifndef _TIME64_T_DEFINED
  158. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  159. typedef __int64 __time64_t; /* 64-bit time value */
  160. #endif
  161. #define _TIME64_T_DEFINED
  162. #endif
  163. #ifndef _FSIZE_T_DEFINED
  164. typedef unsigned long _fsize_t; /* Could be 64 bits for Win32 */
  165. #define _FSIZE_T_DEFINED
  166. #endif
  167. #ifndef _FINDDATA_T_DEFINED
  168. struct _finddata_t {
  169. unsigned attrib;
  170. time_t time_create; /* -1 for FAT file systems */
  171. time_t time_access; /* -1 for FAT file systems */
  172. time_t time_write;
  173. _fsize_t size;
  174. char name[260];
  175. };
  176. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  177. struct _finddatai64_t {
  178. unsigned attrib;
  179. time_t time_create; /* -1 for FAT file systems */
  180. time_t time_access; /* -1 for FAT file systems */
  181. time_t time_write;
  182. __int64 size;
  183. char name[260];
  184. };
  185. struct __finddata64_t {
  186. unsigned attrib;
  187. __time64_t time_create; /* -1 for FAT file systems */
  188. __time64_t time_access; /* -1 for FAT file systems */
  189. __time64_t time_write;
  190. __int64 size;
  191. char name[260];
  192. };
  193. #endif
  194. #define _FINDDATA_T_DEFINED
  195. #endif
  196. #ifndef _WFINDDATA_T_DEFINED
  197. struct _wfinddata_t {
  198. unsigned attrib;
  199. time_t time_create; /* -1 for FAT file systems */
  200. time_t time_access; /* -1 for FAT file systems */
  201. time_t time_write;
  202. _fsize_t size;
  203. wchar_t name[260];
  204. };
  205. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  206. struct _wfinddatai64_t {
  207. unsigned attrib;
  208. time_t time_create; /* -1 for FAT file systems */
  209. time_t time_access; /* -1 for FAT file systems */
  210. time_t time_write;
  211. __int64 size;
  212. wchar_t name[260];
  213. };
  214. struct __wfinddata64_t {
  215. unsigned attrib;
  216. __time64_t time_create; /* -1 for FAT file systems */
  217. __time64_t time_access; /* -1 for FAT file systems */
  218. __time64_t time_write;
  219. __int64 size;
  220. wchar_t name[260];
  221. };
  222. #endif
  223. #define _WFINDDATA_T_DEFINED
  224. #endif
  225. /* File attribute constants for _findfirst() */
  226. #define _A_NORMAL 0x00 /* Normal file - No read/write restrictions */
  227. #define _A_RDONLY 0x01 /* Read only file */
  228. #define _A_HIDDEN 0x02 /* Hidden file */
  229. #define _A_SYSTEM 0x04 /* System file */
  230. #define _A_SUBDIR 0x10 /* Subdirectory */
  231. #define _A_ARCH 0x20 /* Archive file */
  232. /* function prototypes */
  233. _CRTIMP int __cdecl _access(const char *, int);
  234. _CRTIMP int __cdecl _chmod(const char *, int);
  235. _CRTIMP int __cdecl _chsize(int, long);
  236. _CRTIMP int __cdecl _close(int);
  237. _CRTIMP int __cdecl _commit(int);
  238. _CRTIMP int __cdecl _creat(const char *, int);
  239. _CRTIMP int __cdecl _dup(int);
  240. _CRTIMP int __cdecl _dup2(int, int);
  241. _CRTIMP int __cdecl _eof(int);
  242. _CRTIMP long __cdecl _filelength(int);
  243. _CRTIMP intptr_t __cdecl _findfirst(const char *, struct _finddata_t *);
  244. _CRTIMP int __cdecl _findnext(intptr_t, struct _finddata_t *);
  245. _CRTIMP int __cdecl _findclose(intptr_t);
  246. _CRTIMP int __cdecl _isatty(int);
  247. _CRTIMP int __cdecl _locking(int, int, long);
  248. _CRTIMP long __cdecl _lseek(int, long, int);
  249. _CRTIMP char * __cdecl _mktemp(char *);
  250. _CRTIMP int __cdecl _open(const char *, int, ...);
  251. _CRTIMP int __cdecl _pipe(int *, unsigned int, int);
  252. _CRTIMP int __cdecl _read(int, void *, unsigned int);
  253. _CRTIMP int __cdecl remove(const char *);
  254. _CRTIMP int __cdecl rename(const char *, const char *);
  255. _CRTIMP int __cdecl _setmode(int, int);
  256. _CRTIMP int __cdecl _sopen(const char *, int, int, ...);
  257. _CRTIMP long __cdecl _tell(int);
  258. _CRTIMP int __cdecl _umask(int);
  259. _CRTIMP int __cdecl _unlink(const char *);
  260. _CRTIMP int __cdecl _write(int, const void *, unsigned int);
  261. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  262. _CRTIMP __int64 __cdecl _filelengthi64(int);
  263. _CRTIMP intptr_t __cdecl _findfirsti64(const char *, struct _finddatai64_t *);
  264. _CRTIMP intptr_t __cdecl _findfirst64(const char *, struct __finddata64_t *);
  265. _CRTIMP int __cdecl _findnexti64(intptr_t, struct _finddatai64_t *);
  266. _CRTIMP int __cdecl _findnext64(intptr_t, struct __finddata64_t *);
  267. _CRTIMP __int64 __cdecl _lseeki64(int, __int64, int);
  268. _CRTIMP __int64 __cdecl _telli64(int);
  269. #endif
  270. #ifndef _WIO_DEFINED
  271. /* wide function prototypes, also declared in wchar.h */
  272. _CRTIMP int __cdecl _waccess(const wchar_t *, int);
  273. _CRTIMP int __cdecl _wchmod(const wchar_t *, int);
  274. _CRTIMP int __cdecl _wcreat(const wchar_t *, int);
  275. _CRTIMP intptr_t __cdecl _wfindfirst(const wchar_t *, struct _wfinddata_t *);
  276. _CRTIMP int __cdecl _wfindnext(intptr_t, struct _wfinddata_t *);
  277. _CRTIMP int __cdecl _wunlink(const wchar_t *);
  278. _CRTIMP int __cdecl _wrename(const wchar_t *, const wchar_t *);
  279. _CRTIMP int __cdecl _wopen(const wchar_t *, int, ...);
  280. _CRTIMP int __cdecl _wsopen(const wchar_t *, int, int, ...);
  281. _CRTIMP wchar_t * __cdecl _wmktemp(wchar_t *);
  282. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  283. _CRTIMP intptr_t __cdecl _wfindfirsti64(const wchar_t *, struct _wfinddatai64_t *);
  284. _CRTIMP int __cdecl _wfindnexti64(intptr_t, struct _wfinddatai64_t *);
  285. _CRTIMP intptr_t __cdecl _wfindfirst64(const wchar_t *, struct __wfinddata64_t *);
  286. _CRTIMP int __cdecl _wfindnext64(intptr_t, struct __wfinddata64_t *);
  287. #endif
  288. #define _WIO_DEFINED
  289. #endif
  290. #ifndef _NOT_CRTL_BUILD_
  291. #ifdef _MT
  292. int __cdecl _chsize_lk(int,long);
  293. int __cdecl _close_lk(int);
  294. long __cdecl _lseek_lk(int, long, int);
  295. int __cdecl _setmode_lk(int, int);
  296. int __cdecl _read_lk(int, void *, unsigned int);
  297. int __cdecl _write_lk(int, const void *, unsigned int);
  298. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  299. __int64 __cdecl _lseeki64_lk(int, __int64, int);
  300. #endif
  301. #else /* not _MT */
  302. #define _chsize_lk(fh,size) _chsize(fh,size)
  303. #define _close_lk(fh) _close(fh)
  304. #define _lseek_lk(fh,offset,origin) _lseek(fh,offset,origin)
  305. #define _setmode_lk(fh,mode) _setmode(fh,mode)
  306. #define _read_lk(fh,buff,count) _read(fh,buff,count)
  307. #define _write_lk(fh,buff,count) _write(fh,buff,count)
  308. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  309. #define _lseeki64_lk(fh,offset,origin) _lseeki64(fh,offset,origin)
  310. #endif
  311. #endif /* _MT */
  312. #endif /* _NOT_CRTL_BUILD_ */
  313. _CRTIMP intptr_t __cdecl _get_osfhandle(int);
  314. _CRTIMP int __cdecl _open_osfhandle(intptr_t, int);
  315. #if !__STDC__
  316. /* Non-ANSI names for compatibility */
  317. _CRTIMP int __cdecl access(const char *, int);
  318. _CRTIMP int __cdecl chmod(const char *, int);
  319. _CRTIMP int __cdecl chsize(int, long);
  320. _CRTIMP int __cdecl close(int);
  321. _CRTIMP int __cdecl creat(const char *, int);
  322. _CRTIMP int __cdecl dup(int);
  323. _CRTIMP int __cdecl dup2(int, int);
  324. _CRTIMP int __cdecl eof(int);
  325. _CRTIMP long __cdecl filelength(int);
  326. _CRTIMP int __cdecl isatty(int);
  327. _CRTIMP int __cdecl locking(int, int, long);
  328. _CRTIMP long __cdecl lseek(int, long, int);
  329. _CRTIMP char * __cdecl mktemp(char *);
  330. _CRTIMP int __cdecl open(const char *, int, ...);
  331. _CRTIMP int __cdecl read(int, void *, unsigned int);
  332. _CRTIMP int __cdecl setmode(int, int);
  333. _CRTIMP int __cdecl sopen(const char *, int, int, ...);
  334. _CRTIMP long __cdecl tell(int);
  335. _CRTIMP int __cdecl umask(int);
  336. _CRTIMP int __cdecl unlink(const char *);
  337. _CRTIMP int __cdecl write(int, const void *, unsigned int);
  338. #endif /* __STDC__ */
  339. #ifdef __cplusplus
  340. }
  341. #endif
  342. #endif /* _POSIX_ */
  343. #ifdef _MSC_VER
  344. #pragma pack(pop)
  345. #endif /* _MSC_VER */
  346. #endif /* _INC_IO */