stdio.in.h 48 KB

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