0001: /* Define ISO C stdio on top of C++ iostreams.
0002: Copyright (C) 1991, 1994-2010, 2011 Free Software Foundation, Inc.
0003: This file is part of the GNU C Library.
0004:
0005: The GNU C Library is free software; you can redistribute it and/or
0006: modify it under the terms of the GNU Lesser General Public
0007: License as published by the Free Software Foundation; either
0008: version 2.1 of the License, or (at your option) any later version.
0009:
0010: The GNU C Library is distributed in the hope that it will be useful,
0011: but WITHOUT ANY WARRANTY; without even the implied warranty of
0012: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0013: Lesser General Public License for more details.
0014:
0015: You should have received a copy of the GNU Lesser General Public
0016: License along with the GNU C Library; if not, write to the Free
0017: Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
0018: 02111-1307 USA. */
0019:
0020: /*
0021: * ISO C99 Standard: 7.19 Input/output <stdio.h>
0022: */
0023:
0024: #ifndef _STDIO_H
0025:
0026: #if !defined __need_FILE && !defined __need___FILE
0027: # define _STDIO_H 1
0028: # include <features.h>
0029:
0030: __BEGIN_DECLS
0031:
0032: # define __need_size_t
0033: # define __need_NULL
0034: # include <stddef.h>
0035:
0036: # include <bits/types.h>
0037: # define __need_FILE
0038: # define __need___FILE
0039: #endif /* Don't need FILE. */
0040:
0041:
0042: #if !defined __FILE_defined && defined __need_FILE
0043:
0044: /* Define outside of namespace so the C++ is happy. */
0045: struct _IO_FILE;
0046:
0047: __BEGIN_NAMESPACE_STD
0048: /* The opaque type of streams. This is the definition used elsewhere. */
0049: typedef struct _IO_FILE FILE;
0050: __END_NAMESPACE_STD
0051: #if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
0052: || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
0053: || defined __USE_POSIX2
0054: __USING_NAMESPACE_STD(FILE)
0055: #endif
0056:
0057: # define __FILE_defined 1
0058: #endif /* FILE not defined. */
0059: #undef __need_FILE
0060:
0061:
0062: #if !defined ____FILE_defined && defined __need___FILE
0063:
0064: /* The opaque type of streams. This is the definition used elsewhere. */
0065: typedef struct _IO_FILE __FILE;
0066:
0067: # define ____FILE_defined 1
0068: #endif /* __FILE not defined. */
0069: #undef __need___FILE
0070:
0071:
0072: #ifdef _STDIO_H
0073: #define _STDIO_USES_IOSTREAM
0074:
0075: #include <libio.h>
0076:
0077: #if defined __USE_XOPEN || defined __USE_XOPEN2K8
0078: # ifdef __GNUC__
0079: # ifndef _VA_LIST_DEFINED
0080: typedef _G_va_list va_list;
0081: # define _VA_LIST_DEFINED
0082: # endif
0083: # else
0084: # include <stdarg.h>
0085: # endif
0086: #endif
0087:
0088: #ifdef __USE_XOPEN2K8
0089: # ifndef __off_t_defined
0090: # ifndef __USE_FILE_OFFSET64
0091: typedef __off_t off_t;
0092: # else
0093: typedef __off64_t off_t;
0094: # endif
0095: # define __off_t_defined
0096: # endif
0097: # if defined __USE_LARGEFILE64 && !defined __off64_t_defined
0098: typedef __off64_t off64_t;
0099: # define __off64_t_defined
0100: # endif
0101:
0102: # ifndef __ssize_t_defined
0103: typedef __ssize_t ssize_t;
0104: # define __ssize_t_defined
0105: # endif
0106: #endif
0107:
0108: /* The type of the second argument to `fgetpos' and `fsetpos'. */
0109: __BEGIN_NAMESPACE_STD
0110: #ifndef __USE_FILE_OFFSET64
0111: typedef _G_fpos_t fpos_t;
0112: #else
0113: typedef _G_fpos64_t fpos_t;
0114: #endif
0115: __END_NAMESPACE_STD
0116: #ifdef __USE_LARGEFILE64
0117: typedef _G_fpos64_t fpos64_t;
0118: #endif
0119:
0120: /* The possibilities for the third argument to `setvbuf'. */
0121: #define _IOFBF 0 /* Fully buffered. */
0122: #define _IOLBF 1 /* Line buffered. */
0123: #define _IONBF 2 /* No buffering. */
0124:
0125:
0126: /* Default buffer size. */
0127: #ifndef BUFSIZ
0128: # define BUFSIZ _IO_BUFSIZ
0129: #endif
0130:
0131:
0132: /* End of file character.
0133: Some things throughout the library rely on this being -1. */
0134: #ifndef EOF
0135: # define EOF (-1)
0136: #endif
0137:
0138:
0139: /* The possibilities for the third argument to `fseek'.
0140: These values should not be changed. */
0141: #define SEEK_SET 0 /* Seek from beginning of file. */
0142: #define SEEK_CUR 1 /* Seek from current position. */
0143: #define SEEK_END 2 /* Seek from end of file. */
0144: #ifdef __USE_GNU
0145: # define SEEK_DATA 3 /* Seek to next data. */
0146: # define SEEK_HOLE 4 /* Seek to next hole. */
0147: #endif
0148:
0149:
0150: #if defined __USE_SVID || defined __USE_XOPEN
0151: /* Default path prefix for `tempnam' and `tmpnam'. */
0152: # define P_tmpdir "/tmp"
0153: #endif
0154:
0155:
0156: /* Get the values:
0157: L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
0158: TMP_MAX The minimum number of unique filenames generated by tmpnam
0159: (and tempnam when it uses tmpnam's name space),
0160: or tempnam (the two are separate).
0161: L_ctermid How long an array to pass to `ctermid'.
0162: L_cuserid How long an array to pass to `cuserid'.
0163: FOPEN_MAX Minimum number of files that can be open at once.
0164: FILENAME_MAX Maximum length of a filename. */
0165: #include <bits/stdio_lim.h>
0166:
0167:
0168: /* Standard streams. */
0169: extern struct _IO_FILE *stdin; /* Standard input stream. */
0170: extern struct _IO_FILE *stdout; /* Standard output stream. */
0171: extern struct _IO_FILE *stderr; /* Standard error output stream. */
0172: /* C89/C99 say they're macros. Make them happy. */
0173: #define stdin stdin
0174: #define stdout stdout
0175: #define stderr stderr
0176:
0177: __BEGIN_NAMESPACE_STD
0178: /* Remove file FILENAME. */
0179: extern int remove (__const char *__filename) __THROW;
0180: /* Rename file OLD to NEW. */
0181: extern int rename (__const char *__old, __const char *__new) __THROW;
0182: __END_NAMESPACE_STD
0183:
0184: #ifdef __USE_ATFILE
0185: /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
0186: extern int renameat (int __oldfd, __const char *__old, int __newfd,
0187: __const char *__new) __THROW;
0188: #endif
0189:
0190: __BEGIN_NAMESPACE_STD
0191: /* Create a temporary file and open it read/write.
0192:
0193: This function is a possible cancellation point and therefore not
0194: marked with __THROW. */
0195: #ifndef __USE_FILE_OFFSET64
0196: extern FILE *tmpfile (void) __wur;
0197: #else
0198: # ifdef __REDIRECT
0199: extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
0200: # else
0201: # define tmpfile tmpfile64
0202: # endif
0203: #endif
0204:
0205: #ifdef __USE_LARGEFILE64
0206: extern FILE *tmpfile64 (void) __wur;
0207: #endif
0208:
0209: /* Generate a temporary filename. */
0210: extern char *tmpnam (char *__s) __THROW __wur;
0211: __END_NAMESPACE_STD
0212:
0213: #ifdef __USE_MISC
0214: /* This is the reentrant variant of `tmpnam'. The only difference is
0215: that it does not allow S to be NULL. */
0216: extern char *tmpnam_r (char *__s) __THROW __wur;
0217: #endif
0218:
0219:
0220: #if defined __USE_SVID || defined __USE_XOPEN
0221: /* Generate a unique temporary filename using up to five characters of PFX
0222: if it is not NULL. The directory to put this file in is searched for
0223: as follows: First the environment variable "TMPDIR" is checked.
0224: If it contains the name of a writable directory, that directory is used.
0225: If not and if DIR is not NULL, that value is checked. If that fails,
0226: P_tmpdir is tried and finally "/tmp". The storage for the filename
0227: is allocated by `malloc'. */
0228: extern char *tempnam (__const char *__dir, __const char *__pfx)
0229: __THROW __attribute_malloc__ __wur;
0230: #endif
0231:
0232:
0233: __BEGIN_NAMESPACE_STD
0234: /* Close STREAM.
0235:
0236: This function is a possible cancellation point and therefore not
0237: marked with __THROW. */
0238: extern int fclose (FILE *__stream);
0239: /* Flush STREAM, or all streams if STREAM is NULL.
0240:
0241: This function is a possible cancellation point and therefore not
0242: marked with __THROW. */
0243: extern int fflush (FILE *__stream);
0244: __END_NAMESPACE_STD
0245:
0246: #ifdef __USE_MISC
0247: /* Faster versions when locking is not required.
0248:
0249: This function is not part of POSIX and therefore no official
0250: cancellation point. But due to similarity with an POSIX interface
0251: or due to the implementation it is a cancellation point and
0252: therefore not marked with __THROW. */
0253: extern int fflush_unlocked (FILE *__stream);
0254: #endif
0255:
0256: #ifdef __USE_GNU
0257: /* Close all streams.
0258:
0259: This function is not part of POSIX and therefore no official
0260: cancellation point. But due to similarity with an POSIX interface
0261: or due to the implementation it is a cancellation point and
0262: therefore not marked with __THROW. */
0263: extern int fcloseall (void);
0264: #endif
0265:
0266:
0267: __BEGIN_NAMESPACE_STD
0268: #ifndef __USE_FILE_OFFSET64
0269: /* Open a file and create a new stream for it.
0270:
0271: This function is a possible cancellation point and therefore not
0272: marked with __THROW. */
0273: extern FILE *fopen (__const char *__restrict __filename,
0274: __const char *__restrict __modes) __wur;
0275: /* Open a file, replacing an existing stream with it.
0276:
0277: This function is a possible cancellation point and therefore not
0278: marked with __THROW. */
0279: extern FILE *freopen (__const char *__restrict __filename,
0280: __const char *__restrict __modes,
0281: FILE *__restrict __stream) __wur;
0282: #else
0283: # ifdef __REDIRECT
0284: extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
0285: __const char *__restrict __modes), fopen64)
0286: __wur;
0287: extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
0288: __const char *__restrict __modes,
0289: FILE *__restrict __stream), freopen64)
0290: __wur;
0291: # else
0292: # define fopen fopen64
0293: # define freopen freopen64
0294: # endif
0295: #endif
0296: __END_NAMESPACE_STD
0297: #ifdef __USE_LARGEFILE64
0298: extern FILE *fopen64 (__const char *__restrict __filename,
0299: __const char *__restrict __modes) __wur;
0300: extern FILE *freopen64 (__const char *__restrict __filename,
0301: __const char *__restrict __modes,
0302: FILE *__restrict __stream) __wur;
0303: #endif
0304:
0305: #ifdef __USE_POSIX
0306: /* Create a new stream that refers to an existing system file descriptor. */
0307: extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;
0308: #endif
0309:
0310: #ifdef __USE_GNU
0311: /* Create a new stream that refers to the given magic cookie,
0312: and uses the given functions for input and output. */
0313: extern FILE *fopencookie (void *__restrict __magic_cookie,
0314: __const char *__restrict __modes,
0315: _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
0316: #endif
0317:
0318: #ifdef __USE_XOPEN2K8
0319: /* Create a new stream that refers to a memory buffer. */
0320: extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
0321: __THROW __wur;
0322:
0323: /* Open a stream that writes into a malloc'd buffer that is expanded as
0324: necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
0325: and the number of characters written on fflush or fclose. */
0326: extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
0327: #endif
0328:
0329:
0330: __BEGIN_NAMESPACE_STD
0331: /* If BUF is NULL, make STREAM unbuffered.
0332: Else make it use buffer BUF, of size BUFSIZ. */
0333: extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
0334: /* Make STREAM use buffering mode MODE.
0335: If BUF is not NULL, use N bytes of it for buffering;
0336: else allocate an internal buffer N bytes long. */
0337: extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
0338: int __modes, size_t __n) __THROW;
0339: __END_NAMESPACE_STD
0340:
0341: #ifdef __USE_BSD
0342: /* If BUF is NULL, make STREAM unbuffered.
0343: Else make it use SIZE bytes of BUF for buffering. */
0344: extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
0345: size_t __size) __THROW;
0346:
0347: /* Make STREAM line-buffered. */
0348: extern void setlinebuf (FILE *__stream) __THROW;
0349: #endif
0350:
0351:
0352: __BEGIN_NAMESPACE_STD
0353: /* Write formatted output to STREAM.
0354:
0355: This function is a possible cancellation point and therefore not
0356: marked with __THROW. */
0357: extern int fprintf (FILE *__restrict __stream,
0358: __const char *__restrict __format, ...);
0359: /* Write formatted output to stdout.
0360:
0361: This function is a possible cancellation point and therefore not
0362: marked with __THROW. */
0363: extern int printf (__const char *__restrict __format, ...);
0364: /* Write formatted output to S. */
0365: extern int sprintf (char *__restrict __s,
0366: __const char *__restrict __format, ...) __THROWNL;
0367:
0368: /* Write formatted output to S from argument list ARG.
0369:
0370: This function is a possible cancellation point and therefore not
0371: marked with __THROW. */
0372: extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
0373: _G_va_list __arg);
0374: /* Write formatted output to stdout from argument list ARG.
0375:
0376: This function is a possible cancellation point and therefore not
0377: marked with __THROW. */
0378: extern int vprintf (__const char *__restrict __format, _G_va_list __arg);
0379: /* Write formatted output to S from argument list ARG. */
0380: extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
0381: _G_va_list __arg) __THROWNL;
0382: __END_NAMESPACE_STD
0383:
0384: #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
0385: __BEGIN_NAMESPACE_C99
0386: /* Maximum chars of output to write in MAXLEN. */
0387: extern int snprintf (char *__restrict __s, size_t __maxlen,
0388: __const char *__restrict __format, ...)
0389: __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
0390:
0391: extern int vsnprintf (char *__restrict __s, size_t __maxlen,
0392: __const char *__restrict __format, _G_va_list __arg)
0393: __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
0394: __END_NAMESPACE_C99
0395: #endif
0396:
0397: #ifdef __USE_GNU
0398: /* Write formatted output to a string dynamically allocated with `malloc'.
0399: Store the address of the string in *PTR. */
0400: extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
0401: _G_va_list __arg)
0402: __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
0403: extern int __asprintf (char **__restrict __ptr,
0404: __const char *__restrict __fmt, ...)
0405: __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
0406: extern int asprintf (char **__restrict __ptr,
0407: __const char *__restrict __fmt, ...)
0408: __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
0409: #endif
0410:
0411: #ifdef __USE_XOPEN2K8
0412: /* Write formatted output to a file descriptor.
0413:
0414: These functions are not part of POSIX and therefore no official
0415: cancellation point. But due to similarity with an POSIX interface
0416: or due to the implementation they are cancellation points and
0417: therefore not marked with __THROW. */
0418: extern int vdprintf (int __fd, __const char *__restrict __fmt,
0419: _G_va_list __arg)
0420: __attribute__ ((__format__ (__printf__, 2, 0)));
0421: extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
0422: __attribute__ ((__format__ (__printf__, 2, 3)));
0423: #endif
0424:
0425:
0426: __BEGIN_NAMESPACE_STD
0427: /* Read formatted input from STREAM.
0428:
0429: This function is a possible cancellation point and therefore not
0430: marked with __THROW. */
0431: extern int fscanf (FILE *__restrict __stream,
0432: __const char *__restrict __format, ...) __wur;
0433: /* Read formatted input from stdin.
0434:
0435: This function is a possible cancellation point and therefore not
0436: marked with __THROW. */
0437: extern int scanf (__const char *__restrict __format, ...) __wur;
0438: /* Read formatted input from S. */
0439: extern int sscanf (__const char *__restrict __s,
0440: __const char *__restrict __format, ...) __THROW;
0441:
0442: #if defined __USE_ISOC99 && !defined __USE_GNU \
0443: && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
0444: && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
0445: # ifdef __REDIRECT
0446: /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
0447: GNU extension which conflicts with valid %a followed by letter
0448: s, S or [. */
0449: extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
0450: __const char *__restrict __format, ...),
0451: __isoc99_fscanf) __wur;
0452: extern int __REDIRECT (scanf, (__const char *__restrict __format, ...),
0453: __isoc99_scanf) __wur;
0454: extern int __REDIRECT_NTH (sscanf, (__const char *__restrict __s,
0455: __const char *__restrict __format, ...),
0456: __isoc99_sscanf);
0457: # else
0458: extern int __isoc99_fscanf (FILE *__restrict __stream,
0459: __const char *__restrict __format, ...) __wur;
0460: extern int __isoc99_scanf (__const char *__restrict __format, ...) __wur;
0461: extern int __isoc99_sscanf (__const char *__restrict __s,
0462: __const char *__restrict __format, ...) __THROW;
0463: # define fscanf __isoc99_fscanf
0464: # define scanf __isoc99_scanf
0465: # define sscanf __isoc99_sscanf
0466: # endif
0467: #endif
0468:
0469: __END_NAMESPACE_STD
0470:
0471: #ifdef __USE_ISOC99
0472: __BEGIN_NAMESPACE_C99
0473: /* Read formatted input from S into argument list ARG.
0474:
0475: This function is a possible cancellation point and therefore not
0476: marked with __THROW. */
0477: extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
0478: _G_va_list __arg)
0479: __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
0480:
0481: /* Read formatted input from stdin into argument list ARG.
0482:
0483: This function is a possible cancellation point and therefore not
0484: marked with __THROW. */
0485: extern int vscanf (__const char *__restrict __format, _G_va_list __arg)
0486: __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
0487:
0488: /* Read formatted input from S into argument list ARG. */
0489: extern int vsscanf (__const char *__restrict __s,
0490: __const char *__restrict __format, _G_va_list __arg)
0491: __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
0492:
0493: # if !defined __USE_GNU \
0494: && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
0495: && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
0496: # ifdef __REDIRECT
0497: /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
0498: GNU extension which conflicts with valid %a followed by letter
0499: s, S or [. */
0500: extern int __REDIRECT (vfscanf,
0501: (FILE *__restrict __s,
0502: __const char *__restrict __format, _G_va_list __arg),
0503: __isoc99_vfscanf)
0504: __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
0505: extern int __REDIRECT (vscanf, (__const char *__restrict __format,
0506: _G_va_list __arg), __isoc99_vscanf)
0507: __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
0508: extern int __REDIRECT_NTH (vsscanf,
0509: (__const char *__restrict __s,
0510: __const char *__restrict __format,
0511: _G_va_list __arg), __isoc99_vsscanf)
0512: __attribute__ ((__format__ (__scanf__, 2, 0)));
0513: # else
0514: extern int __isoc99_vfscanf (FILE *__restrict __s,
0515: __const char *__restrict __format,
0516: _G_va_list __arg) __wur;
0517: extern int __isoc99_vscanf (__const char *__restrict __format,
0518: _G_va_list __arg) __wur;
0519: extern int __isoc99_vsscanf (__const char *__restrict __s,
0520: __const char *__restrict __format,
0521: _G_va_list __arg) __THROW;
0522: # define vfscanf __isoc99_vfscanf
0523: # define vscanf __isoc99_vscanf
0524: # define vsscanf __isoc99_vsscanf
0525: # endif
0526: # endif
0527:
0528: __END_NAMESPACE_C99
0529: #endif /* Use ISO C9x. */
0530:
0531:
0532: __BEGIN_NAMESPACE_STD
0533: /* Read a character from STREAM.
0534:
0535: These functions are possible cancellation points and therefore not
0536: marked with __THROW. */
0537: extern int fgetc (FILE *__stream);
0538: extern int getc (FILE *__stream);
0539:
0540: /* Read a character from stdin.
0541:
0542: This function is a possible cancellation point and therefore not
0543: marked with __THROW. */
0544: extern int getchar (void);
0545: __END_NAMESPACE_STD
0546:
0547: /* The C standard explicitly says this is a macro, so we always do the
0548: optimization for it. */
0549: #define getc(_fp) _IO_getc (_fp)
0550:
0551: #if defined __USE_POSIX || defined __USE_MISC
0552: /* These are defined in POSIX.1:1996.
0553:
0554: These functions are possible cancellation points and therefore not
0555: marked with __THROW. */
0556: extern int getc_unlocked (FILE *__stream);
0557: extern int getchar_unlocked (void);
0558: #endif /* Use POSIX or MISC. */
0559:
0560: #ifdef __USE_MISC
0561: /* Faster version when locking is not necessary.
0562:
0563: This function is not part of POSIX and therefore no official
0564: cancellation point. But due to similarity with an POSIX interface
0565: or due to the implementation it is a cancellation point and
0566: therefore not marked with __THROW. */
0567: extern int fgetc_unlocked (FILE *__stream);
0568: #endif /* Use MISC. */
0569:
0570:
0571: __BEGIN_NAMESPACE_STD
0572: /* Write a character to STREAM.
0573:
0574: These functions are possible cancellation points and therefore not
0575: marked with __THROW.
0576:
0577: These functions is a possible cancellation point and therefore not
0578: marked with __THROW. */
0579: extern int fputc (int __c, FILE *__stream);
0580: extern int putc (int __c, FILE *__stream);
0581:
0582: /* Write a character to stdout.
0583:
0584: This function is a possible cancellation point and therefore not
0585: marked with __THROW. */
0586: extern int putchar (int __c);
0587: __END_NAMESPACE_STD
0588:
0589: /* The C standard explicitly says this can be a macro,
0590: so we always do the optimization for it. */
0591: #define putc(_ch, _fp) _IO_putc (_ch, _fp)
0592:
0593: #ifdef __USE_MISC
0594: /* Faster version when locking is not necessary.
0595:
0596: This function is not part of POSIX and therefore no official
0597: cancellation point. But due to similarity with an POSIX interface
0598: or due to the implementation it is a cancellation point and
0599: therefore not marked with __THROW. */
0600: extern int fputc_unlocked (int __c, FILE *__stream);
0601: #endif /* Use MISC. */
0602:
0603: #if defined __USE_POSIX || defined __USE_MISC
0604: /* These are defined in POSIX.1:1996.
0605:
0606: These functions are possible cancellation points and therefore not
0607: marked with __THROW. */
0608: extern int putc_unlocked (int __c, FILE *__stream);
0609: extern int putchar_unlocked (int __c);
0610: #endif /* Use POSIX or MISC. */
0611:
0612:
0613: #if defined __USE_SVID || defined __USE_MISC \
0614: || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
0615: /* Get a word (int) from STREAM. */
0616: extern int getw (FILE *__stream);
0617:
0618: /* Write a word (int) to STREAM. */
0619: extern int putw (int __w, FILE *__stream);
0620: #endif
0621:
0622:
0623: __BEGIN_NAMESPACE_STD
0624: /* Get a newline-terminated string of finite length from STREAM.
0625:
0626: This function is a possible cancellation point and therefore not
0627: marked with __THROW. */
0628: extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
0629: __wur;
0630:
0631: /* Get a newline-terminated string from stdin, removing the newline.
0632: DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
0633:
0634: This function is a possible cancellation point and therefore not
0635: marked with __THROW. */
0636: extern char *gets (char *__s) __wur;
0637: __END_NAMESPACE_STD
0638:
0639: #ifdef __USE_GNU
0640: /* This function does the same as `fgets' but does not lock the stream.
0641:
0642: This function is not part of POSIX and therefore no official
0643: cancellation point. But due to similarity with an POSIX interface
0644: or due to the implementation it is a cancellation point and
0645: therefore not marked with __THROW. */
0646: extern char *fgets_unlocked (char *__restrict __s, int __n,
0647: FILE *__restrict __stream) __wur;
0648: #endif
0649:
0650:
0651: #ifdef __USE_XOPEN2K8
0652: /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
0653: (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
0654: NULL), pointing to *N characters of space. It is realloc'd as
0655: necessary. Returns the number of characters read (not including the
0656: null terminator), or -1 on error or EOF.
0657:
0658: These functions are not part of POSIX and therefore no official
0659: cancellation point. But due to similarity with an POSIX interface
0660: or due to the implementation they are cancellation points and
0661: therefore not marked with __THROW. */
0662: extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
0663: size_t *__restrict __n, int __delimiter,
0664: FILE *__restrict __stream) __wur;
0665: extern _IO_ssize_t getdelim (char **__restrict __lineptr,
0666: size_t *__restrict __n, int __delimiter,
0667: FILE *__restrict __stream) __wur;
0668:
0669: /* Like `getdelim', but reads up to a newline.
0670:
0671: This function is not part of POSIX and therefore no official
0672: cancellation point. But due to similarity with an POSIX interface
0673: or due to the implementation it is a cancellation point and
0674: therefore not marked with __THROW. */
0675: extern _IO_ssize_t getline (char **__restrict __lineptr,
0676: size_t *__restrict __n,
0677: FILE *__restrict __stream) __wur;
0678: #endif
0679:
0680:
0681: __BEGIN_NAMESPACE_STD
0682: /* Write a string to STREAM.
0683:
0684: This function is a possible cancellation point and therefore not
0685: marked with __THROW. */
0686: extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
0687:
0688: /* Write a string, followed by a newline, to stdout.
0689:
0690: This function is a possible cancellation point and therefore not
0691: marked with __THROW. */
0692: extern int puts (__const char *__s);
0693:
0694:
0695: /* Push a character back onto the input buffer of STREAM.
0696:
0697: This function is a possible cancellation point and therefore not
0698: marked with __THROW. */
0699: extern int ungetc (int __c, FILE *__stream);
0700:
0701:
0702: /* Read chunks of generic data from STREAM.
0703:
0704: This function is a possible cancellation point and therefore not
0705: marked with __THROW. */
0706: extern size_t fread (void *__restrict __ptr, size_t __size,
0707: size_t __n, FILE *__restrict __stream) __wur;
0708: /* Write chunks of generic data to STREAM.
0709:
0710: This function is a possible cancellation point and therefore not
0711: marked with __THROW. */
0712: extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
0713: size_t __n, FILE *__restrict __s);
0714: __END_NAMESPACE_STD
0715:
0716: #ifdef __USE_GNU
0717: /* This function does the same as `fputs' but does not lock the stream.
0718:
0719: This function is not part of POSIX and therefore no official
0720: cancellation point. But due to similarity with an POSIX interface
0721: or due to the implementation it is a cancellation point and
0722: therefore not marked with __THROW. */
0723: extern int fputs_unlocked (__const char *__restrict __s,
0724: FILE *__restrict __stream);
0725: #endif
0726:
0727: #ifdef __USE_MISC
0728: /* Faster versions when locking is not necessary.
0729:
0730: These functions are not part of POSIX and therefore no official
0731: cancellation point. But due to similarity with an POSIX interface
0732: or due to the implementation they are cancellation points and
0733: therefore not marked with __THROW. */
0734: extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
0735: size_t __n, FILE *__restrict __stream) __wur;
0736: extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
0737: size_t __n, FILE *__restrict __stream);
0738: #endif
0739:
0740:
0741: __BEGIN_NAMESPACE_STD
0742: /* Seek to a certain position on STREAM.
0743:
0744: This function is a possible cancellation point and therefore not
0745: marked with __THROW. */
0746: extern int fseek (FILE *__stream, long int __off, int __whence);
0747: /* Return the current position of STREAM.
0748:
0749: This function is a possible cancellation point and therefore not
0750: marked with __THROW. */
0751: extern long int ftell (FILE *__stream) __wur;
0752: /* Rewind to the beginning of STREAM.
0753:
0754: This function is a possible cancellation point and therefore not
0755: marked with __THROW. */
0756: extern void rewind (FILE *__stream);
0757: __END_NAMESPACE_STD
0758:
0759: /* The Single Unix Specification, Version 2, specifies an alternative,
0760: more adequate interface for the two functions above which deal with
0761: file offset. `long int' is not the right type. These definitions
0762: are originally defined in the Large File Support API. */
0763:
0764: #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
0765: # ifndef __USE_FILE_OFFSET64
0766: /* Seek to a certain position on STREAM.
0767:
0768: This function is a possible cancellation point and therefore not
0769: marked with __THROW. */
0770: extern int fseeko (FILE *__stream, __off_t __off, int __whence);
0771: /* Return the current position of STREAM.
0772:
0773: This function is a possible cancellation point and therefore not
0774: marked with __THROW. */
0775: extern __off_t ftello (FILE *__stream) __wur;
0776: # else
0777: # ifdef __REDIRECT
0778: extern int __REDIRECT (fseeko,
0779: (FILE *__stream, __off64_t __off, int __whence),
0780: fseeko64);
0781: extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
0782: # else
0783: # define fseeko fseeko64
0784: # define ftello ftello64
0785: # endif
0786: # endif
0787: #endif
0788:
0789: __BEGIN_NAMESPACE_STD
0790: #ifndef __USE_FILE_OFFSET64
0791: /* Get STREAM's position.
0792:
0793: This function is a possible cancellation point and therefore not
0794: marked with __THROW. */
0795: extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
0796: /* Set STREAM's position.
0797:
0798: This function is a possible cancellation point and therefore not
0799: marked with __THROW. */
0800: extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
0801: #else
0802: # ifdef __REDIRECT
0803: extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
0804: fpos_t *__restrict __pos), fgetpos64);
0805: extern int __REDIRECT (fsetpos,
0806: (FILE *__stream, __const fpos_t *__pos), fsetpos64);
0807: # else
0808: # define fgetpos fgetpos64
0809: # define fsetpos fsetpos64
0810: # endif
0811: #endif
0812: __END_NAMESPACE_STD
0813:
0814: #ifdef __USE_LARGEFILE64
0815: extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
0816: extern __off64_t ftello64 (FILE *__stream) __wur;
0817: extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
0818: extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
0819: #endif
0820:
0821: __BEGIN_NAMESPACE_STD
0822: /* Clear the error and EOF indicators for STREAM. */
0823: extern void clearerr (FILE *__stream) __THROW;
0824: /* Return the EOF indicator for STREAM. */
0825: extern int feof (FILE *__stream) __THROW __wur;
0826: /* Return the error indicator for STREAM. */
0827: extern int ferror (FILE *__stream) __THROW __wur;
0828: __END_NAMESPACE_STD
0829:
0830: #ifdef __USE_MISC
0831: /* Faster versions when locking is not required. */
0832: extern void clearerr_unlocked (FILE *__stream) __THROW;
0833: extern int feof_unlocked (FILE *__stream) __THROW __wur;
0834: extern int ferror_unlocked (FILE *__stream) __THROW __wur;
0835: #endif
0836:
0837:
0838: __BEGIN_NAMESPACE_STD
0839: /* Print a message describing the meaning of the value of errno.
0840:
0841: This function is a possible cancellation point and therefore not
0842: marked with __THROW. */
0843: extern void perror (__const char *__s);
0844: __END_NAMESPACE_STD
0845:
0846: /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
0847: are available on this system. Even if available, these variables
0848: should not be used directly. The `strerror' function provides
0849: all the necessary functionality. */
0850: #include <bits/sys_errlist.h>
0851:
0852:
0853: #ifdef __USE_POSIX
0854: /* Return the system file descriptor for STREAM. */
0855: extern int fileno (FILE *__stream) __THROW __wur;
0856: #endif /* Use POSIX. */
0857:
0858: #ifdef __USE_MISC
0859: /* Faster version when locking is not required. */
0860: extern int fileno_unlocked (FILE *__stream) __THROW __wur;
0861: #endif
0862:
0863:
0864: #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
0865: defined __USE_MISC)
0866: /* Create a new stream connected to a pipe running the given command.
0867:
0868: This function is a possible cancellation point and therefore not
0869: marked with __THROW. */
0870: extern FILE *popen (__const char *__command, __const char *__modes) __wur;
0871:
0872: /* Close a stream opened by popen and return the status of its child.
0873:
0874: This function is a possible cancellation point and therefore not
0875: marked with __THROW. */
0876: extern int pclose (FILE *__stream);
0877: #endif
0878:
0879:
0880: #ifdef __USE_POSIX
0881: /* Return the name of the controlling terminal. */
0882: extern char *ctermid (char *__s) __THROW;
0883: #endif /* Use POSIX. */
0884:
0885:
0886: #ifdef __USE_XOPEN
0887: /* Return the name of the current user. */
0888: extern char *cuserid (char *__s);
0889: #endif /* Use X/Open, but not issue 6. */
0890:
0891:
0892: #ifdef __USE_GNU
0893: struct obstack; /* See <obstack.h>. */
0894:
0895: /* Write formatted output to an obstack. */
0896: extern int obstack_printf (struct obstack *__restrict __obstack,
0897: __const char *__restrict __format, ...)
0898: __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
0899: extern int obstack_vprintf (struct obstack *__restrict __obstack,
0900: __const char *__restrict __format,
0901: _G_va_list __args)
0902: __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
0903: #endif /* Use GNU. */
0904:
0905:
0906: #if defined __USE_POSIX || defined __USE_MISC
0907: /* These are defined in POSIX.1:1996. */
0908:
0909: /* Acquire ownership of STREAM. */
0910: extern void flockfile (FILE *__stream) __THROW;
0911:
0912: /* Try to acquire ownership of STREAM but do not block if it is not
0913: possible. */
0914: extern int ftrylockfile (FILE *__stream) __THROW __wur;
0915:
0916: /* Relinquish the ownership granted for STREAM. */
0917: extern void funlockfile (FILE *__stream) __THROW;
0918: #endif /* POSIX || misc */
0919:
0920: #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
0921: /* The X/Open standard requires some functions and variables to be
0922: declared here which do not belong into this header. But we have to
0923: follow. In GNU mode we don't do this nonsense. */
0924: # define __need_getopt
0925: # include <getopt.h>
0926: #endif /* X/Open, but not issue 6 and not for GNU. */
0927:
0928: /* If we are compiling with optimizing read this file. It contains
0929: several optimizing inline functions and macros. */
0930: #ifdef __USE_EXTERN_INLINES
0931: # include <bits/stdio.h>
0932: #endif
0933: #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
0934: # include <bits/stdio2.h>
0935: #endif
0936: #ifdef __LDBL_COMPAT
0937: # include <bits/stdio-ldbl.h>
0938: #endif
0939:
0940: __END_DECLS
0941:
0942: #endif /* <stdio.h> included. */
0943:
0944: #endif /* !_STDIO_H */