diff options
Diffstat (limited to 'lib/stdio.h')
-rw-r--r-- | lib/stdio.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/stdio.h b/lib/stdio.h index 201cce1..4711a29 100644 --- a/lib/stdio.h +++ b/lib/stdio.h @@ -1,6 +1,38 @@ #pragma once +#include <stdarg.h> + +/** An object type used for streams */ +typedef struct FILE_t { + int id; + /** Functions that prints a character to the stream */ + void (*putc)(const struct FILE_t *, char); + /** Function that prints a string to the stream */ + int (*puts)(const struct FILE_t *, const char *, int); + /** Flush all buffers */ + void (*flush)(const struct FILE_t *); +} FILE; + +/** A FILE value corresponding to stdin, the keyboard buffer */ +extern FILE *stdin; +/** A FILE value corresponding to stdout, the display */ +extern FILE *stdout; +/** A FILE value corresponding to stderr, the uart */ +extern FILE *stderr; + /** - * Supports %s (string), %d (decimal), %u (unsigned), %x (hexadecimal) + * Write the formatted string to stdout + * + * Supports ``%s`` (string), ``%d`` (decimal), ``%u`` (unsigned), ``%x`` (hexadecimal) */ int printf(const char *restrict format, ...); + +/** + * Write the formatted string to stream; see printf + */ +int fprintf(FILE *restrict stream, const char *restrict format, ...); + +/** + * Write the formatted string to stream; see printf + */ +int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap); |