]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/Include/stdio.h
Re-enable the declaration for ftello.
[mirror_edk2.git] / StdLib / Include / stdio.h
index 7a60a290acb905cc2676e1be0ae4cec6f4e483c7..62cbecef91819fc5c522d36d13bf1c4b913cac84 100644 (file)
@@ -1,4 +1,119 @@
-/*-\r
+/** @file\r
+  Macros, types, and functions for performing I/O.\r
+\r
+  The following functions are declared in this file:<BR>\r
+@verbatim\r
+    ################### Operations on files.   ####\r
+    int       remove          (const char *FileName);\r
+    int       rename          (const char *, const char *);\r
+    FILE     *tmpfile         (void);\r
+    char     *tmpnam          (char *);\r
+\r
+    ################### File access functions.   ####\r
+    int       fclose          (FILE *);\r
+    int       fflush          (FILE *);\r
+    FILE     *fopen           (const char * __restrict ,\r
+                               const char * __restrict);\r
+    FILE     *freopen         (const char * __restrict,\r
+                               const char * __restrict, FILE * __restrict);\r
+    void      setbuf          (FILE * __restrict, char * __restrict);\r
+    int       setvbuf         (FILE * __restrict, char * __restrict,\r
+                               int, size_t);\r
+\r
+    ################### Formatted Input/Output Functions.  ####\r
+    int       fprintf         (FILE * __restrict stream,\r
+                               const char * __restrict format, ...);\r
+    int       fscanf          (FILE * __restrict, const char * __restrict, ...);\r
+    int       printf          (const char * __restrict, ...);\r
+    int       scanf           (const char * __restrict, ...);\r
+    int       sprintf         (char * __restrict, const char * __restrict, ...);\r
+    int       sscanf          (const char * __restrict,\r
+                               const char * __restrict, ...);\r
+    int       vfprintf        (FILE * __restrict,\r
+                               const char * __restrict, va_list);\r
+    int       vprintf         (const char * __restrict, va_list);\r
+    int       vsprintf        (char * __restrict,\r
+                               const char * __restrict, va_list);\r
+\r
+    ################### Character Input/Output Functions. ####\r
+    int       fgetc           (FILE *);\r
+    char     *fgets           (char * __restrict, int, FILE * __restrict);\r
+    int       fputc           (int, FILE *);\r
+    int       fputs           (const char * __restrict, FILE * __restrict);\r
+    int       getc            (FILE *);\r
+    int       getchar         (void);\r
+    char     *gets            (char *);\r
+    int       putc            (int, FILE *);\r
+    int       putchar         (int);\r
+    int       puts            (const char *);\r
+    int       ungetc          (int, FILE *);\r
+\r
+    ################### Direct Input/Output Functions. ####\r
+    size_t    fread           (void * __restrict, size_t, size_t,\r
+                               FILE * __restrict);\r
+    size_t    fwrite          (const void * __restrict, size_t, size_t,\r
+                               FILE * __restrict);\r
+\r
+    ################### File Positioning Functions.  ####\r
+    int       fgetpos         (FILE * __restrict, fpos_t * __restrict);\r
+    int       fseek           (FILE *, long, int);\r
+    int       fsetpos         (FILE *, const fpos_t *);\r
+    long      ftell           (FILE *);\r
+    void      rewind          (FILE *);\r
+\r
+    ################### Error-handling Functions.  ####\r
+    void      clearerr        (FILE *);\r
+    int       feof            (FILE *);\r
+    int       ferror          (FILE *);\r
+    void      perror          (const char *);\r
+\r
+    ################### Functions NOT specified by C95  ####\r
+\r
+    FILE     *fdopen          (int, const char *);\r
+    void      flockfile       (FILE *);\r
+    int       ftrylockfile    (FILE *);\r
+    void      funlockfile     (FILE *);\r
+    int       getc_unlocked   (FILE *);\r
+    int       getchar_unlocked(void);\r
+    int       putc_unlocked   (int, FILE *);\r
+    int       putchar_unlocked(int);\r
+    int       pclose          (FILE *);\r
+    FILE     *popen           (const char *, const char *);\r
+    int       snprintf        (char * __restrict, size_t,\r
+                               const char * __restrict, ...);\r
+    int       vsnprintf       (char * __restrict, size_t,\r
+                               const char * __restrict, va_list);\r
+    char     *mkdtemp         (char *);\r
+    int       mkstemp         (char *);\r
+    char     *mktemp          (char *);\r
+    char     *tempnam         (const char *, const char *);\r
+    int       fseeko          (FILE *, off_t, int);\r
+    char     *fgetln          (FILE * __restrict, size_t * __restrict);\r
+    char     *fparseln        (FILE *, size_t *, size_t *, const char[3], int);\r
+    int       fpurge          (FILE *);\r
+    void      setbuffer       (FILE *, char *, int);\r
+    int       setlinebuf      (FILE *);\r
+    int       vasprintf       (char ** __restrict, const char * __restrict,\r
+                               va_list);\r
+    int       vscanf          (const char * __restrict, va_list);\r
+    int       vsscanf         (const char * __restrict,\r
+                             const char * __restrict, va_list);\r
+@endverbatim\r
+\r
+  @note   To fit things in six character monocase externals, the stdio\r
+          code uses the prefix `__s' for stdio objects, typically followed\r
+          by a three-character attempt at a mnemonic.\r
+\r
+\r
+  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials are licensed and made available under\r
+  the terms and conditions of the BSD License that accompanies this distribution.\r
+  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
  * Copyright (c) 1990, 1993\r
  *  The Regents of the University of California.  All rights reserved.\r
  *\r
  * SUCH DAMAGE.\r
  *\r
  *  @(#)stdio.h 8.5 (Berkeley) 4/29/95\r
+    NetBSD: stdio.h,v 1.66.2.3 2007/08/24 20:07:38 liamjfoy Exp\r
  */\r
-/*  $NetBSD: stdio.h,v 1.66.2.3 2007/08/24 20:07:38 liamjfoy Exp $  */\r
-\r
 #ifndef _STDIO_H_\r
 #define _STDIO_H_\r
 \r
-#include  <sys/EfiCdefs.h>\r
+#include  <stdarg.h>\r
 #include  <limits.h>\r
 #include  <sys/ansi.h>\r
 #include  <machine/ansi.h>\r
 \r
 #ifdef _EFI_SIZE_T_\r
+  /** size_t is the unsigned integer type of the result of the sizeof operator. **/\r
   typedef _EFI_SIZE_T_  size_t;\r
   #undef _EFI_SIZE_T_\r
   #undef _BSD_SIZE_T_\r
 #endif\r
 \r
-/*\r
- * This is fairly grotesque, but pure ANSI code must not inspect the\r
- * innards of an fpos_t anyway.  The library internally uses off_t,\r
- * which we assume is exactly as big as eight chars.\r
- */\r
+/** @{\r
+    An object type capable of holding all information necessary to specify any\r
+    position within a file.\r
+\r
+    Each wide-oriented stream has an associated mbstate_t object that stores the\r
+    current parse state of the stream.  A successful call to fgetpos stores a\r
+    representation of the value of this mbstate_t object as part of the value\r
+    of the fpos_t object.  A later successful call to fsetpos using the same\r
+    stored fpos_t value restores the value of the associated mbstate_t object\r
+    as well as the position within the controlled stream.\r
+\r
+    This is fairly grotesque, but pure ANSI code must not inspect the\r
+    innards of an fpos_t anyway.  The library internally uses off_t,\r
+    which we assume is exactly as big as eight chars.\r
+**/\r
 #if (!defined(_ANSI_SOURCE) && !defined(__STRICT_ANSI__)) || defined(_LIBC)\r
 typedef __off_t fpos_t;\r
 #else\r
@@ -59,14 +184,7 @@ typedef struct __sfpos {
   __off_t _pos;\r
 } fpos_t;\r
 #endif\r
