+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
#ifndef lint
-static char sccsid[] = "@(#)cmds.c 4.12 (Berkeley) 6/25/83";
-#endif
+static char sccsid[] = "@(#)cmds.c 5.4 (Berkeley) 5/5/86";
+#endif not lint
#include "tip.h"
/*
while ((c&0177) != '\n');
ioctl(0, TIOCSETC, &defchars);
+ (void) setjmp(intbuf);
f = signal(SIGINT, intcopy);
start = time(0);
- (void) setjmp(intbuf);
for (ct = 0; !quit;) {
eof = read(FD, &c, 1) <= 0;
c &= 0177;
prtime(" lines transferred in ", time(0)-start);
ioctl(0, TIOCSETC, &tchars);
write(fildes[1], (char *)&ccc, 1);
- signal(SIGINT, SIG_DFL);
+ signal(SIGINT, f);
close(fd);
}
char *pc, lastc;
int c, ccount, lcount;
time_t start_t, stop_t;
+ int (*f)();
kill(pid, SIGIOT); /* put TIPOUT into a wait state */
- signal(SIGINT, stopsnd);
stop = 0;
+ f = signal(SIGINT, stopsnd);
ioctl(0, TIOCSETC, &defchars);
read(repdes[0], (char *)&ccc, 1);
if (command != NULL) {
if (boolean(value(VERBOSE)))
printf("\r%d", ++lcount);
if (boolean(value(ECHOCHECK))) {
- alarm(value(ETIMEOUT));
timedout = 0;
+ alarm(value(ETIMEOUT));
do { /* wait for prompt */
read(FD, (char *)&c, 1);
if (timedout || stop) {
send(*pc);
stop_t = time(0);
fclose(fd);
- signal(SIGINT, SIG_DFL);
+ signal(SIGINT, f);
if (boolean(value(VERBOSE)))
if (boolean(value(RAWFTP)))
prtime(" chars transferred in ", stop_t-start_t);
timedout = 1;
}
+/*
+ * Stolen from consh() -- puts a remote file on the output of a local command.
+ * Identical to consh() except for where stdout goes.
+ */
+pipeout(c)
+{
+ char buf[256];
+ int cpid, status, p;
+ time_t start;
+
+ putchar(c);
+ if (prompt("Local command? ", buf))
+ return;
+ kill(pid, SIGIOT); /* put TIPOUT into a wait state */
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, SIG_IGN);
+ ioctl(0, TIOCSETC, &defchars);
+ read(repdes[0], (char *)&ccc, 1);
+ /*
+ * Set up file descriptors in the child and
+ * let it go...
+ */
+ if ((cpid = fork()) < 0)
+ printf("can't fork!\r\n");
+ else if (cpid) {
+ start = time(0);
+ while ((p = wait(&status)) > 0 && p != cpid)
+ ;
+ } else {
+ register int i;
+
+ dup2(FD, 1);
+ for (i = 3; i < 20; i++)
+ close(i);
+ signal(SIGINT, SIG_DFL);
+ signal(SIGQUIT, SIG_DFL);
+ execute(buf);
+ printf("can't find `%s'\r\n", buf);
+ exit(0);
+ }
+ if (boolean(value(VERBOSE)))
+ prtime("away for ", time(0)-start);
+ write(fildes[1], (char *)&ccc, 1);
+ ioctl(0, TIOCSETC, &tchars);
+ signal(SIGINT, SIG_DFL);
+ signal(SIGQUIT, SIG_DFL);
+}
+
#ifdef CONNECT
/*
* Fork a program with:
printf("!\r\n");
}
-finish()
+abort(msg)
+ char *msg;
{
- char *dismsg;
- if ((dismsg = value(DISCONNECT)) != NOSTR) {
- write(FD,dismsg,strlen(dismsg));
- sleep(5);
- }
kill(pid, SIGTERM);
- disconnect();
+ setreuid(euid, euid);
+ setregid(egid, egid);
+ disconnect(msg);
+ if (msg != NOSTR)
+ printf("\r\n%s", msg);
printf("\r\n[EOT]\r\n");
delock(uucplock);
unraw();
exit(0);
}
+finish()
+{
+ char *dismsg;
+
+ if ((dismsg = value(DISCONNECT)) != NOSTR) {
+ write(FD, dismsg, strlen(dismsg));
+ sleep(5);
+ }
+ abort(NOSTR);
+}
+
intcopy()
{
}
printf("%s", s);
while (--i >= 0)
- if (nums[i])
+ if (nums[i] || i == 0 && nums[1] == 0 && nums[2] == 0)
printf("%d %s%c ", nums[i], sep[i],
nums[i] == 1 ? '\0' : 's');
printf("\r\n!\r\n");
/*
* Suspend tip
*/
-suspend()
+suspend(c)
+ char c;
{
unraw();
- kill(0, SIGTSTP);
+ kill(c == CTRL(y) ? getpid() : 0, SIGTSTP);
raw();
}