/* v01.c
 * Visual Editor, Tastatur testen
 * Autor: Andre Adrian
 * Version: 01Feb2011 fuer CP/M, MS-DOS, MS-Windows, Linux
 */
 
#include <stdio.h>
#ifdef CPM
#	include <conio.h>
#	define system(s)
#endif
#if defined(_MSC_VER) || defined(__TURBOC__)
#	include <conio.h>
#	define putch(c) putchar(c)
#	define cputs(s) fputs(s,stdout)
#	define system(s)
#endif
#ifdef linux
#	define putch(c) putchar(c)
#	define cputs(s) fputs(s,stdout)
#	define getch()  getchar()
#endif

/* Zeichen von Tastatur */
#define ETX	('C'-'@')	/* Strg-C */
 
int main() {
	int c;
	system("stty -icanon -echo");	/* Zeicheneingabe unter Linux */
	do {
		c = getch();
		if (c >= 32 && c <= 126) {
			/* Druckbares ASCII Zeichen direkt zeigen */
			putch(c);
		} else {
			/* Andere ASCII Zeichen als Hexzahl zeigen */
			printf("<%02x>", c);
		}
	} while (c != ETX);
	system("stty sane");		/* Zeileneingabe unter Linux */
	return 0;
}