67 lines
2.2 KiB
C
67 lines
2.2 KiB
C
#ifndef _STDIO_H
|
|
#define _STDIO_H
|
|
|
|
#include <stdarg.h>
|
|
|
|
typedef struct __sFILE FILE;
|
|
typedef unsigned int size_t;
|
|
|
|
extern FILE *stdin;
|
|
extern FILE *stdout;
|
|
extern FILE *stderr;
|
|
|
|
int putchar(int c);
|
|
int puts(const char *s);
|
|
int printf(const char *fmt, ...);
|
|
int vprintf(const char *fmt, va_list ap);
|
|
int sprintf(char *buf, const char *fmt, ...);
|
|
int snprintf(char *buf, size_t n, const char *fmt, ...);
|
|
int vsprintf(char *buf, const char *fmt, va_list ap);
|
|
int vsnprintf(char *buf, size_t n, const char *fmt, va_list ap);
|
|
int fprintf(FILE *stream, const char *fmt, ...);
|
|
int vfprintf(FILE *stream, const char *fmt, va_list ap);
|
|
void perror(const char *prefix);
|
|
int fputc(int c, FILE *stream);
|
|
int fputs(const char *s, FILE *stream);
|
|
int fflush(FILE *stream);
|
|
int fclose(FILE *stream);
|
|
|
|
FILE *fopen(const char *path, const char *mode);
|
|
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
|
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
|
|
int fseek(FILE *stream, long offset, int whence);
|
|
long ftell(FILE *stream);
|
|
int feof(FILE *stream);
|
|
int ferror(FILE *stream);
|
|
void clearerr(FILE *stream);
|
|
|
|
#define SEEK_SET 0
|
|
#define SEEK_CUR 1
|
|
#define SEEK_END 2
|
|
|
|
#define EOF (-1)
|
|
|
|
int getchar(void);
|
|
int fgetc(FILE *stream);
|
|
char *fgets(char *buf, int n, FILE *stream);
|
|
int ungetc(int c, FILE *stream);
|
|
#define getc(s) fgetc(s)
|
|
|
|
// scanf family — only sscanf and vsscanf are implemented (parsing
|
|
// from a string buffer). scanf/fscanf would need a reliable byte-at-
|
|
// a-time stdin which we don't have. Supports %d %i %u %x %X %o %s
|
|
// %c %% with optional `l` long modifier.
|
|
int sscanf (const char *str, const char *fmt, ...);
|
|
int vsscanf(const char *str, const char *fmt, va_list ap);
|
|
void rewind(FILE *stream); // = fseek(s, 0, SEEK_SET) + clearerr
|
|
|
|
// Memory-backed FS: register a memory region as a named file so
|
|
// fopen can open it. `cap` should be >= size; use cap > size for
|
|
// files that may grow on write. `writable` controls whether
|
|
// fopen("...", "w") / "a" / "r+" succeeds. Returns 0 on success,
|
|
// -1 on duplicate name or table full.
|
|
int mfsRegister(const char *path, void *buf, size_t size, size_t cap,
|
|
int writable);
|
|
int mfsUnregister(const char *path);
|
|
|
|
#endif
|