home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / io.h < prev    next >
C/C++ Source or Header  |  1998-06-17  |  9KB  |  295 lines

  1. /***
  2. *io.h - declarations for low-level file handling and I/O functions
  3. *
  4. *       Copyright (c) 1985-1997, 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. ****/
  13.  
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif  /* _MSC_VER > 1000 */
  17.  
  18. #ifndef _INC_IO
  19. #define _INC_IO
  20.  
  21. #if !defined (_WIN32) && !defined (_MAC)
  22. #error ERROR: Only Mac or Win32 targets supported!
  23. #endif  /* !defined (_WIN32) && !defined (_MAC) */
  24.  
  25. #ifndef _CRTBLD
  26. /* This version of the header files is NOT for user programs.
  27.  * It is intended for use when building the C runtimes ONLY.
  28.  * The version intended for public use will not have this message.
  29.  */
  30. #error ERROR: Use of C runtime library internal header file.
  31. #endif  /* _CRTBLD */
  32.  
  33. #ifdef _MSC_VER
  34. /*
  35.  * Currently, all MS C compilers for Win32 platforms default to 8 byte
  36.  * alignment.
  37.  */
  38. #pragma pack(push,8)
  39. #endif  /* _MSC_VER */
  40.  
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif  /* __cplusplus */
  45.  
  46. #ifndef _INTERNAL_IFSTRIP_
  47. #include <cruntime.h>
  48. #endif  /* _INTERNAL_IFSTRIP_ */
  49.  
  50.  
  51. /* Define _CRTIMP */
  52.  
  53. #ifndef _CRTIMP
  54. #ifdef CRTDLL
  55. #define _CRTIMP __declspec(dllexport)
  56. #else  /* CRTDLL */
  57. #ifdef _DLL
  58. #define _CRTIMP __declspec(dllimport)
  59. #else  /* _DLL */
  60. #define _CRTIMP
  61. #endif  /* _DLL */
  62. #endif  /* CRTDLL */
  63. #endif  /* _CRTIMP */
  64.  
  65.  
  66. /* Define __cdecl for non-Microsoft compilers */
  67.  
  68. #if (!defined (_MSC_VER) && !defined (__cdecl))
  69. #define __cdecl
  70. #endif  /* (!defined (_MSC_VER) && !defined (__cdecl)) */
  71.  
  72. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  73.  
  74. #ifndef _CRTAPI1
  75. #if _MSC_VER >= 800 && _M_IX86 >= 300
  76. #define _CRTAPI1 __cdecl
  77. #else  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  78. #define _CRTAPI1
  79. #endif  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  80. #endif  /* _CRTAPI1 */
  81.  
  82. #ifndef _MAC
  83. #ifndef _WCHAR_T_DEFINED
  84. typedef unsigned short wchar_t;
  85. #define _WCHAR_T_DEFINED
  86. #endif  /* _WCHAR_T_DEFINED */
  87. #endif  /* _MAC */
  88.  
  89. #ifndef _TIME_T_DEFINED
  90. typedef long time_t;            /* time value */
  91. #define _TIME_T_DEFINED         /* avoid multiple def's of time_t */
  92. #endif  /* _TIME_T_DEFINED */
  93.  
  94. #ifndef _FSIZE_T_DEFINED
  95. typedef unsigned long _fsize_t; /* Could be 64 bits for Win32 */
  96. #define _FSIZE_T_DEFINED
  97. #endif  /* _FSIZE_T_DEFINED */
  98.  
  99. #ifndef _MAC
  100.  
  101. #ifndef _FINDDATA_T_DEFINED
  102.  
  103. struct _finddata_t {
  104.     unsigned    attrib;
  105.     time_t      time_create;    /* -1 for FAT file systems */
  106.     time_t      time_access;    /* -1 for FAT file systems */
  107.     time_t      time_write;
  108.     _fsize_t    size;
  109.     char        name[260];
  110. };
  111.  
  112. #if _INTEGRAL_MAX_BITS >= 64   
  113. struct _finddatai64_t {
  114.     unsigned    attrib;
  115.     time_t      time_create;    /* -1 for FAT file systems */
  116.     time_t      time_access;    /* -1 for FAT file systems */
  117.     time_t      time_write;
  118.     __int64     size;
  119.     char        name[260];
  120. };
  121. #endif  /* _INTEGRAL_MAX_BITS >= 64    */
  122.  
  123. #define _FINDDATA_T_DEFINED
  124. #endif  /* _FINDDATA_T_DEFINED */
  125.  
  126. #ifndef _WFINDDATA_T_DEFINED
  127.  
  128. struct _wfinddata_t {
  129.     unsigned    attrib;
  130.     time_t      time_create;    /* -1 for FAT file systems */
  131.     time_t      time_access;    /* -1 for FAT file systems */
  132.     time_t      time_write;
  133.     _fsize_t    size;
  134.     wchar_t     name[260];
  135. };
  136.  
  137. #if _INTEGRAL_MAX_BITS >= 64   
  138. struct _wfinddatai64_t {
  139.     unsigned    attrib;
  140.     time_t      time_create;    /* -1 for FAT file systems */
  141.     time_t      time_access;    /* -1 for FAT file systems */
  142.     time_t      time_write;
  143.     __int64     size;
  144.     wchar_t     name[260];
  145. };
  146. #endif  /* _INTEGRAL_MAX_BITS >= 64    */
  147.  
  148. #define _WFINDDATA_T_DEFINED
  149. #endif  /* _WFINDDATA_T_DEFINED */
  150.  
  151. /* File attribute constants for _findfirst() */
  152.  
  153. #define _A_NORMAL       0x00    /* Normal file - No read/write restrictions */
  154. #define _A_RDONLY       0x01    /* Read only file */
  155. #define _A_HIDDEN       0x02    /* Hidden file */
  156. #define _A_SYSTEM       0x04    /* System file */
  157. #define _A_SUBDIR       0x10    /* Subdirectory */
  158. #define _A_ARCH         0x20    /* Archive file */
  159.  
  160. #endif  /* _MAC */
  161.  
  162. /* function prototypes */
  163.  
  164. _CRTIMP int __cdecl _access(const char *, int);
  165. _CRTIMP int __cdecl _chmod(const char *, int);
  166. _CRTIMP int __cdecl _chsize(int, long);
  167. _CRTIMP int __cdecl _close(int);
  168. _CRTIMP int __cdecl _commit(int);
  169. _CRTIMP int __cdecl _creat(const char *, int);
  170. _CRTIMP int __cdecl _dup(int);
  171. _CRTIMP int __cdecl _dup2(int, int);
  172. _CRTIMP int __cdecl _eof(int);
  173. _CRTIMP long __cdecl _filelength(int);
  174. #ifndef _MAC
  175. _CRTIMP long __cdecl _findfirst(const char *, struct _finddata_t *);
  176. _CRTIMP int __cdecl _findnext(long, struct _finddata_t *);
  177. _CRTIMP int __cdecl _findclose(long);
  178. #endif  /* _MAC */
  179. _CRTIMP int __cdecl _isatty(int);
  180. _CRTIMP int __cdecl _locking(int, int, long);
  181. _CRTIMP long __cdecl _lseek(int, long, int);
  182. _CRTIMP char * __cdecl _mktemp(char *);
  183. _CRTIMP int __cdecl _open(const char *, int, ...);
  184. #ifndef _MAC
  185. _CRTIMP int __cdecl _pipe(int *, unsigned int, int);
  186. #endif  /* _MAC */
  187. _CRTIMP int __cdecl _read(int, void *, unsigned int);
  188. _CRTIMP int __cdecl remove(const char *);
  189. _CRTIMP int __cdecl rename(const char *, const char *);
  190. _CRTIMP int __cdecl _setmode(int, int);
  191. _CRTIMP int __cdecl _sopen(const char *, int, int, ...);
  192. _CRTIMP long __cdecl _tell(int);
  193. _CRTIMP int __cdecl _umask(int);
  194. _CRTIMP int __cdecl _unlink(const char *);
  195. _CRTIMP int __cdecl _write(int, const void *, unsigned int);
  196.  
  197. #if _INTEGRAL_MAX_BITS >= 64   
  198. _CRTIMP __int64 __cdecl _filelengthi64(int);
  199. _CRTIMP long __cdecl _findfirsti64(const char *, struct _finddatai64_t *);
  200. _CRTIMP int __cdecl _findnexti64(long, struct _finddatai64_t *);
  201. _CRTIMP __int64 __cdecl _lseeki64(int, __int64, int);
  202. _CRTIMP __int64 __cdecl _telli64(int);
  203. #endif  /* _INTEGRAL_MAX_BITS >= 64    */
  204.  
  205. #ifndef _MAC
  206. #ifndef _WIO_DEFINED
  207.  
  208. /* wide function prototypes, also declared in wchar.h  */
  209.  
  210. _CRTIMP int __cdecl _waccess(const wchar_t *, int);
  211. _CRTIMP int __cdecl _wchmod(const wchar_t *, int);
  212. _CRTIMP int __cdecl _wcreat(const wchar_t *, int);
  213. _CRTIMP long __cdecl _wfindfirst(const wchar_t *, struct _wfinddata_t *);
  214. _CRTIMP int __cdecl _wfindnext(long, struct _wfinddata_t *);
  215. _CRTIMP int __cdecl _wunlink(const wchar_t *);
  216. _CRTIMP int __cdecl _wrename(const wchar_t *, const wchar_t *);
  217. _CRTIMP int __cdecl _wopen(const wchar_t *, int, ...);
  218. _CRTIMP int __cdecl _wsopen(const wchar_t *, int, int, ...);
  219. _CRTIMP wchar_t * __cdecl _wmktemp(wchar_t *);
  220.  
  221. #if _INTEGRAL_MAX_BITS >= 64
  222. _CRTIMP long __cdecl _wfindfirsti64(const wchar_t *, struct _wfinddatai64_t *);
  223. _CRTIMP int __cdecl _wfindnexti64(long, struct _wfinddatai64_t *);
  224. #endif  /* _INTEGRAL_MAX_BITS >= 64 */
  225.  
  226. #define _WIO_DEFINED
  227. #endif  /* _WIO_DEFINED */
  228. #endif  /* _MAC */
  229.  
  230. #ifndef _NOT_CRTL_BUILD_
  231. #ifdef _MT
  232. int __cdecl _chsize_lk(int,long);
  233. int __cdecl _close_lk(int);
  234. long __cdecl _lseek_lk(int, long, int);
  235. int __cdecl _setmode_lk(int, int);
  236. int __cdecl _read_lk(int, void *, unsigned int);
  237. int __cdecl _write_lk(int, const void *, unsigned int);
  238. #if _INTEGRAL_MAX_BITS >= 64
  239. __int64 __cdecl _lseeki64_lk(int, __int64, int);
  240. #endif  /* _INTEGRAL_MAX_BITS >= 64 */
  241. #else  /* _MT */
  242. #define _chsize_lk(fh,size)             _chsize(fh,size)
  243. #define _close_lk(fh)                   _close(fh)
  244. #define _lseek_lk(fh,offset,origin)     _lseek(fh,offset,origin)
  245. #define _setmode_lk(fh,mode)            _setmode(fh,mode)
  246. #define _read_lk(fh,buff,count)         _read(fh,buff,count)
  247. #define _write_lk(fh,buff,count)        _write(fh,buff,count)
  248. #if _INTEGRAL_MAX_BITS >= 64
  249. #define _lseeki64_lk(fh,offset,origin)  _lseeki64(fh,offset,origin)
  250. #endif  /* _INTEGRAL_MAX_BITS >= 64 */
  251. #endif  /* _MT */
  252. #endif  /* _NOT_CRTL_BUILD_ */
  253.  
  254. _CRTIMP long __cdecl _get_osfhandle(int);
  255. _CRTIMP int __cdecl _open_osfhandle(long, int);
  256.  
  257. #if !__STDC__
  258.  
  259. /* Non-ANSI names for compatibility */
  260.  
  261. _CRTIMP int __cdecl access(const char *, int);
  262. _CRTIMP int __cdecl chmod(const char *, int);
  263. _CRTIMP int __cdecl chsize(int, long);
  264. _CRTIMP int __cdecl close(int);
  265. _CRTIMP int __cdecl creat(const char *, int);
  266. _CRTIMP int __cdecl dup(int);
  267. _CRTIMP int __cdecl dup2(int, int);
  268. _CRTIMP int __cdecl eof(int);
  269. _CRTIMP long __cdecl filelength(int);
  270. _CRTIMP int __cdecl isatty(int);
  271. _CRTIMP int __cdecl locking(int, int, long);
  272. _CRTIMP long __cdecl lseek(int, long, int);
  273. _CRTIMP char * __cdecl mktemp(char *);
  274. _CRTIMP int __cdecl open(const char *, int, ...);
  275. _CRTIMP int __cdecl read(int, void *, unsigned int);
  276. _CRTIMP int __cdecl setmode(int, int);
  277. _CRTIMP int __cdecl sopen(const char *, int, int, ...);
  278. _CRTIMP long __cdecl tell(int);
  279. _CRTIMP int __cdecl umask(int);
  280. _CRTIMP int __cdecl unlink(const char *);
  281. _CRTIMP int __cdecl write(int, const void *, unsigned int);
  282.  
  283. #endif  /* !__STDC__ */
  284.  
  285. #ifdef __cplusplus
  286. }
  287. #endif  /* __cplusplus */
  288.  
  289.  
  290. #ifdef _MSC_VER
  291. #pragma pack(pop)
  292. #endif  /* _MSC_VER */
  293.  
  294. #endif  /* _INC_IO */
  295.