1 /* $Id$ */
2 /*
3 * Copyright (c) 1994-1996 Sam Leffler
4 * Copyright (c) 1994-1996 Silicon Graphics, Inc.
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that (i) the above copyright notices and this permission notice appear in
9 * all copies of the software and related documentation, and (ii) the names of
10 * Sam Leffler and Silicon Graphics may not be used in any advertising or
11 * publicity relating to the software without the specific, prior written
12 * permission of Sam Leffler and Silicon Graphics.
13 *
14 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17 *
18 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
19 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 * OF THIS SOFTWARE.
24 */
25 #include <stdio.h>
26 #include <syslog.h>
27 #include <string.h>
28
29 static struct {
30 char *c_name;
31 int c_val;
32 } facilitynames[] = {
33 #ifdef LOG_AUDIT
34 { "audit", LOG_AUDIT },
35 #endif
36 #ifdef LOG_AUTH
37 { "auth", LOG_AUTH },
38 #endif
39 #ifdef LOG_CRON
40 { "cron", LOG_CRON },
41 #endif
42 #ifdef LOG_DAEMON
43 { "daemon", LOG_DAEMON },
44 #endif
45 #ifdef LOG_MAIL
46 { "mail", LOG_MAIL },
47 #endif
48 #ifdef LOG_NEWS
49 { "news", LOG_NEWS },
50 #endif
51 #ifdef LOG_SAT
52 { "sat", LOG_AUDIT },
53 #endif
54 #ifdef LOG_SYSLOG
55 { "syslog", LOG_SYSLOG },
56 #endif
57 #ifdef LOG_USER
58 { "user", LOG_USER },
59 #endif
60 #ifdef LOG_UUCP
61 { "uucp", LOG_UUCP },
62 #endif
63 #ifdef LOG_LOCAL0
64 { "local0", LOG_LOCAL0 },
65 #endif
66 #ifdef LOG_LOCAL1
67 { "local1", LOG_LOCAL1 },
68 #endif
69 #ifdef LOG_LOCAL2
70 { "local2", LOG_LOCAL2 },
71 #endif
72 #ifdef LOG_LOCAL3
73 { "local3", LOG_LOCAL3 },
74 #endif
75 #ifdef LOG_LOCAL4
76 { "local4", LOG_LOCAL4 },
77 #endif
78 #ifdef LOG_LOCAL5
79 { "local5", LOG_LOCAL5 },
80 #endif
81 #ifdef LOG_LOCAL6
82 { "local6", LOG_LOCAL6 },
83 #endif
84 #ifdef LOG_LOCAL7
85 { "local7", LOG_LOCAL7 },
86 #endif
87 { NULL, -1 },
88 };
89
90 int
cvtFacility(const char * name,int * facility)91 cvtFacility(const char* name, int* facility)
92 {
93 int i;
94
95 for (i = 0; facilitynames[i].c_name != NULL; i++)
96 if (strcasecmp(facilitynames[i].c_name, name) == 0) {
97 *facility = facilitynames[i].c_val;
98 return (1);
99 }
100 return (0);
101 }
102