stdio.in.h 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  1. /* A GNU-like <stdio.h>.
  2. Copyright (C) 2004, 2007-2013 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, see <http://www.gnu.org/licenses/>. */
  13. #if __GNUC__ >= 3
  14. @PRAGMA_SYSTEM_HEADER@
  15. #endif
  16. @PRAGMA_COLUMNS@
  17. #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
  18. /* Special invocation convention:
  19. - Inside glibc header files.
  20. - On OSF/1 5.1 we have a sequence of nested includes
  21. <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
  22. <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
  23. In this situation, the functions are not yet declared, therefore we cannot
  24. provide the C++ aliases. */
  25. #@INCLUDE_NEXT@ @NEXT_STDIO_H@
  26. #else
  27. /* Normal invocation convention. */
  28. #ifndef _@GUARD_PREFIX@_STDIO_H
  29. #define _GL_ALREADY_INCLUDING_STDIO_H
  30. /* The include_next requires a split double-inclusion guard. */
  31. #@INCLUDE_NEXT@ @NEXT_STDIO_H@
  32. #undef _GL_ALREADY_INCLUDING_STDIO_H
  33. #ifndef _@GUARD_PREFIX@_STDIO_H
  34. #define _@GUARD_PREFIX@_STDIO_H
  35. /* Get va_list. Needed on many systems, including glibc 2.8. */
  36. #include <stdarg.h>
  37. #include <stddef.h>
  38. /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
  39. and eglibc 2.11.2.
  40. May also define off_t to a 64-bit type on native Windows. */
  41. #include <sys/types.h>
  42. /* 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 bug 11959 when fortifying glibc 2.4 through 2.15
  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 under certain
  523. versions of gcc, and is not needed for C++. */
  524. # if (0 < __USE_FORTIFY_LEVEL \
  525. && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
  526. && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
  527. && !defined __cplusplus)
  528. # undef fwrite
  529. # define fwrite(a, b, c, d) ({size_t __r = fwrite (a, b, c, d); __r; })
  530. # endif
  531. # endif
  532. _GL_CXXALIASWARN (fwrite);
  533. #endif
  534. #if @GNULIB_GETC@
  535. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  536. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  537. # undef getc
  538. # define getc rpl_fgetc
  539. # endif
  540. _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
  541. _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
  542. # else
  543. _GL_CXXALIAS_SYS (getc, int, (FILE *stream));
  544. # endif
  545. _GL_CXXALIASWARN (getc);
  546. #endif
  547. #if @GNULIB_GETCHAR@
  548. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  549. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  550. # undef getchar
  551. # define getchar rpl_getchar
  552. # endif
  553. _GL_FUNCDECL_RPL (getchar, int, (void));
  554. _GL_CXXALIAS_RPL (getchar, int, (void));
  555. # else
  556. _GL_CXXALIAS_SYS (getchar, int, (void));
  557. # endif
  558. _GL_CXXALIASWARN (getchar);
  559. #endif
  560. #if @GNULIB_GETDELIM@
  561. /* Read input, up to (and including) the next occurrence of DELIMITER, from
  562. STREAM, store it in *LINEPTR (and NUL-terminate it).
  563. *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
  564. bytes of space. It is realloc'd as necessary.
  565. Return the number of bytes read and stored at *LINEPTR (not including the
  566. NUL terminator), or -1 on error or EOF. */
  567. # if @REPLACE_GETDELIM@
  568. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  569. # undef getdelim
  570. # define getdelim rpl_getdelim
  571. # endif
  572. _GL_FUNCDECL_RPL (getdelim, ssize_t,
  573. (char **lineptr, size_t *linesize, int delimiter,
  574. FILE *stream)
  575. _GL_ARG_NONNULL ((1, 2, 4)));
  576. _GL_CXXALIAS_RPL (getdelim, ssize_t,
  577. (char **lineptr, size_t *linesize, int delimiter,
  578. FILE *stream));
  579. # else
  580. # if !@HAVE_DECL_GETDELIM@
  581. _GL_FUNCDECL_SYS (getdelim, ssize_t,
  582. (char **lineptr, size_t *linesize, int delimiter,
  583. FILE *stream)
  584. _GL_ARG_NONNULL ((1, 2, 4)));
  585. # endif
  586. _GL_CXXALIAS_SYS (getdelim, ssize_t,
  587. (char **lineptr, size_t *linesize, int delimiter,
  588. FILE *stream));
  589. # endif
  590. _GL_CXXALIASWARN (getdelim);
  591. #elif defined GNULIB_POSIXCHECK
  592. # undef getdelim
  593. # if HAVE_RAW_DECL_GETDELIM
  594. _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
  595. "use gnulib module getdelim for portability");
  596. # endif
  597. #endif
  598. #if @GNULIB_GETLINE@
  599. /* Read a line, up to (and including) the next newline, from STREAM, store it
  600. in *LINEPTR (and NUL-terminate it).
  601. *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
  602. bytes of space. It is realloc'd as necessary.
  603. Return the number of bytes read and stored at *LINEPTR (not including the
  604. NUL terminator), or -1 on error or EOF. */
  605. # if @REPLACE_GETLINE@
  606. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  607. # undef getline
  608. # define getline rpl_getline
  609. # endif
  610. _GL_FUNCDECL_RPL (getline, ssize_t,
  611. (char **lineptr, size_t *linesize, FILE *stream)
  612. _GL_ARG_NONNULL ((1, 2, 3)));
  613. _GL_CXXALIAS_RPL (getline, ssize_t,
  614. (char **lineptr, size_t *linesize, FILE *stream));
  615. # else
  616. # if !@HAVE_DECL_GETLINE@
  617. _GL_FUNCDECL_SYS (getline, ssize_t,
  618. (char **lineptr, size_t *linesize, FILE *stream)
  619. _GL_ARG_NONNULL ((1, 2, 3)));
  620. # endif
  621. _GL_CXXALIAS_SYS (getline, ssize_t,
  622. (char **lineptr, size_t *linesize, FILE *stream));
  623. # endif
  624. # if @HAVE_DECL_GETLINE@
  625. _GL_CXXALIASWARN (getline);
  626. # endif
  627. #elif defined GNULIB_POSIXCHECK
  628. # undef getline
  629. # if HAVE_RAW_DECL_GETLINE
  630. _GL_WARN_ON_USE (getline, "getline is unportable - "
  631. "use gnulib module getline for portability");
  632. # endif
  633. #endif
  634. /* It is very rare that the developer ever has full control of stdin,
  635. so any use of gets warrants an unconditional warning; besides, C11
  636. removed it. */
  637. #undef gets
  638. #if HAVE_RAW_DECL_GETS
  639. _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
  640. #endif
  641. #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
  642. struct obstack;
  643. /* Grow an obstack with formatted output. Return the number of
  644. bytes added to OBS. No trailing nul byte is added, and the
  645. object should be closed with obstack_finish before use. Upon
  646. memory allocation error, call obstack_alloc_failed_handler. Upon
  647. other error, return -1. */
  648. # if @REPLACE_OBSTACK_PRINTF@
  649. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  650. # define obstack_printf rpl_obstack_printf
  651. # endif
  652. _GL_FUNCDECL_RPL (obstack_printf, int,
  653. (struct obstack *obs, const char *format, ...)
  654. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  655. _GL_ARG_NONNULL ((1, 2)));
  656. _GL_CXXALIAS_RPL (obstack_printf, int,
  657. (struct obstack *obs, const char *format, ...));
  658. # else
  659. # if !@HAVE_DECL_OBSTACK_PRINTF@
  660. _GL_FUNCDECL_SYS (obstack_printf, int,
  661. (struct obstack *obs, const char *format, ...)
  662. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  663. _GL_ARG_NONNULL ((1, 2)));
  664. # endif
  665. _GL_CXXALIAS_SYS (obstack_printf, int,
  666. (struct obstack *obs, const char *format, ...));
  667. # endif
  668. _GL_CXXALIASWARN (obstack_printf);
  669. # if @REPLACE_OBSTACK_PRINTF@
  670. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  671. # define obstack_vprintf rpl_obstack_vprintf
  672. # endif
  673. _GL_FUNCDECL_RPL (obstack_vprintf, int,
  674. (struct obstack *obs, const char *format, va_list args)
  675. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  676. _GL_ARG_NONNULL ((1, 2)));
  677. _GL_CXXALIAS_RPL (obstack_vprintf, int,
  678. (struct obstack *obs, const char *format, va_list args));
  679. # else
  680. # if !@HAVE_DECL_OBSTACK_PRINTF@
  681. _GL_FUNCDECL_SYS (obstack_vprintf, int,
  682. (struct obstack *obs, const char *format, va_list args)
  683. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  684. _GL_ARG_NONNULL ((1, 2)));
  685. # endif
  686. _GL_CXXALIAS_SYS (obstack_vprintf, int,
  687. (struct obstack *obs, const char *format, va_list args));
  688. # endif
  689. _GL_CXXALIASWARN (obstack_vprintf);
  690. #endif
  691. #if @GNULIB_PCLOSE@
  692. # if !@HAVE_PCLOSE@
  693. _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
  694. # endif
  695. _GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
  696. _GL_CXXALIASWARN (pclose);
  697. #elif defined GNULIB_POSIXCHECK
  698. # undef pclose
  699. # if HAVE_RAW_DECL_PCLOSE
  700. _GL_WARN_ON_USE (pclose, "pclose is unportable - "
  701. "use gnulib module pclose for more portability");
  702. # endif
  703. #endif
  704. #if @GNULIB_PERROR@
  705. /* Print a message to standard error, describing the value of ERRNO,
  706. (if STRING is not NULL and not empty) prefixed with STRING and ": ",
  707. and terminated with a newline. */
  708. # if @REPLACE_PERROR@
  709. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  710. # define perror rpl_perror
  711. # endif
  712. _GL_FUNCDECL_RPL (perror, void, (const char *string));
  713. _GL_CXXALIAS_RPL (perror, void, (const char *string));
  714. # else
  715. _GL_CXXALIAS_SYS (perror, void, (const char *string));
  716. # endif
  717. _GL_CXXALIASWARN (perror);
  718. #elif defined GNULIB_POSIXCHECK
  719. # undef perror
  720. /* Assume perror is always declared. */
  721. _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
  722. "use gnulib module perror for portability");
  723. #endif
  724. #if @GNULIB_POPEN@
  725. # if @REPLACE_POPEN@
  726. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  727. # undef popen
  728. # define popen rpl_popen
  729. # endif
  730. _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
  731. _GL_ARG_NONNULL ((1, 2)));
  732. _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
  733. # else
  734. # if !@HAVE_POPEN@
  735. _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode)
  736. _GL_ARG_NONNULL ((1, 2)));
  737. # endif
  738. _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
  739. # endif
  740. _GL_CXXALIASWARN (popen);
  741. #elif defined GNULIB_POSIXCHECK
  742. # undef popen
  743. # if HAVE_RAW_DECL_POPEN
  744. _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
  745. "use gnulib module popen or pipe for more portability");
  746. # endif
  747. #endif
  748. #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
  749. # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
  750. || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  751. # if defined __GNUC__
  752. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  753. /* Don't break __attribute__((format(printf,M,N))). */
  754. # define printf __printf__
  755. # endif
  756. # if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
  757. _GL_FUNCDECL_RPL_1 (__printf__, int,
  758. (const char *format, ...)
  759. __asm__ (@ASM_SYMBOL_PREFIX@
  760. _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
  761. _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
  762. _GL_ARG_NONNULL ((1)));
  763. # else
  764. _GL_FUNCDECL_RPL_1 (__printf__, int,
  765. (const char *format, ...)
  766. __asm__ (@ASM_SYMBOL_PREFIX@
  767. _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
  768. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
  769. _GL_ARG_NONNULL ((1)));
  770. # endif
  771. _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
  772. # else
  773. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  774. # define printf rpl_printf
  775. # endif
  776. _GL_FUNCDECL_RPL (printf, int,
  777. (const char *format, ...)
  778. _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
  779. _GL_ARG_NONNULL ((1)));
  780. _GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
  781. # endif
  782. # define GNULIB_overrides_printf 1
  783. # else
  784. _GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
  785. # endif
  786. _GL_CXXALIASWARN (printf);
  787. #endif
  788. #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  789. # if !GNULIB_overrides_printf
  790. # undef printf
  791. # endif
  792. /* Assume printf is always declared. */
  793. _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
  794. "use gnulib module printf-posix for portable "
  795. "POSIX compliance");
  796. #endif
  797. #if @GNULIB_PUTC@
  798. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  799. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  800. # undef putc
  801. # define putc rpl_fputc
  802. # endif
  803. _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
  804. _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
  805. # else
  806. _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
  807. # endif
  808. _GL_CXXALIASWARN (putc);
  809. #endif
  810. #if @GNULIB_PUTCHAR@
  811. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  812. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  813. # undef putchar
  814. # define putchar rpl_putchar
  815. # endif
  816. _GL_FUNCDECL_RPL (putchar, int, (int c));
  817. _GL_CXXALIAS_RPL (putchar, int, (int c));
  818. # else
  819. _GL_CXXALIAS_SYS (putchar, int, (int c));
  820. # endif
  821. _GL_CXXALIASWARN (putchar);
  822. #endif
  823. #if @GNULIB_PUTS@
  824. # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
  825. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  826. # undef puts
  827. # define puts rpl_puts
  828. # endif
  829. _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
  830. _GL_CXXALIAS_RPL (puts, int, (const char *string));
  831. # else
  832. _GL_CXXALIAS_SYS (puts, int, (const char *string));
  833. # endif
  834. _GL_CXXALIASWARN (puts);
  835. #endif
  836. #if @GNULIB_REMOVE@
  837. # if @REPLACE_REMOVE@
  838. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  839. # undef remove
  840. # define remove rpl_remove
  841. # endif
  842. _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
  843. _GL_CXXALIAS_RPL (remove, int, (const char *name));
  844. # else
  845. _GL_CXXALIAS_SYS (remove, int, (const char *name));
  846. # endif
  847. _GL_CXXALIASWARN (remove);
  848. #elif defined GNULIB_POSIXCHECK
  849. # undef remove
  850. /* Assume remove is always declared. */
  851. _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
  852. "use gnulib module remove for more portability");
  853. #endif
  854. #if @GNULIB_RENAME@
  855. # if @REPLACE_RENAME@
  856. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  857. # undef rename
  858. # define rename rpl_rename
  859. # endif
  860. _GL_FUNCDECL_RPL (rename, int,
  861. (const char *old_filename, const char *new_filename)
  862. _GL_ARG_NONNULL ((1, 2)));
  863. _GL_CXXALIAS_RPL (rename, int,
  864. (const char *old_filename, const char *new_filename));
  865. # else
  866. _GL_CXXALIAS_SYS (rename, int,
  867. (const char *old_filename, const char *new_filename));
  868. # endif
  869. _GL_CXXALIASWARN (rename);
  870. #elif defined GNULIB_POSIXCHECK
  871. # undef rename
  872. /* Assume rename is always declared. */
  873. _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
  874. "use gnulib module rename for more portability");
  875. #endif
  876. #if @GNULIB_RENAMEAT@
  877. # if @REPLACE_RENAMEAT@
  878. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  879. # undef renameat
  880. # define renameat rpl_renameat
  881. # endif
  882. _GL_FUNCDECL_RPL (renameat, int,
  883. (int fd1, char const *file1, int fd2, char const *file2)
  884. _GL_ARG_NONNULL ((2, 4)));
  885. _GL_CXXALIAS_RPL (renameat, int,
  886. (int fd1, char const *file1, int fd2, char const *file2));
  887. # else
  888. # if !@HAVE_RENAMEAT@
  889. _GL_FUNCDECL_SYS (renameat, int,
  890. (int fd1, char const *file1, int fd2, char const *file2)
  891. _GL_ARG_NONNULL ((2, 4)));
  892. # endif
  893. _GL_CXXALIAS_SYS (renameat, int,
  894. (int fd1, char const *file1, int fd2, char const *file2));
  895. # endif
  896. _GL_CXXALIASWARN (renameat);
  897. #elif defined GNULIB_POSIXCHECK
  898. # undef renameat
  899. # if HAVE_RAW_DECL_RENAMEAT
  900. _GL_WARN_ON_USE (renameat, "renameat is not portable - "
  901. "use gnulib module renameat for portability");
  902. # endif
  903. #endif
  904. #if @GNULIB_SCANF@
  905. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  906. # if defined __GNUC__
  907. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  908. # undef scanf
  909. /* Don't break __attribute__((format(scanf,M,N))). */
  910. # define scanf __scanf__
  911. # endif
  912. _GL_FUNCDECL_RPL_1 (__scanf__, int,
  913. (const char *format, ...)
  914. __asm__ (@ASM_SYMBOL_PREFIX@
  915. _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
  916. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
  917. _GL_ARG_NONNULL ((1)));
  918. _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...));
  919. # else
  920. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  921. # undef scanf
  922. # define scanf rpl_scanf
  923. # endif
  924. _GL_FUNCDECL_RPL (scanf, int, (const char *format, ...)
  925. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
  926. _GL_ARG_NONNULL ((1)));
  927. _GL_CXXALIAS_RPL (scanf, int, (const char *format, ...));
  928. # endif
  929. # else
  930. _GL_CXXALIAS_SYS (scanf, int, (const char *format, ...));
  931. # endif
  932. _GL_CXXALIASWARN (scanf);
  933. #endif
  934. #if @GNULIB_SNPRINTF@
  935. # if @REPLACE_SNPRINTF@
  936. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  937. # define snprintf rpl_snprintf
  938. # endif
  939. _GL_FUNCDECL_RPL (snprintf, int,
  940. (char *str, size_t size, const char *format, ...)
  941. _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
  942. _GL_ARG_NONNULL ((3)));
  943. _GL_CXXALIAS_RPL (snprintf, int,
  944. (char *str, size_t size, const char *format, ...));
  945. # else
  946. # if !@HAVE_DECL_SNPRINTF@
  947. _GL_FUNCDECL_SYS (snprintf, int,
  948. (char *str, size_t size, const char *format, ...)
  949. _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
  950. _GL_ARG_NONNULL ((3)));
  951. # endif
  952. _GL_CXXALIAS_SYS (snprintf, int,
  953. (char *str, size_t size, const char *format, ...));
  954. # endif
  955. _GL_CXXALIASWARN (snprintf);
  956. #elif defined GNULIB_POSIXCHECK
  957. # undef snprintf
  958. # if HAVE_RAW_DECL_SNPRINTF
  959. _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
  960. "use gnulib module snprintf for portability");
  961. # endif
  962. #endif
  963. /* Some people would argue that all sprintf uses should be warned about
  964. (for example, OpenBSD issues a link warning for it),
  965. since it can cause security holes due to buffer overruns.
  966. However, we believe that sprintf can be used safely, and is more
  967. efficient than snprintf in those safe cases; and as proof of our
  968. belief, we use sprintf in several gnulib modules. So this header
  969. intentionally avoids adding a warning to sprintf except when
  970. GNULIB_POSIXCHECK is defined. */
  971. #if @GNULIB_SPRINTF_POSIX@
  972. # if @REPLACE_SPRINTF@
  973. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  974. # define sprintf rpl_sprintf
  975. # endif
  976. _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
  977. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  978. _GL_ARG_NONNULL ((1, 2)));
  979. _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
  980. # else
  981. _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...));
  982. # endif
  983. _GL_CXXALIASWARN (sprintf);
  984. #elif defined GNULIB_POSIXCHECK
  985. # undef sprintf
  986. /* Assume sprintf is always declared. */
  987. _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
  988. "use gnulib module sprintf-posix for portable "
  989. "POSIX compliance");
  990. #endif
  991. #if @GNULIB_TMPFILE@
  992. # if @REPLACE_TMPFILE@
  993. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  994. # define tmpfile rpl_tmpfile
  995. # endif
  996. _GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
  997. _GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
  998. # else
  999. _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
  1000. # endif
  1001. _GL_CXXALIASWARN (tmpfile);
  1002. #elif defined GNULIB_POSIXCHECK
  1003. # undef tmpfile
  1004. # if HAVE_RAW_DECL_TMPFILE
  1005. _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
  1006. "use gnulib module tmpfile for portability");
  1007. # endif
  1008. #endif
  1009. #if @GNULIB_VASPRINTF@
  1010. /* Write formatted output to a string dynamically allocated with malloc().
  1011. If the memory allocation succeeds, store the address of the string in
  1012. *RESULT and return the number of resulting bytes, excluding the trailing
  1013. NUL. Upon memory allocation error, or some other error, return -1. */
  1014. # if @REPLACE_VASPRINTF@
  1015. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1016. # define asprintf rpl_asprintf
  1017. # endif
  1018. _GL_FUNCDECL_RPL (asprintf, int,
  1019. (char **result, const char *format, ...)
  1020. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  1021. _GL_ARG_NONNULL ((1, 2)));
  1022. _GL_CXXALIAS_RPL (asprintf, int,
  1023. (char **result, const char *format, ...));
  1024. # else
  1025. # if !@HAVE_VASPRINTF@
  1026. _GL_FUNCDECL_SYS (asprintf, int,
  1027. (char **result, const char *format, ...)
  1028. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
  1029. _GL_ARG_NONNULL ((1, 2)));
  1030. # endif
  1031. _GL_CXXALIAS_SYS (asprintf, int,
  1032. (char **result, const char *format, ...));
  1033. # endif
  1034. _GL_CXXALIASWARN (asprintf);
  1035. # if @REPLACE_VASPRINTF@
  1036. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1037. # define vasprintf rpl_vasprintf
  1038. # endif
  1039. _GL_FUNCDECL_RPL (vasprintf, int,
  1040. (char **result, const char *format, va_list args)
  1041. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1042. _GL_ARG_NONNULL ((1, 2)));
  1043. _GL_CXXALIAS_RPL (vasprintf, int,
  1044. (char **result, const char *format, va_list args));
  1045. # else
  1046. # if !@HAVE_VASPRINTF@
  1047. _GL_FUNCDECL_SYS (vasprintf, int,
  1048. (char **result, const char *format, va_list args)
  1049. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1050. _GL_ARG_NONNULL ((1, 2)));
  1051. # endif
  1052. _GL_CXXALIAS_SYS (vasprintf, int,
  1053. (char **result, const char *format, va_list args));
  1054. # endif
  1055. _GL_CXXALIASWARN (vasprintf);
  1056. #endif
  1057. #if @GNULIB_VDPRINTF@
  1058. # if @REPLACE_VDPRINTF@
  1059. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1060. # define vdprintf rpl_vdprintf
  1061. # endif
  1062. _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
  1063. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1064. _GL_ARG_NONNULL ((2)));
  1065. _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
  1066. # else
  1067. # if !@HAVE_VDPRINTF@
  1068. _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
  1069. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1070. _GL_ARG_NONNULL ((2)));
  1071. # endif
  1072. /* Need to cast, because on Solaris, the third parameter will likely be
  1073. __va_list args. */
  1074. _GL_CXXALIAS_SYS_CAST (vdprintf, int,
  1075. (int fd, const char *format, va_list args));
  1076. # endif
  1077. _GL_CXXALIASWARN (vdprintf);
  1078. #elif defined GNULIB_POSIXCHECK
  1079. # undef vdprintf
  1080. # if HAVE_RAW_DECL_VDPRINTF
  1081. _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
  1082. "use gnulib module vdprintf for portability");
  1083. # endif
  1084. #endif
  1085. #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
  1086. # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
  1087. || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  1088. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1089. # define vfprintf rpl_vfprintf
  1090. # endif
  1091. # define GNULIB_overrides_vfprintf 1
  1092. # if @GNULIB_VFPRINTF_POSIX@
  1093. _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
  1094. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1095. _GL_ARG_NONNULL ((1, 2)));
  1096. # else
  1097. _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
  1098. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
  1099. _GL_ARG_NONNULL ((1, 2)));
  1100. # endif
  1101. _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
  1102. # else
  1103. /* Need to cast, because on Solaris, the third parameter is
  1104. __va_list args
  1105. and GCC's fixincludes did not change this to __gnuc_va_list. */
  1106. _GL_CXXALIAS_SYS_CAST (vfprintf, int,
  1107. (FILE *fp, const char *format, va_list args));
  1108. # endif
  1109. _GL_CXXALIASWARN (vfprintf);
  1110. #endif
  1111. #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  1112. # if !GNULIB_overrides_vfprintf
  1113. # undef vfprintf
  1114. # endif
  1115. /* Assume vfprintf is always declared. */
  1116. _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
  1117. "use gnulib module vfprintf-posix for portable "
  1118. "POSIX compliance");
  1119. #endif
  1120. #if @GNULIB_VFSCANF@
  1121. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  1122. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1123. # undef vfscanf
  1124. # define vfscanf rpl_vfscanf
  1125. # endif
  1126. _GL_FUNCDECL_RPL (vfscanf, int,
  1127. (FILE *stream, const char *format, va_list args)
  1128. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
  1129. _GL_ARG_NONNULL ((1, 2)));
  1130. _GL_CXXALIAS_RPL (vfscanf, int,
  1131. (FILE *stream, const char *format, va_list args));
  1132. # else
  1133. _GL_CXXALIAS_SYS (vfscanf, int,
  1134. (FILE *stream, const char *format, va_list args));
  1135. # endif
  1136. _GL_CXXALIASWARN (vfscanf);
  1137. #endif
  1138. #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
  1139. # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
  1140. || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
  1141. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1142. # define vprintf rpl_vprintf
  1143. # endif
  1144. # define GNULIB_overrides_vprintf 1
  1145. # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
  1146. _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
  1147. _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
  1148. _GL_ARG_NONNULL ((1)));
  1149. # else
  1150. _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
  1151. _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
  1152. _GL_ARG_NONNULL ((1)));
  1153. # endif
  1154. _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
  1155. # else
  1156. /* Need to cast, because on Solaris, the second parameter is
  1157. __va_list args
  1158. and GCC's fixincludes did not change this to __gnuc_va_list. */
  1159. _GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args));
  1160. # endif
  1161. _GL_CXXALIASWARN (vprintf);
  1162. #endif
  1163. #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
  1164. # if !GNULIB_overrides_vprintf
  1165. # undef vprintf
  1166. # endif
  1167. /* Assume vprintf is always declared. */
  1168. _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
  1169. "use gnulib module vprintf-posix for portable "
  1170. "POSIX compliance");
  1171. #endif
  1172. #if @GNULIB_VSCANF@
  1173. # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
  1174. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1175. # undef vscanf
  1176. # define vscanf rpl_vscanf
  1177. # endif
  1178. _GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args)
  1179. _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
  1180. _GL_ARG_NONNULL ((1)));
  1181. _GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args));
  1182. # else
  1183. _GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args));
  1184. # endif
  1185. _GL_CXXALIASWARN (vscanf);
  1186. #endif
  1187. #if @GNULIB_VSNPRINTF@
  1188. # if @REPLACE_VSNPRINTF@
  1189. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1190. # define vsnprintf rpl_vsnprintf
  1191. # endif
  1192. _GL_FUNCDECL_RPL (vsnprintf, int,
  1193. (char *str, size_t size, const char *format, va_list args)
  1194. _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
  1195. _GL_ARG_NONNULL ((3)));
  1196. _GL_CXXALIAS_RPL (vsnprintf, int,
  1197. (char *str, size_t size, const char *format, va_list args));
  1198. # else
  1199. # if !@HAVE_DECL_VSNPRINTF@
  1200. _GL_FUNCDECL_SYS (vsnprintf, int,
  1201. (char *str, size_t size, const char *format, va_list args)
  1202. _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
  1203. _GL_ARG_NONNULL ((3)));
  1204. # endif
  1205. _GL_CXXALIAS_SYS (vsnprintf, int,
  1206. (char *str, size_t size, const char *format, va_list args));
  1207. # endif
  1208. _GL_CXXALIASWARN (vsnprintf);
  1209. #elif defined GNULIB_POSIXCHECK
  1210. # undef vsnprintf
  1211. # if HAVE_RAW_DECL_VSNPRINTF
  1212. _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
  1213. "use gnulib module vsnprintf for portability");
  1214. # endif
  1215. #endif
  1216. #if @GNULIB_VSPRINTF_POSIX@
  1217. # if @REPLACE_VSPRINTF@
  1218. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1219. # define vsprintf rpl_vsprintf
  1220. # endif
  1221. _GL_FUNCDECL_RPL (vsprintf, int,
  1222. (char *str, const char *format, va_list args)
  1223. _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
  1224. _GL_ARG_NONNULL ((1, 2)));
  1225. _GL_CXXALIAS_RPL (vsprintf, int,
  1226. (char *str, const char *format, va_list args));
  1227. # else
  1228. /* Need to cast, because on Solaris, the third parameter is
  1229. __va_list args
  1230. and GCC's fixincludes did not change this to __gnuc_va_list. */
  1231. _GL_CXXALIAS_SYS_CAST (vsprintf, int,
  1232. (char *str, const char *format, va_list args));
  1233. # endif
  1234. _GL_CXXALIASWARN (vsprintf);
  1235. #elif defined GNULIB_POSIXCHECK
  1236. # undef vsprintf
  1237. /* Assume vsprintf is always declared. */
  1238. _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
  1239. "use gnulib module vsprintf-posix for portable "
  1240. "POSIX compliance");
  1241. #endif
  1242. #endif /* _@GUARD_PREFIX@_STDIO_H */
  1243. #endif /* _@GUARD_PREFIX@_STDIO_H */
  1244. #endif