Skip to content

Commit

Permalink
add a bunch of additional stdio.h stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Nov 23, 2024
1 parent 9e4f9a8 commit cb3a894
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/libc/include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ int scanf(const char *format, ...);
int fscanf(FILE *stream, const char *format, ...);
int sscanf(const char *str, const char *format, ...);

int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap);
int vsnprintf(char *str, size_t size, const char *format, va_list ap);

char getchar(void);

int fflush(FILE *stream);
int ferror(FILE *stream);
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *restrict stream);

/*
int vprintf(const char *format, va_list ap);
int vfprintf(FILE *stream, const char *format, va_list ap);
Expand All @@ -74,12 +78,17 @@ __attribute__((__format__(__scanf__,2,0)));
*/

void perror(const char *s);

int fclose(FILE *stream);
FILE *fopen(const char *path, const char *mode);
int feof(FILE *stream);
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
char *fgets(char *s, int size, FILE *stream);
long ftell(FILE *stream);

FILE *popen(const char *command, const char *type);
int pclose(FILE *stream);

FILE *open_memstream(char **ptr, size_t *sizeloc);
#endif
15 changes: 15 additions & 0 deletions src/libc/src/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ int fscanf(FILE *stream, const char *format, ...) { return 0; }
int sscanf(const char *str, const char *format, ...) { return 0; }

int fflush(FILE *stream) { return 0; }
int ferror(FILE *stream) { return 0; }
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *restrict stream) {
return 0;
}

void perror(const char *s) {}

int fclose(FILE *stream) { return 0; }
FILE *fopen(const char *path, const char *mode) { return 0; }
Expand All @@ -33,10 +39,19 @@ size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
return 0;
}
char *fgets(char *s, int size, FILE *stream) { return 0; }
long ftell(FILE *stream) { return 0; }

FILE *popen(const char *command, const char *type) { return 0; }
int pclose(FILE *stream) { return 0; }

int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap) {
return 0;
}
int vsnprintf(char *str, size_t size, const char *format, va_list ap) {
return 0;
}

FILE memstream = {0};
FILE *open_memstream(char **ptr, size_t *sizeloc) {
return &memstream;
}

0 comments on commit cb3a894

Please sign in to comment.