X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=bootcensus;a=blobdiff_plain;f=src%2Flibc%2Fstdio.h;h=19abc10f536ac9c14361f5c3d01a3dfcb629360a;hp=fbc79b70829537ffc00d4d07fd3a5fd9b0434e92;hb=81c11bdd80190ec319a82b0402173cfb65fcbf72;hpb=7dcd5071e600f8cf48174d1fddb3dba57ec9476d diff --git a/src/libc/stdio.h b/src/libc/stdio.h index fbc79b7..19abc10 100644 --- a/src/libc/stdio.h +++ b/src/libc/stdio.h @@ -1,6 +1,6 @@ /* pcboot - bootable PC demo/game kernel -Copyright (C) 2018 John Tsiombikas +Copyright (C) 2018-2019 John Tsiombikas This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +21,18 @@ along with this program. If not, see . #include #include +typedef struct FILE FILE; + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#define EOF (-1) + +#define stdin ((FILE*)0) +#define stdout ((FILE*)1) +#define stderr ((FILE*)2) + int putchar(int c); int puts(const char *s); @@ -33,8 +45,46 @@ int vsprintf(char *buf, const char *fmt, va_list ap); int snprintf(char *buf, size_t sz, const char *fmt, ...); int vsnprintf(char *buf, size_t sz, const char *fmt, va_list ap); +/* TODO */ +int fprintf(FILE *fp, const char *fmt, ...); +int vfprintf(FILE *fp, const char *fmt, va_list ap); + +/* TODO +int fscanf(FILE *fp, const char *fmt, ...); +int vfscanf(FILE *fp, const char *fmt, va_list ap); + +int sscanf(const char *str, const char *fmt, ...); +int vsscanf(const char *ptr, const char *fmt, va_list ap); +*/ + /* printf to the serial port */ int ser_printf(const char *fmt, ...); int ser_vprintf(const char *fmt, va_list ap); +void perror(const char *s); + + +/* FILE I/O */ +FILE *fopen(const char *path, const char *mode); +int fclose(FILE *fp); + +long filesize(FILE *fp); +int fseek(FILE *fp, long offset, int from); +void rewind(FILE *fp); +long ftell(FILE *fp); + +size_t fread(void *buf, size_t size, size_t count, FILE *fp); +size_t fwrite(const void *buf, size_t size, size_t count, FILE *fp); + +int fgetc(FILE *fp); +char *fgets(char *buf, int size, FILE *fp); + +int fputc(int c, FILE *fp); + +int fflush(FILE *fp); + +int feof(FILE *fp); +int ferror(FILE *fp); +void clearerr(FILE *fp); + #endif /* STDIO_H_ */