OSDN Git Service

Update several incorrectly attributed header files.
[mingw/mingw-org-wsl.git] / mingwrt / include / stdio.h
1 /*
2  * stdio.h
3  *
4  * Definitions of types and prototypes of functions for operations on
5  * standard input and standard output streams.
6  *
7  * $Id$
8  *
9  * Written by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
10  * Copyright (C) 1997-2005, 2007-2010, 2014-2016, MinGW.org Project.
11  *
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice, this permission notice, and the following
21  * disclaimer shall be included in all copies or substantial portions of
22  * the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
27  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
30  * DEALINGS IN THE SOFTWARE.
31  *
32  * NOTE: The file manipulation functions provided by Microsoft seem to
33  * work with either slash (/) or backslash (\) as the directory separator;
34  * (this is consistent with Microsoft's own documentation, on MSDN).
35  *
36  */
37 #ifndef _STDIO_H
38 #pragma GCC system_header
39
40 /* When including <wchar.h>, some of the definitions and declarations
41  * which are nominally provided in <stdio.h> must be duplicated.  Rather
42  * than require duplicated maintenance effort, we provide for partial
43  * inclusion of <stdio.h> by <wchar.h>; only when not included in
44  * this partial fashion...
45  */
46 #ifndef __WCHAR_H_SOURCED__
47  /*
48   * ...which is exclusive to <wchar.h>, do we assert the multiple
49   * inclusion guard for <stdio.h> itself.
50   */
51 #define _STDIO_H
52 #endif
53
54 /* All the headers include this file.
55  */
56 #include <_mingw.h>
57
58 #ifndef RC_INVOKED
59 /* POSIX stipulates that the following set of types, (as identified by
60  * __need_TYPENAME macros), shall be defined consistently with <stddef.h>;
61  * by defining the appropriate __need_TYPENAME macros, we may selectively
62  * obtain the required definitions by inclusion of <stddef.h>, WITHOUT
63  * automatic exposure of any of its additional content.
64  */
65 #define __need_NULL
66 #define __need_size_t
67 #define __need_wchar_t
68 #define __need_wint_t
69 #include <stddef.h>
70
71 #if _POSIX_C_SOURCE >= 200809L
72  /* Similarly, for types defined in <sys/types.h>, (which are explicitly
73   * dependent on the POSIX.1-2008 feature test)...
74   */
75 # define __need_off_t
76 # define __need_ssize_t
77 #endif
78 #if !(defined __STRICT_ANSI__ || defined (__NO_MINGW_LFS)) \
79  && defined (__MSVCRT__)
80  /* ...while this is required to support our fseeko64() and ftello64()
81   * implementations, (neither of which is in any way standardized)...
82   */
83 # define __need___off64_t
84 #endif
85 /* It is sufficient to test for just one define from each of the two
86  * preceding groups...
87  */
88 #if defined __need_off_t || defined __need___off64_t
89  /* ...to identify a requirement for selective inclusion from...
90   */
91 # include <sys/types.h>
92 #endif
93
94 #ifndef __VALIST
95  /* Also similarly, for the va_list type, defined in <stdarg.h>
96   */
97 # if defined __GNUC__ && __GNUC__ >= 3
98 #  define __need___va_list
99 #  include <stdarg.h>
100 #  define __VALIST __builtin_va_list
101 # else
102 #  define __VALIST char *
103 # endif
104 #endif
105 #endif  /* ! RC_INVOKED */
106
107 #ifdef _STDIO_H
108 /* Flags for the iobuf structure
109  */
110 #define _IOREAD         1       /* currently reading */
111 #define _IOWRT          2       /* currently writing */
112 #define _IORW      0x0080       /* opened as "r+w" */
113
114 /* The three standard file pointers provided by the run time library.
115  * NOTE: These will go to the bit-bucket silently in GUI applications!
116  */
117 #define STDIN_FILENO    0
118 #define STDOUT_FILENO   1
119 #define STDERR_FILENO   2
120
121 /* Returned by various functions on end of file condition or error.
122  */
123 #define EOF           (-1)
124
125 #endif  /* _STDIO_H */
126
127 /* The maximum length of a file name.  It may be better to use the Windows'
128  * GetVolumeInformation() function in preference to this constant, but hey,
129  * this works!  Note that <io.h> also defines it, but we don't guard it, so
130  * that the compiler has a chance to catch inconsistencies.
131  *
132  * FIXME: Right now, we define this unconditionally for both full <stdio.h>
133  * inclusion, and for partial inclusion on behalf of <wchar.h>, (which needs
134  * it for some non-ANSI structure declarations).  The conditions under which
135  * <wchar.h> needs this require review, because defining it as a consequence
136  * of including <wchar.h> alone may violate strict ANSI conformity.
137  */
138 #define FILENAME_MAX  (260)
139
140 #ifdef _STDIO_H
141 /* The maximum number of files that may be open at once. I have set this to
142  * a conservative number. The actual value may be higher.
143  */
144 #define FOPEN_MAX      (20)
145
146 /* After creating this many names, tmpnam and tmpfile return NULL
147  */
148 #define TMP_MAX      32767
149
150 /* Tmpnam, tmpfile and, sometimes, _tempnam try to create
151  * temp files in the root directory of the current drive
152  * (not in pwd, as suggested by some older MS doc's).
153  * Redefining these macros does not effect the CRT functions.
154  */
155 #define _P_tmpdir   "\\"
156 #ifndef __STRICT_ANSI__
157 #define P_tmpdir _P_tmpdir
158 #endif
159 #define _wP_tmpdir  L"\\"
160
161 /* The maximum size of name (including NUL) that will be put in the user
162  * supplied buffer caName for tmpnam.
163  * Inferred from the size of the static buffer returned by tmpnam
164  * when passed a NULL argument. May actually be smaller.
165  */
166 #define L_tmpnam (16)
167
168 #define _IOFBF          0x0000  /* full buffered */
169 #define _IOLBF          0x0040  /* line buffered */
170 #define _IONBF          0x0004  /* not buffered */
171
172 #define _IOMYBUF        0x0008  /* stdio malloc()'d buffer */
173 #define _IOEOF          0x0010  /* EOF reached on read */
174 #define _IOERR          0x0020  /* I/O error from system */
175 #define _IOSTRG         0x0040  /* Strange or no file descriptor */
176 #ifdef _POSIX_SOURCE
177 # define _IOAPPEND      0x0200
178 #endif
179
180 /* The buffer size as used by setbuf such that it is equivalent to
181  * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
182  */
183 #define BUFSIZ             512
184
185 /* Constants for nOrigin indicating the position relative to which fseek
186  * sets the file position.  Defined unconditionally since ISO and POSIX
187  * say they are defined here.
188  */
189 #define SEEK_SET             0
190 #define SEEK_CUR             1
191 #define SEEK_END             2
192
193 #endif  /* _STDIO_H */
194
195 #ifndef RC_INVOKED
196 #if ! (defined _STDIO_H && defined _WCHAR_H)
197 /* The structure underlying the FILE type; this should be defined when
198  * including either <stdio.h> or <wchar.h>.  If both header include guards
199  * are now in place, then we must currently be including <stdio.h> in its
200  * own right, having already processed this block during a prior partial
201  * inclusion by <wchar.h>; there is no need to process it a second time.
202  *
203  * Some believe that nobody in their right mind should make use of the
204  * internals of this structure. Provided by Pedro A. Aranda Gutiirrez
205  * <paag@tid.es>.
206  */
207 typedef struct _iobuf
208 {
209   char  *_ptr;
210   int    _cnt;
211   char  *_base;
212   int    _flag;
213   int    _file;
214   int    _charbuf;
215   int    _bufsiz;
216   char  *_tmpfname;
217 } FILE;
218
219 #endif  /* ! (_STDIO_H && _WCHAR_H) */
220 #ifdef _STDIO_H
221 /* Content to be exposed only when including <stdio.h> in its own right;
222  * these will not be exposed when __WCHAR_H_SOURCE__ is defined, as will
223  * be the case when <stdio.h> is included indirectly, by <wchar.h>
224  *
225  *
226  * The standard file handles
227  */
228 #ifndef __DECLSPEC_SUPPORTED
229
230 extern FILE (*_imp___iob)[];    /* A pointer to an array of FILE */
231
232 #define _iob (*_imp___iob)      /* An array of FILE */
233
234 #else /* __DECLSPEC_SUPPORTED */
235
236 __MINGW_IMPORT FILE _iob[];     /* An array of FILE imported from DLL. */
237
238 #endif /* __DECLSPEC_SUPPORTED */
239
240 #define stdin   (&_iob[STDIN_FILENO])
241 #define stdout  (&_iob[STDOUT_FILENO])
242 #define stderr  (&_iob[STDERR_FILENO])
243
244 /* Need to close the current _STDIO_H specific block here...
245  */
246 #endif
247 /* ...because, we need this regardless of the inclusion mode...
248  */
249 _BEGIN_C_DECLS
250
251 #ifdef _STDIO_H
252 /* ...then revert to _STDIO_H specific mode, to declare...
253  *
254  *
255  * File Operations
256  */
257 _CRTIMP __cdecl __MINGW_NOTHROW  FILE * fopen (const char *, const char *);
258 _CRTIMP __cdecl __MINGW_NOTHROW  FILE * freopen (const char *, const char *, FILE *);
259 _CRTIMP __cdecl __MINGW_NOTHROW  int    fflush (FILE *);
260 _CRTIMP __cdecl __MINGW_NOTHROW  int    fclose (FILE *);
261
262 /* Note: Microsoft also declares remove & rename (but not their wide char
263  * variants) in <io.h>; since duplicate prototypes are acceptable, provided
264  * they are consistent, we simply declare them here anyway, while allowing
265  * the compiler to check consistency as appropriate.
266  */
267 _CRTIMP __cdecl __MINGW_NOTHROW  int    remove (const char *);
268 _CRTIMP __cdecl __MINGW_NOTHROW  int    rename (const char *, const char *);
269 _CRTIMP __cdecl __MINGW_NOTHROW  FILE * tmpfile (void);
270 _CRTIMP __cdecl __MINGW_NOTHROW  char * tmpnam (char *);
271
272 #ifndef __STRICT_ANSI__
273 _CRTIMP __cdecl __MINGW_NOTHROW  char *_tempnam (const char *, const char *);
274 _CRTIMP __cdecl __MINGW_NOTHROW  int   _rmtmp (void);
275 _CRTIMP __cdecl __MINGW_NOTHROW  int   _unlink (const char *);
276
277 #ifndef NO_OLDNAMES
278 _CRTIMP __cdecl __MINGW_NOTHROW  char * tempnam (const char *, const char *);
279 _CRTIMP __cdecl __MINGW_NOTHROW  int    rmtmp (void);
280 _CRTIMP __cdecl __MINGW_NOTHROW  int    unlink (const char *);
281 #endif
282 #endif /* __STRICT_ANSI__ */
283
284 _CRTIMP __cdecl __MINGW_NOTHROW  int    setvbuf (FILE *, char *, int, size_t);
285 _CRTIMP __cdecl __MINGW_NOTHROW  void   setbuf (FILE *, char *);
286
287 /* Formatted Output
288  *
289  * MSVCRT implementations are not ANSI C99 conformant...
290  * we offer these conforming alternatives from libmingwex.a
291  */
292 #undef  __mingw_stdio_redirect__
293 #define __mingw_stdio_redirect__(F) __cdecl __MINGW_NOTHROW __mingw_##F
294
295 extern int __mingw_stdio_redirect__(fprintf)(FILE*, const char*, ...);
296 extern int __mingw_stdio_redirect__(printf)(const char*, ...);
297 extern int __mingw_stdio_redirect__(sprintf)(char*, const char*, ...);
298 extern int __mingw_stdio_redirect__(snprintf)(char*, size_t, const char*, ...);
299 extern int __mingw_stdio_redirect__(vfprintf)(FILE*, const char*, __VALIST);
300 extern int __mingw_stdio_redirect__(vprintf)(const char*, __VALIST);
301 extern int __mingw_stdio_redirect__(vsprintf)(char*, const char*, __VALIST);
302 extern int __mingw_stdio_redirect__(vsnprintf)(char*, size_t, const char*, __VALIST);
303
304 /* When using these C99 conforming alternatives, we may wish to support
305  * some of Microsoft's quirky formatting options, even when they violate
306  * strict C99 conformance.
307  */
308 #define _MSVC_PRINTF_QUIRKS             0x0100U
309 #define _QUERY_MSVC_PRINTF_QUIRKS       ~0U, 0U
310 #define _DISABLE_MSVC_PRINTF_QUIRKS     ~_MSVC_PRINTF_QUIRKS, 0U
311 #define _ENABLE_MSVC_PRINTF_QUIRKS      ~0U, _MSVC_PRINTF_QUIRKS
312
313 /* Those quirks which conflict with ANSI C99 specified behaviour are
314  * disabled by default; use the following function, like this:
315  *
316  *   _mingw_output_format_control( _ENABLE_MSVC_PRINTF_QUIRKS );
317  *
318  * to enable them, like this:
319  *
320  *   state = _mingw_output_format_control( _QUERY_MSVC_PRINTF_QUIRKS )
321  *              & _MSVC_PRINTF_QUIRKS;
322  *
323  * to ascertain the currently active enabled state, or like this:
324  *
325  *   _mingw_output_format_control( _DISABLE_MSVC_PRINTF_QUIRKS );
326  *
327  * to disable them again.
328  */
329 extern unsigned int _mingw_output_format_control( unsigned int, unsigned int );
330
331 #if __USE_MINGW_ANSI_STDIO
332 /* User has expressed a preference for C99 conformance...
333  */
334 # undef __mingw_stdio_redirect__
335 # ifdef __cplusplus
336 /* For C++ we use inline implementations, to avoid interference
337  * with namespace qualification, which may result from using #defines.
338  */
339 #  define __mingw_stdio_redirect__  inline __cdecl __MINGW_NOTHROW
340
341 # elif defined __GNUC__
342 /* FIXME: Is there any GCC version prerequisite here?
343  *
344  * We also prefer inline implementations for C, when we can be confident
345  * that the GNU specific __inline__ mechanism is supported.
346  */
347 #  define __mingw_stdio_redirect__  static __inline__ __cdecl __MINGW_NOTHROW
348
349 # else
350 /* Can't use inlines; fall back on module local static stubs.
351  */
352 #  define __mingw_stdio_redirect__  static __cdecl __MINGW_NOTHROW
353 # endif
354
355 __mingw_stdio_redirect__
356 int fprintf (FILE *__stream, const char *__format, ...)
357 {
358   register int __retval;
359   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
360   __retval = __mingw_vfprintf( __stream, __format, __local_argv );
361   __builtin_va_end( __local_argv );
362   return __retval;
363 }
364
365 __mingw_stdio_redirect__
366 int printf (const char *__format, ...)
367 {
368   register int __retval;
369   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
370   __retval = __mingw_vprintf( __format, __local_argv );
371   __builtin_va_end( __local_argv );
372   return __retval;
373 }
374
375 __mingw_stdio_redirect__
376 int sprintf (char *__stream, const char *__format, ...)
377 {
378   register int __retval;
379   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
380   __retval = __mingw_vsprintf( __stream, __format, __local_argv );
381   __builtin_va_end( __local_argv );
382   return __retval;
383 }
384
385 __mingw_stdio_redirect__
386 int vfprintf (FILE *__stream, const char *__format, __VALIST __local_argv)
387 {
388   return __mingw_vfprintf( __stream, __format, __local_argv );
389 }
390
391 __mingw_stdio_redirect__
392 int vprintf (const char *__format, __VALIST __local_argv)
393 {
394   return __mingw_vprintf( __format, __local_argv );
395 }
396
397 __mingw_stdio_redirect__
398 int vsprintf (char *__stream, const char *__format, __VALIST __local_argv)
399 {
400   return __mingw_vsprintf( __stream, __format, __local_argv );
401 }
402
403 #else
404 /* Default configuration: simply direct all calls to MSVCRT...
405  */
406 _CRTIMP __cdecl __MINGW_NOTHROW  int fprintf (FILE *, const char *, ...);
407 _CRTIMP __cdecl __MINGW_NOTHROW  int printf (const char *, ...);
408 _CRTIMP __cdecl __MINGW_NOTHROW  int sprintf (char *, const char *, ...);
409 _CRTIMP __cdecl __MINGW_NOTHROW  int vfprintf (FILE *, const char *, __VALIST);
410 _CRTIMP __cdecl __MINGW_NOTHROW  int vprintf (const char *, __VALIST);
411 _CRTIMP __cdecl __MINGW_NOTHROW  int vsprintf (char *, const char *, __VALIST);
412
413 #endif
414 /* Regardless of user preference, always offer these alternative
415  * entry points, for direct access to the MSVCRT implementations.
416  */
417 #undef  __mingw_stdio_redirect__
418 #define __mingw_stdio_redirect__(F) __cdecl __MINGW_NOTHROW __msvcrt_##F
419
420 _CRTIMP int __mingw_stdio_redirect__(fprintf)(FILE *, const char *, ...);
421 _CRTIMP int __mingw_stdio_redirect__(printf)(const char *, ...);
422 _CRTIMP int __mingw_stdio_redirect__(sprintf)(char *, const char *, ...);
423 _CRTIMP int __mingw_stdio_redirect__(vfprintf)(FILE *, const char *, __VALIST);
424 _CRTIMP int __mingw_stdio_redirect__(vprintf)(const char *, __VALIST);
425 _CRTIMP int __mingw_stdio_redirect__(vsprintf)(char *, const char *, __VALIST);
426
427 #undef  __mingw_stdio_redirect__
428
429 /* The following three ALWAYS refer to the MSVCRT implementations...
430  */
431 _CRTIMP __cdecl __MINGW_NOTHROW  int _snprintf (char *, size_t, const char *, ...);
432 _CRTIMP __cdecl __MINGW_NOTHROW  int _vsnprintf (char *, size_t, const char *, __VALIST);
433 _CRTIMP __cdecl __MINGW_NOTHROW  int _vscprintf (const char *, __VALIST);
434
435 #ifdef _ISOC99_SOURCE
436 /* Microsoft does not provide implementations for the following,
437  * which are required by C99.  Note in particular that Microsoft's
438  * corresponding implementations of _snprintf() and _vsnprintf() are
439  * NOT compatible with C99, but the following are; if you want the
440  * MSVCRT behaviour, you MUST use the Microsoft "uglified" names.
441  */
442 __cdecl __MINGW_NOTHROW  int snprintf (char *, size_t, const char *, ...);
443 __cdecl __MINGW_NOTHROW  int vsnprintf (char *, size_t, const char *, __VALIST);
444
445 __cdecl __MINGW_NOTHROW  int vscanf (const char * __restrict__, __VALIST);
446
447 __cdecl __MINGW_NOTHROW
448 int vfscanf (FILE * __restrict__, const char * __restrict__, __VALIST);
449
450 __cdecl __MINGW_NOTHROW
451 int vsscanf (const char * __restrict__, const char * __restrict__, __VALIST);
452
453 #endif  /* _ISOC99_SOURCE */
454 #if __MSVCRT_VERSION__ >= __MSVCR80_DLL || _WIN32_WINNT >= _WIN32_WINNT_VISTA
455 /*
456  * In MSVCR80.DLL, (and its descendants), Microsoft introduced variants
457  * of the printf() functions, with names qualified by an underscore prefix
458  * and "_p" or "_p_l" suffixes; implemented in Microsoft's typically crass,
459  * non-standard, and non-portable fashion, these provide support for access
460  * to printf() arguments in random order, as was standardised by POSIX as a
461  * feature of the optional Extended Systems Interface (XSI) specification,
462  * and is now required for conformity with the POSIX.1-2008 base standard.
463  * Although these additional Microsoft functions were subsequently added
464  * to MSVCRT.DLL, from Windows-Vista onward, and they are prototyped here,
465  * MinGW applications are strenuously encouraged to avoid using them; a
466  * much better alternative is to "#define _XOPEN_SOURCE 700" before any
467  * system header is included, then use POSIX standard printf() functions
468  * instead; this is both portable to many non-Windows platforms, and it
469  * offers better compatibility with earlier Windows versions.
470  */
471 _CRTIMP __cdecl __MINGW_NOTHROW
472 int _printf_p (const char *, ...);
473
474 _CRTIMP __cdecl __MINGW_NOTHROW
475 int _fprintf_p (FILE *, const char *, ...);
476
477 _CRTIMP __cdecl __MINGW_NOTHROW
478 int _sprintf_p (char *, size_t, const char *, ...);
479
480 _CRTIMP __cdecl __MINGW_NOTHROW
481 int _vprintf_p (const char *, __VALIST);
482
483 _CRTIMP __cdecl __MINGW_NOTHROW
484 int _vfprintf_p (FILE *, const char *, __VALIST);
485
486 _CRTIMP __cdecl __MINGW_NOTHROW
487 int _vsprintf_p (char *, size_t, const char *, __VALIST);
488
489 _CRTIMP __cdecl __MINGW_NOTHROW
490 int _printf_p_l (const char *, locale_t, ...);
491
492 _CRTIMP __cdecl __MINGW_NOTHROW
493 int _fprintf_p_l (FILE *, const char *, locale_t, ...);
494
495 _CRTIMP __cdecl __MINGW_NOTHROW
496 int _sprintf_p_l (char *, size_t, const char *, locale_t, ...);
497
498 _CRTIMP __cdecl __MINGW_NOTHROW
499 int _vprintf_p_l (const char *, locale_t, __VALIST);
500
501 _CRTIMP __cdecl __MINGW_NOTHROW
502 int _vfprintf_p_l (FILE *, const char *, locale_t, __VALIST);
503
504 _CRTIMP __cdecl __MINGW_NOTHROW
505 int _vsprintf_p_l (char *, size_t, const char *, locale_t, __VALIST);
506
507 #endif  /* MSVCR80.DLL and descendants, or MSVCRT.DLL since Vista */
508 #endif  /* <stdio.h> included in its own right */
509 #if ! (defined _STDIO_H && defined _WCHAR_H) \
510  && __MSVCRT_VERSION__ >= __MSVCR80_DLL || _WIN32_WINNT >= _WIN32_WINNT_VISTA
511 /*
512  * Wide character variants of the foregoing "positional parameter" printf()
513  * functions; MSDN says that these should be declared when either <stdio.h>, or
514  * <wchar.h> is included, so we make them selectively available to <wchar.h>,
515  * but, just as in the foregoing, we advise against their use.
516  */
517 _CRTIMP __cdecl __MINGW_NOTHROW
518 int _wprintf_p (const wchar_t *, ...);
519
520 _CRTIMP __cdecl __MINGW_NOTHROW
521 int _fwprintf_p (FILE *, const wchar_t *, ...);
522
523 _CRTIMP __cdecl __MINGW_NOTHROW
524 int _swprintf_p (wchar_t *, size_t, const wchar_t *, ...);
525
526 _CRTIMP __cdecl __MINGW_NOTHROW
527 int _vwprintf_p (const wchar_t *, __VALIST);
528
529 _CRTIMP __cdecl __MINGW_NOTHROW
530 int _vfwprintf_p (FILE *, const wchar_t *, __VALIST);
531
532 _CRTIMP __cdecl __MINGW_NOTHROW
533 int _vswprintf_p (wchar_t *, size_t, const wchar_t *, __VALIST);
534
535 _CRTIMP __cdecl __MINGW_NOTHROW
536 int _wprintf_p_l (const wchar_t *, locale_t, ...);
537
538 _CRTIMP __cdecl __MINGW_NOTHROW
539 int _fwprintf_p_l (FILE *, const wchar_t *, locale_t, ...);
540
541 _CRTIMP __cdecl __MINGW_NOTHROW
542 int _swprintf_p_l (wchar_t *, size_t, const wchar_t *, locale_t, ...);
543
544 _CRTIMP __cdecl __MINGW_NOTHROW
545 int _vwprintf_p_l (const wchar_t *, locale_t, __VALIST);
546
547 _CRTIMP __cdecl __MINGW_NOTHROW
548 int _vfwprintf_p_l (FILE *, const wchar_t *, locale_t, __VALIST);
549
550 _CRTIMP __cdecl __MINGW_NOTHROW
551 int _vswprintf_p_l (wchar_t *, size_t, const wchar_t *, locale_t, __VALIST);
552
553 #endif  /* ! (defined _STDIO_H && defined _WCHAR_H) */
554 #ifdef _STDIO_H
555 /* Once again, back to <stdio.h> specific declarations.
556  */
557
558 /* Formatted Input
559  */
560 _CRTIMP __cdecl __MINGW_NOTHROW  int    fscanf (FILE *, const char *, ...);
561 _CRTIMP __cdecl __MINGW_NOTHROW  int    scanf (const char *, ...);
562 _CRTIMP __cdecl __MINGW_NOTHROW  int    sscanf (const char *, const char *, ...);
563
564 /* Character Input and Output Functions
565  */
566 _CRTIMP __cdecl __MINGW_NOTHROW  int    fgetc (FILE *);
567 _CRTIMP __cdecl __MINGW_NOTHROW  char * fgets (char *, int, FILE *);
568 _CRTIMP __cdecl __MINGW_NOTHROW  int    fputc (int, FILE *);
569 _CRTIMP __cdecl __MINGW_NOTHROW  int    fputs (const char *, FILE *);
570 _CRTIMP __cdecl __MINGW_NOTHROW  char * gets (char *);
571 _CRTIMP __cdecl __MINGW_NOTHROW  int    puts (const char *);
572 _CRTIMP __cdecl __MINGW_NOTHROW  int    ungetc (int, FILE *);
573
574 /* Traditionally, getc and putc are defined as macros. but the
575  * standard doesn't say that they must be macros.  We use inline
576  * functions here to allow the fast versions to be used in C++
577  * with namespace qualification, eg., ::getc.
578  *
579  * NOTE: _filbuf and _flsbuf  are not thread-safe.
580  */
581 _CRTIMP __cdecl __MINGW_NOTHROW  int   _filbuf (FILE *);
582 _CRTIMP __cdecl __MINGW_NOTHROW  int   _flsbuf (int, FILE *);
583
584 #if !defined _MT
585
586 __CRT_INLINE __cdecl __MINGW_NOTHROW  int getc (FILE * __F)
587 {
588   return (--__F->_cnt >= 0)
589     ?  (int) (unsigned char) *__F->_ptr++
590     : _filbuf (__F);
591 }
592
593 __CRT_INLINE __cdecl __MINGW_NOTHROW  int putc (int __c, FILE * __F)
594 {
595   return (--__F->_cnt >= 0)
596     ?  (int) (unsigned char) (*__F->_ptr++ = (char)__c)
597     :  _flsbuf (__c, __F);
598 }
599
600 __CRT_INLINE __cdecl __MINGW_NOTHROW  int getchar (void)
601 {
602   return (--stdin->_cnt >= 0)
603     ?  (int) (unsigned char) *stdin->_ptr++
604     : _filbuf (stdin);
605 }
606
607 __CRT_INLINE __cdecl __MINGW_NOTHROW  int putchar(int __c)
608 {
609   return (--stdout->_cnt >= 0)
610     ?  (int) (unsigned char) (*stdout->_ptr++ = (char)__c)
611     :  _flsbuf (__c, stdout);}
612
613 #else  /* Use library functions.  */
614
615 _CRTIMP __cdecl __MINGW_NOTHROW  int    getc (FILE *);
616 _CRTIMP __cdecl __MINGW_NOTHROW  int    putc (int, FILE *);
617 _CRTIMP __cdecl __MINGW_NOTHROW  int    getchar (void);
618 _CRTIMP __cdecl __MINGW_NOTHROW  int    putchar (int);
619
620 #endif
621
622 /* Direct Input and Output Functions
623  */
624 _CRTIMP __cdecl __MINGW_NOTHROW  size_t fread (void *, size_t, size_t, FILE *);
625 _CRTIMP __cdecl __MINGW_NOTHROW  size_t fwrite (const void *, size_t, size_t, FILE *);
626
627 /* File Positioning Functions
628  */
629 _CRTIMP __cdecl __MINGW_NOTHROW  int    fseek (FILE *, long, int);
630 _CRTIMP __cdecl __MINGW_NOTHROW  long   ftell (FILE *);
631 _CRTIMP __cdecl __MINGW_NOTHROW  void   rewind (FILE *);
632
633 #if _WIN32_WINNT >= _WIN32_WINNT_VISTA || __MSVCRT_VERSION__ >= __MSVCR80_DLL
634  /*
635   * Microsoft introduced a number of variations on fseek() and ftell(),
636   * beginning with MSVCR80.DLL; the bare _fseeki64() and _ftelli64() were
637   * subsequently integrated into MSVCRT.DLL, from Vista onward...
638   */
639 _CRTIMP __cdecl __MINGW_NOTHROW  int    _fseeki64 (FILE *, __int64, int);
640 _CRTIMP __cdecl __MINGW_NOTHROW __int64 _ftelli64 (FILE *);
641
642 #if __MSVCRT_VERSION__ >= __MSVCR80_DLL
643  /*
644   * ...while the "nolock" variants remain exclusive to MSVCR80.DLL, and
645   * its later MSVC specific derivatives.
646   */
647 _CRTIMP __cdecl __MINGW_NOTHROW  int    _fseek_nolock (FILE *, long, int);
648 _CRTIMP __cdecl __MINGW_NOTHROW  long   _ftell_nolock (FILE *);
649
650 _CRTIMP __cdecl __MINGW_NOTHROW  int    _fseeki64_nolock (FILE *, __int64, int);
651 _CRTIMP __cdecl __MINGW_NOTHROW __int64 _ftelli64_nolock (FILE *);
652
653 #endif  /* MSVCR80.DLL and later derivatives ONLY */
654 #endif  /* MSVCR80.DLL and descendants, or MSVCRT.DLL since Vista */
655
656 #ifdef __USE_MINGW_FSEEK
657 /* Workaround for a limitation on Win9x where a file is not zero padded
658  * on write, following a seek beyond the original end of file; these are
659  * implemented in libmingwex.a
660  */
661 __cdecl __MINGW_NOTHROW  int    __mingw_fseek (FILE *, long, int);
662 __cdecl __MINGW_NOTHROW  size_t __mingw_fwrite (const void *, size_t, size_t, FILE *);
663
664 #define fwrite(buffer, size, count, fp)  __mingw_fwrite(buffer, size, count, fp)
665 #define fseek(fp, offset, whence)        __mingw_fseek(fp, offset, whence)
666 #endif /* __USE_MINGW_FSEEK */
667
668 /* An opaque data type used for storing file positions... The contents of
669  * this type are unknown, but we (the compiler) need to know the size
670  * because the programmer using fgetpos and fsetpos will be setting aside
671  * storage for fpos_t structres. Actually I tested using a byte array and
672  * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
673  * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in
674  * MSVCRT however, and for now `long long' will do.
675  */
676 #ifdef __MSVCRT__
677 typedef long long  fpos_t;
678 #else
679 typedef long       fpos_t;
680 #endif
681
682 _CRTIMP __cdecl __MINGW_NOTHROW  int fgetpos (FILE *, fpos_t *);
683 _CRTIMP __cdecl __MINGW_NOTHROW  int fsetpos (FILE *, const fpos_t *);
684
685 /* Error Functions
686  */
687 _CRTIMP __cdecl __MINGW_NOTHROW  int feof (FILE *);
688 _CRTIMP __cdecl __MINGW_NOTHROW  int ferror (FILE *);
689
690 #ifdef __cplusplus
691 inline __cdecl __MINGW_NOTHROW  int feof (FILE * __F){ return __F->_flag & _IOEOF; }
692 inline __cdecl __MINGW_NOTHROW  int ferror (FILE * __F){ return __F->_flag & _IOERR; }
693 #else
694 #define feof(__F)     ((__F)->_flag & _IOEOF)
695 #define ferror(__F)   ((__F)->_flag & _IOERR)
696 #endif
697
698 _CRTIMP __cdecl __MINGW_NOTHROW  void clearerr (FILE *);
699 _CRTIMP __cdecl __MINGW_NOTHROW  void perror (const char *);
700
701
702 #ifndef __STRICT_ANSI__
703 /*
704  * Pipes
705  */
706 _CRTIMP __cdecl __MINGW_NOTHROW  FILE * _popen (const char *, const char *);
707 _CRTIMP __cdecl __MINGW_NOTHROW  int    _pclose (FILE *);
708
709 #ifndef NO_OLDNAMES
710 _CRTIMP __cdecl __MINGW_NOTHROW  FILE *  popen (const char *, const char *);
711 _CRTIMP __cdecl __MINGW_NOTHROW  int     pclose (FILE *);
712 #endif
713
714 /* Other Non ANSI functions
715  */
716 _CRTIMP __cdecl __MINGW_NOTHROW  int    _flushall (void);
717 _CRTIMP __cdecl __MINGW_NOTHROW  int    _fgetchar (void);
718 _CRTIMP __cdecl __MINGW_NOTHROW  int    _fputchar (int);
719 _CRTIMP __cdecl __MINGW_NOTHROW  FILE * _fdopen (int, const char *);
720 _CRTIMP __cdecl __MINGW_NOTHROW  int    _fileno (FILE *);
721 _CRTIMP __cdecl __MINGW_NOTHROW  int    _fcloseall (void);
722 _CRTIMP __cdecl __MINGW_NOTHROW  FILE * _fsopen (const char *, const char *, int);
723 #ifdef __MSVCRT__
724 _CRTIMP __cdecl __MINGW_NOTHROW  int    _getmaxstdio (void);
725 _CRTIMP __cdecl __MINGW_NOTHROW  int    _setmaxstdio (int);
726 #endif
727
728 /* Microsoft introduced a capability in MSVCR80.DLL and later, to
729  * set the minimum number of digits to be displayed in a printf()
730  * floating point exponent; they retro-fitted this in MSVCRT.DLL,
731  * from Windows-Vista onwards, but we provide our own wrappers in
732  * libmingwex.a, which make it possible for us to emulate the API
733  * for any version of MSVCRT.DLL (including WinXP and earlier).
734  */
735 #define _TWO_DIGIT_EXPONENT    1
736
737 /* While Microsoft define the preceding manifest constant, they
738  * appear to neglect to define its complement, (for restoration
739  * of their default exponent display format); for orthogonality,
740  * we will provide this regardless of Microsoft's negligence.
741  */
742 #define _THREE_DIGIT_EXPONENT  0
743
744 /* Once again, unspecified by Microsoft, (and mostly redundant),
745  * it is convenient to specify a combining mask for these.
746  */
747 #define _EXPONENT_DIGIT_MASK  (_TWO_DIGIT_EXPONENT | _THREE_DIGIT_EXPONENT)
748
749 unsigned int __cdecl __mingw_get_output_format (void);
750 unsigned int __cdecl __mingw_set_output_format (unsigned int);
751
752 /* Also appearing for the first time in MSVCR80.DLL, and then also
753  * retro-fitted to MSVCRT.DLL from Windows-Vista onwards, was this
754  * pair of functions to control availability of "%n" formatting in
755  * the MSVCRT.DLL printf() family of functions, for which we also
756  * provide our own DLL version agnostic wrappers:
757  */
758 int __cdecl __mingw_get_printf_count_output (void);
759 int __cdecl __mingw_set_printf_count_output (int);
760
761 #if __MSVCRT_VERSION__ >= __MSVCR80_DLL
762 /* When the user declares that MSVCR80.DLL features are supported,
763  * we simply expose the corresponding APIs...
764  */
765 _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _get_output_format (void);
766 _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _set_output_format (unsigned int);
767
768 _CRTIMP __cdecl __MINGW_NOTHROW  int _get_printf_count_output (void);
769 _CRTIMP __cdecl __MINGW_NOTHROW  int _set_printf_count_output (int);
770
771 #else
772 /* ...otherwise, we emulate the APIs, in a DLL version agnostic
773  * manner, using our own implementation wrappers.
774  */
775 __CRT_ALIAS unsigned int __cdecl _get_output_format (void)
776 { return __mingw_get_output_format (); }
777
778 __CRT_ALIAS unsigned int __cdecl _set_output_format (unsigned int __style)
779 { return __mingw_set_output_format (__style); }
780
781 /* When using our own printf() implementation, "%n" format is ALWAYS
782  * supported, so we make this API a no-op, reporting it to be so; for
783  * the alternative case, when using MSVCRT.DLL's printf(), we delegate
784  * to our wrapper API implementation, which will invoke the API function
785  * calls within the DLL, if they are available, or persistently report
786  * the state of "%n" formatting as DISABLED if they are not.
787  */
788 #if __USE_MINGW_ANSI_STDIO
789 /* Note that __USE_MINGW_ANSI_STDIO is not guaranteed to resolve to any
790  * symbol which will represent a compilable logic state; map it to this
791  * alternative which will, for the true state...
792  */
793 # define __USE_MINGW_PRINTF  1
794 #else
795 /* ...and for the false.
796  */
797 # define __USE_MINGW_PRINTF  0
798 #endif
799
800 __CRT_ALIAS int __cdecl _get_printf_count_output (void)
801 { return __USE_MINGW_PRINTF ? 1 : __mingw_get_printf_count_output (); }
802
803 __CRT_ALIAS int __cdecl _set_printf_count_output (int __mode)
804 { return __USE_MINGW_PRINTF ? 1 : __mingw_set_printf_count_output (__mode); }
805 #endif
806
807 #ifndef _NO_OLDNAMES
808 _CRTIMP __cdecl __MINGW_NOTHROW  int    fgetchar (void);
809 _CRTIMP __cdecl __MINGW_NOTHROW  int    fputchar (int);
810 _CRTIMP __cdecl __MINGW_NOTHROW  FILE * fdopen (int, const char *);
811 _CRTIMP __cdecl __MINGW_NOTHROW  int    fileno (FILE *);
812 #endif  /* !_NO_OLDNAMES */
813
814 #define _fileno(__F) ((__F)->_file)
815 #ifndef _NO_OLDNAMES
816 #define fileno(__F) ((__F)->_file)
817 #endif
818
819 #if defined (__MSVCRT__) && ! defined (__NO_MINGW_LFS)
820 __CRT_INLINE __JMPSTUB__(( FUNCTION = fopen64, REMAPPED = fopen ))
821 FILE * __cdecl __MINGW_NOTHROW  fopen64 (const char * filename, const char * mode)
822 { return fopen (filename, mode); }
823
824 int __cdecl __MINGW_NOTHROW  fseeko64 (FILE *, __off64_t, int);
825
826 #ifdef __USE_MINGW_FSEEK
827 int __cdecl __MINGW_NOTHROW __mingw_fseeko64 (FILE *, __off64_t, int);
828 #define fseeko64(fp, offset, whence)  __mingw_fseeko64(fp, offset, whence)
829 #endif
830
831 __CRT_INLINE __LIBIMPL__(( FUNCTION = ftello64 ))
832 __off64_t __cdecl __MINGW_NOTHROW ftello64 (FILE * stream)
833 { fpos_t __pos; return (fgetpos(stream, &__pos)) ? -1LL : (__off64_t)(__pos); }
834
835 #endif  /* __MSVCRT__ && !__NO_MINGW_LFS */
836 #endif  /* !__STRICT_ANSI__ */
837 #endif  /* _STDIO_H */
838
839 #if ! (defined _STDIO_H && defined _WCHAR_H)
840 /* The following are declared when including either <stdio.h> or <wchar.h>.
841  * If both header include guards are now in place, then we must currently be
842  * including <stdio.h> in its own right, having already processed this block
843  * during prior partial inclusion by <wchar.h>; there is no need to process
844  * it a second time.
845  */
846 _CRTIMP __cdecl __MINGW_NOTHROW  int     fwprintf (FILE *, const wchar_t *, ...);
847 _CRTIMP __cdecl __MINGW_NOTHROW  int     wprintf (const wchar_t *, ...);
848 _CRTIMP __cdecl __MINGW_NOTHROW  int     vfwprintf (FILE *, const wchar_t *, __VALIST);
849 _CRTIMP __cdecl __MINGW_NOTHROW  int     vwprintf (const wchar_t *, __VALIST);
850 _CRTIMP __cdecl __MINGW_NOTHROW  int    _snwprintf (wchar_t *, size_t, const wchar_t *, ...);
851 _CRTIMP __cdecl __MINGW_NOTHROW  int    _vscwprintf (const wchar_t *, __VALIST);
852 _CRTIMP __cdecl __MINGW_NOTHROW  int    _vsnwprintf (wchar_t *, size_t, const wchar_t *, __VALIST);
853 _CRTIMP __cdecl __MINGW_NOTHROW  int     fwscanf (FILE *, const wchar_t *, ...);
854 _CRTIMP __cdecl __MINGW_NOTHROW  int     wscanf (const wchar_t *, ...);
855 _CRTIMP __cdecl __MINGW_NOTHROW  int     swscanf (const wchar_t *, const wchar_t *, ...);
856 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t  fgetwc (FILE *);
857 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t  fputwc (wchar_t, FILE *);
858 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t  ungetwc (wchar_t, FILE *);
859
860 #ifndef __STRICT_ANSI__
861 /* These differ from the ISO C prototypes, which have a maxlen parameter (like snprintf).
862  */
863 _CRTIMP __cdecl __MINGW_NOTHROW  int  swprintf (wchar_t *, const wchar_t *, ...);
864 _CRTIMP __cdecl __MINGW_NOTHROW  int  vswprintf (wchar_t *, const wchar_t *, __VALIST);
865 #endif
866
867 #ifdef __MSVCRT__
868 _CRTIMP __cdecl __MINGW_NOTHROW  wchar_t * fgetws (wchar_t *, int, FILE *);
869 _CRTIMP __cdecl __MINGW_NOTHROW  int       fputws (const wchar_t *, FILE *);
870 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t    getwc (FILE *);
871 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t    getwchar (void);
872 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t    putwc (wint_t, FILE *);
873 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t    putwchar (wint_t);
874
875 #ifndef __STRICT_ANSI__
876 _CRTIMP __cdecl __MINGW_NOTHROW  wchar_t * _getws (wchar_t *);
877 _CRTIMP __cdecl __MINGW_NOTHROW  int       _putws (const wchar_t *);
878 _CRTIMP __cdecl __MINGW_NOTHROW  FILE    * _wfdopen(int, const wchar_t *);
879 _CRTIMP __cdecl __MINGW_NOTHROW  FILE    * _wfopen (const wchar_t *, const wchar_t *);
880 _CRTIMP __cdecl __MINGW_NOTHROW  FILE    * _wfreopen (const wchar_t *, const wchar_t *, FILE *);
881 _CRTIMP __cdecl __MINGW_NOTHROW  FILE    * _wfsopen (const wchar_t *, const wchar_t *, int);
882 _CRTIMP __cdecl __MINGW_NOTHROW  wchar_t * _wtmpnam (wchar_t *);
883 _CRTIMP __cdecl __MINGW_NOTHROW  wchar_t * _wtempnam (const wchar_t *, const wchar_t *);
884 _CRTIMP __cdecl __MINGW_NOTHROW  int       _wrename (const wchar_t *, const wchar_t *);
885 _CRTIMP __cdecl __MINGW_NOTHROW  int       _wremove (const wchar_t *);
886 _CRTIMP __cdecl __MINGW_NOTHROW  void      _wperror (const wchar_t *);
887 _CRTIMP __cdecl __MINGW_NOTHROW  FILE    * _wpopen (const wchar_t *, const wchar_t *);
888
889 #endif  /* !__STRICT_ANSI__ */
890 #endif  /* __MSVCRT__ */
891
892 #ifdef _ISOC99_SOURCE
893 __cdecl __MINGW_NOTHROW  int snwprintf (wchar_t *, size_t, const wchar_t *, ...);
894 __cdecl __MINGW_NOTHROW  int vsnwprintf (wchar_t *, size_t, const wchar_t *, __VALIST);
895
896 #ifndef __NO_INLINE__
897 __CRT_INLINE __cdecl __MINGW_NOTHROW
898 __JMPSTUB__(( FUNCTION = vsnwprintf, REMAPPED = _vsnwprintf ))
899 int vsnwprintf (wchar_t *__s, size_t __n, const wchar_t *__fmt, __VALIST __arg)
900 { return _vsnwprintf ( __s, __n, __fmt, __arg); }
901 #endif
902
903 __cdecl __MINGW_NOTHROW  int  vwscanf (const wchar_t *__restrict__, __VALIST);
904 __cdecl __MINGW_NOTHROW
905 int  vfwscanf (FILE *__restrict__, const wchar_t *__restrict__, __VALIST);
906 __cdecl __MINGW_NOTHROW
907 int  vswscanf (const wchar_t *__restrict__, const wchar_t * __restrict__, __VALIST);
908
909 #endif  /* _ISOC99_SOURCE */
910 #endif  /* ! (_STDIO_H && _WCHAR_H) */
911
912 #if defined _STDIO_H && ! defined __STRICT_ANSI__
913 #if defined __MSVCRT__ && ! defined _NO_OLDNAMES
914 _CRTIMP __cdecl __MINGW_NOTHROW  FILE * wpopen (const wchar_t *, const wchar_t *);
915 #endif
916
917 /* Other non-ANSI wide character functions...
918  */
919 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t _fgetwchar (void);
920 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t _fputwchar (wint_t);
921 _CRTIMP __cdecl __MINGW_NOTHROW  int    _getw (FILE *);
922 _CRTIMP __cdecl __MINGW_NOTHROW  int    _putw (int, FILE *);
923
924 #ifndef _NO_OLDNAMES
925 /* ...and their original names, before Microsoft uglification...
926  */
927 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t  fgetwchar (void);
928 _CRTIMP __cdecl __MINGW_NOTHROW  wint_t  fputwchar (wint_t);
929 _CRTIMP __cdecl __MINGW_NOTHROW  int     getw (FILE *);
930 _CRTIMP __cdecl __MINGW_NOTHROW  int     putw (int, FILE *);
931
932 #endif  /* !_NO_OLDNAMES */
933 #endif  /* !__STRICT_ANSI__ */
934
935 _END_C_DECLS
936
937 #endif  /* ! RC_INVOKED */
938 #endif  /* !_STDIO_H: $RCSfile$: end of file */