stdio.h 61 KB

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