[IO] rework dprintf to take a debug level, defined in DEBUGLEVEL
printf at the moment just calls dprintf, but soon will become
a seperate I/O queue.
diff --git a/app/console/console.c b/app/console/console.c
index 6fa4a4b..7f450b5 100644
--- a/app/console/console.c
+++ b/app/console/console.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
+#include <stdio.h>
static cmd_block *command_list = NULL;
@@ -81,7 +82,7 @@
char c;
/* loop until we get a char */
- if (dgetc(&c) < 0)
+ if (getc(&c) < 0)
continue;
// printf("c = 0x%hhx\n", c);
@@ -90,16 +91,16 @@
switch (c) {
case '\r':
case '\n':
- dputc(c);
+ putc(c);
goto done;
case 0x7f: // backspace or delete
case 0x8:
if (pos > 0) {
pos--;
- dputs("\x1b[1D"); // move to the left one
- dputc(' ');
- dputs("\x1b[1D"); // move to the left one
+ puts("\x1b[1D"); // move to the left one
+ putc(' ');
+ puts("\x1b[1D"); // move to the left one
}
break;
@@ -109,7 +110,7 @@
default:
buffer[pos++] = c;
- dputc(c);
+ putc(c);
}
} else if (escape_level == 1) {
// inside an escape, look for '['
@@ -123,14 +124,14 @@
switch (c) {
case 67: // right arrow
buffer[pos++] = ' ';
- dputc(' ');
+ putc(' ');
break;
case 68: // left arrow
if (pos > 0) {
pos--;
- dputs("\x1b[1D"); // move to the left one
- dputc(' ');
- dputs("\x1b[1D"); // move to the left one
+ puts("\x1b[1D"); // move to the left one
+ putc(' ');
+ puts("\x1b[1D"); // move to the left one
}
break;
case 65: // up arrow
@@ -145,7 +146,7 @@
/* end of line. */
if (pos == (len - 1)) {
- dputs("\nerror: line too long\n");
+ puts("\nerror: line too long\n");
pos = 0;
goto done;
}
@@ -240,7 +241,7 @@
printf("entering main console loop\n");
for (;;) {
- dputs("] ");
+ puts("] ");
int len = read_line(buffer, sizeof(buffer));
if (len == 0)