-\r
-#define _FSTDIO     /* Define for new stdio with functions. */\r
-\r
-/*\r
- * NB: to fit things in six character monocase externals, the stdio\r
- * code uses the prefix `__s' for stdio objects, typically followed\r
- * by a three-character attempt at a mnemonic.\r
- */\r
+/*@}*/\r
 \r
 /* stdio buffers */\r
 struct __sbuf {\r
@@ -74,15 +192,14 @@ struct __sbuf {
   int _size;\r
 };\r
 \r
-/*\r
- * stdio state variables.\r
+/** Structure which holds all the information needed to control a stream or file.\r
  *\r
- * The following always hold:\r
+ * The following always hold:<BR>\r
  *\r
- *  if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),\r
- *    _lbfsize is -_bf._size, else _lbfsize is 0\r
- *  if _flags&__SRD, _w is 0\r
- *  if _flags&__SWR, _r is 0\r
+ *  if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),\r
+ *    _lbfsize is -_bf._size, else _lbfsize is 0\r
+ *  if _flags&__SRD, _w is 0\r
+ *  if _flags&__SWR, _r is 0\r
  *\r
  * This ensures that the getc and putc macros (or inline functions) never\r
  * try to write or read from a file that is in `read' or `write' mode.\r
@@ -98,133 +215,295 @@ struct __sbuf {
  * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff\r
  * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.\r
  *\r
- * NB: see WARNING above before changing the layout of this structure!\r
  */\r
 typedef struct __sFILE {\r
-  unsigned char  *_p;         /* current position in (some) buffer */\r
-  int             _r;         /* read space left for getc() */\r
-  int             _w;         /* write space left for putc() */\r
-  unsigned short  _flags;     /* flags, below; this FILE is free if 0 */\r
-  short           _file;      /* fileno, if Unix descriptor, else -1 */\r
-  struct  __sbuf  _bf;        /* the buffer (at least 1 byte, if !NULL) */\r
-  int             _lbfsize;   /* 0 or -_bf._size, for inline putc */\r
+  unsigned char  *_p;         /**< current position in (some) buffer */\r
+  int             _r;         /**< read space left for getc() */\r
+  int             _w;         /**< write space left for putc() */\r
+  unsigned short  _flags;     /**< flags, below; this FILE is free if 0 */\r
+  short           _file;      /**< fileno, if Unix descriptor, else -1 */\r
+  struct  __sbuf  _bf;        /**< the buffer (at least 1 byte, if !NULL) */\r
+  int             _lbfsize;   /**< 0 or -_bf._size, for inline putc */\r
 \r
   /* operations */\r
-  void           *_cookie;    /* cookie passed to io functions */\r
+  void           *_cookie;    /**< cookie passed to io functions */\r
   int           (*_close)(void *);\r
   int           (*_read) (void *, char *, int);\r
   fpos_t        (*_seek) (void *, fpos_t, int);\r
   int           (*_write)(void *, const char *, int);\r
 \r
-  /* file extension */\r
+  /** file extension */\r
   struct  __sbuf  _ext;\r
 \r
-  /* separate buffer for long sequences of ungetc() */\r
-  unsigned char  *_up;        /* saved _p when _p is doing ungetc data */\r
-  int             _ur;        /* saved _r when _r is counting ungetc data */\r
+  /** @{\r
+      Separate buffer for long sequences of ungetc().\r
+  **/\r
+  unsigned char  *_up;        /**< saved _p when _p is doing ungetc data */\r
+  int             _ur;        /**< saved _r when _r is counting ungetc data */\r
+  /*@}*/\r
 \r
   /* tricks to meet minimum requirements even when malloc() fails */\r
-  unsigned char   _ubuf[3];   /* guarantee an ungetc() buffer */\r
-  unsigned char   _nbuf[1];   /* guarantee a getc() buffer */\r
+  unsigned char   _ubuf[3];   /**< guarantee an ungetc() buffer */\r
+  unsigned char   _nbuf[1];   /**< guarantee a getc() buffer */\r
 \r
-  /* separate buffer for fgetln() when line crosses buffer boundary */\r
+  /** separate buffer for fgetln() when line crosses buffer boundary */\r
   struct  __sbuf  _lb;        /* buffer for fgetln() */\r
 \r
   /* Unix stdio files get aligned to block boundaries on fseek() */\r
-  int             _blksize;   /* stat.st_blksize (may be != _bf._size) */\r
-  fpos_t          _offset;    /* current lseek offset */\r
+  int             _blksize;   /**< stat.st_blksize (may be != _bf._size) */\r
+  fpos_t          _offset;    /**< current lseek offset */\r
 } FILE;\r
 \r
 __BEGIN_DECLS\r
 extern FILE   __sF[];\r
 __END_DECLS\r
 \r
-#define __SLBF  0x0001    /* line buffered */\r
-#define __SNBF  0x0002    /* unbuffered */\r
-#define __SRD   0x0004    /* OK to read */\r
-#define __SWR   0x0008    /* OK to write */\r
+#define __SLBF  0x0001    /**< line buffered */\r
+#define __SNBF  0x0002    /**< unbuffered */\r
+#define __SRD   0x0004    /**< OK to read */\r
+#define __SWR   0x0008    /**< OK to write */\r
   /* RD and WR are never simultaneously asserted */\r
-#define __SRW   0x0010    /* open for reading & writing */\r
-#define __SEOF  0x0020    /* found EOF */\r
-#define __SERR  0x0040    /* found error */\r
-#define __SMBF  0x0080    /* _buf is from malloc */\r
-#define __SAPP  0x0100    /* fdopen()ed in append mode */\r
-#define __SSTR  0x0200    /* this is an sprintf/snprintf string */\r
-#define __SOPT  0x0400    /* do fseek() optimization */\r
-#define __SNPT  0x0800    /* do not do fseek() optimization */\r
-#define __SOFF  0x1000    /* set iff _offset is in fact correct */\r
-#define __SMOD  0x2000    /* true => fgetln modified _p text */\r
-#define __SALC  0x4000    /* allocate string space dynamically */\r
+#define __SRW   0x0010    /**< open for reading & writing */\r
+#define __SEOF  0x0020    /**< found EOF */\r
+#define __SERR  0x0040    /**< found error */\r
+#define __SMBF  0x0080    /**< _buf is from malloc */\r
+#define __SAPP  0x0100    /**< fdopen()ed in append mode */\r
+#define __SSTR  0x0200    /**< this is an sprintf/snprintf string */\r
+#define __SOPT  0x0400    /**< do fseek() optimization */\r
+#define __SNPT  0x0800    /**< do not do fseek() optimization */\r
+#define __SOFF  0x1000    /**< set iff _offset is in fact correct */\r
+#define __SMOD  0x2000    /**< true => fgetln modified _p text */\r
+#define __SALC  0x4000    /**< allocate string space dynamically */\r
 \r
-/*\r
- * The following three definitions are for ANSI C, which took them\r
- * from System V, which brilliantly took internal interface macros and\r
- * made them official arguments to setvbuf(), without renaming them.\r
- * Hence, these ugly _IOxxx names are *supposed* to appear in user code.\r
- *\r
- * Although numbered as their counterparts above, the implementation\r
- * does not rely on this.\r
+/*  The following three definitions are for ANSI C, which took them\r
+    from System V, which brilliantly took internal interface macros and\r
+    made them official arguments to setvbuf(), without renaming them.\r
+    Hence, these ugly _IOxxx names are *supposed* to appear in user code.\r
+\r
+    Although numbered as their counterparts above, the implementation\r
+    does not rely on this.\r
  */\r
-#define _IOFBF  0   /* setvbuf should set fully buffered */\r
-#define _IOLBF  1   /* setvbuf should set line buffered */\r
-#define _IONBF  2   /* setvbuf should set unbuffered */\r
+#define _IOFBF  0   /**< setvbuf should set fully buffered */\r
+#define _IOLBF  1   /**< setvbuf should set line buffered */\r
+#define _IONBF  2   /**< setvbuf should set unbuffered */\r
 \r
-#define BUFSIZ  1024    /* size of buffer used by setbuf */\r
-#define EOF     (-1)\r
+#define BUFSIZ  1024    /**< size of buffer used by setbuf */\r
+#define EOF     (-1)    /**< A constant integer expression indicating end-of-file. */\r
 \r
-/*\r
- * FOPEN_MAX is a minimum maximum, and is the number of streams that\r
- * stdio can provide without attempting to allocate further resources\r
- * (which could fail).  Do not use this for anything.\r
+/** FOPEN_MAX is a minimum maximum, and is the number of streams that\r
+    stdio can provide without attempting to allocate further resources\r
+    (which could fail).  Do not use this for anything.\r
  */\r
 #define FOPEN_MAX     OPEN_MAX    /* must be <= OPEN_MAX <sys/syslimits.h> */\r
+\r
+/** Size needed for an array of char large enough to hold the longest file name string. */\r
 #define FILENAME_MAX  PATH_MAX    /* must be <= PATH_MAX <sys/syslimits.h> */\r
 \r
+/** Size needed for an array of char large enough to hold the file name string\r
+    generated by the tmpname() function.\r
+**/\r
 #define L_tmpnam      PATH_MAX    /* must be == PATH_MAX */\r
 \r
 #ifndef TMP_MAX\r
-#define TMP_MAX     308915776 /* Legacy */\r
+#define TMP_MAX     308915776     /**< The maximum number of unique file names\r
+                                       that can be generated by tmpnam(). **/\r
 #endif\r
 \r
 /* Always ensure that these are consistent with <fcntl.h>! */\r
 #ifndef SEEK_SET\r
-#define SEEK_SET  0 /* set file offset to offset */\r
+#define SEEK_SET  0 /**< set file offset to offset */\r
 #endif\r
 #ifndef SEEK_CUR\r
-#define SEEK_CUR  1 /* set file offset to current plus offset */\r
+#define SEEK_CUR  1 /**< set file offset to current plus offset */\r
 #endif\r
 #ifndef SEEK_END\r
-#define SEEK_END  2 /* set file offset to EOF plus offset */\r
+#define SEEK_END  2 /**< set file offset to EOF plus offset */\r
 #endif\r
 \r
-#define stdin   (&__sF[0])\r
-#define stdout  (&__sF[1])\r
-#define stderr  (&__sF[2])\r
+#define stdin   (&__sF[0])    /**< FILE reference for the STanDard INput stream. */\r
+#define stdout  (&__sF[1])    /**< FILE reference for the STanDard OUTput stream. */\r
+#define stderr  (&__sF[2])    /**< FILE reference for the STanDard ERRor stream. */\r
 \r
-/*\r
- * Functions defined in ANSI C standard.\r
- */\r
 __BEGIN_DECLS\r
-void      clearerr(FILE *);\r
-int       fclose  (FILE *);\r
-int       feof    (FILE *);\r
-int       ferror  (FILE *);\r
-int       fflush  (FILE *);\r
-int       fgetc   (FILE *);\r
-int       fgetpos (FILE * __restrict, fpos_t * __restrict);\r
-char     *fgets   (char * __restrict, int, FILE * __restrict);\r
-FILE     *fopen   (const char * __restrict , const char * __restrict);\r
+/* Functions defined in C95 standard. ###################################### */\r
+\r
+/* ################ Operations on files.   */\r
+\r
+/** Remove (delete) a file.\r
+\r
+    @param[in]    FileName    The path to the file to be removed.\r
+\r
+    @retval   Zero      The operation succeeded.\r
+    @retval   Non-zero  The operation failed.\r
+**/\r
+int       remove  (const char *FileName);\r
+\r
+/** Rename the file named OldName to NewName.\r
+\r
+    @param[in]  OldName   The name of the existing file to be renamed.\r
+    @param[in]  NewName   The new name of the file.\r
+\r
+    @retval   Zero      The operation succeeded.\r
+    @retval   Non-zero  The operation failed.  OldName still exists and has been unmodified.\r
+                        If OldName does not exist, or a file named NewName already exists,\r
+                        rename() will fail are return a non-zero value.\r
+**/\r
+int       rename  (const char *OldName, const char *NewName);\r
+\r
+/** Create a guaranteed unique temporary file.\r
+    A binary file is created in the _PATH_TMP directory that is guaranteed to\r
+    have a unique name.  The file will be open for update with mode "wb+" and\r
+    its FILE pointer returned upon successfull completion.  When the file is\r
+    closed, or when the creating program terminates, the file will be removed.\r
+\r
+    @retval   NULL      The temporary file could not be created.\r
+    @retval   non-NULL  The returned value is a pointer to the FILE object\r
+                        associated with the newly created and open temporary file.\r
+**/\r
+FILE     *tmpfile (void);\r
+\r
+/** Generate a string that is a valid file name, in the _PATH_TMP directory, that\r
+    is not the same as the name of an existing file.  The function can potentially\r
+    generate up to TMP_MAX different strings.\r
+\r
+    @param[out]   Buffer    A pointer to an array of at least L_tmpnam char elements.\r
+                            or NULL.  If non-NULL, the tmpnam function writes its\r
+                            result into that array and returns the argument\r
+                            as its value.\r
+\r
+    @return       If no suitable string can be generated a NULL pointer is returned.\r
+                  Otherwise, if Buffer is NULL, the result is produced in an internal\r
+                  static object and a pointer to that object is returned.  If Buffer\r
+                  is non-null, the results are written into the array pointed to by\r
+                  Buffer and Buffer is returned.\r
+**/\r
+char     *tmpnam  (char *Buffer);\r
+\r
+/* ################ File access functions.   */\r
+\r
+/** Close the open stream, specified by fp, and de-associate it from any file or device.\r
+\r
+    @param[in]    fp    Pointer to a stream object, of type FILE, associated with a\r
+                        file or device.\r
+\r
+    @retval   Zero      The stream was successfully closed.\r
+    @retval   Non-zero  There was an error closing the stream.\r
+**/\r
+int       fclose  (FILE *fp);\r
+\r
+/** Empties any buffers associated with the stream specified by fp.\r
+\r
+    @param[in]    fp    Pointer to a stream object, of type FILE, associated with a\r
+                        file or device.\r
+\r
+    @retval   Zero      The stream's buffers were successfully emptied.\r
+    @retval   EOF       There was an error writing to the stream.\r
+**/\r
+int       fflush  (FILE *fp);\r
+\r
+/** Associates a file, named by Path, with a stream and prepares it for subsequent\r
+    operations.\r
+\r
+    The parameter Mode points to a string specifying behavior characteristics for\r
+    the opened file.  The recognized Mode strings are:\r
+      - r     Open text file for reading.\r
+      - w     Truncate file to zero length or create text file for writing.\r
+      - a     Open or create a text file for writing at end-of-file (append).\r
+      - rb    Open binary file for reading.\r
+      - wb    Truncate file to zero length or create binary file for writing.\r
+      - ab    Open or create a binary file for writing at end-of-file (append).\r
+      - r+    Open text file for update (reading and writing).\r
+      - w+    Truncate file to zero length or create text file for update.\r
+      - a+    Open or create a text file for update, writing at end-of-file.\r
+      - r+b or rb+  Open binary file for update (reading and writing).\r
+      - w+b or wb+  Truncate file to zero length or create binary file for update.\r
+      - a+b or ab+  Open or create a binary file for update, writing at end-of-file.\r
+\r
+      Opening a file with read mode fails if the file does not exist.\r
+\r
+      Opening a file with append mode causes all writes to the file to be forced to\r
+      the current end-of-file, regardless of any intervening calls to fseek.\r
+\r
+    @param[in]    Path    The path or name of the file or device to open.\r
+    @param[in]    Mode    The mode in which the file is to be opened.\r
+\r
+    @return     A pointer to a FILE object associated with the opened file is returned\r
+                if the file was opened successfully.  Otherwise, NULL is returned.\r
+**/\r
+FILE     *fopen   (const char * __restrict Path, const char * __restrict Mode);\r
+\r
+/** Closes the file associated with Ofp then opens the file specified by Path and associates it with\r
+    stream Ofp.\r
+\r
+    Any errors that occur when closing Ofp are ignored.  The file specified by Path is opened with mode Mode\r
+    and associated with stream Ofp instead of producing a new stream object.\r
+\r
+    If Path is NULL, the mode of the file associated with Ofp is changed to Mode.\r
+\r
+    @param[in]    Path    The path or name of the file or device to open.\r
+    @param[in]    Mode    The mode in which the file is to be opened.\r
+    @param[in]    Ofp     Pointer to the FILE object to be closed and associated with the new file.\r
+\r
+    @return       If Path was not able to be opened, or the mode changed, NULL is returned;\r
+                  otherwise Ofp is returned.\r
+**/\r
+FILE     *freopen (const char * __restrict Path, const char * __restrict Mode, FILE * __restrict Ofp);\r
+\r
+/** Establishes Fully Buffered or Non-buffered mode for a stream, fp, using Buff as the buffer.\r
+\r
+    The file associated with fp must have been successfully opened with no operations, other than\r
+    possibly an unsuccessful call to setvbuf, performed prior to the call to setbuf.\r
+\r
+    If Buff is non-NULL, the stream associated with fp is set to Fully Buffered mode using the\r
+    array pointed to by Buff as the buffer.  The buffer is assumed to be BUFSIZ char long.\r
+    This is equivalent to calling setvbuf(fp, Buff, _IOFBF, BUFSIZ);\r
+\r
+    If Buff is NULL, stream fp is set to Non-buffered mode.\r
+    This is equivalent to calling setvbuf(fp, NULL, _IONBF, 0);\r
+\r
+    @param[in]  fp      Pointer to the FILE object which will have its buffer set.\r
+    @param[in]  Buff    The buffer to use for fp, or NULL.\r
+**/\r
+void      setbuf  (FILE * __restrict fp, char * __restrict Buff);\r
+\r
+/** Establishes a buffering mode and buffer for use by operations performed on the file associated with fp.\r
+\r
+    The file associated with fp must have been successfully opened with no operations, other than\r
+    possibly an unsuccessful call to setvbuf, performed prior to the call to setbuf.\r
+\r
+    Parameter BufMode determines how stream fp will be buffered:\r
+      - _IOFBF causes I/O to be fully buffered.\r
+      - _IOLBF causes I/O to be line buffered.\r
+      - _IONBF causes I/O to be unbuffered.\r
+\r
+    If Buff is not NULL, it points to an array to be used as an I/O buffer for stream fp.  The\r
+    buffer is set to BufSize char in length.  Otherwise, an array of BufSize char is allocated\r
+    by the setvbuf function if BufMode is not _IONBF.\r
+\r
+    It is an error for BufSize to be zero unless BufMode is _IONBF, in which case BufSize is ignored.\r
+\r
+    @param[in]  fp        Pointer to the FILE object which will have its buffer set.\r
+    @param[in]  Buff      The buffer to use for fp, or NULL.\r
+    @param[in]  BufMode   The buffering mode to use.\r
+    @param[in]  BufSize   The size of the buffer to use, specified in char.\r
+\r
+    @retval   Zero      The buffer and mode were established successfully.\r
+    @retval   Non-zero  The request can not be honored, or an invalid value for BufMode was given.\r
+**/\r
+int       setvbuf (FILE * __restrict fp, char * __restrict Buff, int BufMode, size_t BufSize);\r
+\r
+/* ################ Formatted Input/Output Functions.  */\r
 \r
 /** The fprintf function writes output to the stream pointed to by stream,\r
     under control of the string pointed to by format that specifies how\r
     subsequent arguments are converted for output. If there are insufficient\r
-    arguments for the format, the behavior is undefined. If the format is\r
+    arguments for the format, the behavior is indeterminate. If the format is\r
     exhausted while arguments remain, the excess arguments are evaluated\r
     (as always) but are otherwise ignored. The fprintf function returns when\r
     the end of the format string is encountered.\r
 \r
-    The format shall be a multibyte character sequence, beginning and ending in\r
-    its initial shift state. The format is composed of zero or more directives:\r
+    The format is interpreted as a multibyte character sequence, beginning and ending\r
+    in its initial shift state. The format is composed of zero or more directives:\r
     ordinary multibyte characters (not %), which are copied unchanged to the\r
     output stream; and conversion specifications, each of which results in\r
     fetching zero or more subsequent arguments, converting them, if applicable,\r
@@ -248,8 +527,8 @@ FILE     *fopen   (const char * __restrict , const char * __restrict);
         conversions. The precision takes the form of a period (.) followed\r
         either by an asterisk * (described later) or by an optional decimal\r
         integer; if only the period is specified, the precision is taken as\r
-        zero. If a precision appears with any other conversion specifier, the\r
-        behavior is undefined.\r
+        zero. If a precision appears with any other conversion specifier, it\r
+        is ignored.\r
       - An optional length modifier that specifies the size of the argument.\r
       - A conversion specifier character that specifies the type of conversion\r
         to be applied.\r
@@ -259,7 +538,7 @@ FILE     *fopen   (const char * __restrict , const char * __restrict);
     precision. The arguments specifying field width, or precision, or both, shall\r
     appear (in that order) before the argument (if any) to be converted. A negative\r
     field width argument is taken as a - flag followed by a positive field width.\r
-    A negative precision argument is taken as if the precision were omitted.\r
+    A negative precision argument is interpreted as if the precision were omitted.\r
 \r
     The flag characters and their meanings are:\r
       -     The result of the conversion is left-justified within the field.\r
@@ -271,24 +550,24 @@ FILE     *fopen   (const char * __restrict , const char * __restrict);
             if a signed conversion results in no characters, a space is\r
             prefixed to the result. If the space and + flags both appear, the\r
             space flag is ignored.\r
-      #     The result is converted to an "alternative form". For o\r
-            conversion, it increases the precision, if and only if necessary,\r
-            to force the first digit of the result to be a zero (if the value\r
-            and precision are both 0, a single 0 is printed). For x (or X)\r
-            conversion, a nonzero result has 0x (or 0X) prefixed to it. For e,\r
-            E, f, F, g, and G conversions, the result of converting a\r
-            floating-point number always contains a decimal-point character,\r
-            even if no digits follow it. (Normally, a decimal-point character\r
-            appears in the result of these conversions only if a digit follows\r
-            it.) For g and G conversions, trailing zeros are not removed from\r
-            the result. For other conversions, the behavior is undefined.\r
+      #     The result is converted to an "alternative form".\r
+              - For o conversion, it increases the precision, if and only if necessary,\r
+                to force the first digit of the result to be a zero (if the value\r
+                and precision are both 0, a single 0 is printed).\r
+              - For x (or X) conversion, a nonzero result has 0x (or 0X) prefixed to it.\r
+              - For e, E, f, F, g, and G conversions, the result of converting a\r
+                floating-point number always contains a decimal-point character,\r
+                even if no digits follow it. (Normally, a decimal-point character\r
+                appears in the result of these conversions only if a digit follows\r
+                it.)\r
+              - For g and G conversions, trailing zeros are not removed from\r
+                the result. For other conversions, it is ignored.\r
       0     For d, i, o, u, x, X, e, E, f, F, g, and G conversions, leading\r
             zeros (following any indication of sign or base) are used to pad to\r
             the field width rather than performing space padding, except when\r
             converting an infinity or NaN. If the 0 and - flags both appear,\r
             the 0 flag is ignored. For d, i, o, u, x, and X conversions, if a\r
-            precision is specified, the 0 flag is ignored. For other\r
-            conversions, the behavior is undefined.\r
+            precision is specified, the 0 flag is ignored.\r
 \r
     The length modifiers and their meanings are:\r
       hh    Specifies that a following d, i, o, u, x, or X conversion specifier\r
@@ -329,7 +608,7 @@ FILE     *fopen   (const char * __restrict , const char * __restrict);
             applies to a long double argument.\r
 \r
     If a length modifier appears with any conversion specifier other than as\r
-    specified above, the behavior is undefined.\r
+    specified above, it is ignored.\r
 \r
     The conversion specifiers and their meanings are:\r
       d,i       The int argument is converted to signed decimal in the style\r
@@ -354,12 +633,9 @@ FILE     *fopen   (const char * __restrict , const char * __restrict);
             decimal-point character appears. If a decimal-point character\r
             appears, at least one digit appears before it. The value is rounded\r
             to the appropriate number of digits.\r
-                A double argument representing an infinity is converted in one\r
-            of the styles [-]inf or [-]infinity - which style is\r
-            implementation-defined. A double argument representing a NaN is\r
-            converted in one of the styles [-]nan or [-]nan(n-char-sequence)\r
-            - which style, and the meaning of any n-char-sequence, is\r
-            implementation-defined. The F conversion specifier produces INF,\r
+                A double argument representing an infinity is converted in\r
+            the style [-]inf. A double argument representing a NaN is\r
+            converted in the style [-]nan. The F conversion specifier produces INF,\r
             INFINITY, or NAN instead of inf, infinity, or nan, respectively.\r
       e,E       A double argument representing a floating-point number is\r
             converted in the style [-]d.ddd e[+-]dd, where there is one digit\r
@@ -423,13 +699,12 @@ FILE     *fopen   (const char * __restrict , const char * __restrict);
             past the end of the array. In no case is a partial multibyte\r
             character written.\r
       p         The argument shall be a pointer to void. The value of the\r
-            pointer is converted to a sequence of printing characters, in an\r
-            implementation-defined manner.\r
+            pointer is converted to a sequence of printing characters.\r
       n         The argument shall be a pointer to signed integer into which is\r
             written the number of characters written to the output stream so\r
             far by this call to fprintf. No argument is converted, but one is\r
             consumed. If the conversion specification includes any flags, a\r
-            field width, or a precision, the behavior is undefined.\r
+            field width, or a precision, they will be ignored.\r
       %         A % character is written. No argument is converted. The\r
             complete conversion specification shall be %%.\r
 \r
@@ -438,139 +713,791 @@ FILE     *fopen   (const char * __restrict , const char * __restrict);
     field is expanded to contain the conversion result.\r
 \r
     @param[in]  stream    An open File specifier to which the output is sent.\r
+    @param[in]  format    A multi-byte character sequence containing characters\r
+                          to be copied unchanged, and conversion specifiers\r
+                          which convert their associated arguments.\r
+    @param      ...       Variable number of parameters as required by format.\r
+\r
+    @return     The fprintf function returns the number of characters\r
+                transmitted, or a negative value if an output or encoding\r
+                error occurred.\r
+**/\r
+int       fprintf (FILE * __restrict stream, const char * __restrict format, ...);\r
+\r
+/** Reads characters from stream, under control of format, storing the converted values\r
+    in variables pointed to by the variable-length parameter list.\r
+\r
+    The format is interpreted as a multibyte character sequence, beginning and ending\r
+    in its initial shift state. The format is composed of zero or more directives:\r
+    one or more white-space characters, an ordinary multibyte character\r
+    (neither % nor a white-space character), or a conversion specification.\r
+\r
+    Each conversion specification is introduced by the character %. After\r
+    the %, the following appear in sequence:\r
+      - An optional assignment-suppressing character, *.\r
+      - An optional decimal integer, greater than zero, that specifies the\r
+        maximum field width (in characters).\r
+      - An optional length modifier that specifies the size of the receiving object.\r
+      - A conversion specifier character that specifies the type of conversion\r
+        to be applied.\r
+\r
+    The fscanf function executes each directive of the format in turn. If a directive fails, as\r
+    detailed below, the function returns. Failures are described as input failures (due to the\r
+    occurrence of an encoding error or the unavailability of input characters), or matching\r
+    failures (due to inappropriate input).\r
+\r
+    A directive composed of white-space character(s) is executed by reading input up to the\r
+    first non-white-space character (which remains unread), or until no more characters can\r
+    be read.\r
+\r
+    A directive that is an ordinary multibyte character is executed by reading the next\r
+    characters of the stream. If any of those characters differ from the ones composing the\r
+    directive, the directive fails and the differing and subsequent characters remain unread.\r
+    Similarly, if end-of-file, an encoding error, or a read error prevents a character from being\r
+    read, the directive fails.\r
+\r
+    The length modifiers and their meanings are:\r
+      - hh            Specifies that a following d, i, o, u, x, X, or n conversion\r
+                      specifier applies to an argument with type pointer to signed\r
+                      char or unsigned char.\r
+      - h             Specifies that a following d, i, o, u, x, X, or n conversion\r
+                      specifier applies to an argument with type pointer to short\r
+                      int or unsigned short int.\r
+      - l (ell)       Specifies that a following d, i, o, u, x, X, or n conversion\r
+                      specifier applies to an argument with type pointer to\r
+                      long int or unsigned long int; that a following a, A, e,\r
+                      E, f, F, g, or G conversion specifier applies to an\r
+                      argument with type pointer to double; or that a following\r
+                      c, s, or [ conversion specifier applies to an argument\r
+                      with type pointer to wchar_t.\r
+      - ll (ell-ell)  Specifies that a following d, i, o, u, x, X, or n conversion\r
+                      specifier applies to an argument with type pointer to\r
+                      long long int or unsigned long long int.\r
+      - j             Specifies that a following d, i, o, u, x, X, or n conversion\r
+                      specifier applies to an argument with type pointer to\r
+                      intmax_t or uintmax_t.\r
+      - z             Specifies that a following d, i, o, u, x, X, or n conversion\r
+                      specifier applies to an argument with type pointer to\r
+                      size_t or the corresponding signed integer type.\r
+      - t             Specifies that a following d, i, o, u, x, X, or n conversion\r
+                      specifier applies to an argument with type pointer to\r
+                      ptrdiff_t or the corresponding unsigned integer type.\r
+      - L             Specifies that a following e, E, f, F, g, or G\r
+                      conversion specifier applies to an argument with type\r
+                      pointer to long double.\r
+\r
+    If a length modifier appears with any conversion specifier other than as specified above,\r
+    it will be ignored.\r
+\r
+    The conversion specifiers and their meanings are:\r
+      - d       Matches an optionally signed decimal integer, whose format is\r
+                the same as expected for the subject sequence of the strtol\r
+                function with the value 10 for the base argument. The\r
+                corresponding argument shall be a pointer to signed integer.\r
+      - i       Matches an optionally signed integer, whose format is the same\r
+                as expected for the subject sequence of the strtol function\r
+                with the value 0 for the base argument. The corresponding\r
+                argument shall be a pointer to signed integer.\r
+      - o       Matches an optionally signed octal integer, whose format is the\r
+                same as expected for the subject sequence of the strtoul\r
+                function with the value 8 for the base argument. The\r
+                corresponding argument shall be a pointer to unsigned integer.\r
+      - u       Matches an optionally signed decimal integer, whose format is\r
+                the same as expected for the subject sequence of the strtoul\r
+                function with the value 10 for the base argument. The\r
+                corresponding argument shall be a pointer to unsigned integer.\r
+      - x       Matches an optionally signed hexadecimal integer, whose format\r
+                is the same as expected for the subject sequence of the strtoul\r
+                function with the value 16 for the base argument. The\r
+                corresponding argument shall be a pointer to unsigned integer.\r
+      - e,f,g   Matches an optionally signed floating-point number, infinity,\r
+                or NaN, whose format is the same as expected for the subject\r
+                sequence of the strtod function. The corresponding argument\r
+                shall be a pointer to floating.\r
+      - c       Matches a sequence of characters of exactly the number\r
+                specified by the field width (1 if no field width is present\r
+                in the directive).  If no l length modifier is present, the\r
+                corresponding argument shall be a pointer to the initial\r
+                element of a character array large enough to accept the\r
+                sequence. No null character is added.<BR><BR>\r
+                If an l length modifier is present, the input shall be a\r
+                sequence of multibyte characters that begins in the initial\r
+                shift state. Each multibyte character in the sequence is\r
+                converted to a wide character as if by a call to the mbrtowc\r
+                function, with the conversion state described by an mbstate_t\r
+                object initialized to zero before the first multibyte character\r
+                is converted. The corresponding argument shall be a pointer to\r
+                the initial element of an array of wchar_t large enough to\r
+                accept the resulting sequence of wide characters.  No null wide\r
+                character is added.\r
+      - s       Matches a sequence of non-white-space characters.\r
+                If no l length modifier is present, the corresponding argument\r
+                shall be a pointer to the initial element of a character array\r
+                large enough to accept the sequence and a terminating null\r
+                character, which will be added automatically.  If an l length\r
+                modifier is present, the input shall be a sequence of multibyte\r
+                characters that begins in the initial shift state. Each\r
+                multibyte character is converted to a wide character as if by a\r
+                call to the mbrtowc function, with the conversion state\r
+                described by an mbstate_t object initialized to zero before the\r
+                first multibyte character is converted. The corresponding\r
+                argument shall be a pointer to the initial element of an array\r
+                of wchar_t large enough to accept the sequence and the\r
+                terminating null wide character, which will be added automatically.\r
+      - [       Matches a nonempty sequence of characters from a set of\r
+                expected characters (the scanset).<BR><BR>\r
+                If no l length modifier is present, the corresponding argument\r
+                shall be a pointer to the initial element of a character array\r
+                large enough to accept the sequence and a terminating null\r
+                character, which will be added automatically.  If an l length\r
+                modifier is present, the input shall be a sequence of multibyte\r
+                characters that begins in the initial shift state. Each\r
+                multibyte character is converted to a wide character as if by a\r
+                call to the mbrtowc function, with the conversion state\r
+                described by an mbstate_t object initialized to zero before the\r
+                first multibyte character is converted. The corresponding\r
+                argument shall be a pointer to the initial element of an array\r
+                of wchar_t large enough to accept the sequence and the\r
+                terminating null wide character, which will be added\r
+                automatically.<BR><BR>\r
+                The conversion specifier includes all subsequent characters in\r
+                the format string, up to and including the matching right\r
+                bracket (]). The characters between the brackets (the scanlist)\r
+                compose the scanset, unless the character after the left\r
+                bracket is a circumflex (^), in which case the scanset contains\r
+                all characters that do not appear in the scanlist between the\r
+                circumflex and the right bracket. If the conversion specifier\r
+                begins with [] or [^], the right bracket character is in the\r
+                scanlist and the next following right bracket character is the\r
+                matching right bracket that ends the specification; otherwise\r
+                the first following right bracket character is the one that\r
+                ends the specification. If a - character is in the scanlist and\r
+                is not the first, nor the second where the first character is\r
+                a ^, nor the last character, it will be treated as a regular character.\r
+      - p       Matches a set of sequences, which are the same as the set of\r
+                sequences that are produced by the %p conversion of the fprintf\r
+                function. The corresponding argument must be a pointer to a\r
+                pointer to void. The input item is converted to a pointer value.\r
+                If the input item is a value converted earlier during the same\r
+                program execution, the pointer that results will compare equal\r
+                to that value; otherwise the behavior of the %p conversion is\r
+                indeterminate.\r
+      - n       No input is consumed. The corresponding argument shall be a\r
+                pointer to signed integer into which is to be written the\r
+                number of characters read from the input stream so far by this\r
+                call to the fscanf function. Execution of a %n directive does\r
+                not increment the assignment count returned at the completion\r
+                of execution of the fscanf function. No argument is converted,\r
+                but one is consumed. If the conversion specification includes\r
+                an assignment suppressing character the conversion specification\r
+                is ignored.  If the conversion specification contains a\r
+                field width, the field width will be ignored.\r
+      - %       Matches a single % character; no conversion or assignment occurs.\r
+\r
+    @param[in]  stream    An open File specifier from which the input is read.\r
+    @param[in]  format    A multi-byte character sequence containing characters\r
+                          to be matched against, and conversion specifiers\r
+                          which convert their associated arguments.  Converted\r
+                          items are stored according to their associated arguments.\r
+    @param      ...       Variable number of parameters, as required by format,\r
+                          specifying the objects to receive the converted input.\r
+\r
+    @return     The fscanf function returns EOF if an input failure occurs before\r
+                any conversion.  Otherwise the number of input items assigned\r
+                is returned; which can be fewer than provided for, or even zero\r
+                in the event of an early matching failure.\r
+**/\r
+int       fscanf  (FILE * __restrict stream, const char * __restrict format, ...);\r
+\r
+/** Formatted print to stdout.\r
+\r
+    The printf function is equivalent to fprintf with stdout used as the output stream.\r
+\r
     @param[in]  format    A multi-byte character sequence containing characters\r
                           to be copied unchanged, and conversion specifiers\r
                           which convert their associated arguments.  Copied and\r
                           converted characters are sent to the output stream.\r
     @param      ...       Variable number of parameters as required by format.\r
 \r
-    @return     The fprintf function returns the number of characters\r
+    @return     The printf function returns the number of characters\r
                 transmitted, or a negative value if an output or encoding\r
                 error occurred.\r
+**/\r
+int       printf  (const char * __restrict format, ...);\r
+\r
+/** Formatted input from stdin.\r
 \r
+    The scanf function is equivalent to fscanf with stdin used as the input stream.\r
+\r
+    @param[in]  format    A multi-byte character sequence containing characters\r
+                          to be matched against, and conversion specifiers\r
+                          which convert their associated arguments.  Converted\r
+                          items are stored according to their associated arguments.\r
+    @param[out] ...       Variable number of parameters, as required by format,\r
+                          specifying the objects to receive the converted input.\r
+\r
+    @return     The scanf function returns EOF if an input failure occurs before\r
+                any conversion.  Otherwise the number of input items assigned\r
+                is returned; which can be fewer than provided for, or even zero\r
+                in the event of an early matching failure.\r
 **/\r
-int       fprintf (FILE * __restrict stream, const char * __restrict format, ...);\r
+int       scanf   (const char * __restrict format, ...);\r
+\r
+/** Formatted output to a buffer.\r
+\r
+    The sprintf function is equivalent to fprintf, except that the output is\r
+    written into array Buff instead of to a stream.  A null character is written\r
+    at the end of the characters written; it is not counted as part of the\r
+    returned value.\r
+\r
+    @param[out]   Buff      A pointer to the array to receive the formatted output.\r
+    @param[in]    Format    A multi-byte character sequence containing characters\r
+                            to be copied unchanged, and conversion specifiers\r
+                            which convert their associated arguments.  Copied and\r
+                            converted characters are written to the array pointed\r
+                            to by Buff.\r
+    @param        ...       Variable number of parameters as required by format.\r
+\r
+    @return   The sprintf function returns the number of characters written in\r
+              the array, not counting the terminating null character, or a\r
+              negative value if an encoding error occurred.\r
+**/\r
+int       sprintf (char * __restrict Buff, const char * __restrict Format, ...);\r
+\r
+/** Formatted input from a string.\r
+\r
+    The sscanf function is equivalent to fscanf, except that input is obtained\r
+    from a string rather than from a stream.  Reaching the end of the string\r
+    is equivalent to encountering end-of-file for the fscanf function.\r
+\r
+    @param[in]  Buff      Pointer to the string from which to obtain input.\r
+    @param[in]  Format    A multi-byte character sequence containing characters\r
+                          to be matched against, and conversion specifiers\r
+                          which convert their associated arguments.  Converted\r
+                          items are stored according to their associated arguments.\r
+    @param[out] ...       Variable number of parameters, as required by format,\r
+                          specifying the objects to receive the converted input.\r
+\r
+    @return     The scanf function returns EOF if an input failure occurs before\r
+                any conversion.  Otherwise the number of input items assigned\r
+                is returned; which can be fewer than provided for, or even zero\r
+                in the event of an early matching failure.\r
+**/\r
+int       sscanf  (const char * __restrict Buff, const char * __restrict Format, ...);\r
+\r
+/** Print formatted values from an argument list.\r
+\r
+    The vfprintf function is equivalent to fprintf, with the variable argument\r
+    list replaced by Args, which must have been initialized by the va_start macro.\r
+    The vfprintf function does not invoke the va_end macro.\r
+\r
+    @param[in]  Stream    The output stream to receive the formatted output.\r
+    @param[in]  Format    A multi-byte character sequence containing characters\r
+                          to be matched against, and conversion specifiers\r
+                          which convert their associated arguments.  Converted\r
+                          items are stored according to their associated arguments.\r
+    @param[in]  Args      A list of arguments, initialized by the va_start macro\r
+                          and accessed using the va_arg macro, used to satisfy\r
+                          the directives in the Format string.\r
+\r
+    @return   The vfprintf function returns the number of characters transmitted,\r
+              or a negative value if an output or encoding error occurred.\r
+**/\r
+int       vfprintf(FILE * __restrict Stream, const char * __restrict Format, va_list Args);\r
+\r
+/** Formatted print, to stdout, from an argument list.\r
+\r
+    The vprintf function is equivalent to printf, with the variable argument\r
+    list replaced by Args, which must have been initialized by the va_start\r
+    macro (and possibly subsequent va_arg calls). The vprintf function does\r
+    not invoke the va_end macro.\r
+\r
+    @param[in]  Format    A multi-byte character sequence containing characters\r
+                          to be matched against, and conversion specifiers\r
+                          which convert their associated arguments.  Converted\r
+                          items are stored according to their associated arguments.\r
+    @param[in]  Args      A list of arguments, initialized by the va_start macro\r
+                          and accessed using the va_arg macro, used to satisfy\r
+                          the directives in the Format string.\r
+\r
+    @return   The vprintf function returns the number of characters transmitted,\r
+              or a negative value if an output or encoding error occurred.\r
+**/\r
+int       vprintf (const char * __restrict Format, va_list Args);\r
 \r
-int       fputc   (int, FILE *);\r
-int       fputs   (const char * __restrict, FILE * __restrict);\r
-size_t    fread   (void * __restrict, size_t, size_t, FILE * __restrict);\r
-FILE     *freopen (const char * __restrict, const char * __restrict, FILE * __restrict);\r
-int       fscanf  (FILE * __restrict, const char * __restrict, ...);\r
-int       fseek   (FILE *, long, int);\r
-int       fsetpos (FILE *, const fpos_t *);\r
-long      ftell   (FILE *);\r
-size_t    fwrite  (const void * __restrict, size_t, size_t, FILE * __restrict);\r
+/** Formatted print, to a buffer, from an argument list.\r
+\r
+    The vsprintf function is equivalent to sprintf, with the variable argument\r
+    list replaced by Args, which must have been initialized by the va_start\r
+    macro. The vsprintf function does not invoke the va_end macro.\r
+\r
+    @param[out]   Buff      A pointer to the array to receive the formatted output.\r
+    @param[in]    Format    A multi-byte character sequence containing characters\r
+                            to be copied unchanged, and conversion specifiers\r
+                            which convert their associated arguments.  Copied and\r
+                            converted characters are written to the array pointed\r
+                            to by Buff.\r
+    @param[in]    Args      A list of arguments, initialized by the va_start macro\r
+                            and accessed using the va_arg macro, used to satisfy\r
+                            the directives in the Format string.\r
+\r
+    @return   The vsprintf function returns the number of characters written in\r
+              the array, not counting the terminating null character, or a\r
+              negative value if an encoding error occurred.\r
+**/\r
+int       vsprintf(char * __restrict Buff, const char * __restrict Format, va_list Args);\r
+\r
+/* ################ Character Input/Output Functions. */\r
+\r
+/** Get a character from an input Stream.\r
+\r
+    If the end-of-file indicator for the input stream pointed to by Stream is\r
+    not set, and a next character is present, the fgetc function obtains that\r
+    character as an unsigned char converted to an int and advances the\r
+    associated file position indicator for the stream.\r
+\r
+    @param[in]  Stream    An input stream from which to obtain a character.\r
+\r
+    @return   If the end-of-file indicator for the stream is set, or if the\r
+              stream is at end-of-file, the end-of-file indicator for the\r
+              stream is set and the fgetc function returns EOF.  Otherwise,\r
+              the fgetc function returns the next character from the input\r
+              stream pointed to by Stream.  If a read error occurs, the\r
+              error indicator for the stream is set and the fgetc function\r
+              returns EOF.\r
+**/\r
+int       fgetc   (FILE *Stream);\r
+\r
+/** Read a string from an input stream into a buffer.\r
+\r
+    The fgets function reads at most one less than the number of characters\r
+    specified by Limit from the stream pointed to by Stream into the array\r
+    pointed to by Buff.  No additional characters are read after a\r
+    new-line character (which is retained) or after end-of-file.  A null\r
+    character is written immediately after the last character read into the array.\r
+\r
+    @param[out] Buff      A pointer to the array to receive the input string.\r
+    @param[in]  Limit     The maximum number of characters to put into Buff,\r
+                          including the terminating null character.\r
+    @param[in]  Stream    An input stream from which to obtain a character.\r
+\r
+    @return   The fgets function returns Buff if successful. If end-of-file is\r
+              encountered and no characters have been read into the array, the\r
+              contents of the array remain unchanged and a null pointer is\r
+              returned. If a read error occurs during the operation, the array\r
+              contents are indeterminate and a null pointer is returned.\r
+**/\r
+char     *fgets   (char * __restrict Buff, int Limit, FILE * __restrict Stream);\r
+\r
+/** Write a character to an output stream.\r
+\r
+    The fputc function writes the character specified by C (converted to an\r
+    unsigned char) to the output stream pointed to by Stream, at the position\r
+    indicated by the associated file position indicator for the stream\r
+    (if defined), and advances the indicator appropriately. If the file cannot\r
+    support positioning requests, or if the stream was opened with append mode,\r
+    the character is appended to the output stream.\r
+\r
+    @param[in]  C       The character to be written to Stream.\r
+    @param[in]  Stream  The output stream that C is to be written to.\r
+\r
+    @return   The fputc function returns the character written. If a write\r
+              error occurs, the error indicator for the stream is set and\r
+              fputc returns EOF.\r
+**/\r
+int       fputc   (int C, FILE *Stream);\r
+\r
+/** Write a string to an output stream.\r
+\r
+    The fputs function writes String to the stream pointed to by Stream.  The\r
+    terminating null character is not written.\r
+\r
+    @param[in]  String  The character string to be written to Stream.\r
+    @param[in]  Stream  The output stream that String is to be written to.\r
+\r
+    @return   The fputs function returns EOF if a write error occurs; otherwise\r
+              it returns a non-negative value.\r
+**/\r
+int       fputs   (const char * __restrict String, FILE * __restrict Stream);\r
+\r
+/** Get a character from an input stream.\r
+\r
+    The getc function is equivalent to fgetc, except that if it is implemented\r
+    as a macro, it may evaluate stream more than once, so the argument should\r
+    never be an expression with side effects.\r
+\r
+    @param[in]  Stream    An input stream from which to obtain a character.\r
+\r
+    @return   If the end-of-file indicator for the stream is set, or if the\r
+              stream is at end-of-file, the end-of-file indicator for the\r
+              stream is set and getc returns EOF.  Otherwise, getc returns\r
+              the next character from the input stream pointed to by Stream.\r
+              If a read error occurs, the error indicator for the stream is set\r
+              and getc returns EOF.\r
+**/\r
 int       getc    (FILE *);\r
+\r
+/** Get a character from stdin.\r
+\r
+    The getchar function is equivalent to getc with the argument stdin.\r
+\r
+    @return   If the end-of-file indicator for stdin is set, or if stdin\r
+              is at end-of-file, the end-of-file indicator is set and getchar\r
+              returns EOF.  Otherwise, getchar returns the next character from\r
+              stdin.  If a read error occurs, the error indicator for stdin is\r
+              set and getchar returns EOF.\r
+**/\r
 int       getchar (void);\r
-void      perror  (const char *);\r
-int       printf  (const char * __restrict, ...);\r
-int       putc    (int, FILE *);\r
-int       putchar (int);\r
-int       puts    (const char *);\r
-int       remove  (const char *);\r
-void      rewind  (FILE *);\r
-int       scanf   (const char * __restrict, ...);\r
-void      setbuf  (FILE * __restrict, char * __restrict);\r
-int       setvbuf (FILE * __restrict, char * __restrict, int, size_t);\r
-int       sscanf  (const char * __restrict, const char * __restrict, ...);\r
-FILE     *tmpfile (void);\r
-int       ungetc  (int, FILE *);\r
-int       vfprintf(FILE * __restrict, const char * __restrict, _BSD_VA_LIST_);\r
-int       vprintf (const char * __restrict, _BSD_VA_LIST_);\r
-\r
-#ifndef __AUDIT__\r
-char     *gets    (char *);\r
-int       sprintf (char * __restrict, const char * __restrict, ...);\r
-char     *tmpnam  (char *);\r
-int       vsprintf(char * __restrict, const char * __restrict, _BSD_VA_LIST_);\r
-#endif\r
 \r
-#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)\r
-int       rename  (const char *, const char *) __RENAME(__posix_rename);\r
-#else\r
-int       rename  (const char *, const char *);\r
-#endif\r
+/** Read a string from stdin into a buffer.\r
+\r
+    The gets function reads characters from the input stream pointed to by\r
+    stdin, into the array pointed to by Buff, until end-of-file is encountered\r
+    or a new-line character is read.  Any new-line character is discarded, and\r
+    a null character is written immediately after the last character read into\r
+    the array.\r
+\r
+    @param[out] Buff      A pointer to the array to receive the input string.\r
+\r
+    @return   The gets function returns Buff if successful.  If end-of-file is\r
+              encountered and no characters have been read into the array, the\r
+              contents of the array remain unchanged and a null pointer is\r
+              returned. If a read error occurs during the operation, the array\r
+              contents are indeterminate and a null pointer is returned.\r
+**/\r
+char     *gets    (char *Buff);\r
+\r
+/** Write a character to an output stream.\r
+\r
+    The putc function is equivalent to fputc, except that if it is implemented\r
+    as a macro, it may evaluate Stream more than once, so that argument should\r
+    never be an expression with side effects.\r
+\r
+    @param[in]  C       The character to be written to Stream.\r
+    @param[in]  Stream  The output stream that C is to be written to.\r
+\r
+    @return   The putc function returns the character written. If a write\r
+              error occurs, the error indicator for the stream is set and\r
+              putc returns EOF.\r
+**/\r
+int       putc    (int C, FILE *Stream);\r
+\r
+/** Write a character to stdout.\r
+\r
+    The putchar function is equivalent to putc with stdout as the Stream argument.\r
+\r
+    @param[in]    C   The character to be written to stdout.\r
+\r
+    @return   The putchar function returns the character written. If a write\r
+              error occurs, the error indicator for stdout is set and putchar\r
+              returns EOF.\r
+**/\r
+int       putchar (int C);\r
+\r
+/** Write String to stdout.\r
+\r
+    The puts function writes the string pointed to by String to the stream\r
+    pointed to by stdout, and appends a new-line character to the output. The\r
+    terminating null character is not written.\r
+\r
+    @param[in]  String    A pointer to the character string to write to stdout.\r
+\r
+    @return   The puts function returns EOF if a write error occurs; otherwise\r
+              it returns a non-negative value.\r
+**/\r
+int       puts    (const char *String);\r
+\r
+/** Return a character to the input Stream as if it had not been read.\r
+\r
+    The ungetc function pushes the character specified by C (converted to an\r
+    unsigned char) back onto the input stream pointed to by Stream. Pushed-back\r
+    characters will be returned by subsequent reads on that stream in the\r
+    reverse order of their being pushed.  A successful intervening call\r
+    (with the stream pointed to by Stream) to a file positioning function\r
+    (fseek, fsetpos, or rewind) discards any pushed-back characters for the\r
+    stream. The external storage corresponding to the stream is unchanged.\r
+\r
+    One character of pushback is guaranteed. If the ungetc function is called\r
+    too many times on the same stream without an intervening read or file\r
+    positioning operation on that stream, the operation will fail.\r
+\r
+    If the value of C equals that of the macro EOF, the operation fails and the\r
+    input stream is unchanged.\r
+\r
+    A successful call to the ungetc function clears the end-of-file indicator\r
+    for the stream.  The value of the file position indicator for the stream\r
+    after reading or discarding all pushed-back characters is the same as it\r
+    was before the characters were pushed back.  For a binary stream, its\r
+    file position indicator is decremented by each successful call to the\r
+    ungetc function; if its value was zero before a call, it will remain zero\r
+    after the call.\r
+\r
+    @param[in]  C       The character to push back onto the Stream.\r
+    @param[in]  Stream  The output stream that C is to be pushed back onto.\r
+\r
+    @return   The ungetc function returns the character pushed back,\r
+              or EOF if the operation fails.\r
+**/\r
+int       ungetc  (int C, FILE *Stream);\r
+\r
+/* ################ Direct Input/Output Functions. */\r
+\r
+/** Read Num elements of size Size from a Stream into a Buffer.\r
+\r
+    The fread function reads, into the array pointed to by Buffer, up to Num\r
+    elements, whose size is specified by Size, from the stream pointed to by\r
+    Stream.  For each object, Size calls are made to the fgetc function and the\r
+    results stored, in the order read, in an array of unsigned char exactly\r
+    overlaying the Buffer object.  The file position indicator for the stream\r
+    (if defined) is advanced by the number of characters successfully read. If\r
+    an error occurs, the resulting value of the file position indicator for the\r
+    stream is indeterminate.\r
+\r
+    @param[out]   Buffer    Pointer to an object to receive the read data.\r
+    @param[in]    Size      Size of each element to be read.\r
+    @param[in]    Num       Number of elements to read.\r
+    @param[in]    Stream    Input stream to read the data from.\r
+\r
+    @return   The fread function returns the number of elements successfully\r
+              read, which may be less than Num if a read error or end-of-file\r
+              is encountered.  If Size or Num is zero, fread returns zero and\r
+              the contents of the array and the state of the stream remain\r
+              unchanged.\r
+**/\r
+size_t    fread   (void   * __restrict  Buffer,\r
+                   size_t               Size,\r
+                   size_t               Num,\r
+                   FILE   * __restrict  Stream\r
+                  );\r
+\r
+/** Write Num elements of size Size from Buffer to Stream.\r
+\r
+    The fwrite function writes, from the array pointed to by Buffer, up to Num\r
+    elements whose size is specified by Size, to the stream pointed to by\r
+    Stream.  For each object, Size calls are made to the fputc function, taking\r
+    the values (in order) from an array of unsigned char exactly overlaying the\r
+    Buffer object.  The file position indicator for the stream (if defined) is\r
+    advanced by the number of characters successfully written.  If an error\r
+    occurs, the resulting value of the file position indicator for the stream is\r
+    indeterminate.\r
+\r
+    @param[out]   Buffer    Pointer to an object containing the data to be written.\r
+    @param[in]    Size      Size of each element to be written.\r
+    @param[in]    Num       Number of elements to write.\r
+    @param[in]    Stream    Output stream to write the data to.\r
+\r
+    @return   The fwrite function returns the number of elements successfully\r
+              written, which will be less than Num only if a write error is\r
+              encountered.  If Size or Num is zero, fwrite returns zero and\r
+              the state of the stream remains unchanged.\r
+**/\r
+size_t    fwrite  (void   * __restrict  Buffer,\r
+                   size_t               Size,\r
+                   size_t               Num,\r
+                   FILE   * __restrict  Stream\r
+                  );\r
+\r
+/* ################ File Positioning Functions.  */\r
+\r
+/** Get a stream's position and parse state.\r
+\r
+    The fgetpos function stores the current values of the parse state (if any)\r
+    and file position indicator for the stream pointed to by Stream in the\r
+    object pointed to by Pos.  The values stored contain unspecified\r
+    information usable by the fsetpos function for repositioning the stream\r
+    to its position at the time of the call to the fgetpos function.\r
+\r
+    @param[in]    Stream    Stream to get current position of.\r
+    @param[out]   Pos       Object to receive the stream's state and position information.\r
+\r
+    @return   If successful, the fgetpos function returns zero; if either\r
+              parameter is NULL, the fgetpos function returns nonzero and\r
+              stores EINVAL in errno.\r
+**/\r
+int       fgetpos (FILE * __restrict Stream, fpos_t * __restrict Pos);\r
+\r
+/** Set the file position for a stream.\r
+\r
+    The fseek function sets the file position indicator for the stream pointed\r
+    to by Stream.  If a read or write error occurs, the error indicator for the\r
+    stream is set and fseek fails.\r
+\r
+    For a binary stream, the new position, measured in characters from the\r
+    beginning of the file, is obtained by adding Offset to the position\r
+    specified by Whence. The specified position is the beginning of the file if\r
+    Whence is SEEK_SET, the current value of the file position indicator if\r
+    SEEK_CUR, or end-of-file if SEEK_END.\r
+\r
+    For a text stream, Offset must either be zero or a value returned by an\r
+    earlier successful call to the ftell function, on a stream associated with\r
+    the same file, and Whence must be SEEK_SET.\r
+\r
+    After determining the new position, a successful call to the fseek function\r
+    undoes any effects of the ungetc function on the stream, clears the\r
+    end-of-file indicator for the stream, and then establishes the new position.\r
+    After a successful fseek call, the next operation on an update stream may\r
+    be either input or output.\r
+\r
+    @param[in]  Stream  The I/O stream to set the position of.\r
+    @param[in]  Offset  The position, interpreted depending upon the value of\r
+                        Whence, that the stream is to be positioned to.\r
+    @param[in]  Whence  A value indicating how Offset is to be interpreted:\r
+                          - SEEK_SET indicates Offset is an absolute position.\r
+                          - SEEK_END indicates Offset is relative to the end of the file.\r
+                          - SEEK_CUR indicates Offset is relative to the current position.\r
+\r
+@return   The fseek function returns nonzero only for a request that cannot be satisfied.\r
+**/\r
+int       fseek   (FILE *Stream, long Offset, int Whence);\r
+\r
+/** Set a stream's position and parse state.\r
+\r
+    The fsetpos function sets the mbstate_t object (if any) and file position\r
+    indicator for the stream pointed to by Stream according to the value of the\r
+    object pointed to by Pos, which is a value that was obtained from an\r
+    earlier successful call to the fgetpos function on a stream associated with\r
+    the same file. If a read or write error occurs, the error indicator for the\r
+    stream is set and fsetpos fails.\r
+\r
+    A successful call to the fsetpos function undoes any effects of the ungetc\r
+    function on the stream, clears the end-of-file indicator for the stream,\r
+    and then establishes the new parse state and position. After a successful\r
+    fsetpos call, the next operation on an update stream may be either input or output.\r
+\r
+    @param[in]    Stream    Stream to set current position of.\r
+    @param[in]    Pos       Object containing the state and position information.\r
+\r
+    @return   If successful, the fsetpos function returns zero; on failure, the\r
+              fsetpos function returns nonzero and stores EINVAL, or ESPIPE,\r
+              in errno; depending upon whether the error was because of an invalid\r
+              parameter, or because Stream is not seekable.\r
+**/\r
+int       fsetpos (FILE *Stream, const fpos_t *Pos);\r
+\r
+/** Get Stream's current position.\r
+\r
+    The ftell function obtains the current value of the file position indicator\r
+    for the stream pointed to by Stream. For a binary stream, the value is the\r
+    number of characters from the beginning of the file. For a text stream, its\r
+    file position indicator contains unspecified information, usable by the\r
+    fseek function for returning the file position indicator for the stream to\r
+    its position at the time of the ftell call; the difference between two such\r
+    return values is not necessarily a meaningful measure of the number of\r
+    characters written or read.\r
+\r
+    @param[in]  Stream    Pointer to the FILE object to get the current position of.\r
+\r
+    @return   If successful, the ftell function returns the current value of\r
+              the file position indicator for the stream.  On failure, the\r
+              ftell function returns -1L and stores ESPIPE in errno indicating\r
+              that the stream is not seekable.\r
+**/\r
+long      ftell   (FILE *Stream);\r
+\r
+/** Restore a Stream's file position to the beginning of the file.\r
+\r
+    The rewind function sets the file position indicator for the stream pointed\r
+    to by Stream to the beginning of the file and clears the stream's error indicator.\r
+\r
+    @param[in]  Stream    Pointer to the stream to be positioned to its beginning.\r
+**/\r
+void      rewind  (FILE *Stream);\r
+\r
+/* ################ Error-handling Functions.  */\r
+\r
+/** Clear a Stream's error and end-of-file indicators.\r
+\r
+    @param[in]  Stream    Pointer to the stream to be cleared of errors.\r
+**/\r
+void      clearerr(FILE *Stream);\r
+\r
+/** Test the end-of-file indicator for Stream.\r
+\r
+    @param[in]  Stream    Pointer to the FILE object to be tested for EOF.\r
+\r
+    @return   The feof function returns non-zero if, and only if, the end-of-file\r
+              indicator is set for Stream.\r
+**/\r
+int       feof    (FILE *Stream);\r
+\r
+/** Test the error indicator for Stream.\r
+\r
+    @param[in]  Stream    Pointer to the stream to be tested for error.\r
+\r
+    @return   The ferror function returns non-zero if, and only if, the error\r
+              indicator is set for Stream.\r
+**/\r
+int       ferror  (FILE *Stream);\r
+\r
+/** Print an error message to stderr based upon the value of errno and String.\r
+\r
+    The perror function maps the error number in the integer expression errno\r
+    to an error message.  It writes a sequence of characters to the standard\r
+    error stream thus: first (if String is not a null pointer and the character\r
+    pointed to by String is not the null character), the string pointed to by\r
+    String followed by a colon (:) and a space; then an appropriate error\r
+    message string followed by a new-line character. The contents of the error\r
+    message strings are the same as those returned by the strerror function\r
+    with argument errno.\r
+\r
+    @param[in]  String    A text string to prefix the output error message with.\r
+\r
+    @sa strerror in <string.h>\r
+**/\r
+void      perror  (const char *String);\r
+\r
 __END_DECLS\r
 \r
 /*\r
  * IEEE Std 1003.1-90\r
  */\r
-#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \\r
-    defined(_NETBSD_SOURCE)\r
-  #define L_ctermid 1024  /* size for ctermid(); PATH_MAX */\r
-  #define L_cuserid 9     /* size for cuserid(); UT_NAMESIZE + 1 */\r
-\r
-  __BEGIN_DECLS\r
-  char  *ctermid(char *);\r
-  #ifndef __CUSERID_DECLARED\r
-    #define __CUSERID_DECLARED\r
-    /* also declared in unistd.h */\r
-    char  *cuserid(char *);\r
-  #endif /* __CUSERID_DECLARED */\r
-  FILE  *fdopen(int, const char *);\r
-  int  fileno(FILE *);\r
-  __END_DECLS\r
-#endif /* not ANSI */\r
+__BEGIN_DECLS\r
+FILE  *fdopen(int, const char *);\r
+__END_DECLS\r
 \r
 /*\r
  * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2\r
  */\r
-#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \\r
-    defined(_REENTRANT) || defined(_NETBSD_SOURCE)\r
-  __BEGIN_DECLS\r
-  void    flockfile       (FILE *);\r
-  int     ftrylockfile    (FILE *);\r
-  void    funlockfile     (FILE *);\r
-  int     getc_unlocked   (FILE *);\r
-  int     getchar_unlocked(void);\r
-  int     putc_unlocked   (int, FILE *);\r
-  int     putchar_unlocked(int);\r
-  __END_DECLS\r
-#endif /* _POSIX_C_SOURCE >= 1995056 || _XOPEN_SOURCE >= 500 || ... */\r
+__BEGIN_DECLS\r
+void    flockfile       (FILE *);\r
+int     ftrylockfile    (FILE *);\r
+void    funlockfile     (FILE *);\r
+int     getc_unlocked   (FILE *);\r
+int     getchar_unlocked(void);\r
+int     putc_unlocked   (int, FILE *);\r
+int     putchar_unlocked(int);\r
+__END_DECLS\r
 \r
 /*\r
  * Functions defined in POSIX 1003.2 and XPG2 or later.\r
  */\r
-#if (_POSIX_C_SOURCE - 0) >= 2 || (_XOPEN_SOURCE - 0) >= 2 || \\r
-    defined(_NETBSD_SOURCE)\r
-  __BEGIN_DECLS\r
+__BEGIN_DECLS\r
   int     pclose  (FILE *);\r
   FILE   *popen   (const char *, const char *);\r
-  __END_DECLS\r
-#endif\r
+__END_DECLS\r
 \r
 /*\r
  * Functions defined in ISO XPG4.2, ISO C99, POSIX 1003.1-2001 or later.\r
  */\r
-#if ((__STDC_VERSION__ - 0) >= 199901L) || \\r
-    ((_POSIX_C_SOURCE - 0) >= 200112L) || \\r
-    (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \\r
-    ((_XOPEN_SOURCE - 0) >= 500) || \\r
-    defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)\r
-  __BEGIN_DECLS\r
+__BEGIN_DECLS\r
   int     snprintf (char * __restrict, size_t, const char * __restrict, ...)\r
           __attribute__((__format__(__printf__, 3, 4)));\r
-  int     vsnprintf(char * __restrict, size_t, const char * __restrict, _BSD_VA_LIST_)\r
+  int     vsnprintf(char * __restrict, size_t, const char * __restrict, va_list)\r
           __attribute__((__format__(__printf__, 3, 0)));\r
-  __END_DECLS\r
-#endif\r
+__END_DECLS\r
 \r
 /*\r
  * Functions defined in XPG4.2.\r
  */\r
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)\r
-  __BEGIN_DECLS\r
-  int   getw(FILE *);\r
-  int   putw(int, FILE *);\r
+__BEGIN_DECLS\r
+  //int   getw(FILE *);\r
+  //int   putw(int, FILE *);\r
   char *mkdtemp(char *);\r
   int   mkstemp(char *);\r
   char *mktemp(char *);\r
 \r
