2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
28
29 /*
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
32 * All Rights Reserved
33 *
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
36 * contributors.
37 */
38
39 #pragma ident "%Z%%M% %I% %E% SMI"
40
41 #include <sys/types.h>
42 #include <unistd.h>
43 #include <stdio.h>
44 #include <syslog.h>
45 #include <ctype.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <locale.h>
49 #include <limits.h>
50 #include <pwd.h>
51 #include <errno.h>
52
53 #define LOG_MARK (LOG_NFACILITIES << 3) /* mark "facility" */
54 #define LOGGER_BUFLEN 1024
55
56 struct code {
57 char *c_name;
58 int c_val;
59 };
68 "warn", LOG_WARNING,
69 "warning", LOG_WARNING,
70 "notice", LOG_NOTICE,
71 "info", LOG_INFO,
72 "debug", LOG_DEBUG,
73 NULL, -1
74 };
75
76 static struct code FacNames[] = {
77 "kern", LOG_KERN,
78 "user", LOG_USER,
79 "mail", LOG_MAIL,
80 "daemon", LOG_DAEMON,
81 "auth", LOG_AUTH,
82 "security", LOG_AUTH,
83 "mark", LOG_MARK,
84 "syslog", LOG_SYSLOG,
85 "lpr", LOG_LPR,
86 "news", LOG_NEWS,
87 "uucp", LOG_UUCP,
88 "cron", LOG_CRON,
89 "audit", LOG_AUDIT,
90 "local0", LOG_LOCAL0,
91 "local1", LOG_LOCAL1,
92 "local2", LOG_LOCAL2,
93 "local3", LOG_LOCAL3,
94 "local4", LOG_LOCAL4,
95 "local5", LOG_LOCAL5,
96 "local6", LOG_LOCAL6,
97 "local7", LOG_LOCAL7,
98 NULL, -1
99 };
100
101 static int pencode(register char *);
102 static int decode(char *, struct code *);
103 static void bailout(char *, char *);
104 static void usage(void);
105
106 /*
107 * LOGGER -- read and log utility
108 *
109 * This routine reads from an input and arranges to write the
|
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2013 Gary Mills
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29
30 /*
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
34 *
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
38 */
39
40
41 #include <sys/types.h>
42 #include <unistd.h>
43 #include <stdio.h>
44 #include <syslog.h>
45 #include <ctype.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <locale.h>
49 #include <limits.h>
50 #include <pwd.h>
51 #include <errno.h>
52
53 #define LOG_MARK (LOG_NFACILITIES << 3) /* mark "facility" */
54 #define LOGGER_BUFLEN 1024
55
56 struct code {
57 char *c_name;
58 int c_val;
59 };
68 "warn", LOG_WARNING,
69 "warning", LOG_WARNING,
70 "notice", LOG_NOTICE,
71 "info", LOG_INFO,
72 "debug", LOG_DEBUG,
73 NULL, -1
74 };
75
76 static struct code FacNames[] = {
77 "kern", LOG_KERN,
78 "user", LOG_USER,
79 "mail", LOG_MAIL,
80 "daemon", LOG_DAEMON,
81 "auth", LOG_AUTH,
82 "security", LOG_AUTH,
83 "mark", LOG_MARK,
84 "syslog", LOG_SYSLOG,
85 "lpr", LOG_LPR,
86 "news", LOG_NEWS,
87 "uucp", LOG_UUCP,
88 "bsdcron", LOG_BSDCRON,
89 "authpriv", LOG_AUTHPRIV,
90 "ftp", LOG_FTP,
91 "ntp", LOG_NTP,
92 "audit", LOG_AUDIT,
93 "console", LOG_CONSOLE,
94 "cron", LOG_CRON,
95 "local0", LOG_LOCAL0,
96 "local1", LOG_LOCAL1,
97 "local2", LOG_LOCAL2,
98 "local3", LOG_LOCAL3,
99 "local4", LOG_LOCAL4,
100 "local5", LOG_LOCAL5,
101 "local6", LOG_LOCAL6,
102 "local7", LOG_LOCAL7,
103 NULL, -1
104 };
105
106 static int pencode(register char *);
107 static int decode(char *, struct code *);
108 static void bailout(char *, char *);
109 static void usage(void);
110
111 /*
112 * LOGGER -- read and log utility
113 *
114 * This routine reads from an input and arranges to write the
|