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