1135446Strhodes/* 2174187Sdougb * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 3135446Strhodes * Copyright (C) 2001 Internet Software Consortium. 4135446Strhodes * 5174187Sdougb * Permission to use, copy, modify, and/or distribute this software for any 6135446Strhodes * purpose with or without fee is hereby granted, provided that the above 7135446Strhodes * copyright notice and this permission notice appear in all copies. 8135446Strhodes * 9135446Strhodes * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10135446Strhodes * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11135446Strhodes * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12135446Strhodes * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13135446Strhodes * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14135446Strhodes * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15135446Strhodes * PERFORMANCE OF THIS SOFTWARE. 16135446Strhodes */ 17135446Strhodes 18234010Sdougb/* $Id: syslog.c,v 1.8 2007/09/13 04:45:18 each Exp $ */ 19135446Strhodes 20170222Sdougb/*! \file */ 21170222Sdougb 22135446Strhodes#include <config.h> 23135446Strhodes 24135446Strhodes#include <stdlib.h> 25135446Strhodes#include <syslog.h> 26135446Strhodes 27135446Strhodes#include <isc/result.h> 28174187Sdougb#include <isc/string.h> 29135446Strhodes#include <isc/syslog.h> 30135446Strhodes#include <isc/util.h> 31135446Strhodes 32135446Strhodesstatic struct dsn_c_pvt_sfnt { 33135446Strhodes int val; 34135446Strhodes const char *strval; 35135446Strhodes} facilities[] = { 36135446Strhodes { LOG_KERN, "kern" }, 37135446Strhodes { LOG_USER, "user" }, 38135446Strhodes { LOG_MAIL, "mail" }, 39135446Strhodes { LOG_DAEMON, "daemon" }, 40135446Strhodes { LOG_AUTH, "auth" }, 41135446Strhodes { LOG_SYSLOG, "syslog" }, 42135446Strhodes { LOG_LPR, "lpr" }, 43135446Strhodes#ifdef LOG_NEWS 44135446Strhodes { LOG_NEWS, "news" }, 45135446Strhodes#endif 46135446Strhodes#ifdef LOG_UUCP 47135446Strhodes { LOG_UUCP, "uucp" }, 48135446Strhodes#endif 49135446Strhodes#ifdef LOG_CRON 50135446Strhodes { LOG_CRON, "cron" }, 51135446Strhodes#endif 52135446Strhodes#ifdef LOG_AUTHPRIV 53135446Strhodes { LOG_AUTHPRIV, "authpriv" }, 54135446Strhodes#endif 55135446Strhodes#ifdef LOG_FTP 56135446Strhodes { LOG_FTP, "ftp" }, 57135446Strhodes#endif 58135446Strhodes { LOG_LOCAL0, "local0"}, 59135446Strhodes { LOG_LOCAL1, "local1"}, 60135446Strhodes { LOG_LOCAL2, "local2"}, 61135446Strhodes { LOG_LOCAL3, "local3"}, 62135446Strhodes { LOG_LOCAL4, "local4"}, 63135446Strhodes { LOG_LOCAL5, "local5"}, 64135446Strhodes { LOG_LOCAL6, "local6"}, 65135446Strhodes { LOG_LOCAL7, "local7"}, 66135446Strhodes { 0, NULL } 67135446Strhodes}; 68135446Strhodes 69135446Strhodesisc_result_t 70135446Strhodesisc_syslog_facilityfromstring(const char *str, int *facilityp) { 71135446Strhodes int i; 72135446Strhodes 73135446Strhodes REQUIRE(str != NULL); 74135446Strhodes REQUIRE(facilityp != NULL); 75135446Strhodes 76135446Strhodes for (i = 0; facilities[i].strval != NULL; i++) { 77135446Strhodes if (strcasecmp(facilities[i].strval, str) == 0) { 78135446Strhodes *facilityp = facilities[i].val; 79135446Strhodes return (ISC_R_SUCCESS); 80135446Strhodes } 81135446Strhodes } 82135446Strhodes return (ISC_R_NOTFOUND); 83135446Strhodes 84135446Strhodes} 85