stdio.in.h 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  1. /* A GNU-like <stdio.h>.
  2. Copyright (C) 2004, 2007-2012 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program 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, write to the Free Software Foundation,
  13. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  14. #if __GNUC__ >= 3
  15. @PRAGMA_SYSTEM_HEADER@
  16. #endif
  17. @PRAGMA_COLUMNS@
  18. #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
  19. /* Special invocation convention:
  20. - Inside glibc header files.
  21. - On OSF/1 5.1 we have a sequence of nested includes
  22. <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
  23. <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
  24. In this situation, the functions are not yet declared, therefore we cannot
  25. provide the C++ aliases. */
  26. #@INCLUDE_NEXT@ @NEXT_STDIO_H@
  27. #else
  28. /* Normal invocation convention. */
  29. #ifndef _@GUARD_PREFIX@_STDIO_H
  30. #define _GL_ALREADY_INCLUDING_STDIO_H
  31. /* The include_next requires a split double-inclusion guard. */
  32. #@INCLUDE_NEXT@ @NEXT_STDIO_H@
  33. #undef _GL_ALREADY_INCLUDING_STDIO_H
  34. #ifndef _@GUARD_PREFIX@_STDIO_H
  35. #define _@GUARD_PREFIX@_STDIO_H
  36. /* Get va_list. Needed on many systems, including glibc 2.8. */
  37. #include <stdarg.h>
  38. #include <stddef.h>
  39. /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
  40. and eglibc 2.11.2. */
  41. #include <sys/types.h>
  42. /* The __attribute__ feature is available in gcc versions 2.5 and later.
  43. The __-protected variants of the attributes 'format' and 'printf' are
  44. accepted by gcc versions 2.6.4 (effectively 2.7) and later.
  45. We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
  46. gnulib and libintl do '#define printf __printf__' when they override
  47. the 'printf' function. */
  48. #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
  49. # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
  50. #else
  51. # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
  52. #endif
  53. /* _GL_ATTRIBUTE_FORMAT_PRINTF
  54. indicates to GCC that the function takes a format string and arguments,
  55. where the format string directives are the ones standardized by ISO C99
  56. and POSIX. */
  57. #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
  58. # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
  59. _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
  60. #else
  61. # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
  62. _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
  63. #endif
  64. /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF,
  65. except that it indicates to GCC that the supported format string directives
  66. are the ones of the system printf(), rather than the ones standardized by
  67. ISO C99 and POSIX. */
  68. #define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
  69. _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
  70. /* _GL_ATTRIBUTE_FORMAT_SCANF
  71. indicates to GCC that the function takes a format string and arguments,
  72. where the format string directives are the ones standardized by ISO C99
  73. and POSIX. */
  74. #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
  75. # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
  76. _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
  77. #else
  78. # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
  79. _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
  80. #endif
  81. /* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
  82. except that it indicates to GCC that the supported format string directives
  83. are the ones of the system scanf(), rather than the ones standardized by
  84. ISO C99 and POSIX. */
  85. #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
  86. _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
  87. /* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>. */
  88. /* But in any case avoid namespace pollution on glibc systems. */
  89. #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
  90. && ! defined __GLIBC__
  91. # include <unistd.h>
  92. #endif
  93. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  94. /* The definition of _GL_ARG_NONNULL is copied here. */
  95. /* The definition of _GL_WARN_ON_USE is copied here. */
  96. /* Macros for stringification. */
  97. #define _GL_STDIO_STRINGIZE(token) #token
  98. #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
  99. #if @GNULIB_DPRINTF@
  100. # if @REPLACE_DPRINTF@
  101. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  102. # define dprintf rpl_dprintf
  103. # endif
  104. _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
  105. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  106. _GL_ARG_NONNULL ((2)));
  107. _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...));
  108. # else
  109. # if !@HAVE_DPRINTF@
  110. _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...)
  111. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  112. _GL_ARG_NONNULL ((2)));
  113. # endif
  114. _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
  115. # endif
  116. _GL_CXXALIASWARN (dprintf);
  117. #elif defined GNULIB_POSIXCHECK
  118. # undef dprintf
  119. # if HAVE_RAW_DECL_DPRINTF
  120. _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
  121. "use gnulib module dprintf for portability");
  122. # endif
  123. #endif
  124. #if @GNULIB_FCLOSE@
  125. /* Close STREAM and its underlying file descriptor. */
  126. # if @REPLACE_FCLOSE@
  127. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  128. # define fclose rpl_fclose
  129. # endif
  130. _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
  131. _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
  132. # else
  133. _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
  134. # endif
  135. _GL_CXXALIASWARN (fclose);
  136. #elif defined GNULIB_POSIXCHECK
  137. # undef fclose
  138. /* Assume fclose is always declared. */
  139. _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
  140. "use gnulib module fclose for portable POSIX compliance");
  141. #endif
  142. #if @GNULIB_FDOPEN@
  143. # if @REPLACE_FDOPEN@
  144. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  145. # undef fdopen
  146. # define fdopen rpl_fdopen
  147. # endif
  148. _GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode)
  149. _GL_ARG_NONNULL ((2)));
  150. _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
  151. # else
  152. _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
  153. # endif
  154. _GL_CXXALIASWARN (fdopen);
  155. #elif defined GNULIB_POSIXCHECK
  156. # undef fdopen
  157. /* Assume fdopen is always declared. */
  158. _GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
  159. "use gnulib module fdopen for portability");
  160. #endif
  161. #if @GNULIB_FFLUSH@
  162. /* Flush all pending data on STREAM according to POSIX rules. Both
  163. output and seekable input streams are supported.
  164. Note! LOSS OF DATA can occur if fflush is applied on an input stream
  165. that is _not_seekable_ or on an update stream that is _not_seekable_
  166. and in which the most recent operation was input. Seekability can
  167. be tested with lseek(fileno(fp),0,SEEK_CUR). */
  168. # if @REPLACE_FFLUSH@
  169. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  170. # define fflush rpl_fflush
  171. # endif
  172. _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
  173. _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
  174. # else
  175. _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
  176. # endif
  177. _GL_CXXALIASWARN (fflush);
  178. #elif defined GNULIB_POSIXCHECK
  179. # undef fflush
  180. /* Assume fflush is always declared. */
  181. _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
  182. "use gnulib module fflush for portable POSIX compliance");
  183. #endif
  184. #if @GNULIB_FGETC@
  185. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  186. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  187. # undef fgetc
  188. # define fgetc rpl_fgetc
  189. # endif
  190. _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
  191. _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
  192. # else
  193. _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
  194. # endif
  195. _GL_CXXALIASWARN (fgetc);
  196. #endif
  197. #if @GNULIB_FGETS@
  198. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  199. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  200. # undef fgets
  201. # define fgets rpl_fgets
  202. # endif
  203. _GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream)
  204. _GL_ARG_NONNULL ((1, 3)));
  205. _GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream));
  206. # else
  207. _GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream));
  208. # endif
  209. _GL_CXXALIASWARN (fgets);
  210. #endif
  211. #if @GNULIB_FOPEN@
  212. # if @REPLACE_FOPEN@
  213. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  214. # undef fopen
  215. # define fopen rpl_fopen
  216. # endif
  217. _GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode)
  218. _GL_ARG_NONNULL ((1, 2)));
  219. _GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode));
  220. # else
  221. _GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode));
  222. # endif
  223. _GL_CXXALIASWARN (fopen);
  224. #elif defined GNULIB_POSIXCHECK
  225. # undef fopen
  226. /* Assume fopen is always declared. */
  227. _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
  228. "use gnulib module fopen for portability");
  229. #endif
  230. #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
  231. # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
  232. || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  233. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  234. # define fprintf rpl_fprintf
  235. # endif
  236. # define GNULIB_overrides_fprintf 1
  237. # if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
  238. _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
  239. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  240. _GL_ARG_NONNULL ((1, 2)));
  241. # else
  242. _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
  243. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
  244. _GL_ARG_NONNULL ((1, 2)));
  245. # endif
  246. _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
  247. # else
  248. _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
  249. # endif
  250. _GL_CXXALIASWARN (fprintf);
  251. #endif
  252. #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  253. # if !GNULIB_overrides_fprintf
  254. # undef fprintf
  255. # endif
  256. /* Assume fprintf is always declared. */
  257. _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
  258. "use gnulib module fprintf-posix for portable "
  259. "POSIX compliance");
  260. #endif
  261. #if @GNULIB_FPURGE@
  262. /* Discard all pending buffered I/O data on STREAM.
  263. STREAM must not be wide-character oriented.
  264. When discarding pending output, the file position is set back to where it
  265. was before the write calls. When discarding pending input, the file
  266. position is advanced to match the end of the previously read input.
  267. Return 0 if successful. Upon error, return -1 and set errno. */
  268. # if @REPLACE_FPURGE@
  269. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  270. # define fpurge rpl_fpurge
  271. # endif
  272. _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
  273. _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
  274. # else
  275. # if !@HAVE_DECL_FPURGE@
  276. _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
  277. # endif
  278. _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
  279. # endif
  280. _GL_CXXALIASWARN (fpurge);
  281. #elif defined GNULIB_POSIXCHECK
  282. # undef fpurge
  283. # if HAVE_RAW_DECL_FPURGE
  284. _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
  285. "use gnulib module fpurge for portability");
  286. # endif
  287. #endif
  288. #if @GNULIB_FPUTC@
  289. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  290. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  291. # undef fputc
  292. # define fputc rpl_fputc
  293. # endif
  294. _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
  295. _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
  296. # else
  297. _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
  298. # endif
  299. _GL_CXXALIASWARN (fputc);
  300. #endif
  301. #if @GNULIB_FPUTS@
  302. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  303. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  304. # undef fputs
  305. # define fputs rpl_fputs
  306. # endif
  307. _GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream)
  308. _GL_ARG_NONNULL ((1, 2)));
  309. _GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream));
  310. # else
  311. _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
  312. # endif
  313. _GL_CXXALIASWARN (fputs);
  314. #endif
  315. #if @GNULIB_FREAD@
  316. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  317. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  318. # undef fread
  319. # define fread rpl_fread
  320. # endif
  321. _GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)
  322. _GL_ARG_NONNULL ((4)));
  323. _GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
  324. # else
  325. _GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
  326. # endif
  327. _GL_CXXALIASWARN (fread);
  328. #endif
  329. #if @GNULIB_FREOPEN@
  330. # if @REPLACE_FREOPEN@
  331. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  332. # undef freopen
  333. # define freopen rpl_freopen
  334. # endif
  335. _GL_FUNCDECL_RPL (freopen, FILE *,
  336. (const char *filename, const char *mode, FILE *stream)
  337. _GL_ARG_NONNULL ((2, 3)));
  338. _GL_CXXALIAS_RPL (freopen, FILE *,
  339. (const char *filename, const char *mode, FILE *stream));
  340. # else
  341. _GL_CXXALIAS_SYS (freopen, FILE *,
  342. (const char *filename, const char *mode, FILE *stream));
  343. # endif
  344. _GL_CXXALIASWARN (freopen);
  345. #elif defined GNULIB_POSIXCHECK
  346. # undef freopen
  347. /* Assume freopen is always declared. */
  348. _GL_WARN_ON_USE (freopen,
  349. "freopen on native Windows platforms is not POSIX compliant - "
  350. "use gnulib module freopen for portability");
  351. #endif
  352. #if @GNULIB_FSCANF@
  353. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  354. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  355. # undef fscanf
  356. # define fscanf rpl_fscanf
  357. # endif
  358. _GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...)
  359. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
  360. _GL_ARG_NONNULL ((1, 2)));
  361. _GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...));
  362. # else
  363. _GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...));
  364. # endif
  365. _GL_CXXALIASWARN (fscanf);
  366. #endif
  367. /* Set up the following warnings, based on which modules are in use.
  368. GNU Coding Standards discourage the use of fseek, since it imposes
  369. an arbitrary limitation on some 32-bit hosts. Remember that the
  370. fseek module depends on the fseeko module, so we only have three
  371. cases to consider:
  372. 1. The developer is not using either module. Issue a warning under
  373. GNULIB_POSIXCHECK for both functions, to remind them that both
  374. functions have bugs on some systems. _GL_NO_LARGE_FILES has no
  375. impact on this warning.
  376. 2. The developer is using both modules. They may be unaware of the
  377. arbitrary limitations of fseek, so issue a warning under
  378. GNULIB_POSIXCHECK. On the other hand, they may be using both
  379. modules intentionally, so the developer can define
  380. _GL_NO_LARGE_FILES in the compilation units where the use of fseek
  381. is safe, to silence the warning.
  382. 3. The developer is using the fseeko module, but not fseek. Gnulib
  383. guarantees that fseek will still work around platform bugs in that
  384. case, but we presume that the developer is aware of the pitfalls of
  385. fseek and was trying to avoid it, so issue a warning even when
  386. GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be
  387. defined to silence the warning in particular compilation units.
  388. In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
  389. fseek gets defined as a macro, it is recommended that the developer
  390. uses the fseek module, even if he is not calling the fseek function.
  391. Most gnulib clients that perform stream operations should fall into
  392. category 3. */
  393. #if @GNULIB_FSEEK@
  394. # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
  395. # define _GL_FSEEK_WARN /* Category 2, above. */
  396. # undef fseek
  397. # endif
  398. # if @REPLACE_FSEEK@
  399. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  400. # undef fseek
  401. # define fseek rpl_fseek
  402. # endif
  403. _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
  404. _GL_ARG_NONNULL ((1)));
  405. _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
  406. # else
  407. _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
  408. # endif
  409. _GL_CXXALIASWARN (fseek);
  410. #endif
  411. #if @GNULIB_FSEEKO@
  412. # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
  413. # define _GL_FSEEK_WARN /* Category 3, above. */
  414. # undef fseek
  415. # endif
  416. # if @REPLACE_FSEEKO@
  417. /* Provide an fseeko function that is aware of a preceding fflush(), and which
  418. detects pipes. */
  419. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  420. # undef fseeko
  421. # define fseeko rpl_fseeko
  422. # endif
  423. _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
  424. _GL_ARG_NONNULL ((1)));
  425. _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
  426. # else
  427. # if ! @HAVE_DECL_FSEEKO@
  428. _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
  429. _GL_ARG_NONNULL ((1)));
  430. # endif
  431. _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
  432. # endif
  433. _GL_CXXALIASWARN (fseeko);
  434. #elif defined GNULIB_POSIXCHECK
  435. # define _GL_FSEEK_WARN /* Category 1, above. */
  436. # undef fseek
  437. # undef fseeko
  438. # if HAVE_RAW_DECL_FSEEKO
  439. _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
  440. "use gnulib module fseeko for portability");
  441. # endif
  442. #endif
  443. #ifdef _GL_FSEEK_WARN
  444. # undef _GL_FSEEK_WARN
  445. /* Here, either fseek is undefined (but C89 guarantees that it is
  446. declared), or it is defined as rpl_fseek (declared above). */
  447. _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
  448. "on 32-bit platforms - "
  449. "use fseeko function for handling of large files");
  450. #endif
  451. /* ftell, ftello. See the comments on fseek/fseeko. */
  452. #if @GNULIB_FTELL@
  453. # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
  454. # define _GL_FTELL_WARN /* Category 2, above. */
  455. # undef ftell
  456. # endif
  457. # if @REPLACE_FTELL@
  458. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  459. # undef ftell
  460. # define ftell rpl_ftell
  461. # endif
  462. _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
  463. _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
  464. # else
  465. _GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
  466. # endif
  467. _GL_CXXALIASWARN (ftell);
  468. #endif
  469. #if @GNULIB_FTELLO@
  470. # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
  471. # define _GL_FTELL_WARN /* Category 3, above. */
  472. # undef ftell
  473. # endif
  474. # if @REPLACE_FTELLO@
  475. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  476. # undef ftello
  477. # define ftello rpl_ftello
  478. # endif
  479. _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
  480. _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
  481. # else
  482. # if ! @HAVE_DECL_FTELLO@
  483. _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
  484. # endif
  485. _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
  486. # endif
  487. _GL_CXXALIASWARN (ftello);
  488. #elif defined GNULIB_POSIXCHECK
  489. # define _GL_FTELL_WARN /* Category 1, above. */
  490. # undef ftell
  491. # undef ftello
  492. # if HAVE_RAW_DECL_FTELLO
  493. _GL_WARN_ON_USE (ftello, "ftello is unportable - "
  494. "use gnulib module ftello for portability");
  495. # endif
  496. #endif
  497. #ifdef _GL_FTELL_WARN
  498. # undef _GL_FTELL_WARN
  499. /* Here, either ftell is undefined (but C89 guarantees that it is
  500. declared), or it is defined as rpl_ftell (declared above). */
  501. _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
  502. "on 32-bit platforms - "
  503. "use ftello function for handling of large files");
  504. #endif
  505. #if @GNULIB_FWRITE@
  506. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  507. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  508. # undef fwrite
  509. # define fwrite rpl_fwrite
  510. # endif
  511. _GL_FUNCDECL_RPL (fwrite, size_t,
  512. (const void *ptr, size_t s, size_t n, FILE *stream)
  513. _GL_ARG_NONNULL ((1, 4)));
  514. _GL_CXXALIAS_RPL (fwrite, size_t,
  515. (const void *ptr, size_t s, size_t n, FILE *stream));
  516. # else
  517. _GL_CXXALIAS_SYS (fwrite, size_t,
  518. (const void *ptr, size_t s, size_t n, FILE *stream));
  519. /* Work around glibc bug 11959
  520. <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
  521. which sometimes causes an unwanted diagnostic for fwrite calls.
  522. This affects only function declaration attributes, so it's not
  523. needed for C++. */
  524. # if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL
  525. static inline size_t _GL_ARG_NONNULL ((1, 4))
  526. rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
  527. {
  528. size_t r = fwrite (ptr, s, n, stream);
  529. (void) r;
  530. return r;
  531. }
  532. # undef fwrite
  533. # define fwrite rpl_fwrite
  534. # endif
  535. # endif
  536. _GL_CXXALIASWARN (fwrite);
  537. #endif
  538. #if @GNULIB_GETC@
  539. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  540. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  541. # undef getc
  542. # define getc rpl_fgetc
  543. # endif
  544. _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
  545. _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
  546. # else
  547. _GL_CXXALIAS_SYS (getc, int, (FILE *stream));
  548. # endif
  549. _GL_CXXALIASWARN (getc);
  550. #endif
  551. #if @GNULIB_GETCHAR@
  552. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  553. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  554. # undef getchar
  555. # define getchar rpl_getchar
  556. # endif
  557. _GL_FUNCDECL_RPL (getchar, int, (void));
  558. _GL_CXXALIAS_RPL (getchar, int, (void));
  559. # else
  560. _GL_CXXALIAS_SYS (getchar, int, (void));
  561. # endif
  562. _GL_CXXALIASWARN (getchar);
  563. #endif
  564. #if @GNULIB_GETDELIM@
  565. /* Read input, up to (and including) the next occurrence of DELIMITER, from
  566. STREAM, store it in *LINEPTR (and NUL-terminate it).
  567. *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
  568. bytes of space. It is realloc'd as necessary.
  569. Return the number of bytes read and stored at *LINEPTR (not including the
  570. NUL terminator), or -1 on error or EOF. */
  571. # if @REPLACE_GETDELIM@
  572. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  573. # undef getdelim
  574. # define getdelim rpl_getdelim
  575. # endif
  576. _GL_FUNCDECL_RPL (getdelim, ssize_t,
  577. (char **lineptr, size_t *linesize, int delimiter,
  578. FILE *stream)
  579. _GL_ARG_NONNULL ((1, 2, 4)));
  580. _GL_CXXALIAS_RPL (getdelim, ssize_t,
  581. (char **lineptr, size_t *linesize, int delimiter,
  582. FILE *stream));
  583. # else
  584. # if !@HAVE_DECL_GETDELIM@
  585. _GL_FUNCDECL_SYS (getdelim, ssize_t,
  586. (char **lineptr, size_t *linesize, int delimiter,
  587. FILE *stream)
  588. _GL_ARG_NONNULL ((1, 2, 4)));
  589. # endif
  590. _GL_CXXALIAS_SYS (getdelim, ssize_t,
  591. (char **lineptr, size_t *linesize, int delimiter,
  592. FILE *stream));
  593. # endif
  594. _GL_CXXALIASWARN (getdelim);
  595. #elif defined GNULIB_POSIXCHECK
  596. # undef getdelim
  597. # if HAVE_RAW_DECL_GETDELIM
  598. _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
  599. "use gnulib module getdelim for portability");
  600. # endif
  601. #endif
  602. #if @GNULIB_GETLINE@
  603. /* Read a line, up to (and including) the next newline, from STREAM, store it
  604. in *LINEPTR (and NUL-terminate it).
  605. *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
  606. bytes of space. It is realloc'd as necessary.
  607. Return the number of bytes read and stored at *LINEPTR (not including the
  608. NUL terminator), or -1 on error or EOF. */
  609. # if @REPLACE_GETLINE@
  610. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  611. # undef getline
  612. # define getline rpl_getline
  613. # endif
  614. _GL_FUNCDECL_RPL (getline, ssize_t,
  615. (char **lineptr, size_t *linesize, FILE *stream)
  616. _GL_ARG_NONNULL ((1, 2, 3)));
  617. _GL_CXXALIAS_RPL (getline, ssize_t,
  618. (char **lineptr, size_t *linesize, FILE *stream));
  619. # else
  620. # if !@HAVE_DECL_GETLINE@
  621. _GL_FUNCDECL_SYS (getline, ssize_t,
  622. (char **lineptr, size_t *linesize, FILE *stream)
  623. _GL_ARG_NONNULL ((1, 2, 3)));
  624. # endif
  625. _GL_CXXALIAS_SYS (getline, ssize_t,
  626. (char **lineptr, size_t *linesize, FILE *stream));
  627. # endif
  628. # if @HAVE_DECL_GETLINE@
  629. _GL_CXXALIASWARN (getline);
  630. # endif
  631. #elif defined GNULIB_POSIXCHECK
  632. # undef getline
  633. # if HAVE_RAW_DECL_GETLINE
  634. _GL_WARN_ON_USE (getline, "getline is unportable - "
  635. "use gnulib module getline for portability");
  636. # endif
  637. #endif
  638. #if @GNULIB_GETS@
  639. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  640. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  641. # undef gets
  642. # define gets rpl_gets
  643. # endif
  644. _GL_FUNCDECL_RPL (gets, char *, (char *s) _GL_ARG_NONNULL ((1)));
  645. _GL_CXXALIAS_RPL (gets, char *, (char *s));
  646. # else
  647. _GL_CXXALIAS_SYS (gets, char *, (char *s));
  648. # undef gets
  649. # endif
  650. _GL_CXXALIASWARN (gets);
  651. /* It is very rare that the developer ever has full control of stdin,
  652. so any use of gets warrants an unconditional warning. Assume it is
  653. always declared, since it is required by C89. */
  654. _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
  655. #endif
  656. #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
  657. struct obstack;
  658. /* Grow an obstack with formatted output. Return the number of
  659. bytes added to OBS. No trailing nul byte is added, and the
  660. object should be closed with obstack_finish before use. Upon
  661. memory allocation error, call obstack_alloc_failed_handler. Upon
  662. other error, return -1. */
  663. # if @REPLACE_OBSTACK_PRINTF@
  664. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  665. # define obstack_printf rpl_obstack_printf
  666. # endif
  667. _GL_FUNCDECL_RPL (obstack_printf, int,
  668. (struct obstack *obs, const char *format, ...)
  669. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  670. _GL_ARG_NONNULL ((1, 2)));
  671. _GL_CXXALIAS_RPL (obstack_printf, int,
  672. (struct obstack *obs, const char *format, ...));
  673. # else
  674. # if !@HAVE_DECL_OBSTACK_PRINTF@
  675. _GL_FUNCDECL_SYS (obstack_printf, int,
  676. (struct obstack *obs, const char *format, ...)
  677. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  678. _GL_ARG_NONNULL ((1, 2)));
  679. # endif
  680. _GL_CXXALIAS_SYS (obstack_printf, int,
  681. (struct obstack *obs, const char *format, ...));
  682. # endif
  683. _GL_CXXALIASWARN (obstack_printf);
  684. # if @REPLACE_OBSTACK_PRINTF@
  685. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  686. # define obstack_vprintf rpl_obstack_vprintf
  687. # endif
  688. _GL_FUNCDECL_RPL (obstack_vprintf, int,
  689. (struct obstack *obs, const char *format, va_list args)
  690. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  691. _GL_ARG_NONNULL ((1, 2)));
  692. _GL_CXXALIAS_RPL (obstack_vprintf, int,
  693. (struct obstack *obs, const char *format, va_list args));
  694. # else
  695. # if !@HAVE_DECL_OBSTACK_PRINTF@
  696. _GL_FUNCDECL_SYS (obstack_vprintf, int,
  697. (struct obstack *obs, const char *format, va_list args)
  698. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  699. _GL_ARG_NONNULL ((1, 2)));
  700. # endif
  701. _GL_CXXALIAS_SYS (obstack_vprintf, int,
  702. (struct obstack *obs, const char *format, va_list args));
  703. # endif
  704. _GL_CXXALIASWARN (obstack_vprintf);
  705. #endif
  706. #if @GNULIB_PCLOSE@
  707. # if !@HAVE_PCLOSE@
  708. _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
  709. # endif
  710. _GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
  711. _GL_CXXALIASWARN (pclose);
  712. #elif defined GNULIB_POSIXCHECK
  713. # undef pclose
  714. # if HAVE_RAW_DECL_PCLOSE
  715. _GL_WARN_ON_USE (pclose, "popen is unportable - "
  716. "use gnulib module pclose for more portability");
  717. # endif
  718. #endif
  719. #if @GNULIB_PERROR@
  720. /* Print a message to standard error, describing the value of ERRNO,
  721. (if STRING is not NULL and not empty) prefixed with STRING and ": ",
  722. and terminated with a newline. */
  723. # if @REPLACE_PERROR@
  724. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  725. # define perror rpl_perror
  726. # endif
  727. _GL_FUNCDECL_RPL (perror, void, (const char *string));
  728. _GL_CXXALIAS_RPL (perror, void, (const char *string));
  729. # else
  730. _GL_CXXALIAS_SYS (perror, void, (const char *string));
  731. # endif
  732. _GL_CXXALIASWARN (perror);
  733. #elif defined GNULIB_POSIXCHECK
  734. # undef perror
  735. /* Assume perror is always declared. */
  736. _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
  737. "use gnulib module perror for portability");
  738. #endif
  739. #if @GNULIB_POPEN@
  740. # if @REPLACE_POPEN@
  741. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  742. # undef popen
  743. # define popen rpl_popen
  744. # endif
  745. _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
  746. _GL_ARG_NONNULL ((1, 2)));
  747. _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
  748. # else
  749. # if !@HAVE_POPEN@
  750. _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode)
  751. _GL_ARG_NONNULL ((1, 2)));
  752. # endif
  753. _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
  754. # endif
  755. _GL_CXXALIASWARN (popen);
  756. #elif defined GNULIB_POSIXCHECK
  757. # undef popen
  758. # if HAVE_RAW_DECL_POPEN
  759. _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
  760. "use gnulib module popen or pipe for more portability");
  761. # endif
  762. #endif
  763. #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
  764. # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
  765. || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  766. # if defined __GNUC__
  767. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  768. /* Don't break __attribute__((format(printf,M,N))). */
  769. # define printf __printf__
  770. # endif
  771. # if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
  772. _GL_FUNCDECL_RPL_1 (__printf__, int,
  773. (const char *format, ...)
  774. __asm__ (@ASM_SYMBOL_PREFIX@
  775. _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
  776. _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
  777. _GL_ARG_NONNULL ((1)));
  778. # else
  779. _GL_FUNCDECL_RPL_1 (__printf__, int,
  780. (const char *format, ...)
  781. __asm__ (@ASM_SYMBOL_PREFIX@
  782. _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
  783. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
  784. _GL_ARG_NONNULL ((1)));
  785. # endif
  786. _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
  787. # else
  788. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  789. # define printf rpl_printf
  790. # endif
  791. _GL_FUNCDECL_RPL (printf, int,
  792. (const char *format, ...)
  793. _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
  794. _GL_ARG_NONNULL ((1)));
  795. _GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
  796. # endif
  797. # define GNULIB_overrides_printf 1
  798. # else
  799. _GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
  800. # endif
  801. _GL_CXXALIASWARN (printf);
  802. #endif
  803. #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  804. # if !GNULIB_overrides_printf
  805. # undef printf
  806. # endif
  807. /* Assume printf is always declared. */
  808. _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
  809. "use gnulib module printf-posix for portable "
  810. "POSIX compliance");
  811. #endif
  812. #if @GNULIB_PUTC@
  813. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  814. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  815. # undef putc
  816. # define putc rpl_fputc
  817. # endif
  818. _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
  819. _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
  820. # else
  821. _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
  822. # endif
  823. _GL_CXXALIASWARN (putc);
  824. #endif
  825. #if @GNULIB_PUTCHAR@
  826. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  827. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  828. # undef putchar
  829. # define putchar rpl_putchar
  830. # endif
  831. _GL_FUNCDECL_RPL (putchar, int, (int c));
  832. _GL_CXXALIAS_RPL (putchar, int, (int c));
  833. # else
  834. _GL_CXXALIAS_SYS (putchar, int, (int c));
  835. # endif
  836. _GL_CXXALIASWARN (putchar);
  837. #endif
  838. #if @GNULIB_PUTS@
  839. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  840. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  841. # undef puts
  842. # define puts rpl_puts
  843. # endif
  844. _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
  845. _GL_CXXALIAS_RPL (puts, int, (const char *string));
  846. # else
  847. _GL_CXXALIAS_SYS (puts, int, (const char *string));
  848. # endif
  849. _GL_CXXALIASWARN (puts);
  850. #endif
  851. #if @GNULIB_REMOVE@
  852. # if @REPLACE_REMOVE@
  853. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  854. # undef remove
  855. # define remove rpl_remove
  856. # endif
  857. _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
  858. _GL_CXXALIAS_RPL (remove, int, (const char *name));
  859. # else
  860. _GL_CXXALIAS_SYS (remove, int, (const char *name));
  861. # endif
  862. _GL_CXXALIASWARN (remove);
  863. #elif defined GNULIB_POSIXCHECK
  864. # undef remove
  865. /* Assume remove is always declared. */
  866. _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
  867. "use gnulib module remove for more portability");
  868. #endif
  869. #if @GNULIB_RENAME@
  870. # if @REPLACE_RENAME@
  871. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  872. # undef rename
  873. # define rename rpl_rename
  874. # endif
  875. _GL_FUNCDECL_RPL (rename, int,
  876. (const char *old_filename, const char *new_filename)
  877. _GL_ARG_NONNULL ((1, 2)));
  878. _GL_CXXALIAS_RPL (rename, int,
  879. (const char *old_filename, const char *new_filename));
  880. # else
  881. _GL_CXXALIAS_SYS (rename, int,
  882. (const char *old_filename, const char *new_filename));
  883. # endif
  884. _GL_CXXALIASWARN (rename);
  885. #elif defined GNULIB_POSIXCHECK
  886. # undef rename
  887. /* Assume rename is always declared. */
  888. _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
  889. "use gnulib module rename for more portability");
  890. #endif
  891. #if @GNULIB_RENAMEAT@
  892. # if @REPLACE_RENAMEAT@
  893. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  894. # undef renameat
  895. # define renameat rpl_renameat
  896. # endif
  897. _GL_FUNCDECL_RPL (renameat, int,
  898. (int fd1, char const *file1, int fd2, char const *file2)
  899. _GL_ARG_NONNULL ((2, 4)));
  900. _GL_CXXALIAS_RPL (renameat, int,
  901. (int fd1, char const *file1, int fd2, char const *file2));
  902. # else
  903. # if !@HAVE_RENAMEAT@
  904. _GL_FUNCDECL_SYS (renameat, int,
  905. (int fd1, char const *file1, int fd2, char const *file2)
  906. _GL_ARG_NONNULL ((2, 4)));
  907. # endif
  908. _GL_CXXALIAS_SYS (renameat, int,
  909. (int fd1, char const *file1, int fd2, char const *file2));
  910. # endif
  911. _GL_CXXALIASWARN (renameat);
  912. #elif defined GNULIB_POSIXCHECK
  913. # undef renameat
  914. # if HAVE_RAW_DECL_RENAMEAT
  915. _GL_WARN_ON_USE (renameat, "renameat is not portable - "
  916. "use gnulib module renameat for portability");
  917. # endif
  918. #endif
  919. #if @GNULIB_SCANF@
  920. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  921. # if defined __GNUC__
  922. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  923. # undef scanf
  924. /* Don't break __attribute__((format(scanf,M,N))). */
  925. # define scanf __scanf__
  926. # endif
  927. _GL_FUNCDECL_RPL_1 (__scanf__, int,
  928. (const char *format, ...)
  929. __asm__ (@ASM_SYMBOL_PREFIX@
  930. _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
  931. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
  932. _GL_ARG_NONNULL ((1)));
  933. _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...));
  934. # else
  935. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  936. # undef scanf
  937. # define scanf rpl_scanf
  938. # endif
  939. _GL_FUNCDECL_RPL (scanf, int, (const char *format, ...)
  940. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
  941. _GL_ARG_NONNULL ((1)));
  942. _GL_CXXALIAS_RPL (scanf, int, (const char *format, ...));
  943. # endif
  944. # else
  945. _GL_CXXALIAS_SYS (scanf, int, (const char *format, ...));
  946. # endif
  947. _GL_CXXALIASWARN (scanf);
  948. #endif
  949. #if @GNULIB_SNPRINTF@
  950. # if @REPLACE_SNPRINTF@
  951. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  952. # define snprintf rpl_snprintf
  953. # endif
  954. _GL_FUNCDECL_RPL (snprintf, int,
  955. (char *str, size_t size, const char *format, ...)
  956. _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
  957. _GL_ARG_NONNULL ((3)));
  958. _GL_CXXALIAS_RPL (snprintf, int,
  959. (char *str, size_t size, const char *format, ...));
  960. # else
  961. # if !@HAVE_DECL_SNPRINTF@
  962. _GL_FUNCDECL_SYS (snprintf, int,
  963. (char *str, size_t size, const char *format, ...)
  964. _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
  965. _GL_ARG_NONNULL ((3)));
  966. # endif
  967. _GL_CXXALIAS_SYS (snprintf, int,
  968. (char *str, size_t size, const char *format, ...));
  969. # endif
  970. _GL_CXXALIASWARN (snprintf);
  971. #elif defined GNULIB_POSIXCHECK
  972. # undef snprintf
  973. # if HAVE_RAW_DECL_SNPRINTF
  974. _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
  975. "use gnulib module snprintf for portability");
  976. # endif
  977. #endif
  978. /* Some people would argue that sprintf should be handled like gets
  979. (for example, OpenBSD issues a link warning for both functions),
  980. since both can cause security holes due to buffer overruns.
  981. However, we believe that sprintf can be used safely, and is more
  982. efficient than snprintf in those safe cases; and as proof of our
  983. belief, we use sprintf in several gnulib modules. So this header
  984. intentionally avoids adding a warning to sprintf except when
  985. GNULIB_POSIXCHECK is defined. */
  986. #if @GNULIB_SPRINTF_POSIX@
  987. # if @REPLACE_SPRINTF@
  988. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  989. # define sprintf rpl_sprintf
  990. # endif
  991. _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
  992. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  993. _GL_ARG_NONNULL ((1, 2)));
  994. _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
  995. # else
  996. _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...));
  997. # endif
  998. _GL_CXXALIASWARN (sprintf);
  999. #elif defined GNULIB_POSIXCHECK
  1000. # undef sprintf
  1001. /* Assume sprintf is always declared. */
  1002. _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
  1003. "use gnulib module sprintf-posix for portable "
  1004. "POSIX compliance");
  1005. #endif
  1006. #if @GNULIB_TMPFILE@
  1007. # if @REPLACE_TMPFILE@
  1008. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1009. # define tmpfile rpl_tmpfile
  1010. # endif
  1011. _GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
  1012. _GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
  1013. # else
  1014. _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
  1015. # endif
  1016. _GL_CXXALIASWARN (tmpfile);
  1017. #elif defined GNULIB_POSIXCHECK
  1018. # undef tmpfile
  1019. # if HAVE_RAW_DECL_TMPFILE
  1020. _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
  1021. "use gnulib module tmpfile for portability");
  1022. # endif
  1023. #endif
  1024. #if @GNULIB_VASPRINTF@
  1025. /* Write formatted output to a string dynamically allocated with malloc().
  1026. If the memory allocation succeeds, store the address of the string in
  1027. *RESULT and return the number of resulting bytes, excluding the trailing
  1028. NUL. Upon memory allocation error, or some other error, return -1. */
  1029. # if @REPLACE_VASPRINTF@
  1030. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1031. # define asprintf rpl_asprintf
  1032. # endif
  1033. _GL_FUNCDECL_RPL (asprintf, int,
  1034. (char **result, const char *format, ...)
  1035. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  1036. _GL_ARG_NONNULL ((1, 2)));
  1037. _GL_CXXALIAS_RPL (asprintf, int,
  1038. (char **result, const char *format, ...));
  1039. # else
  1040. # if !@HAVE_VASPRINTF@
  1041. _GL_FUNCDECL_SYS (asprintf, int,
  1042. (char **result, const char *format, ...)
  1043. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  1044. _GL_ARG_NONNULL ((1, 2)));
  1045. # endif
  1046. _GL_CXXALIAS_SYS (asprintf, int,
  1047. (char **result, const char *format, ...));
  1048. # endif
  1049. _GL_CXXALIASWARN (asprintf);
  1050. # if @REPLACE_VASPRINTF@
  1051. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1052. # define vasprintf rpl_vasprintf
  1053. # endif
  1054. _GL_FUNCDECL_RPL (vasprintf, int,
  1055. (char **result, const char *format, va_list args)
  1056. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1057. _GL_ARG_NONNULL ((1, 2)));
  1058. _GL_CXXALIAS_RPL (vasprintf, int,
  1059. (char **result, const char *format, va_list args));
  1060. # else
  1061. # if !@HAVE_VASPRINTF@
  1062. _GL_FUNCDECL_SYS (vasprintf, int,
  1063. (char **result, const char *format, va_list args)
  1064. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1065. _GL_ARG_NONNULL ((1, 2)));
  1066. # endif
  1067. _GL_CXXALIAS_SYS (vasprintf, int,
  1068. (char **result, const char *format, va_list args));
  1069. # endif
  1070. _GL_CXXALIASWARN (vasprintf);
  1071. #endif
  1072. #if @GNULIB_VDPRINTF@
  1073. # if @REPLACE_VDPRINTF@
  1074. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1075. # define vdprintf rpl_vdprintf
  1076. # endif
  1077. _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
  1078. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1079. _GL_ARG_NONNULL ((2)));
  1080. _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
  1081. # else
  1082. # if !@HAVE_VDPRINTF@
  1083. _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
  1084. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1085. _GL_ARG_NONNULL ((2)));
  1086. # endif
  1087. /* Need to cast, because on Solaris, the third parameter will likely be
  1088. __va_list args. */
  1089. _GL_CXXALIAS_SYS_CAST (vdprintf, int,
  1090. (int fd, const char *format, va_list args));
  1091. # endif
  1092. _GL_CXXALIASWARN (vdprintf);
  1093. #elif defined GNULIB_POSIXCHECK
  1094. # undef vdprintf
  1095. # if HAVE_RAW_DECL_VDPRINTF
  1096. _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
  1097. "use gnulib module vdprintf for portability");
  1098. # endif
  1099. #endif
  1100. #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
  1101. # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
  1102. || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  1103. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1104. # define vfprintf rpl_vfprintf
  1105. # endif
  1106. # define GNULIB_overrides_vfprintf 1
  1107. # if @GNULIB_VFPRINTF_POSIX@
  1108. _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
  1109. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1110. _GL_ARG_NONNULL ((1, 2)));
  1111. # else
  1112. _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
  1113. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
  1114. _GL_ARG_NONNULL ((1, 2)));
  1115. # endif
  1116. _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
  1117. # else
  1118. /* Need to cast, because on Solaris, the third parameter is
  1119. __va_list args
  1120. and GCC's fixincludes did not change this to __gnuc_va_list. */
  1121. _GL_CXXALIAS_SYS_CAST (vfprintf, int,
  1122. (FILE *fp, const char *format, va_list args));
  1123. # endif
  1124. _GL_CXXALIASWARN (vfprintf);
  1125. #endif
  1126. #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  1127. # if !GNULIB_overrides_vfprintf
  1128. # undef vfprintf
  1129. # endif
  1130. /* Assume vfprintf is always declared. */
  1131. _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
  1132. "use gnulib module vfprintf-posix for portable "
  1133. "POSIX compliance");
  1134. #endif
  1135. #if @GNULIB_VFSCANF@
  1136. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  1137. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1138. # undef vfscanf
  1139. # define vfscanf rpl_vfscanf
  1140. # endif
  1141. _GL_FUNCDECL_RPL (vfscanf, int,
  1142. (FILE *stream, const char *format, va_list args)
  1143. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
  1144. _GL_ARG_NONNULL ((1, 2)));
  1145. _GL_CXXALIAS_RPL (vfscanf, int,
  1146. (FILE *stream, const char *format, va_list args));
  1147. # else
  1148. _GL_CXXALIAS_SYS (vfscanf, int,
  1149. (FILE *stream, const char *format, va_list args));
  1150. # endif
  1151. _GL_CXXALIASWARN (vfscanf);
  1152. #endif
  1153. #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
  1154. # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
  1155. || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  1156. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1157. # define vprintf rpl_vprintf
  1158. # endif
  1159. # define GNULIB_overrides_vprintf 1
  1160. # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
  1161. _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
  1162. _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
  1163. _GL_ARG_NONNULL ((1)));
  1164. # else
  1165. _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
  1166. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
  1167. _GL_ARG_NONNULL ((1)));
  1168. # endif
  1169. _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
  1170. # else
  1171. /* Need to cast, because on Solaris, the second parameter is
  1172. __va_list args
  1173. and GCC's fixincludes did not change this to __gnuc_va_list. */
  1174. _GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args));
  1175. # endif
  1176. _GL_CXXALIASWARN (vprintf);
  1177. #endif
  1178. #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  1179. # if !GNULIB_overrides_vprintf
  1180. # undef vprintf
  1181. # endif
  1182. /* Assume vprintf is always declared. */
  1183. _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
  1184. "use gnulib module vprintf-posix for portable "
  1185. "POSIX compliance");
  1186. #endif
  1187. #if @GNULIB_VSCANF@
  1188. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  1189. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1190. # undef vscanf
  1191. # define vscanf rpl_vscanf
  1192. # endif
  1193. _GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args)
  1194. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
  1195. _GL_ARG_NONNULL ((1)));
  1196. _GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args));
  1197. # else
  1198. _GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args));
  1199. # endif
  1200. _GL_CXXALIASWARN (vscanf);
  1201. #endif
  1202. #if @GNULIB_VSNPRINTF@
  1203. # if @REPLACE_VSNPRINTF@
  1204. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1205. # define vsnprintf rpl_vsnprintf
  1206. # endif
  1207. _GL_FUNCDECL_RPL (vsnprintf, int,
  1208. (char *str, size_t size, const char *format, va_list args)
  1209. _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
  1210. _GL_ARG_NONNULL ((3)));
  1211. _GL_CXXALIAS_RPL (vsnprintf, int,
  1212. (char *str, size_t size, const char *format, va_list args));
  1213. # else
  1214. # if !@HAVE_DECL_VSNPRINTF@
  1215. _GL_FUNCDECL_SYS (vsnprintf, int,
  1216. (char *str, size_t size, const char *format, va_list args)
  1217. _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
  1218. _GL_ARG_NONNULL ((3)));
  1219. # endif
  1220. _GL_CXXALIAS_SYS (vsnprintf, int,
  1221. (char *str, size_t size, const char *format, va_list args));
  1222. # endif
  1223. _GL_CXXALIASWARN (vsnprintf);
  1224. #elif defined GNULIB_POSIXCHECK
  1225. # undef vsnprintf
  1226. # if HAVE_RAW_DECL_VSNPRINTF
  1227. _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
  1228. "use gnulib module vsnprintf for portability");
  1229. # endif
  1230. #endif
  1231. #if @GNULIB_VSPRINTF_POSIX@
  1232. # if @REPLACE_VSPRINTF@
  1233. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1234. # define vsprintf rpl_vsprintf
  1235. # endif
  1236. _GL_FUNCDECL_RPL (vsprintf, int,
  1237. (char *str, const char *format, va_list args)
  1238. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1239. _GL_ARG_NONNULL ((1, 2)));
  1240. _GL_CXXALIAS_RPL (vsprintf, int,
  1241. (char *str, const char *format, va_list args));
  1242. # else
  1243. /* Need to cast, because on Solaris, the third parameter is
  1244. __va_list args
  1245. and GCC's fixincludes did not change this to __gnuc_va_list. */
  1246. _GL_CXXALIAS_SYS_CAST (vsprintf, int,
  1247. (char *str, const char *format, va_list args));
  1248. # endif
  1249. _GL_CXXALIASWARN (vsprintf);
  1250. #elif defined GNULIB_POSIXCHECK
  1251. # undef vsprintf
  1252. /* Assume vsprintf is always declared. */
  1253. _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
  1254. "use gnulib module vsprintf-posix for portable "
  1255. "POSIX compliance");
  1256. #endif
  1257. #endif /* _@GUARD_PREFIX@_STDIO_H */
  1258. #endif /* _@GUARD_PREFIX@_STDIO_H */
  1259. #endif