aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/logger
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1997-07-22 07:33:48 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1997-07-22 07:33:48 +0000
commitdf0715563dce9e936001bb627875dcb675e53edf (patch)
tree43020f7c9531d88567fb3e44ac1091bf119e9130 /usr.bin/logger
parent3ec665d4828579ed6b3a43561e104937a264905f (diff)
Notes
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 0621dba10f3f..30744f7d258a 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 553591ffe110..c272ae269305 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);
}