home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / pcomm / part05 / s_gen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-17  |  4.2 KB  |  146 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 "misc.h"
  9. #include "param.h"
  10.  
  11. int
  12. gen_setup()
  13. {
  14.     WINDOW *g_win, *newwin();
  15.     int i, num, ret_code;
  16.     char c, *ans, *str_prompt(), *menu_prompt(), chr_prompt();
  17.     char *strdup();
  18.     void free_ptr();
  19.     extern char *v_yes[], *v_abort[];
  20.  
  21.     g_win = newwin(23, 80, 0, 0);
  22.  
  23.     waddstr(g_win, "--------------------------------- ");
  24.     wattrstr(g_win, A_BOLD, "General Setup");
  25.     waddstr(g_win, " --------------------------------");
  26.     mvwprintw(g_win, 3, 22, "1) Default log file ....... %s", param->logfile);
  27.     mvwprintw(g_win, 4, 22, "2) Screen dump file ....... %s", param->dumpfile);
  28.     mvwprintw(g_win, 6, 22, "3) Strip high bit  ........ %s", param->strip);
  29.     mvwprintw(g_win, 8, 22, "4) Pause character ........ %c", param->pause_char);
  30.     mvwprintw(g_win, 9, 22, "5) CR character ........... %c", param->cr_char);
  31.     mvwprintw(g_win, 10, 22, "6) CTRL character ......... %c", param->ctrl_char);
  32.     mvwprintw(g_win, 11, 22, "7) ESC character .......... %c", param->esc_char);
  33.     mvwprintw(g_win, 13, 22, "8) Aborted downloads ...... %s", param->abort);
  34.     mvwprintw(g_win, 15, 22, "9) Connect delay time ..... %d", param->cdelay);
  35.     mvwprintw(g_win, 16, 21, "10) Pause between redials .. %d", param->pause);
  36.     mvwprintw(g_win, 19, 0, "--------------------------------------------------------------------------------");
  37.     mvwattrstr(g_win, 20, 0, A_BOLD, "OPTION ==> ");
  38.     mvwaddstr(g_win, 20, 60, "Press ESC to return");
  39.     wmove(g_win, 20, 12);
  40.     touchwin(g_win);
  41.     wrefresh(g_win);
  42.                     /* get the option number */
  43.     ret_code = 0;
  44.     while ((i = get_num(g_win, 2)) != -1) {
  45.         switch(i) {
  46.             case 1:
  47.                 if ((ans = str_prompt(g_win, 3, 50, "Default log file", NULL)) != NULL) {
  48.                     free_ptr(param->logfile);
  49.                     param->logfile = strdup(ans);
  50.                     ret_code++;
  51.                 }
  52.                 break;
  53.             case 2:
  54.                 if ((ans = str_prompt(g_win, 4, 50, "Default screen dump file", NULL)) != NULL) {
  55.                     free_ptr(param->dumpfile);
  56.                     param->dumpfile = strdup(ans);
  57.                     ret_code++;
  58.                 }
  59.                 break;
  60.             case 3:
  61.                 if ((ans = menu_prompt(g_win, 6, 50, "Strip high bit ?", v_yes)) != NULL) {
  62.                     free_ptr(param->strip);
  63.                     param->strip = strdup(ans);
  64.                     ret_code++;
  65.                 }
  66.                 break;
  67.             case 4:
  68.                 if ((c = chr_prompt(g_win, 8, 50, "Pause character", "1 second")) != NULL) {
  69.                     param->pause_char = c;
  70.                     ret_code++;
  71.                 }
  72.                 break;
  73.             case 5:
  74.                 if ((c = chr_prompt(g_win, 9, 50, "CR character", "(carriage return)")) != NULL) {
  75.                     param->cr_char = c;
  76.                     ret_code++;
  77.                 }
  78.                 break;
  79.             case 6:
  80.                 if ((c = chr_prompt(g_win, 10, 50, "CTRL character", "(control)")) != NULL) {
  81.                     param->ctrl_char = c;
  82.                     ret_code++;
  83.                 }
  84.                 break;
  85.             case 7:
  86.                 if ((c = chr_prompt(g_win, 11, 50, "ESC character", "(escape)")) != NULL) {
  87.                     param->esc_char = c;
  88.                     ret_code++;
  89.                 }
  90.                 break;
  91.             case 8:
  92.                 if ((ans = menu_prompt(g_win, 13, 50, "Aborted downloads", v_abort)) != NULL) {
  93.                     free_ptr(param->abort);
  94.                     param->abort = strdup(ans);
  95.                     ret_code++;
  96.                 }
  97.                 break;
  98.             case 9:
  99.                 if ((num = num_prompt(g_win, 15, 50, "Connect delay time", "in seconds")) != -1) {
  100.                     if (num > MAX_CDELAY || num < MIN_CDELAY) {
  101.                         beep();
  102.                     /* some reasonable range of values */
  103.                         if (num < MIN_CDELAY)
  104.                             num = MIN_CDELAY;
  105.                         else
  106.                             num = MAX_CDELAY;
  107.                         mvwaddstr(g_win, 15, 50, "   ");
  108.                         wrefresh(g_win);
  109.                         mvwattrnum(g_win, 15, 50, A_BOLD, num);
  110.                         wrefresh(g_win);
  111.                     }
  112.                     param->cdelay = num;
  113.                     ret_code++;
  114.                 }
  115.                 break;
  116.             case 10:
  117.                 if ((num = num_prompt(g_win, 16, 50, "Pause between redials", "in seconds")) != -1) {
  118.                     if (num > MAX_PAUSE || num < MIN_PAUSE) {
  119.                         beep();
  120.                     /* some reasonable range */
  121.                         if (num < MIN_PAUSE)
  122.                             num = MIN_PAUSE;
  123.                         else
  124.                             num = MAX_PAUSE;
  125.                         mvwaddstr(g_win, 16, 50, "    ");
  126.                         wrefresh(g_win);
  127.                         mvwattrnum(g_win, 16, 50, A_BOLD, num);
  128.                         wrefresh(g_win);
  129.                     }
  130.                     param->pause = num;
  131.                     ret_code++;
  132.                 }
  133.                 break;
  134.             default:
  135.                 beep();
  136.         }
  137.         mvwaddstr(g_win, 20, 12, "  ");
  138.         clear_line(g_win, 21, 0, 0);
  139.         clear_line(g_win, 22, 0, 0);
  140.         wmove(g_win, 20, 12);
  141.         wrefresh(g_win);
  142.     }
  143.     delwin(g_win);
  144.     return(ret_code);
  145. }
  146.