• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the mingw-w64 runtime package.
4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5  */
6 #ifndef _INC_STDIO
7 #define _INC_STDIO
8 
9 #include <crtdefs.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 #ifndef _WIN64
69 #define NULL 0
70 #else
71 #define NULL 0LL
72 #endif  /* W64 */
73 #else
74 #define NULL ((void *)0)
75 #endif
76 #endif
77 
78 #include <_mingw_off_t.h>
79 
80 _CRTIMP FILE *__cdecl __acrt_iob_func(unsigned index);
81 #ifndef _STDIO_DEFINED
82 #ifdef _WIN64
83   _CRTIMP FILE *__cdecl __iob_func(void);
84 #define _iob  __iob_func()
85 #else
86 #ifdef _MSVCRT_
87 extern FILE _iob[];	/* A pointer to an array of FILE */
88 #define __iob_func()	(_iob)
89 #else
90 extern FILE (* __MINGW_IMP_SYMBOL(_iob))[];	/* A pointer to an array of FILE */
91 #define __iob_func()	(* __MINGW_IMP_SYMBOL(_iob))
92 #define _iob __iob_func()
93 #endif
94 #endif
95 #endif
96 
97 #ifndef _FPOS_T_DEFINED
98 #define _FPOS_T_DEFINED
99 #undef _FPOSOFF
100 
101 #if (!defined(NO_OLDNAMES) || defined(__GNUC__))
102   __MINGW_EXTENSION typedef __int64 fpos_t;
103 #define _FPOSOFF(fp) ((long)(fp))
104 #else
105   __MINGW_EXTENSION typedef long long fpos_t;
106 #define _FPOSOFF(fp) ((long)(fp))
107 #endif
108 
109 #endif
110 
111 #ifndef _STDSTREAM_DEFINED
112 #define _STDSTREAM_DEFINED
113 
114 #define stdin (__acrt_iob_func(0))
115 #define stdout (__acrt_iob_func(1))
116 #define stderr (__acrt_iob_func(2))
117 #endif
118 
119 #define _IOREAD 0x0001
120 #define _IOWRT 0x0002
121 
122 #define _IOFBF 0x0000
123 #define _IOLBF 0x0040
124 #define _IONBF 0x0004
125 
126 #define _IOMYBUF 0x0008
127 #define _IOEOF 0x0010
128 #define _IOERR 0x0020
129 #define _IOSTRG 0x0040
130 #define _IORW 0x0080
131 #ifdef _POSIX_
132 #define _IOAPPEND 0x0200
133 #endif
134 
135 #define _TWO_DIGIT_EXPONENT 0x1
136 
137 #if !defined(_UCRTBASE_STDIO_DEFINED) && defined(_UCRT)
138 #define _UCRTBASE_STDIO_DEFINED
139 
140 #define UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION (0x0001)
141 #define UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR      (0x0002)
142 #define UCRTBASE_PRINTF_LEGACY_WIDE_SPECIFIERS           (0x0004)
143 #define UCRTBASE_PRINTF_LEGACY_MSVCRT_COMPATIBILITY      (0x0008)
144 #define UCRTBASE_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS     (0x0010)
145 
146 #define UCRTBASE_SCANF_SECURECRT                         (0x0001)
147 #define UCRTBASE_SCANF_LEGACY_WIDE_SPECIFIERS            (0x0002)
148 #define UCRTBASE_SCANF_LEGACY_MSVCRT_COMPATIBILITY       (0x0004)
149 
150 // Default wide printfs and scanfs to the legacy wide mode. Only code built
151 // with -D__USE_MINGW_ANSI_STDIO=1 will expect the standard behaviour.
152 #ifndef UCRTBASE_PRINTF_DEFAULT_WIDE
153 #define UCRTBASE_PRINTF_DEFAULT_WIDE UCRTBASE_PRINTF_LEGACY_WIDE_SPECIFIERS
154 #endif
155 #ifndef UCRTBASE_SCANF_DEFAULT_WIDE
156 #define UCRTBASE_SCANF_DEFAULT_WIDE UCRTBASE_SCANF_LEGACY_WIDE_SPECIFIERS
157 #endif
158 #endif
159 
160 #if __MINGW_FORTIFY_LEVEL > 0
161 __mingw_bos_declare;
162 #endif
163 
164 #ifndef _STDIO_DEFINED
165 extern
166   __attribute__((__format__ (gnu_scanf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
167   int __cdecl __mingw_sscanf(const char * __restrict__ _Src,const char * __restrict__ _Format,...);
168 extern
169   __attribute__((__format__ (gnu_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
170   int __cdecl __mingw_vsscanf (const char * __restrict__ _Str,const char * __restrict__ Format,va_list argp);
171 extern
172   __attribute__((__format__ (gnu_scanf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
173   int __cdecl __mingw_scanf(const char * __restrict__ _Format,...);
174 extern
175   __attribute__((__format__ (gnu_scanf, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
176   int __cdecl __mingw_vscanf(const char * __restrict__ Format, va_list argp);
177 extern
178   __attribute__((__format__ (gnu_scanf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
179   int __cdecl __mingw_fscanf(FILE * __restrict__ _File,const char * __restrict__ _Format,...);
180 extern
181   __attribute__((__format__ (gnu_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
182   int __cdecl __mingw_vfscanf (FILE * __restrict__ fp, const char * __restrict__ Format,va_list argp);
183 
184 extern
185   __attribute__((__format__ (gnu_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
186   int __cdecl __mingw_vsnprintf(char * __restrict__ _DstBuf,size_t _MaxCount,const char * __restrict__ _Format,
187                                va_list _ArgList);
188 extern
189   __attribute__((__format__ (gnu_printf, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
190   int __cdecl __mingw_snprintf(char * __restrict__ s, size_t n, const char * __restrict__  format, ...);
191 extern
192   __attribute__((__format__ (gnu_printf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
193   int __cdecl __mingw_printf(const char * __restrict__ , ... ) __MINGW_NOTHROW;
194 extern
195   __attribute__((__format__ (gnu_printf, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
196   int __cdecl __mingw_vprintf (const char * __restrict__ , va_list) __MINGW_NOTHROW;
197 extern
198   __attribute__((__format__ (gnu_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
199   int __cdecl __mingw_fprintf (FILE * __restrict__ , const char * __restrict__ , ...) __MINGW_NOTHROW;
200 extern
201   __attribute__((__format__ (gnu_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
202   int __cdecl __mingw_vfprintf (FILE * __restrict__ , const char * __restrict__ , va_list) __MINGW_NOTHROW;
203 extern
204   __attribute__((__format__ (gnu_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
205   int __cdecl __mingw_sprintf (char * __restrict__ , const char * __restrict__ , ...) __MINGW_NOTHROW;
206 extern
207   __attribute__((__format__ (gnu_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
208   int __cdecl __mingw_vsprintf (char * __restrict__ , const char * __restrict__ , va_list) __MINGW_NOTHROW;
209 extern
210   __attribute__((__format__ (gnu_printf, 2, 3))) __attribute__((nonnull (1,2)))
211   int __cdecl __mingw_asprintf(char ** __restrict__ , const char * __restrict__ , ...) __MINGW_NOTHROW;
212 extern
213   __attribute__((__format__ (gnu_printf, 2, 0))) __attribute__((nonnull (1,2)))
214   int __cdecl __mingw_vasprintf(char ** __restrict__ , const char * __restrict__ , va_list) __MINGW_NOTHROW;
215 
216 #ifdef _UCRT
217   int __cdecl __stdio_common_vsprintf(unsigned __int64 options, char *str, size_t len, const char *format, _locale_t locale, va_list valist);
218   int __cdecl __stdio_common_vfprintf(unsigned __int64 options, FILE *file, const char *format, _locale_t locale, va_list valist);
219   int __cdecl __stdio_common_vsscanf(unsigned __int64 options, const char *input, size_t length, const char *format, _locale_t locale, va_list valist);
220   int __cdecl __stdio_common_vfscanf(unsigned __int64 options, FILE *file, const char *format, _locale_t locale, va_list valist);
221 #endif
222 
223 #undef __MINGW_PRINTF_FORMAT
224 #undef __MINGW_SCANF_FORMAT
225 
226 #if defined(__clang__)
227 #define __MINGW_PRINTF_FORMAT printf
228 #define __MINGW_SCANF_FORMAT  scanf
229 #elif defined(_UCRT) || __USE_MINGW_ANSI_STDIO
230 #define __MINGW_PRINTF_FORMAT gnu_printf
231 #define __MINGW_SCANF_FORMAT  gnu_scanf
232 #else
233 #define __MINGW_PRINTF_FORMAT ms_printf
234 #define __MINGW_SCANF_FORMAT  ms_scanf
235 #endif
236 
237 #if __USE_MINGW_ANSI_STDIO
238 /*
239  * User has expressed a preference for C99 conformance...
240  */
241 
242 #ifdef _GNU_SOURCE
243 __mingw_ovr
244 __attribute__ ((__format__ (gnu_printf, 2, 3))) __attribute__((nonnull (1,2)))
asprintf(char ** __ret,const char * __format,...)245 int asprintf(char **__ret, const char *__format, ...)
246 {
247   int __retval;
248   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
249   __retval = __mingw_vasprintf( __ret, __format, __local_argv );
250   __builtin_va_end( __local_argv );
251   return __retval;
252 }
253 
254 __mingw_ovr
255 __attribute__ ((__format__ (gnu_printf, 2, 0))) __attribute__((nonnull (1,2)))
vasprintf(char ** __ret,const char * __format,__builtin_va_list __local_argv)256 int vasprintf(char **__ret, const char *__format, __builtin_va_list __local_argv)
257 {
258   return __mingw_vasprintf( __ret, __format, __local_argv );
259 }
260 #endif /* _GNU_SOURCE */
261 
262 /* There seems to be a bug about builtins and static overrides of them
263    in g++.  So we need to do here some trickery.  */
264 #ifdef __cplusplus
265 extern "C++" {
266 #endif
267 
268 __mingw_ovr
269 __attribute__((__format__ (gnu_scanf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
sscanf(const char * __source,const char * __format,...)270 int sscanf(const char *__source, const char *__format, ...)
271 {
272   int __retval;
273   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
274   __retval = __mingw_vsscanf( __source, __format, __local_argv );
275   __builtin_va_end( __local_argv );
276   return __retval;
277 }
278 
279 __mingw_ovr
280 __attribute__((__format__ (gnu_scanf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
scanf(const char * __format,...)281 int scanf(const char *__format, ...)
282 {
283   int __retval;
284   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
285   __retval = __mingw_vfscanf( stdin, __format, __local_argv );
286   __builtin_va_end( __local_argv );
287   return __retval;
288 }
289 
290 __mingw_ovr
291 __attribute__((__format__ (gnu_scanf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
fscanf(FILE * __stream,const char * __format,...)292 int fscanf(FILE *__stream, const char *__format, ...)
293 {
294   int __retval;
295   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
296   __retval = __mingw_vfscanf( __stream, __format, __local_argv );
297   __builtin_va_end( __local_argv );
298   return __retval;
299 }
300 
301 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
302 #ifdef __GNUC__
303 #pragma GCC diagnostic push
304 #pragma GCC diagnostic ignored "-Wshadow"
305 #endif
306 
307 __mingw_ovr
308 __attribute__((__format__ (gnu_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
vsscanf(const char * __source,const char * __format,__builtin_va_list __local_argv)309 int vsscanf (const char *__source, const char *__format, __builtin_va_list __local_argv)
310 {
311   return __mingw_vsscanf( __source, __format, __local_argv );
312 }
313 
314 __mingw_ovr
315 __attribute__((__format__ (gnu_scanf, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
vscanf(const char * __format,__builtin_va_list __local_argv)316 int vscanf(const char *__format,  __builtin_va_list __local_argv)
317 {
318   return __mingw_vfscanf( stdin, __format, __local_argv );
319 }
320 
321 __mingw_ovr
322 __attribute__((__format__ (gnu_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
vfscanf(FILE * __stream,const char * __format,__builtin_va_list __local_argv)323 int vfscanf (FILE *__stream,  const char *__format, __builtin_va_list __local_argv)
324 {
325   return __mingw_vfscanf( __stream, __format, __local_argv );
326 }
327 
328 #ifdef __GNUC__
329 #pragma GCC diagnostic pop
330 #endif
331 #endif /* __NO_ISOCEXT */
332 
333 
334 
335 __mingw_ovr
336 __attribute__((__format__ (gnu_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
fprintf(FILE * __stream,const char * __format,...)337 int fprintf (FILE *__stream, const char *__format, ...)
338 {
339   int __retval;
340   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
341   __retval = __mingw_vfprintf( __stream, __format, __local_argv );
342   __builtin_va_end( __local_argv );
343   return __retval;
344 }
345 
346 __mingw_ovr
347 __attribute__((__format__ (gnu_printf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
printf(const char * __format,...)348 int printf (const char *__format, ...)
349 {
350   int __retval;
351   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
352   __retval = __mingw_vfprintf( stdout, __format, __local_argv );
353   __builtin_va_end( __local_argv );
354   return __retval;
355 }
356 
357 #if __MINGW_FORTIFY_VA_ARG
358 
359 __mingw_bos_ovr
360 __attribute__((__format__ (gnu_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
sprintf(char * __stream,const char * __format,...)361 int sprintf (char *__stream, const char *__format, ...)
362 {
363   if (__mingw_bos_known(__stream)) {
364     int __retval = __mingw_snprintf( __stream, __mingw_bos(__stream, 1), __format, __builtin_va_arg_pack() );
365     if (__retval >= 0)
366       __mingw_bos_ptr_chk(__stream, (size_t)__retval + 1, 1);
367     return __retval;
368   }
369   return __mingw_sprintf( __stream, __format, __builtin_va_arg_pack() );
370 }
371 
372 #else /* !__MINGW_FORTIFY_VA_ARG */
373 
374 __mingw_ovr
375 __attribute__((__format__ (gnu_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
sprintf(char * __stream,const char * __format,...)376 int sprintf (char *__stream, const char *__format, ...)
377 {
378   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 #endif /* __MINGW_FORTIFY_VA_ARG */
386 
387 __mingw_ovr
388 __attribute__((__format__ (gnu_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
vfprintf(FILE * __stream,const char * __format,__builtin_va_list __local_argv)389 int vfprintf (FILE *__stream, const char *__format, __builtin_va_list __local_argv)
390 {
391   return __mingw_vfprintf( __stream, __format, __local_argv );
392 }
393 
394 __mingw_ovr
395 __attribute__((__format__ (gnu_printf, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
vprintf(const char * __format,__builtin_va_list __local_argv)396 int vprintf (const char *__format, __builtin_va_list __local_argv)
397 {
398   return __mingw_vfprintf( stdout, __format, __local_argv );
399 }
400 
401 __mingw_bos_ovr
402 __attribute__((__format__ (gnu_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
vsprintf(char * __stream,const char * __format,__builtin_va_list __local_argv)403 int vsprintf (char *__stream, const char *__format, __builtin_va_list __local_argv)
404 {
405 #if __MINGW_FORTIFY_LEVEL > 0
406   if (__mingw_bos_known(__stream)) {
407     int __retval = __mingw_vsnprintf( __stream, __mingw_bos(__stream, 1), __format, __local_argv );
408     if (__retval >= 0)
409       __mingw_bos_ptr_chk(__stream, (size_t)__retval + 1, 1);
410     return __retval;
411   }
412 #endif
413   return __mingw_vsprintf( __stream, __format, __local_argv );
414 }
415 /* #ifndef __NO_ISOCEXT */  /* externs in libmingwex.a */
416 
417 #if __MINGW_FORTIFY_VA_ARG
418 
419 __mingw_bos_ovr
420 __attribute__((__format__ (gnu_printf, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
snprintf(char * __stream,size_t __n,const char * __format,...)421 int snprintf (char *__stream, size_t __n, const char *__format, ...)
422 {
423   __mingw_bos_ptr_chk_warn(__stream, __n, 1);
424   return __mingw_snprintf( __stream, __n, __format, __builtin_va_arg_pack() );
425 }
426 
427 #else /* !__MINGW_FORTIFY_VA_ARG */
428 
429 __mingw_ovr
430 __attribute__((__format__ (gnu_printf, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
snprintf(char * __stream,size_t __n,const char * __format,...)431 int snprintf (char *__stream, size_t __n, const char *__format, ...)
432 {
433   int __retval;
434   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
435   __retval = __mingw_vsnprintf( __stream, __n, __format, __local_argv );
436   __builtin_va_end( __local_argv );
437   return __retval;
438 }
439 
440 #endif /* __MINGW_FORTIFY_VA_ARG */
441 
442 __mingw_bos_ovr
443 __attribute__((__format__ (gnu_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
vsnprintf(char * __stream,size_t __n,const char * __format,__builtin_va_list __local_argv)444 int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv)
445 {
446 #if __MINGW_FORTIFY_LEVEL > 0
447   __mingw_bos_ptr_chk_warn(__stream, __n, 1);
448 #endif
449   return __mingw_vsnprintf( __stream, __n, __format, __local_argv );
450 }
451 
452 /* Override __builtin_printf-routines ... Kludge for libstdc++ ...*/
453 #define __builtin_vsnprintf __mingw_vsnprintf
454 #define __builtin_vsprintf __mingw_vsprintf
455 
456 /* #endif */ /* __NO_ISOCEXT */
457 
458 #ifdef __cplusplus
459 }
460 #endif
461 
462 #else /* !__USE_MINGW_ANSI_STDIO */
463 
464 #undef __builtin_vsnprintf
465 #undef __builtin_vsprintf
466 
467 /*
468  * Default configuration: simply direct all calls to MSVCRT...
469  */
470 #ifdef _UCRT
471 #ifdef __GNUC__
472 #pragma GCC diagnostic push
473 #pragma GCC diagnostic ignored "-Wshadow"
474 #endif
475   __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
476   int __cdecl fprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,...);
477   __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
478   int __cdecl printf(const char * __restrict__ _Format,...);
479   __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
480   int __cdecl sprintf(char * __restrict__ _Dest,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
481 
482   __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
483   int __cdecl vfprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,va_list _ArgList);
484   __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
485   int __cdecl vprintf(const char * __restrict__ _Format,va_list _ArgList);
486   __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
487   int __cdecl vsprintf(char * __restrict__ _Dest,const char * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
488 
489   __mingw_ovr
490   __attribute__((__format__ (__MINGW_SCANF_FORMAT, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
fscanf(FILE * __restrict__ _File,const char * __restrict__ _Format,...)491   int __cdecl fscanf(FILE * __restrict__ _File,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
492   {
493     __builtin_va_list ap;
494     int ret;
495     __builtin_va_start(ap, _Format);
496     ret = __stdio_common_vfscanf(0, _File, _Format, NULL, ap);
497     __builtin_va_end(ap);
498     return ret;
499   }
500   __mingw_ovr
501   __attribute__((__format__ (__MINGW_SCANF_FORMAT, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
scanf(const char * __restrict__ _Format,...)502   int __cdecl scanf(const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
503   {
504     __builtin_va_list ap;
505     int ret;
506     __builtin_va_start(ap, _Format);
507     ret = __stdio_common_vfscanf(0, stdin, _Format, NULL, ap);
508     __builtin_va_end(ap);
509     return ret;
510   }
511   __mingw_ovr
512   __attribute__((__format__ (__MINGW_SCANF_FORMAT, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
sscanf(const char * __restrict__ _Src,const char * __restrict__ _Format,...)513   int __cdecl sscanf(const char * __restrict__ _Src,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
514   {
515     __builtin_va_list ap;
516     int ret;
517     __builtin_va_start(ap, _Format);
518     ret = __stdio_common_vsscanf(0, _Src, (size_t)-1, _Format, NULL, ap);
519     __builtin_va_end(ap);
520     return ret;
521   }
522 #ifdef _GNU_SOURCE
523   __attribute__ ((__format__ (__MINGW_PRINTF_FORMAT, 2, 0)))
524   int __cdecl vasprintf(char ** __restrict__ _Ret,const char * __restrict__ _Format,va_list _Args);
525   __attribute__ ((__format__ (__MINGW_PRINTF_FORMAT, 2, 3)))
526   int __cdecl asprintf(char ** __restrict__ _Ret,const char * __restrict__ _Format,...);
527 #endif /*_GNU_SOURCE*/
528 
529   __mingw_ovr
530   __attribute__((__format__ (__MINGW_SCANF_FORMAT, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
vfscanf(FILE * __stream,const char * __format,__builtin_va_list __local_argv)531   int vfscanf (FILE *__stream,  const char *__format, __builtin_va_list __local_argv)
532   {
533     return __stdio_common_vfscanf(0, __stream, __format, NULL, __local_argv);
534   }
535 
536   __mingw_ovr
537   __attribute__((__format__ (__MINGW_SCANF_FORMAT, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
vsscanf(const char * __restrict__ __source,const char * __restrict__ __format,__builtin_va_list __local_argv)538   int vsscanf (const char * __restrict__ __source, const char * __restrict__ __format, __builtin_va_list __local_argv)
539   {
540     return __stdio_common_vsscanf(0, __source, (size_t)-1, __format, NULL, __local_argv);
541   }
542   __mingw_ovr
543   __attribute__((__format__ (__MINGW_SCANF_FORMAT, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
vscanf(const char * __format,__builtin_va_list __local_argv)544   int vscanf(const char *__format,  __builtin_va_list __local_argv)
545   {
546     return __stdio_common_vfscanf(0, stdin, __format, NULL, __local_argv);
547   }
548 
549 #ifdef __GNUC__
550 #pragma GCC diagnostic pop
551 #endif
552 
553 #else
554   __attribute__((__format__ (ms_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
555   int __cdecl fprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,...);
556   __attribute__((__format__ (ms_printf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
557   int __cdecl printf(const char * __restrict__ _Format,...);
558   __attribute__((__format__ (ms_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
559   int __cdecl sprintf(char * __restrict__ _Dest,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
560 
561   __attribute__((__format__ (ms_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
562   int __cdecl vfprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,va_list _ArgList);
563   __attribute__((__format__ (ms_printf, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
564   int __cdecl vprintf(const char * __restrict__ _Format,va_list _ArgList);
565   __attribute__((__format__ (ms_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
566   int __cdecl vsprintf(char * __restrict__ _Dest,const char * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
567 
568   __attribute__((__format__ (ms_scanf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
569   int __cdecl fscanf(FILE * __restrict__ _File,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
570   __attribute__((__format__ (ms_scanf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
571   int __cdecl scanf(const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
572   __attribute__((__format__ (ms_scanf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
573   int __cdecl sscanf(const char * __restrict__ _Src,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
574 #ifdef _GNU_SOURCE
575   int __cdecl vasprintf(char ** __restrict__ ret,const char * __restrict__ format,va_list ap)  __attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 0)));
576   int __cdecl asprintf(char ** __restrict__ ret,const char * __restrict__ format,...) __attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3)));
577 #endif /*_GNU_SOURCE*/
578 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
579 #ifdef __GNUC__
580 #pragma GCC diagnostic push
581 #pragma GCC diagnostic ignored "-Wshadow"
582 #endif
583 
584   __attribute__((__format__ (ms_scanf, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
585   int __cdecl __ms_vscanf(const char * __restrict__ Format, va_list argp);
586   __attribute__((__format__ (ms_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
587   int __cdecl __ms_vfscanf (FILE * __restrict__ fp, const char * __restrict__ Format,va_list argp);
588   __attribute__((__format__ (ms_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
589   int __cdecl __ms_vsscanf (const char * __restrict__ _Str,const char * __restrict__ Format,va_list argp);
590 
591   __mingw_ovr
592   __attribute__((__format__ (ms_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
vfscanf(FILE * __stream,const char * __format,__builtin_va_list __local_argv)593   int vfscanf (FILE *__stream,  const char *__format, __builtin_va_list __local_argv)
594   {
595     return __ms_vfscanf (__stream, __format, __local_argv);
596   }
597 
598   __mingw_ovr
599   __attribute__((__format__ (ms_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
vsscanf(const char * __restrict__ __source,const char * __restrict__ __format,__builtin_va_list __local_argv)600   int vsscanf (const char * __restrict__ __source, const char * __restrict__ __format, __builtin_va_list __local_argv)
601   {
602     return __ms_vsscanf( __source, __format, __local_argv );
603   }
604   __mingw_ovr
605   __attribute__((__format__ (ms_scanf, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
vscanf(const char * __format,__builtin_va_list __local_argv)606   int vscanf(const char *__format,  __builtin_va_list __local_argv)
607   {
608     return __ms_vscanf (__format, __local_argv);
609   }
610 
611 #ifdef __GNUC__
612 #pragma GCC diagnostic pop
613 #endif
614 
615 #endif /* __NO_ISOCEXT */
616 #endif /* _UCRT */
617 #endif /* __USE_MINGW_ANSI_STDIO */
618 
619   _CRTIMP int __cdecl _filbuf(FILE *_File);
620   _CRTIMP int __cdecl _flsbuf(int _Ch,FILE *_File);
621 #ifdef _POSIX_
622   _CRTIMP FILE *__cdecl _fsopen(const char *_Filename,const char *_Mode);
623 #else
624   _CRTIMP FILE *__cdecl _fsopen(const char *_Filename,const char *_Mode,int _ShFlag);
625 #endif
626   void __cdecl clearerr(FILE *_File);
627   int __cdecl fclose(FILE *_File);
628   _CRTIMP int __cdecl _fcloseall(void);
629 #ifdef _POSIX_
630   FILE *__cdecl fdopen(int _FileHandle,const char *_Mode) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
631 #else
632   _CRTIMP FILE *__cdecl _fdopen(int _FileHandle,const char *_Mode);
633 #endif
634   int __cdecl feof(FILE *_File);
635   int __cdecl ferror(FILE *_File);
636   int __cdecl fflush(FILE *_File);
637   int __cdecl fgetc(FILE *_File);
638   _CRTIMP int __cdecl _fgetchar(void);
639   int __cdecl fgetpos(FILE * __restrict__ _File ,fpos_t * __restrict__ _Pos); /* 64bit only, no 32bit version */
640   int __cdecl fgetpos64(FILE * __restrict__ _File ,fpos_t * __restrict__ _Pos); /* fgetpos already 64bit */
641   char *__cdecl fgets(char * __restrict__ _Buf,int _MaxCount,FILE * __restrict__ _File);
642   _CRTIMP int __cdecl _fileno(FILE *_File);
643 #ifdef _POSIX_
644   int __cdecl fileno(FILE *_File) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
645 #endif
646   _CRTIMP char *__cdecl _tempnam(const char *_DirName,const char *_FilePrefix);
647   _CRTIMP int __cdecl _flushall(void);
648   FILE *__cdecl fopen(const char * __restrict__ _Filename,const char * __restrict__ _Mode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
649   FILE *fopen64(const char * __restrict__ filename,const char * __restrict__  mode);
650   int __cdecl fputc(int _Ch,FILE *_File);
651   _CRTIMP int __cdecl _fputchar(int _Ch);
652   int __cdecl fputs(const char * __restrict__ _Str,FILE * __restrict__ _File);
653   size_t __cdecl fread(void * __restrict__ _DstBuf,size_t _ElementSize,size_t _Count,FILE * __restrict__ _File);
654   FILE *__cdecl freopen(const char * __restrict__ _Filename,const char * __restrict__ _Mode,FILE * __restrict__ _File) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
655   int __cdecl fsetpos(FILE *_File,const fpos_t *_Pos);
656   int __cdecl fsetpos64(FILE *_File,const fpos_t *_Pos); /* fsetpos already 64bit */
657   int __cdecl fseek(FILE *_File,long _Offset,int _Origin);
658   long __cdecl ftell(FILE *_File);
659 
660   /* Shouldn't be any fseeko32 in glibc, 32bit to 64bit casting should be fine */
661   /* int fseeko32(FILE* stream, _off_t offset, int whence);*/ /* fseeko32 redirects to fseeko64 */
662   _CRTIMP int __cdecl _fseeki64(FILE *_File,__int64 _Offset,int _Origin);
663   _CRTIMP __int64 __cdecl _ftelli64(FILE *_File);
664 #ifdef _UCRT
fseeko(FILE * _File,_off_t _Offset,int _Origin)665   __mingw_static_ovr int fseeko(FILE *_File, _off_t _Offset, int _Origin) {
666     return fseek(_File, _Offset, _Origin);
667   }
fseeko64(FILE * _File,_off64_t _Offset,int _Origin)668   __mingw_static_ovr int fseeko64(FILE *_File, _off64_t _Offset, int _Origin) {
669     return _fseeki64(_File, _Offset, _Origin);
670   }
ftello(FILE * _File)671   __mingw_static_ovr _off_t ftello(FILE *_File) {
672     return ftell(_File);
673   }
ftello64(FILE * _File)674   __mingw_static_ovr _off64_t ftello64(FILE *_File) {
675     return _ftelli64(_File);
676   }
677 #else
678   int fseeko64(FILE* stream, _off64_t offset, int whence);
679   int fseeko(FILE* stream, _off_t offset, int whence);
680   /* Returns truncated 64bit off_t */
681   _off_t ftello(FILE * stream);
682   _off64_t ftello64(FILE * stream);
683 #endif
684 
685 #ifndef _FILE_OFFSET_BITS_SET_FSEEKO
686 #define _FILE_OFFSET_BITS_SET_FSEEKO
687 #if (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64))
688 #define fseeko fseeko64
689 #endif /* (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)) */
690 #endif /* _FILE_OFFSET_BITS_SET_FSEEKO */
691 
692 #ifndef _FILE_OFFSET_BITS_SET_FTELLO
693 #define _FILE_OFFSET_BITS_SET_FTELLO
694 #if (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64))
695 #define ftello ftello64
696 #endif /* (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)) */
697 #endif /* _FILE_OFFSET_BITS_SET_FTELLO */
698 
699   size_t __cdecl fwrite(const void * __restrict__ _Str,size_t _Size,size_t _Count,FILE * __restrict__ _File);
700   int __cdecl getc(FILE *_File);
701   int __cdecl getchar(void);
702   _CRTIMP int __cdecl _getmaxstdio(void);
703   char *__cdecl gets(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
704   int __cdecl _getw(FILE *_File);
705 #ifndef _CRT_PERROR_DEFINED
706 #define _CRT_PERROR_DEFINED
707   void __cdecl perror(const char *_ErrMsg);
708 #endif
709   _CRTIMP int __cdecl _pclose(FILE *_File);
710   _CRTIMP FILE *__cdecl _popen(const char *_Command,const char *_Mode);
711 #if !defined(NO_OLDNAMES) && !defined(popen)
712 #define popen	_popen
713 #define pclose	_pclose
714 #endif
715   int __cdecl putc(int _Ch,FILE *_File);
716   int __cdecl putchar(int _Ch);
717   int __cdecl puts(const char *_Str);
718   _CRTIMP int __cdecl _putw(int _Word,FILE *_File);
719 #ifndef _CRT_DIRECTORY_DEFINED
720 #define _CRT_DIRECTORY_DEFINED
721   int __cdecl remove(const char *_Filename);
722   int __cdecl rename(const char *_OldFilename,const char *_NewFilename);
723   _CRTIMP int __cdecl _unlink(const char *_Filename);
724 #ifndef	NO_OLDNAMES
725   int __cdecl unlink(const char *_Filename) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
726 #endif
727 #endif
728   void __cdecl rewind(FILE *_File);
729   _CRTIMP int __cdecl _rmtmp(void);
730   void __cdecl setbuf(FILE * __restrict__ _File,char * __restrict__ _Buffer) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
731   _CRTIMP int __cdecl _setmaxstdio(int _Max);
732   _CRTIMP unsigned int __cdecl _set_output_format(unsigned int _Format);
733   _CRTIMP unsigned int __cdecl _get_output_format(void);
734   int __cdecl setvbuf(FILE * __restrict__ _File,char * __restrict__ _Buf,int _Mode,size_t _Size);
735 #ifdef _UCRT
736   __mingw_ovr
_scprintf(const char * __restrict__ _Format,...)737   int __cdecl _scprintf(const char * __restrict__ _Format,...)
738   {
739     __builtin_va_list ap;
740     int ret;
741     __builtin_va_start(ap, _Format);
742     ret = __stdio_common_vsprintf(UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, NULL, 0, _Format, NULL, ap);
743     __builtin_va_end(ap);
744     return ret;
745   }
746   __mingw_ovr
_snscanf(const char * __restrict__ _Src,size_t _MaxCount,const char * __restrict__ _Format,...)747   int __cdecl _snscanf(const char * __restrict__ _Src,size_t _MaxCount,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
748   {
749     __builtin_va_list ap;
750     int ret;
751     __builtin_va_start(ap, _Format);
752     ret = __stdio_common_vsscanf(0, _Src, _MaxCount, _Format, NULL, ap);
753     __builtin_va_end(ap);
754     return ret;
755   }
756 #else
757   _CRTIMP int __cdecl _scprintf(const char * __restrict__ _Format,...);
758   _CRTIMP int __cdecl _snscanf(const char * __restrict__ _Src,size_t _MaxCount,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
759 #endif
760   FILE *__cdecl tmpfile(void) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
761   char *__cdecl tmpnam(char *_Buffer);
762   int __cdecl ungetc(int _Ch,FILE *_File);
763 
764 #ifdef _UCRT
765   __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
766   int __cdecl _vsnprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
767   __mingw_ovr
768   __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
_snprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,...)769   int __cdecl _snprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
770   {
771     __builtin_va_list ap;
772     int ret;
773     __builtin_va_start(ap, _Format);
774     ret = _vsnprintf(_Dest, _Count, _Format, ap);
775     __builtin_va_end(ap);
776     return ret;
777   }
778 #else
779   __attribute__((__format__ (ms_printf, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
780   _CRTIMP int __cdecl _snprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
781   __attribute__((__format__ (ms_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
782   _CRTIMP int __cdecl _vsnprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
783 #endif
784 
785 #if __MINGW_FORTIFY_LEVEL > 0
786 
787 char * __cdecl __gets_chk(char *, size_t);
788 char * __cdecl __mingw_call_gets_warn(char *) __MINGW_ASM_CALL(gets)
789   __attribute__((__warning__("Using gets() is always unsafe - use fgets() instead")));
790 char * __cdecl __mingw_call_fgets(char * __restrict__, int, FILE * __restrict__) __MINGW_ASM_CALL(fgets);
791 size_t __cdecl __mingw_call_fread(void * __restrict__, size_t, size_t, FILE * __restrict__) __MINGW_ASM_CALL(fread);
792 char * __cdecl __mingw_call_tmpnam(char *) __MINGW_ASM_CALL(tmpnam);
793 
794 __mingw_bos_extern_ovr
gets(char * __dst)795 char * gets(char * __dst)
796 {
797   if (__mingw_bos_known(__dst))
798     return __gets_chk(__dst, __mingw_bos(__dst, 1));
799   return __mingw_call_gets_warn(__dst);
800 }
801 
802 __mingw_bos_extern_ovr
fgets(char * __restrict__ __dst,int __n,FILE * __restrict__ __f)803 char * fgets(char * __restrict__ __dst, int __n, FILE * __restrict__ __f)
804 {
805   __mingw_bos_ptr_chk_warn(__dst, __n, 1);
806   return __mingw_call_fgets(__dst, __n, __f);
807 }
808 
809 __mingw_bos_extern_ovr
fread(void * __restrict__ __dst,size_t __sz,size_t __n,FILE * __restrict__ __f)810 size_t fread(void * __restrict__ __dst, size_t __sz, size_t __n, FILE * __restrict__ __f)
811 {
812   __mingw_bos_ptr_chk_warn(__dst, __sz * __n, 0);
813   return __mingw_call_fread(__dst, __sz, __n, __f);
814 }
815 
816 __mingw_bos_extern_ovr
tmpnam(char * __dst)817 char * tmpnam(char * __dst)
818 {
819   __mingw_bos_ptr_chk_warn(__dst, L_tmpnam, 1);
820   return __mingw_call_tmpnam(__dst);
821 }
822 
823 #endif /* __MINGW_FORTIFY_LEVEL > 0 */
824 
825 #if __USE_MINGW_ANSI_STDIO == 0
826 
827 #ifdef _UCRT
828 #ifdef __GNUC__
829 #pragma GCC diagnostic push
830 #pragma GCC diagnostic ignored "-Wshadow"
831 #endif
832   __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
833   int vsnprintf (char * __restrict__ __stream, size_t __n, const char * __restrict__ __format, va_list __local_argv);
834 
835   __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
836   int snprintf (char * __restrict__ __stream, size_t __n, const char * __restrict__ __format, ...);
837 #ifdef __GNUC__
838 #pragma GCC diagnostic pop
839 #endif
840 #else
841 
842 /* this is here to deal with software defining
843  * vsnprintf as _vsnprintf, eg. libxml2.  */
844 
845 #ifdef __GNUC__
846 #pragma GCC diagnostic push
847 #pragma GCC diagnostic ignored "-Wshadow"
848 #endif
849 
850 #pragma push_macro("snprintf")
851 #pragma push_macro("vsnprintf")
852 # undef snprintf
853 # undef vsnprintf
854   __attribute__((__format__ (ms_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
855   int __cdecl __ms_vsnprintf(char * __restrict__ d,size_t n,const char * __restrict__ format,va_list arg)
856     __MINGW_ATTRIB_DEPRECATED_MSVC2005 __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
857 
858   __mingw_bos_ovr
859   __attribute__((__format__ (ms_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
vsnprintf(char * __restrict__ __stream,size_t __n,const char * __restrict__ __format,va_list __local_argv)860   int vsnprintf (char * __restrict__ __stream, size_t __n, const char * __restrict__ __format, va_list __local_argv)
861   {
862 #if __MINGW_FORTIFY_LEVEL > 0
863     __mingw_bos_ptr_chk_warn(__stream, __n, 1);
864 #endif
865     return __ms_vsnprintf (__stream, __n, __format, __local_argv);
866   }
867 
868   __attribute__((__format__ (ms_printf, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
869   int __cdecl __ms_snprintf(char * __restrict__ s, size_t n, const char * __restrict__  format, ...);
870 
871 #ifndef __NO_ISOCEXT
872 #if __MINGW_FORTIFY_VA_ARG
873 
874 __mingw_bos_ovr
875 __attribute__((__format__ (ms_printf, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
snprintf(char * __restrict__ __stream,size_t __n,const char * __restrict__ __format,...)876 int snprintf (char * __restrict__ __stream, size_t __n, const char * __restrict__ __format, ...)
877 {
878   __mingw_bos_ptr_chk_warn(__stream, __n, 1);
879   return __ms_snprintf(__stream, __n, __format, __builtin_va_arg_pack());
880 }
881 
882 #else /* !__MINGW_FORTIFY_VA_ARG */
883 
884 __mingw_ovr
885 __attribute__((__format__ (ms_printf, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
snprintf(char * __restrict__ __stream,size_t __n,const char * __restrict__ __format,...)886 int snprintf (char * __restrict__ __stream, size_t __n, const char * __restrict__ __format, ...)
887 {
888   int __retval;
889   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
890   __retval = __ms_vsnprintf (__stream, __n, __format, __local_argv);
891   __builtin_va_end( __local_argv );
892   return __retval;
893 }
894 
895 #endif /* !__MINGW_FORTIFY_VA_ARG */
896 #endif /* !__NO_ISOCEXT */
897 
898 #if __MINGW_FORTIFY_VA_ARG
899 
900 int __cdecl __mingw_call_ms_sprintf(char * __restrict__, const char * __restrict__, ...) __MINGW_ASM_CALL(sprintf);
901 
902 __mingw_bos_extern_ovr
903 __attribute__((__format__ (ms_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
sprintf(char * __restrict__ __stream,const char * __restrict__ __format,...)904 int sprintf (char * __restrict__ __stream, const char * __restrict__ __format, ...)
905 {
906   if (__mingw_bos_known(__stream)) {
907     int __retval = __ms_snprintf( __stream, __mingw_bos(__stream, 1), __format, __builtin_va_arg_pack() );
908     if (__retval >= 0)
909       __mingw_bos_ptr_chk(__stream, (size_t)__retval + 1, 1);
910     return __retval;
911   }
912   return __mingw_call_ms_sprintf( __stream, __format, __builtin_va_arg_pack() );
913 }
914 
915 #endif /* __MINGW_FORTIFY_VA_ARG */
916 
917 #if __MINGW_FORTIFY_LEVEL > 0
918 
919 int __cdecl __mingw_call_ms_vsprintf(char * __restrict__, const char * __restrict__, va_list) __MINGW_ASM_CALL(vsprintf);
920 
921 __mingw_bos_extern_ovr
922 __attribute__((__format__ (ms_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
vsprintf(char * __restrict__ __stream,const char * __restrict__ __format,va_list __local_argv)923 int vsprintf (char * __restrict__ __stream, const char * __restrict__ __format, va_list __local_argv)
924 {
925   if (__mingw_bos_known(__stream)) {
926     int __retval = __ms_vsnprintf( __stream, __mingw_bos(__stream, 1), __format, __local_argv );
927     if (__retval >= 0)
928       __mingw_bos_ptr_chk(__stream, (size_t)__retval + 1, 1);
929     return __retval;
930   }
931   return __mingw_call_ms_vsprintf( __stream, __format, __local_argv );
932 }
933 
934 #endif /* __MINGW_FORTIFY_LEVEL > 0 */
935 
936 #pragma pop_macro ("vsnprintf")
937 #pragma pop_macro ("snprintf")
938 #ifdef __GNUC__
939 #pragma GCC diagnostic pop
940 #endif
941 #endif /* _UCRT */
942 #endif /* __USE_MINGW_ANSI_STDIO */
943 
944 #ifdef _UCRT
945   __mingw_ovr
_vscprintf(const char * __restrict__ _Format,va_list _ArgList)946   int __cdecl _vscprintf(const char * __restrict__ _Format,va_list _ArgList)
947   {
948     return __stdio_common_vsprintf(UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, NULL, 0, _Format, NULL, _ArgList);
949   }
950 #else
951   _CRTIMP int __cdecl _vscprintf(const char * __restrict__ _Format,va_list _ArgList);
952 #endif /* _UCRT */
953 
954   _CRTIMP int __cdecl _set_printf_count_output(int _Value);
955   _CRTIMP int __cdecl _get_printf_count_output(void);
956 
957 #ifndef _WSTDIO_DEFINED
958 #define _WSTDIO_DEFINED
959 
960 /* __attribute__((__format__ (gnu_wscanf, 2, 3))) */ __MINGW_ATTRIB_NONNULL(2)
961   int __cdecl __mingw_swscanf(const wchar_t * __restrict__ _Src,const wchar_t * __restrict__ _Format,...);
962 /* __attribute__((__format__ (gnu_wscanf, 2, 0))) */ __MINGW_ATTRIB_NONNULL(2)
963   int __cdecl __mingw_vswscanf (const wchar_t * __restrict__ _Str,const wchar_t * __restrict__ Format,va_list argp);
964 /* __attribute__((__format__ (gnu_wscanf, 1, 2))) */ __MINGW_ATTRIB_NONNULL(1)
965   int __cdecl __mingw_wscanf(const wchar_t * __restrict__ _Format,...);
966 /* __attribute__((__format__ (gnu_wscanf, 1, 0))) */ __MINGW_ATTRIB_NONNULL(1)
967   int __cdecl __mingw_vwscanf(const wchar_t * __restrict__ Format, va_list argp);
968 /* __attribute__((__format__ (gnu_wscanf, 2, 3))) */ __MINGW_ATTRIB_NONNULL(2)
969   int __cdecl __mingw_fwscanf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...);
970 /* __attribute__((__format__ (gnu_wscanf, 2, 0))) */ __MINGW_ATTRIB_NONNULL(2)
971   int __cdecl __mingw_vfwscanf (FILE * __restrict__ fp, const wchar_t * __restrict__ Format,va_list argp);
972 
973 /* __attribute__((__format__ (gnu_wprintf, 2, 3))) */ __MINGW_ATTRIB_NONNULL(2)
974   int __cdecl __mingw_fwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...);
975 /* __attribute__((__format__ (gnu_wprintf, 1, 2))) */ __MINGW_ATTRIB_NONNULL(1)
976   int __cdecl __mingw_wprintf(const wchar_t * __restrict__ _Format,...);
977 /* __attribute__((__format__ (gnu_wprintf, 2, 0))) */__MINGW_ATTRIB_NONNULL(2)
978   int __cdecl __mingw_vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList);
979 /*__attribute__((__format__ (gnu_wprintf, 1, 0))) */ __MINGW_ATTRIB_NONNULL(1)
980   int __cdecl __mingw_vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList);
981 /* __attribute__((__format__ (gnu_wprintf, 3, 4))) */ __MINGW_ATTRIB_NONNULL(3)
982   int __cdecl __mingw_snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...);
983 /* __attribute__((__format__ (gnu_wprintf, 3, 0))) */ __MINGW_ATTRIB_NONNULL(3)
984   int __cdecl __mingw_vsnwprintf (wchar_t * __restrict__ , size_t, const wchar_t * __restrict__ , va_list);
985 /* __attribute__((__format__ (gnu_wprintf, 2, 3))) */ __MINGW_ATTRIB_NONNULL(2)
986   int __cdecl __mingw_swprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...);
987 /* __attribute__((__format__ (gnu_wprintf, 2, 0))) */ __MINGW_ATTRIB_NONNULL(2)
988   int __cdecl __mingw_vswprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ ,va_list);
989 
990 #ifdef _UCRT
991   int __cdecl __stdio_common_vswprintf(unsigned __int64 options, wchar_t *str, size_t len, const wchar_t *format, _locale_t locale, va_list valist);
992   int __cdecl __stdio_common_vfwprintf(unsigned __int64 options, FILE *file, const wchar_t *format, _locale_t locale, va_list valist);
993   int __cdecl __stdio_common_vswscanf(unsigned __int64 options, const wchar_t *input, size_t length, const wchar_t *format, _locale_t locale, va_list valist);
994   int __cdecl __stdio_common_vfwscanf(unsigned __int64 options, FILE *file, const wchar_t *format, _locale_t locale, va_list valist);
995 #endif
996 
997 #if __USE_MINGW_ANSI_STDIO
998 /*
999  * User has expressed a preference for C99 conformance...
1000  */
1001 
1002 __mingw_ovr
1003 /* __attribute__((__format__ (gnu_wscanf, 2, 3))) */ __MINGW_ATTRIB_NONNULL(2)
swscanf(const wchar_t * __source,const wchar_t * __format,...)1004 int swscanf(const wchar_t *__source, const wchar_t *__format, ...)
1005 {
1006   int __retval;
1007   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
1008   __retval = __mingw_vswscanf( __source, __format, __local_argv );
1009   __builtin_va_end( __local_argv );
1010   return __retval;
1011 }
1012 
1013 __mingw_ovr
1014 /* __attribute__((__format__ (gnu_wscanf, 1, 2))) */ __MINGW_ATTRIB_NONNULL(1)
wscanf(const wchar_t * __format,...)1015 int wscanf(const wchar_t *__format, ...)
1016 {
1017   int __retval;
1018   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
1019   __retval = __mingw_vfwscanf( stdin, __format, __local_argv );
1020   __builtin_va_end( __local_argv );
1021   return __retval;
1022 }
1023 
1024 __mingw_ovr
1025 /* __attribute__((__format__ (gnu_wscanf, 2, 3))) */ __MINGW_ATTRIB_NONNULL(2)
fwscanf(FILE * __stream,const wchar_t * __format,...)1026 int fwscanf(FILE *__stream, const wchar_t *__format, ...)
1027 {
1028   int __retval;
1029   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
1030   __retval = __mingw_vfwscanf( __stream, __format, __local_argv );
1031   __builtin_va_end( __local_argv );
1032   return __retval;
1033 }
1034 
1035 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
1036 __mingw_ovr
1037 /* __attribute__((__format__ (gnu_wscanf, 2, 0))) */ __MINGW_ATTRIB_NONNULL(2)
vswscanf(const wchar_t * __restrict__ __source,const wchar_t * __restrict__ __format,__builtin_va_list __local_argv)1038 int vswscanf (const wchar_t * __restrict__ __source, const wchar_t * __restrict__ __format, __builtin_va_list __local_argv)
1039 {
1040   return __mingw_vswscanf( __source, __format, __local_argv );
1041 }
1042 
1043 __mingw_ovr
1044 /* __attribute__((__format__ (gnu_wscanf, 1, 0))) */ __MINGW_ATTRIB_NONNULL(1)
vwscanf(const wchar_t * __format,__builtin_va_list __local_argv)1045 int vwscanf(const wchar_t *__format,  __builtin_va_list __local_argv)
1046 {
1047   return __mingw_vfwscanf( stdin, __format, __local_argv );
1048 }
1049 
1050 __mingw_ovr
1051 /* __attribute__((__format__ (gnu_wscanf, 2, 0))) */ __MINGW_ATTRIB_NONNULL(2)
vfwscanf(FILE * __stream,const wchar_t * __format,__builtin_va_list __local_argv)1052 int vfwscanf (FILE *__stream,  const wchar_t *__format, __builtin_va_list __local_argv)
1053 {
1054   return __mingw_vfwscanf( __stream, __format, __local_argv );
1055 }
1056 #endif /* __NO_ISOCEXT */
1057 
1058 
1059 
1060 __mingw_ovr
1061 /* __attribute__((__format__ (gnu_wprintf, 2, 3))) */ __MINGW_ATTRIB_NONNULL(2)
fwprintf(FILE * __stream,const wchar_t * __format,...)1062 int fwprintf (FILE *__stream, const wchar_t *__format, ...)
1063 {
1064   int __retval;
1065   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
1066   __retval = __mingw_vfwprintf( __stream, __format, __local_argv );
1067   __builtin_va_end( __local_argv );
1068   return __retval;
1069 }
1070 
1071 __mingw_ovr
1072 /* __attribute__((__format__ (gnu_wprintf, 1, 2))) */ __MINGW_ATTRIB_NONNULL(1)
wprintf(const wchar_t * __format,...)1073 int wprintf (const wchar_t *__format, ...)
1074 {
1075   int __retval;
1076   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
1077   __retval = __mingw_vfwprintf( stdout, __format, __local_argv );
1078   __builtin_va_end( __local_argv );
1079   return __retval;
1080 }
1081 
1082 __mingw_ovr
1083 /* __attribute__((__format__ (gnu_wprintf, 2, 0))) */ __MINGW_ATTRIB_NONNULL(2)
vfwprintf(FILE * __stream,const wchar_t * __format,__builtin_va_list __local_argv)1084 int vfwprintf (FILE *__stream, const wchar_t *__format, __builtin_va_list __local_argv)
1085 {
1086   return __mingw_vfwprintf( __stream, __format, __local_argv );
1087 }
1088 
1089 __mingw_ovr
1090 /* __attribute__((__format__ (gnu_wprintf, 1, 0))) */ __MINGW_ATTRIB_NONNULL(1)
vwprintf(const wchar_t * __format,__builtin_va_list __local_argv)1091 int vwprintf (const wchar_t *__format, __builtin_va_list __local_argv)
1092 {
1093   return __mingw_vfwprintf( stdout, __format, __local_argv );
1094 }
1095 
1096 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
1097 
1098 #if __MINGW_FORTIFY_VA_ARG
1099 
1100 __mingw_bos_ovr
1101 /* __attribute__((__format__ (gnu_wprintf, 3, 4))) */ __MINGW_ATTRIB_NONNULL(3)
snwprintf(wchar_t * __stream,size_t __n,const wchar_t * __format,...)1102 int snwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, ...)
1103 {
1104   __mingw_bos_ptr_chk_warn(__stream, __n * sizeof(wchar_t), 1);
1105   return __mingw_snwprintf( __stream, __n, __format, __builtin_va_arg_pack() );
1106 }
1107 
1108 #else /* !__MINGW_FORTIFY_VA_ARG */
1109 
1110 __mingw_ovr
1111 /* __attribute__((__format__ (gnu_wprintf, 3, 4))) */ __MINGW_ATTRIB_NONNULL(3)
snwprintf(wchar_t * __stream,size_t __n,const wchar_t * __format,...)1112 int snwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, ...)
1113 {
1114   int __retval;
1115   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
1116   __retval = __mingw_vsnwprintf( __stream, __n, __format, __local_argv );
1117   __builtin_va_end( __local_argv );
1118   return __retval;
1119 }
1120 
1121 #endif /* __MINGW_FORTIFY_VA_ARG */
1122 
1123 __mingw_bos_ovr
1124 /* __attribute__((__format__ (gnu_wprintf, 3, 0))) */ __MINGW_ATTRIB_NONNULL(3)
vsnwprintf(wchar_t * __stream,size_t __n,const wchar_t * __format,__builtin_va_list __local_argv)1125 int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builtin_va_list __local_argv)
1126 {
1127 #if __MINGW_FORTIFY_LEVEL > 0
1128   __mingw_bos_ptr_chk_warn(__stream, __n * sizeof(wchar_t), 1);
1129 #endif
1130   return __mingw_vsnwprintf( __stream, __n, __format, __local_argv );
1131 }
1132 #endif /* __NO_ISOCEXT */
1133 
1134 #else /* !__USE_MINGW_ANSI_STDIO */
1135 
1136 #ifdef _UCRT
1137   __mingw_ovr
fwscanf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...)1138   int __cdecl fwscanf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
1139   {
1140     __builtin_va_list ap;
1141     int ret;
1142     __builtin_va_start(ap, _Format);
1143     ret = __stdio_common_vfwscanf(UCRTBASE_SCANF_DEFAULT_WIDE, _File, _Format, NULL, ap);
1144     __builtin_va_end(ap);
1145     return ret;
1146   }
1147   __mingw_ovr
swscanf(const wchar_t * __restrict__ _Src,const wchar_t * __restrict__ _Format,...)1148   int __cdecl swscanf(const wchar_t * __restrict__ _Src,const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
1149   {
1150     __builtin_va_list ap;
1151     int ret;
1152     __builtin_va_start(ap, _Format);
1153     ret = __stdio_common_vswscanf(UCRTBASE_SCANF_DEFAULT_WIDE, _Src, (size_t)-1, _Format, NULL, ap);
1154     __builtin_va_end(ap);
1155     return ret;
1156   }
1157   __mingw_ovr
wscanf(const wchar_t * __restrict__ _Format,...)1158   int __cdecl wscanf(const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
1159   {
1160     __builtin_va_list ap;
1161     int ret;
1162     __builtin_va_start(ap, _Format);
1163     ret = __stdio_common_vfwscanf(UCRTBASE_SCANF_DEFAULT_WIDE, stdin, _Format, NULL, ap);
1164     __builtin_va_end(ap);
1165     return ret;
1166   }
1167   __mingw_ovr
1168   __MINGW_ATTRIB_NONNULL(2)
vfwscanf(FILE * __stream,const wchar_t * __format,va_list __local_argv)1169   int vfwscanf (FILE *__stream,  const wchar_t *__format, va_list __local_argv)
1170   {
1171     return __stdio_common_vfwscanf(UCRTBASE_SCANF_DEFAULT_WIDE, __stream, __format, NULL, __local_argv);
1172   }
1173 
1174   __mingw_ovr
1175   __MINGW_ATTRIB_NONNULL(2)
vswscanf(const wchar_t * __restrict__ __source,const wchar_t * __restrict__ __format,va_list __local_argv)1176   int vswscanf (const wchar_t * __restrict__ __source, const wchar_t * __restrict__ __format, va_list __local_argv)
1177   {
1178     return __stdio_common_vswscanf(UCRTBASE_SCANF_DEFAULT_WIDE, __source, (size_t)-1, __format, NULL, __local_argv);
1179   }
1180   __mingw_ovr
1181   __MINGW_ATTRIB_NONNULL(1)
vwscanf(const wchar_t * __format,va_list __local_argv)1182   int vwscanf(const wchar_t *__format, va_list __local_argv)
1183   {
1184     return __stdio_common_vfwscanf(UCRTBASE_SCANF_DEFAULT_WIDE, stdin, __format, NULL, __local_argv);
1185   }
1186 
1187   __mingw_static_ovr
fwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...)1188   int __cdecl fwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...)
1189   {
1190     __builtin_va_list ap;
1191     int ret;
1192     __builtin_va_start(ap, _Format);
1193     ret = __stdio_common_vfwprintf(UCRTBASE_PRINTF_DEFAULT_WIDE, _File, _Format, NULL, ap);
1194     __builtin_va_end(ap);
1195     return ret;
1196   }
1197   __mingw_ovr
wprintf(const wchar_t * __restrict__ _Format,...)1198   int __cdecl wprintf(const wchar_t * __restrict__ _Format,...)
1199   {
1200     __builtin_va_list ap;
1201     int ret;
1202     __builtin_va_start(ap, _Format);
1203     ret = __stdio_common_vfwprintf(UCRTBASE_PRINTF_DEFAULT_WIDE, stdout, _Format, NULL, ap);
1204     __builtin_va_end(ap);
1205     return ret;
1206   }
1207   __mingw_ovr
vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList)1208   int __cdecl vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList)
1209   {
1210     return __stdio_common_vfwprintf(UCRTBASE_PRINTF_DEFAULT_WIDE, _File, _Format, NULL, _ArgList);
1211   }
1212   __mingw_ovr
vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList)1213   int __cdecl vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList)
1214   {
1215     return __stdio_common_vfwprintf(UCRTBASE_PRINTF_DEFAULT_WIDE, stdout, _Format, NULL, _ArgList);
1216   }
1217 #else
1218 
1219   int __cdecl fwscanf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
1220   int __cdecl swscanf(const wchar_t * __restrict__ _Src,const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
1221   int __cdecl wscanf(const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
1222 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
1223   int __cdecl __ms_vwscanf (const wchar_t * __restrict__ , va_list);
1224   int __cdecl __ms_vfwscanf (FILE * __restrict__ ,const wchar_t * __restrict__ ,va_list);
1225   int __cdecl __ms_vswscanf (const wchar_t * __restrict__ ,const wchar_t * __restrict__ ,va_list);
1226 
1227   __mingw_ovr
1228   __MINGW_ATTRIB_NONNULL(2)
vfwscanf(FILE * __stream,const wchar_t * __format,__builtin_va_list __local_argv)1229   int vfwscanf (FILE *__stream,  const wchar_t *__format, __builtin_va_list __local_argv)
1230   {
1231     return __ms_vfwscanf (__stream, __format, __local_argv);
1232   }
1233 
1234   __mingw_ovr
1235   __MINGW_ATTRIB_NONNULL(2)
vswscanf(const wchar_t * __restrict__ __source,const wchar_t * __restrict__ __format,__builtin_va_list __local_argv)1236   int vswscanf (const wchar_t * __restrict__ __source, const wchar_t * __restrict__ __format, __builtin_va_list __local_argv)
1237   {
1238     return __ms_vswscanf( __source, __format, __local_argv );
1239   }
1240   __mingw_ovr
1241   __MINGW_ATTRIB_NONNULL(1)
vwscanf(const wchar_t * __format,__builtin_va_list __local_argv)1242   int vwscanf(const wchar_t *__format,  __builtin_va_list __local_argv)
1243   {
1244     return __ms_vwscanf (__format, __local_argv);
1245   }
1246 
1247 #endif /* __NO_ISOCEXT */
1248 
1249   int __cdecl fwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...);
1250   int __cdecl wprintf(const wchar_t * __restrict__ _Format,...);
1251   int __cdecl vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList);
1252   int __cdecl vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList);
1253 #endif /* _UCRT */
1254 #endif /* __USE_MINGW_ANSI_STDIO */
1255 
1256 #ifndef WEOF
1257 #define WEOF (wint_t)(0xFFFF)
1258 #endif
1259 
1260 #ifdef _POSIX_
1261   _CRTIMP FILE *__cdecl _wfsopen(const wchar_t *_Filename,const wchar_t *_Mode);
1262 #else
1263   _CRTIMP FILE *__cdecl _wfsopen(const wchar_t *_Filename,const wchar_t *_Mode,int _ShFlag);
1264 #endif
1265 
1266   wint_t __cdecl fgetwc(FILE *_File);
1267   _CRTIMP wint_t __cdecl _fgetwchar(void);
1268   wint_t __cdecl fputwc(wchar_t _Ch,FILE *_File);
1269   _CRTIMP wint_t __cdecl _fputwchar(wchar_t _Ch);
1270   wint_t __cdecl getwc(FILE *_File);
1271   wint_t __cdecl getwchar(void);
1272   wint_t __cdecl putwc(wchar_t _Ch,FILE *_File);
1273   wint_t __cdecl putwchar(wchar_t _Ch);
1274   wint_t __cdecl ungetwc(wint_t _Ch,FILE *_File);
1275   wchar_t *__cdecl fgetws(wchar_t * __restrict__ _Dst,int _SizeInWords,FILE * __restrict__ _File);
1276   int __cdecl fputws(const wchar_t * __restrict__ _Str,FILE * __restrict__ _File);
1277   _CRTIMP wchar_t *__cdecl _getws(wchar_t *_String) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
1278   _CRTIMP int __cdecl _putws(const wchar_t *_Str);
1279 
1280 #ifdef _UCRT
1281   __mingw_ovr
_scwprintf(const wchar_t * __restrict__ _Format,...)1282   int __cdecl _scwprintf(const wchar_t * __restrict__ _Format,...)
1283   {
1284     __builtin_va_list ap;
1285     int ret;
1286     __builtin_va_start(ap, _Format);
1287     ret = __stdio_common_vswprintf(UCRTBASE_PRINTF_DEFAULT_WIDE | UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, NULL, 0, _Format, NULL, ap);
1288     __builtin_va_end(ap);
1289     return ret;
1290   }
1291   __mingw_static_ovr
_snwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...)1292   int __cdecl _snwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
1293   {
1294     __builtin_va_list ap;
1295     int ret;
1296     __builtin_va_start(ap, _Format);
1297     ret = __stdio_common_vswprintf(UCRTBASE_PRINTF_DEFAULT_WIDE | UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, _Dest, _Count, _Format, NULL, ap);
1298     __builtin_va_end(ap);
1299     return ret;
1300   }
1301   int __cdecl _vsnwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
1302 
1303 #if __USE_MINGW_ANSI_STDIO == 0
1304   __mingw_ovr
snwprintf(wchar_t * __restrict__ s,size_t n,const wchar_t * __restrict__ format,...)1305   int snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...)
1306   {
1307     __builtin_va_list ap;
1308     int ret;
1309     __builtin_va_start(ap, format);
1310     ret = __stdio_common_vswprintf(UCRTBASE_PRINTF_DEFAULT_WIDE | UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, s, n, format, NULL, ap);
1311     __builtin_va_end(ap);
1312     return ret;
1313   }
1314   __mingw_ovr
vsnwprintf(wchar_t * __restrict__ s,size_t n,const wchar_t * __restrict__ format,va_list arg)1315   int __cdecl vsnwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, va_list arg)
1316   {
1317     return __stdio_common_vswprintf(UCRTBASE_PRINTF_DEFAULT_WIDE | UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, s, n, format, NULL, arg);
1318   }
1319 #endif
1320 
1321   __mingw_ovr
_swprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,...)1322   int __cdecl _swprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,...)
1323   {
1324     __builtin_va_list ap;
1325     int ret;
1326     __builtin_va_start(ap, _Format);
1327     ret = __stdio_common_vswprintf(UCRTBASE_PRINTF_DEFAULT_WIDE, _Dest, (size_t)-1, _Format, NULL, ap);
1328     __builtin_va_end(ap);
1329     return ret;
1330   }
1331   __mingw_ovr
_vswprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,va_list _Args)1332   int __cdecl _vswprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,va_list _Args)
1333   {
1334     return __stdio_common_vswprintf(UCRTBASE_PRINTF_DEFAULT_WIDE, _Dest, (size_t)-1, _Format, NULL, _Args);
1335   }
1336 
1337   __mingw_ovr
_vscwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList)1338   int __cdecl _vscwprintf(const wchar_t * __restrict__ _Format, va_list _ArgList)
1339   {
1340       int _Result = __stdio_common_vswprintf(UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, NULL, 0, _Format, NULL, _ArgList);
1341       return _Result < 0 ? -1 : _Result;
1342   }
1343 #else
1344   _CRTIMP int __cdecl _scwprintf(const wchar_t * __restrict__ _Format,...);
1345   _CRTIMP int __cdecl _swprintf_c(wchar_t * __restrict__ _DstBuf,size_t _SizeInWords,const wchar_t * __restrict__ _Format,...);
1346   _CRTIMP int __cdecl _vswprintf_c(wchar_t * __restrict__ _DstBuf,size_t _SizeInWords,const wchar_t * __restrict__ _Format,va_list _ArgList);
1347   _CRTIMP int __cdecl _snwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
1348   _CRTIMP int __cdecl _vsnwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
1349   _CRTIMP int __cdecl _vscwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList);
1350 
1351 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
1352 
1353 #if __USE_MINGW_ANSI_STDIO == 0
1354 #pragma push_macro("snwprintf")
1355 #pragma push_macro("vsnwprintf")
1356 # undef snwprintf
1357 # undef vsnwprintf
1358   int __cdecl __ms_snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...);
1359   int __cdecl __ms_vsnwprintf (wchar_t * __restrict__ , size_t, const wchar_t * __restrict__ , va_list);
1360   __mingw_ovr
snwprintf(wchar_t * __restrict__ s,size_t n,const wchar_t * __restrict__ format,...)1361   int snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...)
1362   {
1363     int r;
1364     va_list argp;
1365     __builtin_va_start (argp, format);
1366     r = _vsnwprintf (s, n, format, argp);
1367     __builtin_va_end (argp);
1368     return r;
1369   }
1370   __mingw_ovr
vsnwprintf(wchar_t * __restrict__ s,size_t n,const wchar_t * __restrict__ format,va_list arg)1371   int __cdecl vsnwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, va_list arg)
1372   {
1373     return _vsnwprintf(s,n,format,arg);
1374   }
1375 #pragma pop_macro ("vsnwprintf")
1376 #pragma pop_macro ("snwprintf")
1377 #endif
1378 
1379 #endif /* ! __NO_ISOCEXT */
1380   _CRTIMP int __cdecl _swprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,...);
1381   _CRTIMP int __cdecl _vswprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,va_list _Args);
1382 #endif /* _UCRT */
1383 
1384 #ifndef RC_INVOKED
1385 #include <swprintf.inl>
1386 #endif
1387 
1388 #ifdef _CRT_NON_CONFORMING_SWPRINTFS
1389 #ifndef __cplusplus
1390 #define _swprintf_l __swprintf_l
1391 #define _vswprintf_l __vswprintf_l
1392 #endif
1393 #endif
1394 
1395   _CRTIMP wchar_t *__cdecl _wtempnam(const wchar_t *_Directory,const wchar_t *_FilePrefix);
1396   _CRTIMP int __cdecl _snwscanf(const wchar_t * __restrict__ _Src,size_t _MaxCount,const wchar_t * __restrict__ _Format,...);
1397   _CRTIMP FILE *__cdecl _wfdopen(int _FileHandle ,const wchar_t *_Mode);
1398   _CRTIMP FILE *__cdecl _wfopen(const wchar_t * __restrict__ _Filename,const wchar_t *__restrict__  _Mode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
1399   _CRTIMP FILE *__cdecl _wfreopen(const wchar_t * __restrict__ _Filename,const wchar_t * __restrict__ _Mode,FILE * __restrict__ _OldFile) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
1400 
1401 #ifndef _CRT_WPERROR_DEFINED
1402 #define _CRT_WPERROR_DEFINED
1403   _CRTIMP void __cdecl _wperror(const wchar_t *_ErrMsg);
1404 #endif
1405   _CRTIMP FILE *__cdecl _wpopen(const wchar_t *_Command,const wchar_t *_Mode);
1406 #if !defined(NO_OLDNAMES) && !defined(wpopen)
1407 #define wpopen	_wpopen
1408 #endif
1409 
1410   _CRTIMP int __cdecl _wremove(const wchar_t *_Filename);
1411   _CRTIMP wchar_t *__cdecl _wtmpnam(wchar_t *_Buffer);
1412   _CRTIMP wint_t __cdecl _fgetwc_nolock(FILE *_File);
1413   _CRTIMP wint_t __cdecl _fputwc_nolock(wchar_t _Ch,FILE *_File);
1414   _CRTIMP wint_t __cdecl _ungetwc_nolock(wint_t _Ch,FILE *_File);
1415 
1416 #undef _CRT_GETPUTWCHAR_NOINLINE
1417 
1418 #if !defined(__cplusplus) || defined(_CRT_GETPUTWCHAR_NOINLINE) || defined (__CRT__NO_INLINE)
1419 #define getwchar() fgetwc(stdin)
1420 #define putwchar(_c) fputwc((_c),stdout)
1421 #else
getwchar()1422   __CRT_INLINE wint_t __cdecl getwchar() {return (fgetwc(stdin)); }
putwchar(wchar_t _C)1423   __CRT_INLINE wint_t __cdecl putwchar(wchar_t _C) {return (fputwc(_C,stdout)); }
1424 #endif
1425 
1426 #define getwc(_stm) fgetwc(_stm)
1427 #define putwc(_c,_stm) fputwc(_c,_stm)
1428 #define _putwc_nolock(_c,_stm) _fputwc_nolock(_c,_stm)
1429 #define _getwc_nolock(_c) _fgetwc_nolock(_c)
1430 #endif
1431 
1432 #define _STDIO_DEFINED
1433 #endif
1434 
1435 #ifdef _UCRT
1436   _CRTIMP int __cdecl _fgetc_nolock(FILE *_File);
1437   _CRTIMP int __cdecl _fputc_nolock(int _Char, FILE *_File);
1438   _CRTIMP int __cdecl _getc_nolock(FILE *_File);
1439   _CRTIMP int __cdecl _putc_nolock(int _Char, FILE *_File);
1440 #else
1441 #define _fgetc_nolock(_stream) (--(_stream)->_cnt >= 0 ? 0xff & *(_stream)->_ptr++ : _filbuf(_stream))
1442 #define _fputc_nolock(_c,_stream) (--(_stream)->_cnt >= 0 ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream)))
1443 #define _getc_nolock(_stream) _fgetc_nolock(_stream)
1444 #define _putc_nolock(_c,_stream) _fputc_nolock(_c,_stream)
1445 #endif
1446 #define _getchar_nolock() _getc_nolock(stdin)
1447 #define _putchar_nolock(_c) _putc_nolock((_c),stdout)
1448 #define _getwchar_nolock() _getwc_nolock(stdin)
1449 #define _putwchar_nolock(_c) _putwc_nolock((_c),stdout)
1450 
1451   _CRTIMP void __cdecl _lock_file(FILE *_File);
1452   _CRTIMP void __cdecl _unlock_file(FILE *_File);
1453   _CRTIMP int __cdecl _fclose_nolock(FILE *_File);
1454   _CRTIMP int __cdecl _fflush_nolock(FILE *_File);
1455   _CRTIMP size_t __cdecl _fread_nolock(void * __restrict__ _DstBuf,size_t _ElementSize,size_t _Count,FILE * __restrict__ _File);
1456   _CRTIMP int __cdecl _fseek_nolock(FILE *_File,long _Offset,int _Origin);
1457   _CRTIMP long __cdecl _ftell_nolock(FILE *_File);
1458   __MINGW_EXTENSION _CRTIMP int __cdecl _fseeki64_nolock(FILE *_File,__int64 _Offset,int _Origin);
1459   __MINGW_EXTENSION _CRTIMP __int64 __cdecl _ftelli64_nolock(FILE *_File);
1460   _CRTIMP size_t __cdecl _fwrite_nolock(const void * __restrict__ _DstBuf,size_t _Size,size_t _Count,FILE * __restrict__ _File);
1461   _CRTIMP int __cdecl _ungetc_nolock(int _Ch,FILE *_File);
1462 
1463 #if !defined(NO_OLDNAMES) || !defined(_POSIX)
1464 #define P_tmpdir _P_tmpdir
1465 #define SYS_OPEN _SYS_OPEN
1466 
1467   char *__cdecl tempnam(const char *_Directory,const char *_FilePrefix) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
1468   int __cdecl fcloseall(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
1469   FILE *__cdecl fdopen(int _FileHandle,const char *_Format) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
1470   int __cdecl fgetchar(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
1471   int __cdecl fileno(FILE *_File) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
1472   int __cdecl flushall(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
1473   int __cdecl fputchar(int _Ch) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
1474   int __cdecl getw(FILE *_File) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
1475   int __cdecl putw(int _Ch,FILE *_File) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
1476   int __cdecl rmtmp(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
1477 #endif
1478 
1479 #ifndef __MINGW_MBWC_CONVERT_DEFINED
1480 #define __MINGW_MBWC_CONVERT_DEFINED
1481 
1482 /**
1483  * __mingw_str_wide_utf8
1484  * Converts a null terminated UCS-2 string to a multibyte (UTF-8) equivalent.
1485  * Caller is supposed to free allocated buffer with __mingw_str_free().
1486  * @param[in] wptr Pointer to wide string.
1487  * @param[out] mbptr Pointer to multibyte string.
1488  * @param[out] buflen Optional parameter for length of allocated buffer.
1489  * @return Number of characters converted, 0 for failure.
1490  *
1491  * WideCharToMultiByte - http://msdn.microsoft.com/en-us/library/dd374130(VS.85).aspx
1492  */
1493 int __cdecl __mingw_str_wide_utf8 (const wchar_t * const wptr, char **mbptr, size_t * buflen);
1494 
1495 /**
1496  * __mingw_str_utf8_wide
1497  * Converts a null terminated UTF-8 string to a UCS-2 equivalent.
1498  * Caller is supposed to free allocated buffer with __mingw_str_free().
1499  * @param[out] mbptr Pointer to multibyte string.
1500  * @param[in] wptr Pointer to wide string.
1501  * @param[out] buflen Optional parameter for length of allocated buffer.
1502  * @return Number of characters converted, 0 for failure.
1503  *
1504  * MultiByteToWideChar - http://msdn.microsoft.com/en-us/library/dd319072(VS.85).aspx
1505  */
1506 
1507 int __cdecl __mingw_str_utf8_wide (const char *const mbptr, wchar_t ** wptr, size_t * buflen);
1508 
1509 /**
1510  * __mingw_str_free
1511  * Frees buffer create by __mingw_str_wide_utf8 and __mingw_str_utf8_wide.
1512  * @param[in] ptr memory block to free.
1513  *
1514  */
1515 
1516 void __cdecl __mingw_str_free(void *ptr);
1517 
1518 #endif /* __MINGW_MBWC_CONVERT_DEFINED */
1519 
1520 #ifndef _WSPAWN_DEFINED
1521 #define _WSPAWN_DEFINED
1522   _CRTIMP intptr_t __cdecl _wspawnl(int _Mode,const wchar_t *_Filename,const wchar_t *_ArgList,...);
1523   _CRTIMP intptr_t __cdecl _wspawnle(int _Mode,const wchar_t *_Filename,const wchar_t *_ArgList,...);
1524   _CRTIMP intptr_t __cdecl _wspawnlp(int _Mode,const wchar_t *_Filename,const wchar_t *_ArgList,...);
1525   _CRTIMP intptr_t __cdecl _wspawnlpe(int _Mode,const wchar_t *_Filename,const wchar_t *_ArgList,...);
1526   _CRTIMP intptr_t __cdecl _wspawnv(int _Mode,const wchar_t *_Filename,const wchar_t *const *_ArgList);
1527   _CRTIMP intptr_t __cdecl _wspawnve(int _Mode,const wchar_t *_Filename,const wchar_t *const *_ArgList,const wchar_t *const *_Env);
1528   _CRTIMP intptr_t __cdecl _wspawnvp(int _Mode,const wchar_t *_Filename,const wchar_t *const *_ArgList);
1529   _CRTIMP intptr_t __cdecl _wspawnvpe(int _Mode,const wchar_t *_Filename,const wchar_t *const *_ArgList,const wchar_t *const *_Env);
1530 #endif
1531 
1532 #ifndef _P_WAIT
1533 #define _P_WAIT 0
1534 #define _P_NOWAIT 1
1535 #define _OLD_P_OVERLAY 2
1536 #define _P_NOWAITO 3
1537 #define _P_DETACH 4
1538 #define _P_OVERLAY 2
1539 
1540 #define _WAIT_CHILD 0
1541 #define _WAIT_GRANDCHILD 1
1542 #endif
1543 
1544 #ifndef _SPAWNV_DEFINED
1545 #define _SPAWNV_DEFINED
1546   _CRTIMP intptr_t __cdecl _spawnv(int _Mode,const char *_Filename,const char *const *_ArgList);
1547   _CRTIMP intptr_t __cdecl _spawnve(int _Mode,const char *_Filename,const char *const *_ArgList,const char *const *_Env);
1548   _CRTIMP intptr_t __cdecl _spawnvp(int _Mode,const char *_Filename,const char *const *_ArgList);
1549   _CRTIMP intptr_t __cdecl _spawnvpe(int _Mode,const char *_Filename,const char *const *_ArgList,const char *const *_Env);
1550 #endif
1551 
1552 #ifdef __cplusplus
1553 }
1554 #endif
1555 
1556 #pragma pack(pop)
1557 
1558 #include <sec_api/stdio_s.h>
1559 
1560 #endif
1561