home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume16
/
pcomm2
/
part08
/
x_win.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-09-14
|
3KB
|
98 lines
/*
* Display the file transfer window, and invoke the transfer protocol.
*/
#include <stdio.h>
#include <curses.h>
#include "config.h"
#ifdef OLDCURSES
#include <termio.h>
#endif /* OLDCURSES */
#include "dial_dir.h"
#include "misc.h"
#include "xmodem.h"
void
xfer_win(list, up, type)
char *list;
int up, type;
{
extern int fd;
WINDOW *xf_win, *newwin();
int ret_code, fast, my_speed;
void xmodem_mode(), input_off(), line_set(), error_win(), st_line();
static int speed[15] = {0, 50, 75, 110, 134, 150, 200, 300, 600,
1200, 1800, 2400, 4800, 9600, 19200};
struct termio tbuf;
touchwin(stdscr);
refresh();
st_line("");
xf_win = newwin(15, 44, 2, 30);
/*
* This window should be in the non-blocking mode, so we can
* scan the keyboard for input while transferring a file.
*/
nodelay(xf_win, 1);
/* basic window stuff */
mvwaddstr(xf_win, 2, 14, "Protocol:");
mvwaddstr(xf_win, 3, 13, "File name:");
mvwaddstr(xf_win, 4, 13, "File size:");
mvwaddstr(xf_win, 5, 4, "Error check method:");
mvwaddstr(xf_win, 6, 5, "Est transfer time:");
mvwaddstr(xf_win, 7, 11, "Block count:");
mvwaddstr(xf_win, 8, 6, "Percent complete:");
mvwaddstr(xf_win, 9, 5, "Bytes transferred:");
mvwaddstr(xf_win, 10, 5, "Errors this block:");
mvwaddstr(xf_win, 11, 5, "Total error count:");
mvwaddstr(xf_win, 12, 10, "Last message: NONE");
box(xf_win, VERT, HORZ);
if (up)
mvwattrstr(xf_win, 0, 17, A_BOLD, " Uploading ");
else
mvwattrstr(xf_win, 0, 16, A_BOLD, " Downloading ");
mvwaddstr(xf_win, 14, 11, " Press <ESC> to abort ");
wrefresh(xf_win);
/* fix up the terminal mode */
input_off();
xmodem_mode(fd);
/*
* Is your terminal slower than the xfer baud rate? For example:
* I'm at home with my PC and 1200 baud modem, I call my system
* at work so I can use their 2400 baud modems to call some other
* system. In this case, I don't wanna spend too much time updating
* my screen at 1200 baud, when I'm transferring the file at 2400 baud.
*/
fast = 0;
ioctl(0, TCGETA, &tbuf);
my_speed = speed[tbuf.c_cflag & CBAUD];
if (my_speed >= dir->baud[dir->d_cur])
fast++;
if (up)
ret_code = send_xmodem(xf_win, list, type, fast);
else
ret_code = rcv_xmodem(xf_win, list, type, fast);
nodelay(xf_win, 0);
/* prompt for a key on errors */
if (ret_code) {
beep();
clear_line(xf_win, 13, 9, 1);
wattrstr(xf_win, A_BOLD, "Press any key to continue");
wrefresh(xf_win);
wgetch(xf_win);
}
werase(xf_win);
wrefresh(xf_win);
delwin(xf_win);
/* undo what xmodem_mode() did */
line_set();
return;
}