-  #ifndef __AUDIT__\r
     char *tempnam(const char *, const char *);\r
-  #endif\r
-  __END_DECLS\r
-#endif\r
+__END_DECLS\r
 \r
 /*\r
  * X/Open CAE Specification Issue 5 Version 2\r
@@ -581,22 +1508,20 @@ __END_DECLS
 #endif /* off_t */\r
 \r
 __BEGIN_DECLS\r
-int  fseeko(FILE *, off_t, int);\r
-off_t  ftello(FILE *);\r
+int     fseeko(FILE *, off_t, int);\r
+off_t   ftello(FILE *);\r
 __END_DECLS\r
 \r
 /*\r
  * Routines that are purely local.\r
  */\r
-#if defined(_NETBSD_SOURCE)\r
+#define FPARSELN_UNESCESC   0x01\r
+#define FPARSELN_UNESCCONT  0x02\r
+#define FPARSELN_UNESCCOMM  0x04\r
+#define FPARSELN_UNESCREST  0x08\r
+#define FPARSELN_UNESCALL   0x0f\r
 \r
-  #define FPARSELN_UNESCESC 0x01\r
-  #define FPARSELN_UNESCCONT  0x02\r
-  #define FPARSELN_UNESCCOMM  0x04\r
-  #define FPARSELN_UNESCREST  0x08\r
-  #define FPARSELN_UNESCALL 0x0f\r
-\r
-  __BEGIN_DECLS\r
+__BEGIN_DECLS\r
   //int     asprintf(char ** __restrict, const char * __restrict, ...)\r
   //      __attribute__((__format__(__printf__, 2, 3)));\r
   char   *fgetln(FILE * __restrict, size_t * __restrict);\r
