2 * Copyright (C) 1993-2001 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: facpri.c,v 1.6 2003/12/01 01:59:43 darrenr Exp $
12 #include <sys/types.h>
13 #if !defined(__SVR4) && !defined(__svr4__)
22 static const char rcsid
[] = "@(#)$Id: facpri.c,v 1.6 2003/12/01 01:59:43 darrenr Exp $";
25 typedef struct table
{
31 { "kern", LOG_KERN
}, { "user", LOG_USER
},
32 { "mail", LOG_MAIL
}, { "daemon", LOG_DAEMON
},
33 { "auth", LOG_AUTH
}, { "syslog", LOG_SYSLOG
},
34 { "lpr", LOG_LPR
}, { "news", LOG_NEWS
},
36 #if LOG_CRON == LOG_CRON2
37 { "cron2", LOG_CRON1
},
39 { "cron", LOG_CRON1
},
45 { "authpriv", LOG_AUTHPRIV
},
48 { "audit", LOG_AUDIT
},
51 { "logalert", LOG_LFMT
},
53 #if LOG_CRON == LOG_CRON1
54 { "cron", LOG_CRON2
},
56 { "cron2", LOG_CRON2
},
59 { "security", LOG_SECURITY
},
61 { "local0", LOG_LOCAL0
}, { "local1", LOG_LOCAL1
},
62 { "local2", LOG_LOCAL2
}, { "local3", LOG_LOCAL3
},
63 { "local4", LOG_LOCAL4
}, { "local5", LOG_LOCAL5
},
64 { "local6", LOG_LOCAL6
}, { "local7", LOG_LOCAL7
},
70 * map a facility number to its name
78 fac
= facpri
& LOG_FACMASK
;
81 if (facs
[j
].value
== fac
)
83 for (i
= 0; facs
[i
].name
; i
++)
84 if (fac
== facs
[i
].value
)
93 * map a facility name to its number
101 for (i
= 0; facs
[i
].name
; i
++)
102 if (!strcmp(facs
[i
].name
, name
))
103 return facs
[i
].value
;
109 { "emerg", LOG_EMERG
}, { "alert", LOG_ALERT
},
110 { "crit", LOG_CRIT
}, { "err", LOG_ERR
},
111 { "warn", LOG_WARNING
}, { "notice", LOG_NOTICE
},
112 { "info", LOG_INFO
}, { "debug", LOG_DEBUG
},
118 * map a priority name to its number
126 for (i
= 0; pris
[i
].name
; i
++)
127 if (!strcmp(pris
[i
].name
, name
))
128 return pris
[i
].value
;
134 * map a priority number to its name
142 pri
= facpri
& LOG_PRIMASK
;
143 if (pris
[pri
].value
== pri
)
144 return pris
[pri
].name
;
145 for (i
= 0; pris
[i
].name
; i
++)
146 if (pri
== pris
[i
].value
)