stdio.in.h 48 KB

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