libc: fscanf stubs

This commit is contained in:
K. Lange 2018-10-10 11:30:25 +09:00
parent 994150501a
commit 045e511d74
2 changed files with 25 additions and 0 deletions

View File

@ -81,3 +81,5 @@ extern char * tmpnam(char * s);
extern int vsscanf(const char *str, const char *format, va_list ap);
extern int sscanf(const char *str, const char *format, ...);
extern int vfscanf(FILE * stream, const char *format, va_list ap);
extern int fscanf(FILE *stream, const char *format, ...);

View File

@ -22,6 +22,21 @@ int vsscanf(const char *str, const char *format, va_list ap) {
return 0;
}
int vfscanf(FILE * stream, const char *format, va_list ap) {
fprintf(stderr, "%s: fscanf(%d, format=%s, ...);\n", _argv_0, fileno(stream), format);
while (*format) {
if (*format == ' ') {
/* Handle whitespace */
} else if (*format == '%') {
/* Parse */
} else {
/* Expect exact character? */
}
format++;
}
return 0;
}
int sscanf(const char *str, const char *format, ...) {
va_list args;
va_start(args, format);
@ -29,3 +44,11 @@ int sscanf(const char *str, const char *format, ...) {
va_end(args);
return out;
}
int fscanf(FILE *stream, const char *format, ...) {
va_list args;
va_start(args, format);
int out = vfscanf(stream, format, args);
va_end(args);
return out;
}