* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
static char sccsid
[] = "@(#)logger.c 6.2 (Berkeley) 9/19/85";
** LOGGER -- read and log utility
** This routine reads from an input and arranges to write the
** result on the system log, along with a useful tag.
/* this can be used to give null parameters */
if (argc
> 1 && argv
[1][0] != '-')
if (argc
> 1 && argv
[1][0] != '-')
case 'i': /* log process id also */
case 'f': /* file to log */
if (argc
> 1 && argv
[1][0] != '-')
if (freopen(*++argv
, "r", stdin
) == NULL
)
fprintf(stderr
, "logger: unknown flag -%s\n", p
);
openlog(tag
, logflags
, 0);
/* log input line if appropriate */
while (fgets(buf
, sizeof buf
, stdin
) != NULL
)
struct code PriNames
[] = {
struct code FacNames
[] = {
* Decode a symbolic name to a numeric value
for (p
= buf
; *s
&& *s
!= '.'; )
fac
= decode(buf
, FacNames
);
bailout("unknown facility name: ", buf
);
for (p
= buf
; *p
++ = *s
++; )
lev
= decode(buf
, PriNames
);
bailout("unknown priority name: ", buf
);
return ((lev
& LOG_PRIMASK
) | (fac
& LOG_FACMASK
));
(void) strcpy(buf
, name
);
for (c
= codetab
; c
->c_name
; c
++)
if (!strcmp(buf
, c
->c_name
))
fprintf(stderr
, "logger: %s%s\n", a
, b
);