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.

254 lines
6.0 KiB

  1. /***
  2. *stdio.h - definitions/declarations for standard I/O routines
  3. *
  4. * Copyright (c) 1985-1990, 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. #if defined(_DLL) && !defined(_MT)
  13. #error Cannot define _DLL without _MT
  14. #endif
  15. #ifdef _MT
  16. #define _FAR_ _far
  17. #else
  18. #define _FAR_
  19. #endif
  20. #ifndef _SIZE_T_DEFINED
  21. typedef unsigned int size_t;
  22. #define _SIZE_T_DEFINED
  23. #endif
  24. #ifndef _VA_LIST_DEFINED
  25. typedef char _FAR_ *va_list;
  26. #define _VA_LIST_DEFINED
  27. #endif
  28. /* buffered I/O macros */
  29. #define BUFSIZ 512
  30. #ifdef _MT
  31. #define _NFILE 40
  32. #else
  33. #define _NFILE 20
  34. #endif
  35. #define EOF (-1)
  36. #ifndef _FILE_DEFINED
  37. struct _iobuf {
  38. char _FAR_ *_ptr;
  39. int _cnt;
  40. char _FAR_ *_base;
  41. char _flag;
  42. char _file;
  43. };
  44. typedef struct _iobuf FILE;
  45. #define _FILE_DEFINED
  46. #endif
  47. /* P_tmpnam: Directory where temporary files may be created.
  48. * L_tmpnam size = size of P_tmpdir
  49. * + 1 (in case P_tmpdir does not end in "\\")
  50. * + 6 (for the temp number string)
  51. * + 1 (for the null terminator)
  52. */
  53. #define P_tmpdir "\\"
  54. #define L_tmpnam sizeof(P_tmpdir)+8
  55. /* fseek constants */
  56. #define SEEK_CUR 1
  57. #define SEEK_END 2
  58. #define SEEK_SET 0
  59. /* minimum guaranteed filename length, open file count, and unique
  60. * tmpnam filenames.
  61. */
  62. #define FILENAME_MAX 63
  63. #define FOPEN_MAX 20
  64. #define SYS_OPEN 20
  65. #define TMP_MAX 32767
  66. /* define NULL pointer value */
  67. #ifndef NULL
  68. #if (_MSC_VER >= 600)
  69. #define NULL ((void *)0)
  70. #elif (defined(M_I86SM) || defined(M_I86MM))
  71. #define NULL 0
  72. #else
  73. #define NULL 0L
  74. #endif
  75. #endif
  76. /* declare _iob[] array */
  77. #ifndef _STDIO_DEFINED
  78. #ifdef _DLL
  79. extern FILE _FAR_ _cdecl _iob[];
  80. #else
  81. extern FILE _near _cdecl _iob[];
  82. #endif
  83. #endif
  84. /* define file position type */
  85. #ifndef _FPOS_T_DEFINED
  86. typedef long fpos_t;
  87. #define _FPOS_T_DEFINED
  88. #endif
  89. /* standard file pointers */
  90. #ifndef _WINDOWS
  91. #define stdin (&_iob[0])
  92. #define stdout (&_iob[1])
  93. #define stderr (&_iob[2])
  94. #define stdaux (&_iob[3])
  95. #define stdprn (&_iob[4])
  96. #endif
  97. #define _IOREAD 0x01
  98. #define _IOWRT 0x02
  99. #define _IOFBF 0x0
  100. #define _IOLBF 0x40
  101. #define _IONBF 0x04
  102. #define _IOMYBUF 0x08
  103. #define _IOEOF 0x10
  104. #define _IOERR 0x20
  105. #define _IOSTRG 0x40
  106. #define _IORW 0x80
  107. /* function prototypes */
  108. #ifndef _STDIO_DEFINED
  109. int _FAR_ _cdecl _filbuf(FILE _FAR_ *);
  110. int _FAR_ _cdecl _flsbuf(int, FILE _FAR_ *);
  111. FILE _FAR_ * _FAR_ _cdecl _fsopen(const char _FAR_ *,
  112. const char _FAR_ *, int);
  113. void _FAR_ _cdecl clearerr(FILE _FAR_ *);
  114. int _FAR_ _cdecl fclose(FILE _FAR_ *);
  115. int _FAR_ _cdecl fcloseall(void);
  116. FILE _FAR_ * _FAR_ _cdecl fdopen(int, const char _FAR_ *);
  117. int _FAR_ _cdecl feof(FILE _FAR_ *);
  118. int _FAR_ _cdecl ferror(FILE _FAR_ *);
  119. int _FAR_ _cdecl fflush(FILE _FAR_ *);
  120. int _FAR_ _cdecl fgetc(FILE _FAR_ *);
  121. #ifndef _WINDOWS
  122. int _FAR_ _cdecl fgetchar(void);
  123. #endif
  124. int _FAR_ _cdecl fgetpos(FILE _FAR_ *, fpos_t _FAR_ *);
  125. char _FAR_ * _FAR_ _cdecl fgets(char _FAR_ *, int, FILE _FAR_ *);
  126. int _FAR_ _cdecl fileno(FILE _FAR_ *);
  127. int _FAR_ _cdecl flushall(void);
  128. FILE _FAR_ * _FAR_ _cdecl fopen(const char _FAR_ *,
  129. const char _FAR_ *);
  130. #ifndef _WINDLL
  131. int _FAR_ _cdecl fprintf(FILE _FAR_ *, const char _FAR_ *, ...);
  132. #endif
  133. int _FAR_ _cdecl fputc(int, FILE _FAR_ *);
  134. #ifndef _WINDOWS
  135. int _FAR_ _cdecl fputchar(int);
  136. #endif
  137. int _FAR_ _cdecl fputs(const char _FAR_ *, FILE _FAR_ *);
  138. size_t _FAR_ _cdecl fread(void _FAR_ *, size_t, size_t, FILE _FAR_ *);
  139. FILE _FAR_ * _FAR_ _cdecl freopen(const char _FAR_ *,
  140. const char _FAR_ *, FILE _FAR_ *);
  141. #ifndef _WINDLL
  142. int _FAR_ _cdecl fscanf(FILE _FAR_ *, const char _FAR_ *, ...);
  143. #endif
  144. int _FAR_ _cdecl fsetpos(FILE _FAR_ *, const fpos_t _FAR_ *);
  145. int _FAR_ _cdecl fseek(FILE _FAR_ *, long, int);
  146. long _FAR_ _cdecl ftell(FILE _FAR_ *);
  147. size_t _FAR_ _cdecl fwrite(const void _FAR_ *, size_t, size_t,
  148. FILE _FAR_ *);
  149. int _FAR_ _cdecl getc(FILE _FAR_ *);
  150. #ifndef _WINDOWS
  151. int _FAR_ _cdecl getchar(void);
  152. char _FAR_ * _FAR_ _cdecl gets(char _FAR_ *);
  153. #endif
  154. int _FAR_ _cdecl getw(FILE _FAR_ *);
  155. #ifndef _WINDOWS
  156. void _FAR_ _cdecl perror(const char _FAR_ *);
  157. #endif
  158. int _FAR_ _cdecl _pclose(FILE _FAR_ *);
  159. FILE _FAR_ * _FAR_ _cdecl _popen(const char _FAR_ *,
  160. const char _FAR_ *);
  161. #ifndef _WINDOWS
  162. int _FAR_ _cdecl printf(const char _FAR_ *, ...);
  163. #endif
  164. int _FAR_ _cdecl putc(int, FILE _FAR_ *);
  165. #ifndef _WINDOWS
  166. int _FAR_ _cdecl putchar(int);
  167. int _FAR_ _cdecl puts(const char _FAR_ *);
  168. #endif
  169. int _FAR_ _cdecl putw(int, FILE _FAR_ *);
  170. int _FAR_ _cdecl remove(const char _FAR_ *);
  171. int _FAR_ _cdecl rename(const char _FAR_ *, const char _FAR_ *);
  172. void _FAR_ _cdecl rewind(FILE _FAR_ *);
  173. int _FAR_ _cdecl rmtmp(void);
  174. #ifndef _WINDOWS
  175. int _FAR_ _cdecl scanf(const char _FAR_ *, ...);
  176. #endif
  177. void _FAR_ _cdecl setbuf(FILE _FAR_ *, char _FAR_ *);
  178. int _FAR_ _cdecl setvbuf(FILE _FAR_ *, char _FAR_ *, int, size_t);
  179. #ifndef _WINDLL
  180. int _FAR_ _cdecl sprintf(char _FAR_ *, const char _FAR_ *, ...);
  181. int _FAR_ _cdecl sscanf(const char _FAR_ *, const char _FAR_ *, ...);
  182. #endif
  183. char _FAR_ * _FAR_ _cdecl tempnam(char _FAR_ *, char _FAR_ *);
  184. FILE _FAR_ * _FAR_ _cdecl tmpfile(void);
  185. char _FAR_ * _FAR_ _cdecl tmpnam(char _FAR_ *);
  186. int _FAR_ _cdecl ungetc(int, FILE _FAR_ *);
  187. int _FAR_ _cdecl unlink(const char _FAR_ *);
  188. #ifndef _WINDLL
  189. int _FAR_ _cdecl vfprintf(FILE _FAR_ *, const char _FAR_ *, va_list);
  190. #endif
  191. #ifndef _WINDOWS
  192. int _FAR_ _cdecl vprintf(const char _FAR_ *, va_list);
  193. #endif
  194. #ifndef _WINDLL
  195. int _FAR_ _cdecl vsprintf(char _FAR_ *, const char _FAR_ *, va_list);
  196. #endif
  197. #define _STDIO_DEFINED
  198. #endif
  199. /* macro definitions */
  200. #define feof(_stream) ((_stream)->_flag & _IOEOF)
  201. #define ferror(_stream) ((_stream)->_flag & _IOERR)
  202. #define fileno(_stream) ((int)(unsigned char)(_stream)->_file)
  203. #define getc(_stream) (--(_stream)->_cnt >= 0 ? 0xff & *(_stream)->_ptr++ \
  204. : _filbuf(_stream))
  205. #define putc(_c,_stream) (--(_stream)->_cnt >= 0 \
  206. ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream)))
  207. #ifndef _WINDOWS
  208. #define getchar() getc(stdin)
  209. #define putchar(_c) putc((_c),stdout)
  210. #endif
  211. #ifdef _MT
  212. #undef getc
  213. #undef putc
  214. #undef getchar
  215. #undef putchar
  216. #endif