+++ /dev/null
-/** @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 - 2012, 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
- * This code is derived from software contributed to Berkeley by\r
- * Chris Torek.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- * 3. Neither the name of the University nor the names of its contributors\r
- * may be used to endorse or promote products derived from this software\r
- * without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\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
-#ifndef _STDIO_H_\r
-#define _STDIO_H_\r
-\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
- 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
-typedef struct __sfpos {\r
- __off_t _pos;\r
-} fpos_t;\r
-#endif\r
-/*@}*/\r
-\r
-/* stdio buffers */\r
-struct __sbuf {\r
- unsigned char *_base;\r
- int _size;\r
-};\r
-\r
-/** Structure which holds all the information needed to control a stream or file.\r
- *\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
- *\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
- * (Moreover, they can, and do, automatically switch from read mode to\r
- * write mode, and back, on "r+" and "w+" files.)\r
- *\r
- * _lbfsize is used only to make the inline line-buffered output stream\r
- * code as compact as possible.\r
- *\r
- * _ub, _up, and _ur are used when ungetc() pushes back more characters\r
- * than fit in the current _bf, or when ungetc() pushes back a character\r
- * that does not match the previous one in _bf. When this happens,\r
- * _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
- */\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
-\r
- /* operations */\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
- struct __sbuf _ext;\r
-\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 * MB_LEN_MAX]; /**< guarantee an ungetc() buffer */\r
- unsigned char _nbuf[1 * MB_LEN_MAX]; /**< guarantee a getc() buffer */\r
-\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
-} 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
- /* 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
-\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
-\r
-#define BUFSIZ 1024 /**< size of buffer used by setbuf */\r
-#define EOF (-1) /**< A constant integer expression indicating end-of-file. */\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
- */\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 /**< 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
-#endif\r
-#ifndef SEEK_CUR\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
-#endif\r
-\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
-__BEGIN_DECLS\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 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 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
- according to the corresponding conversion specifier, and then writing the\r
- result to the output stream.\r
-\r
- Each conversion specification is introduced by the character %. After\r
- the %, the following appear in sequence:\r
- - Zero or more flags (in any order) that modify the meaning of the\r
- conversion specification.\r
- - An optional minimum field width. If the converted value has fewer\r
- characters than the field width, it is padded with spaces (by default)\r
- on the left (or right, if the left adjustment flag, described later,\r
- has been given) to the field width. The field width takes the form of\r
- an asterisk * (described later) or a nonnegative decimal integer.\r
- - An optional precision that gives the minimum number of digits to appear\r
- for the d, i, o, u, x, and X conversions, the number of digits to\r
- appear after the decimal-point character for e, E, f, and F\r
- conversions, the maximum number of significant digits for the g and G\r
- conversions, or the maximum number of bytes to be written for s\r
- 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, 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
-\r
- As noted above, a field width, or precision, or both, may be indicated by\r
- an asterisk. In this case, an int argument supplies the field width or\r
- 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 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
- (It is right-justified if this flag is not specified.)\r
- + The result of a signed conversion always begins with a plus or\r
- minus sign. (It begins with a sign only when a negative value is\r
- converted if this flag is not specified.)\r
- space If the first character of a signed conversion is not a sign, or\r
- 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".\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.\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
- applies to a signed char or unsigned char argument (the argument\r
- will have been promoted according to the integer promotions, but\r
- its value shall be converted to signed char or unsigned char before\r
- printing); or that a following n conversion specifier applies to a\r
- pointer to a signed char argument.\r
- h Specifies that a following d, i, o, u, x, or X conversion specifier\r
- applies to a short int or unsigned short int argument (the argument\r
- will have been promoted according to the integer promotions, but\r
- its value shall be converted to short int or unsigned short int\r
- before printing); or that a following n conversion specifier\r
- applies to a pointer to a short int argument.\r
- l (ell) Specifies that a following d, i, o, u, x, or X conversion\r
- specifier applies to a long int or unsigned long int argument; that\r
- a following n conversion specifier applies to a pointer to a long\r
- int argument; that a following c conversion specifier applies to a\r
- wint_t argument; that a following s conversion specifier applies to\r
- a pointer to a wchar_t argument; or has no effect on a following e,\r
- E, f, F, g, or G conversion specifier.\r
- ll (ell-ell) Specifies that a following d, i, o, u, x, or X conversion\r
- specifier applies to a long long int or unsigned long long int\r
- argument; or that a following n conversion specifier applies to a\r
- pointer to a long long int argument.\r
- j Specifies that a following d, i, o, u, x, or X conversion specifier\r
- applies to an intmax_t or uintmax_t argument; or that a following n\r
- conversion specifier applies to a pointer to an intmax_t argument.\r
- z Specifies that a following d, i, o, u, x, or X conversion specifier\r
- applies to a size_t or the corresponding signed integer type\r
- argument; or that a following n conversion specifier applies to a\r
- pointer to a signed integer type corresponding to size_t argument.\r
- t Specifies that a following d, i, o, u, x, or X conversion specifier\r
- applies to a ptrdiff_t or the corresponding unsigned integer type\r
- argument; or that a following n conversion specifier applies to a\r
- pointer to a ptrdiff_t argument.\r
- L Specifies that a following e, E, f, F, g, or G conversion specifier\r
- applies to a long double argument.\r
-\r
- If a length modifier appears with any conversion specifier other than as\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
- [-]dddd. The precision specifies the minimum number of digits to\r
- appear; if the value being converted can be represented in fewer\r
- digits, it is expanded with leading zeros. The default precision\r
- is 1. The result of converting a zero value with a precision of\r
- zero is no characters.\r
- o,u,x,X The unsigned int argument is converted to unsigned octal (o),\r
- unsigned decimal (u), or unsigned hexadecimal notation (x or X) in\r
- the style dddd; the letters abcdef are used for x conversion and\r
- the letters ABCDEF for X conversion. The precision specifies the\r
- minimum number of digits to appear; if the value being converted\r
- can be represented in fewer digits, it is expanded with leading\r
- zeros. The default precision is 1. The result of converting a zero\r
- value with a precision of zero is no characters.\r
- f,F A double argument representing a floating-point number is\r
- converted to decimal notation in the style [-]ddd.ddd, where the\r
- number of digits after the decimal-point character is equal to the\r
- precision specification. If the precision is missing, it is taken\r
- as 6; if the precision is zero and the # flag is not specified, no\r
- 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\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
- (which is nonzero if the argument is nonzero) before the\r
- decimal-point character and the number of digits after it is equal\r
- to the precision; if the precision is missing, it is taken as 6; if\r
- the precision is zero and the # flag is not specified, no\r
- decimal-point character appears. The value is rounded to the\r
- appropriate number of digits. The E conversion specifier produces a\r
- number with E instead of e introducing the exponent. The exponent\r
- always contains at least two digits, and only as many more digits\r
- as necessary to represent the exponent. If the value is zero, the\r
- exponent is zero.\r
- A double argument representing an infinity or NaN is converted\r
- in the style of an f or F conversion specifier.\r
- g,G A double argument representing a floating-point number is\r
- converted in style f or e (or in style F or E in the case of a G\r
- conversion specifier), depending on the value converted and the\r
- precision. Let P equal the precision if nonzero, 6 if the precision\r
- is omitted, or 1 if the precision is zero. Then, if a conversion\r
- with style E would have an exponent of X:\r
- - if P > X = -4, the conversion is with style f (or F) and\r
- precision P - (X + 1).\r
- - otherwise, the conversion is with style e (or E) and\r
- precision P - 1.\r
-\r
- Finally, unless the # flag is used, any trailing zeros are removed\r
- from the fractional portion of the result and the decimal-point\r
- character is removed if there is no fractional portion remaining.\r
- A double argument representing an infinity or NaN is converted in\r
- the style of an f or F conversion specifier.\r
- c If no l length modifier is present, the int argument is\r
- converted to an unsigned char, and the resulting character is\r
- written. If an l length modifier is present, the wint_t argument is\r
- converted as if by an ls conversion specification with no precision\r
- and an argument that points to the initial element of a two-element\r
- array of wchar_t, the first element containing the wint_t argument\r
- to the lc conversion specification and the second a null wide\r
- character.\r
- s If no l length modifier is present, the argument is a pointer\r
- to the initial element of an array of character type. Characters\r
- from the array are written up to (but not including) the\r
- terminating null character. If the precision is specified, no more\r
- than that many bytes are written. If the precision is not specified\r
- or is greater than the size of the array, the array shall contain a\r
- null character.\r
- If an l length modifier is present, the argument shall be a\r
- pointer to the initial element of an array of wchar_t type. Wide\r
- characters from the array are converted to multibyte characters\r
- (each as if by a call to the wcrtomb function, with the conversion\r
- state described by an mbstate_t object initialized to zero before\r
- the first wide character is converted) up to and including a\r
- terminating null wide character. The resulting multibyte characters\r
- are written up to (but not including) the terminating null\r
- character (byte). If no precision is specified, the array shall\r
- contain a null wide character. If a precision is specified, no more\r
- than that many bytes are written (including shift sequences, if\r
- any), and the array shall contain a null wide character if, to\r
- equal the multibyte character sequence length given by the\r
- precision, the function would need to access a wide character one\r
- 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.\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, they will be ignored.\r
- % A % character is written. No argument is converted. The\r
- complete conversion specification shall be %%.\r
-\r
- In no case does a nonexistent or small field width cause truncation of a\r
- field; if the result of a conversion is wider than the field width, the\r
- 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 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 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
-/** 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
-\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 (const 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
-__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
-__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
-__BEGIN_DECLS\r
- int pclose (FILE *);\r
- FILE *popen (const char *, const char *);\r
-__END_DECLS\r
-\r
-/*\r
- * Functions defined in ISO XPG4.2, ISO C99, POSIX 1003.1-2001 or later.\r
- */\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, va_list)\r
- __attribute__((__format__(__printf__, 3, 0)));\r
-__END_DECLS\r
-\r
-/*\r
- * Functions defined in XPG4.2.\r
- */\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
- char *tempnam(const char *, const char *);\r
-__END_DECLS\r
-\r
-/*\r
- * X/Open CAE Specification Issue 5 Version 2\r
- */\r
-#ifndef off_t\r
- typedef __off_t off_t;\r
- #define off_t __off_t\r
-#endif /* off_t */\r
-\r
-__BEGIN_DECLS\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
-#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
- //int asprintf(char ** __restrict, const char * __restrict, ...)\r
- // __attribute__((__format__(__printf__, 2, 3)));\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
- __attribute__((__format__(__printf__, 2, 0)));\r
- int vscanf(const char * __restrict, va_list)\r
- __attribute__((__format__(__scanf__, 1, 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
- 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
-\r
- /*\r
- * Stdio function-access interface.\r
- */\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
- //#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)\r
- //#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)\r
-\r
-/*\r
- * Functions internal to the implementation.\r
- */\r
-__BEGIN_DECLS\r
-int __srget(FILE *);\r
-int __swbuf(int, FILE *);\r
-__END_DECLS\r
-\r
-/*\r
- * The __sfoo macros are here so that we can\r
- * 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
- return (*_p->_p++ = _c);\r
- else\r
- return (__swbuf(_c, _p));\r
- }\r
-#else\r
- /*\r
- * This has been tuned to generate reasonable code on the vax using pcc.\r
- */\r
- #define __sputc(c, p) \\r
- (--(p)->_w < 0 ? \\r
- (p)->_w >= (p)->_lbfsize ? \\r
- (*(p)->_p = (unsigned char)(c)), *(p)->_p != '\n' ? \\r
- (int)*(p)->_p++ : \\r
- __swbuf('\n', p) : \\r
- __swbuf((int)(c), p) : \\r
- (*(p)->_p = (unsigned char)(c), (int)*(p)->_p++))\r
-#endif\r
-\r
-#define __sfeof(p) (((p)->_flags & __SEOF) != 0)\r
-#define __sferror(p) (((p)->_flags & __SERR) != 0)\r
-#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))\r
-#define __sfileno(p) ((p)->_file)\r
-\r
-#ifndef __lint__\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 /* __lint__ */\r
-\r
-#define getchar() getc(stdin)\r
-#define putchar(x) putc(x, stdout)\r
-\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