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