#ifndef DEF_STDIO_H #define DEF_STDIO_H #include #include #ifdef __cplusplus extern "C" { namespace libc { #endif #define EOF 0x1E0F #define TERM_INPUT_BUFFER_SIZE 256 typedef struct { int fd; long pos; // -1 : it's a stream file_info info; // terminal input buffer // Possible states : // - tib_u_begin = tib_u_end = tib_begin : buffer is empty // - tib_begin = tib_u_begin < tib_u_end : buffer contains some data // - tib_begin < tib_u_begin < tib_u_end : buffer contains some data that is // being read, and some space for putting back characters char *tib_begin, *tib_end, *tib_u_begin, *tib_u_end; int term_echo; // enable echoing of entered keypresses ? } FILE; extern FILE term; #define stdin (&term) #define stdout (&term) #define SEEK_SET 0x5EEC0001 #define SEEK_CUR 0x5EEC0002 #define SEEK_END 0x5EEC0003 FILE *fopen(const char *path, const char *mode); void __tce_libc_fsetup(FILE *f); // INTERNAL // These two handle buffering for terminals int fgetc(FILE*); int ungetc(int, FILE*); // These do not handle buffering for terminals size_t fread(void* ptr, size_t size, size_t nmemb, FILE*); size_t fwrite(void* ptr, size_t size, size_t nmemb, FILE*); size_t fseek(FILE *stream, long offset, int whence); long ftell(FILE *stream); void fclose(FILE *f); int getchar(); int scanf(const char *s, ...); int print(const char *s); int printf(const char *s, ...); int fprint(FILE *f, const char *s); int fprintf(FILE *f, const char *s, ...); int vfprintf(FILE *f, const char *s, va_list arg); #ifdef __cplusplus } } #endif #endif