@@ -605,33 +1530,32 @@ __END_DECLS
   void    setbuffer(FILE *, char *, int);\r
   int     setlinebuf(FILE *);\r
   int     vasprintf(char ** __restrict, const char * __restrict,\r
-        _BSD_VA_LIST_)\r
+        va_list)\r
         __attribute__((__format__(__printf__, 2, 0)));\r
-  int     vscanf(const char * __restrict, _BSD_VA_LIST_)\r
+  int     vscanf(const char * __restrict, va_list)\r
         __attribute__((__format__(__scanf__, 1, 0)));\r
-  int     vfscanf(FILE * __restrict, const char * __restrict,\r
-        _BSD_VA_LIST_)\r
-        __attribute__((__format__(__scanf__, 2, 0)));\r
+  //int     vfscanf(FILE * __restrict, const char * __restrict,\r
+  //      va_list)\r
+  //      __attribute__((__format__(__scanf__, 2, 0)));\r
   int     vsscanf(const char * __restrict, const char * __restrict,\r
-        _BSD_VA_LIST_)\r
+        va_list)\r
         __attribute__((__format__(__scanf__, 2, 0)));\r
-  const char *fmtcheck(const char *, const char *)\r
-        __attribute__((__format_arg__(2)));\r
-  __END_DECLS\r
+  //const char *fmtcheck(const char *, const char *)\r
+  //      __attribute__((__format_arg__(2)));\r
+__END_DECLS\r
 \r
   /*\r
    * Stdio function-access interface.\r
    */\r
