303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington/*
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 2001, 2004, 2005, 2007, 2016 Internet Systems Consortium, Inc. ("ISC")
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington *
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington */
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington
7de2c6e6d51f38daeb2d346f3f21dc01ccece6daEvan Hunt/* $Id: syslog.c,v 1.8 2007/09/13 04:45:18 each Exp $ */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/*! \file */
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#include <config.h>
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#include <stdlib.h>
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#include <syslog.h>
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#include <isc/result.h>
7de2c6e6d51f38daeb2d346f3f21dc01ccece6daEvan Hunt#include <isc/string.h>
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#include <isc/syslog.h>
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#include <isc/util.h>
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellingtonstatic struct dsn_c_pvt_sfnt {
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington int val;
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington const char *strval;
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington} facilities[] = {
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_KERN, "kern" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_USER, "user" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_MAIL, "mail" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_DAEMON, "daemon" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_AUTH, "auth" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_SYSLOG, "syslog" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_LPR, "lpr" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#ifdef LOG_NEWS
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_NEWS, "news" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#endif
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#ifdef LOG_UUCP
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_UUCP, "uucp" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#endif
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#ifdef LOG_CRON
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_CRON, "cron" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#endif
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#ifdef LOG_AUTHPRIV
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_AUTHPRIV, "authpriv" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#endif
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#ifdef LOG_FTP
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_FTP, "ftp" },
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington#endif
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_LOCAL0, "local0"},
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_LOCAL1, "local1"},
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_LOCAL2, "local2"},
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_LOCAL3, "local3"},
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_LOCAL4, "local4"},
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_LOCAL5, "local5"},
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_LOCAL6, "local6"},
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { LOG_LOCAL7, "local7"},
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington { 0, NULL }
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington};
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellingtonisc_result_t
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellingtonisc_syslog_facilityfromstring(const char *str, int *facilityp) {
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington int i;
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington REQUIRE(str != NULL);
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington REQUIRE(facilityp != NULL);
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington
f1b68725503ff3e46001eee5a1751e29a43a09d1Andreas Gustafsson for (i = 0; facilities[i].strval != NULL; i++) {
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington if (strcasecmp(facilities[i].strval, str) == 0) {
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington *facilityp = facilities[i].val;
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington return (ISC_R_SUCCESS);
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington }
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington }
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington return (ISC_R_NOTFOUND);
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington
303243b9d403fb2105dba02c8c9e236bf4cf0fc9Brian Wellington}