stdio.in.h 49 KB

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