4 * Copyright (C) 2000-2006 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Id: facpri.c,v 1.6.2.5 2006/06/16 17:20:58 darrenr Exp
14 #include <sys/types.h>
15 #if !defined(__SVR4) && !defined(__svr4__)
25 static const char rcsid
[] = "@(#)Id: facpri.c,v 1.6.2.5 2006/06/16 17:20:58 darrenr Exp";
29 typedef struct table
{
35 { "kern", LOG_KERN
}, { "user", LOG_USER
},
36 { "mail", LOG_MAIL
}, { "daemon", LOG_DAEMON
},
37 { "auth", LOG_AUTH
}, { "syslog", LOG_SYSLOG
},
38 { "lpr", LOG_LPR
}, { "news", LOG_NEWS
},
40 #if LOG_CRON == LOG_CRON2
41 { "cron2", LOG_CRON1
},
43 { "cron", LOG_CRON1
},
49 { "authpriv", LOG_AUTHPRIV
},
52 { "audit", LOG_AUDIT
},
55 { "logalert", LOG_LFMT
},
57 #if LOG_CRON == LOG_CRON1
58 { "cron", LOG_CRON2
},
60 { "cron2", LOG_CRON2
},
63 { "security", LOG_SECURITY
},
65 { "local0", LOG_LOCAL0
}, { "local1", LOG_LOCAL1
},
66 { "local2", LOG_LOCAL2
}, { "local3", LOG_LOCAL3
},
67 { "local4", LOG_LOCAL4
}, { "local5", LOG_LOCAL5
},
68 { "local6", LOG_LOCAL6
}, { "local7", LOG_LOCAL7
},
74 * map a facility number to its name
82 fac
= facpri
& LOG_FACMASK
;
84 if (j
< (sizeof(facs
)/sizeof(facs
[0]))) {
85 if (facs
[j
].value
== fac
)
88 for (i
= 0; facs
[i
].name
; i
++)
89 if (fac
== facs
[i
].value
)
97 * map a facility name to its number
105 for (i
= 0; facs
[i
].name
; i
++)
106 if (!strcmp(facs
[i
].name
, name
))
107 return facs
[i
].value
;
113 { "emerg", LOG_EMERG
}, { "alert", LOG_ALERT
},
114 { "crit", LOG_CRIT
}, { "err", LOG_ERR
},
115 { "warn", LOG_WARNING
}, { "notice", LOG_NOTICE
},
116 { "info", LOG_INFO
}, { "debug", LOG_DEBUG
},
122 * map a priority number to its name
130 pri
= facpri
& LOG_PRIMASK
;
131 if (pris
[pri
].value
== pri
)
132 return pris
[pri
].name
;
133 for (i
= 0; pris
[i
].name
; i
++)
134 if (pri
== pris
[i
].value
)