Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
Data Structures | Macros | Functions | Variables
stdio.h File Reference
#include <pthread.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/reent.h>
#include <sys/types.h>
Include dependency graph for stdio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  FILE
 

Macros

#define SEEK_SET   0
 
#define SEEK_CUR   1
 
#define SEEK_END   2
 
#define EOF   (-1)
 
#define fopen   _fopen
 
#define fclose   _fclose
 
#define fread   _fread
 
#define fwrite   _fwrite
 
#define fseek   _fseek
 
#define ftell   _ftell
 
#define rewind   _rewind
 
#define fileno   _fileno
 
#define freopen   _freopen
 
#define fseeko   _fseeko
 
#define ftello   _ftello
 
#define fputs   _fputs
 
#define fputc   _fputc
 
#define putchar   _putchar
 
#define puts   _puts
 
#define fgetc   _fgetc
 
#define getchar(void)   _getchar
 Read a character from the standard input. More...
 
#define fgets   _fgets
 
#define feof   _feof
 
#define ferror   _ferror
 
#define clearerr   _clearerr
 
#define fflush   _fflush
 
#define setvbuf   _setvbuf
 
#define setbuf   _setbuf
 
#define putc(c, stream)   fputc(c, stream)
 
#define getc(stream)   fgetc(stream)
 
#define getc_unlocked(stream)   _fgetc(stream)
 
#define getchar_unlocked()   _getchar()
 
#define putc_unlocked(c, stream)   _fputc(c, stream)
 
#define putchar_unlocked(c)   _putchar(c)
 
#define fputc_unlocked(c, stream)   _fputc(c, stream)
 
#define fgetc_unlocked(stream)   _fgetc(stream)
 
#define fgets_unlocked(s, size, stream)   _fgets(s, size, stream)
 
#define fputs_unlocked(s, stream)   _fputs(s, stream)
 
#define fread_unlocked(p, size, n, stream)   _fread(p, size, n, stream)
 
#define fwrite_unlocked(p, size, n, stream)   _fwrite(p, size, n, stream)
 
#define feof_unlocked(stream)   _feof(stream)
 
#define ferror_unlocked(stream)   _ferror(stream)
 
#define clearerr_unlocked(stream)   _clearerr(stream)
 
#define fflush_unlocked(stream)   _fflush(stream)
 
#define fileno_unlocked(stream)   _fileno(stream)
 
#define flockfile(stream)   ((void) (stream))
 
#define funlockfile(stream)   ((void) (stream))
 
#define ftrylockfile(stream)   (0)
 
#define __SIZEOF_FILE   sizeof(__FILE)
 
#define _IOFBF   0
 
#define _IOLBF   1
 
#define _IONBF   2
 
#define BUFSIZ   1024
 

Functions

FILEfopen (const char *pathname, const char *mode)
 Open the file whose name is the string pointed to by pathname and associate a stream with it. More...
 
FILEfdopen (int fd, const char *mode)
 Put a stream on a descriptor that is already open. More...
 
FILEfreopen (const char *pathname, const char *mode, FILE *stream)
 Point a stream that is already open at another file, which is how a program replaces one of the standard streams. More...
 
int fseeko (FILE *stream, off_t offset, int whence)
 Reposition a stream, with the offset given as an off_t. More...
 
off_t ftello (FILE *stream)
 Report where a stream is, as an off_t. More...
 
int fclose (FILE *stream)
 Close the given file stream. More...
 
size_t fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
 Read nmemb items of data, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr. More...
 
size_t fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
 Write nmemb items of data, each size bytes long, to the stream pointed to by stream, obtaining them from the location given by ptr. More...
 
int fseek (FILE *stream, long offset, int whence)
 Set the file position indicator for the stream pointed to by stream. More...
 
long ftell (FILE *stream)
 Obtain the current value of the file position indicator. More...
 
void rewind (FILE *stream)
 Set the file position indicator to the beginning of the file. More...
 
int fileno (FILE *stream)
 Examine the argument stream and returns the integer file descriptor used to implement this stream. More...
 
int rename (const char *oldpath, const char *newpath)
 Change the name or the location of a file. More...
 
int remove (const char *pathname)
 Delete a file or an empty directory. More...
 
int printf (const char *format,...)
 Format and print data to the standard output. More...
 
int fprintf (FILE *stream, const char *format,...)
 Format and print data to a file. More...
 
int dprintf (int fd, const char *format,...)
 Format and print data to a file. More...
 
