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

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