stdio.h(3avr) | avr-libc | stdio.h(3avr) |
stdio.h
#define stdin (__iob[0])
#define stdout (__iob[1])
#define stderr (__iob[2])
#define EOF (-1)
#define fdev_set_udata(stream, u) do { (stream)->udata = u; }
while(0)
#define fdev_get_udata(stream) ((stream)->udata)
#define fdev_setup_stream(stream, put, get, rwflag)
#define _FDEV_SETUP_READ __SRD
#define _FDEV_SETUP_WRITE __SWR
#define _FDEV_SETUP_RW (__SRD|__SWR)
#define _FDEV_ERR (-1)
#define _FDEV_EOF (-2)
#define FDEV_SETUP_STREAM(put, get, rwflag)
#define fdev_close()
#define putc(__c, __stream) fputc(__c, __stream)
#define putchar(__c) fputc(__c, stdout)
#define getc(__stream) fgetc(__stream)
#define getchar() fgetc(stdin)
typedef struct __file FILE
int fclose (FILE *__stream)
int vfprintf (FILE *__stream, const char *__fmt, va_list __ap)
int vfprintf_P (FILE *__stream, const char *__fmt, va_list __ap)
int fputc (int __c, FILE *__stream)
int printf (const char *__fmt,...)
int printf_P (const char *__fmt,...)
int vprintf (const char *__fmt, va_list __ap)
int sprintf (char *__s, const char *__fmt,...)
int sprintf_P (char *__s, const char *__fmt,...)
int snprintf (char *__s, size_t __n, const char *__fmt,...)
int snprintf_P (char *__s, size_t __n, const char *__fmt,...)
int vsprintf (char *__s, const char *__fmt, va_list ap)
int vsprintf_P (char *__s, const char *__fmt, va_list ap)
int vsnprintf (char *__s, size_t __n, const char *__fmt, va_list ap)
int vsnprintf_P (char *__s, size_t __n, const char *__fmt, va_list ap)
int fprintf (FILE *__stream, const char *__fmt,...)
int fprintf_P (FILE *__stream, const char *__fmt,...)
int fputs (const char *__str, FILE *__stream)
int fputs_P (const char *__str, FILE *__stream)
int puts (const char *__str)
int puts_P (const char *__str)
size_t fwrite (const void *__ptr, size_t __size, size_t __nmemb,
FILE *__stream)
int fgetc (FILE *__stream)
int ungetc (int __c, FILE *__stream)
char * fgets (char *__str, int __size, FILE *__stream)
char * gets (char *__str)
size_t fread (void *__ptr, size_t __size, size_t __nmemb, FILE
*__stream)
void clearerr (FILE *__stream)
int feof (FILE *__stream)
int ferror (FILE *__stream)
int vfscanf (FILE *__stream, const char *__fmt, va_list __ap)
int vfscanf_P (FILE *__stream, const char *__fmt, va_list __ap)
int fscanf (FILE *__stream, const char *__fmt,...)
int fscanf_P (FILE *__stream, const char *__fmt,...)
int scanf (const char *__fmt,...)
int scanf_P (const char *__fmt,...)
int vscanf (const char *__fmt, va_list __ap)
int sscanf (const char *__buf, const char *__fmt,...)
int sscanf_P (const char *__buf, const char *__fmt,...)
int fflush (FILE *stream)
Return code for an end-of-file condition during device read.
To be used in the get function of fdevopen().
Return code for an error condition during device read.
To be used in the get function of fdevopen().
fdev_setup_stream() with read intent
fdev_setup_stream() with read/write intent
fdev_setup_stream() with write intent
EOF declares the value that is returned by various standard IO functions in case of an error. Since the AVR platform (currently) doesn't contain an abstraction for actual files, its origin as 'end of file' is somewhat meaningless here.
This macro frees up any library resources that might be associated with stream. It should be called if stream is no longer needed, right before the application is going to destroy the stream object itself.
(Currently, this macro evaluates to nothing, but this might change in future versions of the library.)
This macro retrieves a pointer to user defined data from a FILE stream object.
This macro inserts a pointer to user defined data into a FILE stream object.
The user data can be useful for tracking state in the put and get functions supplied to the fdevopen() function.
Initializer for a user-supplied stdio stream. This macro acts similar to fdev_setup_stream(), but it is to be used as the initializer of a variable of type FILE.
The remaining arguments are to be used as explained in fdev_setup_stream().
Setup a user-supplied buffer as an stdio stream. This macro takes a user-supplied buffer stream, and sets it up as a stream that is valid for stdio operations, similar to one that has been obtained dynamically from fdevopen(). The buffer to setup must be of type FILE.
The arguments put and get are identical to those that need to be passed to fdevopen().
The rwflag argument can take one of the values _FDEV_SETUP_READ, _FDEV_SETUP_WRITE, or _FDEV_SETUP_RW, for read, write, or read/write intent, respectively.
Note
The macro getc used to be a 'fast' macro implementation with a functionality identical to fgetc(). For space constraints, in avr-libc, it is just an alias for fgetc.
The macro getchar reads a character from stdin. Return values and error handling is identical to fgetc().
The macro putc used to be a 'fast' macro implementation with a functionality identical to fputc(). For space constraints, in avr-libc, it is just an alias for fputc.
The macro putchar sends character c to stdout.
Stream destined for error output. Unless specifically assigned, identical to stdout.
If stderr should point to another stream, the result of another fdevopen() must be explicitly assigned to it without closing the previous stderr (since this would also close stdout).
Stream that will be used as an input stream by the simplified functions that don't take a stream argument.
The first stream opened with read intent using fdevopen() will be assigned to stdin.
Stream that will be used as an output stream by the simplified functions that don't take a stream argument.
The first stream opened with write intent using fdevopen() will be assigned to both, stdin, and stderr.
FILE is the opaque structure that is passed around between the various standard IO functions.
Clear the error and end-of-file flags of stream.
This function closes stream, and disallows and further IO to and from it.
When using fdevopen() to setup the stream, a call to fclose() is needed in order to free the internal resources allocated.
If the stream has been set up using fdev_setup_stream() or FDEV_SETUP_STREAM(), use fdev_close() instead.
It currently always returns 0 (for success).
Test the end-of-file flag of stream. This flag can only be cleared by a call to clearerr().
Test the error flag of stream. This flag can only be cleared by a call to clearerr().
Flush stream.
This is a null operation provided for source-code compatibility only, as the standard IO implementation currently does not perform any buffering.
The function fgetc reads a character from stream. It returns the character, or EOF in case end-of-file was encountered or an error occurred. The routines feof() or ferror() must be used to distinguish between both situations.
Read at most size - 1 bytes from stream, until a newline character was encountered, and store the characters in the buffer pointed to by str. Unless an error was encountered while reading, the string will then be terminated with a NUL character.
If an error was encountered, the function returns NULL and sets the error flag of stream, which can be tested using ferror(). Otherwise, a pointer to the string will be returned.
The function fprintf performs formatted output to stream. See vfprintf() for details.
Variant of fprintf() that uses a fmt string that resides in program memory.
The function fputc sends the character c (though given as type int) to stream. It returns the character, or EOF in case an error occurred.
Write the string pointed to by str to stream stream.
Returns 0 on success and EOF on error.
Variant of fputs() where str resides in program memory.
Read nmemb objects, size bytes each, from stream, to the buffer pointed to by ptr.
Returns the number of objects successfully read, i. e. nmemb unless an input error occured or end-of-file was encountered. feof() and ferror() must be used to distinguish between these two conditions.
The function fscanf performs formatted input, reading the input data from stream.
See vfscanf() for details.
Variant of fscanf() using a fmt string in program memory.
Write nmemb objects, size bytes each, to stream. The first byte of the first object is referenced by ptr.
Returns the number of objects successfully written, i. e. nmemb unless an output error occured.
Similar to fgets() except that it will operate on stream stdin, and the trailing newline (if any) will not be stored in the string. It is the caller's responsibility to provide enough storage to hold the characters read.
The function printf performs formatted output to stream stdout. See vfprintf() for details.
Variant of printf() that uses a fmt string that resides in program memory.
Write the string pointed to by str, and a trailing newline character, to stdout.
Variant of puts() where str resides in program memory.
The function scanf performs formatted input from stream stdin.
See vfscanf() for details.
Variant of scanf() where fmt resides in program memory.
Like sprintf(), but instead of assuming s to be of infinite size, no more than n characters (including the trailing NUL character) will be converted to s.
Returns the number of characters that would have been written to s if there were enough space.
Variant of snprintf() that uses a fmt string that resides in program memory.
Variant of printf() that sends the formatted characters to string s.
Variant of sprintf() that uses a fmt string that resides in program memory.
The function sscanf performs formatted input, reading the input data from the buffer pointed to by buf.
See vfscanf() for details.
Variant of sscanf() using a fmt string in program memory.
The ungetc() function pushes the character c (converted to an unsigned char) back onto the input stream pointed to by stream. The pushed-back character will be returned by a subsequent read on the stream.
Currently, only a single character can be pushed back onto the stream.
The ungetc() function returns the character pushed back after the conversion, or EOF if the operation fails. If the value of the argument c character equals EOF, the operation will fail and the stream will remain unchanged.
vfprintf is the central facility of the printf family of functions. It outputs values to stream under control of a format string passed in fmt. The actual values to print are passed as a variable argument list ap.
vfprintf returns the number of characters written to stream, or EOF in case of an error. Currently, this will only happen if stream has not been opened with write intent.
The format string is composed of zero or more directives: ordinary characters (not %), which are copied unchanged to the output stream; and conversion specifications, each of which results in fetching zero or more subsequent arguments. Each conversion specification is introduced by the % character. The arguments must properly correspond (after type promotion) with the conversion specifier. After the %, the following appear in sequence:
The conversion specifiers and their meanings are:
In no case does a non-existent or small field width cause truncation of a numeric field; if the result of a conversion is wider than the field width, the field is expanded to contain the conversion result.
Since the full implementation of all the mentioned features becomes fairly large, three different flavours of vfprintf() can be selected using linker options. The default vfprintf() implements all the mentioned functionality except floating point conversions. A minimized version of vfprintf() is available that only implements the very basic integer and string conversion facilities, but only the # additional option can be specified using conversion flags (these flags are parsed correctly from the format specification, but then simply ignored). This version can be requested using the following compiler options:
-Wl,-u,vfprintf -lprintf_min
If the full functionality including the floating point conversions is required, the following options should be used:
-Wl,-u,vfprintf -lprintf_flt -lm
Limitations:
Notes:
Variant of vfprintf() that uses a fmt string that resides in program memory.
Formatted input. This function is the heart of the scanf family of functions.
Characters are read from stream and processed in a way described by fmt. Conversion results will be assigned to the parameters passed via ap.
The format string fmt is scanned for conversion specifications. Anything that doesn't comprise a conversion specification is taken as text that is matched literally against the input. White space in the format string will match any white space in the data (including none), all other characters match only itself. Processing is aborted as soon as the data and format string no longer match, or there is an error or end-of-file condition on stream.
Most conversions skip leading white space before starting the actual conversion.
Conversions are introduced with the character %. Possible options can follow the %:
In addition, a maximal field width may be specified as a nonzero positive decimal integer, which will restrict the conversion to at most this many characters from the input stream. This field width is limited to at most 255 characters which is also the default value (except for the c conversion that defaults to 1).
The following conversion flags are supported:
These functions return the number of input items assigned, which can be fewer than provided for, or even zero, in the event of a matching failure. Zero indicates that, while there was input available, no conversions were assigned; typically this is due to an invalid input character, such as an alphabetic character for a d conversion. The value EOF is returned if an input failure occurs before any conversion such as an end-of-file occurs. If an error or end-of-file occurs after conversion has begun, the number of conversions which were successfully completed is returned.
By default, all the conversions described above are available except the floating-point conversions and the width is limited to 255 characters. The float-point conversion will be available in the extended version provided by the library libscanf_flt.a. Also in this case the width is not limited (exactly, it is limited to 65535 characters). To link a program against the extended version, use the following compiler flags in the link stage:
-Wl,-u,vfscanf -lscanf_flt -lm
A third version is available for environments that are tight on space. In addition to the restrictions of the standard one, this version implements no %[ specification. This version is provided in the library libscanf_min.a, and can be requested using the following options in the link stage:
-Wl,-u,vfscanf -lscanf_min -lm
Variant of vfscanf() using a fmt string in program memory.
The function vprintf performs formatted output to stream stdout, taking a variable argument list as in vfprintf().
See vfprintf() for details.
The function vscanf performs formatted input from stream stdin, taking a variable argument list as in vfscanf().
See vfscanf() for details.
Like vsprintf(), but instead of assuming s to be of infinite size, no more than n characters (including the trailing NUL character) will be converted to s.
Returns the number of characters that would have been written to s if there were enough space.
Variant of vsnprintf() that uses a fmt string that resides in program memory.
Like sprintf() but takes a variable argument list for the arguments.
Variant of vsprintf() that uses a fmt string that resides in program memory.
Generated automatically by Doxygen for avr-libc from the source code.
Fri Jan 1 2021 | Version 2.0.0 |