int sprintf (char *str, const char *format,...)
 Format and print data to a buffer. More...
 
int snprintf (char *str, size_t size, const char *format,...)
 Format and print data to a buffer with limited buffer size. More...
 
int vprintf (const char *format, va_list ap)
 Format and print data to the standard output with argument list. More...
 
int vfprintf (FILE *stream, const char *format, va_list ap)
 Format and print data to a file with argument list. More...
 
int vdprintf (int fd, const char *format, va_list ap)
 Format and print data to a file with argument list. More...
 
int vsprintf (char *str, const char *format, va_list ap)
 Format and print data to a buffer with argument list. More...
 
int vsnprintf (char *str, size_t size, const char *format, va_list ap)
 Format and print data to a buffer with limited size and argument list. More...
 
int sscanf (const char *str, const char *format,...)
 Read from the string what the format says is in it. Only the string half of scanf is here: the stream half would have to read a FILE of Tenok, which the one the C library brings is not. More...
 
int vsscanf (const char *str, const char *format, va_list ap)
 Read from the string what the format says is in it, taking the places to put it from a variable argument list. More...
 
int fputs (const char *s, FILE *stream)
 Write a string to the stream, without its terminating null byte. More...
 
int fputc (int c, FILE *stream)
 Write a character to the stream. More...
 
int putchar (int c)
 Write a character to the standard output. More...
 
int puts (const char *s)
 Write a string and a newline to the standard output. More...
 
int fgetc (FILE *stream)
 Read a character from the stream. More...
 
char * fgets (char *s, int size, FILE *stream)
 Read a line from the stream, the newline included, and terminate it. More...
 
int feof (FILE *stream)
 Tell whether the end of the stream has been reached. More...
 
int ferror (FILE *stream)
 Tell whether the stream has failed. More...
 
void clearerr (FILE *stream)
 Clear the end of file and the error state of the stream. More...
 
int fflush (FILE *stream)
 Hand over what the stream is holding. Tenok does not buffer, so there is never anything to hand over. More...
 
int setvbuf (FILE *stream, char *buf, int mode, size_t size)
 Ask the stream to buffer what is written to it. Tenok reaches the device on the call that writes, so the only buffering it can be given is the one it already has. More...
 
void setbuf (FILE *stream, char *buf)
 Ask the stream to buffer what is written to it, the way setvbuf() does, without reporting whether it could be done. More...
 

Variables

FILEstdin
 
FILEstdout
 
FILEstderr
 

Macro Definition Documentation

◆ getchar

int getchar (   void)    _getchar

Read a character from the standard input.

Return values
intThe character read, and EOF at the end of the file or on error.

Function Documentation

◆ clearerr()

void clearerr ( FILE stream)

Clear the end of file and the error state of the stream.

Parameters
streamThe file stream to provide.

◆ dprintf()

int dprintf ( int  fd,
const char *  format,
  ... 
)

Format and print data to a file.

Parameters
strThe pointer to the print buffer.
formatFormat string.
...Print arguments.
Return values
Uponsuccessful return, the function returns the number of characters printed; otherwie a negative value is returned.

◆ fclose()

int fclose ( FILE stream)

Close the given file stream.

Parameters
streamThe file stream to provide.
Return values
int0 on success and nonzero error number on error.

◆ fdopen()

FILE* fdopen ( int  fd,
const char *  mode 
)

Put a stream on a descriptor that is already open.

Parameters
fdThe file descriptor to provide.
modeNot used, the descriptor carries how it was opened.
Return values
FILE*: The stream on success and a null pointer on error, with the reason left in errno.

◆ feof()

int feof ( FILE stream)

Tell whether the end of the stream has been reached.

Parameters
streamThe file stream to provide.
Return values
intNonzero once the end of the file was reached.

◆ ferror()

int ferror ( FILE stream)

Tell whether the stream has failed.

Parameters
streamThe file stream to provide.
Return values
intNonzero once a call on the stream has failed.

◆ fflush()

int fflush ( FILE stream)

Hand over what the stream is holding. Tenok does not buffer, so there is never anything to hand over.

Parameters
streamThe file stream to provide.
Return values
int0 on success and EOF on error.

◆ fgetc()

int fgetc ( FILE stream)

Read a character from the stream.

Parameters
streamThe file stream to provide.
Return values
intThe character read, and EOF at the end of the file or on error.

◆ fgets()

char* fgets ( char *  s,
int  size,
FILE stream 
)

