summaryrefslogtreecommitdiffstats
path: root/usr.bin/logger
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-07-22 07:33:48 +0000
committercharnier <charnier@FreeBSD.org>1997-07-22 07:33:48 +0000
commit651e4c77827af8a163183a41586f11242d15fd12 (patch)
tree0984cd087afac9593f7fab32dfe1475b7dc5a03b /usr.bin/logger
parentd2c83baea4bd64747d13909e2d4780d40670c161 (diff)
downloadFreeBSD-src-651e4c77827af8a163183a41586f11242d15fd12.zip
FreeBSD-src-651e4c77827af8a163183a41586f11242d15fd12.tar.gz
Use err(3).
Diffstat (limited to 'usr.bin/logger')
-rw-r--r--usr.bin/logger/logger.16
-rw-r--r--usr.bin/logger/logger.c41
2 files changed, 21 insertions, 26 deletions
diff --git a/usr.bin/logger/logger.1 b/usr.bin/logger/logger.1
index 0621dba..30744f7 100644
--- a/usr.bin/logger/logger.1
+++ b/usr.bin/logger/logger.1
@@ -38,7 +38,7 @@
.Nm logger
.Nd make entries in the system log
.Sh SYNOPSIS
-.Nm logger
+.Nm
.Op Fl is
.Op Fl f Ar file
.Op Fl p Ar pri
@@ -81,7 +81,7 @@ provided, standard input is logged.
.El
.Pp
The
-.Nm logger
+.Nm
utility exits 0 on success, and >0 if an error occurs.
.Sh EXAMPLES
.Bd -literal -offset indent -compact
@@ -94,7 +94,7 @@ logger \-p local0.notice \-t HOSTIDM \-f /dev/idmc
.Xr syslogd 8
.Sh STANDARDS
The
-.Nm logger
+.Nm
command is expected to be
.St -p1003.2
compatible.
diff --git a/usr.bin/logger/logger.c b/usr.bin/logger/logger.c
index 553591f..c272ae2 100644
--- a/usr.bin/logger/logger.c
+++ b/usr.bin/logger/logger.c
@@ -32,28 +32,32 @@
*/
#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[] = "@(#)logger.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
#include <ctype.h>
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#define SYSLOG_NAMES
#include <syslog.h>
int decode __P((char *, CODE *));
int pencode __P((char *));
-void usage __P((void));
+static void usage __P((void));
/*
* logger -- read and log utility
@@ -76,11 +80,8 @@ main(argc, argv)
while ((ch = getopt(argc, argv, "f:ip:st:")) != -1)
switch((char)ch) {
case 'f': /* file to log */
- if (freopen(optarg, "r", stdin) == NULL) {
- (void)fprintf(stderr, "logger: %s: %s.\n",
- optarg, strerror(errno));
- exit(1);
- }
+ if (freopen(optarg, "r", stdin) == NULL)
+ err(1, "%s", optarg);
break;
case 'i': /* log process id also */
logflags |= LOG_PID;
@@ -147,11 +148,8 @@ pencode(s)
if (*s) {
*s = '\0';
fac = decode(save, facilitynames);
- if (fac < 0) {
- (void)fprintf(stderr,
- "logger: unknown facility name: %s.\n", save);
- exit(1);
- }
+ if (fac < 0)
+ errx(1, "unknown facility name: %s", save);
*s++ = '.';
}
else {
@@ -159,11 +157,8 @@ pencode(s)
s = save;
}
lev = decode(s, prioritynames);
- if (lev < 0) {
- (void)fprintf(stderr,
- "logger: unknown priority name: %s.\n", save);
- exit(1);
- }
+ if (lev < 0)
+ errx(1, "unknown priority name: %s", save);
return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
}
@@ -184,10 +179,10 @@ decode(name, codetab)
return (-1);
}
-void
+static void
usage()
{
(void)fprintf(stderr,
- "logger: [-is] [-f file] [-p pri] [-t tag] [ message ... ]\n");
+ "usage: logger [-is] [-f file] [-p pri] [-t tag] [message ...]\n");
exit(1);
}
OpenPOWER on IntegriCloud