aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules/fancyhello.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/modules/fancyhello.c')
-rw-r--r--com32/modules/fancyhello.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/com32/modules/fancyhello.c b/com32/modules/fancyhello.c
index a59be43a..42c04d92 100644
--- a/com32/modules/fancyhello.c
+++ b/com32/modules/fancyhello.c
@@ -1,3 +1,4 @@
+
#ident "$Id$"
/* ----------------------------------------------------------------------- *
*
@@ -14,31 +15,47 @@
/*
* fancyhello.c
*
- * Hello, World! using libcom32 and ASI console
+ * Hello, World! using libcom32 and ANSI console; also possible to compile
+ * as a Linux application for testing.
*/
#include <string.h>
#include <stdio.h>
+
+#ifdef __COM32__
+
#include <console.h>
+static void console_init(void)
+{
+ /* Write both to the ANSI console and the serial port, if configured */
+ openconsole(&dev_stdcon_r, &dev_ansiserial_w);
+ printf("\033[20h"); /* Automatically convert \r\n -> \n */
+}
+
+#else
+
+static void console_init(void)
+{
+ /* Do Linux initialization (none needed) */
+}
+
+#endif
+
int main(void)
{
char buffer[1024];
- /* Write both to the ANSI console and the serial port, if configured */
- openconsole(&dev_stdcon_r, &dev_ansiserial_w);
+ console_init();
- printf("(lifesign)\r\n(another)\r\n(another)\r\n");
- printf("\033[1;33;44m *** \033[37mHello, World!\033[33m *** \033[0m\r\n");
+ printf("\033[1;33;44m *** \033[37mHello, World!\033[33m *** \033[0m\n");
for (;;) {
printf("\033[1;36m>\033[0m ");
fgets(buffer, sizeof buffer, stdin);
- /* fgets() prints an \n for us, but not \r */
- putchar('\r');
if ( !strncmp(buffer, "exit", 4) )
break;
- printf("\033[1m:\033[0m %s\r", buffer);
+ printf("\033[1m:\033[0m %s", buffer);
}
return 0;
}