syslog.c revision f1b68725503ff3e46001eee5a1751e29a43a09d1
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews/*
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Copyright (C) 2001 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews *
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews * copyright notice and this permission notice appear in all copies.
12178c86525332bb0ab66155feb61fbf32eca6acEvan Hunt *
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
e13d04fda918c0c14c2247475bb99e0760d9a6a4Evan Hunt * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafsson * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews */
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki/* $Id: syslog.c,v 1.2 2001/11/27 00:56:20 gson Exp $ */
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki#include <config.h>
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews#include <stdlib.h>
0e40083fdd5445703bd30e46e5bfe7d047bced12Brian Wellington#include <string.h>
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#include <syslog.h>
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉#include <isc/result.h>
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews#include <isc/syslog.h>
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews#include <isc/util.h>
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellingtonstatic struct dsn_c_pvt_sfnt {
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews int val;
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews const char *strval;
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews} facilities[] = {
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 { LOG_KERN, "kern" },
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 { LOG_USER, "user" },
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews { LOG_MAIL, "mail" },
e99691e566c10f8901b3f66a6b6629705cf78c52Mark Andrews { LOG_DAEMON, "daemon" },
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews { LOG_AUTH, "auth" },
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews { LOG_SYSLOG, "syslog" },
f4cbe536b11da614fe05aeaeff41e324854cda7bMark Andrews { LOG_LPR, "lpr" },
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews#ifdef LOG_NEWS
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews { LOG_NEWS, "news" },
bb1cf189bb9fd9059cf13b785d15b0e50c0be8fbAndreas Gustafsson#endif
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews#ifdef LOG_UUCP
01b8865b1462ba219c90cf6c00f1bf0fdf780d9bBrian Wellington { LOG_UUCP, "uucp" },
01b8865b1462ba219c90cf6c00f1bf0fdf780d9bBrian Wellington#endif
c40265eba0c99708887d68e67901924065ba2514Brian Wellington#ifdef LOG_CRON
c40265eba0c99708887d68e67901924065ba2514Brian Wellington { LOG_CRON, "cron" },
c40265eba0c99708887d68e67901924065ba2514Brian Wellington#endif
c40265eba0c99708887d68e67901924065ba2514Brian Wellington#ifdef LOG_AUTHPRIV
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews { LOG_AUTHPRIV, "authpriv" },
9e77d51069a97a21c68184134a0c9847e95490ffMark Andrews#endif
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafsson#ifdef LOG_FTP
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews { LOG_FTP, "ftp" },
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews#endif
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafsson { LOG_LOCAL0, "local0"},
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafsson { LOG_LOCAL1, "local1"},
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafsson { LOG_LOCAL2, "local2"},
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews { LOG_LOCAL3, "local3"},
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews { LOG_LOCAL4, "local4"},
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafsson { LOG_LOCAL5, "local5"},
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafsson { LOG_LOCAL6, "local6"},
fcb54ce0a4f7377486df5bec83b3aa4711bf4131Mark Andrews { LOG_LOCAL7, "local7"},
0c2313eb367de3b58801d643d52c0fd9bc0e5df7Evan Hunt { 0, NULL }
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉};
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉isc_result_t
e99691e566c10f8901b3f66a6b6629705cf78c52Mark Andrewsisc_syslog_facilityfromstring(const char *str, int *facilityp) {
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt int i;
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt REQUIRE(str != NULL);
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 REQUIRE(facilityp != NULL);
bb01a40e659564bcb9571eca0319762eb20b7a01Andreas Gustafsson
c40265eba0c99708887d68e67901924065ba2514Brian Wellington for (i = 0; facilities[i].strval != NULL; i++) {
c40265eba0c99708887d68e67901924065ba2514Brian Wellington if (strcasecmp(facilities[i].strval, str) == 0) {
c40265eba0c99708887d68e67901924065ba2514Brian Wellington *facilityp = facilities[i].val;
c40265eba0c99708887d68e67901924065ba2514Brian Wellington return (ISC_R_SUCCESS);
bb01a40e659564bcb9571eca0319762eb20b7a01Andreas Gustafsson }
bb01a40e659564bcb9571eca0319762eb20b7a01Andreas Gustafsson }
4137fd1295f3c6242a1c641352c8811378912820Andreas Gustafsson return (ISC_R_NOTFOUND);
01b8865b1462ba219c90cf6c00f1bf0fdf780d9bBrian Wellington
bb01a40e659564bcb9571eca0319762eb20b7a01Andreas Gustafsson}
f4cbe536b11da614fe05aeaeff41e324854cda7bMark Andrews