=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/ftp.c,v retrieving revision 1.17 retrieving revision 1.18 diff -c -r1.17 -r1.18 *** src/usr.bin/ftp/ftp.c 1997/04/16 05:02:54 1.17 --- src/usr.bin/ftp/ftp.c 1997/04/23 20:33:13 1.18 *************** *** 1,4 **** ! /* $OpenBSD: ftp.c,v 1.17 1997/04/16 05:02:54 millert Exp $ */ /* $NetBSD: ftp.c,v 1.25 1997/04/14 09:09:22 lukem Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: ftp.c,v 1.18 1997/04/23 20:33:13 deraadt Exp $ */ /* $NetBSD: ftp.c,v 1.25 1997/04/14 09:09:22 lukem Exp $ */ /* *************** *** 38,44 **** #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else ! static char rcsid[] = "$OpenBSD: ftp.c,v 1.17 1997/04/16 05:02:54 millert Exp $"; #endif #endif /* not lint */ --- 38,44 ---- #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else ! static char rcsid[] = "$OpenBSD: ftp.c,v 1.18 1997/04/23 20:33:13 deraadt Exp $"; #endif #endif /* not lint */ *************** *** 129,135 **** hp->h_addr_list++; memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0], hp->h_length); ! printf("Trying %s...\n", inet_ntoa(hisctladdr.sin_addr)); (void)close(s); s = socket(hisctladdr.sin_family, SOCK_STREAM, 0); if (s < 0) { --- 129,135 ---- hp->h_addr_list++; memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0], hp->h_length); ! fprintf(ttyout, "Trying %s...\n", inet_ntoa(hisctladdr.sin_addr)); (void)close(s); s = socket(hisctladdr.sin_family, SOCK_STREAM, 0); if (s < 0) { *************** *** 166,172 **** goto bad; } if (verbose) ! printf("Connected to %s.\n", hostname); if (getreply(0) > 2) { /* read startup message from server */ if (cin) (void)fclose(cin); --- 166,172 ---- goto bad; } if (verbose) ! fprintf(ttyout, "Connected to %s.\n", hostname); if (getreply(0) > 2) { /* read startup message from server */ if (cin) (void)fclose(cin); *************** *** 198,205 **** { alarmtimer(0); ! putchar('\n'); ! (void)fflush(stdout); abrtflag++; if (ptflag) longjmp(ptabort, 1); --- 198,205 ---- { alarmtimer(0); ! putc('\n', ttyout); ! (void)fflush(ttyout); abrtflag++; if (ptflag) longjmp(ptabort, 1); *************** *** 223,229 **** abrtflag = 0; if (debug) { ! fputs("---> ", stdout); #ifdef __STDC__ va_start(ap, fmt); #else --- 223,229 ---- abrtflag = 0; if (debug) { ! fputs("---> ", ttyout); #ifdef __STDC__ va_start(ap, fmt); #else *************** *** 231,244 **** fmt = va_arg(ap, const char *); #endif if (strncmp("PASS ", fmt, 5) == 0) ! fputs("PASS XXXX", stdout); else if (strncmp("ACCT ", fmt, 5) == 0) ! fputs("ACCT XXXX", stdout); else vprintf(fmt, ap); va_end(ap); ! putchar('\n'); ! (void)fflush(stdout); } if (cout == NULL) { warnx("No control connection for command."); --- 231,244 ---- fmt = va_arg(ap, const char *); #endif if (strncmp("PASS ", fmt, 5) == 0) ! fputs("PASS XXXX", ttyout); else if (strncmp("ACCT ", fmt, 5) == 0) ! fputs("ACCT XXXX", ttyout); else vprintf(fmt, ap); va_end(ap); ! putc('\n', ttyout); ! (void)fflush(ttyout); } if (cout == NULL) { warnx("No control connection for command."); *************** *** 311,319 **** } lostpeer(); if (verbose) { ! puts( ! "421 Service not available, remote server has closed connection."); ! (void)fflush(stdout); } code = 421; return (4); --- 311,319 ---- } lostpeer(); if (verbose) { ! fputs( ! "421 Service not available, remote server has closed connection.\n", ttyout); ! (void)fflush(ttyout); } code = 421; return (4); *************** *** 323,330 **** (n < '5' || !retry_connect)) { if (proxflag && (dig == 1 || (dig == 5 && verbose == 0))) ! printf("%s:", hostname); ! (void)putchar(c); } if (dig < 4 && isdigit(c)) code = code * 10 + (c - '0'); --- 323,330 ---- (n < '5' || !retry_connect)) { if (proxflag && (dig == 1 || (dig == 5 && verbose == 0))) ! fprintf(ttyout, "%s:", hostname); ! (void)putc(c, ttyout); } if (dig < 4 && isdigit(c)) code = code * 10 + (c - '0'); *************** *** 352,359 **** } if (verbose > 0 || ((verbose > -1 && n == '5') && (n < '5' || !retry_connect))) { ! (void)putchar(c); ! (void)fflush (stdout); } if (line == 0) { size_t len = cp - current_line; --- 352,359 ---- } if (verbose > 0 || ((verbose > -1 && n == '5') && (n < '5' || !retry_connect))) { ! (void)putc(c, ttyout); ! (void)fflush (ttyout); } if (line == 0) { size_t len = cp - current_line; *************** *** 403,410 **** alarmtimer(0); mflag = 0; abrtflag = 0; ! puts("\nsend aborted\nwaiting for remote to finish abort."); ! (void)fflush(stdout); longjmp(sendabort, 1); } --- 403,410 ---- alarmtimer(0); mflag = 0; abrtflag = 0; ! fputs("\nsend aborted\nwaiting for remote to finish abort.\n", ttyout); ! (void)fflush(ttyout); longjmp(sendabort, 1); } *************** *** 429,437 **** oprogress = progress; if (verbose && printnames) { if (local && *local != '-') ! printf("local: %s ", local); if (remote) ! printf("remote: %s\n", remote); } if (proxy) { proxtrans(cmd, local, remote); --- 429,437 ---- oprogress = progress; if (verbose && printnames) { if (local && *local != '-') ! fprintf(ttyout, "local: %s ", local); if (remote) ! fprintf(ttyout, "remote: %s\n", remote); } if (proxy) { proxtrans(cmd, local, remote); *************** *** 492,498 **** closefunc = fclose; if (fstat(fileno(fin), &st) < 0 || (st.st_mode & S_IFMT) != S_IFREG) { ! printf("%s: not a plain file.\n", local); (void)signal(SIGINT, oldintr); (void)signal(SIGINFO, oldinti); fclose(fin); --- 492,498 ---- closefunc = fclose; if (fstat(fileno(fin), &st) < 0 || (st.st_mode & S_IFMT) != S_IFREG) { ! fprintf(ttyout, "%s: not a plain file.\n", local); (void)signal(SIGINT, oldintr); (void)signal(SIGINFO, oldinti); fclose(fin); *************** *** 587,603 **** break; if (hash && (!progress || filesize < 0) ) { while (bytes >= hashbytes) { ! (void)putchar('#'); hashbytes += mark; } ! (void)fflush(stdout); } } if (hash && (!progress || filesize < 0) && bytes > 0) { if (bytes < mark) ! (void)putchar('#'); ! (void)putchar('\n'); ! (void)fflush(stdout); } if (c < 0) warn("local: %s", local); --- 587,603 ---- break; if (hash && (!progress || filesize < 0) ) { while (bytes >= hashbytes) { ! (void)putc('#', ttyout); hashbytes += mark; } ! (void)fflush(ttyout); } } if (hash && (!progress || filesize < 0) && bytes > 0) { if (bytes < mark) ! (void)putc('#', ttyout); ! (void)putc('\n', ttyout); ! (void)fflush(ttyout); } if (c < 0) warn("local: %s", local); *************** *** 613,620 **** if (c == '\n') { while (hash && (!progress || filesize < 0) && (bytes >= hashbytes)) { ! (void)putchar('#'); ! (void)fflush(stdout); hashbytes += mark; } if (ferror(dout)) --- 613,620 ---- if (c == '\n') { while (hash && (!progress || filesize < 0) && (bytes >= hashbytes)) { ! (void)putc('#', ttyout); ! (void)fflush(ttyout); hashbytes += mark; } if (ferror(dout)) *************** *** 633,641 **** } if (hash && (!progress || filesize < 0)) { if (bytes < hashbytes) ! (void)putchar('#'); ! (void)putchar('\n'); ! (void)fflush(stdout); } if (ferror(fin)) warn("local: %s", local); --- 633,641 ---- } if (hash && (!progress || filesize < 0)) { if (bytes < hashbytes) ! (void)putc('#', ttyout); ! (void)putc('\n', ttyout); ! (void)fflush(ttyout); } if (ferror(fin)) warn("local: %s", local); *************** *** 693,700 **** alarmtimer(0); mflag = 0; abrtflag = 0; ! puts("\nreceive aborted\nwaiting for remote to finish abort."); ! (void)fflush(stdout); longjmp(recvabort, 1); } --- 693,700 ---- alarmtimer(0); mflag = 0; abrtflag = 0; ! fputs("\nreceive aborted\nwaiting for remote to finish abort.\n", ttyout); ! (void)fflush(ttyout); longjmp(recvabort, 1); } *************** *** 724,732 **** is_retr = strcmp(cmd, "RETR") == 0; if (is_retr && verbose && printnames) { if (local && *local != '-') ! printf("local: %s ", local); if (remote) ! printf("remote: %s\n", remote); } if (proxy && is_retr) { proxtrans(cmd, local, remote); --- 724,732 ---- is_retr = strcmp(cmd, "RETR") == 0; if (is_retr && verbose && printnames) { if (local && *local != '-') ! fprintf(ttyout, "local: %s ", local); if (remote) ! fprintf(ttyout, "remote: %s\n", remote); } if (proxy && is_retr) { proxtrans(cmd, local, remote); *************** *** 896,912 **** bytes += c; if (hash && (!progress || filesize < 0)) { while (bytes >= hashbytes) { ! (void)putchar('#'); hashbytes += mark; } ! (void)fflush(stdout); } } if (hash && (!progress || filesize < 0) && bytes > 0) { if (bytes < mark) ! (void)putchar('#'); ! (void)putchar('\n'); ! (void)fflush(stdout); } if (c < 0) { if (errno != EPIPE) --- 896,912 ---- bytes += c; if (hash && (!progress || filesize < 0)) { while (bytes >= hashbytes) { ! (void)putc('#', ttyout); hashbytes += mark; } ! (void)fflush(ttyout); } } if (hash && (!progress || filesize < 0) && bytes > 0) { if (bytes < mark) ! (void)putc('#', ttyout); ! (void)putc('\n', ttyout); ! (void)fflush(ttyout); } if (c < 0) { if (errno != EPIPE) *************** *** 950,957 **** while (c == '\r') { while (hash && (!progress || filesize < 0) && (bytes >= hashbytes)) { ! (void)putchar('#'); ! (void)fflush(stdout); hashbytes += mark; } bytes++; --- 950,957 ---- while (c == '\r') { while (hash && (!progress || filesize < 0) && (bytes >= hashbytes)) { ! (void)putc('#', ttyout); ! (void)fflush(ttyout); hashbytes += mark; } bytes++; *************** *** 975,987 **** if (bare_lfs) { printf( "WARNING! %d bare linefeeds received in ASCII mode.\n", bare_lfs); ! puts("File may not have transferred correctly."); } if (hash && (!progress || filesize < 0)) { if (bytes < hashbytes) ! (void)putchar('#'); ! (void)putchar('\n'); ! (void)fflush(stdout); } if (ferror(din)) { if (errno != EPIPE) --- 975,987 ---- if (bare_lfs) { printf( "WARNING! %d bare linefeeds received in ASCII mode.\n", bare_lfs); ! fputs("File may not have transferred correctly.\n", ttyout); } if (hash && (!progress || filesize < 0)) { if (bytes < hashbytes) ! (void)putc('#', ttyout); ! (void)putc('\n', ttyout); ! (void)fflush(ttyout); } if (ferror(din)) { if (errno != EPIPE) *************** *** 1077,1083 **** sizeof(on)) < 0) warn("setsockopt (ignored)"); if (command("PASV") != COMPLETE) { ! puts("Passive mode refused."); goto bad; } --- 1077,1083 ---- sizeof(on)) < 0) warn("setsockopt (ignored)"); if (command("PASV") != COMPLETE) { ! fputs("Passive mode refused.\n", ttyout); goto bad; } *************** *** 1091,1098 **** if (sscanf(pasv, "%d,%d,%d,%d,%d,%d", &a0, &a1, &a2, &a3, &p0, &p1) != 6) { ! puts( ! "Passive mode address scan failure. Shouldn't happen!"); goto bad; } --- 1091,1098 ---- if (sscanf(pasv, "%d,%d,%d,%d,%d,%d", &a0, &a1, &a2, &a3, &p0, &p1) != 6) { ! fputs( ! "Passive mode address scan failure. Shouldn't happen!\n", ttyout); goto bad; } *************** *** 1330,1337 **** { alarmtimer(0); ! putchar('\n'); ! (void)fflush(stdout); ptabflg++; mflag = 0; abrtflag = 0; --- 1330,1337 ---- { alarmtimer(0); ! putc('\n', ttyout); ! (void)fflush(ttyout); ptabflg++; mflag = 0; abrtflag = 0; *************** *** 1360,1371 **** if (curtype != prox_type) changetype(prox_type, 1); if (command("PASV") != COMPLETE) { ! puts("proxy server does not support third party transfers."); return; } pswitch(0); if (!connected) { ! puts("No primary connection."); pswitch(1); code = -1; return; --- 1360,1372 ---- if (curtype != prox_type) changetype(prox_type, 1); if (command("PASV") != COMPLETE) { ! fputs("proxy server does not support third party transfers.\n", ! ttyout); return; } pswitch(0); if (!connected) { ! fputs("No primary connection.\n", ttyout); pswitch(1); code = -1; return; *************** *** 1396,1402 **** (void)signal(SIGINT, oldintr); pswitch(1); ptflag = 0; ! printf("local: %s remote: %s\n", local, remote); return; abort: (void)signal(SIGINT, SIG_IGN); --- 1397,1403 ---- (void)signal(SIGINT, oldintr); pswitch(1); ptflag = 0; ! fprintf(ttyout, "local: %s remote: %s\n", local, remote); return; abort: (void)signal(SIGINT, SIG_IGN); *************** *** 1502,1508 **** *cp++ = '.'; while (!d) { if (++count == 100) { ! puts("runique: can't find unique file name."); return ((char *) 0); } *cp++ = ext; --- 1503,1509 ---- *cp++ = '.'; while (!d) { if (++count == 100) { ! fputs("runique: can't find unique file name.\n", ttyout); return ((char *) 0); } *cp++ = ext;