diff --git a/libmaxsi/c/file.c b/libmaxsi/c/file.c index 57af98a4..8e29fe56 100644 --- a/libmaxsi/c/file.c +++ b/libmaxsi/c/file.c @@ -193,3 +193,16 @@ int fcloseall(void) return (result) ? EOF : 0; } +int fgetc(FILE* fp) +{ + char c; + if ( fread(&c, 1, sizeof(char), fp) < sizeof(char) ) { return EOF; } + return c; +} + +int fputc(int c, FILE* fp) +{ + if ( fwrite(&c, 1, sizeof(char), fp) < sizeof(char) ) { return EOF; } + return c; +} + diff --git a/libmaxsi/c/hsrc/stdio.h b/libmaxsi/c/hsrc/stdio.h index 44a65016..408f0262 100644 --- a/libmaxsi/c/hsrc/stdio.h +++ b/libmaxsi/c/hsrc/stdio.h @@ -81,7 +81,9 @@ extern int feof(FILE* stream); extern int ferror(FILE* stream); extern int fflush(FILE* stream); extern int fileno(FILE* stream); +extern int fgetc(FILE* stream); extern int fprintf(FILE* restrict stream, const char* restrict format, ...); +extern int fputc(int c, FILE* stream); extern size_t fread(void* restrict ptr, size_t size, size_t nitems, FILE* restrict stream); extern int fseek(FILE* stream, long offset, int whence); extern long ftell(FILE* stream); @@ -104,9 +106,7 @@ extern FILE* open_memstream(char** bufp, size_t* sizep); extern FILE* popen(const char* command, const char* mode); extern FILE* tmpfile(void); extern int dprintf(int fildes, const char* restrict format, ...); -extern int fgetc(FILE* stream); extern int fgetpos(FILE* restrict stream, fpos_t* restrict pos); -extern int fputc(int c, FILE* stream); extern int fputs(const char* restrict s, FILE* restrict stream); extern int fscanf(FILE* restrict stream, const char* restrict format, ... ); extern int fseeko(FILE* stream, off_t offset, int whence);