home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / pcomm-2.0.2 / part02 / s_menu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-13  |  2.9 KB  |  146 lines

  1. /*
  2.  * Display the setup menu, prompts for a bunch of other menus. 
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <curses.h>
  7. #include "misc.h"
  8.  
  9. static void top_line();
  10.  
  11. void
  12. setup_menu()
  13. {
  14.     extern int fd, xmc;
  15.     WINDOW *s_win, *newwin();
  16.     char *ans, *get_str();
  17.     static int param_flag = 0, modem_flag = 0, ext_flag = 0;
  18.  
  19.     s_win = newwin(LINES-1, COLS, 0, 0);
  20.  
  21.     top_line(s_win);
  22.     mvwaddstr(s_win, 3, 29, "1) TTY Setup");
  23.     mvwaddstr(s_win, 5, 29, "2) Modem Setup");
  24.     mvwaddstr(s_win, 7, 29, "3) Terminal Setup");
  25.     mvwaddstr(s_win, 9, 29, "4) General Setup");
  26.     mvwaddstr(s_win, 11, 29, "5) ASCII Transfer Setup");
  27.     mvwaddstr(s_win, 13, 29, "6) External Protocol Setup");
  28.     mvwaddstr(s_win, 15, 29, "S) Save setup to disk");
  29.     horizontal(s_win, 19, 0, 80);
  30.     mvwattrstr(s_win, 20, 0, A_BOLD, "OPTION ==> ");
  31.     mvwaddstr(s_win, 20, 58, "  Press <ESC> to exit");
  32.     wmove(s_win, 20, 12);
  33.     touchwin(s_win);
  34.     wrefresh(s_win);
  35.  
  36.                     /* get the options */
  37.     while ((ans = get_str(s_win, 1, "123456Ss", "")) != NULL) {
  38.         if (xmc > 0) {
  39.             clear_line(s_win, 0, 0, FALSE);
  40.             wrefresh(s_win);
  41.         }
  42.         switch (*ans) {
  43.             case '1':
  44.                 if (tty_setup())
  45.                     modem_flag++;
  46.                 break;
  47.             case '2':
  48.                 if (modem_setup())
  49.                     modem_flag++;
  50.                 break;
  51.             case '3':
  52.                 if (term_setup())
  53.                     param_flag++;
  54.                 break;
  55.             case '4':
  56.                 if (gen_setup())
  57.                     param_flag++;
  58.                 break;
  59.             case '5':
  60.                 if (axfer_setup())
  61.                     param_flag++;
  62.                 break;
  63.             case '6':
  64.                 if (ext_setup())
  65.                     ext_flag++;
  66.                 break;
  67.             case 's':
  68.             case 'S':
  69.                 if (xmc > 0)
  70.                     top_line(s_win);
  71.                 /*
  72.                  * Writes to disk are not critical, since
  73.                  * the changes are made in memory.
  74.                  */
  75.                 if (param_flag) {
  76.                     mvwattrstr(s_win, 22, 27, A_BLINK, "Updating Parameter File");
  77.                     wrefresh(s_win);
  78.                     wait_key(s_win, 3);
  79.                     if (up_param()) {
  80.                         touchwin(s_win);
  81.                         wrefresh(s_win);
  82.                     }
  83.                     else
  84.                         param_flag = 0;
  85.                 }
  86.                 if (modem_flag) {
  87.                     mvwattrstr(s_win, 22, 27, A_BLINK, "Updating Modem Database");
  88.                     wrefresh(s_win);
  89.                     wait_key(s_win, 3);
  90.                     if (up_modem()) {
  91.                         touchwin(s_win);
  92.                         wrefresh(s_win);
  93.                     }
  94.                     else
  95.                         modem_flag = 0;
  96.                 }
  97.                 if (ext_flag) {
  98.                     mvwattrstr(s_win, 22, 25, A_BLINK, "Updating External Protocols");
  99.                     wrefresh(s_win);
  100.                     wait_key(s_win, 3);
  101.                     if (up_extrnl()) {
  102.                         touchwin(s_win);
  103.                         wrefresh(s_win);
  104.                     }
  105.                     else
  106.                         ext_flag = 0;
  107.                 }
  108.                 clear_line(s_win, 22, 25, FALSE);
  109.                 wrefresh(s_win);
  110.                 break;
  111.             default:
  112.                 beep();
  113.         }
  114.         touchwin(s_win);
  115.         if (xmc > 0)
  116.             top_line(s_win);
  117.  
  118.         mvwaddch(s_win, 20, 12, (chtype) ' ');
  119.         wmove(s_win, 20, 12);
  120.         wrefresh(s_win);
  121.     }
  122.     if (fd == -1) {
  123.         werase(s_win);
  124.         wrefresh(s_win);
  125.     }
  126.     delwin(s_win);
  127.     return;
  128. }
  129.  
  130. /*
  131.  * Put the top line on the window.
  132.  */
  133.  
  134. static void
  135. top_line(win)
  136. WINDOW *win;
  137. {
  138.     clear_line(win, 0, 0, FALSE);
  139.     wrefresh(win);
  140.     horizontal(win, 0, 0, 33);
  141.     mvwattrstr(win, 0, 34, A_BOLD, "Setup Menu");
  142.     horizontal(win, 0, 45, 34);
  143.     wrefresh(win);
  144.     return;
  145. }
  146.