00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef FREEBSD
00026 #define bool bool_aup
00027 #endif
00028 #include "defs.h"
00029 #ifndef FREEBSD
00030 #undef bool
00031 #endif
00032
00033
00034 #include <curses.h>
00035
00036
00037 #define ec_ERR(x) ec_cmp(x, ERR)
00038
00039 int main(void)
00040 {
00041 int c;
00042 char s[100];
00043 bool ok = false;
00044
00045 (void)initscr();
00046 ec_ERR( raw() )
00047 while (true) {
00048 ec_ERR( clear() )
00049 ec_ERR( mvaddstr(2, 9, "What do you want to do?") )
00050 ec_ERR( mvaddstr(3, 9, "1. Check out tape/DVD") )
00051 ec_ERR( mvaddstr(4, 9, "2. Reserve tape/DVD") )
00052 ec_ERR( mvaddstr(5, 9, "3. Register new member") )
00053 ec_ERR( mvaddstr(6, 9, "4. Search for title/actor") )
00054 ec_ERR( mvaddstr(7, 9, "5. Quit") )
00055 ec_ERR( mvaddstr(9, 9, "(Type item number to continue)") )
00056 ec_ERR( c = getch() )
00057 switch (c) {
00058 case '1':
00059 case '2':
00060 case '3':
00061 case '4':
00062 ec_ERR( clear() )
00063 snprintf(s, sizeof(s), "You typed %c", c);
00064 ec_ERR( mvaddstr(4, 9, s) )
00065 ec_ERR( mvaddstr(9, 9, "(Press any key to continue)") )
00066 ec_ERR( getch() )
00067 break;
00068 case '5':
00069 ok = true;
00070 EC_CLEANUP
00071 default:
00072 ec_ERR( beep() )
00073 }
00074 }
00075
00076 EC_CLEANUP_BGN
00077 (void)clear();
00078 (void)refresh();
00079 (void)endwin();
00080 exit(ok ? EXIT_SUCCESS : EXIT_FAILURE);
00081 EC_CLEANUP_END
00082 }