version 1.23, 2006/03/16 21:13:12 |
version 1.24, 2006/03/17 14:43:06 |
|
|
char *sep[] = { "second", "minute", "hour" }; |
char *sep[] = { "second", "minute", "hour" }; |
static char *argv[10]; /* argument vector for take and put */ |
static char *argv[10]; /* argument vector for take and put */ |
|
|
void timeout(int); /* timeout function called on alarm */ |
static void transfer(char *, int, char *); |
void stopsnd(int); /* SIGINT handler during file transfers */ |
static void stopsnd(int); /* SIGINT handler during file transfers */ |
void intcopy(int); /* interrupt routine for file transfers */ |
static void intcopy(int); /* interrupt routine for file transfers */ |
|
static void transmit(FILE *, char *, char *); |
|
static void send(int); |
|
static void execute(char *); |
|
static int args(char *, char **, int); |
|
static void prtime(char *, time_t); |
|
static void tandem(char *); |
|
static void hardwareflow(char *); |
|
static int anyof(char *, char *); |
|
|
/* |
/* |
* FTP - remote ==> local |
* FTP - remote ==> local |
* get a file from the remote host |
* get a file from the remote host |
*/ |
*/ |
void |
void |
getfl(char c) |
getfl(int c) |
{ |
{ |
char buf[256], *cp, *expand(char *); |
char buf[256], *cp; |
|
|
putchar(c); |
putchar(c); |
/* |
/* |
|
|
* Cu-like take command |
* Cu-like take command |
*/ |
*/ |
void |
void |
cu_take(char cc) |
cu_take(int c) |
{ |
{ |
int fd, argc; |
int fd, argc; |
char line[BUFSIZ], *expand(char *), *cp; |
char line[BUFSIZ], *cp; |
|
|
if (prompt("[take] ", copyname, sizeof(copyname))) |
if (prompt("[take] ", copyname, sizeof(copyname))) |
return; |
return; |
|
|
* Bulk transfer routine -- |
* Bulk transfer routine -- |
* used by getfl(), cu_take(), and pipefile() |
* used by getfl(), cu_take(), and pipefile() |
*/ |
*/ |
void |
static void |
transfer(char *buf, int fd, char *eofchars) |
transfer(char *buf, int fd, char *eofchars) |
{ |
{ |
int ct; |
int ct; |
|
|
* FTP - remote ==> local process |
* FTP - remote ==> local process |
* send remote input to local process via pipe |
* send remote input to local process via pipe |
*/ |
*/ |
|
/*ARGSUSED*/ |
void |
void |
pipefile(void) |
pipefile(int c) |
{ |
{ |
int pdes[2]; |
int pdes[2]; |
char buf[256]; |
char buf[256]; |
|
|
* Interrupt service routine for FTP |
* Interrupt service routine for FTP |
*/ |
*/ |
/*ARGSUSED*/ |
/*ARGSUSED*/ |
void |
static void |
stopsnd(int signo) |
stopsnd(int signo) |
{ |
{ |
|
|
stop = 1; |
stop = 1; |
signal(SIGINT, SIG_IGN); |
signal(SIGINT, SIG_IGN); |
} |
} |
|
|
* terminate transmission with pseudo EOF sequence |
* terminate transmission with pseudo EOF sequence |
*/ |
*/ |
void |
void |
sendfile(char cc) |
sendfile(int c) |
{ |
{ |
FILE *fp; |
FILE *fp; |
char *fnamex; |
char *fnamex; |
char *expand(char *); |
|
|
|
putchar(cc); |
putchar(c); |
/* |
/* |
* get file name |
* get file name |
*/ |
*/ |
|
|
* Bulk transfer routine to remote host -- |
* Bulk transfer routine to remote host -- |
* used by sendfile() and cu_put() |
* used by sendfile() and cu_put() |
*/ |
*/ |
void |
static void |
transmit(FILE *fp, char *eofchars, char *command) |
transmit(FILE *fp, char *eofchars, char *command) |
{ |
{ |
char *pc, lastc; |
char *pc, lastc; |
|
|
/* |
/* |
* Cu-like put command |
* Cu-like put command |
*/ |
*/ |
|
/*ARGSUSED*/ |
void |
void |
cu_put(char cc) |
cu_put(int c) |
{ |
{ |
FILE *fp; |
FILE *fp; |
char line[BUFSIZ]; |
char line[BUFSIZ]; |
int argc; |
int argc; |
char *expand(char *); |
|
char *copynamex; |
char *copynamex; |
|
|
if (prompt("[put] ", copyname, sizeof(copyname))) |
if (prompt("[put] ", copyname, sizeof(copyname))) |
|
|
* FTP - send single character |
* FTP - send single character |
* wait for echo & handle timeout |
* wait for echo & handle timeout |
*/ |
*/ |
void |
static void |
send(int c) |
send(int c) |
{ |
{ |
char cc; |
char cc; |
|
|
/* |
/* |
* Escape to local shell |
* Escape to local shell |
*/ |
*/ |
|
/*ARGSUSED*/ |
void |
void |
shell(void) |
shell(int c) |
{ |
{ |
int status; |
int status; |
char *cp; |
char *cp; |
|
|
* Change current working directory of |
* Change current working directory of |
* local portion of tip |
* local portion of tip |
*/ |
*/ |
|
/*ARGSUSED*/ |
void |
void |
chdirectory(void) |
chdirectory(int c) |
{ |
{ |
char dirname[PATH_MAX]; |
char dirname[PATH_MAX]; |
char *cp = dirname; |
char *cp = dirname; |
|
|
exit(0); |
exit(0); |
} |
} |
|
|
|
/*ARGSUSED*/ |
void |
void |
finish(void) |
finish(int c) |
{ |
{ |
char *dismsg; |
char *dismsg; |
|
|
|
|
tipabort(NOSTR); |
tipabort(NOSTR); |
} |
} |
|
|
void |
static void |
intcopy(int signo) |
intcopy(int signo) |
{ |
{ |
raw(); |
raw(); |
|
|
longjmp(intbuf, 1); |
longjmp(intbuf, 1); |
} |
} |
|
|
void |
static void |
execute(char *s) |
execute(char *s) |
{ |
{ |
char *cp; |
char *cp; |
|
|
execl(value(SHELL), cp, "-c", s, (char *)NULL); |
execl(value(SHELL), cp, "-c", s, (char *)NULL); |
} |
} |
|
|
int |
static int |
args(char *buf, char *a[], int num) |
args(char *buf, char *a[], int num) |
{ |
{ |
char *p = buf, *start; |
char *p = buf, *start; |
|
|
return(n); |
return(n); |
} |
} |
|
|
void |
static void |
prtime(char *s, time_t a) |
prtime(char *s, time_t a) |
{ |
{ |
int i; |
int i; |
|
|
printf("\r\n!\r\n"); |
printf("\r\n!\r\n"); |
} |
} |
|
|
|
/*ARGSUSED*/ |
void |
void |
variable(void) |
variable(int c) |
{ |
{ |
char buf[256]; |
char buf[256]; |
|
|
|
|
} |
} |
} |
} |
|
|
|
/*ARGSUSED*/ |
void |
void |
listvariables(void) |
listvariables(int c) |
{ |
{ |
value_t *p; |
value_t *p; |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
|
|
/* |
/* |
* Turn tandem mode on or off for remote tty. |
* Turn tandem mode on or off for remote tty. |
*/ |
*/ |
void |
static void |
tandem(char *option) |
tandem(char *option) |
{ |
{ |
struct termios rmtty; |
struct termios rmtty; |
|
|
/* |
/* |
* Turn hardware flow control on or off for remote tty. |
* Turn hardware flow control on or off for remote tty. |
*/ |
*/ |
void |
static void |
hardwareflow(char *option) |
hardwareflow(char *option) |
{ |
{ |
struct termios rmtty; |
struct termios rmtty; |
|
|
/* |
/* |
* Send a break. |
* Send a break. |
*/ |
*/ |
|
/*ARGSUSED*/ |
void |
void |
genbrk(void) |
genbrk(int c) |
{ |
{ |
|
|
ioctl(FD, TIOCSBRK, NULL); |
ioctl(FD, TIOCSBRK, NULL); |
sleep(1); |
sleep(1); |
ioctl(FD, TIOCCBRK, NULL); |
ioctl(FD, TIOCCBRK, NULL); |
|
|
* Suspend tip |
* Suspend tip |
*/ |
*/ |
void |
void |
suspend(char c) |
suspend(int c) |
{ |
{ |
|
|
unraw(); |
unraw(); |
kill(c == CTRL('y') ? getpid() : 0, SIGTSTP); |
kill(c == CTRL('y') ? getpid() : 0, SIGTSTP); |
raw(); |
raw(); |
|
|
/* |
/* |
* expand a file name if it includes shell meta characters |
* expand a file name if it includes shell meta characters |
*/ |
*/ |
|
|
char * |
char * |
expand(char name[]) |
expand(char name[]) |
{ |
{ |
|
|
/* |
/* |
* Are any of the characters in the two strings the same? |
* Are any of the characters in the two strings the same? |
*/ |
*/ |
int |
static int |
anyof(char *s1, char *s2) |
anyof(char *s1, char *s2) |
{ |
{ |
int c; |
int c; |