386BSD 0.1 development
[unix-history] / usr / src / usr.bin / ftp / ftp.c
index 4bdee1d..a63c986 100644 (file)
@@ -2,21 +2,37 @@
  * Copyright (c) 1985, 1989 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1985, 1989 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)ftp.c      5.30 (Berkeley) %G%";
+static char sccsid[] = "@(#)ftp.c      5.38 (Berkeley) 4/22/91";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -27,6 +43,8 @@ static char sccsid[] = "@(#)ftp.c     5.30 (Berkeley) %G%";
 #include <sys/file.h>
 
 #include <netinet/in.h>
 #include <sys/file.h>
 
 #include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
 #include <arpa/ftp.h>
 #include <arpa/telnet.h>
 
 #include <arpa/ftp.h>
 #include <arpa/telnet.h>
 
@@ -45,10 +63,13 @@ struct      sockaddr_in data_addr;
 int    data = -1;
 int    abrtflag = 0;
 int    ptflag = 0;
 int    data = -1;
 int    abrtflag = 0;
 int    ptflag = 0;
-int    connected;
 struct sockaddr_in myctladdr;
 uid_t  getuid();
 sig_t  lostpeer();
 struct sockaddr_in myctladdr;
 uid_t  getuid();
 sig_t  lostpeer();
+off_t  restart_point = 0;
+
+extern char *strerror();
+extern int connected, errno;
 
 FILE   *cin, *cout;
 FILE   *dataconn();
 
 FILE   *cin, *cout;
 FILE   *dataconn();
@@ -59,7 +80,7 @@ hookup(host, port)
        int port;
 {
        register struct hostent *hp = 0;
        int port;
 {
        register struct hostent *hp = 0;
-       int s,len;
+       int s, len, tos;
        static char hostnamebuf[80];
 
        bzero((char *)&hisctladdr, sizeof (hisctladdr));
        static char hostnamebuf[80];
 
        bzero((char *)&hisctladdr, sizeof (hisctladdr));
@@ -121,6 +142,11 @@ hookup(host, port)
                code = -1;
                goto bad;
        }
                code = -1;
                goto bad;
        }
+#ifdef IP_TOS
+       tos = IPTOS_LOWDELAY;
+       if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0)
+               perror("ftp: setsockopt TOS (ignored)");
+#endif
        cin = fdopen(s, "r");
        cout = fdopen(s, "w");
        if (cin == NULL || cout == NULL) {
        cin = fdopen(s, "r");
        cout = fdopen(s, "w");
        if (cin == NULL || cout == NULL) {
@@ -146,7 +172,7 @@ hookup(host, port)
        {
        int on = 1;
 
        {
        int on = 1;
 
-       if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &on, sizeof(on))
+       if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on))
                < 0 && debug) {
                        perror("ftp: setsockopt");
                }
                < 0 && debug) {
                        perror("ftp: setsockopt");
                }
@@ -221,7 +247,7 @@ login(host)
        return (1);
 }
 
        return (1);
 }
 
