syslog.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: syslog.c,v 1.8 2007/09/13 04:45:18 each Exp $ */
00019 
00020 /*! \file */
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 }

Generated on Tue Apr 28 17:41:06 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha