version 1.6, 1997/08/22 22:42:07 |
version 1.7, 1997/09/01 23:24:23 |
|
|
* FTP - remote ==> local |
* FTP - remote ==> local |
* get a file from the remote host |
* get a file from the remote host |
*/ |
*/ |
|
void |
getfl(c) |
getfl(c) |
char c; |
char c; |
{ |
{ |
|
|
/* |
/* |
* Cu-like take command |
* Cu-like take command |
*/ |
*/ |
|
void |
cu_take(cc) |
cu_take(cc) |
char cc; |
char cc; |
{ |
{ |
|
|
|
|
if (prompt("[take] ", copyname, sizeof(copyname))) |
if (prompt("[take] ", copyname, sizeof(copyname))) |
return; |
return; |
if ((argc = args(copyname, argv)) < 1 || argc > 2) { |
if ((argc = args(copyname, argv, sizeof(argv)/sizeof(argv[0]))) < 1 || |
|
argc > 2) { |
printf("usage: <take> from [to]\r\n"); |
printf("usage: <take> from [to]\r\n"); |
return; |
return; |
} |
} |
|
|
} |
} |
|
|
static jmp_buf intbuf; |
static jmp_buf intbuf; |
|
|
/* |
/* |
* Bulk transfer routine -- |
* Bulk transfer routine -- |
* used by getfl(), cu_take(), and pipefile() |
* used by getfl(), cu_take(), and pipefile() |
*/ |
*/ |
|
void |
transfer(buf, fd, eofchars) |
transfer(buf, fd, eofchars) |
char *buf, *eofchars; |
char *buf, *eofchars; |
|
int fd; |
{ |
{ |
register int ct; |
register int ct; |
char c, buffer[BUFSIZ]; |
char c, buffer[BUFSIZ]; |
register char *p = buffer; |
char *p = buffer; |
register int cnt, eof; |
register int cnt, eof; |
time_t start; |
time_t start; |
sig_t f; |
sig_t f; |
|
|
p = buffer; |
p = buffer; |
} |
} |
} |
} |
if (cnt = (p-buffer)) |
if ((cnt = (p-buffer))) |
if (write(fd, buffer, cnt) != cnt) |
if (write(fd, buffer, cnt) != cnt) |
printf("\r\nwrite error\r\n"); |
printf("\r\nwrite error\r\n"); |
|
|
|
|
* FTP - remote ==> local process |
* FTP - remote ==> local process |
* send remote input to local process via pipe |
* send remote input to local process via pipe |
*/ |
*/ |
|
void |
pipefile() |
pipefile() |
{ |
{ |
int cpid, pdes[2]; |
int cpid, pdes[2]; |
|
|
* send local file to remote host |
* send local file to remote host |
* terminate transmission with pseudo EOF sequence |
* terminate transmission with pseudo EOF sequence |
*/ |
*/ |
|
void |
sendfile(cc) |
sendfile(cc) |
char cc; |
char cc; |
{ |
{ |
|
|
* 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 |
transmit(fd, eofchars, command) |
transmit(fd, eofchars, command) |
FILE *fd; |
FILE *fd; |
char *eofchars, *command; |
char *eofchars, *command; |
|
|
/* |
/* |
* Cu-like put command |
* Cu-like put command |
*/ |
*/ |
|
void |
cu_put(cc) |
cu_put(cc) |
char cc; |
char cc; |
{ |
{ |
|
|
|
|
if (prompt("[put] ", copyname, sizeof(copyname))) |
if (prompt("[put] ", copyname, sizeof(copyname))) |
return; |
return; |
if ((argc = args(copyname, argv)) < 1 || argc > 2) { |
if ((argc = args(copyname, argv, sizeof(argv)/sizeof(argv[0]))) < 1 || |
|
argc > 2) { |
printf("usage: <put> from [to]\r\n"); |
printf("usage: <put> from [to]\r\n"); |
return; |
return; |
} |
} |
|
|
* FTP - send single character |
* FTP - send single character |
* wait for echo & handle timeout |
* wait for echo & handle timeout |
*/ |
*/ |
|
void |
send(c) |
send(c) |
char c; |
int c; |
{ |
{ |
char cc; |
char cc; |
int retry = 0; |
int retry = 0; |
|
|
* Stolen from consh() -- puts a remote file on the output of a local command. |
* Stolen from consh() -- puts a remote file on the output of a local command. |
* Identical to consh() except for where stdout goes. |
* Identical to consh() except for where stdout goes. |
*/ |
*/ |
|
void |
pipeout(c) |
pipeout(c) |
{ |
{ |
char buf[256]; |
char buf[256]; |
int cpid, status, p; |
int cpid, status, p; |
time_t start; |
time_t start = time(NULL); |
|
|
putchar(c); |
putchar(c); |
if (prompt("Local command? ", buf, sizeof(buf))) |
if (prompt("Local command? ", buf, sizeof(buf))) |
|
|
if ((cpid = fork()) < 0) |
if ((cpid = fork()) < 0) |
printf("can't fork!\r\n"); |
printf("can't fork!\r\n"); |
else if (cpid) { |
else if (cpid) { |
start = time(0); |
start = time(NULL); |
while ((p = wait(&status)) > 0 && p != cpid) |
while ((p = wait(&status)) > 0 && p != cpid) |
; |
; |
} else { |
} else { |
|
|
* 1 <-> remote tty out |
* 1 <-> remote tty out |
* 2 <-> local tty out |
* 2 <-> local tty out |
*/ |
*/ |
|
void |
consh(c) |
consh(c) |
{ |
{ |
char buf[256]; |
char buf[256]; |
int cpid, status, p; |
int cpid, status, p; |
time_t start; |
time_t start = time(NULL); |
|
|
putchar(c); |
putchar(c); |
if (prompt("Local command? ", buf, sizeof(buf))) |
if (prompt("Local command? ", buf, sizeof(buf))) |
|
|
/* |
/* |
* Escape to local shell |
* Escape to local shell |
*/ |
*/ |
|
void |
shell() |
shell() |
{ |
{ |
int shpid, status; |
int shpid, status; |
extern char **environ; |
|
char *cp; |
char *cp; |
|
|
printf("[sh]\r\n"); |
printf("[sh]\r\n"); |
signal(SIGINT, SIG_IGN); |
signal(SIGINT, SIG_IGN); |
signal(SIGQUIT, SIG_IGN); |
signal(SIGQUIT, SIG_IGN); |
unraw(); |
unraw(); |
if (shpid = fork()) { |
if ((shpid = fork())) { |
while (shpid != wait(&status)); |
while (shpid != wait(&status)); |
raw(); |
raw(); |
printf("\r\n!\r\n"); |
printf("\r\n!\r\n"); |
|
|
* TIPIN portion of scripting |
* TIPIN portion of scripting |
* initiate the conversation with TIPOUT |
* initiate the conversation with TIPOUT |
*/ |
*/ |
|
void |
setscript() |
setscript() |
{ |
{ |
char c; |
char c; |
|
|
* Change current working directory of |
* Change current working directory of |
* local portion of tip |
* local portion of tip |
*/ |
*/ |
|
void |
chdirectory() |
chdirectory() |
{ |
{ |
char dirname[PATH_MAX]; |
char dirname[PATH_MAX]; |
|
|
printf("!\r\n"); |
printf("!\r\n"); |
} |
} |
|
|
|
void |
tipabort(msg) |
tipabort(msg) |
char *msg; |
char *msg; |
{ |
{ |
|
|
exit(0); |
exit(0); |
} |
} |
|
|
|
void |
finish() |
finish() |
{ |
{ |
char *dismsg; |
char *dismsg; |
|
|
longjmp(intbuf, 1); |
longjmp(intbuf, 1); |
} |
} |
|
|
|
void |
execute(s) |
execute(s) |
char *s; |
char *s; |
{ |
{ |
|
|
execl(value(SHELL), cp, "-c", s, 0); |
execl(value(SHELL), cp, "-c", s, 0); |
} |
} |
|
|
args(buf, a) |
int |
|
args(buf, a, num) |
char *buf, *a[]; |
char *buf, *a[]; |
|
int num; |
{ |
{ |
register char *p = buf, *start; |
register char *p = buf, *start; |
register char **parg = a; |
register char **parg = a; |
|
|
parg++, n++; |
parg++, n++; |
if (*p) |
if (*p) |
*p++ = '\0'; |
*p++ = '\0'; |
} while (*p); |
} while (*p && n < num); |
|
|
return(n); |
return(n); |
} |
} |
|
|
|
void |
prtime(s, a) |
prtime(s, a) |
char *s; |
char *s; |
time_t a; |
time_t a; |
|
|
printf("\r\n!\r\n"); |
printf("\r\n!\r\n"); |
} |
} |
|
|
|
void |
variable() |
variable() |
{ |
{ |
char buf[256]; |
char buf[256]; |
|
|
} |
} |
if (vtable[PARITY].v_access&CHANGED) { |
if (vtable[PARITY].v_access&CHANGED) { |
vtable[PARITY].v_access &= ~CHANGED; |
vtable[PARITY].v_access &= ~CHANGED; |
setparity(); |
setparity(NOSTR); |
} |
} |
} |
} |
|
|
/* |
/* |
* Turn tandem mode on or off for remote tty. |
* Turn tandem mode on or off for remote tty. |
*/ |
*/ |
|
void |
tandem(option) |
tandem(option) |
char *option; |
char *option; |
{ |
{ |
|
|
/* |
/* |
* Send a break. |
* Send a break. |
*/ |
*/ |
|
void |
genbrk() |
genbrk() |
{ |
{ |
|
|
|
|
/* |
/* |
* Suspend tip |
* Suspend tip |
*/ |
*/ |
|
void |
suspend(c) |
suspend(c) |
char c; |
char c; |
{ |
{ |
|
|
{ |
{ |
static char xname[BUFSIZ]; |
static char xname[BUFSIZ]; |
char cmdbuf[BUFSIZ]; |
char cmdbuf[BUFSIZ]; |
register int pid, l, rc; |
register int pid, l; |
register char *cp, *Shell; |
register char *cp, *Shell; |
int s, pivec[2], (*sigint)(); |
int s, pivec[2]; |
|
|
if (!anyof(name, "~{[*?$`'\"\\")) |
if (!anyof(name, "~{[*?$`'\"\\")) |
return(name); |
return(name); |
|
|
/* |
/* |
* Are any of the characters in the two strings the same? |
* Are any of the characters in the two strings the same? |
*/ |
*/ |
|
int |
anyof(s1, s2) |
anyof(s1, s2) |
register char *s1, *s2; |
register char *s1, *s2; |
{ |
{ |
register int c; |
register int c; |
|
|
while (c = *s1++) |
while ((c = *s1++)) |
if (any(c, s2)) |
if (any(c, s2)) |
return(1); |
return(1); |
return(0); |
return(0); |