00001 /* 00002 tc_setraw test program 00003 AUP2, Sec. 4.05.10 00004 00005 Copyright 2003 by Marc J. Rochkind. All rights reserved. 00006 May be copied only for purposes and under conditions described 00007 on the Web page www.basepath.com/aup/copyright.htm. 00008 00009 The Example Files are provided "as is," without any warranty; 00010 without even the implied warranty of merchantability or fitness 00011 for a particular purpose. The author and his publisher are not 00012 responsible for any damages, direct or incidental, resulting 00013 from the use or non-use of these Example Files. 00014 00015 The Example Files may contain defects, and some contain deliberate 00016 coding mistakes that were included for educational reasons. 00017 You are responsible for determining if and how the Example Files 00018 are to be used. 00019 00020 */ 00021 #include "defs.h" 00022 #include <termios.h> 00023 #include "tc_setraw.h" 00024 00025 int main(void) 00026 { 00027 int c; 00028 00029 #if 0 00030 system("stty sane"); 00031 /*[tc_setraw-test]*/ 00032 setbuf(stdout, NULL); 00033 printf("Initial attributes:\n"); 00034 system("stty | fold -s -w 60"); 00035 printf("\r\nRaw attributes:\n"); 00036 tc_setraw(); 00037 system("stty | fold -s -w 60"); 00038 tc_restore(); 00039 printf("\r\nRestored attributes:\n"); 00040 system("stty | fold -s -w 60"); 00041 /*[]*/ 00042 system("stty sane"); 00043 printf("\r\n"); 00044 #else 00045 /*[tc_keystroke-test]*/ 00046 setbuf(stdout, NULL); 00047 while (true) { 00048 c = tc_keystroke(); 00049 putchar(c); 00050 if (c == 5) { /* ^E */ 00051 ec_false( tc_restore() ) 00052 printf("\nExiting...\n"); 00053 exit(EXIT_SUCCESS); 00054 } 00055 } 00056 /*[]*/ 00057 #endif 00058 exit(EXIT_SUCCESS); 00059 00060 EC_CLEANUP_BGN 00061 exit(EXIT_FAILURE); 00062 EC_CLEANUP_END 00063 }