Read a line from the stream, the newline included, and terminate it.

Parameters
sThe buffer to read into.
sizeThe size of the buffer, the null byte included.
streamThe file stream to provide.
Return values
char*: The buffer on success and a null pointer at the end of the file or on error.

◆ fileno()

int fileno ( FILE stream)

Examine the argument stream and returns the integer file descriptor used to implement this stream.

Parameters
streamThe file stream to provide.
Return values
intThe file descriptor integer.

◆ fopen()

FILE* fopen ( const char *  pathname,
const char *  mode 
)

Open the file whose name is the string pointed to by pathname and associate a stream with it.

Parameters
pathnameThe pathname of the file to open.
modeNot used.
Return values
FILE*: File stream object.

◆ fprintf()

int fprintf ( FILE stream,
const char *  format,
  ... 
)

Format and print data to a file.

Parameters
streamThe pointer to the file stream.
formatFormat string.
...Print arguments.
Return values
Uponsuccessful return, the function returns the number of characters printed; otherwie a negative value is returned.

◆ fputc()

int fputc ( int  c,
FILE stream 
)

Write a character to the stream.

Parameters
cThe character to write.
streamThe file stream to provide.
Return values
intThe character written on success and EOF on error.

◆ fputs()

int fputs ( const char *  s,
FILE stream 
)

Write a string to the stream, without its terminating null byte.

Parameters
sThe string to write.
streamThe file stream to provide.
Return values
intA nonnegative number on success and EOF on error.

◆ fread()

size_t fread ( void *  ptr,
size_t  size,
size_t  nmemb,
FILE stream 
)

Read nmemb items of data, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr.

Parameters
ptrThe memory space for storing the read data.
sizeThe number of nmemb bytes to read.
nmembThe bytes number to read at once.
streamThe file stream to provide.
Return values
size_tThe number of the items that were read, which is smaller than nmemb if the end of the file is reached or an error occurs.

◆ freopen()

FILE* freopen ( const char *  pathname,
const char *  mode,
FILE stream 
)

Point a stream that is already open at another file, which is how a program replaces one of the standard streams.

Parameters
pathnameThe pathname of the file to open.
modeThe mode to open it with.
streamThe stream to point at it.
Return values
FILE*: The stream on success and a null pointer on error, with the reason left in errno.

◆ fseek()

int fseek ( FILE stream,
long  offset,
int  whence 
)

Set the file position indicator for the stream pointed to by stream.

Parameters
streamThe file stream to provide.
offsetThe new offset to the position specified by whence.
whenceThe start position of the new offset.
Return values
int0 on success and -1 on error.

◆ fseeko()

int fseeko ( FILE stream,
off_t  offset,
int  whence 
)

Reposition a stream, with the offset given as an off_t.

Parameters
streamThe file stream to provide.
offsetThe new offset from the position whence names.
whenceSEEK_SET, SEEK_CUR or SEEK_END.
Return values
int0 on success and -1 on error, with the reason left in errno.

◆ ftell()

long ftell ( FILE stream)

Obtain the current value of the file position indicator.

Parameters
streamThe file stream to provide.
Return values
longThe current file position on success and -1 on error.

◆ ftello()

off_t ftello ( FILE stream)

Report where a stream is, as an off_t.

Parameters
streamThe file stream to provide.
Return values
off_tThe position on success and -1 on error, with the reason left in errno.

◆ fwrite()

size_t fwrite ( const void *  ptr,
size_t  size,
size_t  nmemb,
FILE stream 
)

Write nmemb items of data, each size bytes long, to the stream pointed to by stream, obtaining them from the location given by ptr.

Parameters
ptrThe data to write to the file.
sizeThe number of nmemb bytes to write.
nmembThe byte number to write at once.
streamThe file stream to provide.
Return values
size_tThe number of the items that were written, which is smaller than nmemb if an error occurs.

◆ printf()

int printf ( const char *  format,
  ... 
)

Format and print data to the standard output.

Parameters
formatFormat string.
...Print arguments.
Return values
Uponsuccessful return, the function returns the number of characters printed; otherwie a negative value is returned.

◆ putchar()

int putchar ( int  c)

Write a character to the standard output.

Parameters
cThe character to write.
Return values
intThe character written on success and EOF on error.

◆ puts()

int puts ( const char *  s)

Write a string and a newline to the standard output.

Parameters
sThe string to write.
Return values
intA nonnegative number on success and EOF on error.