-sig_t
+void
 cmdabort()
 {
        extern jmp_buf ptabort;
 cmdabort()
 {
        extern jmp_buf ptabort;
@@ -240,7 +266,8 @@ va_dcl
        va_list ap;
        char *fmt;
        int r;
        va_list ap;
        char *fmt;
        int r;
-       sig_t (*oldintr)(), cmdabort();
+       sig_t oldintr;
+       void cmdabort();
 
        abrtflag = 0;
        if (debug) {
 
        abrtflag = 0;
        if (debug) {
@@ -270,7 +297,7 @@ va_dcl
        cpend = 1;
        r = getreply(!strcmp(fmt, "QUIT"));
        if (abrtflag && oldintr != SIG_IGN)
        cpend = 1;
        r = getreply(!strcmp(fmt, "QUIT"));
        if (abrtflag && oldintr != SIG_IGN)
-               (*oldintr)();
+               (*oldintr)(SIGINT);
        (void) signal(SIGINT, oldintr);
        return(r);
 }
        (void) signal(SIGINT, oldintr);
        return(r);
 }
@@ -286,9 +313,10 @@ getreply(expecteof)
        register int dig;
        register char *cp;
        int originalcode = 0, continuation = 0;
        register int dig;
        register char *cp;
        int originalcode = 0, continuation = 0;
-       sig_t (*oldintr)(), cmdabort();
+       sig_t oldintr;
        int pflag = 0;
        char *pt = pasv;
        int pflag = 0;
        char *pt = pasv;
+       void cmdabort();
 
        oldintr = signal(SIGINT, cmdabort);
        for (;;) {
 
        oldintr = signal(SIGINT, cmdabort);
        for (;;) {
@@ -376,7 +404,7 @@ getreply(expecteof)
                if (code == 421 || originalcode == 421)
                        lostpeer();
                if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN)
                if (code == 421 || originalcode == 421)
                        lostpeer();
                if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN)
-                       (*oldintr)();
+                       (*oldintr)(SIGINT);
                return (n - '0');
        }
 }
                return (n - '0');
        }
 }
@@ -394,6 +422,7 @@ empty(mask, sec)
 
 jmp_buf        sendabort;
 
 
 jmp_buf        sendabort;
 
