00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023
00024 #include <stdlib.h>
00025 #include <syslog.h>
00026
00027 #include <isc/result.h>
00028 #include <isc/string.h>
00029 #include <isc/syslog.h>
00030 #include <isc/util.h>
00031
00032 static struct dsn_c_pvt_sfnt {
00033 int val;
00034 const char *strval;
00035 } facilities[] = {
00036 { LOG_KERN, "kern" },
00037 { LOG_USER, "user" },
00038 { LOG_MAIL, "mail" },
00039 { LOG_DAEMON, "daemon" },
00040 { LOG_AUTH, "auth" },
00041 { LOG_SYSLOG, "syslog" },
00042 { LOG_LPR, "lpr" },
00043 #ifdef LOG_NEWS
00044 { LOG_NEWS, "news" },
00045 #endif
00046 #ifdef LOG_UUCP
00047 { LOG_UUCP, "uucp" },
00048 #endif
00049 #ifdef LOG_CRON
00050 { LOG_CRON, "cron" },
00051 #endif
00052 #ifdef LOG_AUTHPRIV
00053 { LOG_AUTHPRIV, "authpriv" },
00054 #endif
00055 #ifdef LOG_FTP
00056 { LOG_FTP, "ftp" },
00057 #endif
00058 { LOG_LOCAL0, "local0"},
00059 { LOG_LOCAL1, "local1"},
00060 { LOG_LOCAL2, "local2"},
00061 { LOG_LOCAL3, "local3"},
00062 { LOG_LOCAL4, "local4"},
00063 { LOG_LOCAL5, "local5"},
00064 { LOG_LOCAL6, "local6"},
00065 { LOG_LOCAL7, "local7"},
00066 { 0, NULL }
00067 };
00068
00069 isc_result_t
00070 isc_syslog_facilityfromstring(const char *str, int *facilityp) {
00071 int i;
00072
00073 REQUIRE(str != NULL);
00074 REQUIRE(facilityp != NULL);
00075
00076 for (i = 0; facilities[i].strval != NULL; i++) {
00077 if (strcasecmp(facilities[i].strval, str) == 0) {
00078 *facilityp = facilities[i].val;
00079 return (ISC_R_SUCCESS);
00080 }
00081 }
00082 return (ISC_R_NOTFOUND);
00083
00084 }