summaryrefslogtreecommitdiff
path: root/usr.bin/ftp/ftp.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-02-03 01:05:47 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-02-03 01:05:47 +0000
commit2032b3ac7a76c4acb7c8a879ce1366c4ceaeff7b (patch)
tree8345ed4044fa5e9a654b42cb2d3c1fe128239ae7 /usr.bin/ftp/ftp.c
parent608493bb3d8aaa88f2804c620ef8d208ba98b08a (diff)
Add back ``-r'' option and fix strncpy() usage and other nits because
I'm anal. Closer to KNF now.
Diffstat (limited to 'usr.bin/ftp/ftp.c')
-rw-r--r--usr.bin/ftp/ftp.c398
1 files changed, 198 insertions, 200 deletions
diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c
index 98cc4107c28..835007c8cbf 100644
--- a/usr.bin/ftp/ftp.c
+++ b/usr.bin/ftp/ftp.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: ftp.c,v 1.11 1997/02/03 01:05:40 millert Exp $ */
/* $NetBSD: ftp.c,v 1.22 1997/02/01 10:45:03 lukem Exp $ */
/*
@@ -37,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
-static char rcsid[] = "$NetBSD: ftp.c,v 1.22 1997/02/01 10:45:03 lukem Exp $";
+static char rcsid[] = "$OpenBSD: ftp.c,v 1.11 1997/02/03 01:05:40 millert Exp $";
#endif
#endif /* not lint */
@@ -87,10 +88,11 @@ hookup(host, port)
int s, len, tos;
static char hostnamebuf[MAXHOSTNAMELEN];
- memset((char *)&hisctladdr, 0, sizeof (hisctladdr));
+ memset((char *)&hisctladdr, 0, sizeof(hisctladdr));
if (inet_aton(host, &hisctladdr.sin_addr) != 0) {
hisctladdr.sin_family = AF_INET;
- (void) strncpy(hostnamebuf, host, sizeof(hostnamebuf));
+ (void)strncpy(hostnamebuf, host, sizeof(hostnamebuf) - 1);
+ hostnamebuf[sizeof(hostnamebuf) - 1] = '\0';
} else {
hp = gethostbyname(host);
if (hp == NULL) {
@@ -99,10 +101,9 @@ hookup(host, port)
return ((char *) 0);
}
hisctladdr.sin_family = hp->h_addrtype;
- memmove((caddr_t)&hisctladdr.sin_addr,
- hp->h_addr_list[0], hp->h_length);
- memcpy(&hisctladdr.sin_addr, hp->h_addr, hp->h_length);
- (void) strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf));
+ memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0], hp->h_length);
+ (void)strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf) - 1);
+ hostnamebuf[sizeof(hostnamebuf) - 1] = '\0';
}
hostname = hostnamebuf;
s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
@@ -113,7 +114,7 @@ hookup(host, port)
}
hisctladdr.sin_port = port;
while (connect(s, (struct sockaddr *)&hisctladdr,
- sizeof (hisctladdr)) < 0) {
+ sizeof(hisctladdr)) < 0) {
if (hp && hp->h_addr_list[1]) {
int oerrno = errno;
char *ia;
@@ -122,11 +123,10 @@ hookup(host, port)
errno = oerrno;
warn("connect to address %s", ia);
hp->h_addr_list++;
- memmove((caddr_t)&hisctladdr.sin_addr,
- hp->h_addr_list[0], hp->h_length);
- fprintf(stdout, "Trying %s...\n",
- inet_ntoa(hisctladdr.sin_addr));
- (void) close(s);
+ 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) {
warn("socket");
@@ -139,7 +139,7 @@ hookup(host, port)
code = -1;
goto bad;
}
- len = sizeof (myctladdr);
+ len = sizeof(myctladdr);
if (getsockname(s, (struct sockaddr *)&myctladdr, &len) < 0) {
warn("getsockname");
code = -1;
@@ -155,9 +155,9 @@ hookup(host, port)
if (cin == NULL || cout == NULL) {
warnx("fdopen failed.");
if (cin)
- (void) fclose(cin);
+ (void)fclose(cin);
if (cout)
- (void) fclose(cout);
+ (void)fclose(cout);
code = -1;
goto bad;
}
@@ -165,9 +165,9 @@ hookup(host, port)
printf("Connected to %s.\n", hostname);
if (getreply(0) > 2) { /* read startup message from server */
if (cin)
- (void) fclose(cin);
+ (void)fclose(cin);
if (cout)
- (void) fclose(cout);
+ (void)fclose(cout);
code = -1;
goto bad;
}
@@ -184,7 +184,7 @@ hookup(host, port)
return (hostname);
bad:
- (void) close(s);
+ (void)close(s);
return ((char *)0);
}
@@ -247,7 +247,7 @@ login(host)
printf("Name (%s:%s): ", host, myname);
else
printf("Name (%s): ", host);
- (void) fgets(tmp, sizeof(tmp) - 1, stdin);
+ (void)fgets(tmp, sizeof(tmp) - 1, stdin);
tmp[strlen(tmp) - 1] = '\0';
if (*tmp == '\0')
user = myname;
@@ -270,12 +270,12 @@ login(host)
return (0);
}
if (!aflag && acct != NULL)
- (void) command("ACCT %s", acct);
+ (void)command("ACCT %s", acct);
if (proxy)
return (1);
for (n = 0; n < macnum; ++n) {
if (!strcmp("init", macros[n].mac_name)) {
- (void) strcpy(line, "$init");
+ (void)strcpy(line, "$init");
makeargv();
domacro(margc, margv);
break;
@@ -289,8 +289,8 @@ cmdabort()
{
alarmtimer(0);
- printf("\n");
- (void) fflush(stdout);
+ putchar('\n');
+ (void)fflush(stdout);
abrtflag++;
if (ptflag)
longjmp(ptabort, 1);
@@ -308,18 +308,18 @@ va_dcl
abrtflag = 0;
if (debug) {
- printf("---> ");
+ fputs("---> ", stdout);
va_start(ap);
fmt = va_arg(ap, char *);
if (strncmp("PASS ", fmt, 5) == 0)
- printf("PASS XXXX");
+ fputs("PASS XXXX", stdout);
else if (strncmp("ACCT ", fmt, 5) == 0)
- printf("ACCT XXXX");
+ fputs("ACCT XXXX", stdout);
else
- vfprintf(stdout, fmt, ap);
+ vprintf(fmt, ap);
va_end(ap);
- printf("\n");
- (void) fflush(stdout);
+ putchar('\n');
+ (void)fflush(stdout);
}
if (cout == NULL) {
warn("No control connection for command");
@@ -331,13 +331,13 @@ va_dcl
fmt = va_arg(ap, char *);
vfprintf(cout, fmt, ap);
va_end(ap);
- fprintf(cout, "\r\n");
- (void) fflush(cout);
+ fputs("\r\n", cout);
+ (void)fflush(cout);
cpend = 1;
r = getreply(!strcmp(fmt, "QUIT"));
if (abrtflag && oldintr != SIG_IGN)
(*oldintr)(SIGINT);
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
return (r);
}
@@ -366,13 +366,13 @@ getreply(expecteof)
case WONT:
c = getc(cin);
fprintf(cout, "%c%c%c", IAC, DONT, c);
- (void) fflush(cout);
+ (void)fflush(cout);
break;
case DO:
case DONT:
c = getc(cin);
fprintf(cout, "%c%c%c", IAC, WONT, c);
- (void) fflush(cout);
+ (void)fflush(cout);
break;
default:
break;
@@ -382,26 +382,26 @@ getreply(expecteof)
dig++;
if (c == EOF) {
if (expecteof) {
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
code = 221;
return (0);
}
lostpeer();
if (verbose) {
- printf("421 Service not available, "
- "remote server has closed "
- "connection\n");
- (void) fflush(stdout);
+ puts(
+"421 Service not available, remote server has closed connection");
+ (void)fflush(stdout);
}
code = 421;
return (4);
}
if (c != '\r' && (verbose > 0 ||
- (verbose > -1 && n == '5' && dig > 4))) {
+ (verbose > -1 && n == '5' && dig > 4)) &&
+ (n < '5' || !retry_connect)) {
if (proxflag &&
(dig == 1 || (dig == 5 && verbose == 0)))
printf("%s:", hostname);
- (void) putchar(c);
+ (void)putchar(c);
}
if (dig < 4 && isdigit(c))
code = code * 10 + (c - '0');
@@ -427,9 +427,10 @@ getreply(expecteof)
if (cp < &current_line[sizeof(current_line) - 1])
*cp++ = c;
}
- if (verbose > 0 || (verbose > -1 && n == '5')) {
- (void) putchar(c);
- (void) fflush (stdout);
+ 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;
@@ -437,7 +438,7 @@ getreply(expecteof)
if (len > sizeof(reply_string))
len = sizeof(reply_string);
- (void) strncpy(reply_string, current_line, len);
+ (void)strncpy(reply_string, current_line, len);
reply_string[len] = '\0';
}
if (continuation && code != originalcode) {
@@ -448,7 +449,7 @@ getreply(expecteof)
*cp = '\0';
if (n != '1')
cpend = 0;
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
if (code == 421 || originalcode == 421)
lostpeer();
if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN)
@@ -478,8 +479,8 @@ abortsend()
alarmtimer(0);
mflag = 0;
abrtflag = 0;
- printf("\nsend aborted\nwaiting for remote to finish abort\n");
- (void) fflush(stdout);
+ puts("\nsend aborted\nwaiting for remote to finish abort");
+ (void)fflush(stdout);
longjmp(sendabort, 1);
}
@@ -519,18 +520,18 @@ sendrequest(cmd, local, remote, printnames)
lmode = "w";
if (setjmp(sendabort)) {
while (cpend) {
- (void) getreply(0);
+ (void)getreply(0);
}
if (data >= 0) {
- (void) close(data);
+ (void)close(data);
data = -1;
}
if (oldintr)
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
if (oldinti)
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
@@ -543,9 +544,9 @@ sendrequest(cmd, local, remote, printnames)
fin = popen(local + 1, "r");
if (fin == NULL) {
warn("%s", local + 1);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGPIPE, oldintp);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGPIPE, oldintp);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
@@ -554,17 +555,17 @@ sendrequest(cmd, local, remote, printnames)
fin = fopen(local, "r");
if (fin == NULL) {
warn("local: %s", local);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
closefunc = fclose;
if (fstat(fileno(fin), &st) < 0 ||
(st.st_mode&S_IFMT) != S_IFREG) {
- fprintf(stdout, "%s: not a plain file.\n", local);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ printf("%s: not a plain file.\n", local);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
fclose(fin);
code = -1;
return;
@@ -572,10 +573,10 @@ sendrequest(cmd, local, remote, printnames)
filesize = st.st_size;
}
if (initconn()) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
code = -1;
if (closefunc != NULL)
(*closefunc)(fin);
@@ -617,20 +618,20 @@ sendrequest(cmd, local, remote, printnames)
}
if (remote) {
if (command("%s %s", cmd, remote) != PRELIM) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
if (closefunc != NULL)
(*closefunc)(fin);
return;
}
} else
if (command("%s", cmd) != PRELIM) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
if (closefunc != NULL)
(*closefunc)(fin);
return;
@@ -645,24 +646,24 @@ sendrequest(cmd, local, remote, printnames)
case TYPE_I:
case TYPE_L:
errno = d = 0;
- while ((c = read(fileno(fin), buf, sizeof (buf))) > 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;
if (hash && (!progress || filesize < 0) ) {
while (bytes >= hashbytes) {
- (void) putchar('#');
+ (void)putchar('#');
hashbytes += mark;
}
- (void) fflush(stdout);
+ (void)fflush(stdout);
}
}
if (hash && (!progress || filesize < 0) && bytes > 0) {
if (bytes < mark)
- (void) putchar('#');
- (void) putchar('\n');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)putchar('\n');
+ (void)fflush(stdout);
}
if (c < 0)
warn("local: %s", local);
@@ -678,16 +679,16 @@ sendrequest(cmd, local, remote, printnames)
if (c == '\n') {
while (hash && (!progress || filesize < 0) &&
(bytes >= hashbytes)) {
- (void) putchar('#');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)fflush(stdout);
hashbytes += mark;
}
if (ferror(dout))
break;
- (void) putc('\r', dout);
+ (void)putc('\r', dout);
bytes++;
}
- (void) putc(c, dout);
+ (void)putc(c, dout);
bytes++;
#if 0 /* this violates RFC */
if (c == '\r') {
@@ -698,9 +699,9 @@ sendrequest(cmd, local, remote, printnames)
}
if (hash && (!progress || filesize < 0)) {
if (bytes < hashbytes)
- (void) putchar('#');
- (void) putchar('\n');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)putchar('\n');
+ (void)fflush(stdout);
}
if (ferror(fin))
warn("local: %s", local);
@@ -714,31 +715,31 @@ sendrequest(cmd, local, remote, printnames)
progressmeter(1);
if (closefunc != NULL)
(*closefunc)(fin);
- (void) fclose(dout);
- (void) getreply(0);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)fclose(dout);
+ (void)getreply(0);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
if (bytes > 0)
ptransfer(0);
return;
abort:
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
+ (void)signal(SIGPIPE, oldintp);
if (!cpend) {
code = -1;
return;
}
if (data >= 0) {
- (void) close(data);
+ (void)close(data);
data = -1;
}
if (dout)
- (void) fclose(dout);
- (void) getreply(0);
+ (void)fclose(dout);
+ (void)getreply(0);
code = -1;
if (closefunc != NULL && fin != NULL)
(*closefunc)(fin);
@@ -755,8 +756,8 @@ abortrecv()
alarmtimer(0);
mflag = 0;
abrtflag = 0;
- printf("\nreceive aborted\nwaiting for remote to finish abort\n");
- (void) fflush(stdout);
+ puts("\nreceive aborted\nwaiting for remote to finish abort");
+ (void)fflush(stdout);
longjmp(recvabort, 1);
}
@@ -797,16 +798,16 @@ recvrequest(cmd, local, remote, lmode, printnames)
tcrflag = !crflag && is_retr;
if (setjmp(recvabort)) {
while (cpend) {
- (void) getreply(0);
+ (void)getreply(0);
}
if (data >= 0) {
- (void) close(data);
+ (void)close(data);
data = -1;
}
if (oldintr)
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
if (oldinti)
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
@@ -818,8 +819,8 @@ recvrequest(cmd, local, remote, lmode, printnames)
if (errno != ENOENT && errno != EACCES) {
warn("local: %s", local);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
@@ -830,30 +831,30 @@ recvrequest(cmd, local, remote, lmode, printnames)
*dir = '/';
if (d < 0) {
warn("local: %s", local);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
if (!runique && errno == EACCES &&
chmod(local, 0600) < 0) {
warn("local: %s", local);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
if (runique && errno == EACCES &&
(local = gunique(local)) == NULL) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
}
else if (runique && (local = gunique(local)) == NULL) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
@@ -867,8 +868,8 @@ recvrequest(cmd, local, remote, lmode, printnames)
filesize = remotesize(remote, 0);
}
if (initconn()) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
code = -1;
return;
}
@@ -879,14 +880,14 @@ recvrequest(cmd, local, remote, lmode, printnames)
return;
if (remote) {
if (command("%s %s", cmd, remote) != PRELIM) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
return;
}
} else {
if (command("%s", cmd) != PRELIM) {
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
return;
}
}
@@ -915,7 +916,7 @@ recvrequest(cmd, local, remote, lmode, printnames)
st.st_blksize = BUFSIZ;
if (st.st_blksize > bufsize) {
if (buf)
- (void) free(buf);
+ (void)free(buf);
buf = malloc((unsigned)st.st_blksize);
if (buf == NULL) {
warn("malloc");
@@ -943,17 +944,17 @@ recvrequest(cmd, local, remote, lmode, printnames)
bytes += c;
if (hash && (!progress || filesize < 0)) {
while (bytes >= hashbytes) {
- (void) putchar('#');
+ (void)putchar('#');
hashbytes += mark;
}
- (void) fflush(stdout);
+ (void)fflush(stdout);
}
}
if (hash && (!progress || filesize < 0) && bytes > 0) {
if (bytes < mark)
- (void) putchar('#');
- (void) putchar('\n');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)putchar('\n');
+ (void)fflush(stdout);
}
if (c < 0) {
if (errno != EPIPE)
@@ -995,15 +996,15 @@ done:
while (c == '\r') {
while (hash && (!progress || filesize < 0) &&
(bytes >= hashbytes)) {
- (void) putchar('#');
- (void) fflush(stdout);
+ (void)putchar('#');
+ (void)fflush(stdout);
hashbytes += mark;
}
bytes++;
if ((c = getc(din)) != '\n' || tcrflag) {
if (ferror(fout))
goto break2;
- (void) putc('\r', fout);
+ (void)putc('\r', fout);
if (c == '\0') {
bytes++;
goto contin2;
@@ -1012,21 +1013,21 @@ done:
goto contin2;
}
}
- (void) putc(c, fout);
+ (void)putc(c, fout);
bytes++;
contin2: ;
}
break2:
if (bare_lfs) {
- printf("WARNING! %d bare linefeeds received in ASCII "
- "mode\n", bare_lfs);
- printf("File may not have transferred correctly.\n");
+ 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);
+ (void)putchar('#');
+ (void)putchar('\n');
+ (void)fflush(stdout);
}
if (ferror(din)) {
if (errno != EPIPE)
@@ -1040,26 +1041,25 @@ break2:
progressmeter(1);
if (closefunc != NULL)
(*closefunc)(fout);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
- (void) fclose(din);
- (void) getreply(0);
+ (void)signal(SIGPIPE, oldintp);
+ (void)fclose(din);
+ (void)getreply(0);
if (bytes >= 0 && is_retr) {
if (bytes > 0)
ptransfer(0);
if (preserve && (closefunc == fclose)) {
mtime = remotemodtime(remote, 0);
if (mtime != -1) {
- (void) gettimeofday(&tval[0],
+ (void)gettimeofday(&tval[0],
(struct timezone *)0);
tval[1].tv_sec = mtime;
tval[1].tv_usec = 0;
if (utimes(local, tval) == -1) {
- printf("Can't change modification time "
- "on %s to %s", local,
- asctime(localtime(&mtime)));
+ printf("Can't change modification time on %s to %s",
+ local, asctime(localtime(&mtime)));
}
}
}
@@ -1070,29 +1070,29 @@ abort:
/* abort using RFC959 recommended IP,SYNC sequence */
if (oldintp)
- (void) signal(SIGPIPE, oldintp);
- (void) signal(SIGINT, SIG_IGN);
+ (void)signal(SIGPIPE, oldintp);
+ (void)signal(SIGINT, SIG_IGN);
if (!cpend) {
code = -1;
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
return;
}
abort_remote(din);
code = -1;
if (data >= 0) {
- (void) close(data);
+ (void)close(data);
data = -1;
}
if (closefunc != NULL && fout != NULL)
(*closefunc)(fout);
if (din)
- (void) fclose(din);
+ (void)fclose(din);
if (bytes > 0)
ptransfer(0);
- (void) signal(SIGINT, oldintr);
- (void) signal(SIGINFO, oldinti);
+ (void)signal(SIGINT, oldintr);
+ (void)signal(SIGINFO, oldinti);
}
/*
@@ -1115,10 +1115,10 @@ initconn()
}
if ((options & SO_DEBUG) &&
setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
- sizeof (on)) < 0)
+ sizeof(on)) < 0)
warn("setsockopt (ignored)");
if (command("PASV") != COMPLETE) {
- printf("Passive mode refused.\n");
+ puts("Passive mode refused.");
goto bad;
}
@@ -1132,8 +1132,7 @@ initconn()
if (sscanf(pasv, "%d,%d,%d,%d,%d,%d",
&a0, &a1, &a2, &a3, &p0, &p1) != 6) {
- printf("Passive mode address scan failure. "
- "Shouldn't happen!\n");
+ puts("Passive mode address scan failure. Shouldn't happen!");
goto bad;
}
@@ -1167,7 +1166,7 @@ noport:
if (sendport)
data_addr.sin_port = 0; /* let system pick one */
if (data != -1)
- (void) close(data);
+ (void)close(data);
data = socket(AF_INET, SOCK_STREAM, 0);
if (data < 0) {
warn("socket");
@@ -1177,19 +1176,19 @@ noport:
}
if (!sendport)
if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, (char *)&on,
- sizeof (on)) < 0) {
+ sizeof(on)) < 0) {
warn("setsockopt (reuse address)");
goto bad;
}
- if (bind(data, (struct sockaddr *)&data_addr, sizeof (data_addr)) < 0) {
+ if (bind(data, (struct sockaddr *)&data_addr, sizeof(data_addr)) < 0) {
warn("bind");
goto bad;
}
if (options & SO_DEBUG &&
setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
- sizeof (on)) < 0)
+ sizeof(on)) < 0)
warn("setsockopt (ignored)");
- len = sizeof (data_addr);
+ len = sizeof(data_addr);
if (getsockname(data, (struct sockaddr *)&data_addr, &len) < 0) {
warn("getsockname");
goto bad;
@@ -1220,7 +1219,7 @@ noport:
#endif
return (0);
bad:
- (void) close(data), data = -1;
+ (void)close(data), data = -1;
if (tmpno)
sendport = 1;
return (1);
@@ -1231,7 +1230,7 @@ dataconn(lmode)
const char *lmode;
{
struct sockaddr_in from;
- int s, fromlen = sizeof (from), tos;
+ int s, fromlen = sizeof(from), tos;
if (passivemode)
return (fdopen(data, lmode));
@@ -1239,10 +1238,10 @@ dataconn(lmode)
s = accept(data, (struct sockaddr *) &from, &fromlen);
if (s < 0) {
warn("accept");
- (void) close(data), data = -1;
+ (void)close(data), data = -1;
return (NULL);
}
- (void) close(data);
+ (void)close(data);
data = s;
#ifdef IP_TOS
tos = IPTOS_THROUGHPUT;
@@ -1314,10 +1313,10 @@ pswitch(flag)
ip->connect = connected;
connected = op->connect;
if (hostname) {
- (void) strncpy(ip->name, hostname, sizeof(ip->name) - 1);
- ip->name[strlen(ip->name)] = '\0';
+ (void)strncpy(ip->name, hostname, sizeof(ip->name) - 1);
+ ip->name[sizeof(ip->name) - 1] = '\0';
} else
- ip->name[0] = 0;
+ ip->name[0] = '\0';
hostname = op->name;
ip->hctl = hisctladdr;
hisctladdr = op->hctl;
@@ -1341,21 +1340,21 @@ pswitch(flag)
mcase = op->mcse;
ip->ntflg = ntflag;
ntflag = op->ntflg;
- (void) strncpy(ip->nti, ntin, 16);
- (ip->nti)[strlen(ip->nti)] = '\0';
- (void) strcpy(ntin, op->nti);
- (void) strncpy(ip->nto, ntout, 16);
- (ip->nto)[strlen(ip->nto)] = '\0';
- (void) strcpy(ntout, op->nto);
+ (void)strncpy(ip->nti, ntin, sizeof(ip->nti) - 1);
+ (ip->nti)[sizeof(ip->nti) - 1] = '\0';
+ (void)strcpy(ntin, op->nti);
+ (void)strncpy(ip->nto, ntout, sizeof(ip->nto) - 1);
+ (ip->nto)[sizeof(ip->nto) - 1] = '\0';
+ (void)strcpy(ntout, op->nto);
ip->mapflg = mapflag;
mapflag = op->mapflg;
- (void) strncpy(ip->mi, mapin, MAXPATHLEN - 1);
- (ip->mi)[strlen(ip->mi)] = '\0';
- (void) strcpy(mapin, op->mi);
- (void) strncpy(ip->mo, mapout, MAXPATHLEN - 1);
- (ip->mo)[strlen(ip->mo)] = '\0';
- (void) strcpy(mapout, op->mo);
- (void) signal(SIGINT, oldintr);
+ (void)strncpy(ip->mi, mapin, sizeof(ip->mi) - 1);
+ (ip->mi)[sizeof(ip->mi) - 1] = '\0';
+ (void)strcpy(mapin, op->mi);
+ (void)strncpy(ip->mo, mapout, sizeof(ip->mo) - 1);
+ (ip->mo)[sizeof(ip->mo) - 1] = '\0';
+ (void)strcpy(mapout, op->mo);
+ (void)signal(SIGINT, oldintr);
if (abrtflag) {
abrtflag = 0;
(*oldintr)(SIGINT);
@@ -1367,8 +1366,8 @@ abortpt()
{
alarmtimer(0);
- printf("\n");
- (void) fflush(stdout);
+ putchar('\n');
+ (void)fflush(stdout);
ptabflg++;
mflag = 0;
abrtflag = 0;
@@ -1397,13 +1396,12 @@ proxtrans(cmd, local, remote)
if (curtype != prox_type)
changetype(prox_type, 1);
if (command("PASV") != COMPLETE) {
- printf("proxy server does not support third party "
- "transfers.\n");
+ puts("proxy server does not support third party transfers.");
return;
}
pswitch(0);
if (!connected) {
- printf("No primary connection\n");
+ puts("No primary connection");
pswitch(1);
code = -1;
return;
@@ -1418,7 +1416,7 @@ proxtrans(cmd, local, remote)
goto abort;
oldintr = signal(SIGINT, abortpt);
if (command("%s %s", cmd, remote) != PRELIM) {
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
pswitch(1);
return;
}
@@ -1428,16 +1426,16 @@ proxtrans(cmd, local, remote)
if (command("%s %s", cmd2, local) != PRELIM)
goto abort;
ptflag++;
- (void) getreply(0);
+ (void)getreply(0);
pswitch(0);
- (void) getreply(0);
- (void) signal(SIGINT, oldintr);
+ (void)getreply(0);
+ (void)signal(SIGINT, oldintr);
pswitch(1);
ptflag = 0;
printf("local: %s remote: %s\n", local, remote);
return;
abort:
- (void) signal(SIGINT, SIG_IGN);
+ (void)signal(SIGINT, SIG_IGN);
ptflag = 0;
if (strcmp(cmd, "RETR") && !proxy)
pswitch(1);
@@ -1452,7 +1450,7 @@ abort:
pswitch(1);
if (ptabflg)
code = -1;
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
return;
}
if (cpend)
@@ -1466,7 +1464,7 @@ abort:
pswitch(1);
if (ptabflg)
code = -1;
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
return;
}
}
@@ -1484,15 +1482,15 @@ abort:
code = -1;
lostpeer();
}
- (void) getreply(0);
- (void) getreply(0);
+ (void)getreply(0);
+ (void)getreply(0);
}
if (proxy)
pswitch(0);
pswitch(1);
if (ptabflg)
code = -1;
- (void) signal(SIGINT, oldintr);
+ (void)signal(SIGINT, oldintr);
}
void
@@ -1512,7 +1510,7 @@ reset(argc, argv)
lostpeer();
}
else if (nfnd) {
- (void) getreply(0);
+ (void)getreply(0);
}
}
}
@@ -1535,12 +1533,12 @@ gunique(local)
warn("local: %s", local);
return ((char *) 0);
}
- (void) strcpy(new, local);
+ (void)strcpy(new, local);
cp = new + strlen(new);
*cp++ = '.';
while (!d) {
if (++count == 100) {
- printf("runique: can't find unique file name.\n");
+ puts("runique: can't find unique file name.");
return ((char *) 0);
}
*cp++ = ext;
@@ -1579,7 +1577,7 @@ abort_remote(din)
if (send(fileno(cout), buf, 3, MSG_OOB) != 3)
warn("abort");
fprintf(cout, "%cABOR\r\n", DM);
- (void) fflush(cout);
+ (void)fflush(cout);
FD_ZERO(&mask);
FD_SET(fileno(cin), &mask);
if (din) {
@@ -1599,7 +1597,7 @@ abort_remote(din)
}
if (getreply(0) == ERROR && code == 552) {
/* 552 needed for nic style abort */
- (void) getreply(0);
+ (void)getreply(0);
}
- (void) getreply(0);
+ (void)getreply(0);
}