From 873a103fb71d6b7b1993a64535a7fa150317ca3c Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sat, 7 Feb 2015 10:08:34 -0500 Subject: refactor stdio --- libc/stdio.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'libc/stdio.c') diff --git a/libc/stdio.c b/libc/stdio.c index 92fba27..0ef8b0c 100644 --- a/libc/stdio.c +++ b/libc/stdio.c @@ -1,20 +1,33 @@ -#include "tty.h" +#include "log.h" #include #include #include +static void (*putchar_ptr)(char) = log_putchar; +static void (*puts_ptr)(const char*) = log_puts; + int putchar(int ch) { - tty_putchar((char)ch); + putchar_ptr((char)ch); return 0; } int puts(const char* str) { - tty_puts(str); + puts_ptr(str); return 0; } +void set_putchar(void (*func)(char)) +{ + putchar_ptr = func; +} + +void set_puts(void (*func)(const char*)) +{ + puts_ptr = func; +} + static char hex_table[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; -- cgit v1.1