stdio.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. /**
  2. * This file has no copyright assigned and is placed in the Public Domain.
  3. * This file is part of the w64 mingw-runtime package.
  4. * No warranty is given; refer to the file DISCLAIMER within this package.
  5. */
  6. #ifndef _INC_STDIO
  7. #define _INC_STDIO
  8. #include <_mingw.h>
  9. #pragma pack(push,_CRT_PACKING)
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #define BUFSIZ 512
  14. #define _NFILE _NSTREAM_
  15. #define _NSTREAM_ 512
  16. #define _IOB_ENTRIES 20
  17. #define EOF (-1)
  18. #ifndef _FILE_DEFINED
  19. struct _iobuf {
  20. char *_ptr;
  21. int _cnt;
  22. char *_base;
  23. int _flag;
  24. int _file;
  25. int _charbuf;
  26. int _bufsiz;
  27. char *_tmpfname;
  28. };
  29. typedef struct _iobuf FILE;
  30. #define _FILE_DEFINED
  31. #endif
  32. #ifdef _POSIX_
  33. #define _P_tmpdir "/"
  34. #define _wP_tmpdir L"/"
  35. #else
  36. #define _P_tmpdir "\\"
  37. #define _wP_tmpdir L"\\"
  38. #endif
  39. #define L_tmpnam (sizeof(_P_tmpdir) + 12)
  40. #ifdef _POSIX_
  41. #define L_ctermid 9
  42. #define L_cuserid 32
  43. #endif
  44. #define SEEK_CUR 1
  45. #define SEEK_END 2
  46. #define SEEK_SET 0
  47. #define STDIN_FILENO 0
  48. #define STDOUT_FILENO 1
  49. #define STDERR_FILENO 2
  50. #define FILENAME_MAX 260
  51. #define FOPEN_MAX 20
  52. #define _SYS_OPEN 20
  53. #define TMP_MAX 32767
  54. #ifndef NULL
  55. #ifdef __cplusplus
  56. #define NULL 0
  57. #else
  58. #define NULL ((void *)0)
  59. #endif
  60. #endif
  61. #ifndef _OFF_T_DEFINED
  62. #define _OFF_T_DEFINED
  63. #ifndef _OFF_T_
  64. #define _OFF_T_
  65. typedef long _off_t;
  66. #if !defined(NO_OLDNAMES) || defined(_POSIX)
  67. typedef long off_t;
  68. #endif
  69. #endif
  70. #endif
  71. #ifndef _OFF64_T_DEFINED
  72. #define _OFF64_T_DEFINED
  73. typedef long long _off64_t;
  74. #if !defined(NO_OLDNAMES) || defined(_POSIX)
  75. typedef long long off64_t;
  76. #endif
  77. #endif
  78. #ifndef _STDIO_DEFINED
  79. #ifdef _WIN64
  80. _CRTIMP FILE *__cdecl __iob_func(void);
  81. #else
  82. #ifdef _MSVCRT_
  83. extern FILE _iob[]; /* A pointer to an array of FILE */
  84. #define __iob_func() (_iob)
  85. #else
  86. extern FILE (*_imp___iob)[]; /* A pointer to an array of FILE */
  87. #define __iob_func() (*_imp___iob)
  88. #define _iob __iob_func()
  89. #endif
  90. #endif
  91. #endif
  92. #ifndef _FPOS_T_DEFINED
  93. #define _FPOS_T_DEFINED
  94. #undef _FPOSOFF
  95. #if (!defined(NO_OLDNAMES) || defined(__GNUC__)) && _INTEGRAL_MAX_BITS >= 64
  96. typedef __int64 fpos_t;
  97. #define _FPOSOFF(fp) ((long)(fp))
  98. #else
  99. typedef long long fpos_t;
  100. #define _FPOSOFF(fp) ((long)(fp))
  101. #endif
  102. #endif
  103. #ifndef _STDSTREAM_DEFINED
  104. #define _STDSTREAM_DEFINED
  105. #define stdin (&__iob_func()[0])
  106. #define stdout (&__iob_func()[1])
  107. #define stderr (&__iob_func()[2])
  108. #endif
  109. #define _IOREAD 0x0001
  110. #define _IOWRT 0x0002
  111. #define _IOFBF 0x0000
  112. #define _IOLBF 0x0040
  113. #define _IONBF 0x0004
  114. #define _IOMYBUF 0x0008
  115. #define _IOEOF 0x0010
  116. #define _IOERR 0x0020
  117. #define _IOSTRG 0x0040
  118. #define _IORW 0x0080
  119. #ifdef _POSIX_
  120. #define _IOAPPEND 0x0200
  121. #endif
  122. #define _TWO_DIGIT_EXPONENT 0x1
  123. #ifndef _STDIO_DEFINED
  124. _CRTIMP int __cdecl _filbuf(FILE *_File);
  125. _CRTIMP int __cdecl _flsbuf(int _Ch,FILE *_File);
  126. #ifdef _POSIX_
  127. _CRTIMP FILE *__cdecl _fsopen(const char *_Filename,const char *_Mode);
  128. #else
  129. _CRTIMP FILE *__cdecl _fsopen(const char *_Filename,const char *_Mode,int _ShFlag);
  130. #endif
  131. void __cdecl clearerr(FILE *_File);
  132. int __cdecl fclose(FILE *_File);
  133. _CRTIMP int __cdecl _fcloseall(void);
  134. #ifdef _POSIX_
  135. FILE *__cdecl fdopen(int _FileHandle,const char *_Mode);
  136. #else
  137. _CRTIMP FILE *__cdecl _fdopen(int _FileHandle,const char *_Mode);
  138. #endif
  139. int __cdecl feof(FILE *_File);
  140. int __cdecl ferror(FILE *_File);
  141. int __cdecl fflush(FILE *_File);
  142. int __cdecl fgetc(FILE *_File);
  143. _CRTIMP int __cdecl _fgetchar(void);
  144. int __cdecl fgetpos(FILE *_File ,fpos_t *_Pos);
  145. char *__cdecl fgets(char *_Buf,int _MaxCount,FILE *_File);
  146. #ifdef _POSIX_
  147. int __cdecl fileno(FILE *_File);
  148. #else
  149. _CRTIMP int __cdecl _fileno(FILE *_File);
  150. #endif
  151. _CRTIMP char *__cdecl _tempnam(const char *_DirName,const char *_FilePrefix);
  152. _CRTIMP int __cdecl _flushall(void);
  153. FILE *__cdecl fopen(const char *_Filename,const char *_Mode);
  154. FILE *fopen64(const char *filename,const char *mode);
  155. int __cdecl fprintf(FILE *_File,const char *_Format,...);
  156. int __cdecl fputc(int _Ch,FILE *_File);
  157. _CRTIMP int __cdecl _fputchar(int _Ch);
  158. int __cdecl fputs(const char *_Str,FILE *_File);
  159. size_t __cdecl fread(void *_DstBuf,size_t _ElementSize,size_t _Count,FILE *_File);
  160. FILE *__cdecl freopen(const char *_Filename,const char *_Mode,FILE *_File);
  161. int __cdecl fscanf(FILE *_File,const char *_Format,...);
  162. int __cdecl fsetpos(FILE *_File,const fpos_t *_Pos);
  163. int __cdecl fseek(FILE *_File,long _Offset,int _Origin);
  164. int fseeko64(FILE* stream, _off64_t offset, int whence);
  165. long __cdecl ftell(FILE *_File);
  166. _off64_t ftello64(FILE * stream);
  167. int __cdecl _fseeki64(FILE *_File,__int64 _Offset,int _Origin);
  168. __int64 __cdecl _ftelli64(FILE *_File);
  169. size_t __cdecl fwrite(const void *_Str,size_t _Size,size_t _Count,FILE *_File);
  170. int __cdecl getc(FILE *_File);
  171. int __cdecl getchar(void);
  172. _CRTIMP int __cdecl _getmaxstdio(void);
  173. char *__cdecl gets(char *_Buffer);
  174. int __cdecl _getw(FILE *_File);
  175. #ifndef _CRT_PERROR_DEFINED
  176. #define _CRT_PERROR_DEFINED
  177. void __cdecl perror(const char *_ErrMsg);
  178. #endif
  179. _CRTIMP int __cdecl _pclose(FILE *_File);
  180. _CRTIMP FILE *__cdecl _popen(const char *_Command,const char *_Mode);
  181. #if !defined(NO_OLDNAMES) && !defined(popen)
  182. #define popen _popen
  183. #define pclose _pclose
  184. #endif
  185. int __cdecl printf(const char *_Format,...);
  186. int __cdecl putc(int _Ch,FILE *_File);
  187. int __cdecl putchar(int _Ch);
  188. int __cdecl puts(const char *_Str);
  189. _CRTIMP int __cdecl _putw(int _Word,FILE *_File);
  190. #ifndef _CRT_DIRECTORY_DEFINED
  191. #define _CRT_DIRECTORY_DEFINED
  192. int __cdecl remove(const char *_Filename);
  193. int __cdecl rename(const char *_OldFilename,const char *_NewFilename);
  194. _CRTIMP int __cdecl _unlink(const char *_Filename);
  195. #ifndef NO_OLDNAMES
  196. int __cdecl unlink(const char *_Filename);
  197. #endif
  198. #endif
  199. void __cdecl rewind(FILE *_File);
  200. _CRTIMP int __cdecl _rmtmp(void);
  201. int __cdecl scanf(const char *_Format,...);
  202. void __cdecl setbuf(FILE *_File,char *_Buffer);
  203. _CRTIMP int __cdecl _setmaxstdio(int _Max);
  204. _CRTIMP unsigned int __cdecl _set_output_format(unsigned int _Format);
  205. _CRTIMP unsigned int __cdecl _get_output_format(void);
  206. int __cdecl setvbuf(FILE *_File,char *_Buf,int _Mode,size_t _Size);
  207. _CRTIMP int __cdecl _scprintf(const char *_Format,...);
  208. int __cdecl sscanf(const char *_Src,const char *_Format,...);
  209. _CRTIMP int __cdecl _snscanf(const char *_Src,size_t _MaxCount,const char *_Format,...);
  210. FILE *__cdecl tmpfile(void);
  211. char *__cdecl tmpnam(char *_Buffer);
  212. int __cdecl ungetc(int _Ch,FILE *_File);
  213. int __cdecl vfprintf(FILE *_File,const char *_Format,va_list _ArgList);
  214. int __cdecl vprintf(const char *_Format,va_list _ArgList);
  215. /* Make sure macros are not defined. */
  216. #pragma push_macro("vsnprintf")
  217. #pragma push_macro("snprintf")
  218. # undef vsnprintf
  219. # undef snprintf
  220. extern
  221. __attribute__((format(gnu_printf, 3, 0))) __attribute__((nonnull (3)))
  222. int __mingw_vsnprintf(char *_DstBuf,size_t _MaxCount,const char *_Format,va_list _ArgList);
  223. extern
  224. __attribute__((format(gnu_printf, 3, 4))) __attribute__((nonnull (3)))
  225. int __mingw_snprintf(char* s, size_t n, const char* format, ...);
  226. int __cdecl vsnprintf(char *_DstBuf,size_t _MaxCount,const char *_Format,va_list _ArgList);
  227. _CRTIMP int __cdecl _snprintf(char *_Dest,size_t _Count,const char *_Format,...);
  228. _CRTIMP int __cdecl _vsnprintf(char *_Dest,size_t _Count,const char *_Format,va_list _Args);
  229. int __cdecl sprintf(char *_Dest,const char *_Format,...);
  230. int __cdecl vsprintf(char *_Dest,const char *_Format,va_list _Args);
  231. #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
  232. int __cdecl snprintf(char* s, size_t n, const char* format, ...);
  233. __CRT_INLINE int __cdecl vsnprintf (char* s, size_t n, const char* format,va_list arg) {
  234. return _vsnprintf ( s, n, format, arg);
  235. }
  236. int __cdecl vscanf(const char * Format, va_list argp);
  237. int __cdecl vfscanf (FILE * fp, const char * Format,va_list argp);
  238. int __cdecl vsscanf (const char * _Str,const char * Format,va_list argp);
  239. #endif
  240. /* Restore may prior defined macros snprintf/vsnprintf. */
  241. #pragma pop_macro("snprintf")
  242. #pragma pop_macro("vsnprintf")
  243. /* Check if vsnprintf and snprintf are defaulting to gnu-style. */
  244. # if defined(USE_MINGW_GNU_SNPRINTF) && USE_MINGW_GNU_SNPRINTF
  245. # ifndef vsnprint
  246. # define vsnprintf __mingw_vsnprintf
  247. # endif
  248. # ifndef snprintf
  249. # define snprintf __mingw_snprintf
  250. # endif
  251. # endif
  252. _CRTIMP int __cdecl _vscprintf(const char *_Format,va_list _ArgList);
  253. _CRTIMP int __cdecl _set_printf_count_output(int _Value);
  254. _CRTIMP int __cdecl _get_printf_count_output(void);
  255. #ifndef _WSTDIO_DEFINED
  256. #ifndef WEOF
  257. #define WEOF (wint_t)(0xFFFF)
  258. #endif
  259. #ifdef _POSIX_
  260. _CRTIMP FILE *__cdecl _wfsopen(const wchar_t *_Filename,const wchar_t *_Mode);
  261. #else
  262. _CRTIMP FILE *__cdecl _wfsopen(const wchar_t *_Filename,const wchar_t *_Mode,int _ShFlag);
  263. #endif
  264. wint_t __cdecl fgetwc(FILE *_File);
  265. _CRTIMP wint_t __cdecl _fgetwchar(void);
  266. wint_t __cdecl fputwc(wchar_t _Ch,FILE *_File);
  267. _CRTIMP wint_t __cdecl _fputwchar(wchar_t _Ch);
  268. wint_t __cdecl getwc(FILE *_File);
  269. wint_t __cdecl getwchar(void);
  270. wint_t __cdecl putwc(wchar_t _Ch,FILE *_File);
  271. wint_t __cdecl putwchar(wchar_t _Ch);
  272. wint_t __cdecl ungetwc(wint_t _Ch,FILE *_File);
  273. wchar_t *__cdecl fgetws(wchar_t *_Dst,int _SizeInWords,FILE *_File);
  274. int __cdecl fputws(const wchar_t *_Str,FILE *_File);
  275. _CRTIMP wchar_t *__cdecl _getws(wchar_t *_String);
  276. _CRTIMP int __cdecl _putws(const wchar_t *_Str);
  277. int __cdecl fwprintf(FILE *_File,const wchar_t *_Format,...);
  278. int __cdecl wprintf(const wchar_t *_Format,...);
  279. _CRTIMP int __cdecl _scwprintf(const wchar_t *_Format,...);
  280. int __cdecl vfwprintf(FILE *_File,const wchar_t *_Format,va_list _ArgList);
  281. int __cdecl vwprintf(const wchar_t *_Format,va_list _ArgList);
  282. _CRTIMP int __cdecl swprintf(wchar_t*, const wchar_t*, ...);
  283. _CRTIMP int __cdecl vswprintf(wchar_t*, const wchar_t*,va_list);
  284. _CRTIMP int __cdecl _swprintf_c(wchar_t *_DstBuf,size_t _SizeInWords,const wchar_t *_Format,...);
  285. _CRTIMP int __cdecl _vswprintf_c(wchar_t *_DstBuf,size_t _SizeInWords,const wchar_t *_Format,va_list _ArgList);
  286. _CRTIMP int __cdecl _snwprintf(wchar_t *_Dest,size_t _Count,const wchar_t *_Format,...);
  287. _CRTIMP int __cdecl _vsnwprintf(wchar_t *_Dest,size_t _Count,const wchar_t *_Format,va_list _Args);
  288. #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
  289. int __cdecl snwprintf (wchar_t* s, size_t n, const wchar_t* format, ...);
  290. __CRT_INLINE int __cdecl vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, va_list arg) { return _vsnwprintf(s,n,format,arg); }
  291. int __cdecl vwscanf (const wchar_t *, va_list);
  292. int __cdecl vfwscanf (FILE *,const wchar_t *,va_list);
  293. int __cdecl vswscanf (const wchar_t *,const wchar_t *,va_list);
  294. #endif
  295. _CRTIMP int __cdecl _swprintf(wchar_t *_Dest,const wchar_t *_Format,...);
  296. _CRTIMP int __cdecl _vswprintf(wchar_t *_Dest,const wchar_t *_Format,va_list _Args);
  297. #ifndef RC_INVOKED
  298. #include <vadefs.h>
  299. #endif
  300. #ifdef _CRT_NON_CONFORMING_SWPRINTFS
  301. #ifndef __cplusplus
  302. #define swprintf _swprintf
  303. #define vswprintf _vswprintf
  304. #define _swprintf_l __swprintf_l
  305. #define _vswprintf_l __vswprintf_l
  306. #endif
  307. #endif
  308. _CRTIMP wchar_t *__cdecl _wtempnam(const wchar_t *_Directory,const wchar_t *_FilePrefix);
  309. _CRTIMP int __cdecl _vscwprintf(const wchar_t *_Format,va_list _ArgList);
  310. int __cdecl fwscanf(FILE *_File,const wchar_t *_Format,...);
  311. int __cdecl swscanf(const wchar_t *_Src,const wchar_t *_Format,...);
  312. _CRTIMP int __cdecl _snwscanf(const wchar_t *_Src,size_t _MaxCount,const wchar_t *_Format,...);
  313. int __cdecl wscanf(const wchar_t *_Format,...);
  314. _CRTIMP FILE *__cdecl _wfdopen(int _FileHandle ,const wchar_t *_Mode);
  315. _CRTIMP FILE *__cdecl _wfopen(const wchar_t *_Filename,const wchar_t *_Mode);
  316. _CRTIMP FILE *__cdecl _wfreopen(const wchar_t *_Filename,const wchar_t *_Mode,FILE *_OldFile);
  317. #ifndef _CRT_WPERROR_DEFINED
  318. #define _CRT_WPERROR_DEFINED
  319. _CRTIMP void __cdecl _wperror(const wchar_t *_ErrMsg);
  320. #endif
  321. _CRTIMP FILE *__cdecl _wpopen(const wchar_t *_Command,const wchar_t *_Mode);
  322. #if !defined(NO_OLDNAMES) && !defined(wpopen)
  323. #define wpopen _wpopen
  324. #endif
  325. _CRTIMP int __cdecl _wremove(const wchar_t *_Filename);
  326. _CRTIMP wchar_t *__cdecl _wtmpnam(wchar_t *_Buffer);
  327. _CRTIMP wint_t __cdecl _fgetwc_nolock(FILE *_File);
  328. _CRTIMP wint_t __cdecl _fputwc_nolock(wchar_t _Ch,FILE *_File);
  329. _CRTIMP wint_t __cdecl _ungetwc_nolock(wint_t _Ch,FILE *_File);
  330. #undef _CRT_GETPUTWCHAR_NOINLINE
  331. #if !defined(__cplusplus) || defined(_CRT_GETPUTWCHAR_NOINLINE)
  332. #define getwchar() fgetwc(stdin)
  333. #define putwchar(_c) fputwc((_c),stdout)
  334. #else
  335. __CRT_INLINE wint_t __cdecl getwchar() { return (fgetwc(stdin)); }
  336. __CRT_INLINE wint_t __cdecl putwchar(wchar_t _C) { return (fputwc(_C,stdout)); }
  337. #endif
  338. #define getwc(_stm) fgetwc(_stm)
  339. #define putwc(_c,_stm) fputwc(_c,_stm)
  340. #define _putwc_nolock(_c,_stm) _fputwc_nolock(_c,_stm)
  341. #define _getwc_nolock(_stm) _fgetwc_nolock(_stm)
  342. #define _WSTDIO_DEFINED
  343. #endif
  344. #define _STDIO_DEFINED
  345. #endif
  346. #define _fgetc_nolock(_stream) (--(_stream)->_cnt >= 0 ? 0xff & *(_stream)->_ptr++ : _filbuf(_stream))
  347. #define _fputc_nolock(_c,_stream) (--(_stream)->_cnt >= 0 ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream)))
  348. #define _getc_nolock(_stream) _fgetc_nolock(_stream)
  349. #define _putc_nolock(_c,_stream) _fputc_nolock(_c,_stream)
  350. #define _getchar_nolock() _getc_nolock(stdin)
  351. #define _putchar_nolock(_c) _putc_nolock((_c),stdout)
  352. #define _getwchar_nolock() _getwc_nolock(stdin)
  353. #define _putwchar_nolock(_c) _putwc_nolock((_c),stdout)
  354. _CRTIMP void __cdecl _lock_file(FILE *_File);
  355. _CRTIMP void __cdecl _unlock_file(FILE *_File);
  356. _CRTIMP int __cdecl _fclose_nolock(FILE *_File);
  357. _CRTIMP int __cdecl _fflush_nolock(FILE *_File);
  358. _CRTIMP size_t __cdecl _fread_nolock(void *_DstBuf,size_t _ElementSize,size_t _Count,FILE *_File);
  359. _CRTIMP int __cdecl _fseek_nolock(FILE *_File,long _Offset,int _Origin);
  360. _CRTIMP long __cdecl _ftell_nolock(FILE *_File);
  361. _CRTIMP int __cdecl _fseeki64_nolock(FILE *_File,__int64 _Offset,int _Origin);
  362. _CRTIMP __int64 __cdecl _ftelli64_nolock(FILE *_File);
  363. _CRTIMP size_t __cdecl _fwrite_nolock(const void *_DstBuf,size_t _Size,size_t _Count,FILE *_File);
  364. _CRTIMP int __cdecl _ungetc_nolock(int _Ch,FILE *_File);
  365. #if !defined(NO_OLDNAMES) || !defined(_POSIX)
  366. #define P_tmpdir _P_tmpdir
  367. #define SYS_OPEN _SYS_OPEN
  368. char *__cdecl tempnam(const char *_Directory,const char *_FilePrefix);
  369. int __cdecl fcloseall(void);
  370. FILE *__cdecl fdopen(int _FileHandle,const char *_Format);
  371. int __cdecl fgetchar(void);
  372. int __cdecl fileno(FILE *_File);
  373. int __cdecl flushall(void);
  374. int __cdecl fputchar(int _Ch);
  375. int __cdecl getw(FILE *_File);
  376. int __cdecl putw(int _Ch,FILE *_File);
  377. int __cdecl rmtmp(void);
  378. #endif
  379. #ifdef __cplusplus
  380. }
  381. #endif
  382. #pragma pack(pop)
  383. #include <sec_api/stdio_s.h>
  384. #endif