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.

224 lines
5.9 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. #define stdin (&_iob[0])
  91. #define stdout (&_iob[1])
  92. #define stderr (&_iob[2])
  93. #define stdaux (&_iob[3])
  94. #define stdprn (&_iob[4])
  95. #define _IOREAD 0x01
  96. #define _IOWRT 0x02
  97. #define _IOFBF 0x0
  98. #define _IOLBF 0x40
  99. #define _IONBF 0x04
  100. #define _IOMYBUF 0x08
  101. #define _IOEOF 0x10
  102. #define _IOERR 0x20
  103. #define _IOSTRG 0x40
  104. #define _IORW 0x80
  105. /* function prototypes */
  106. #ifndef _STDIO_DEFINED
  107. int _FAR_ _cdecl _filbuf(FILE _FAR_ *);
  108. int _FAR_ _cdecl _flsbuf(int, FILE _FAR_ *);
  109. FILE _FAR_ * _FAR_ _cdecl _fsopen(const char _FAR_ *,
  110. const char _FAR_ *, int);
  111. void _FAR_ _cdecl clearerr(FILE _FAR_ *);
  112. int _FAR_ _cdecl fclose(FILE _FAR_ *);
  113. int _FAR_ _cdecl fcloseall(void);
  114. FILE _FAR_ * _FAR_ _cdecl fdopen(int, const char _FAR_ *);
  115. int _FAR_ _cdecl feof(FILE _FAR_ *);
  116. int _FAR_ _cdecl ferror(FILE _FAR_ *);
  117. int _FAR_ _cdecl fflush(FILE _FAR_ *);
  118. int _FAR_ _cdecl fgetc(FILE _FAR_ *);
  119. int _FAR_ _cdecl fgetchar(void);
  120. int _FAR_ _cdecl fgetpos(FILE _FAR_ *, fpos_t _FAR_ *);
  121. char _FAR_ * _FAR_ _cdecl fgets(char _FAR_ *, int, FILE _FAR_ *);
  122. int _FAR_ _cdecl fileno(FILE _FAR_ *);
  123. int _FAR_ _cdecl flushall(void);
  124. FILE _FAR_ * _FAR_ _cdecl fopen(const char _FAR_ *,
  125. const char _FAR_ *);
  126. int _FAR_ _cdecl fprintf(FILE _FAR_ *, const char _FAR_ *, ...);
  127. int _FAR_ _cdecl fputc(int, FILE _FAR_ *);
  128. int _FAR_ _cdecl fputchar(int);
  129. int _FAR_ _cdecl fputs(const char _FAR_ *, FILE _FAR_ *);
  130. size_t _FAR_ _cdecl fread(void _FAR_ *, size_t, size_t, FILE _FAR_ *);
  131. FILE _FAR_ * _FAR_ _cdecl freopen(const char _FAR_ *,
  132. const char _FAR_ *, FILE _FAR_ *);
  133. int _FAR_ _cdecl fscanf(FILE _FAR_ *, const char _FAR_ *, ...);
  134. int _FAR_ _cdecl fsetpos(FILE _FAR_ *, const fpos_t _FAR_ *);
  135. int _FAR_ _cdecl fseek(FILE _FAR_ *, long, int);
  136. long _FAR_ _cdecl ftell(FILE _FAR_ *);
  137. size_t _FAR_ _cdecl fwrite(const void _FAR_ *, size_t, size_t,
  138. FILE _FAR_ *);
  139. int _FAR_ _cdecl getc(FILE _FAR_ *);
  140. int _FAR_ _cdecl getchar(void);
  141. char _FAR_ * _FAR_ _cdecl gets(char _FAR_ *);
  142. int _FAR_ _cdecl getw(FILE _FAR_ *);
  143. void _FAR_ _cdecl perror(const char _FAR_ *);
  144. int _FAR_ _cdecl _pclose(FILE _FAR_ *);
  145. FILE _FAR_ * _FAR_ _cdecl _popen(const char _FAR_ *,
  146. const char _FAR_ *);
  147. int _FAR_ _cdecl printf(const char _FAR_ *, ...);
  148. int _FAR_ _cdecl putc(int, FILE _FAR_ *);
  149. int _FAR_ _cdecl putchar(int);
  150. int _FAR_ _cdecl puts(const char _FAR_ *);
  151. int _FAR_ _cdecl putw(int, FILE _FAR_ *);
  152. int _FAR_ _cdecl remove(const char _FAR_ *);
  153. int _FAR_ _cdecl rename(const char _FAR_ *, const char _FAR_ *);
  154. void _FAR_ _cdecl rewind(FILE _FAR_ *);
  155. int _FAR_ _cdecl rmtmp(void);
  156. int _FAR_ _cdecl scanf(const char _FAR_ *, ...);
  157. void _FAR_ _cdecl setbuf(FILE _FAR_ *, char _FAR_ *);
  158. int _FAR_ _cdecl setvbuf(FILE _FAR_ *, char _FAR_ *, int, size_t);
  159. int _FAR_ _cdecl sprintf(char _FAR_ *, const char _FAR_ *, ...);
  160. int _FAR_ _cdecl sscanf(const char _FAR_ *, const char _FAR_ *, ...);
  161. char _FAR_ * _FAR_ _cdecl tempnam(char _FAR_ *, char _FAR_ *);
  162. FILE _FAR_ * _FAR_ _cdecl tmpfile(void);
  163. char _FAR_ * _FAR_ _cdecl tmpnam(char _FAR_ *);
  164. int _FAR_ _cdecl ungetc(int, FILE _FAR_ *);
  165. int _FAR_ _cdecl unlink(const char _FAR_ *);
  166. int _FAR_ _cdecl vfprintf(FILE _FAR_ *, const char _FAR_ *, va_list);
  167. int _FAR_ _cdecl vprintf(const char _FAR_ *, va_list);
  168. int _FAR_ _cdecl vsprintf(char _FAR_ *, const char _FAR_ *, va_list);
  169. #define _STDIO_DEFINED
  170. #endif
  171. /* macro definitions */
  172. #define feof(_stream) ((_stream)->_flag & _IOEOF)
  173. #define ferror(_stream) ((_stream)->_flag & _IOERR)
  174. #define fileno(_stream) ((int)(unsigned char)(_stream)->_file)
  175. #define getc(_stream) (--(_stream)->_cnt >= 0 ? 0xff & *(_stream)->_ptr++ \
  176. : _filbuf(_stream))
  177. #define putc(_c,_stream) (--(_stream)->_cnt >= 0 \
  178. ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream)))
  179. #define getchar() getc(stdin)
  180. #define putchar(_c) putc((_c),stdout)
  181. #ifdef _MT
  182. #undef getc
  183. #undef putc
  184. #undef getchar
  185. #undef putchar
  186. #endif