home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / pcomm / part05 / s_axfer.c next >
Encoding:
C/C++ Source or Header  |  1988-05-17  |  3.8 KB  |  131 lines

  1. /*
  2.  * Display the ASCII transfer setup, query for changes.  A return code
  3.  * of 1 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. ascii_xfer_setup()
  13. {
  14.     WINDOW *x_win, *newwin();
  15.     int i, ret_code, num;
  16.     char *ans, *str_prompt(), *menu_prompt(), *strdup();
  17.     void free_ptr();
  18.     extern char *v_yes[], *v_cr[], *v_lf[], *v_delay[];
  19.  
  20.     x_win = newwin(23, 80, 0, 0);
  21.  
  22.     waddstr(x_win, "----------------------------- ");
  23.     wattrstr(x_win, A_BOLD, "ASCII Transfer Setup");
  24.     waddstr(x_win, " -----------------------------");
  25.     mvwaddstr(x_win, 3, 34, "ASCII UPLOAD");
  26.     mvwprintw(x_win, 5, 22, "1) Echo locally ........... %s", param->lecho);
  27.     mvwprintw(x_win, 6, 22, "2) Expand blank lines ..... %s", param->expand);
  28.     mvwprintw(x_win, 7, 22, "3) CR delay (ms) .......... %d", param->cr_delay);
  29.     mvwprintw(x_win, 8, 22, "4) Pace the output ........ %s", param->pace);
  30.     mvwprintw(x_win, 9, 22, "5) CR translation ......... %s", param->cr_up);
  31.     mvwprintw(x_win, 10, 22, "6) LF translation ......... %s", param->lf_up);
  32.     mvwaddstr(x_win, 12, 32, "ASCII DOWNLOAD");
  33.     mvwprintw(x_win, 14, 22, "7) Transfer timeout ....... %d", param->timer);
  34.     mvwprintw(x_win, 15, 22, "8) CR translation ......... %s", param->cr_dn);
  35.     mvwprintw(x_win, 16, 22, "9) LF translation ......... %s", param->lf_dn);
  36.     mvwprintw(x_win, 19, 0, "--------------------------------------------------------------------------------");
  37.     mvwattrstr(x_win, 20, 0, A_BOLD, "OPTION ==> ");
  38.     mvwaddstr(x_win, 20, 60, "Press ESC to return");
  39.     wmove(x_win, 20, 12);
  40.     touchwin(x_win);
  41.     wrefresh(x_win);
  42.                     /* get the option number */
  43.     ret_code = 0;
  44.     while ((i = get_num(x_win, 1)) != -1) {
  45.         switch(i) {
  46.             case 1:
  47.                 if ((ans = menu_prompt(x_win, 5, 50, "Echo locally", v_yes)) != NULL) {
  48.                     free_ptr(param->lecho);
  49.                     param->lecho = strdup(ans);
  50.                     ret_code++;
  51.                 }
  52.                 break;
  53.             case 2:
  54.                 if ((ans = menu_prompt(x_win, 6, 50, "Expand blank lines", v_yes)) != NULL) {
  55.                     free_ptr(param->expand);
  56.                     param->expand = strdup(ans);
  57.                     ret_code++;
  58.                 }
  59.                 break;
  60.             case 3:
  61.                 if ((ans = menu_prompt(x_win, 7, 50, "CR delay (ms)", v_delay)) != NULL) {
  62.                     param->cr_delay = atoi(ans);
  63.                     ret_code++;
  64.                 }
  65.                 break;
  66.             case 4:
  67.                 if ((ans = menu_prompt(x_win, 8, 50, "Pace the output", v_yes)) != NULL) {
  68.                     free_ptr(param->pace);
  69.                     param->pace = strdup(ans);
  70.                     ret_code++;
  71.                 }
  72.                 break;
  73.             case 5:
  74.                 if ((ans = menu_prompt(x_win, 9, 50, "CR translation (upload)", v_cr)) != NULL) {
  75.                     free_ptr(param->cr_up);
  76.                     param->cr_up = strdup(ans);
  77.                     ret_code++;
  78.                 }
  79.                 break;
  80.             case 6:
  81.                 if ((ans = menu_prompt(x_win, 10, 50, "LF translation (upload)", v_lf)) != NULL) {
  82.                     free_ptr(param->lf_up);
  83.                     param->lf_up = strdup(ans);
  84.                     ret_code++;
  85.                 }
  86.                 break;
  87.             case 7:
  88.                 if ((num = num_prompt(x_win, 14, 50, "Transfer timeout", NULL)) != -1) {
  89.                     if (num > MAX_TIMER || num < MIN_TIMER) {
  90.                         beep();
  91.                     /* some reasonable range of values */
  92.                         if (num < MIN_TIMER)
  93.                             num = MIN_TIMER;
  94.                         else
  95.                             num = MAX_TIMER;
  96.                         mvwaddstr(x_win, 14, 50, "   ");
  97.                         wrefresh(x_win);
  98.                         mvwattrnum(x_win, 14, 50, A_BOLD, num);
  99.                         wrefresh(x_win);
  100.                     }
  101.                     param->timer = num;
  102.                     ret_code++;
  103.                 }
  104.                 break;
  105.             case 8:
  106.                 if ((ans = menu_prompt(x_win, 15, 50, "CR translation (download)", v_cr)) != NULL) {
  107.                     free_ptr(param->cr_dn);
  108.                     param->cr_dn = strdup(ans);
  109.                     ret_code++;
  110.                 }
  111.                 break;
  112.             case 9:
  113.                 if ((ans = menu_prompt(x_win, 16, 50, "LF translation (download)", v_lf)) != NULL) {
  114.                     free_ptr(param->lf_dn);
  115.                     param->lf_dn = strdup(ans);
  116.                     ret_code++;
  117.                 }
  118.                 break;
  119.             default:
  120.                 beep();
  121.         }
  122.         mvwaddch(x_win, 20, 12, ' ');
  123.         clear_line(x_win, 21, 0, 0);
  124.         clear_line(x_win, 22, 0, 0);
  125.         wmove(x_win, 20, 12);
  126.         wrefresh(x_win);
  127.     }
  128.     delwin(x_win);
  129.     return(ret_code);
  130. }
  131.