summaryrefslogtreecommitdiff
path: root/usr.bin/tftp
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-24 20:21:41 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-24 20:21:41 +0000
commit30775b0c5c6c82ff6c26566ce986fa64de21aae5 (patch)
tree69d755ae7001a211b827826701538e64e742685f /usr.bin/tftp
parent780100eac9fc276c871e2aeb620c35216687819d (diff)
knf
Diffstat (limited to 'usr.bin/tftp')
-rw-r--r--usr.bin/tftp/main.c17
-rw-r--r--usr.bin/tftp/tftp.c26
-rw-r--r--usr.bin/tftp/tftpsubs.c35
3 files changed, 37 insertions, 41 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c
index b512f7eba21..1a50a844f2b 100644
--- a/usr.bin/tftp/main.c
+++ b/usr.bin/tftp/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.17 2003/09/24 20:19:48 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.18 2003/09/24 20:21:40 deraadt Exp $ */
/* $NetBSD: main.c,v 1.6 1995/05/21 16:54:10 mycroft Exp $ */
/*
@@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: main.c,v 1.17 2003/09/24 20:19:48 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: main.c,v 1.18 2003/09/24 20:21:40 deraadt Exp $";
#endif /* not lint */
/* Many bug fixes are from Jim Guyton <guyton@rand-unix> */
@@ -356,13 +356,14 @@ put(int argc, char *argv[])
}
if (verbose)
printf("putting %s to %s:%s [%s]\n",
- cp, hostname, targ, mode);
+ cp, hostname, targ, mode);
peeraddr.sin_port = port;
sendfile(fd, targ, mode);
return;
}
- /* this assumes the target is a directory */
- /* on a remote unix system. hmmmm. */
+
+ /* this assumes the target is a directory */
+ /* on a remote unix system. hmmmm. */
for (n = 1; n < argc - 1; n++) {
if (asprintf(&cp, "%s/%s", targ, tail(argv[n])) == -1)
err(1, "asprintf");
@@ -373,7 +374,7 @@ put(int argc, char *argv[])
}
if (verbose)
printf("putting %s to %s:%s [%s]\n",
- argv[n], hostname, cp, mode);
+ argv[n], hostname, cp, mode);
peeraddr.sin_port = port;
sendfile(fd, cp, mode);
free(cp);
@@ -446,7 +447,7 @@ get(int argc, char *argv[])
}
if (verbose)
printf("getting from %s:%s to %s [%s]\n",
- hostname, src, cp, mode);
+ hostname, src, cp, mode);
peeraddr.sin_port = port;
recvfile(fd, src, mode);
break;
@@ -459,7 +460,7 @@ get(int argc, char *argv[])
}
if (verbose)
printf("getting from %s:%s to %s [%s]\n",
- hostname, src, cp, mode);
+ hostname, src, cp, mode);
peeraddr.sin_port = port;
recvfile(fd, src, mode);
}
diff --git a/usr.bin/tftp/tftp.c b/usr.bin/tftp/tftp.c
index b8859c0ccf9..189ceadc650 100644
--- a/usr.bin/tftp/tftp.c
+++ b/usr.bin/tftp/tftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tftp.c,v 1.14 2003/06/25 15:45:10 deraadt Exp $ */
+/* $OpenBSD: tftp.c,v 1.15 2003/09/24 20:21:40 deraadt Exp $ */
/* $NetBSD: tftp.c,v 1.5 1995/04/29 05:55:25 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)tftp.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: tftp.c,v 1.14 2003/06/25 15:45:10 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: tftp.c,v 1.15 2003/09/24 20:21:40 deraadt Exp $";
#endif /* not lint */
/* Many bug fixes are from Jim Guyton <guyton@rand-unix> */
@@ -151,7 +151,7 @@ send_data:
ap->th_block = ntohs(ap->th_block);
if (ap->th_opcode == ERROR) {
printf("Error code %d: %s\n", ap->th_code,
- ap->th_msg);
+ ap->th_msg);
goto abort;
}
if (ap->th_opcode == ACK) {
@@ -164,13 +164,10 @@ send_data:
* both sides.
*/
j = synchnet(f);
- if (j && trace) {
- printf("discarded %d packets\n",
- j);
- }
- if (ap->th_block == (block-1)) {
+ if (j && trace)
+ printf("discarded %d packets\n", j);
+ if (ap->th_block == (block-1))
goto send_data;
- }
}
}
if (block > 0)
@@ -250,7 +247,7 @@ send_ack:
dp->th_block = ntohs(dp->th_block);
if (dp->th_opcode == ERROR) {
printf("Error code %d: %s\n", dp->th_code,
- dp->th_msg);
+ dp->th_msg);
goto abort;
}
if (dp->th_opcode == DATA) {
@@ -263,12 +260,10 @@ send_ack:
* both sides.
*/
j = synchnet(f);
- if (j && trace) {
+ if (j && trace)
printf("discarded %d packets\n", j);
- }
- if (dp->th_block == (block-1)) {
+ if (dp->th_block == (block-1))
goto send_ack; /* resend ack */
- }
}
}
/* size = write(fd, dp->th_data, n - 4); */
@@ -413,7 +408,8 @@ static void
printstats(const char *direction, unsigned long amount)
{
double delta;
- /* compute delta in 1/10's second units */
+
+ /* compute delta in 1/10's second units */
delta = ((tstop.tv_sec*10.)+(tstop.tv_usec/100000)) -
((tstart.tv_sec*10.)+(tstart.tv_usec/100000));
delta = delta/10.; /* back to seconds */
diff --git a/usr.bin/tftp/tftpsubs.c b/usr.bin/tftp/tftpsubs.c
index ffc2177a7d6..5c23d0fd32e 100644
--- a/usr.bin/tftp/tftpsubs.c
+++ b/usr.bin/tftp/tftpsubs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tftpsubs.c,v 1.8 2003/06/26 07:59:49 deraadt Exp $ */
+/* $OpenBSD: tftpsubs.c,v 1.9 2003/09/24 20:21:40 deraadt Exp $ */
/* $NetBSD: tftpsubs.c,v 1.3 1994/12/08 09:51:31 jtc Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)tftpsubs.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: tftpsubs.c,v 1.8 2003/06/26 07:59:49 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: tftpsubs.c,v 1.9 2003/09/24 20:21:40 deraadt Exp $";
#endif /* not lint */
/* Simple minded read-ahead/write-behind subroutines for tftp user and
@@ -156,10 +156,10 @@ read_ahead(FILE *file, int convert)
if (newline) {
if (prevchar == '\n')
c = '\n'; /* lf to cr,lf */
- else c = '\0'; /* cr to cr,nul */
+ else
+ c = '\0'; /* cr to cr,nul */
newline = 0;
- }
- else {
+ } else {
c = getc(file);
if (c == EOF) break;
if (c == '\n' || c == '\r') {
@@ -194,7 +194,7 @@ writeit(FILE *file, struct tftphdr **dpp, int ct, int convert)
* CR,NUL -> CR and CR,LF => LF.
* Note spec is undefined if we get CR as last byte of file or a
* CR followed by anything else. In this case we leave it alone.
- */
+n */
int
write_behind(FILE *file, int convert)
{
@@ -224,18 +224,17 @@ write_behind(FILE *file, int convert)
p = buf;
ct = count;
while (ct--) { /* loop over the buffer */
- c = *p++; /* pick up a character */
- if (prevchar == '\r') { /* if prev char was cr */
- if (c == '\n') /* if have cr,lf then just */
- fseek(file, -1, 1); /* smash lf on top of the cr */
- else
- if (c == '\0') /* if have cr,nul then */
- goto skipit; /* just skip over the putc */
- /* else just fall through and allow it */
- }
- putc(c, file);
+ c = *p++; /* pick up a character */
+ if (prevchar == '\r') { /* if prev char was cr */
+ if (c == '\n') /* if have cr,lf then just */
+ fseek(file, -1, 1); /* smash lf on top of the cr */
+ else if (c == '\0') /* if have cr,nul then */
+ goto skipit; /* just skip over the putc */
+ /* else just fall through and allow it */
+ }
+ putc(c, file);
skipit:
- prevchar = c;
+ prevchar = c;
}
return count;
}
@@ -266,7 +265,7 @@ synchnet(int f)
j++;
fromlen = sizeof from;
(void) recvfrom(f, rbuf, sizeof (rbuf), 0,
- (struct sockaddr *)&from, &fromlen);
+ (struct sockaddr *)&from, &fromlen);
} else {
return(j);
}