/* stdio.h: Standard input/output. */ #ifndef _STDIO_H #define _STDIO_H #include #include #include typedef struct { int _fd; int _err; int _eof; } FILE; #define EOF -1 extern FILE* stdin; extern FILE* stdout; extern FILE* stderr; #define stdin stdin #define stdout stdout #define stderr stderr #ifdef __cplusplus extern "C" { #endif int fflush(FILE*); /* Open a file and binds a stream to it. */ FILE* fopen(const char* path, const char* mode); /* Bind a stream to a file descriptor. */ FILE* fdopen(int fd, const char* mode); /* Close a file and frees up its stream. */ int fclose(FILE* stream); /* Return the file descriptor associated with a stream. */ int fileno(FILE* stream); /* Read arbitrarily sized items from a stream. */ size_t fread(void* buf, size_t size, size_t nmemb, FILE* stream); /* Write arbitrarily sized items to a stream. */ size_t fwrite(const void* buf, size_t size, size_t nmemb, FILE* stream); /* Move the file position. Clears the end-of-file indicator on success. */ int fseek(FILE* stream, long offset, int whence); /* Return the current file position. */ long ftell(FILE* stream); /* Rewind the file position and clear the error and end-of-file indicators. */ void rewind(FILE* stream); /* Save the current file position. */ int fgetpos(FILE* stream, fpos_t* pos); /* Restore a file position. */ int fsetpos(FILE* stream, const fpos_t* pos); /* Return whether the error indicator was set in stream. */ int ferror(FILE* stream); /* Return whether the end-of-file indicator was set in stream. */ int feof(FILE* stream); /* Write a character to stream. */ int fputc(int c, FILE* stream); /* Write a character to stream. */ int putc(int c, FILE* stream); /* Write a character to standard output. */ int putchar(int c); /* Write a string to stream. */ int fputs(const char* str, FILE* stream); /* Read a character from stream. */ int fgetc(FILE* stream); /* Read a character from stream. */ int getc(FILE* stream); /* Read a character from standard input. */ int getchar(); /* Read a line from stream. */ char* fgets(char* buf, size_t size, FILE* stream); /* Clear the error and end-of-file indicators in stream. */ void clearerr(FILE* stream); void setbuf(FILE*, char*); /* Write formatted output to a file. */ int fprintf(FILE* stream, const char* format, ...); /* Write formatted output to a file. */ int vfprintf(FILE* stream, const char* format, va_list ap); /* Write formatted output into a buffer. */ int sprintf(char* buf, const char* format, ...); /* Write up to max bytes of formatted output into a buffer. */ int snprintf(char* buf, size_t max, const char* format, ...); /* Write formatted output into a buffer. */ int vsprintf(char*, const char*, va_list); /* Write up to max bytes of formatted output into a buffer. */ int vsnprintf(char*, size_t, const char*, va_list); /* Write formatted output to standard output. */ int vprintf(const char*, va_list ap); /* Write formatted output to standard output. */ int printf(const char*, ...); /* Write a string followed by a newline to standard output. */ int puts(const char* s); /* Write an error message to standard error. */ void perror(const char* s); #ifdef __cplusplus } #endif #endif