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

  1. /*
  2.  * Display the general setup, query for changes.  A return code of 1
  3.  * means something was changed.
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <curses.h>
  8. #include "config.h"
  9. #include "misc.h"
  10. #include "param.h"
  11.  
  12. int
  13. gen_setup()
  14. {
  15.     extern char *v_yes[];
  16.     WINDOW *g_win, *newwin();
  17.     int i, num, ret_code;
  18.     char c, *ans, *str_prompt(), *menu_prompt(), chr_prompt();
  19.     char *strdup();
  20.     void free_ptr(), line_set();
  21.     static char *v_abort[3] = {"KEEP", "DELETE", NULL};
  22.  
  23.     g_win = newwin(23, 80, 0, 0);
  24.  
  25.     horizontal(g_win, 0, 0, 32);
  26.     mvwattrstr(g_win, 0, 33, A_BOLD, "General Setup");
  27.     horizontal(g_win, 0, 47, 32);
  28.     mvwprintw(g_win, 3, 22, "1) Default log file ....... %s", param->logfile);
  29.     mvwprintw(g_win, 4, 22, "2) Screen dump file ....... %s", param->dumpfile);
  30.     mvwprintw(g_win, 6, 22, "3) Strip high bit  ........ %s", param->strip);
  31.     mvwprintw(g_win, 8, 22, "4) Pause character ........ %c", param->pause_char);
  32.     mvwprintw(g_win, 9, 22, "5) CR character ........... %c", param->cr_char);
  33.     mvwprintw(g_win, 10, 22, "6) CTRL character ......... %c", param->ctrl_char);
  34.     mvwprintw(g_win, 11, 22, "7) ESC character .......... %c", param->esc_char);
  35.     mvwprintw(g_win, 12, 22, "8) Break character ........ %c", param->brk_char);
  36.     mvwprintw(g_win, 14, 22, "9) Aborted downloads ...... %s", param->abort);
  37.     mvwprintw(g_win, 16, 21, "10) Connect delay (sec) .... %d", param->c_delay);
  38.     mvwprintw(g_win, 17, 21, "11) Redial delay (sec) ..... %d", param->r_delay);
  39.     horizontal(g_win, 19, 0, 80);
  40.     mvwattrstr(g_win, 20, 0, A_BOLD, "OPTION ==> ");
  41.     mvwaddstr(g_win, 20, 58, "Press <ESC> to return");
  42.     wmove(g_win, 20, 12);
  43.     touchwin(g_win);
  44.     wrefresh(g_win);
  45.                     /* get the option number */
  46.     ret_code = 0;
  47.     while ((i = get_num(g_win, 2)) != -1) {
  48.         switch (i) {
  49.             case 1:
  50.                 if ((ans = str_prompt(g_win, 3, 50, "Default log file", "")) != NULL) {
  51.                     free_ptr(param->logfile);
  52.                     param->logfile = strdup(ans);
  53.                     ret_code++;
  54.                 }
  55.                 break;
  56.             case 2:
  57.                 if ((ans = str_prompt(g_win, 4, 50, "Default screen dump file", "")) != NULL) {
  58.                     free_ptr(param->dumpfile);
  59.                     param->dumpfile = strdup(ans);
  60.                     ret_code++;
  61.                 }
  62.                 break;
  63.             case 3:
  64.                 if ((ans = menu_prompt(g_win, 6, 50, "Strip high bit?", v_yes)) != NULL) {
  65.                     free_ptr(param->strip);
  66.                     param->strip = strdup(ans);
  67.                     line_set();
  68.                     ret_code++;
  69.                 }
  70.                 break;
  71.             case 4:
  72.                 if ((c = chr_prompt(g_win, 8, 50, "Pause character", "1 second")) != NULL) {
  73.                     param->pause_char = c;
  74.                     ret_code++;
  75.                 }
  76.                 break;
  77.             case 5:
  78.                 if ((c = chr_prompt(g_win, 9, 50, "CR character", "(carriage return)")) != NULL) {
  79.                     param->cr_char = c;
  80.                     ret_code++;
  81.                 }
  82.                 break;
  83.             case 6:
  84.                 if ((c = chr_prompt(g_win, 10, 50, "CTRL character", "(control)")) != NULL) {
  85.                     param->ctrl_char = c;
  86.                     ret_code++;
  87.                 }
  88.                 break;
  89.             case 7:
  90.                 if ((c = chr_prompt(g_win, 11, 50, "ESC character", "(escape)")) != NULL) {
  91.                     param->esc_char = c;
  92.                     ret_code++;
  93.                 }
  94.                 break;
  95.             case 8:
  96.                 if ((c = chr_prompt(g_win, 12, 50, "Break character", "")) != NULL) {
  97.                     param->brk_char = c;
  98.                     ret_code++;
  99.                 }
  100.             case 9:
  101.                 if ((ans = menu_prompt(g_win, 14, 50, "Aborted downloads", v_abort)) != NULL) {
  102.                     free_ptr(param->abort);
  103.                     param->abort = strdup(ans);
  104.                     ret_code++;
  105.                 }
  106.                 break;
  107.             case 10:
  108.                 if ((num = num_prompt(g_win, 16, 50, "Connect delay time", "(in seconds)")) != -1) {
  109.                     if (num > MAX_CDELAY || num < MIN_CDELAY) {
  110.                         beep();
  111.                     /* some reasonable range of values */
  112.                         if (num < MIN_CDELAY)
  113.                             num = MIN_CDELAY;
  114.                         else
  115.                             num = MAX_CDELAY;
  116.                         mvwaddstr(g_win, 16, 50, "   ");
  117.                         wrefresh(g_win);
  118.                         mvwattrnum(g_win, 16, 50, A_BOLD, num);
  119.                         wrefresh(g_win);
  120.                     }
  121.                     param->c_delay = num;
  122.                     ret_code++;
  123.                 }
  124.                 break;
  125.             case 11:
  126.                 if ((num = num_prompt(g_win, 17, 50, "Redial delay time", "(in seconds)")) != -1) {
  127.                     if (num > MAX_PAUSE || num < MIN_PAUSE) {
  128.                         beep();
  129.                     /* some reasonable range */
  130.                         if (num < MIN_PAUSE)
  131.                             num = MIN_PAUSE;
  132.                         else
  133.                             num = MAX_PAUSE;
  134.                         mvwaddstr(g_win, 17, 50, "    ");
  135.                         wrefresh(g_win);
  136.                         mvwattrnum(g_win, 17, 50, A_BOLD, num);
  137.                         wrefresh(g_win);
  138.                     }
  139.                     param->r_delay = num;
  140.                     ret_code++;
  141.                 }
  142.                 break;
  143.             default:
  144.                 beep();
  145.         }
  146.         mvwaddstr(g_win, 20, 12, "  ");
  147.         clear_line(g_win, 21, 0, 0);
  148.         clear_line(g_win, 22, 0, 0);
  149.         wmove(g_win, 20, 12);
  150.         wrefresh(g_win);
  151.     }
  152.     delwin(g_win);
  153.     return(ret_code);
  154. }
  155.