From 709223a2f015966cd1c15b15dc4f7a56784ceac2 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Fri, 31 May 2024 16:45:22 -0400 Subject: initial implementation of __scanf() --- src/stdio/_stdio.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/stdio/_stdio.h') diff --git a/src/stdio/_stdio.h b/src/stdio/_stdio.h index 80e25546..f363bd75 100644 --- a/src/stdio/_stdio.h +++ b/src/stdio/_stdio.h @@ -1,6 +1,7 @@ #ifndef ___STDIO_H__ #define ___STDIO_H__ +#include #include #include #include @@ -91,9 +92,39 @@ struct io_options { FILE *stream; /* NULL or the output stream */ int fd; /* -1 or the output file descriptor */ size_t maxlen; /* max number of bytes to write to string */ + size_t pos; /* current index in string */ int ret; /* return value */ }; +struct io_conversion { + enum { IO_IN, IO_OUT } dir; + enum { + F_STAR = (1<<0), + F_LEFT = (1<<1), + F_SIGN = (1<<2), + F_SPACE = (1<<3), + F_ALT = (1<<4), + F_ZERO = (1<<4), + } flags; + enum { + L_default, + L_hh, + L_h, + L_l, + L_ll, + L_j, + L_z, + L_t, + L_L, + } length; + int has_width:1; + int has_precision:1; + uintmax_t width; + uintmax_t precision; + char spec; +}; + +size_t __conv(const char *, struct io_conversion *); int __printf(struct io_options * restrict, const char * restrict, va_list); int __scanf(struct io_options * restrict, const char * restrict, va_list); -- cgit v1.2.1