stdio.in.h 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  1. /* A GNU-like <stdio.h>.
  2. Copyright (C) 2004, 2007-2023 Free Software Foundation, Inc.
  3. This file is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as
  5. published by the Free Software Foundation; either version 2.1 of the
  6. License, or (at your option) any later version.
  7. This file is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  13. #if __GNUC__ >= 3
  14. @PRAGMA_SYSTEM_HEADER@
  15. #endif
  16. @PRAGMA_COLUMNS@
  17. #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
  18. /* Special invocation convention:
  19. - Inside glibc header files.
  20. - On OSF/1 5.1 we have a sequence of nested includes
  21. <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
  22. <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
  23. In this situation, the functions are not yet declared, therefore we cannot
  24. provide the C++ aliases. */
  25. #@INCLUDE_NEXT@ @NEXT_STDIO_H@
  26. #else
  27. /* Normal invocation convention. */
  28. #ifndef _@GUARD_PREFIX@_STDIO_H
  29. #define _GL_ALREADY_INCLUDING_STDIO_H
  30. /* The include_next requires a split double-inclusion guard. */
  31. #@INCLUDE_NEXT@ @NEXT_STDIO_H@
  32. #undef _GL_ALREADY_INCLUDING_STDIO_H
  33. #ifndef _@GUARD_PREFIX@_STDIO_H
  34. #define _@GUARD_PREFIX@_STDIO_H
  35. /* Get va_list. Needed on many systems, including glibc 2.8. */
  36. #include <stdarg.h>
  37. #include <stddef.h>
  38. /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
  39. and eglibc 2.11.2.
  40. May also define off_t to a 64-bit type on native Windows. */
  41. #include <sys/types.h>
  42. /* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
  43. /* But in any case avoid namespace pollution on glibc systems. */
  44. #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
  45. && ! defined __GLIBC__
  46. # include <unistd.h>
  47. #endif
  48. /* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>. */
  49. /* But in any case avoid namespace pollution on glibc systems. */
  50. #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
  51. && ! defined __GLIBC__
  52. # include <sys/stat.h>
  53. #endif
  54. /* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include
  55. it before we #define perror rpl_perror. */
  56. /* But in any case avoid namespace pollution on glibc systems. */
  57. #if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
  58. && (defined _WIN32 && ! defined __CYGWIN__) \
  59. && ! defined __GLIBC__
  60. # include <stdlib.h>
  61. #endif
  62. /* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include
  63. it before we #define remove rpl_remove. */
  64. /* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include
  65. it before we #define rename rpl_rename. */
  66. /* But in any case avoid namespace pollution on glibc systems. */
  67. #if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
  68. && (defined _WIN32 && ! defined __CYGWIN__) \
  69. && ! defined __GLIBC__
  70. # include <io.h>
  71. #endif
  72. /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
  73. that can be freed by passing them as the Ith argument to the
  74. function F. */
  75. #ifndef _GL_ATTRIBUTE_DEALLOC
  76. # if __GNUC__ >= 11
  77. # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
  78. # else
  79. # define _GL_ATTRIBUTE_DEALLOC(f, i)
  80. # endif
  81. #endif
  82. /* The __attribute__ feature is available in gcc versions 2.5 and later.
  83. The __-protected variants of the attributes 'format' and 'printf' are
  84. accepted by gcc versions 2.6.4 (effectively 2.7) and later.
  85. We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
  86. gnulib and libintl do '#define printf __printf__' when they override
  87. the 'printf' function. */
  88. #ifndef _GL_ATTRIBUTE_FORMAT
  89. # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__
  90. # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
  91. # else
  92. # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
  93. # endif
  94. #endif
  95. /* An __attribute__ __format__ specifier for a function that takes a format
  96. string and arguments, where the format string directives are the ones
  97. standardized by ISO C99 and POSIX.
  98. _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */
  99. /* __gnu_printf__ is supported in GCC >= 4.4. */
  100. #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
  101. # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
  102. #else
  103. # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
  104. #endif
  105. /* An __attribute__ __format__ specifier for a function that takes a format
  106. string and arguments, where the format string directives are the ones of the
  107. system printf(), rather than the ones standardized by ISO C99 and POSIX.
  108. _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM */
  109. /* On mingw, Gnulib sets __USE_MINGW_ANSI_STDIO in order to get closer to
  110. the standards. The macro GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU indicates
  111. whether this change is effective. On older mingw, it is not. */
  112. #if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
  113. # define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
  114. #else
  115. # define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM __printf__
  116. #endif
  117. /* _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD
  118. indicates to GCC that the function takes a format string and arguments,
  119. where the format string directives are the ones standardized by ISO C99
  120. and POSIX. */
  121. #define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
  122. _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, formatstring_parameter, first_argument))
  123. /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD,
  124. except that it indicates to GCC that the supported format string directives
  125. are the ones of the system printf(), rather than the ones standardized by
  126. ISO C99 and POSIX. */
  127. #define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
  128. _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, formatstring_parameter, first_argument))
  129. /* _GL_ATTRIBUTE_FORMAT_SCANF
  130. indicates to GCC that the function takes a format string and arguments,
  131. where the format string directives are the ones standardized by ISO C99
  132. and POSIX. */
  133. #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
  134. # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
  135. _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
  136. #else
  137. # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
  138. _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
  139. #endif
  140. /* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
  141. except that it indicates to GCC that the supported format string directives
  142. are the ones of the system scanf(), rather than the ones standardized by
  143. ISO C99 and POSIX. */
  144. #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
  145. _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
  146. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  147. /* The definition of _GL_ARG_NONNULL is copied here. */
  148. /* The definition of _GL_WARN_ON_USE is copied here. */
  149. /* Macros for stringification. */
  150. #define _GL_STDIO_STRINGIZE(token) #token
  151. #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
  152. /* When also using extern inline, suppress the use of static inline in
  153. standard headers of problematic Apple configurations, as Libc at
  154. least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
  155. <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
  156. Perhaps Apple will fix this some day. */
  157. #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
  158. && defined __GNUC__ && defined __STDC__)
  159. # undef putc_unlocked
  160. #endif
  161. #if @GNULIB_DPRINTF@
  162. # if @REPLACE_DPRINTF@
  163. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  164. # define dprintf rpl_dprintf
  165. # endif
  166. _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...)
  167. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
  168. _GL_ARG_NONNULL ((2)));
  169. _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...));
  170. # else
  171. # if !@HAVE_DPRINTF@
  172. _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...)
  173. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
  174. _GL_ARG_NONNULL ((2)));
  175. # endif
  176. _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...));
  177. # endif
  178. _GL_CXXALIASWARN (dprintf);
  179. #elif defined GNULIB_POSIXCHECK
  180. # undef dprintf
  181. # if HAVE_RAW_DECL_DPRINTF
  182. _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
  183. "use gnulib module dprintf for portability");
  184. # endif
  185. #endif
  186. #if @GNULIB_FCLOSE@
  187. /* Close STREAM and its underlying file descriptor. */
  188. # if @REPLACE_FCLOSE@
  189. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  190. # define fclose rpl_fclose
  191. # endif
  192. _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
  193. _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
  194. # else
  195. _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
  196. # endif
  197. # if __GLIBC__ >= 2
  198. _GL_CXXALIASWARN (fclose);
  199. # endif
  200. #elif defined GNULIB_POSIXCHECK
  201. # undef fclose
  202. /* Assume fclose is always declared. */
  203. _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
  204. "use gnulib module fclose for portable POSIX compliance");
  205. #endif
  206. #if @GNULIB_MDA_FCLOSEALL@
  207. /* On native Windows, map 'fcloseall' to '_fcloseall', so that -loldnames is
  208. not required. In C++ with GNULIB_NAMESPACE, avoid differences between
  209. platforms by defining GNULIB_NAMESPACE::fcloseall on all platforms that have
  210. it. */
  211. # if defined _WIN32 && !defined __CYGWIN__
  212. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  213. # undef fcloseall
  214. # define fcloseall _fcloseall
  215. # endif
  216. _GL_CXXALIAS_MDA (fcloseall, int, (void));
  217. # else
  218. # if @HAVE_DECL_FCLOSEALL@
  219. # if defined __FreeBSD__ || defined __DragonFly__
  220. _GL_CXXALIAS_SYS (fcloseall, void, (void));
  221. # else
  222. _GL_CXXALIAS_SYS (fcloseall, int, (void));
  223. # endif
  224. # endif
  225. # endif
  226. # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCLOSEALL@
  227. _GL_CXXALIASWARN (fcloseall);
  228. # endif
  229. #endif
  230. #if @GNULIB_FDOPEN@
  231. # if @REPLACE_FDOPEN@
  232. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  233. # undef fdopen
  234. # define fdopen rpl_fdopen
  235. # endif
  236. _GL_FUNCDECL_RPL (fdopen, FILE *,
  237. (int fd, const char *mode)
  238. _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
  239. _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
  240. # elif defined _WIN32 && !defined __CYGWIN__
  241. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  242. # undef fdopen
  243. # define fdopen _fdopen
  244. # endif
  245. _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
  246. # else
  247. # if __GNUC__ >= 11
  248. /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
  249. _GL_FUNCDECL_SYS (fdopen, FILE *,
  250. (int fd, const char *mode)
  251. _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
  252. # endif
  253. _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
  254. # endif
  255. _GL_CXXALIASWARN (fdopen);
  256. #else
  257. # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen
  258. /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
  259. _GL_FUNCDECL_SYS (fdopen, FILE *,
  260. (int fd, const char *mode)
  261. _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
  262. # endif
  263. # if defined GNULIB_POSIXCHECK
  264. # undef fdopen
  265. /* Assume fdopen is always declared. */
  266. _GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
  267. "use gnulib module fdopen for portability");
  268. # elif @GNULIB_MDA_FDOPEN@
  269. /* On native Windows, map 'fdopen' to '_fdopen', so that -loldnames is not
  270. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  271. platforms by defining GNULIB_NAMESPACE::fdopen always. */
  272. # if defined _WIN32 && !defined __CYGWIN__
  273. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  274. # undef fdopen
  275. # define fdopen _fdopen
  276. # endif
  277. _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
  278. # else
  279. _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
  280. # endif
  281. _GL_CXXALIASWARN (fdopen);
  282. # endif
  283. #endif
  284. #if @GNULIB_FFLUSH@
  285. /* Flush all pending data on STREAM according to POSIX rules. Both
  286. output and seekable input streams are supported.
  287. Note! LOSS OF DATA can occur if fflush is applied on an input stream
  288. that is _not_seekable_ or on an update stream that is _not_seekable_
  289. and in which the most recent operation was input. Seekability can
  290. be tested with lseek(fileno(fp),0,SEEK_CUR). */
  291. # if @REPLACE_FFLUSH@
  292. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  293. # define fflush rpl_fflush
  294. # endif
  295. _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
  296. _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
  297. # else
  298. _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
  299. # endif
  300. # if __GLIBC__ >= 2
  301. _GL_CXXALIASWARN (fflush);
  302. # endif
  303. #elif defined GNULIB_POSIXCHECK
  304. # undef fflush
  305. /* Assume fflush is always declared. */
  306. _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
  307. "use gnulib module fflush for portable POSIX compliance");
  308. #endif
  309. #if @GNULIB_FGETC@
  310. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  311. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  312. # undef fgetc
  313. # define fgetc rpl_fgetc
  314. # endif
  315. _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
  316. _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
  317. # else
  318. _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
  319. # endif
  320. # if __GLIBC__ >= 2
  321. _GL_CXXALIASWARN (fgetc);
  322. # endif
  323. #endif
  324. #if @GNULIB_FGETS@
  325. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  326. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  327. # undef fgets
  328. # define fgets rpl_fgets
  329. # endif
  330. _GL_FUNCDECL_RPL (fgets, char *,
  331. (char *restrict s, int n, FILE *restrict stream)
  332. _GL_ARG_NONNULL ((1, 3)));
  333. _GL_CXXALIAS_RPL (fgets, char *,
  334. (char *restrict s, int n, FILE *restrict stream));
  335. # else
  336. _GL_CXXALIAS_SYS (fgets, char *,
  337. (char *restrict s, int n, FILE *restrict stream));
  338. # endif
  339. # if __GLIBC__ >= 2
  340. _GL_CXXALIASWARN (fgets);
  341. # endif
  342. #endif
  343. #if @GNULIB_MDA_FILENO@
  344. /* On native Windows, map 'fileno' to '_fileno', so that -loldnames is not
  345. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  346. platforms by defining GNULIB_NAMESPACE::fileno always. */
  347. # if defined _WIN32 && !defined __CYGWIN__
  348. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  349. # undef fileno
  350. # define fileno _fileno
  351. # endif
  352. _GL_CXXALIAS_MDA (fileno, int, (FILE *restrict stream));
  353. # else
  354. _GL_CXXALIAS_SYS (fileno, int, (FILE *restrict stream));
  355. # endif
  356. _GL_CXXALIASWARN (fileno);
  357. #endif
  358. #if @GNULIB_FOPEN@
  359. # if (@GNULIB_FOPEN@ && @REPLACE_FOPEN@) \
  360. || (@GNULIB_FOPEN_GNU@ && @REPLACE_FOPEN_FOR_FOPEN_GNU@)
  361. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  362. # undef fopen
  363. # define fopen rpl_fopen
  364. # endif
  365. _GL_FUNCDECL_RPL (fopen, FILE *,
  366. (const char *restrict filename, const char *restrict mode)
  367. _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
  368. _GL_CXXALIAS_RPL (fopen, FILE *,
  369. (const char *restrict filename, const char *restrict mode));
  370. # else
  371. # if __GNUC__ >= 11
  372. /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
  373. _GL_FUNCDECL_SYS (fopen, FILE *,
  374. (const char *restrict filename, const char *restrict mode)
  375. _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
  376. # endif
  377. _GL_CXXALIAS_SYS (fopen, FILE *,
  378. (const char *restrict filename, const char *restrict mode));
  379. # endif
  380. # if __GLIBC__ >= 2
  381. _GL_CXXALIASWARN (fopen);
  382. # endif
  383. #else
  384. # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen
  385. /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
  386. _GL_FUNCDECL_SYS (fopen, FILE *,
  387. (const char *restrict filename, const char *restrict mode)
  388. _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
  389. # endif
  390. # if defined GNULIB_POSIXCHECK
  391. # undef fopen
  392. /* Assume fopen is always declared. */
  393. _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
  394. "use gnulib module fopen for portability");
  395. # endif
  396. #endif
  397. #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
  398. # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
  399. || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  400. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  401. # define fprintf rpl_fprintf
  402. # endif
  403. # define GNULIB_overrides_fprintf 1
  404. # if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
  405. _GL_FUNCDECL_RPL (fprintf, int,
  406. (FILE *restrict fp, const char *restrict format, ...)
  407. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
  408. _GL_ARG_NONNULL ((1, 2)));
  409. # else
  410. _GL_FUNCDECL_RPL (fprintf, int,
  411. (FILE *restrict fp, const char *restrict format, ...)
  412. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
  413. _GL_ARG_NONNULL ((1, 2)));
  414. # endif
  415. _GL_CXXALIAS_RPL (fprintf, int,
  416. (FILE *restrict fp, const char *restrict format, ...));
  417. # else
  418. _GL_CXXALIAS_SYS (fprintf, int,
  419. (FILE *restrict fp, const char *restrict format, ...));
  420. # endif
  421. # if __GLIBC__ >= 2
  422. _GL_CXXALIASWARN (fprintf);
  423. # endif
  424. #endif
  425. #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  426. # if !GNULIB_overrides_fprintf
  427. # undef fprintf
  428. # endif
  429. /* Assume fprintf is always declared. */
  430. _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
  431. "use gnulib module fprintf-posix for portable "
  432. "POSIX compliance");
  433. #endif
  434. #if @GNULIB_FPURGE@
  435. /* Discard all pending buffered I/O data on STREAM.
  436. STREAM must not be wide-character oriented.
  437. When discarding pending output, the file position is set back to where it
  438. was before the write calls. When discarding pending input, the file
  439. position is advanced to match the end of the previously read input.
  440. Return 0 if successful. Upon error, return -1 and set errno. */
  441. # if @REPLACE_FPURGE@
  442. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  443. # define fpurge rpl_fpurge
  444. # endif
  445. _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
  446. _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
  447. # else
  448. # if !@HAVE_DECL_FPURGE@
  449. _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
  450. # endif
  451. _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
  452. # endif
  453. _GL_CXXALIASWARN (fpurge);
  454. #elif defined GNULIB_POSIXCHECK
  455. # undef fpurge
  456. # if HAVE_RAW_DECL_FPURGE
  457. _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
  458. "use gnulib module fpurge for portability");
  459. # endif
  460. #endif
  461. #if @GNULIB_FPUTC@
  462. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  463. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  464. # undef fputc
  465. # define fputc rpl_fputc
  466. # endif
  467. _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
  468. _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
  469. # else
  470. _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
  471. # endif
  472. # if __GLIBC__ >= 2
  473. _GL_CXXALIASWARN (fputc);
  474. # endif
  475. #endif
  476. #if @GNULIB_FPUTS@
  477. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  478. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  479. # undef fputs
  480. # define fputs rpl_fputs
  481. # endif
  482. _GL_FUNCDECL_RPL (fputs, int,
  483. (const char *restrict string, FILE *restrict stream)
  484. _GL_ARG_NONNULL ((1, 2)));
  485. _GL_CXXALIAS_RPL (fputs, int,
  486. (const char *restrict string, FILE *restrict stream));
  487. # else
  488. _GL_CXXALIAS_SYS (fputs, int,
  489. (const char *restrict string, FILE *restrict stream));
  490. # endif
  491. # if __GLIBC__ >= 2
  492. _GL_CXXALIASWARN (fputs);
  493. # endif
  494. #endif
  495. #if @GNULIB_FREAD@
  496. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  497. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  498. # undef fread
  499. # define fread rpl_fread
  500. # endif
  501. _GL_FUNCDECL_RPL (fread, size_t,
  502. (void *restrict ptr, size_t s, size_t n,
  503. FILE *restrict stream)
  504. _GL_ARG_NONNULL ((4)));
  505. _GL_CXXALIAS_RPL (fread, size_t,
  506. (void *restrict ptr, size_t s, size_t n,
  507. FILE *restrict stream));
  508. # else
  509. _GL_CXXALIAS_SYS (fread, size_t,
  510. (void *restrict ptr, size_t s, size_t n,
  511. FILE *restrict stream));
  512. # endif
  513. # if __GLIBC__ >= 2
  514. _GL_CXXALIASWARN (fread);
  515. # endif
  516. #endif
  517. #if @GNULIB_FREOPEN@
  518. # if @REPLACE_FREOPEN@
  519. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  520. # undef freopen
  521. # define freopen rpl_freopen
  522. # endif
  523. _GL_FUNCDECL_RPL (freopen, FILE *,
  524. (const char *restrict filename, const char *restrict mode,
  525. FILE *restrict stream)
  526. _GL_ARG_NONNULL ((2, 3)));
  527. _GL_CXXALIAS_RPL (freopen, FILE *,
  528. (const char *restrict filename, const char *restrict mode,
  529. FILE *restrict stream));
  530. # else
  531. _GL_CXXALIAS_SYS (freopen, FILE *,
  532. (const char *restrict filename, const char *restrict mode,
  533. FILE *restrict stream));
  534. # endif
  535. # if __GLIBC__ >= 2
  536. _GL_CXXALIASWARN (freopen);
  537. # endif
  538. #elif defined GNULIB_POSIXCHECK
  539. # undef freopen
  540. /* Assume freopen is always declared. */
  541. _GL_WARN_ON_USE (freopen,
  542. "freopen on native Windows platforms is not POSIX compliant - "
  543. "use gnulib module freopen for portability");
  544. #endif
  545. #if @GNULIB_FSCANF@
  546. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  547. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  548. # undef fscanf
  549. # define fscanf rpl_fscanf
  550. # endif
  551. _GL_FUNCDECL_RPL (fscanf, int,
  552. (FILE *restrict stream, const char *restrict format, ...)
  553. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
  554. _GL_ARG_NONNULL ((1, 2)));
  555. _GL_CXXALIAS_RPL (fscanf, int,
  556. (FILE *restrict stream, const char *restrict format, ...));
  557. # else
  558. _GL_CXXALIAS_SYS (fscanf, int,
  559. (FILE *restrict stream, const char *restrict format, ...));
  560. # endif
  561. # if __GLIBC__ >= 2
  562. _GL_CXXALIASWARN (fscanf);
  563. # endif
  564. #endif
  565. /* Set up the following warnings, based on which modules are in use.
  566. GNU Coding Standards discourage the use of fseek, since it imposes
  567. an arbitrary limitation on some 32-bit hosts. Remember that the
  568. fseek module depends on the fseeko module, so we only have three
  569. cases to consider:
  570. 1. The developer is not using either module. Issue a warning under
  571. GNULIB_POSIXCHECK for both functions, to remind them that both
  572. functions have bugs on some systems. _GL_NO_LARGE_FILES has no
  573. impact on this warning.
  574. 2. The developer is using both modules. They may be unaware of the
  575. arbitrary limitations of fseek, so issue a warning under
  576. GNULIB_POSIXCHECK. On the other hand, they may be using both
  577. modules intentionally, so the developer can define
  578. _GL_NO_LARGE_FILES in the compilation units where the use of fseek
  579. is safe, to silence the warning.
  580. 3. The developer is using the fseeko module, but not fseek. Gnulib
  581. guarantees that fseek will still work around platform bugs in that
  582. case, but we presume that the developer is aware of the pitfalls of
  583. fseek and was trying to avoid it, so issue a warning even when
  584. GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be
  585. defined to silence the warning in particular compilation units.
  586. In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
  587. fseek gets defined as a macro, it is recommended that the developer
  588. uses the fseek module, even if he is not calling the fseek function.
  589. Most gnulib clients that perform stream operations should fall into
  590. category 3. */
  591. #if @GNULIB_FSEEK@
  592. # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
  593. # define _GL_FSEEK_WARN /* Category 2, above. */
  594. # undef fseek
  595. # endif
  596. # if @REPLACE_FSEEK@
  597. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  598. # undef fseek
  599. # define fseek rpl_fseek
  600. # endif
  601. _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
  602. _GL_ARG_NONNULL ((1)));
  603. _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
  604. # else
  605. _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
  606. # endif
  607. # if __GLIBC__ >= 2
  608. _GL_CXXALIASWARN (fseek);
  609. # endif
  610. #endif
  611. #if @GNULIB_FSEEKO@
  612. # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
  613. # define _GL_FSEEK_WARN /* Category 3, above. */
  614. # undef fseek
  615. # endif
  616. # if @REPLACE_FSEEKO@
  617. /* Provide an fseeko function that is aware of a preceding fflush(), and which
  618. detects pipes. */
  619. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  620. # undef fseeko
  621. # define fseeko rpl_fseeko
  622. # endif
  623. _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
  624. _GL_ARG_NONNULL ((1)));
  625. _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
  626. # else
  627. # if ! @HAVE_DECL_FSEEKO@
  628. _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
  629. _GL_ARG_NONNULL ((1)));
  630. # endif
  631. _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
  632. # endif
  633. _GL_CXXALIASWARN (fseeko);
  634. #elif defined GNULIB_POSIXCHECK
  635. # define _GL_FSEEK_WARN /* Category 1, above. */
  636. # undef fseek
  637. # undef fseeko
  638. # if HAVE_RAW_DECL_FSEEKO
  639. _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
  640. "use gnulib module fseeko for portability");
  641. # endif
  642. #endif
  643. #ifdef _GL_FSEEK_WARN
  644. # undef _GL_FSEEK_WARN
  645. /* Here, either fseek is undefined (but C89 guarantees that it is
  646. declared), or it is defined as rpl_fseek (declared above). */
  647. _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
  648. "on 32-bit platforms - "
  649. "use fseeko function for handling of large files");
  650. #endif
  651. /* ftell, ftello. See the comments on fseek/fseeko. */
  652. #if @GNULIB_FTELL@
  653. # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
  654. # define _GL_FTELL_WARN /* Category 2, above. */
  655. # undef ftell
  656. # endif
  657. # if @REPLACE_FTELL@
  658. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  659. # undef ftell
  660. # define ftell rpl_ftell
  661. # endif
  662. _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
  663. _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
  664. # else
  665. _GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
  666. # endif
  667. # if __GLIBC__ >= 2
  668. _GL_CXXALIASWARN (ftell);
  669. # endif
  670. #endif
  671. #if @GNULIB_FTELLO@
  672. # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
  673. # define _GL_FTELL_WARN /* Category 3, above. */
  674. # undef ftell
  675. # endif
  676. # if @REPLACE_FTELLO@
  677. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  678. # undef ftello
  679. # define ftello rpl_ftello
  680. # endif
  681. _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
  682. _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
  683. # else
  684. # if ! @HAVE_DECL_FTELLO@
  685. _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
  686. # endif
  687. _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
  688. # endif
  689. _GL_CXXALIASWARN (ftello);
  690. #elif defined GNULIB_POSIXCHECK
  691. # define _GL_FTELL_WARN /* Category 1, above. */
  692. # undef ftell
  693. # undef ftello
  694. # if HAVE_RAW_DECL_FTELLO
  695. _GL_WARN_ON_USE (ftello, "ftello is unportable - "
  696. "use gnulib module ftello for portability");
  697. # endif
  698. #endif
  699. #ifdef _GL_FTELL_WARN
  700. # undef _GL_FTELL_WARN
  701. /* Here, either ftell is undefined (but C89 guarantees that it is
  702. declared), or it is defined as rpl_ftell (declared above). */
  703. _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
  704. "on 32-bit platforms - "
  705. "use ftello function for handling of large files");
  706. #endif
  707. #if @GNULIB_FWRITE@
  708. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  709. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  710. # undef fwrite
  711. # define fwrite rpl_fwrite
  712. # endif
  713. _GL_FUNCDECL_RPL (fwrite, size_t,
  714. (const void *restrict ptr, size_t s, size_t n,
  715. FILE *restrict stream)
  716. _GL_ARG_NONNULL ((1, 4)));
  717. _GL_CXXALIAS_RPL (fwrite, size_t,
  718. (const void *restrict ptr, size_t s, size_t n,
  719. FILE *restrict stream));
  720. # else
  721. _GL_CXXALIAS_SYS (fwrite, size_t,
  722. (const void *restrict ptr, size_t s, size_t n,
  723. FILE *restrict stream));
  724. /* Work around bug 11959 when fortifying glibc 2.4 through 2.15
  725. <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
  726. which sometimes causes an unwanted diagnostic for fwrite calls.
  727. This affects only function declaration attributes under certain
  728. versions of gcc and clang, and is not needed for C++. */
  729. # if (0 < __USE_FORTIFY_LEVEL \
  730. && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
  731. && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
  732. && !defined __cplusplus)
  733. # undef fwrite
  734. # undef fwrite_unlocked
  735. extern size_t __REDIRECT (rpl_fwrite,
  736. (const void *__restrict, size_t, size_t,
  737. FILE *__restrict),
  738. fwrite);
  739. extern size_t __REDIRECT (rpl_fwrite_unlocked,
  740. (const void *__restrict, size_t, size_t,
  741. FILE *__restrict),
  742. fwrite_unlocked);
  743. # define fwrite rpl_fwrite
  744. # define fwrite_unlocked rpl_fwrite_unlocked
  745. # endif
  746. # endif
  747. # if __GLIBC__ >= 2
  748. _GL_CXXALIASWARN (fwrite);
  749. # endif
  750. #endif
  751. #if @GNULIB_GETC@
  752. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  753. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  754. # undef getc
  755. # define getc rpl_fgetc
  756. # endif
  757. _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
  758. _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
  759. # else
  760. _GL_CXXALIAS_SYS (getc, int, (FILE *stream));
  761. # endif
  762. # if __GLIBC__ >= 2
  763. _GL_CXXALIASWARN (getc);
  764. # endif
  765. #endif
  766. #if @GNULIB_GETCHAR@
  767. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  768. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  769. # undef getchar
  770. # define getchar rpl_getchar
  771. # endif
  772. _GL_FUNCDECL_RPL (getchar, int, (void));
  773. _GL_CXXALIAS_RPL (getchar, int, (void));
  774. # else
  775. _GL_CXXALIAS_SYS (getchar, int, (void));
  776. # endif
  777. # if __GLIBC__ >= 2
  778. _GL_CXXALIASWARN (getchar);
  779. # endif
  780. #endif
  781. #if @GNULIB_GETDELIM@
  782. /* Read input, up to (and including) the next occurrence of DELIMITER, from
  783. STREAM, store it in *LINEPTR (and NUL-terminate it).
  784. *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
  785. bytes of space. It is realloc'd as necessary.
  786. Return the number of bytes read and stored at *LINEPTR (not including the
  787. NUL terminator), or -1 on error or EOF. */
  788. # if @REPLACE_GETDELIM@
  789. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  790. # undef getdelim
  791. # define getdelim rpl_getdelim
  792. # endif
  793. _GL_FUNCDECL_RPL (getdelim, ssize_t,
  794. (char **restrict lineptr, size_t *restrict linesize,
  795. int delimiter,
  796. FILE *restrict stream)
  797. _GL_ARG_NONNULL ((1, 2, 4)));
  798. _GL_CXXALIAS_RPL (getdelim, ssize_t,
  799. (char **restrict lineptr, size_t *restrict linesize,
  800. int delimiter,
  801. FILE *restrict stream));
  802. # else
  803. # if !@HAVE_DECL_GETDELIM@
  804. _GL_FUNCDECL_SYS (getdelim, ssize_t,
  805. (char **restrict lineptr, size_t *restrict linesize,
  806. int delimiter,
  807. FILE *restrict stream)
  808. _GL_ARG_NONNULL ((1, 2, 4)));
  809. # endif
  810. _GL_CXXALIAS_SYS (getdelim, ssize_t,
  811. (char **restrict lineptr, size_t *restrict linesize,
  812. int delimiter,
  813. FILE *restrict stream));
  814. # endif
  815. _GL_CXXALIASWARN (getdelim);
  816. #elif defined GNULIB_POSIXCHECK
  817. # undef getdelim
  818. # if HAVE_RAW_DECL_GETDELIM
  819. _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
  820. "use gnulib module getdelim for portability");
  821. # endif
  822. #endif
  823. #if @GNULIB_GETLINE@
  824. /* Read a line, up to (and including) the next newline, from STREAM, store it
  825. in *LINEPTR (and NUL-terminate it).
  826. *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
  827. bytes of space. It is realloc'd as necessary.
  828. Return the number of bytes read and stored at *LINEPTR (not including the
  829. NUL terminator), or -1 on error or EOF. */
  830. # if @REPLACE_GETLINE@
  831. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  832. # undef getline
  833. # define getline rpl_getline
  834. # endif
  835. _GL_FUNCDECL_RPL (getline, ssize_t,
  836. (char **restrict lineptr, size_t *restrict linesize,
  837. FILE *restrict stream)
  838. _GL_ARG_NONNULL ((1, 2, 3)));
  839. _GL_CXXALIAS_RPL (getline, ssize_t,
  840. (char **restrict lineptr, size_t *restrict linesize,
  841. FILE *restrict stream));
  842. # else
  843. # if !@HAVE_DECL_GETLINE@
  844. _GL_FUNCDECL_SYS (getline, ssize_t,
  845. (char **restrict lineptr, size_t *restrict linesize,
  846. FILE *restrict stream)
  847. _GL_ARG_NONNULL ((1, 2, 3)));
  848. # endif
  849. _GL_CXXALIAS_SYS (getline, ssize_t,
  850. (char **restrict lineptr, size_t *restrict linesize,
  851. FILE *restrict stream));
  852. # endif
  853. # if @HAVE_DECL_GETLINE@
  854. _GL_CXXALIASWARN (getline);
  855. # endif
  856. #elif defined GNULIB_POSIXCHECK
  857. # undef getline
  858. # if HAVE_RAW_DECL_GETLINE
  859. _GL_WARN_ON_USE (getline, "getline is unportable - "
  860. "use gnulib module getline for portability");
  861. # endif
  862. #endif
  863. /* It is very rare that the developer ever has full control of stdin,
  864. so any use of gets warrants an unconditional warning; besides, C11
  865. removed it. */
  866. #undef gets
  867. #if HAVE_RAW_DECL_GETS && !defined __cplusplus
  868. _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
  869. #endif
  870. #if @GNULIB_MDA_GETW@
  871. /* On native Windows, map 'getw' to '_getw', so that -loldnames is not
  872. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  873. platforms by defining GNULIB_NAMESPACE::getw always. */
  874. # if defined _WIN32 && !defined __CYGWIN__
  875. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  876. # undef getw
  877. # define getw _getw
  878. # endif
  879. _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream));
  880. # else
  881. # if @HAVE_DECL_GETW@
  882. _GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream));
  883. # endif
  884. # endif
  885. # if __GLIBC__ >= 2
  886. _GL_CXXALIASWARN (getw);
  887. # endif
  888. #endif
  889. #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
  890. struct obstack;
  891. /* Grow an obstack with formatted output. Return the number of
  892. bytes added to OBS. No trailing nul byte is added, and the
  893. object should be closed with obstack_finish before use. Upon
  894. memory allocation error, call obstack_alloc_failed_handler. Upon
  895. other error, return -1. */
  896. # if @REPLACE_OBSTACK_PRINTF@
  897. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  898. # define obstack_printf rpl_obstack_printf
  899. # endif
  900. _GL_FUNCDECL_RPL (obstack_printf, int,
  901. (struct obstack *obs, const char *format, ...)
  902. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
  903. _GL_ARG_NONNULL ((1, 2)));
  904. _GL_CXXALIAS_RPL (obstack_printf, int,
  905. (struct obstack *obs, const char *format, ...));
  906. # else
  907. # if !@HAVE_DECL_OBSTACK_PRINTF@
  908. _GL_FUNCDECL_SYS (obstack_printf, int,
  909. (struct obstack *obs, const char *format, ...)
  910. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
  911. _GL_ARG_NONNULL ((1, 2)));
  912. # endif
  913. _GL_CXXALIAS_SYS (obstack_printf, int,
  914. (struct obstack *obs, const char *format, ...));
  915. # endif
  916. _GL_CXXALIASWARN (obstack_printf);
  917. # if @REPLACE_OBSTACK_PRINTF@
  918. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  919. # define obstack_vprintf rpl_obstack_vprintf
  920. # endif
  921. _GL_FUNCDECL_RPL (obstack_vprintf, int,
  922. (struct obstack *obs, const char *format, va_list args)
  923. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
  924. _GL_ARG_NONNULL ((1, 2)));
  925. _GL_CXXALIAS_RPL (obstack_vprintf, int,
  926. (struct obstack *obs, const char *format, va_list args));
  927. # else
  928. # if !@HAVE_DECL_OBSTACK_PRINTF@
  929. _GL_FUNCDECL_SYS (obstack_vprintf, int,
  930. (struct obstack *obs, const char *format, va_list args)
  931. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
  932. _GL_ARG_NONNULL ((1, 2)));
  933. # endif
  934. _GL_CXXALIAS_SYS (obstack_vprintf, int,
  935. (struct obstack *obs, const char *format, va_list args));
  936. # endif
  937. _GL_CXXALIASWARN (obstack_vprintf);
  938. #endif
  939. #if @GNULIB_PCLOSE@
  940. # if !@HAVE_PCLOSE@
  941. _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
  942. # endif
  943. _GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
  944. _GL_CXXALIASWARN (pclose);
  945. #elif defined GNULIB_POSIXCHECK
  946. # undef pclose
  947. # if HAVE_RAW_DECL_PCLOSE
  948. _GL_WARN_ON_USE (pclose, "pclose is unportable - "
  949. "use gnulib module pclose for more portability");
  950. # endif
  951. #endif
  952. #if @GNULIB_PERROR@
  953. /* Print a message to standard error, describing the value of ERRNO,
  954. (if STRING is not NULL and not empty) prefixed with STRING and ": ",
  955. and terminated with a newline. */
  956. # if @REPLACE_PERROR@
  957. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  958. # define perror rpl_perror
  959. # endif
  960. _GL_FUNCDECL_RPL (perror, void, (const char *string));
  961. _GL_CXXALIAS_RPL (perror, void, (const char *string));
  962. # else
  963. _GL_CXXALIAS_SYS (perror, void, (const char *string));
  964. # endif
  965. # if __GLIBC__ >= 2
  966. _GL_CXXALIASWARN (perror);
  967. # endif
  968. #elif defined GNULIB_POSIXCHECK
  969. # undef perror
  970. /* Assume perror is always declared. */
  971. _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
  972. "use gnulib module perror for portability");
  973. #endif
  974. #if @GNULIB_POPEN@
  975. # if @REPLACE_POPEN@
  976. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  977. # undef popen
  978. # define popen rpl_popen
  979. # endif
  980. _GL_FUNCDECL_RPL (popen, FILE *,
  981. (const char *cmd, const char *mode)
  982. _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
  983. _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
  984. # else
  985. # if !@HAVE_POPEN@ || __GNUC__ >= 11
  986. _GL_FUNCDECL_SYS (popen, FILE *,
  987. (const char *cmd, const char *mode)
  988. _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
  989. # endif
  990. _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
  991. # endif
  992. _GL_CXXALIASWARN (popen);
  993. #else
  994. # if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen
  995. /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
  996. _GL_FUNCDECL_SYS (popen, FILE *,
  997. (const char *cmd, const char *mode)
  998. _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
  999. # endif
  1000. # if defined GNULIB_POSIXCHECK
  1001. # undef popen
  1002. # if HAVE_RAW_DECL_POPEN
  1003. _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
  1004. "use gnulib module popen or pipe for more portability");
  1005. # endif
  1006. # endif
  1007. #endif
  1008. #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
  1009. # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
  1010. || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  1011. # if defined __GNUC__ || defined __clang__
  1012. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1013. /* Don't break __attribute__((format(printf,M,N))). */
  1014. # define printf __printf__
  1015. # endif
  1016. # if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
  1017. _GL_FUNCDECL_RPL_1 (__printf__, int,
  1018. (const char *restrict format, ...)
  1019. __asm__ (@ASM_SYMBOL_PREFIX@
  1020. _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
  1021. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
  1022. _GL_ARG_NONNULL ((1)));
  1023. # else
  1024. _GL_FUNCDECL_RPL_1 (__printf__, int,
  1025. (const char *restrict format, ...)
  1026. __asm__ (@ASM_SYMBOL_PREFIX@
  1027. _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
  1028. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
  1029. _GL_ARG_NONNULL ((1)));
  1030. # endif
  1031. _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
  1032. # else
  1033. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1034. # define printf rpl_printf
  1035. # endif
  1036. _GL_FUNCDECL_RPL (printf, int,
  1037. (const char *restrict format, ...)
  1038. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
  1039. _GL_ARG_NONNULL ((1)));
  1040. _GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...));
  1041. # endif
  1042. # define GNULIB_overrides_printf 1
  1043. # else
  1044. _GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...));
  1045. # endif
  1046. # if __GLIBC__ >= 2
  1047. _GL_CXXALIASWARN (printf);
  1048. # endif
  1049. #endif
  1050. #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  1051. # if !GNULIB_overrides_printf
  1052. # undef printf
  1053. # endif
  1054. /* Assume printf is always declared. */
  1055. _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
  1056. "use gnulib module printf-posix for portable "
  1057. "POSIX compliance");
  1058. #endif
  1059. #if @GNULIB_PUTC@
  1060. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  1061. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1062. # undef putc
  1063. # define putc rpl_fputc
  1064. # endif
  1065. _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
  1066. _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
  1067. # else
  1068. _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
  1069. # endif
  1070. # if __GLIBC__ >= 2
  1071. _GL_CXXALIASWARN (putc);
  1072. # endif
  1073. #endif
  1074. #if @GNULIB_PUTCHAR@
  1075. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  1076. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1077. # undef putchar
  1078. # define putchar rpl_putchar
  1079. # endif
  1080. _GL_FUNCDECL_RPL (putchar, int, (int c));
  1081. _GL_CXXALIAS_RPL (putchar, int, (int c));
  1082. # else
  1083. _GL_CXXALIAS_SYS (putchar, int, (int c));
  1084. # endif
  1085. # if __GLIBC__ >= 2
  1086. _GL_CXXALIASWARN (putchar);
  1087. # endif
  1088. #endif
  1089. #if @GNULIB_PUTS@
  1090. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  1091. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1092. # undef puts
  1093. # define puts rpl_puts
  1094. # endif
  1095. _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
  1096. _GL_CXXALIAS_RPL (puts, int, (const char *string));
  1097. # else
  1098. _GL_CXXALIAS_SYS (puts, int, (const char *string));
  1099. # endif
  1100. # if __GLIBC__ >= 2
  1101. _GL_CXXALIASWARN (puts);
  1102. # endif
  1103. #endif
  1104. #if @GNULIB_MDA_PUTW@
  1105. /* On native Windows, map 'putw' to '_putw', so that -loldnames is not
  1106. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  1107. platforms by defining GNULIB_NAMESPACE::putw always. */
  1108. # if defined _WIN32 && !defined __CYGWIN__
  1109. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1110. # undef putw
  1111. # define putw _putw
  1112. # endif
  1113. _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream));
  1114. # else
  1115. # if @HAVE_DECL_PUTW@
  1116. _GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream));
  1117. # endif
  1118. # endif
  1119. # if __GLIBC__ >= 2
  1120. _GL_CXXALIASWARN (putw);
  1121. # endif
  1122. #endif
  1123. #if @GNULIB_REMOVE@
  1124. # if @REPLACE_REMOVE@
  1125. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1126. # undef remove
  1127. # define remove rpl_remove
  1128. # endif
  1129. _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
  1130. _GL_CXXALIAS_RPL (remove, int, (const char *name));
  1131. # else
  1132. _GL_CXXALIAS_SYS (remove, int, (const char *name));
  1133. # endif
  1134. # if __GLIBC__ >= 2
  1135. _GL_CXXALIASWARN (remove);
  1136. # endif
  1137. #elif defined GNULIB_POSIXCHECK
  1138. # undef remove
  1139. /* Assume remove is always declared. */
  1140. _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
  1141. "use gnulib module remove for more portability");
  1142. #endif
  1143. #if @GNULIB_RENAME@
  1144. # if @REPLACE_RENAME@
  1145. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1146. # undef rename
  1147. # define rename rpl_rename
  1148. # endif
  1149. _GL_FUNCDECL_RPL (rename, int,
  1150. (const char *old_filename, const char *new_filename)
  1151. _GL_ARG_NONNULL ((1, 2)));
  1152. _GL_CXXALIAS_RPL (rename, int,
  1153. (const char *old_filename, const char *new_filename));
  1154. # else
  1155. _GL_CXXALIAS_SYS (rename, int,
  1156. (const char *old_filename, const char *new_filename));
  1157. # endif
  1158. # if __GLIBC__ >= 2
  1159. _GL_CXXALIASWARN (rename);
  1160. # endif
  1161. #elif defined GNULIB_POSIXCHECK
  1162. # undef rename
  1163. /* Assume rename is always declared. */
  1164. _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
  1165. "use gnulib module rename for more portability");
  1166. #endif
  1167. #if @GNULIB_RENAMEAT@
  1168. # if @REPLACE_RENAMEAT@
  1169. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1170. # undef renameat
  1171. # define renameat rpl_renameat
  1172. # endif
  1173. _GL_FUNCDECL_RPL (renameat, int,
  1174. (int fd1, char const *file1, int fd2, char const *file2)
  1175. _GL_ARG_NONNULL ((2, 4)));
  1176. _GL_CXXALIAS_RPL (renameat, int,
  1177. (int fd1, char const *file1, int fd2, char const *file2));
  1178. # else
  1179. # if !@HAVE_RENAMEAT@
  1180. _GL_FUNCDECL_SYS (renameat, int,
  1181. (int fd1, char const *file1, int fd2, char const *file2)
  1182. _GL_ARG_NONNULL ((2, 4)));
  1183. # endif
  1184. _GL_CXXALIAS_SYS (renameat, int,
  1185. (int fd1, char const *file1, int fd2, char const *file2));
  1186. # endif
  1187. _GL_CXXALIASWARN (renameat);
  1188. #elif defined GNULIB_POSIXCHECK
  1189. # undef renameat
  1190. # if HAVE_RAW_DECL_RENAMEAT
  1191. _GL_WARN_ON_USE (renameat, "renameat is not portable - "
  1192. "use gnulib module renameat for portability");
  1193. # endif
  1194. #endif
  1195. #if @GNULIB_SCANF@
  1196. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  1197. # if defined __GNUC__ || defined __clang__
  1198. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1199. # undef scanf
  1200. /* Don't break __attribute__((format(scanf,M,N))). */
  1201. # define scanf __scanf__
  1202. # endif
  1203. _GL_FUNCDECL_RPL_1 (__scanf__, int,
  1204. (const char *restrict format, ...)
  1205. __asm__ (@ASM_SYMBOL_PREFIX@
  1206. _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
  1207. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
  1208. _GL_ARG_NONNULL ((1)));
  1209. _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...));
  1210. # else
  1211. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1212. # undef scanf
  1213. # define scanf rpl_scanf
  1214. # endif
  1215. _GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...)
  1216. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
  1217. _GL_ARG_NONNULL ((1)));
  1218. _GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...));
  1219. # endif
  1220. # else
  1221. _GL_CXXALIAS_SYS (scanf, int, (const char *restrict format, ...));
  1222. # endif
  1223. # if __GLIBC__ >= 2
  1224. _GL_CXXALIASWARN (scanf);
  1225. # endif
  1226. #endif
  1227. #if @GNULIB_SNPRINTF@
  1228. # if @REPLACE_SNPRINTF@
  1229. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1230. # define snprintf rpl_snprintf
  1231. # endif
  1232. # define GNULIB_overrides_snprintf 1
  1233. _GL_FUNCDECL_RPL (snprintf, int,
  1234. (char *restrict str, size_t size,
  1235. const char *restrict format, ...)
  1236. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
  1237. _GL_ARG_NONNULL ((3)));
  1238. _GL_CXXALIAS_RPL (snprintf, int,
  1239. (char *restrict str, size_t size,
  1240. const char *restrict format, ...));
  1241. # else
  1242. # if !@HAVE_DECL_SNPRINTF@
  1243. _GL_FUNCDECL_SYS (snprintf, int,
  1244. (char *restrict str, size_t size,
  1245. const char *restrict format, ...)
  1246. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
  1247. _GL_ARG_NONNULL ((3)));
  1248. # endif
  1249. _GL_CXXALIAS_SYS (snprintf, int,
  1250. (char *restrict str, size_t size,
  1251. const char *restrict format, ...));
  1252. # endif
  1253. # if __GLIBC__ >= 2
  1254. _GL_CXXALIASWARN (snprintf);
  1255. # endif
  1256. #elif defined GNULIB_POSIXCHECK
  1257. # undef snprintf
  1258. # if HAVE_RAW_DECL_SNPRINTF
  1259. _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
  1260. "use gnulib module snprintf for portability");
  1261. # endif
  1262. #endif
  1263. /* Some people would argue that all sprintf uses should be warned about
  1264. (for example, OpenBSD issues a link warning for it),
  1265. since it can cause security holes due to buffer overruns.
  1266. However, we believe that sprintf can be used safely, and is more
  1267. efficient than snprintf in those safe cases; and as proof of our
  1268. belief, we use sprintf in several gnulib modules. So this header
  1269. intentionally avoids adding a warning to sprintf except when
  1270. GNULIB_POSIXCHECK is defined. */
  1271. #if @GNULIB_SPRINTF_POSIX@
  1272. # if @REPLACE_SPRINTF@
  1273. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1274. # define sprintf rpl_sprintf
  1275. # endif
  1276. # define GNULIB_overrides_sprintf 1
  1277. _GL_FUNCDECL_RPL (sprintf, int,
  1278. (char *restrict str, const char *restrict format, ...)
  1279. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
  1280. _GL_ARG_NONNULL ((1, 2)));
  1281. _GL_CXXALIAS_RPL (sprintf, int,
  1282. (char *restrict str, const char *restrict format, ...));
  1283. # else
  1284. _GL_CXXALIAS_SYS (sprintf, int,
  1285. (char *restrict str, const char *restrict format, ...));
  1286. # endif
  1287. # if __GLIBC__ >= 2
  1288. _GL_CXXALIASWARN (sprintf);
  1289. # endif
  1290. #elif defined GNULIB_POSIXCHECK
  1291. # undef sprintf
  1292. /* Assume sprintf is always declared. */
  1293. _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
  1294. "use gnulib module sprintf-posix for portable "
  1295. "POSIX compliance");
  1296. #endif
  1297. #if @GNULIB_MDA_TEMPNAM@
  1298. /* On native Windows, map 'tempnam' to '_tempnam', so that -loldnames is not
  1299. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  1300. platforms by defining GNULIB_NAMESPACE::tempnam always. */
  1301. # if defined _WIN32 && !defined __CYGWIN__
  1302. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1303. # undef tempnam
  1304. # define tempnam _tempnam
  1305. # endif
  1306. _GL_CXXALIAS_MDA (tempnam, char *, (const char *dir, const char *prefix));
  1307. # else
  1308. _GL_CXXALIAS_SYS (tempnam, char *, (const char *dir, const char *prefix));
  1309. # endif
  1310. _GL_CXXALIASWARN (tempnam);
  1311. #endif
  1312. #if @GNULIB_TMPFILE@
  1313. # if @REPLACE_TMPFILE@
  1314. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1315. # define tmpfile rpl_tmpfile
  1316. # endif
  1317. _GL_FUNCDECL_RPL (tmpfile, FILE *, (void)
  1318. _GL_ATTRIBUTE_DEALLOC (fclose, 1));
  1319. _GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
  1320. # else
  1321. # if __GNUC__ >= 11
  1322. /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
  1323. _GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
  1324. _GL_ATTRIBUTE_DEALLOC (fclose, 1));
  1325. # endif
  1326. _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
  1327. # endif
  1328. # if __GLIBC__ >= 2
  1329. _GL_CXXALIASWARN (tmpfile);
  1330. # endif
  1331. #else
  1332. # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile
  1333. /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
  1334. _GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
  1335. _GL_ATTRIBUTE_DEALLOC (fclose, 1));
  1336. # endif
  1337. # if defined GNULIB_POSIXCHECK
  1338. # undef tmpfile
  1339. # if HAVE_RAW_DECL_TMPFILE
  1340. _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
  1341. "use gnulib module tmpfile for portability");
  1342. # endif
  1343. # endif
  1344. #endif
  1345. #if @GNULIB_VASPRINTF@
  1346. /* Write formatted output to a string dynamically allocated with malloc().
  1347. If the memory allocation succeeds, store the address of the string in
  1348. *RESULT and return the number of resulting bytes, excluding the trailing
  1349. NUL. Upon memory allocation error, or some other error, return -1. */
  1350. # if @REPLACE_VASPRINTF@
  1351. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1352. # define asprintf rpl_asprintf
  1353. # endif
  1354. # define GNULIB_overrides_asprintf
  1355. _GL_FUNCDECL_RPL (asprintf, int,
  1356. (char **result, const char *format, ...)
  1357. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
  1358. _GL_ARG_NONNULL ((1, 2)));
  1359. _GL_CXXALIAS_RPL (asprintf, int,
  1360. (char **result, const char *format, ...));
  1361. # else
  1362. # if !@HAVE_VASPRINTF@
  1363. _GL_FUNCDECL_SYS (asprintf, int,
  1364. (char **result, const char *format, ...)
  1365. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
  1366. _GL_ARG_NONNULL ((1, 2)));
  1367. # endif
  1368. _GL_CXXALIAS_SYS (asprintf, int,
  1369. (char **result, const char *format, ...));
  1370. # endif
  1371. _GL_CXXALIASWARN (asprintf);
  1372. # if @REPLACE_VASPRINTF@
  1373. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1374. # define vasprintf rpl_vasprintf
  1375. # endif
  1376. # define GNULIB_overrides_vasprintf 1
  1377. _GL_FUNCDECL_RPL (vasprintf, int,
  1378. (char **result, const char *format, va_list args)
  1379. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
  1380. _GL_ARG_NONNULL ((1, 2)));
  1381. _GL_CXXALIAS_RPL (vasprintf, int,
  1382. (char **result, const char *format, va_list args));
  1383. # else
  1384. # if !@HAVE_VASPRINTF@
  1385. _GL_FUNCDECL_SYS (vasprintf, int,
  1386. (char **result, const char *format, va_list args)
  1387. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
  1388. _GL_ARG_NONNULL ((1, 2)));
  1389. # endif
  1390. _GL_CXXALIAS_SYS (vasprintf, int,
  1391. (char **result, const char *format, va_list args));
  1392. # endif
  1393. _GL_CXXALIASWARN (vasprintf);
  1394. #endif
  1395. #if @GNULIB_VDPRINTF@
  1396. # if @REPLACE_VDPRINTF@
  1397. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1398. # define vdprintf rpl_vdprintf
  1399. # endif
  1400. _GL_FUNCDECL_RPL (vdprintf, int,
  1401. (int fd, const char *restrict format, va_list args)
  1402. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
  1403. _GL_ARG_NONNULL ((2)));
  1404. _GL_CXXALIAS_RPL (vdprintf, int,
  1405. (int fd, const char *restrict format, va_list args));
  1406. # else
  1407. # if !@HAVE_VDPRINTF@
  1408. _GL_FUNCDECL_SYS (vdprintf, int,
  1409. (int fd, const char *restrict format, va_list args)
  1410. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
  1411. _GL_ARG_NONNULL ((2)));
  1412. # endif
  1413. /* Need to cast, because on Solaris, the third parameter will likely be
  1414. __va_list args. */
  1415. _GL_CXXALIAS_SYS_CAST (vdprintf, int,
  1416. (int fd, const char *restrict format, va_list args));
  1417. # endif
  1418. # if __GLIBC__ >= 2
  1419. _GL_CXXALIASWARN (vdprintf);
  1420. # endif
  1421. #elif defined GNULIB_POSIXCHECK
  1422. # undef vdprintf
  1423. # if HAVE_RAW_DECL_VDPRINTF
  1424. _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
  1425. "use gnulib module vdprintf for portability");
  1426. # endif
  1427. #endif
  1428. #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
  1429. # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
  1430. || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  1431. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1432. # define vfprintf rpl_vfprintf
  1433. # endif
  1434. # define GNULIB_overrides_vfprintf 1
  1435. # if @GNULIB_VFPRINTF_POSIX@
  1436. _GL_FUNCDECL_RPL (vfprintf, int,
  1437. (FILE *restrict fp,
  1438. const char *restrict format, va_list args)
  1439. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
  1440. _GL_ARG_NONNULL ((1, 2)));
  1441. # else
  1442. _GL_FUNCDECL_RPL (vfprintf, int,
  1443. (FILE *restrict fp,
  1444. const char *restrict format, va_list args)
  1445. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
  1446. _GL_ARG_NONNULL ((1, 2)));
  1447. # endif
  1448. _GL_CXXALIAS_RPL (vfprintf, int,
  1449. (FILE *restrict fp,
  1450. const char *restrict format, va_list args));
  1451. # else
  1452. /* Need to cast, because on Solaris, the third parameter is
  1453. __va_list args
  1454. and GCC's fixincludes did not change this to __gnuc_va_list. */
  1455. _GL_CXXALIAS_SYS_CAST (vfprintf, int,
  1456. (FILE *restrict fp,
  1457. const char *restrict format, va_list args));
  1458. # endif
  1459. # if __GLIBC__ >= 2
  1460. _GL_CXXALIASWARN (vfprintf);
  1461. # endif
  1462. #endif
  1463. #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  1464. # if !GNULIB_overrides_vfprintf
  1465. # undef vfprintf
  1466. # endif
  1467. /* Assume vfprintf is always declared. */
  1468. _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
  1469. "use gnulib module vfprintf-posix for portable "
  1470. "POSIX compliance");
  1471. #endif
  1472. #if @GNULIB_VFSCANF@
  1473. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  1474. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1475. # undef vfscanf
  1476. # define vfscanf rpl_vfscanf
  1477. # endif
  1478. _GL_FUNCDECL_RPL (vfscanf, int,
  1479. (FILE *restrict stream,
  1480. const char *restrict format, va_list args)
  1481. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
  1482. _GL_ARG_NONNULL ((1, 2)));
  1483. _GL_CXXALIAS_RPL (vfscanf, int,
  1484. (FILE *restrict stream,
  1485. const char *restrict format, va_list args));
  1486. # else
  1487. _GL_CXXALIAS_SYS (vfscanf, int,
  1488. (FILE *restrict stream,
  1489. const char *restrict format, va_list args));
  1490. # endif
  1491. # if __GLIBC__ >= 2
  1492. _GL_CXXALIASWARN (vfscanf);
  1493. # endif
  1494. #endif
  1495. #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
  1496. # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
  1497. || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  1498. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1499. # define vprintf rpl_vprintf
  1500. # endif
  1501. # define GNULIB_overrides_vprintf 1
  1502. # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
  1503. _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
  1504. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
  1505. _GL_ARG_NONNULL ((1)));
  1506. # else
  1507. _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
  1508. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
  1509. _GL_ARG_NONNULL ((1)));
  1510. # endif
  1511. _GL_CXXALIAS_RPL (vprintf, int, (const char *restrict format, va_list args));
  1512. # else
  1513. /* Need to cast, because on Solaris, the second parameter is
  1514. __va_list args
  1515. and GCC's fixincludes did not change this to __gnuc_va_list. */
  1516. _GL_CXXALIAS_SYS_CAST (vprintf, int,
  1517. (const char *restrict format, va_list args));
  1518. # endif
  1519. # if __GLIBC__ >= 2
  1520. _GL_CXXALIASWARN (vprintf);
  1521. # endif
  1522. #endif
  1523. #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  1524. # if !GNULIB_overrides_vprintf
  1525. # undef vprintf
  1526. # endif
  1527. /* Assume vprintf is always declared. */
  1528. _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
  1529. "use gnulib module vprintf-posix for portable "
  1530. "POSIX compliance");
  1531. #endif
  1532. #if @GNULIB_VSCANF@
  1533. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  1534. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1535. # undef vscanf
  1536. # define vscanf rpl_vscanf
  1537. # endif
  1538. _GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args)
  1539. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
  1540. _GL_ARG_NONNULL ((1)));
  1541. _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
  1542. # else
  1543. _GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
  1544. # endif
  1545. # if __GLIBC__ >= 2
  1546. _GL_CXXALIASWARN (vscanf);
  1547. # endif
  1548. #endif
  1549. #if @GNULIB_VSNPRINTF@
  1550. # if @REPLACE_VSNPRINTF@
  1551. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1552. # define vsnprintf rpl_vsnprintf
  1553. # endif
  1554. # define GNULIB_overrides_vsnprintf 1
  1555. _GL_FUNCDECL_RPL (vsnprintf, int,
  1556. (char *restrict str, size_t size,
  1557. const char *restrict format, va_list args)
  1558. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
  1559. _GL_ARG_NONNULL ((3)));
  1560. _GL_CXXALIAS_RPL (vsnprintf, int,
  1561. (char *restrict str, size_t size,
  1562. const char *restrict format, va_list args));
  1563. # else
  1564. # if !@HAVE_DECL_VSNPRINTF@
  1565. _GL_FUNCDECL_SYS (vsnprintf, int,
  1566. (char *restrict str, size_t size,
  1567. const char *restrict format, va_list args)
  1568. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
  1569. _GL_ARG_NONNULL ((3)));
  1570. # endif
  1571. _GL_CXXALIAS_SYS (vsnprintf, int,
  1572. (char *restrict str, size_t size,
  1573. const char *restrict format, va_list args));
  1574. # endif
  1575. # if __GLIBC__ >= 2
  1576. _GL_CXXALIASWARN (vsnprintf);
  1577. # endif
  1578. #elif defined GNULIB_POSIXCHECK
  1579. # undef vsnprintf
  1580. # if HAVE_RAW_DECL_VSNPRINTF
  1581. _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
  1582. "use gnulib module vsnprintf for portability");
  1583. # endif
  1584. #endif
  1585. #if @GNULIB_VSPRINTF_POSIX@
  1586. # if @REPLACE_VSPRINTF@
  1587. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1588. # define vsprintf rpl_vsprintf
  1589. # endif
  1590. # define GNULIB_overrides_vsprintf 1
  1591. _GL_FUNCDECL_RPL (vsprintf, int,
  1592. (char *restrict str,
  1593. const char *restrict format, va_list args)
  1594. _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
  1595. _GL_ARG_NONNULL ((1, 2)));
  1596. _GL_CXXALIAS_RPL (vsprintf, int,
  1597. (char *restrict str,
  1598. const char *restrict format, va_list args));
  1599. # else
  1600. /* Need to cast, because on Solaris, the third parameter is
  1601. __va_list args
  1602. and GCC's fixincludes did not change this to __gnuc_va_list. */
  1603. _GL_CXXALIAS_SYS_CAST (vsprintf, int,
  1604. (char *restrict str,
  1605. const char *restrict format, va_list args));
  1606. # endif
  1607. # if __GLIBC__ >= 2
  1608. _GL_CXXALIASWARN (vsprintf);
  1609. # endif
  1610. #elif defined GNULIB_POSIXCHECK
  1611. # undef vsprintf
  1612. /* Assume vsprintf is always declared. */
  1613. _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
  1614. "use gnulib module vsprintf-posix for portable "
  1615. "POSIX compliance");
  1616. #endif
  1617. #endif /* _@GUARD_PREFIX@_STDIO_H */
  1618. #endif /* _@GUARD_PREFIX@_STDIO_H */
  1619. #endif