+void
 abortsend()
 {
 
 abortsend()
 {
 
@@ -410,16 +439,15 @@ sendrequest(cmd, local, remote, printnames)
        char *cmd, *local, *remote;
        int printnames;
 {
        char *cmd, *local, *remote;
        int printnames;
 {
+       struct stat st;
+       struct timeval start, stop;
+       register int c, d;
        FILE *fin, *dout = 0, *popen();
        int (*closefunc)(), pclose(), fclose();
        FILE *fin, *dout = 0, *popen();
        int (*closefunc)(), pclose(), fclose();
-       sig_t (*oldintr)(), (*oldintp)();
-       int abortsend();
-       char buf[BUFSIZ], *bufp;
+       sig_t oldintr, oldintp;
        long bytes = 0, hashbytes = HASHBYTES;
        long bytes = 0, hashbytes = HASHBYTES;
-       register int c, d;
-       struct stat st;
-       struct timeval start, stop;
-       char *mode;
+       char *lmode, buf[BUFSIZ], *bufp;
+       void abortsend();
 
        if (verbose && printnames) {
                if (local && *local != '-')
 
        if (verbose && printnames) {
                if (local && *local != '-')
@@ -436,7 +464,7 @@ sendrequest(cmd, local, remote, printnames)
        closefunc = NULL;
        oldintr = NULL;
        oldintp = NULL;
        closefunc = NULL;
        oldintr = NULL;
        oldintp = NULL;
-       mode = "w";
+       lmode = "w";
        if (setjmp(sendabort)) {
                while (cpend) {
                        (void) getreply(0);
        if (setjmp(sendabort)) {
                while (cpend) {
                        (void) getreply(0);
@@ -469,7 +497,8 @@ sendrequest(cmd, local, remote, printnames)
        } else {
                fin = fopen(local, "r");
                if (fin == NULL) {
        } else {
                fin = fopen(local, "r");
                if (fin == NULL) {
-                       perror(local);
+                       fprintf(stderr, "local: %s: %s\n", local,
+                               strerror(errno));
                        (void) signal(SIGINT, oldintr);
                        code = -1;
                        return;
                        (void) signal(SIGINT, oldintr);
                        code = -1;
                        return;
@@ -496,6 +525,26 @@ sendrequest(cmd, local, remote, printnames)
        if (setjmp(sendabort))
                goto abort;
 
        if (setjmp(sendabort))
                goto abort;
 
+       if (restart_point &&
+           (strcmp(cmd, "STOR") == 0 || strcmp(cmd, "APPE") == 0)) {
+               if (fseek(fin, (long) restart_point, 0) < 0) {
+                       fprintf(stderr, "local: %s: %s\n", local,
+                               strerror(errno));
+                       restart_point = 0;
+                       if (closefunc != NULL)
+                               (*closefunc)(fin);
+                       return;
+               }
+               if (command("REST %ld", (long) restart_point)
+                       != CONTINUE) {
+                       restart_point = 0;
+                       if (closefunc != NULL)
+                               (*closefunc)(fin);
+                       return;
+               }
+               restart_point = 0;
+               lmode = "r+w";
+       }
        if (remote) {
                if (command("%s %s", cmd, remote) != PRELIM) {
                        (void) signal(SIGINT, oldintr);
        if (remote) {
                if (command("%s %s", cmd, remote) != PRELIM) {
                        (void) signal(SIGINT, oldintr);
@@ -514,21 +563,18 @@ sendrequest(cmd, local, remote, printnames)
                                (*closefunc)(fin);
                        return;
                }
                                (*closefunc)(fin);
                        return;
                }
-       dout = dataconn(mode);
+       dout = dataconn(lmode);
        if (dout == NULL)
                goto abort;
        (void) gettimeofday(&start, (struct timezone *)0);
        oldintp = signal(SIGPIPE, SIG_IGN);
        if (dout == NULL)
                goto abort;
        (void) gettimeofday(&start, (struct timezone *)0);
        oldintp = signal(SIGPIPE, SIG_IGN);
-       switch (type) {
+       switch (curtype) {
 
        case TYPE_I:
        case TYPE_L:
                errno = d = 0;
                while ((c = read(fileno(fin), buf, sizeof (buf))) > 0) {
                        bytes += c;
 
        case TYPE_I:
        case TYPE_L:
                errno = d = 0;
                while ((c = read(fileno(fin), buf, sizeof (buf))) > 0) {
                        bytes += c;
-                       for (bufp = buf; c > 0; c -= d, bufp += d)
-                               if ((d = write(fileno(dout), bufp, c)) <= 0)
-                                       break;
                        for (bufp = buf; c > 0; c -= d, bufp += d)
                                if ((d = write(fileno(dout), bufp, c)) <= 0)
                                        break;
                        for (bufp = buf; c > 0; c -= d, bufp += d)
                                if ((d = write(fileno(dout), bufp, c)) <= 0)
                                        break;
@@ -547,11 +593,10 @@ sendrequest(cmd, local, remote, printnames)
                        (void) fflush(stdout);
                }
                if (c < 0)
                        (void) fflush(stdout);
                }
                if (c < 0)
-                       perror(local);
-               if (d <= 0) {
-                       if (d == 0)
-                               fprintf(stderr, "netout: write returned 0?\n");
-                       else if (errno != EPIPE) 
+                       fprintf(stderr, "local: %s: %s\n", local,
+                               strerror(errno));
+               if (d < 0) {
+                       if (errno != EPIPE) 
                                perror("netout");
                        bytes = -1;
                }
                                perror("netout");
                        bytes = -1;
                }
@@ -584,7 +629,8 @@ sendrequest(cmd, local, remote, printnames)
                        (void) fflush(stdout);
                }
                if (ferror(fin))
                        (void) fflush(stdout);
                }
                if (ferror(fin))
-                       perror(local);
+                       fprintf(stderr, "local: %s: %s\n", local,
+                               strerror(errno));
                if (ferror(dout)) {
                        if (errno != EPIPE)
                                perror("netout");
                if (ferror(dout)) {
                        if (errno != EPIPE)
                                perror("netout");
@@ -628,7 +674,7 @@ abort:
 
 jmp_buf        recvabort;
 
 
 jmp_buf        recvabort;
 
-sig_t
+void
 abortrecv()
 {
 
 abortrecv()
 {
 
@@ -639,19 +685,23 @@ abortrecv()
        longjmp(recvabort, 1);
 }
 
        longjmp(recvabort, 1);
 }
 
-recvrequest(cmd, local, remote, mode, printnames)
-       char *cmd, *local, *remote, *mode;
+recvrequest(cmd, local, remote, lmode, printnames)
+       char *cmd, *local, *remote, *lmode;
 {
        FILE *fout, *din = 0, *popen();
 {
        FILE *fout, *din = 0, *popen();
-       char *bufp, *gunique(), msg;
-       static char *buf;
+       int (*closefunc)(), pclose(), fclose();
+       sig_t oldintr, oldintp;
+       int is_retr, tcrflag, bare_lfs = 0;
+       char *gunique();
        static int bufsize;
        static char *buf;
        long bytes = 0, hashbytes = HASHBYTES;
        register int c, d;
        struct timeval start, stop;
        struct stat st;
        static int bufsize;
        static char *buf;
        long bytes = 0, hashbytes = HASHBYTES;
        register int c, d;
        struct timeval start, stop;
        struct stat st;
-       extern char *malloc();
+       off_t lseek();
+       void abortrecv();
+       char *malloc();
 
        is_retr = strcmp(cmd, "RETR") == 0;
        if (is_retr && verbose && printnames) {
 
        is_retr = strcmp(cmd, "RETR") == 0;
        if (is_retr && verbose && printnames) {
@@ -687,7 +737,8 @@ recvrequest(cmd, local, remote, mode, printnames)
                        char *dir = rindex(local, '/');
 
                        if (errno != ENOENT && errno != EACCES) {
                        char *dir = rindex(local, '/');
 
                        if (errno != ENOENT && errno != EACCES) {
-                               perror(local);
+                               fprintf(stderr, "local: %s: %s\n", local,
+                                       strerror(errno));
                                (void) signal(SIGINT, oldintr);
                                code = -1;
                                return;
                                (void) signal(SIGINT, oldintr);
                                code = -1;
                                return;
@@ -698,14 +749,17 @@ recvrequest(cmd, local, remote, mode, printnames)
                        if (dir != NULL)
                                *dir = '/';
                        if (d < 0) {
                        if (dir != NULL)
                                *dir = '/';
                        if (d < 0) {
-                               perror(local);
+                               fprintf(stderr, "local: %s: %s\n", local,
+                                       strerror(errno));
                                (void) signal(SIGINT, oldintr);
                                code = -1;
                                return;
                        }
                        if (!runique && errno == EACCES &&
                            chmod(local, 0600) < 0) {
                                (void) signal(SIGINT, oldintr);
                                code = -1;
                                return;
                        }
                        if (!runique && errno == EACCES &&
                            chmod(local, 0600) < 0) {
-                               perror(local);
+                               fprintf(stderr, "local: %s: %s\n", local,
+                                       strerror(errno));
+                               (void) signal(SIGINT, oldintr);
                                (void) signal(SIGINT, oldintr);
                                code = -1;
                                return;
                                (void) signal(SIGINT, oldintr);
                                code = -1;
                                return;
@@ -763,9 +817,10 @@ recvrequest(cmd, local, remote, mode, printnames)
                }
                closefunc = pclose;
        } else {
                }
                closefunc = pclose;
        } else {
-               fout = fopen(local, mode);
+               fout = fopen(local, lmode);
                if (fout == NULL) {
                if (fout == NULL) {
-                       perror(local);
+                       fprintf(stderr, "local: %s: %s\n", local,
+                               strerror(errno));
                        goto abort;
                }
                closefunc = fclose;
                        goto abort;
                }
                closefunc = fclose;
@@ -779,7 +834,6 @@ recvrequest(cmd, local, remote, mode, printnames)
                if (buf == NULL) {
                        perror("malloc");
                        bufsize = 0;
                if (buf == NULL) {
                        perror("malloc");
                        bufsize = 0;
-                       bufsize = 0;
                        goto abort;
                }
                bufsize = st.st_blksize;
                        goto abort;
                }
                bufsize = st.st_blksize;
@@ -789,6 +843,14 @@ recvrequest(cmd, local, remote, mode, printnames)
 
        case TYPE_I:
        case TYPE_L:
 
        case TYPE_I:
        case TYPE_L:
+               if (restart_point &&
+                   lseek(fileno(fout), (long) restart_point, L_SET) < 0) {
+                       fprintf(stderr, "local: %s: %s\n", local,
+                               strerror(errno));
+                       if (closefunc != NULL)
+                               (*closefunc)(fout);
+                       return;
+               }
                errno = d = 0;
                while ((c = read(fileno(din), buf, bufsize)) > 0) {
                        if ((d = write(fileno(fout), buf, c)) != c)
                errno = d = 0;
                while ((c = read(fileno(din), buf, bufsize)) > 0) {
                        if ((d = write(fileno(fout), buf, c)) != c)
@@ -815,13 +877,35 @@ recvrequest(cmd, local, remote, mode, printnames)
                }
                if (d < c) {
                        if (d < 0)
                }
                if (d < c) {
                        if (d < 0)
-                               perror(local);
+                               fprintf(stderr, "local: %s: %s\n", local,
+                                       strerror(errno));
                        else
                                fprintf(stderr, "%s: short write\n", local);
                }
                break;
 
        case TYPE_A:
                        else
                                fprintf(stderr, "%s: short write\n", local);
                }
                break;
 
        case TYPE_A:
+               if (restart_point) {
+                       register int i, n, ch;
+
+                       if (fseek(fout, 0L, L_SET) < 0)
+                               goto done;
+                       n = restart_point;
+                       for (i = 0; i++ < n;) {
+                               if ((ch = getc(fout)) == EOF)
+                                       goto done;
+                               if (ch == '\n')
+                                       i++;
+                       }
+                       if (fseek(fout, 0L, L_INCR) < 0) {
+done:
+                               fprintf(stderr, "local: %s: %s\n", local,
+                                       strerror(errno));
+                               if (closefunc != NULL)
+                                       (*closefunc)(fout);
+                               return;
+                       }
+               }
                while ((c = getc(din)) != EOF) {
                        if (c == '\n')
                                bare_lfs++;
                while ((c = getc(din)) != EOF) {
                        if (c == '\n')
                                bare_lfs++;
@@ -842,9 +926,6 @@ recvrequest(cmd, local, remote, mode, printnames)
                                        }
                                        if (c == EOF)
                                                goto contin2;
                                        }
                                        if (c == EOF)
                                                goto contin2;
-                                       }
-                                       if (c == EOF)
-                                               goto contin2;
                                }
                        }
                        (void) putc(c, fout);
                                }
                        }
                        (void) putc(c, fout);
@@ -868,7 +949,8 @@ break2:
                        bytes = -1;
                }
                if (ferror(fout))
                        bytes = -1;
                }
                if (ferror(fout))
-                       perror(local);
+                       fprintf(stderr, "local: %s: %s\n", local,
+                               strerror(errno));
                break;
        }
        if (closefunc != NULL)
                break;
        }
        if (closefunc != NULL)
@@ -912,12 +994,9 @@ abort:
 }
 
 /*
 }
 
 /*
- * Need to start a listen on the data channel
- * before we send the command, otherwise the
- * server's connect may fail.
+ * Need to start a listen on the data channel before we send the command,
+ * otherwise the server's connect may fail.
  */
  */
-int sendport;
-
 initconn()
 {
        register char *p, *a;
 initconn()
 {
        register char *p, *a;
@@ -973,6 +1052,11 @@ noport:
        }
        if (tmpno)
                sendport = 1;
        }
        if (tmpno)
                sendport = 1;
+#ifdef IP_TOS
+       on = IPTOS_THROUGHPUT;
+       if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on, sizeof(int)) < 0)
+               perror("ftp: setsockopt TOS (ignored)");
+#endif
        return (0);
 bad:
        (void) close(data), data = -1;
        return (0);
 bad:
        (void) close(data), data = -1;
@@ -982,11 +1066,11 @@ bad:
 }
 
 FILE *
 }
 
 FILE *
-dataconn(mode)
-       char *mode;
+dataconn(lmode)
+       char *lmode;
 {
        struct sockaddr_in from;
 {
        struct sockaddr_in from;
-       int s, fromlen = sizeof (from);
+       int s, fromlen = sizeof (from), tos;
 
        s = accept(data, (struct sockaddr *) &from, &fromlen);
        if (s < 0) {
 
        s = accept(data, (struct sockaddr *) &from, &fromlen);
        if (s < 0) {
@@ -996,7 +1080,12 @@ dataconn(mode)
        }
        (void) close(data);
        data = s;
        }
        (void) close(data);
        data = s;
-       return (fdopen(data, mode));
+#ifdef IP_TOS
+       tos = IPTOS_THROUGHPUT;
+       if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0)
+               perror("ftp: setsockopt TOS (ignored)");
+#endif
+       return (fdopen(data, lmode));
 }
 
 ptransfer(direction, bytes, t0, t1)
 }
 
 ptransfer(direction, bytes, t0, t1)
@@ -1037,7 +1126,7 @@ tvsub(tdiff, t1, t0)
                tdiff->tv_sec--, tdiff->tv_usec += 1000000;
 }
 
                tdiff->tv_sec--, tdiff->tv_usec += 1000000;
 }
 
-sig_t
+void
 psabort()
 {
        extern int abrtflag;
 psabort()
 {
        extern int abrtflag;
@@ -1049,7 +1138,7 @@ pswitch(flag)
        int flag;
 {
        extern int proxy, abrtflag;
        int flag;
 {
        extern int proxy, abrtflag;
-       sig_t (*oldintr)();
+       sig_t oldintr;
        static struct comvars {
                int connect;
                char name[MAXHOSTNAMELEN];
        static struct comvars {
                int connect;
                char name[MAXHOSTNAMELEN];
@@ -1134,14 +1223,14 @@ pswitch(flag)
        (void) signal(SIGINT, oldintr);
        if (abrtflag) {
                abrtflag = 0;
        (void) signal(SIGINT, oldintr);
        if (abrtflag) {
                abrtflag = 0;
-               (*oldintr)();
+               (*oldintr)(SIGINT);
        }
 }
 
 jmp_buf ptabort;
 int ptabflg;
 
        }
 }
 
 jmp_buf ptabort;
 int ptabflg;
 
-sig_t
+void
 abortpt()
 {
        printf("\n");
 abortpt()
 {
        printf("\n");
@@ -1155,11 +1244,12 @@ abortpt()
 proxtrans(cmd, local, remote)
        char *cmd, *local, *remote;
 {
 proxtrans(cmd, local, remote)
        char *cmd, *local, *remote;
 {
-       sig_t (*oldintr)(), abortpt();
+       sig_t oldintr;
        int secndflag = 0, prox_type, nfnd;
        extern jmp_buf ptabort;
        char *cmd2;
        struct fd_set mask;
        int secndflag = 0, prox_type, nfnd;
        extern jmp_buf ptabort;
        char *cmd2;
        struct fd_set mask;
+       void abortpt();
 
        if (strcmp(cmd, "RETR"))
                cmd2 = "RETR";
 
        if (strcmp(cmd, "RETR"))
                cmd2 = "RETR";
@@ -1305,7 +1395,7 @@ gunique(local)
        if (cp)
                *cp = '/';
        if (d < 0) {
        if (cp)
                *cp = '/';
        if (d < 0) {
-               perror(local);
+               fprintf(stderr, "local: %s: %s\n", local, strerror(errno));
                return((char *) 0);
        }
        (void) strcpy(new, local);
                return((char *) 0);
        }
        (void) strcpy(new, local);