-  __BEGIN_DECLS\r
+__BEGIN_DECLS\r
   FILE  *funopen(const void *,\r
       int (*)(void *, char *, int),\r
       int (*)(void *, const char *, int),\r
       fpos_t (*)(void *, fpos_t, int),\r
       int (*)(void *));\r
-  __END_DECLS\r
+__END_DECLS\r
   //#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)\r
   //#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)\r
-#endif /* _NETBSD_SOURCE */\r
 \r
 /*\r
  * Functions internal to the implementation.\r
@@ -646,6 +1570,7 @@ __END_DECLS
  * define function versions in the C library.\r
  */\r
 #define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))\r
+\r
 #if defined(__GNUC__) && defined(__STDC__)\r
   static __inline int __sputc(int _c, FILE *_p) {\r
     if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))\r
@@ -673,33 +1598,23 @@ __END_DECLS
 #define __sfileno(p)    ((p)->_file)\r
 \r
 #ifndef __lint__\r
-  #if !defined(_REENTRANT) && !defined(_PTHREADS)\r
     #define feof(p)     __sfeof(p)\r
     #define ferror(p)   __sferror(p)\r
     #define clearerr(p) __sclearerr(p)\r
 \r
     #define getc(fp)    __sgetc(fp)\r
     #define putc(x, fp) __sputc(x, fp)\r
