home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume16 / pcomm2 / part06 / s_axfer.c next >
Encoding:
C/C++ Source or Header  |  1988-09-14  |  3.8 KB  |  135 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 "config.h"
  9. #include "misc.h"
  10. #include "param.h"
  11.  
  12. int
  13. axfer_setup()
  14. {
  15.     extern char *v_yes[];
  16.     WINDOW *x_win, *newwin();
  17.     int i, ret_code, num;
  18.     char *ans, *menu_prompt(), *strdup();
  19.     void free_ptr();
  20.     static char *v_cr[4] = {"NONE", "STRIP", "ADD LF", NULL};
  21.     static char *v_lf[4] = {"NONE", "STRIP", "ADD CR", NULL};
  22.     static char *v_delay[4] = {"0", "100", "150", NULL};
  23.  
  24.     x_win = newwin(23, 80, 0, 0);
  25.  
  26.     horizontal(x_win, 0, 0, 28);
  27.     mvwattrstr(x_win, 0, 29, A_BOLD, "ASCII Transfer Setup");
  28.     horizontal(x_win, 0, 50, 29);
  29.     mvwaddstr(x_win, 3, 34, "ASCII UPLOAD");
  30.     mvwprintw(x_win, 5, 22, "1) Echo locally ........... %s", param->lecho);
  31.     mvwprintw(x_win, 6, 22, "2) Expand blank lines ..... %s", param->expand);
  32.     mvwprintw(x_win, 7, 22, "3) CR delay (ms) .......... %d", param->cr_delay);
  33.     mvwprintw(x_win, 8, 22, "4) Pace the output ........ %s", param->pace);
  34.     mvwprintw(x_win, 9, 22, "5) CR translation ......... %s", param->cr_up);
  35.     mvwprintw(x_win, 10, 22, "6) LF translation ......... %s", param->lf_up);
  36.     mvwaddstr(x_win, 12, 32, "ASCII DOWNLOAD");
  37.     mvwprintw(x_win, 14, 22, "7) Transfer timeout (sec) . %d", param->timer);
  38.     mvwprintw(x_win, 15, 22, "8) CR translation ......... %s", param->cr_dn);
  39.     mvwprintw(x_win, 16, 22, "9) LF translation ......... %s", param->lf_dn);
  40.     horizontal(x_win, 19, 0, 80);
  41.     mvwattrstr(x_win, 20, 0, A_BOLD, "OPTION ==> ");
  42.     mvwaddstr(x_win, 20, 58, "Press <ESC> to return");
  43.     wmove(x_win, 20, 12);
  44.     touchwin(x_win);
  45.     wrefresh(x_win);
  46.                     /* get the option number */
  47.     ret_code = 0;
  48.     while ((i = get_num(x_win, 1)) != -1) {
  49.         switch (i) {
  50.             case 1:
  51.                 if ((ans = menu_prompt(x_win, 5, 50, "Echo locally", v_yes)) != NULL) {
  52.                     free_ptr(param->lecho);
  53.                     param->lecho = strdup(ans);
  54.                     ret_code++;
  55.                 }
  56.                 break;
  57.             case 2:
  58.                 if ((ans = menu_prompt(x_win, 6, 50, "Expand blank lines", v_yes)) != NULL) {
  59.                     free_ptr(param->expand);
  60.                     param->expand = strdup(ans);
  61.                     ret_code++;
  62.                 }
  63.                 break;
  64.             case 3:
  65.                 if ((ans = menu_prompt(x_win, 7, 50, "CR delay (ms)", v_delay)) != NULL) {
  66.                     param->cr_delay = atoi(ans);
  67.                     ret_code++;
  68.                 }
  69.                 break;
  70.             case 4:
  71.                 if ((ans = menu_prompt(x_win, 8, 50, "Pace the output", v_yes)) != NULL) {
  72.                     free_ptr(param->pace);
  73.                     param->pace = strdup(ans);
  74.                     ret_code++;
  75.                 }
  76.                 break;
  77.             case 5:
  78.                 if ((ans = menu_prompt(x_win, 9, 50, "CR translation (upload)", v_cr)) != NULL) {
  79.                     free_ptr(param->cr_up);
  80.                     param->cr_up = strdup(ans);
  81.                     ret_code++;
  82.                 }
  83.                 break;
  84.             case 6:
  85.                 if ((ans = menu_prompt(x_win, 10, 50, "LF translation (upload)", v_lf)) != NULL) {
  86.                     free_ptr(param->lf_up);
  87.                     param->lf_up = strdup(ans);
  88.                     ret_code++;
  89.                 }
  90.                 break;
  91.             case 7:
  92.                 if ((num = num_prompt(x_win, 14, 50, "Transfer timeout", "(in seconds)")) != -1) {
  93.                     if (num > MAX_TIMER || num < MIN_TIMER) {
  94.                         beep();
  95.                     /* some reasonable range of values */
  96.                         if (num < MIN_TIMER)
  97.                             num = MIN_TIMER;
  98.                         else
  99.                             num = MAX_TIMER;
  100.                         mvwaddstr(x_win, 14, 50, "   ");
  101.                         wrefresh(x_win);
  102.                         mvwattrnum(x_win, 14, 50, A_BOLD, num);
  103.                         wrefresh(x_win);
  104.                     }
  105.                     param->timer = num;
  106.                     ret_code++;
  107.                 }
  108.                 break;
  109.             case 8:
  110.                 if ((ans = menu_prompt(x_win, 15, 50, "CR translation (download)", v_cr)) != NULL) {
  111.                     free_ptr(param->cr_dn);
  112.                     param->cr_dn = strdup(ans);
  113.                     ret_code++;
  114.                 }
  115.                 break;
  116.             case 9:
  117.                 if ((ans = menu_prompt(x_win, 16, 50, "LF translation (download)", v_lf)) != NULL) {
  118.                     free_ptr(param->lf_dn);
  119.                     param->lf_dn = strdup(ans);
  120.                     ret_code++;
  121.                 }
  122.                 break;
  123.             default:
  124.                 beep();
  125.         }
  126.         mvwaddch(x_win, 20, 12, (chtype) ' ');
  127.         clear_line(x_win, 21, 0, 0);
  128.         clear_line(x_win, 22, 0, 0);
  129.         wmove(x_win, 20, 12);
  130.         wrefresh(x_win);
  131.     }
  132.     delwin(x_win);
  133.     return(ret_code);
  134. }
  135.