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.

447 lines
11 KiB

  1. /***
  2. *stdio.h - definitions/declarations for standard I/O routines
  3. *
  4. * Copyright (c) 1985-2000, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file defines the structures, values, macros, and functions
  8. * used by the level 2 I/O ("standard I/O") routines.
  9. * [ANSI/System V]
  10. *
  11. * [Public]
  12. *
  13. ****/
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #ifndef _INC_STDIO
  18. #define _INC_STDIO
  19. #if !defined(_WIN32)
  20. #error ERROR: Only Win32 target supported!
  21. #endif
  22. #ifdef _MSC_VER
  23. /*
  24. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  25. * alignment.
  26. */
  27. #pragma pack(push,8)
  28. #endif /* _MSC_VER */
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #if !defined(_W64)
  33. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
  34. #define _W64 __w64
  35. #else
  36. #define _W64
  37. #endif
  38. #endif
  39. /* Define _CRTIMP */
  40. #ifndef _CRTIMP
  41. #ifdef _DLL
  42. #define _CRTIMP __declspec(dllimport)
  43. #else /* ndef _DLL */
  44. #define _CRTIMP
  45. #endif /* _DLL */
  46. #endif /* _CRTIMP */
  47. /* Define __cdecl for non-Microsoft compilers */
  48. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  49. #define __cdecl
  50. #endif
  51. #ifndef _SIZE_T_DEFINED
  52. #ifdef _WIN64
  53. typedef unsigned __int64 size_t;
  54. #else
  55. typedef _W64 unsigned int size_t;
  56. #endif
  57. #define _SIZE_T_DEFINED
  58. #endif
  59. #if !defined(_WCHAR_T_DEFINED) && !defined(_NATIVE_WCHAR_T_DEFINED)
  60. typedef unsigned short wchar_t;
  61. #define _WCHAR_T_DEFINED
  62. #endif
  63. #ifndef _WCTYPE_T_DEFINED
  64. typedef unsigned short wint_t;
  65. typedef unsigned short wctype_t;
  66. #define _WCTYPE_T_DEFINED
  67. #endif
  68. #ifndef _VA_LIST_DEFINED
  69. #ifdef _M_ALPHA
  70. typedef struct {
  71. char *a0; /* pointer to first homed integer argument */
  72. int offset; /* byte offset of next parameter */
  73. } va_list;
  74. #else
  75. typedef char * va_list;
  76. #endif
  77. #define _VA_LIST_DEFINED
  78. #endif
  79. /* Buffered I/O macros */
  80. #define BUFSIZ 512
  81. /*
  82. * Default number of supported streams. _NFILE is confusing and obsolete, but
  83. * supported anyway for backwards compatibility.
  84. */
  85. #define _NFILE _NSTREAM_
  86. #define _NSTREAM_ 512
  87. /*
  88. * Number of entries in _iob[] (declared below). Note that _NSTREAM_ must be
  89. * greater than or equal to _IOB_ENTRIES.
  90. */
  91. #define _IOB_ENTRIES 20
  92. #define EOF (-1)
  93. #ifndef _FILE_DEFINED
  94. struct _iobuf {
  95. char *_ptr;
  96. int _cnt;
  97. char *_base;
  98. int _flag;
  99. int _file;
  100. int _charbuf;
  101. int _bufsiz;
  102. char *_tmpfname;
  103. };
  104. typedef struct _iobuf FILE;
  105. #define _FILE_DEFINED
  106. #endif
  107. /* Directory where temporary files may be created. */
  108. #ifdef _POSIX_
  109. #define _P_tmpdir "/"
  110. #define _wP_tmpdir L"/"
  111. #else
  112. #define _P_tmpdir "\\"
  113. #define _wP_tmpdir L"\\"
  114. #endif
  115. /* L_tmpnam = size of P_tmpdir
  116. * + 1 (in case P_tmpdir does not end in "/")
  117. * + 12 (for the filename string)
  118. * + 1 (for the null terminator)
  119. */
  120. #define L_tmpnam sizeof(_P_tmpdir)+12
  121. #ifdef _POSIX_
  122. #define L_ctermid 9
  123. #define L_cuserid 32
  124. #endif
  125. /* Seek method constants */
  126. #define SEEK_CUR 1
  127. #define SEEK_END 2
  128. #define SEEK_SET 0
  129. #define FILENAME_MAX 260
  130. #define FOPEN_MAX 20
  131. #define _SYS_OPEN 20
  132. #define TMP_MAX 32767
  133. /* Define NULL pointer value */
  134. #ifndef NULL
  135. #ifdef __cplusplus
  136. #define NULL 0
  137. #else
  138. #define NULL ((void *)0)
  139. #endif
  140. #endif
  141. /* Declare _iob[] array */
  142. #ifndef _STDIO_DEFINED
  143. _CRTIMP extern FILE _iob[];
  144. #endif /* _STDIO_DEFINED */
  145. /* Define file position type */
  146. #ifndef _FPOS_T_DEFINED
  147. #undef _FPOSOFF
  148. #if defined (_POSIX_)
  149. typedef long fpos_t;
  150. #else /* _POSIX_ */
  151. #if !__STDC__ && _INTEGRAL_MAX_BITS >= 64
  152. typedef __int64 fpos_t;
  153. #define _FPOSOFF(fp) ((long)(fp))
  154. #else
  155. typedef struct fpos_t {
  156. unsigned int lopart;
  157. int hipart;
  158. } fpos_t;
  159. #define _FPOSOFF(fp) ((long)(fp).lopart)
  160. #endif
  161. #endif /* _POSIX_ */
  162. #define _FPOS_T_DEFINED
  163. #endif
  164. #define stdin (&_iob[0])
  165. #define stdout (&_iob[1])
  166. #define stderr (&_iob[2])
  167. #define _IOREAD 0x0001
  168. #define _IOWRT 0x0002
  169. #define _IOFBF 0x0000
  170. #define _IOLBF 0x0040
  171. #define _IONBF 0x0004
  172. #define _IOMYBUF 0x0008
  173. #define _IOEOF 0x0010
  174. #define _IOERR 0x0020
  175. #define _IOSTRG 0x0040
  176. #define _IORW 0x0080
  177. #ifdef _POSIX_
  178. #define _IOAPPEND 0x0200
  179. #endif
  180. /* Function prototypes */
  181. #ifndef _STDIO_DEFINED
  182. _CRTIMP int __cdecl _filbuf(FILE *);
  183. _CRTIMP int __cdecl _flsbuf(int, FILE *);
  184. #ifdef _POSIX_
  185. _CRTIMP FILE * __cdecl _fsopen(const char *, const char *);
  186. #else
  187. _CRTIMP FILE * __cdecl _fsopen(const char *, const char *, int);
  188. #endif
  189. _CRTIMP void __cdecl clearerr(FILE *);
  190. _CRTIMP int __cdecl fclose(FILE *);
  191. _CRTIMP int __cdecl _fcloseall(void);
  192. #ifdef _POSIX_
  193. _CRTIMP FILE * __cdecl fdopen(int, const char *);
  194. #else
  195. _CRTIMP FILE * __cdecl _fdopen(int, const char *);
  196. #endif
  197. _CRTIMP int __cdecl feof(FILE *);
  198. _CRTIMP int __cdecl ferror(FILE *);
  199. _CRTIMP int __cdecl fflush(FILE *);
  200. _CRTIMP int __cdecl fgetc(FILE *);
  201. _CRTIMP int __cdecl _fgetchar(void);
  202. _CRTIMP int __cdecl fgetpos(FILE *, fpos_t *);
  203. _CRTIMP char * __cdecl fgets(char *, int, FILE *);
  204. #ifdef _POSIX_
  205. _CRTIMP int __cdecl fileno(FILE *);
  206. #else
  207. _CRTIMP int __cdecl _fileno(FILE *);
  208. #endif
  209. _CRTIMP int __cdecl _flushall(void);
  210. _CRTIMP FILE * __cdecl fopen(const char *, const char *);
  211. _CRTIMP int __cdecl fprintf(FILE *, const char *, ...);
  212. _CRTIMP int __cdecl fputc(int, FILE *);
  213. _CRTIMP int __cdecl _fputchar(int);
  214. _CRTIMP int __cdecl fputs(const char *, FILE *);
  215. _CRTIMP size_t __cdecl fread(void *, size_t, size_t, FILE *);
  216. _CRTIMP FILE * __cdecl freopen(const char *, const char *, FILE *);
  217. _CRTIMP int __cdecl fscanf(FILE *, const char *, ...);
  218. _CRTIMP int __cdecl fsetpos(FILE *, const fpos_t *);
  219. _CRTIMP int __cdecl fseek(FILE *, long, int);
  220. _CRTIMP long __cdecl ftell(FILE *);
  221. _CRTIMP size_t __cdecl fwrite(const void *, size_t, size_t, FILE *);
  222. _CRTIMP int __cdecl getc(FILE *);
  223. _CRTIMP int __cdecl getchar(void);
  224. _CRTIMP int __cdecl _getmaxstdio(void);
  225. _CRTIMP char * __cdecl gets(char *);
  226. _CRTIMP int __cdecl _getw(FILE *);
  227. _CRTIMP void __cdecl perror(const char *);
  228. _CRTIMP int __cdecl _pclose(FILE *);
  229. _CRTIMP FILE * __cdecl _popen(const char *, const char *);
  230. _CRTIMP int __cdecl printf(const char *, ...);
  231. _CRTIMP int __cdecl putc(int, FILE *);
  232. _CRTIMP int __cdecl putchar(int);
  233. _CRTIMP int __cdecl puts(const char *);
  234. _CRTIMP int __cdecl _putw(int, FILE *);
  235. _CRTIMP int __cdecl remove(const char *);
  236. _CRTIMP int __cdecl rename(const char *, const char *);
  237. _CRTIMP void __cdecl rewind(FILE *);
  238. _CRTIMP int __cdecl _rmtmp(void);
  239. _CRTIMP int __cdecl scanf(const char *, ...);
  240. _CRTIMP void __cdecl setbuf(FILE *, char *);
  241. _CRTIMP int __cdecl _setmaxstdio(int);
  242. _CRTIMP int __cdecl setvbuf(FILE *, char *, int, size_t);
  243. _CRTIMP int __cdecl _snprintf(char *, size_t, const char *, ...);
  244. _CRTIMP int __cdecl sprintf(char *, const char *, ...);
  245. _CRTIMP int __cdecl _scprintf(const char *, ...);
  246. _CRTIMP int __cdecl sscanf(const char *, const char *, ...);
  247. _CRTIMP int __cdecl _snscanf(const char *, size_t, const char *, ...);
  248. _CRTIMP char * __cdecl _tempnam(const char *, const char *);
  249. _CRTIMP FILE * __cdecl tmpfile(void);
  250. _CRTIMP char * __cdecl tmpnam(char *);
  251. _CRTIMP int __cdecl ungetc(int, FILE *);
  252. _CRTIMP int __cdecl _unlink(const char *);
  253. _CRTIMP int __cdecl vfprintf(FILE *, const char *, va_list);
  254. _CRTIMP int __cdecl vprintf(const char *, va_list);
  255. _CRTIMP int __cdecl _vsnprintf(char *, size_t, const char *, va_list);
  256. _CRTIMP int __cdecl vsprintf(char *, const char *, va_list);
  257. _CRTIMP int __cdecl _vscprintf(const char *, va_list);
  258. #ifndef _WSTDIO_DEFINED
  259. /* wide function prototypes, also declared in wchar.h */
  260. #ifndef WEOF
  261. #define WEOF (wint_t)(0xFFFF)
  262. #endif
  263. #ifdef _POSIX_
  264. _CRTIMP FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *);
  265. #else
  266. _CRTIMP FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *, int);
  267. #endif
  268. _CRTIMP wint_t __cdecl fgetwc(FILE *);
  269. _CRTIMP wint_t __cdecl _fgetwchar(void);
  270. _CRTIMP wint_t __cdecl fputwc(wint_t, FILE *);
  271. _CRTIMP wint_t __cdecl _fputwchar(wint_t);
  272. _CRTIMP wint_t __cdecl getwc(FILE *);
  273. _CRTIMP wint_t __cdecl getwchar(void);
  274. _CRTIMP wint_t __cdecl putwc(wint_t, FILE *);
  275. _CRTIMP wint_t __cdecl putwchar(wint_t);
  276. _CRTIMP wint_t __cdecl ungetwc(wint_t, FILE *);
  277. _CRTIMP wchar_t * __cdecl fgetws(wchar_t *, int, FILE *);
  278. _CRTIMP int __cdecl fputws(const wchar_t *, FILE *);
  279. _CRTIMP wchar_t * __cdecl _getws(wchar_t *);
  280. _CRTIMP int __cdecl _putws(const wchar_t *);
  281. _CRTIMP int __cdecl fwprintf(FILE *, const wchar_t *, ...);
  282. _CRTIMP int __cdecl wprintf(const wchar_t *, ...);
  283. _CRTIMP int __cdecl _snwprintf(wchar_t *, size_t, const wchar_t *, ...);
  284. _CRTIMP int __cdecl swprintf(wchar_t *, const wchar_t *, ...);
  285. _CRTIMP int __cdecl _scwprintf(const wchar_t *, ...);
  286. _CRTIMP int __cdecl vfwprintf(FILE *, const wchar_t *, va_list);
  287. _CRTIMP int __cdecl vwprintf(const wchar_t *, va_list);
  288. _CRTIMP int __cdecl _vsnwprintf(wchar_t *, size_t, const wchar_t *, va_list);
  289. _CRTIMP int __cdecl vswprintf(wchar_t *, const wchar_t *, va_list);
  290. _CRTIMP int __cdecl _vscwprintf(const wchar_t *, va_list);
  291. _CRTIMP int __cdecl fwscanf(FILE *, const wchar_t *, ...);
  292. _CRTIMP int __cdecl swscanf(const wchar_t *, const wchar_t *, ...);
  293. _CRTIMP int __cdecl _snwscanf(const wchar_t *, size_t, const wchar_t *, ...);
  294. _CRTIMP int __cdecl wscanf(const wchar_t *, ...);
  295. #define getwchar() fgetwc(stdin)
  296. #define putwchar(_c) fputwc((_c),stdout)
  297. #define getwc(_stm) fgetwc(_stm)
  298. #define putwc(_c,_stm) fputwc(_c,_stm)
  299. _CRTIMP FILE * __cdecl _wfdopen(int, const wchar_t *);
  300. _CRTIMP FILE * __cdecl _wfopen(const wchar_t *, const wchar_t *);
  301. _CRTIMP FILE * __cdecl _wfreopen(const wchar_t *, const wchar_t *, FILE *);
  302. _CRTIMP void __cdecl _wperror(const wchar_t *);
  303. _CRTIMP FILE * __cdecl _wpopen(const wchar_t *, const wchar_t *);
  304. _CRTIMP int __cdecl _wremove(const wchar_t *);
  305. _CRTIMP wchar_t * __cdecl _wtempnam(const wchar_t *, const wchar_t *);
  306. _CRTIMP wchar_t * __cdecl _wtmpnam(wchar_t *);
  307. #define _WSTDIO_DEFINED
  308. #endif /* _WSTDIO_DEFINED */
  309. #define _STDIO_DEFINED
  310. #endif /* _STDIO_DEFINED */
  311. /* Macro definitions */
  312. #define feof(_stream) ((_stream)->_flag & _IOEOF)
  313. #define ferror(_stream) ((_stream)->_flag & _IOERR)
  314. #define _fileno(_stream) ((_stream)->_file)
  315. #define getc(_stream) (--(_stream)->_cnt >= 0 \
  316. ? 0xff & *(_stream)->_ptr++ : _filbuf(_stream))
  317. #define putc(_c,_stream) (--(_stream)->_cnt >= 0 \
  318. ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream)))
  319. #define getchar() getc(stdin)
  320. #define putchar(_c) putc((_c),stdout)
  321. #ifdef _MT
  322. #undef getc
  323. #undef putc
  324. #undef getchar
  325. #undef putchar
  326. #endif
  327. #if !__STDC__ && !defined(_POSIX_)
  328. /* Non-ANSI names for compatibility */
  329. #define P_tmpdir _P_tmpdir
  330. #define SYS_OPEN _SYS_OPEN
  331. _CRTIMP int __cdecl fcloseall(void);
  332. _CRTIMP FILE * __cdecl fdopen(int, const char *);
  333. _CRTIMP int __cdecl fgetchar(void);
  334. _CRTIMP int __cdecl fileno(FILE *);
  335. _CRTIMP int __cdecl flushall(void);
  336. _CRTIMP int __cdecl fputchar(int);
  337. _CRTIMP int __cdecl getw(FILE *);
  338. _CRTIMP int __cdecl putw(int, FILE *);
  339. _CRTIMP int __cdecl rmtmp(void);
  340. _CRTIMP char * __cdecl tempnam(const char *, const char *);
  341. _CRTIMP int __cdecl unlink(const char *);
  342. #endif /* __STDC__ */
  343. #ifdef __cplusplus
  344. }
  345. #endif
  346. #ifdef _MSC_VER
  347. #pragma pack(pop)
  348. #endif /* _MSC_VER */
  349. #endif /* _INC_STDIO */