-  #endif /* !_REENTRANT && !_PTHREADS */\r
 #endif /* __lint__ */\r
 \r
 #define getchar()   getc(stdin)\r
 #define putchar(x)  putc(x, stdout)\r
 \r
-#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \\r
-    defined(_NETBSD_SOURCE)\r
-  #if !defined(_REENTRANT) && !defined(_PTHREADS)\r
-    #define fileno(p) __sfileno(p)\r
-  #endif /* !_REENTRANT && !_PTHREADS */\r
-#endif /* !_ANSI_SOURCE */\r
-\r
-#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \\r
-    defined(_REENTRANT) || defined(_NETBSD_SOURCE)\r
-  #define getc_unlocked(fp) __sgetc(fp)\r
-  #define putc_unlocked(x, fp)  __sputc(x, fp)\r
-\r
-  #define getchar_unlocked()  getc_unlocked(stdin)\r
-  #define putchar_unlocked(x) putc_unlocked(x, stdout)\r
-#endif /* _POSIX_C_SOURCE >= 199506 || _XOPEN_SOURCE >= 500 || _REENTRANT... */\r
+#define fileno(p) __sfileno(p)\r
+\r
+#define getc_unlocked(fp) __sgetc(fp)\r
+#define putc_unlocked(x, fp)  __sputc(x, fp)\r
+\r
+#define getchar_unlocked()  getc_unlocked(stdin)\r
+#define putchar_unlocked(x) putc_unlocked(x, stdout)\r
 \r
 #endif /* _STDIO_H_ */\r