2023-01-07 10:39:15 +00:00
|
|
|
/* stdio.h: Standard input/output. */
|
2023-01-06 19:02:07 +00:00
|
|
|
|
2023-01-06 12:31:14 +00:00
|
|
|
#ifndef _STDIO_H
|
|
|
|
#define _STDIO_H
|
|
|
|
|
2023-03-12 12:15:24 +00:00
|
|
|
#include <bits/seek.h>
|
2023-01-06 16:35:07 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2023-03-12 09:23:08 +00:00
|
|
|
int _fd;
|
|
|
|
int _err;
|
|
|
|
int _eof;
|
2023-01-06 16:35:07 +00:00
|
|
|
} FILE;
|
|
|
|
|
2023-03-12 09:23:08 +00:00
|
|
|
#define EOF -1
|
2023-01-06 16:35:07 +00:00
|
|
|
|
2023-03-18 18:23:18 +00:00
|
|
|
extern FILE* stdout;
|
2023-01-06 16:35:07 +00:00
|
|
|
extern FILE* stderr;
|
2023-03-18 18:23:18 +00:00
|
|
|
#define stdout stdout
|
2023-01-06 16:35:07 +00:00
|
|
|
#define stderr stderr
|
|
|
|
|
2023-01-06 12:31:14 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2023-01-06 16:35:07 +00:00
|
|
|
int fflush(FILE*);
|
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Open a file and binds a stream to it. */
|
2023-03-12 09:23:08 +00:00
|
|
|
FILE* fopen(const char* path, const char* mode);
|
|
|
|
|
2023-03-18 18:23:18 +00:00
|
|
|
/* Bind a stream to a file descriptor. */
|
|
|
|
FILE* fdopen(int fd, const char* mode);
|
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Close a file and frees up its stream. */
|
2023-03-12 09:23:08 +00:00
|
|
|
int fclose(FILE* stream);
|
|
|
|
|
2023-03-12 16:38:35 +00:00
|
|
|
/* Return the file descriptor associated with a stream. */
|
|
|
|
int fileno(FILE* stream);
|
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Read arbitrarily sized items from a stream. */
|
2023-03-12 09:23:08 +00:00
|
|
|
size_t fread(void* buf, size_t size, size_t nmemb, FILE* stream);
|
2023-01-06 16:35:07 +00:00
|
|
|
|
2023-03-12 10:37:41 +00:00
|
|
|
/* Write arbitrarily sized items to a stream. */
|
|
|
|
size_t fwrite(const void* buf, size_t size, size_t nmemb, FILE* stream);
|
2023-01-06 16:35:07 +00:00
|
|
|
|
2023-03-12 12:15:24 +00:00
|
|
|
/* 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);
|
2023-01-06 16:35:07 +00:00
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Return whether the error indicator was set in stream. */
|
2023-03-12 09:23:08 +00:00
|
|
|
int ferror(FILE* stream);
|
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Return whether the end-of-file indicator was set in stream. */
|
2023-03-12 09:23:08 +00:00
|
|
|
int feof(FILE* stream);
|
|
|
|
|
2023-03-18 18:23:18 +00:00
|
|
|
/* 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);
|
|
|
|
|
2023-03-12 10:15:45 +00:00
|
|
|
/* Clear the error and end-of-file indicators in stream. */
|
2023-03-12 09:23:08 +00:00
|
|
|
void clearerr(FILE* stream);
|
|
|
|
|
2023-01-06 16:35:07 +00:00
|
|
|
void setbuf(FILE*, char*);
|
|
|
|
|
2023-03-18 19:11:19 +00:00
|
|
|
/* 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);
|
2023-01-06 19:15:43 +00:00
|
|
|
|
|
|
|
/* 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);
|
2023-01-06 16:35:07 +00:00
|
|
|
|
2023-03-18 19:11:19 +00:00
|
|
|
/* Write formatted output to standard output. */
|
|
|
|
int vprintf(const char*, va_list ap);
|
|
|
|
|
2023-01-07 00:49:26 +00:00
|
|
|
/* 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);
|
|
|
|
|
2023-01-13 20:08:10 +00:00
|
|
|
/* Write an error message to standard error. */
|
|
|
|
void perror(const char* s);
|
|
|
|
|
2023-01-06 12:31:14 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|