home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / glibc-1.06 / stdio / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-11  |  21.4 KB  |  631 lines

  1. /* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. /*
  20.  *    ANSI Standard: 4.9 INPUT/OUTPUT    <stdio.h>
  21.  */
  22.  
  23. #ifndef    _STDIO_H
  24.  
  25. #if    !defined(__need_FILE)
  26. #define    _STDIO_H    1
  27. #include <features.h>
  28.  
  29. __BEGIN_DECLS
  30.  
  31. #define    __need_size_t
  32. #define    __need_NULL
  33. #include <stddef.h>
  34.  
  35. #define    __need___va_list
  36. #include <stdarg.h>
  37. #ifndef    __GNUC_VA_LIST
  38. #define    __gnuc_va_list    __ptr_t
  39. #endif
  40.  
  41. #include <gnu/types.h>
  42. #endif /* Don't need FILE.  */
  43. #undef    __need_FILE
  44.  
  45.  
  46. #ifndef    __FILE_defined
  47.  
  48. /* The opaque type of streams.  */
  49. typedef struct __stdio_file FILE;
  50.  
  51. #define    __FILE_defined    1
  52. #endif /* FILE not defined.  */
  53.  
  54.  
  55. #ifdef    _STDIO_H
  56.  
  57. /* The type of the second argument to `fgetpos' and `fsetpos'.  */
  58. typedef __off_t fpos_t;
  59.  
  60. /* The mode of I/O, as given in the MODE argument to fopen, etc.  */
  61. typedef struct
  62. {
  63.   unsigned int __read:1;    /* Open for reading.  */
  64.   unsigned int __write:1;    /* Open for writing.  */
  65.   unsigned int __append:1;    /* Open for appending.  */
  66.   unsigned int __binary:1;    /* Opened binary.  */
  67.   unsigned int __create:1;    /* Create the file.  */
  68.   unsigned int __exclusive:1;    /* Error if it already exists.  */
  69.   unsigned int __truncate:1;    /* Truncate the file on opening.  */
  70. } __io_mode;
  71.  
  72.  
  73. /* Functions to do I/O and file management for a stream.  */
  74.  
  75. /* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF.
  76.    Return number of bytes read.  */
  77. typedef __ssize_t __io_read __P ((__ptr_t __cookie, char *__buf,
  78.                   size_t __nbytes));
  79.  
  80. /* Write N bytes pointed to by BUF to COOKIE.  Write all N bytes
  81.    unless there is an error.  Return number of bytes written, or -1 if
  82.    there is an error without writing anything.  If the file has been
  83.    opened for append (__mode.__append set), then set the file pointer
  84.    to the end of the file and then do the write; if not, just write at
  85.    the current file pointer.  */
  86. typedef __ssize_t __io_write __P ((__ptr_t __cookie, __const char *__buf,
  87.                    size_t __n));
  88.  
  89. /* Move COOKIE's file position to *POS bytes from the
  90.    beginning of the file (if W is SEEK_SET),
  91.    the current position (if W is SEEK_CUR),
  92.    or the end of the file (if W is SEEK_END).
  93.    Set *POS to the new file position.
  94.    Returns zero if successful, nonzero if not.  */
  95. typedef int __io_seek __P ((__ptr_t __cookie, fpos_t *__pos, int __w));
  96.  
  97. /* Close COOKIE.  */
  98. typedef int __io_close __P ((__ptr_t __cookie));
  99.  
  100. /* Low level interface, independent of FILE representation.  */
  101. typedef struct
  102. {
  103.   __io_read *__read;        /* Read bytes.  */
  104.   __io_write *__write;        /* Write bytes.  */
  105.   __io_seek *__seek;        /* Seek/tell file position.  */
  106.   __io_close *__close;        /* Close file.  */
  107. } __io_functions;
  108.  
  109. /* Higher level interface, dependent on FILE representation.  */
  110. typedef struct
  111. {
  112.   /* Make room in the input buffer.  */
  113.   int (*__input) __P ((FILE *__stream));
  114.   /* Make room in the output buffer.  */
  115.   void (*__output) __P ((FILE *__stream, int __c));
  116. } __room_functions;
  117.  
  118. extern __const __io_functions __default_io_functions;
  119. extern __const __room_functions __default_room_functions;
  120.  
  121.  
  122. /* Default close function.  */
  123. extern __io_close __stdio_close;
  124. /* Open FILE with mode M, return cookie or NULL to use an int in *DP.  */
  125. extern __ptr_t __stdio_open __P ((__const char *__file, __io_mode __m,
  126.                   int *__dp));
  127. /* Put out an error message for when stdio needs to die.  */
  128. extern void __stdio_errmsg __P ((__const char *__msg, size_t __len));
  129. /* Generate a unique file name.  */
  130. extern char *__stdio_gen_tempname __P ((__const char *__dir,
  131.                     __const char *__pfx,
  132.                     int __dir_search, size_t *__lenptr));
  133.  
  134. #ifndef    __NORETURN
  135. #ifdef    __GNUC__
  136. #define    __NORETURN    __volatile
  137. #else /* Not GCC.  */
  138. #define    __NORETURN
  139. #endif /* GCC.  */
  140. #endif /* __NORETURN not defined.  */
  141.  
  142. /* Print out MESSAGE on the error output and abort.  */
  143. extern __NORETURN void __libc_fatal __P ((__const char *__message));
  144.  
  145.  
  146. /* The FILE structure.  */
  147. struct __stdio_file
  148. {
  149.   /* Magic number for validation.  Must be negative in open streams
  150.      for the glue to Unix stdio getc/putc to work.
  151.      NOTE: stdio/glue.c has special knowledge of these first four members.  */
  152.   int __magic;
  153. #define    _IOMAGIC    0xfedabeeb    /* Magic number to fill `__magic'.  */
  154. #define    _GLUEMAGIC    0xfeedbabe    /* Magic for glued Unix streams.  */
  155.  
  156.   char *__bufp;            /* Pointer into the buffer.  */
  157.   char *__get_limit;        /* Reading limit.  */
  158.   char *__put_limit;        /* Writing limit.  */
  159.  
  160.   char *__buffer;        /* Base of buffer.  */
  161.   size_t __bufsize;        /* Size of the buffer.  */
  162.   __ptr_t __cookie;        /* Magic cookie.  */
  163.   int __fileno;            /* System file descriptor.  */
  164.   __io_mode __mode;        /* File access mode.  */
  165.   __io_functions __io_funcs;    /* I/O functions.  */
  166.   __room_functions __room_funcs;/* I/O buffer room functions.  */
  167.   fpos_t __offset;        /* Current file position.  */
  168.   fpos_t __target;        /* Target file position.  */
  169.   FILE *__next;            /* Next FILE in the linked list.  */
  170.   char *__pushback_bufp;    /* Old bufp if char pushed back.  */
  171.   unsigned char __pushback;    /* Pushed-back character.  */
  172.   unsigned int __pushed_back:1;    /* A char has been pushed back.  */
  173.   unsigned int __eof:1;        /* End of file encountered.  */
  174.   unsigned int __error:1;    /* Error encountered.  */
  175.   unsigned int __userbuf:1;    /* Buffer from user (should not be freed).  */
  176.   unsigned int __linebuf:1;    /* Flush on newline.  */
  177.   unsigned int __linebuf_active:1; /* put_limit is not really in use.  */
  178.   unsigned int __seen:1;    /* This stream has been seen.  */
  179.   unsigned int __ispipe:1;    /* Nonzero if opened by popen.  */
  180. };
  181.  
  182.  
  183. /* All macros used internally by other macros here and by stdio functions begin
  184.    with `__'.  All of these may evaluate their arguments more than once.  */
  185.  
  186.  
  187. /* Nonzero if STREAM is a valid stream.
  188.    STREAM must be a modifiable lvalue (wow, I got to use that term).
  189.    See stdio/glue.c for what the confusing bit is about.  */
  190. #define    __validfp(stream)                              \
  191.   (stream != NULL && ((stream->__magic == _GLUEMAGIC &&                  \
  192.                (stream = *(FILE **) ((int *) stream)[1])),          \
  193.               (stream->__magic == _IOMAGIC)))                  \
  194.  
  195. /* Clear the error and EOF indicators of STREAM.  */
  196. #define    __clearerr(stream)    ((stream)->__error = (stream)->__eof = 0)
  197.  
  198. /* Nuke STREAM, making it unusable but available for reuse.  */
  199. extern void __invalidate __P ((FILE *__stream));
  200.  
  201. /* Make sure STREAM->__offset and STREAM->__target are initialized.
  202.    Returns 0 if successful, or EOF on
  203.    error (but doesn't set STREAM->__error).  */
  204. extern int __stdio_check_offset __P ((FILE *__stream));
  205.  
  206.  
  207. /* The possibilities for the third argument to `setvbuf'.  */
  208. #define _IOFBF    0x1        /* Full buffering.  */
  209. #define _IOLBF    0x2        /* Line buffering.  */
  210. #define _IONBF    0x4        /* No buffering.  */
  211.  
  212.  
  213. /* Default buffer size.  */
  214. #define    BUFSIZ    1024
  215.  
  216.  
  217. /* End of file character.
  218.    Some things throughout the library rely on this being -1.  */
  219. #define    EOF    (-1)
  220.  
  221.  
  222. /* The possibilities for the third argument to `fseek'.
  223.    These values should not be changed.  */
  224. #define    SEEK_SET    0    /* Seek from beginning of file.  */
  225. #define    SEEK_CUR    1    /* Seek from current position.  */
  226. #define    SEEK_END    2    /* Seek from end of file.  */
  227.  
  228.  
  229. #ifdef    __USE_SVID
  230. /* Default path prefix for `tempnam' and `tmpnam'.  */
  231. #define    P_tmpdir    "/usr/tmp"
  232. #endif
  233.  
  234.  
  235. /* Get the values:
  236.    L_tmpnam    How long an array of chars must be to be passed to `tmpnam'.
  237.    TMP_MAX    The minimum number of unique filenames generated by tmpnam
  238.            (and tempnam when it uses tmpnam's name space),
  239.         or tempnam (the two are separate).
  240.    L_ctermid    How long an array to pass to `ctermid'.
  241.    L_cuserid    How long an array to pass to `cuserid'.
  242.    FOPEN_MAX    Mininum number of files that can be open at once.
  243.    FILENAME_MAX    Maximum length of a filename.  */
  244. #include <stdio_lim.h>
  245.  
  246.  
  247. /* All the known streams are in a linked list
  248.    linked by the `next' field of the FILE structure.  */
  249. extern FILE *__stdio_head;    /* Head of the list.  */
  250.  
  251. /* Standard streams.  */
  252. extern FILE *stdin, *stdout, *stderr;
  253.  
  254.  
  255. /* Remove file FILENAME.  */
  256. extern int remove __P ((__const char *__filename));
  257. /* Rename file OLD to NEW.  */
  258. extern int rename __P ((__const char *__old, __const char *__new));
  259.  
  260.  
  261. /* Create a temporary file and open it read/write.  */
  262. extern FILE *tmpfile __P ((void));
  263. /* Generate a temporary filename.  */
  264. extern char *tmpnam __P ((char *__s));
  265.  
  266.  
  267. #ifdef    __USE_SVID
  268. /* Generate a unique temporary filename using up to five characters of PFX
  269.    if it is not NULL.  The directory to put this file in is searched for
  270.    as follows: First the environment variable "TMPDIR" is checked.
  271.    If it contains the name of a writable directory, that directory is used.
  272.    If not and if DIR is not NULL, that value is checked.  If that fails,
  273.    P_tmpdir is tried and finally "/tmp".  The storage for the filename
  274.    is allocated by `malloc'.  */
  275. extern char *tempnam __P ((__const char *__dir, __const char *__pfx));
  276. #endif
  277.  
  278.  
  279. /* This performs actual output when necessary, flushing
  280.    STREAM's buffer and optionally writing another character.  */
  281. extern int __flshfp __P ((FILE *__stream, int __c));
  282.  
  283.  
  284. /* Close STREAM, or all streams if STREAM is NULL.  */
  285. extern int fclose __P ((FILE *__stream));
  286. /* Flush STREAM, or all streams if STREAM is NULL.  */
  287. extern int fflush __P ((FILE *__stream));
  288.  
  289.  
  290. /* Open a file and create a new stream for it.  */
  291. extern FILE *fopen __P ((__const char *__filename, __const char *__modes));
  292. /* Open a file, replacing an existing stream with it. */
  293. extern FILE *freopen __P ((__const char *__filename,
  294.                __const char *__modes, FILE *__stream));
  295.  
  296. /* Return a new, zeroed, stream.
  297.    You must set its cookie and io_mode.
  298.    The first operation will give it a buffer unless you do.
  299.    It will also give it the default functions unless you set the `seen' flag.
  300.    The offset is set to -1, meaning it will be determined by doing a
  301.    stationary seek.  You can set it to avoid the initial tell call.
  302.    The target is set to -1, meaning it will be set to the offset
  303.    before the target is needed.
  304.    Returns NULL if a stream can't be created.  */
  305. extern FILE *__newstream __P ((void));
  306.  
  307. #ifdef    __USE_POSIX
  308. /* Create a new stream that refers to an existing system file descriptor.  */
  309. extern FILE *fdopen __P ((int __fd, __const char *__modes));
  310. #endif
  311.  
  312. #ifdef    __USE_GNU
  313. /* Create a new stream that refers to the given magic cookie,
  314.    and uses the given functions for input and output.  */
  315. extern FILE *fopencookie __P ((__ptr_t __magic_cookie, __const char *__modes,
  316.                    __io_functions __io_funcs));
  317.  
  318. /* Create a new stream that refers to a memory buffer.  */
  319. extern FILE *fmemopen __P ((__ptr_t __s, size_t __len, __const char *__modes));
  320.  
  321. /* Open a stream that writes into a malloc'd buffer that is expanded as
  322.    necessary.  *BUFLOC and *SIZELOC are updated with the buffer's location
  323.    and the number of characters written on fflush or fclose.  */
  324. extern FILE *open_memstream __P ((char **__bufloc, size_t *__sizeloc));
  325. #endif
  326.  
  327.  
  328. /* If BUF is NULL, make STREAM unbuffered.
  329.    Else make it use buffer BUF, of size BUFSIZ.  */
  330. extern void setbuf __P ((FILE *__stream, char *__buf));
  331. /* Make STREAM use buffering mode MODE.
  332.    If BUF is not NULL, use N bytes of it for buffering;
  333.    else allocate an internal buffer N bytes long.  */
  334. extern int setvbuf __P ((FILE *__stream, char *__buf,
  335.              int __modes, size_t __n));
  336.  
  337. #ifdef    __USE_BSD
  338. /* If BUF is NULL, make STREAM unbuffered.
  339.    Else make it use SIZE bytes of BUF for buffering.  */
  340. extern void setbuffer __P ((FILE *__stream, char *__buf, size_t __size));
  341.  
  342. /* Make STREAM line-buffered.  */
  343. extern void setlinebuf __P ((FILE *__stream));
  344. #endif
  345.  
  346.  
  347. /* Write formatted output to STREAM.  */
  348. extern int fprintf __P ((FILE *__stream, __const char *__format, ...));
  349. /* Write formatted output to stdout.  */
  350. extern int printf __P ((__const char *__format, ...));
  351. /* Write formatted output to S.  */
  352. extern int sprintf __P ((char *__s, __const char *__format, ...));
  353.  
  354. /* Write formatted output to S from argument list ARG.  */
  355. extern int vfprintf __P ((FILE *__s, __const char *__format,
  356.               __gnuc_va_list __arg));
  357. /* Write formatted output to stdout from argument list ARG.  */
  358. extern int vprintf __P ((__const char *__format, __ptr_t __arg));
  359. /* Write formatted output to S from argument list ARG.  */
  360. extern int vsprintf __P ((char *__s, __const char *__format,
  361.               __gnuc_va_list __arg));
  362.  
  363. #ifdef    __OPTIMIZE__
  364. #define    vprintf(fmt, arg)        vfprintf(stdout, (fmt), (arg))
  365. #endif /* Optimizing.  */
  366.  
  367. #ifdef    __USE_GNU
  368. /* Maximum chars of output to write in MAXLEN.  */
  369. extern int snprintf __P ((char *__s, size_t __maxlen,
  370.               __const char *__format, ...));
  371.  
  372. extern int vsnprintf __P ((char *__s, size_t __maxlen,
  373.                __const char *__format, __gnuc_va_list __arg));
  374.  
  375. /* Write formatted output to a string dynamically allocated with `malloc'.
  376.    Store the address of the string in *PTR.  */
  377. extern int vasprintf __P ((char **__ptr, __const char *__f,
  378.                __gnuc_va_list __arg));
  379. extern int asprintf __P ((char **__ptr, __const char *__fmt, ...));
  380.  
  381. /* Write formatted output to a file descriptor.  */
  382. extern int vdprintf __P ((int __fd, __const char *__fmt,
  383.               __gnuc_va_list __arg));
  384. extern int dprintf __P ((int __fd, __const char *__fmt, ...));
  385. #endif
  386.  
  387.  
  388. /* Read formatted input from STREAM.  */
  389. extern int fscanf __P ((FILE *__stream, __const char *__format, ...));
  390. /* Read formatted input from stdin.  */
  391. extern int scanf __P ((__const char *__format, ...));
  392. /* Read formatted input from S.  */
  393. extern int sscanf __P ((__const char *__s, __const char *__format, ...));
  394.  
  395. #ifdef    __USE_GNU
  396. /* Read formatted input from S into argument list ARG.  */
  397. extern int __vfscanf __P ((FILE *__s, __const char *__format,
  398.                __gnuc_va_list __arg));
  399. extern int vfscanf __P ((FILE *__s, __const char *__format,
  400.              __gnuc_va_list __arg));
  401.  
  402. /* Read formatted input from stdin into argument list ARG.  */
  403. extern int vscanf __P ((__const char *__format, __gnuc_va_list __arg));
  404.  
  405. /* Read formatted input from S into argument list ARG.  */
  406. extern int __vsscanf __P ((__const char *__s, __const char *__format,
  407.                __gnuc_va_list __arg));
  408. extern int vsscanf __P ((__const char *__s, __const char *__format,
  409.              __gnuc_va_list __arg));
  410.  
  411.  
  412. #ifdef    __OPTIMIZE__
  413. #define    vfscanf(s, format, arg)    __vfscanf((s), (format), (arg))
  414. #define    vscanf(format, arg)    __vfscanf(stdin, (format), (arg))
  415. #define    vsscanf(s, format, arg)    __vsscanf((s), (format), (arg))
  416. #endif /* Optimizing.  */
  417. #endif /* Use GNU.  */
  418.  
  419.  
  420. /* This does actual reading when necessary, filling STREAM's
  421.    buffer and returning the first character in it.  */
  422. extern int __fillbf __P ((FILE *__stream));
  423.  
  424.  
  425. /* Read a character from STREAM.  */
  426. extern int fgetc __P ((FILE *__stream));
  427. extern int getc __P ((FILE *__stream));
  428.  
  429. /* Read a character from stdin.  */
  430. extern int getchar __P ((void));
  431.  
  432. /* The C standard explicitly says this can
  433.    re-evaluate its argument, so it does. */
  434. #define    __getc(stream)                                  \
  435.   ((stream)->__bufp < (stream)->__get_limit ?                      \
  436.    (int) ((unsigned char) *(stream)->__bufp++) : __fillbf(stream))
  437.  
  438. /* The C standard explicitly says this is a macro,
  439.    so we always do the optimization for it.  */
  440. #define    getc(stream)    __getc(stream)
  441.  
  442. #ifdef    __OPTIMIZE__
  443. #define    getchar()    __getc(stdin)
  444. #endif /* Optimizing.  */
  445.  
  446.  
  447. /* Write a character to STREAM.  */
  448. extern int fputc __P ((int __c, FILE *__stream));
  449. extern int putc __P ((int __c, FILE *__stream));
  450.  
  451. /* Write a character to stdout.  */
  452. extern int putchar __P ((int __c));
  453.  
  454.  
  455. /* The C standard explicitly says this can
  456.    re-evaluate its arguments, so it does.  */
  457. #define    __putc(c, stream)                              \
  458.   ((stream)->__bufp < (stream)->__put_limit ?                      \
  459.    (int) (unsigned char) (*(stream)->__bufp++ = (unsigned char) (c)) :          \
  460.    __flshfp ((stream), (unsigned char) (c)))
  461.  
  462. /* The C standard explicitly says this can be a macro,
  463.    so we always do the optimization for it.  */
  464. #define    putc(c, stream)    __putc ((c), (stream))
  465.  
  466. #ifdef __OPTIMIZE__
  467. /* Note that putchar is NOT allowed to evaluate its arguments more than once.
  468.    This macro is valid only because __putc evaluates C exactly once.  */
  469. #define putchar(c)    __putc ((c), stdout)
  470. #endif
  471.  
  472.  
  473. #if defined(__USE_SVID) || defined(__USE_MISC)
  474. /* Get a word (int) from STREAM.  */
  475. extern int getw __P ((FILE *__stream));
  476.  
  477. /* Write a word (int) to STREAM.  */
  478. extern int putw __P ((int __w, FILE *__stream));
  479. #endif
  480.  
  481.  
  482. /* Get a newline-terminated string of finite length from STREAM.  */
  483. extern char *fgets __P ((char *__s, size_t __n, FILE *__stream));
  484.  
  485. /* Get a newline-terminated string from stdin, removing the newline.
  486.    DO NOT USE THIS FUNCTION!!  There is no limit on how much it will read.  */
  487. extern char *gets __P ((char *__s));
  488.  
  489.  
  490. #ifdef    __USE_GNU
  491. #include <sys/types.h>
  492.  
  493. /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
  494.    (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
  495.    NULL), pointing to *N characters of space.  It is realloc'd as
  496.    necessary.  Returns the number of characters read (not including the
  497.    null terminator), or -1 on error or EOF.  */
  498. ssize_t __getdelim __P ((char **__lineptr, size_t *__n,
  499.              int __delimiter, FILE *__stream));
  500. ssize_t getdelim __P ((char **__lineptr, size_t *__n,
  501.                int __delimiter, FILE *__stream));
  502.  
  503. /* Like `getdelim', but reads up to a newline.  */
  504. ssize_t __getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
  505. ssize_t getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
  506.  
  507. #ifdef    __OPTIMIZE__
  508. #define    getdelim(l, n, d, s)    __getdelim ((l), (n), (d), (s))
  509. #define    getline(l, n, s)    __getline ((l), (n), (s))
  510. #define    __getline(l, n, stream) __getdelim ((l), (n), '\n', (stream))
  511. #endif /* Optimizing.  */
  512. #endif
  513.  
  514.  
  515. /* Write a string to STREAM.  */
  516. extern int fputs __P ((__const char *__s, FILE *__stream));
  517. /* Write a string, followed by a newline, to stdout.  */
  518. extern int puts __P ((__const char *__s));
  519.  
  520. #ifdef    __OPTIMIZE__
  521. #define    puts(s)    ((fputs((s), stdout) || __putc('\n', stdout) == EOF) ? EOF : 0)
  522. #endif /* Optimizing.  */
  523.  
  524.  
  525. /* Push a character back onto the input buffer of STREAM.  */
  526. extern int ungetc __P ((int __c, FILE *__stream));
  527.  
  528.  
  529. /* Read chunks of generic data from STREAM.  */
  530. extern size_t fread __P ((__ptr_t __ptr, size_t __size,
  531.               size_t __n, FILE *__stream));
  532. /* Write chunks of generic data to STREAM.  */
  533. extern size_t fwrite __P ((__const __ptr_t __ptr, size_t __size,
  534.                size_t __n, FILE *__s));
  535.  
  536.  
  537. /* Seek to a certain position on STREAM.  */
  538. extern int fseek __P ((FILE *__stream, long int __off, int __whence));
  539. /* Return the current position of STREAM.  */
  540. extern long int ftell __P ((FILE *__stream));
  541. /* Rewind to the beginning of STREAM.  */
  542. extern void rewind __P ((FILE *__stream));
  543.  
  544. /* Get STREAM's position.  */
  545. extern int fgetpos __P ((FILE *__stream, fpos_t *__pos));
  546. /* Set STREAM's position.  */
  547. extern int fsetpos __P ((FILE *__stream, __const fpos_t *__pos));
  548.  
  549.  
  550. /* Clear the error and EOF indicators for STREAM.  */
  551. extern void clearerr __P ((FILE *__stream));
  552. /* Return the EOF indicator for STREAM.  */
  553. extern int feof __P ((FILE *__stream));
  554. /* Return the error indicator for STREAM.  */
  555. extern int ferror __P ((FILE *__stream));
  556.  
  557. #ifdef    __OPTIMIZE__
  558. #define    feof(stream)    ((stream)->__eof != 0)
  559. #define    ferror(stream)    ((stream)->__error != 0)
  560. #endif /* Optimizing.  */
  561.  
  562.  
  563. /* Print a message describing the meaning of the value of errno.  */
  564. extern void perror __P ((__const char *__s));
  565.  
  566. #ifdef    __USE_BSD
  567. extern int sys_nerr;
  568. extern char *sys_errlist[];
  569. #endif
  570. #ifdef    __USE_GNU
  571. extern int _sys_nerr;
  572. extern char *_sys_errlist[];
  573. #endif
  574.  
  575. #ifdef    __USE_MISC
  576. /* Print a message describing the meaning of the given signal number.  */
  577. extern void psignal __P ((int __sig, __const char *__s));
  578. #endif /* Non strict ANSI and not POSIX only.  */
  579.  
  580.  
  581. #ifdef    __USE_POSIX
  582. /* Return the system file descriptor for STREAM.  */
  583. extern int fileno __P ((__const FILE *__stream));
  584.  
  585. #ifdef    __OPTIMIZE__
  586. /* The `+ 0' makes this not be an lvalue, so it can't be changed.  */
  587. #define    fileno(stream)    ((stream)->__fileno + 0)
  588. #endif /* Optimizing.  */
  589.  
  590. #endif /* Use POSIX.  */
  591.  
  592.  
  593. #if (defined (__USE_POSIX2) || defined(__USE_SVID) || defined(__USE_BSD) || \
  594.      defined(__USE_MISC))
  595. /* Create a new stream connected to a pipe running the given command.  */
  596. extern FILE *popen __P ((__const char *__command, __const char *__modes));
  597.  
  598. /* Close a stream opened by popen and return the status of its child.  */
  599. extern int pclose __P ((FILE *__stream));
  600. #endif
  601.  
  602.  
  603. #ifdef    __USE_POSIX
  604. /* Return the name of the controlling terminal.  */
  605. extern char *ctermid __P ((char *__s));
  606. /* Return the name of the current user.  */
  607. extern char *cuserid __P ((char *__s));
  608. #endif
  609.  
  610.  
  611. #ifdef    __USE_GNU
  612. struct obstack;            /* See <obstack.h>.  */
  613.  
  614. /* Open a stream that writes to OBSTACK.  */
  615. extern FILE *open_obstack_stream __P ((struct obstack *__obstack));
  616.  
  617. /* Write formatted output to an obstack.  */
  618. extern int obstack_printf __P ((struct obstack *__obstack,
  619.                 __const char *__format, ...));
  620. extern int obstack_vprintf __P ((struct obstack *__obstack,
  621.                  __const char *__format,
  622.                  __gnuc_va_list __args));
  623. #endif
  624.  
  625.  
  626. __END_DECLS
  627.  
  628. #endif /* <stdio.h> included.  */
  629.  
  630. #endif /* stdio.h  */
  631.