◆ remove()

int remove ( const char *  pathname)

Delete a file or an empty directory.

Parameters
pathnameThe pathname of the file to remove.
Return values
int0 on success and nonzero error number on error.

◆ rename()

int rename ( const char *  oldpath,
const char *  newpath 
)

Change the name or the location of a file.

Parameters
oldpathThe pathname of the file to rename.
newpathThe new pathname of the file.
Return values
int0 on success and nonzero error number on error.

◆ rewind()

void rewind ( FILE stream)

Set the file position indicator to the beginning of the file.

Parameters
streamThe file stream to provide.
Return values
None

◆ setbuf()

void setbuf ( FILE stream,
char *  buf 
)

Ask the stream to buffer what is written to it, the way setvbuf() does, without reporting whether it could be done.

Parameters
streamThe file stream to provide.
bufThe buffer to use, or NULL to ask for no buffering.

◆ setvbuf()

int setvbuf ( FILE stream,
char *  buf,
int  mode,
size_t  size 
)

Ask the stream to buffer what is written to it. Tenok reaches the device on the call that writes, so the only buffering it can be given is the one it already has.

Parameters
streamThe file stream to provide.
bufThe buffer to use, which Tenok does not take.
modeOne of _IOFBF, _IOLBF and _IONBF.
sizeThe size of the buffer.
Return values
int0 when _IONBF was asked for and nonzero otherwise, with errno set to EINVAL.

◆ snprintf()

int snprintf ( char *  str,
size_t  size,
const char *  format,
  ... 
)

Format and print data to a buffer with limited buffer size.

Parameters
strThe pointer to the print buffer.
sizeThe size of the buffer.
formatFormat string.
...Print arguments.
Return values
Uponsuccessful return, the function returns the number of characters printed; otherwie a negative value is returned.

◆ sprintf()

int sprintf ( char *  str,
const char *  format,
  ... 
)

Format and print data to a buffer.

Parameters
strThe pointer to the print buffer.
formatFormat string.
...Print arguments.
Return values
Uponsuccessful return, the function returns the number of characters printed; otherwie a negative value is returned.

◆ sscanf()

int sscanf ( const char *  str,
const char *  format,
  ... 
)

Read from the string what the format says is in it. Only the string half of scanf is here: the stream half would have to read a FILE of Tenok, which the one the C library brings is not.

Parameters
strThe string to read from.
formatWhat to look for.
Return values
intThe number of items read, and EOF if the string ran out first.

◆ vdprintf()

int vdprintf ( int  fd,
const char *  format,
va_list  ap 
)

Format and print data to a file with argument list.

Parameters
fd: File descriptor number.
formatFormat string.
apArgument list.
Return values
Uponsuccessful return, the function returns the number of characters printed; otherwie a negative value is returned.

◆ vfprintf()

int vfprintf ( FILE stream,
const char *  format,
va_list  ap 
)

Format and print data to a file with argument list.

Parameters
streamThe pointer to the file stream.
formatFormat string.
apArgument list.
Return values
Uponsuccessful return, the function returns the number of characters printed; otherwie a negative value is returned.

◆ vprintf()

int vprintf ( const char *  format,
va_list  ap 
)

Format and print data to the standard output with argument list.

Parameters
formatFormat string.
apArgument list.
Return values
Uponsuccessful return, the function returns the number of characters printed; otherwie a negative value is returned.

◆ vsnprintf()

int vsnprintf ( char *  str,
size_t  size,
const char *  format,
va_list  ap 
)

Format and print data to a buffer with limited size and argument list.

Parameters
strThe pointer to the print buffer.
sizeThe size of the buffer.
formatFormat string.
apArgument list.
Return values
Uponsuccessful return, the function returns the number of characters printed; otherwie a negative value is returned.

◆ vsprintf()

int vsprintf ( char *  str,
const char *  format,
va_list  ap 
)

Format and print data to a buffer with argument list.

Parameters
strThe pointer to the print buffer.
sizeThe size of the buffer.
formatFormat string.
apArgument list.
Return values
Uponsuccessful return, the function returns the number of characters printed; otherwie a negative value is returned.

◆ vsscanf()

int vsscanf ( const char *  str,
const char *  format,
va_list  ap 
)

Read from the string what the format says is in it, taking the places to put it from a variable argument list.

Parameters
strThe string to read from.
formatWhat to look for.
apThe places to put what was read.
Return values
intThe number of items read, and EOF if the string ran out first.