PageRenderTime 35ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/gnutls/gnutls-2.2.0/lgl/stdio.in.h

https://bitbucket.org/thelearninglabs/uclinux-distro-tll-public
C Header | 382 lines | 297 code | 34 blank | 51 comment | 46 complexity | 0ce8a3d49ea0ca918b3ae29439f5ed08 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0, Unlicense, GPL-2.0, GPL-3.0, CC-BY-SA-3.0, AGPL-1.0, ISC, MIT, 0BSD, LGPL-2.0
  1. /* A GNU-like <stdio.h>.
  2. Copyright (C) 2004, 2007 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software Foundation,
  13. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  14. #if defined __need_FILE || defined __need___FILE
  15. /* Special invocation convention inside glibc header files. */
  16. #@INCLUDE_NEXT@ @NEXT_STDIO_H@
  17. #else
  18. /* Normal invocation convention. */
  19. #ifndef _GL_STDIO_H
  20. /* The include_next requires a split double-inclusion guard. */
  21. #@INCLUDE_NEXT@ @NEXT_STDIO_H@
  22. #ifndef _GL_STDIO_H
  23. #define _GL_STDIO_H
  24. #include <stdarg.h>
  25. #include <stddef.h>
  26. #if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \
  27. || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \
  28. || (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \
  29. || (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@))
  30. /* Get off_t and ssize_t. */
  31. # include <sys/types.h>
  32. #endif
  33. #ifndef __attribute__
  34. /* This feature is available in gcc versions 2.5 and later. */
  35. # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
  36. # define __attribute__(Spec) /* empty */
  37. # endif
  38. /* The __-protected variants of `format' and `printf' attributes
  39. are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
  40. # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
  41. # define __format__ format
  42. # define __printf__ printf
  43. # endif
  44. #endif
  45. /* The definition of GL_LINK_WARNING is copied here. */
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. #if @GNULIB_FPRINTF_POSIX@
  50. # if @REPLACE_FPRINTF@
  51. # define fprintf rpl_fprintf
  52. extern int fprintf (FILE *fp, const char *format, ...)
  53. __attribute__ ((__format__ (__printf__, 2, 3)));
  54. # endif
  55. #elif defined GNULIB_POSIXCHECK
  56. # undef fprintf
  57. # define fprintf \
  58. (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
  59. "use gnulib module fprintf-posix for portable " \
  60. "POSIX compliance"), \
  61. fprintf)
  62. #endif
  63. #if @GNULIB_VFPRINTF_POSIX@
  64. # if @REPLACE_VFPRINTF@
  65. # define vfprintf rpl_vfprintf
  66. extern int vfprintf (FILE *fp, const char *format, va_list args)
  67. __attribute__ ((__format__ (__printf__, 2, 0)));
  68. # endif
  69. #elif defined GNULIB_POSIXCHECK
  70. # undef vfprintf
  71. # define vfprintf(s,f,a) \
  72. (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
  73. "use gnulib module vfprintf-posix for portable " \
  74. "POSIX compliance"), \
  75. vfprintf (s, f, a))
  76. #endif
  77. #if @GNULIB_PRINTF_POSIX@
  78. # if @REPLACE_PRINTF@
  79. /* Don't break __attribute__((format(printf,M,N))). */
  80. # define printf __printf__
  81. extern int printf (const char *format, ...)
  82. __attribute__ ((__format__ (__printf__, 1, 2)));
  83. # endif
  84. #elif defined GNULIB_POSIXCHECK
  85. # undef printf
  86. # define printf \
  87. (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
  88. "use gnulib module printf-posix for portable " \
  89. "POSIX compliance"), \
  90. printf)
  91. /* Don't break __attribute__((format(printf,M,N))). */
  92. # define format(kind,m,n) format (__##kind##__, m, n)
  93. # define __format__(kind,m,n) __format__ (__##kind##__, m, n)
  94. # define ____printf____ __printf__
  95. # define ____scanf____ __scanf__
  96. # define ____strftime____ __strftime__
  97. # define ____strfmon____ __strfmon__
  98. #endif
  99. #if @GNULIB_VPRINTF_POSIX@
  100. # if @REPLACE_VPRINTF@
  101. # define vprintf rpl_vprintf
  102. extern int vprintf (const char *format, va_list args)
  103. __attribute__ ((__format__ (__printf__, 1, 0)));
  104. # endif
  105. #elif defined GNULIB_POSIXCHECK
  106. # undef vprintf
  107. # define vprintf(f,a) \
  108. (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
  109. "use gnulib module vprintf-posix for portable " \
  110. "POSIX compliance"), \
  111. vprintf (f, a))
  112. #endif
  113. #if @GNULIB_SNPRINTF@
  114. # if @REPLACE_SNPRINTF@
  115. # define snprintf rpl_snprintf
  116. # endif
  117. # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
  118. extern int snprintf (char *str, size_t size, const char *format, ...)
  119. __attribute__ ((__format__ (__printf__, 3, 4)));
  120. # endif
  121. #elif defined GNULIB_POSIXCHECK
  122. # undef snprintf
  123. # define snprintf \
  124. (GL_LINK_WARNING ("snprintf is unportable - " \
  125. "use gnulib module snprintf for portability"), \
  126. snprintf)
  127. #endif
  128. #if @GNULIB_VSNPRINTF@
  129. # if @REPLACE_VSNPRINTF@
  130. # define vsnprintf rpl_vsnprintf
  131. # endif
  132. # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
  133. extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
  134. __attribute__ ((__format__ (__printf__, 3, 0)));
  135. # endif
  136. #elif defined GNULIB_POSIXCHECK
  137. # undef vsnprintf
  138. # define vsnprintf(b,s,f,a) \
  139. (GL_LINK_WARNING ("vsnprintf is unportable - " \
  140. "use gnulib module vsnprintf for portability"), \
  141. vsnprintf (b, s, f, a))
  142. #endif
  143. #if @GNULIB_SPRINTF_POSIX@
  144. # if @REPLACE_SPRINTF@
  145. # define sprintf rpl_sprintf
  146. extern int sprintf (char *str, const char *format, ...)
  147. __attribute__ ((__format__ (__printf__, 2, 3)));
  148. # endif
  149. #elif defined GNULIB_POSIXCHECK
  150. # undef sprintf
  151. # define sprintf \
  152. (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
  153. "use gnulib module sprintf-posix for portable " \
  154. "POSIX compliance"), \
  155. sprintf)
  156. #endif
  157. #if @GNULIB_VSPRINTF_POSIX@
  158. # if @REPLACE_VSPRINTF@
  159. # define vsprintf rpl_vsprintf
  160. extern int vsprintf (char *str, const char *format, va_list args)
  161. __attribute__ ((__format__ (__printf__, 2, 0)));
  162. # endif
  163. #elif defined GNULIB_POSIXCHECK
  164. # undef vsprintf
  165. # define vsprintf(b,f,a) \
  166. (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
  167. "use gnulib module vsprintf-posix for portable " \
  168. "POSIX compliance"), \
  169. vsprintf (b, f, a))
  170. #endif
  171. #if @GNULIB_VASPRINTF@
  172. # if @REPLACE_VASPRINTF@
  173. # define asprintf rpl_asprintf
  174. # define vasprintf rpl_vasprintf
  175. # endif
  176. # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
  177. /* Write formatted output to a string dynamically allocated with malloc().
  178. If the memory allocation succeeds, store the address of the string in
  179. *RESULT and return the number of resulting bytes, excluding the trailing
  180. NUL. Upon memory allocation error, or some other error, return -1. */
  181. extern int asprintf (char **result, const char *format, ...)
  182. __attribute__ ((__format__ (__printf__, 2, 3)));
  183. extern int vasprintf (char **result, const char *format, va_list args)
  184. __attribute__ ((__format__ (__printf__, 2, 0)));
  185. # endif
  186. #endif
  187. #if @GNULIB_FOPEN@
  188. # if @REPLACE_FOPEN@
  189. # define fopen rpl_fopen
  190. extern FILE * fopen (const char *filename, const char *mode);
  191. # endif
  192. #elif defined GNULIB_POSIXCHECK
  193. # undef fopen
  194. # define fopen(f,m) \
  195. (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \
  196. "use gnulib module fopen for portability"), \
  197. fopen (f, m))
  198. #endif
  199. #if @GNULIB_FREOPEN@
  200. # if @REPLACE_FREOPEN@
  201. # define freopen rpl_freopen
  202. extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
  203. # endif
  204. #elif defined GNULIB_POSIXCHECK
  205. # undef freopen
  206. # define freopen(f,m,s) \
  207. (GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \
  208. "use gnulib module freopen for portability"), \
  209. freopen (f, m, s))
  210. #endif
  211. #if @GNULIB_FSEEKO@
  212. # if @REPLACE_FSEEKO@
  213. /* Provide fseek, fseeko functions that are aware of a preceding
  214. fflush(), and which detect pipes. */
  215. # define fseeko rpl_fseeko
  216. extern int fseeko (FILE *fp, off_t offset, int whence);
  217. # define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
  218. # endif
  219. #elif defined GNULIB_POSIXCHECK
  220. # undef fseeko
  221. # define fseeko(f,o,w) \
  222. (GL_LINK_WARNING ("fseeko is unportable - " \
  223. "use gnulib module fseeko for portability"), \
  224. fseeko (f, o, w))
  225. #endif
  226. #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
  227. extern int rpl_fseek (FILE *fp, long offset, int whence);
  228. # undef fseek
  229. # if defined GNULIB_POSIXCHECK
  230. # define fseek(f,o,w) \
  231. (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
  232. "on 32-bit platforms - " \
  233. "use fseeko function for handling of large files"), \
  234. rpl_fseek (f, o, w))
  235. # else
  236. # define fseek rpl_fseek
  237. # endif
  238. #elif defined GNULIB_POSIXCHECK
  239. # ifndef fseek
  240. # define fseek(f,o,w) \
  241. (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
  242. "on 32-bit platforms - " \
  243. "use fseeko function for handling of large files"), \
  244. fseek (f, o, w))
  245. # endif
  246. #endif
  247. #if @GNULIB_FTELLO@
  248. # if @REPLACE_FTELLO@
  249. # define ftello rpl_ftello
  250. extern off_t ftello (FILE *fp);
  251. # define ftell(fp) ftello (fp)
  252. # endif
  253. #elif defined GNULIB_POSIXCHECK
  254. # undef ftello
  255. # define ftello(f) \
  256. (GL_LINK_WARNING ("ftello is unportable - " \
  257. "use gnulib module ftello for portability"), \
  258. ftello (f))
  259. #endif
  260. #if @GNULIB_FTELL@ && @REPLACE_FTELL@
  261. extern long rpl_ftell (FILE *fp);
  262. # undef ftell
  263. # if GNULIB_POSIXCHECK
  264. # define ftell(f) \
  265. (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
  266. "on 32-bit platforms - " \
  267. "use ftello function for handling of large files"), \
  268. rpl_ftell (f))
  269. # else
  270. # define ftell rpl_ftell
  271. # endif
  272. #elif defined GNULIB_POSIXCHECK
  273. # ifndef ftell
  274. # define ftell(f) \
  275. (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
  276. "on 32-bit platforms - " \
  277. "use ftello function for handling of large files"), \
  278. ftell (f))
  279. # endif
  280. #endif
  281. #if @GNULIB_FFLUSH@
  282. # if @REPLACE_FFLUSH@
  283. # define fflush rpl_fflush
  284. /* Flush all pending data on STREAM according to POSIX rules. Both
  285. output and seekable input streams are supported.
  286. Note! LOSS OF DATA can occur if fflush is applied on an input stream
  287. that is _not_seekable_ or on an update stream that is _not_seekable_
  288. and in which the most recent operation was input. Seekability can
  289. be tested with lseek(fileno(fp),0,SEEK_CUR). */
  290. extern int fflush (FILE *gl_stream);
  291. # endif
  292. #elif defined GNULIB_POSIXCHECK
  293. # undef fflush
  294. # define fflush(f) \
  295. (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
  296. "use gnulib module fflush for portable " \
  297. "POSIX compliance"), \
  298. fflush (f))
  299. #endif
  300. #if @GNULIB_GETDELIM@
  301. # if !@HAVE_DECL_GETDELIM@
  302. /* Read input, up to (and including) the next occurrence of DELIMITER, from
  303. STREAM, store it in *LINEPTR (and NUL-terminate it).
  304. *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
  305. bytes of space. It is realloc'd as necessary.
  306. Return the number of bytes read and stored at *LINEPTR (not including the
  307. NUL terminator), or -1 on error or EOF. */
  308. extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
  309. FILE *stream);
  310. # endif
  311. #elif defined GNULIB_POSIXCHECK
  312. # undef getdelim
  313. # define getdelim(l, s, d, f) \
  314. (GL_LINK_WARNING ("getdelim is unportable - " \
  315. "use gnulib module getdelim for portability"), \
  316. getdelim (l, s, d, f))
  317. #endif
  318. #if @GNULIB_GETLINE@
  319. # if @REPLACE_GETLINE@
  320. # undef getline
  321. # define getline rpl_getline
  322. # endif
  323. # if !@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@
  324. /* Read a line, up to (and including) the next newline, from STREAM, store it
  325. in *LINEPTR (and NUL-terminate it).
  326. *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
  327. bytes of space. It is realloc'd as necessary.
  328. Return the number of bytes read and stored at *LINEPTR (not including the
  329. NUL terminator), or -1 on error or EOF. */
  330. extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
  331. # endif
  332. #elif defined GNULIB_POSIXCHECK
  333. # undef getline
  334. # define getline(l, s, f) \
  335. (GL_LINK_WARNING ("getline is unportable - " \
  336. "use gnulib module getline for portability"), \
  337. getline (l, s, f))
  338. #endif
  339. #ifdef __cplusplus
  340. }
  341. #endif
  342. #endif /* _GL_STDIO_H */
  343. #endif /* _GL_STDIO_H */
  344. #endif