MicrOS
|
Go to the source code of this file.
Classes | |
struct | FILE |
Object containing information to control a stream. More... | |
Macros | |
#define | BUFSIZ 1024 * 32 |
Size of the stream buffer. More... | |
#define | EOF -1 |
Value returned when internal stream position has reached the end of file. More... | |
#define | FILENAME_MAX 255 |
Maximum length of file names. More... | |
#define | FOPEN_MAX INT32_MAX |
Potential limit of simultaneous open streams. More... | |
#define | L_tmpnam 0 |
Minimum length for temporary file name. More... | |
#define | TMP_MAX 0 |
Maximum number of temporary files. More... | |
#define | SEEK_SET 0 |
Seek-Set mode (position is absolute) More... | |
#define | SEEK_CUR 1 |
Seek-Current mode (relative to the current position) More... | |
#define | SEEK_END 2 |
Seek-End mode (relative to the end of the file) More... | |
#define | _IONBF 0 |
No Buffering mode. More... | |
#define | _IOLBF 1 |
Line Buffering mode. More... | |
#define | _IOFBF 2 |
Full Buffering mode. More... | |
Typedefs | |
typedef uint32_t | size_t |
Unsigned integral type. More... | |
typedef uint32_t | fpos_t |
Object containing information to specify a position within a file. More... | |
Enumerations | |
enum | file_buffering_mode { file_buffering_mode_none = 0, file_buffering_mode_line = 1, file_buffering_mode_full = 2 } |
Stream buffering modest. More... | |
enum | file_mode { file_mode_none, file_mode_read, file_mode_write, file_mode_append, file_mode_read_and_update, file_mode_write_and_update, file_mode_append_and_update } |
Functions | |
int | remove (const char *filename) |
Remove file. More... | |
int | rename (const char *oldname, const char *newname) |
Rename file. More... | |
FILE * | fopen (const char *filename, const char *mode) |
Open file. More... | |
FILE * | freopen (const char *filename, const char *mode, FILE *stream) |
Reopen stream with different file or mode. More... | |
int | fclose (FILE *stream) |
Close file. More... | |
int | fflush (FILE *stream) |
Flush stream. More... | |
void | setbuf (FILE *stream, char *buffer) |
Set stream buffer. More... | |
int | setvbuf (FILE *stream, char *buffer, int mode, size_t size) |
Change stream buffering. More... | |
int | fgetc (FILE *stream) |
Get character from stream. More... | |
char * | fgets (char *str, int num, FILE *stream) |
Get string from stream. More... | |
int | fputc (int character, FILE *stream) |
Write character to stream. More... | |
int | fputs (const char *str, FILE *stream) |
Write string to stream. More... | |
int | getc (FILE *stream) |
Get character from stream. More... | |
int | getchar () |
Get character from stdin. More... | |
char * | gets (char *str) |
Get string from stdin. More... | |
int | putc (int character, FILE *stream) |
Write character to stream. More... | |
int | putchar (int character) |
Write character to stdout. More... | |
int | puts (const char *str) |
Write string to stdout. More... | |
int | ungetc (int character, FILE *stream) |
Unget character from stream. More... | |
size_t | fread (void *ptr, size_t size, size_t count, FILE *stream) |
Read block of data from stream. More... | |
size_t | fwrite (const void *ptr, size_t size, size_t count, FILE *stream) |
Write block of data to stream. More... | |
int | fgetpos (FILE *stream, fpos_t *pos) |
Get current position in stream. More... | |
int | fseek (FILE *stream, long int offset, int origin) |
Reposition stream position indicator. More... | |
int | fsetpos (FILE *stream, const fpos_t *pos) |
Set position indicator of stream. More... | |
long int | ftell (FILE *stream) |
Get current position in stream. More... | |
void | rewind (FILE *stream) |
Set position of stream to the beginning. More... | |
void | clearerr (FILE *stream) |
Clear error indicators. More... | |
int | feof (FILE *stream) |
Check end-of-file indicator. More... | |
int | ferror (FILE *stream) |
Check error indicator. More... | |
void | perror (const char *str) |
Print error message. More... | |
int | sprintf (char *str, const char *format,...) |
Write formatted data to string. More... | |
int | printf (const char *format,...) |
Print formatted data to stdout. More... | |
int | fprintf (FILE *file, const char *format,...) |
Print formatted data to stdoutWrite formatted data to stream. More... | |
int | vfprintf (FILE *stream, const char *format, va_list arg) |
Print formatted data from variable argument list to stream. More... | |
int | vprintf (const char *format, va_list arg) |
Print formatted data from variable argument list to stdout. More... | |
int | vsprintf (char *str, const char *format, va_list arg) |
Print formatted data from variable argument list to string. More... | |
int | vfscanf (FILE *stream, const char *format, va_list arg) |
Read formatted data from stream into variable argument list. More... | |
int | scanf (const char *format,...) |
Read formatted data from stdin. More... | |
FILE * | __stdio_create_stream () |
Creates new stream. More... | |
file_mode | __stdio_get_file_mode (const char *str_mode) |
Parses file mode. More... | |
Variables | |
FILE * | stdin |
Standard input (default is keyboard). More... | |
FILE * | stdout |
Standard output (default is console). More... | |
FILE * | stderr |
Standard error output (default is console). More... | |
#define _IOFBF 2 |
Full Buffering mode.
#define _IOLBF 1 |
Line Buffering mode.
#define _IONBF 0 |
No Buffering mode.
#define BUFSIZ 1024 * 32 |
Size of the stream buffer.
#define EOF -1 |
Value returned when internal stream position has reached the end of file.
#define FILENAME_MAX 255 |
Maximum length of file names.
#define FOPEN_MAX INT32_MAX |
Potential limit of simultaneous open streams.
#define L_tmpnam 0 |
Minimum length for temporary file name.
#define SEEK_CUR 1 |
Seek-Current mode (relative to the current position)
#define SEEK_END 2 |
Seek-End mode (relative to the end of the file)
#define SEEK_SET 0 |
Seek-Set mode (position is absolute)
#define TMP_MAX 0 |
Maximum number of temporary files.
enum file_buffering_mode |
enum file_mode |
FILE* __stdio_create_stream | ( | ) |
Creates new stream.
Creates new stream (not assigned to any file or device) and returns it.
file_mode __stdio_get_file_mode | ( | const char * | str_mode | ) |
Parses file mode.
Parses file mode in string format (eg. r+) and returns corresponding enum.
void clearerr | ( | FILE * | stream | ) |
Clear error indicators.
Resets both the error and the eof indicators of the stream.
stream | Pointer to a FILE object that identifies the stream to be closed. |
int fclose | ( | FILE * | stream | ) |
Close file.
Closes the file associated with the stream and disassociates it.
stream | Pointer to a FILE object that identifies the stream to be closed. |
int feof | ( | FILE * | stream | ) |
Check end-of-file indicator.
Checks whether the end-of-File indicator associated with stream is set, returning a value different from zero if it is.
stream | stream Pointer to a FILE object that identifies the stream to be closed. |
int ferror | ( | FILE * | stream | ) |
Check error indicator.
Checks if the error indicator associated with stream is set, returning a value different from zero if it is.
sstream | tream Pointer to a FILE object that identifies the stream to be closed. |
int fflush | ( | FILE * | stream | ) |
Flush stream.
If the given stream was open for writing any unwritten data in its output buffer is written to the file. If stream is a null pointer, all such streams are flushed.
stream | Pointer to a FILE object that identifies the stream to be closed. |
int fgetc | ( | FILE * | stream | ) |
Get character from stream.
Returns the character currently pointed by the internal file position indicator of the specified stream. The internal file position indicator is then advanced to the next character.
stream | Pointer to a FILE object that identifies the stream to be closed. |
Get current position in stream.
Retrieves the current position in the stream.
stream | Pointer to a FILE object that identifies the stream to be closed. |
pos | Pointer to a fpos_t object. This should point to an object already allocated. |
char* fgets | ( | char * | str, |
int | num, | ||
FILE * | stream | ||
) |
Get string from stream.
Reads characters from stream and stores them as a C string into str until (num-1) characters have been read or either a newline or the end-of-file is reached, whichever happens first.
str | Pointer to an array of chars where the string read is copied. |
num | Maximum number of characters to be copied into str (including the terminating null-character). |
stream | Pointer to a FILE object that identifies the stream to be closed. |
FILE* fopen | ( | const char * | filename, |
const char * | mode | ||
) |
Open file.
Opens the file whose name is specified in the parameter filename and associates it with a stream that can be identified in future operations by the FILE pointer returned. The returned stream is fully buffered by default.
filename | C string containing the name of the file to be opened. |
mode | C string containing a file access mode (r, w, a, r+, w+, a+). |
int fprintf | ( | FILE * | file, |
const char * | format, | ||
... | |||
) |
Print formatted data to stdoutWrite formatted data to stream.
Writes the C string pointed by format to the stream. If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
file | Pointer to a FILE object that identifies an output stream. |
format | C string that contains the text to be written to the stream.Can contain embedded format specifiers. |
... | Additional arguments |
int fputc | ( | int | character, |
FILE * | stream | ||
) |
Write character to stream.
Writes a character to the stream and advances the position indicator.
character | The int promotion of the character to be written. |
stream | Pointer to a FILE object that identifies the stream to be closed. |
int fputs | ( | const char * | str, |
FILE * | stream | ||
) |
Write string to stream.
Writes the C string pointed by str to the stream. The function begins copying from the address specified (str) until it reaches the terminating null character ('\0'). This terminating null-character is not copied to the stream.
str | C string with the content to be written to stream. |
stream | Pointer to a FILE object that identifies the stream to be closed. |
Read block of data from stream.
Reads an array of count elements, each one with a size of size bytes, from the stream and stores them in the block of memory specified by ptr. The position indicator of the stream is advanced by the total amount of bytes read.
ptr | Pointer to a block of memory with a size of at least (size*count) bytes, converted to a void*. |
size | Size, in bytes, of each element to be read. |
count | Number of elements, each one with a size of size bytes. |
stream | Pointer to a FILE object that identifies the stream to be closed. |
Reopen stream with different file or mode.
Reuses stream to either open the file specified by filename or to change its access mode. If filename is a null pointer, the function attempts to change the mode of the stream.
filename | C string containing the name of the file to be opened. |
mode | C string containing a file access mode (r, w, a, r+, w+, a+). |
stream | Pointer to a FILE object that identifies the stream to be reopened. |
int fseek | ( | FILE * | stream, |
long int | offset, | ||
int | origin | ||
) |
Reposition stream position indicator.
Sets the position indicator associated with the stream to a new position.
stream | Pointer to a FILE object that identifies the stream to be closed. |
offset | Number of bytes to offset from origin. |
origin | Position used as reference for the offset. It is specified by one of the constants (file begin: SEEK_SET, current position: SEEK_CUR, end of file: SEEK_END). |
Set position indicator of stream.
Restores the current position in the stream to pos.
stream | Pointer to a FILE object that identifies the stream to be closed. |
pos | Pointer to a fpos_t object containing a position previously obtained with fgetpos. |
long int ftell | ( | FILE * | stream | ) |
Get current position in stream.
Returns the current value of the position indicator of the stream.
stream | Pointer to a FILE object that identifies the stream to be closed. |
Write block of data to stream.
Writes an array of count elements, each one with a size of size bytes, from the block of memory pointed by ptr to the current position in the stream. The position indicator of the stream is advanced by the total number of bytes written.
ptr | Pointer to a block of memory with a size of at least (size*count) bytes, converted to a void*. |
size | Size, in bytes, of each element to be read. |
count | Number of elements, each one with a size of size bytes. |
stream | Pointer to a FILE object that identifies the stream to be closed. |
int getc | ( | FILE * | stream | ) |
Get character from stream.
Returns the character currently pointed by the internal file position indicator of the specified stream. The internal file position indicator is then advanced to the next character.
stream | Pointer to a FILE object that identifies the stream to be closed. |
int getchar | ( | ) |
Get character from stdin.
Returns the next character from the standard input.
char* gets | ( | char * | str | ) |
Get string from stdin.
Reads characters from the standard input (stdin) and stores them as a C string into str until a newline character or the end-of-file is reached.
str | Pointer to a block of memory (array of char) where the string read is copied as a C string. |
void perror | ( | const char * | str | ) |
Print error message.
int printf | ( | const char * | format, |
... | |||
) |
Print formatted data to stdout.
Writes the C string pointed by format to the standard output (stdout). If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
format | String that contains text to be written to stdout. Can contain embedded format specifiers. |
... | Additional arguments |
int putc | ( | int | character, |
FILE * | stream | ||
) |
Write character to stream.
Writes a character to the stream and advances the position indicator. The character is written at the position indicated by the internal position indicator of the stream, which is then automatically advanced by one.
character | The int promotion of the character to be written. |
stream | Pointer to a FILE object that identifies the stream to be closed. |
int putchar | ( | int | character | ) |
Write character to stdout.
Writes a character to the standard output (stdout).
character | The int promotion of the character to be written. |
int puts | ( | const char * | str | ) |
Write string to stdout.
Writes the C string pointed by str to the standard output (stdout) and appends a newline character ('
'). The function begins copying from the address specified (str) until it reaches the terminating null character ('\0'). This terminating null-character is not copied to the stream.
str | C string to be printed. |
int remove | ( | const char * | filename | ) |
Remove file.
int rename | ( | const char * | oldname, |
const char * | newname | ||
) |
Rename file.
void rewind | ( | FILE * | stream | ) |
Set position of stream to the beginning.
Sets the position indicator associated with stream to the beginning of the file.
stream | Pointer to a FILE object that identifies the stream to be closed. |
int scanf | ( | const char * | format, |
... | |||
) |
Read formatted data from stdin.
Reads data from stdin and stores them according to the parameter format into the locations pointed by the additional arguments.
format | C string that contains the text to be written to the stream.Can contain embedded format specifiers. |
... | Depending on the format string, the function may expect a sequence of additional arguments, each containing a pointer to allocated storage where the interpretation of the extracted characters is stored with the appropriate type. |
void setbuf | ( | FILE * | stream, |
char * | buffer | ||
) |
Set stream buffer.
Specifies the buffer to be used by the stream for I/O operations, which becomes a fully buffered stream. Or, alternatively, if buffer is a null pointer, buffering is disabled for the stream, which becomes an unbuffered stream.
stream | Pointer to a FILE object that identifies the stream to be closed. |
buffer | User allocated buffer. Shall be at least BUFSIZ bytes long. |
Change stream buffering.
Specifies a buffer for stream. The function allows to specify the mode and size of the buffer (in bytes). If buffer is a null pointer, the function automatically allocates a buffer (using size as a hint on the size to use).
stream | Pointer to a FILE object that identifies the stream to be closed. |
buffer | User allocated buffer. Shall be at least BUFSIZ bytes long. |
mode | Specifies a mode for file buffering (full buffering: _IOFBF, line buffering: _IOLBF, no buffering: _IONBF). |
size | User allocated buffer. Shall be at least BUFSIZ bytes long. |
int sprintf | ( | char * | str, |
const char * | format, | ||
... | |||
) |
Write formatted data to string.
Composes a string with the same text that would be printed if format was used on printf, but instead of being printed, the content is stored as a C string in the buffer pointed by str.
str | Pointer to a buffer where the resulting C-string is stored. The buffer should be large enough to contain the resulting string. |
format | String that contains text to be written to buffer. Can contain embedded format specifiers. |
... | Additional arguments |
int ungetc | ( | int | character, |
FILE * | stream | ||
) |
Unget character from stream.
A character is virtually put back into an input stream, decreasing its internal file position as if a previous getc operation was undone.
character | The int promotion of the character to be written. |
stream | Pointer to a FILE object that identifies the stream to be closed. |
int vfprintf | ( | FILE * | stream, |
const char * | format, | ||
va_list | arg | ||
) |
Print formatted data from variable argument list to stream.
Writes the C string pointed by format to the stream. If format includes format specifiers (subsequences beginning with %), the additional arguments stored in arg list are formatted and inserted in the resulting string replacing their respective specifiers.
stream | Pointer to a FILE object that identifies an output stream. |
format | C string that contains the text to be written to the stream.Can contain embedded format specifiers. |
arg | A value identifying a variable arguments list initialized with va_start. |
int vfscanf | ( | FILE * | stream, |
const char * | format, | ||
va_list | arg | ||
) |
Read formatted data from stream into variable argument list.
Reads data from the stream and stores them according to parameter format into the locations pointed by the elements in the variable argument list identified by arg.
stream | Pointer to a FILE object that identifies an input stream. |
format | C string that contains the text to be written to the stream.Can contain embedded format specifiers. |
arg | A value identifying a variable arguments list initialized with va_start. |
int vprintf | ( | const char * | format, |
va_list | arg | ||
) |
Print formatted data from variable argument list to stdout.
Writes the C string pointed by format to the stream. If format includes format specifiers (subsequences beginning with %), the additional arguments stored in arg list are formatted and inserted in the resulting string replacing their respective specifiers.
format | C string that contains the text to be written to the stream.Can contain embedded format specifiers. |
arg | A value identifying a variable arguments list initialized with va_start. |
int vsprintf | ( | char * | str, |
const char * | format, | ||
va_list | arg | ||
) |
Print formatted data from variable argument list to string.
Composes a string with the same text that would be printed if format was used on printf, but using the elements in the variable argument list identified by arg instead of additional function arguments and storing the resulting content as a C string in the buffer pointed by str.
str | Pointer to a buffer where the resulting C-string is stored. The buffer should be large enough to contain the resulting string. |
format | C string that contains the text to be written to the stream.Can contain embedded format specifiers. |
arg | A value identifying a variable arguments list initialized with va_start. |
FILE* stderr |
Standard error output (default is console).
FILE* stdin |
Standard input (default is keyboard).
FILE* stdout |
Standard output (default is console).