home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume16 / pcomm2 / part06 / s_menu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-09-14  |  2.7 KB  |  135 lines

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