Leaked source code of windows server 2003
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.

441 lines
12 KiB

  1. /***
  2. *stdio.h - definitions/declarations for standard I/O routines
  3. *
  4. * Copyright (c) 1985-2001, 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. typedef char * va_list;
  70. #define _VA_LIST_DEFINED
  71. #endif
  72. /* Buffered I/O macros */
  73. #define BUFSIZ 512
  74. /*
  75. * Default number of supported streams. _NFILE is confusing and obsolete, but
  76. * supported anyway for backwards compatibility.
  77. */
  78. #define _NFILE _NSTREAM_
  79. #define _NSTREAM_ 512
  80. /*
  81. * Number of entries in _iob[] (declared below). Note that _NSTREAM_ must be
  82. * greater than or equal to _IOB_ENTRIES.
  83. */
  84. #define _IOB_ENTRIES 20
  85. #define EOF (-1)
  86. #ifndef _FILE_DEFINED
  87. struct _iobuf {
  88. char *_ptr;
  89. int _cnt;
  90. char *_base;
  91. int _flag;
  92. int _file;
  93. int _charbuf;
  94. int _bufsiz;
  95. char *_tmpfname;
  96. };
  97. typedef struct _iobuf FILE;
  98. #define _FILE_DEFINED
  99. #endif
  100. /* Directory where temporary files may be created. */
  101. #ifdef _POSIX_
  102. #define _P_tmpdir "/"
  103. #define _wP_tmpdir L"/"
  104. #else
  105. #define _P_tmpdir "\\"
  106. #define _wP_tmpdir L"\\"
  107. #endif
  108. /* L_tmpnam = length of string _P_tmpdir
  109. * + 1 if _P_tmpdir does not end in "/" or "\", else 0
  110. * + 12 (for the filename string)
  111. * + 1 (for the null terminator)
  112. */
  113. #define L_tmpnam sizeof(_P_tmpdir)+12
  114. #ifdef _POSIX_
  115. #define L_ctermid 9
  116. #define L_cuserid 32
  117. #endif
  118. /* Seek method constants */
  119. #define SEEK_CUR 1
  120. #define SEEK_END 2
  121. #define SEEK_SET 0
  122. #define FILENAME_MAX 260
  123. #define FOPEN_MAX 20
  124. #define _SYS_OPEN 20
  125. #define TMP_MAX 32767
  126. /* Define NULL pointer value */
  127. #ifndef NULL
  128. #ifdef __cplusplus
  129. #define NULL 0
  130. #else
  131. #define NULL ((void *)0)
  132. #endif
  133. #endif
  134. /* Declare _iob[] array */
  135. #ifndef _STDIO_DEFINED
  136. _CRTIMP extern FILE _iob[];
  137. #endif /* _STDIO_DEFINED */
  138. /* Define file position type */
  139. #ifndef _FPOS_T_DEFINED
  140. #undef _FPOSOFF
  141. #if defined (_POSIX_)
  142. typedef long fpos_t;
  143. #define _FPOSOFF(fp) ((long)(fp))
  144. #else /* _POSIX_ */
  145. #if !__STDC__ && _INTEGRAL_MAX_BITS >= 64
  146. typedef __int64 fpos_t;
  147. #define _FPOSOFF(fp) ((long)(fp))
  148. #else
  149. typedef struct fpos_t {
  150. unsigned int lopart;
  151. int hipart;
  152. } fpos_t;
  153. #define _FPOSOFF(fp) ((long)(fp).lopart)
  154. #endif
  155. #endif /* _POSIX_ */
  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 int __cdecl _getmaxstdio(void);
  219. _CRTIMP char * __cdecl gets(char *);
  220. _CRTIMP int __cdecl _getw(FILE *);
  221. _CRTIMP void __cdecl perror(const char *);
  222. _CRTIMP int __cdecl _pclose(FILE *);
  223. _CRTIMP FILE * __cdecl _popen(const char *, const char *);
  224. _CRTIMP int __cdecl printf(const char *, ...);
  225. _CRTIMP int __cdecl putc(int, FILE *);
  226. _CRTIMP int __cdecl putchar(int);
  227. _CRTIMP int __cdecl puts(const char *);
  228. _CRTIMP int __cdecl _putw(int, FILE *);
  229. _CRTIMP int __cdecl remove(const char *);
  230. _CRTIMP int __cdecl rename(const char *, const char *);
  231. _CRTIMP void __cdecl rewind(FILE *);
  232. _CRTIMP int __cdecl _rmtmp(void);
  233. _CRTIMP int __cdecl scanf(const char *, ...);
  234. _CRTIMP void __cdecl setbuf(FILE *, char *);
  235. _CRTIMP int __cdecl _setmaxstdio(int);
  236. _CRTIMP int __cdecl setvbuf(FILE *, char *, int, size_t);
  237. _CRTIMP int __cdecl _snprintf(char *, size_t, const char *, ...);
  238. _CRTIMP int __cdecl sprintf(char *, const char *, ...);
  239. _CRTIMP int __cdecl _scprintf(const char *, ...);
  240. _CRTIMP int __cdecl sscanf(const char *, const char *, ...);
  241. _CRTIMP int __cdecl _snscanf(const char *, size_t, const char *, ...);
  242. _CRTIMP char * __cdecl _tempnam(const char *, const char *);
  243. _CRTIMP FILE * __cdecl tmpfile(void);
  244. _CRTIMP char * __cdecl tmpnam(char *);
  245. _CRTIMP int __cdecl ungetc(int, FILE *);
  246. _CRTIMP int __cdecl _unlink(const char *);
  247. _CRTIMP int __cdecl vfprintf(FILE *, const char *, va_list);
  248. _CRTIMP int __cdecl vprintf(const char *, va_list);
  249. _CRTIMP int __cdecl _vsnprintf(char *, size_t, const char *, va_list);
  250. _CRTIMP int __cdecl vsprintf(char *, const char *, va_list);
  251. _CRTIMP int __cdecl _vscprintf(const char *, va_list);
  252. #ifndef _WSTDIO_DEFINED
  253. /* wide function prototypes, also declared in wchar.h */
  254. #ifndef WEOF
  255. #define WEOF (wint_t)(0xFFFF)
  256. #endif
  257. #ifdef _POSIX_
  258. _CRTIMP FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *);
  259. #else
  260. _CRTIMP FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *, int);
  261. #endif
  262. _CRTIMP wint_t __cdecl fgetwc(FILE *);
  263. _CRTIMP wint_t __cdecl _fgetwchar(void);
  264. _CRTIMP wint_t __cdecl fputwc(wchar_t, FILE *);
  265. _CRTIMP wint_t __cdecl _fputwchar(wchar_t);
  266. _CRTIMP wint_t __cdecl getwc(FILE *);
  267. _CRTIMP wint_t __cdecl getwchar(void);
  268. _CRTIMP wint_t __cdecl putwc(wchar_t, FILE *);
  269. _CRTIMP wint_t __cdecl putwchar(wchar_t);
  270. _CRTIMP wint_t __cdecl ungetwc(wint_t, FILE *);
  271. _CRTIMP wchar_t * __cdecl fgetws(wchar_t *, int, FILE *);
  272. _CRTIMP int __cdecl fputws(const wchar_t *, FILE *);
  273. _CRTIMP wchar_t * __cdecl _getws(wchar_t *);
  274. _CRTIMP int __cdecl _putws(const wchar_t *);
  275. _CRTIMP int __cdecl fwprintf(FILE *, const wchar_t *, ...);
  276. _CRTIMP int __cdecl wprintf(const wchar_t *, ...);
  277. _CRTIMP int __cdecl _snwprintf(wchar_t *, size_t, const wchar_t *, ...);
  278. _CRTIMP int __cdecl swprintf(wchar_t *, const wchar_t *, ...);
  279. _CRTIMP int __cdecl _scwprintf(const wchar_t *, ...);
  280. _CRTIMP int __cdecl vfwprintf(FILE *, const wchar_t *, va_list);
  281. _CRTIMP int __cdecl vwprintf(const wchar_t *, va_list);
  282. _CRTIMP int __cdecl _vsnwprintf(wchar_t *, size_t, const wchar_t *, va_list);
  283. _CRTIMP int __cdecl vswprintf(wchar_t *, const wchar_t *, va_list);
  284. _CRTIMP int __cdecl _vscwprintf(const wchar_t *, va_list);
  285. _CRTIMP int __cdecl fwscanf(FILE *, const wchar_t *, ...);
  286. _CRTIMP int __cdecl swscanf(const wchar_t *, const wchar_t *, ...);
  287. _CRTIMP int __cdecl _snwscanf(const wchar_t *, size_t, const wchar_t *, ...);
  288. _CRTIMP int __cdecl wscanf(const wchar_t *, ...);
  289. #define getwchar() fgetwc(stdin)
  290. #define putwchar(_c) fputwc((_c),stdout)
  291. #define getwc(_stm) fgetwc(_stm)
  292. #define putwc(_c,_stm) fputwc(_c,_stm)
  293. _CRTIMP FILE * __cdecl _wfdopen(int, const wchar_t *);
  294. _CRTIMP FILE * __cdecl _wfopen(const wchar_t *, const wchar_t *);
  295. _CRTIMP FILE * __cdecl _wfreopen(const wchar_t *, const wchar_t *, FILE *);
  296. _CRTIMP void __cdecl _wperror(const wchar_t *);
  297. _CRTIMP FILE * __cdecl _wpopen(const wchar_t *, const wchar_t *);
  298. _CRTIMP int __cdecl _wremove(const wchar_t *);
  299. _CRTIMP wchar_t * __cdecl _wtempnam(const wchar_t *, const wchar_t *);
  300. _CRTIMP wchar_t * __cdecl _wtmpnam(wchar_t *);
  301. #define _WSTDIO_DEFINED
  302. #endif /* _WSTDIO_DEFINED */
  303. #define _STDIO_DEFINED
  304. #endif /* _STDIO_DEFINED */
  305. /* Macro definitions */
  306. #define feof(_stream) ((_stream)->_flag & _IOEOF)
  307. #define ferror(_stream) ((_stream)->_flag & _IOERR)
  308. #define _fileno(_stream) ((_stream)->_file)
  309. #define getc(_stream) (--(_stream)->_cnt >= 0 \
  310. ? 0xff & *(_stream)->_ptr++ : _filbuf(_stream))
  311. #define putc(_c,_stream) (--(_stream)->_cnt >= 0 \
  312. ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream)))
  313. #define getchar() getc(stdin)
  314. #define putchar(_c) putc((_c),stdout)
  315. #ifdef _MT
  316. #undef getc
  317. #undef putc
  318. #undef getchar
  319. #undef putchar
  320. #endif
  321. #if !__STDC__ && !defined(_POSIX_)
  322. /* Non-ANSI names for compatibility */
  323. #define P_tmpdir _P_tmpdir
  324. #define SYS_OPEN _SYS_OPEN
  325. _CRTIMP int __cdecl fcloseall(void);
  326. _CRTIMP FILE * __cdecl fdopen(int, const char *);
  327. _CRTIMP int __cdecl fgetchar(void);
  328. _CRTIMP int __cdecl fileno(FILE *);
  329. _CRTIMP int __cdecl flushall(void);
  330. _CRTIMP int __cdecl fputchar(int);
  331. _CRTIMP int __cdecl getw(FILE *);
  332. _CRTIMP int __cdecl putw(int, FILE *);
  333. _CRTIMP int __cdecl rmtmp(void);
  334. _CRTIMP char * __cdecl tempnam(const char *, const char *);
  335. _CRTIMP int __cdecl unlink(const char *);
  336. #endif /* __STDC__ */
  337. #ifdef __cplusplus
  338. }
  339. #endif
  340. #ifdef _MSC_VER
  341. #pragma pack(pop)
  342. #endif /* _MSC_VER */
  343. #endif /* _INC_STDIO */