summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-08-14 06:47:41 +0000
committercharnier <charnier@FreeBSD.org>1997-08-14 06:47:41 +0000
commit1cc1919e6eb5e2daabdd40ceb62c0edd333a9533 (patch)
tree91fea672f86e8f513f37578cb55cca7d72c1b876 /usr.bin
parent051a2e06f57a036613bcdc06f3de53f4f23744cf (diff)
downloadFreeBSD-src-1cc1919e6eb5e2daabdd40ceb62c0edd333a9533.zip
FreeBSD-src-1cc1919e6eb5e2daabdd40ceb62c0edd333a9533.tar.gz
Use err(3). 100 -> MAXHOSTNAMELEN from OpenBSD.
Obtained from: OpenBSD
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tftp/main.c39
-rw-r--r--usr.bin/tftp/tftp.18
-rw-r--r--usr.bin/tftp/tftp.c17
-rw-r--r--usr.bin/tftp/tftpsubs.c4
4 files changed, 36 insertions, 32 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c
index 4763f43..5c9376d 100644
--- a/usr.bin/tftp/main.c
+++ b/usr.bin/tftp/main.c
@@ -32,13 +32,17 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/* Many bug fixes are from Jim Guyton <guyton@rand-unix> */
@@ -46,6 +50,7 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
/*
* TFTP User Program -- Command Interface.
*/
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
@@ -55,7 +60,7 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#include <arpa/inet.h>
#include <ctype.h>
-#include <errno.h>
+#include <err.h>
#include <netdb.h>
#include <setjmp.h>
#include <signal.h>
@@ -145,8 +150,6 @@ struct cmd cmdtab[] = {
struct cmd *getcmd();
char *tail();
-char *index();
-char *rindex();
int
main(argc, argv)
@@ -156,21 +159,15 @@ main(argc, argv)
struct sockaddr_in sin;
sp = getservbyname("tftp", "udp");
- if (sp == 0) {
- fprintf(stderr, "tftp: udp/tftp: unknown service\n");
- exit(1);
- }
+ if (sp == 0)
+ errx(1, "udp/tftp: unknown service");
f = socket(AF_INET, SOCK_DGRAM, 0);
- if (f < 0) {
- perror("tftp: socket");
- exit(3);
- }
+ if (f < 0)
+ err(3, "socket");
bzero((char *)&sin, sizeof(sin));
sin.sin_family = AF_INET;
- if (bind(f, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- perror("tftp: bind");
- exit(1);
- }
+ if (bind(f, (struct sockaddr *)&sin, sizeof(sin)) < 0)
+ err(1, "bind");
strcpy(mode, "netascii");
signal(SIGINT, intr);
if (argc > 1) {
@@ -183,7 +180,7 @@ main(argc, argv)
command();
}
-char hostname[100];
+char hostname[MAXHOSTNAMELEN];
void
setpeer(argc, argv)
@@ -364,7 +361,7 @@ put(argc, argv)
cp = argc == 2 ? tail(targ) : argv[1];
fd = open(cp, O_RDONLY);
if (fd < 0) {
- fprintf(stderr, "tftp: "); perror(cp);
+ warn("%s", cp);
return;
}
if (verbose)
@@ -382,7 +379,7 @@ put(argc, argv)
strcpy(cp, tail(argv[n]));
fd = open(argv[n], O_RDONLY);
if (fd < 0) {
- fprintf(stderr, "tftp: "); perror(argv[n]);
+ warn("%s", argv[n]);
continue;
}
if (verbose)
@@ -457,7 +454,7 @@ get(argc, argv)
cp = argc == 3 ? argv[2] : tail(src);
fd = creat(cp, 0644);
if (fd < 0) {
- fprintf(stderr, "tftp: "); perror(cp);
+ warn("%s", cp);
return;
}
if (verbose)
@@ -470,7 +467,7 @@ get(argc, argv)
cp = tail(src); /* new .. jdg */
fd = creat(cp, 0644);
if (fd < 0) {
- fprintf(stderr, "tftp: "); perror(cp);
+ warn("%s", cp);
continue;
}
if (verbose)
diff --git a/usr.bin/tftp/tftp.1 b/usr.bin/tftp/tftp.1
index b2c5a16..4b1a259 100644
--- a/usr.bin/tftp/tftp.1
+++ b/usr.bin/tftp/tftp.1
@@ -38,7 +38,7 @@
.Nm tftp
.Nd trivial file transfer program
.Sh SYNOPSIS
-.Nm tftp
+.Nm
.Op Ar host
.Sh DESCRIPTION
.Nm Tftp
@@ -49,7 +49,7 @@ which allows users to transfer files to and from a remote machine.
The remote
.Ar host
may be specified on the command line, in which case
-.Nm tftp
+.Nm
uses
.Ar host
as the default host for future transfers (see the
@@ -57,9 +57,9 @@ as the default host for future transfers (see the
command below).
.Sh COMMANDS
Once
-.Nm tftp
+.Nm
is running, it issues the prompt
-.LI tftp>
+.Nm tftp>
and recognizes the following commands:
.Pp
.Bl -tag -width verbose -compact
diff --git a/usr.bin/tftp/tftp.c b/usr.bin/tftp/tftp.c
index 2ca4001..014e287 100644
--- a/usr.bin/tftp/tftp.c
+++ b/usr.bin/tftp/tftp.c
@@ -32,7 +32,11 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)tftp.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/* Many bug fixes are from Jim Guyton <guyton@rand-unix> */
@@ -48,6 +52,7 @@ static char sccsid[] = "@(#)tftp.c 8.1 (Berkeley) 6/6/93";
#include <arpa/tftp.h>
+#include <err.h>
#include <errno.h>
#include <setjmp.h>
#include <signal.h>
@@ -57,8 +62,6 @@ static char sccsid[] = "@(#)tftp.c 8.1 (Berkeley) 6/6/93";
#include "extern.h"
#include "tftpsubs.h"
-extern int errno;
-
extern struct sockaddr_in peeraddr; /* filled in by main */
extern int f; /* the opened socket */
extern int trace;
@@ -128,7 +131,7 @@ send_data:
n = sendto(f, dp, size + 4, 0,
(struct sockaddr *)&peeraddr, sizeof(peeraddr));
if (n != size + 4) {
- perror("tftp: sendto");
+ warn("sendto");
goto abort;
}
read_ahead(file, convert);
@@ -141,7 +144,7 @@ send_data:
} while (n <= 0);
alarm(0);
if (n < 0) {
- perror("tftp: recvfrom");
+ warn("recvfrom");
goto abort;
}
peeraddr.sin_port = from.sin_port; /* added */
@@ -232,7 +235,7 @@ send_ack:
if (sendto(f, ackbuf, size, 0, (struct sockaddr *)&peeraddr,
sizeof(peeraddr)) != size) {
alarm(0);
- perror("tftp: sendto");
+ warn("sendto");
goto abort;
}
write_behind(file, convert);
@@ -245,7 +248,7 @@ send_ack:
} while (n <= 0);
alarm(0);
if (n < 0) {
- perror("tftp: recvfrom");
+ warn("recvfrom");
goto abort;
}
peeraddr.sin_port = from.sin_port; /* added */
@@ -363,7 +366,7 @@ nak(error)
tpacket("sent", tp, length);
if (sendto(f, ackbuf, length, 0, (struct sockaddr *)&peeraddr,
sizeof(peeraddr)) != length)
- perror("nak");
+ warn("nak");
}
static void
diff --git a/usr.bin/tftp/tftpsubs.c b/usr.bin/tftp/tftpsubs.c
index a143602..277d561 100644
--- a/usr.bin/tftp/tftpsubs.c
+++ b/usr.bin/tftp/tftpsubs.c
@@ -32,7 +32,11 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)tftpsubs.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/* Simple minded read-ahead/write-behind subroutines for tftp user and
OpenPOWER on IntegriCloud