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.

455 lines
10 KiB

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