aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules/fancyhello.c
diff options
context:
space:
mode:
authorhpa <hpa>2004-12-01 00:11:20 +0000
committerhpa <hpa>2004-12-01 00:11:20 +0000
commitaf175fa146b8117a3f477deb81e6f6bde763d296 (patch)
tree716fc2435080dac0ecc7824e12a055f79d887367 /com32/modules/fancyhello.c
parentb2d5b135fa40925c5677705e12ac3347cdb1e839 (diff)
downloadsyslinux-elf-af175fa146b8117a3f477deb81e6f6bde763d296.tar.gz
syslinux-elf-af175fa146b8117a3f477deb81e6f6bde763d296.tar.xz
syslinux-elf-af175fa146b8117a3f477deb81e6f6bde763d296.zip
Use auto CRNL; compile demo for Linux too
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;
}