All pastes #1474775 Raw Edit

clueless

public text v1 · immutable
#1474775 ·published 2009-06-25 22:18 UTC
rendered paste body
Index: main/syslog.c===================================================================--- main/syslog.c	(revision 0)+++ main/syslog.c	(revision 0)@@ -0,0 +1,100 @@+/*+ * Asterisk -- An open source telephony toolkit.+ *+ * Copyright (C) 2009, malleable, LLC.+ *+ * Sean Bright <sean@malleable.com>+ *+ * See http://www.asterisk.org for more information about+ * the Asterisk project. Please do not directly contact+ * any of the maintainers of this project for assistance;+ * the project provides a web site, mailing lists and IRC+ * channels for your use.+ *+ * This program is free software, distributed under the terms of+ * the GNU General Public License Version 2. See the LICENSE file+ * at the top of the source tree.+ */++/*! \file+ *+ * \brief Asterisk Syslog Utility Functions+ * \author Sean Bright <sean@malleable.com>+ */++/*+ * Define _ASTERISK_LOGGER_H to prevent the inclusion of logger.h;+ * it redefines the LOG_* constants.+ */+#define _ASTERISK_LOGGER_H+#include "asterisk.h"++ASTERISK_FILE_VERSION(__FILE__, "$Revision:$")++#include <syslog.h>++int ast_map_syslog_facility(const char *facility)+{+	if (!strcasecmp(facility, "KERN")) {+		return LOG_KERN;+	} else if (!strcasecmp(facility, "USER")) {+		return LOG_USER;+	} else if (!strcasecmp(facility, "MAIL")) {+		return LOG_MAIL;+	} else if (!strcasecmp(facility, "DAEMON")) {+		return LOG_DAEMON;+	} else if (!strcasecmp(facility, "AUTH")) {+		return LOG_AUTH;+	} else if (!strcasecmp(facility, "SYSLOG")) {+		return LOG_SYSLOG;+	} else if (!strcasecmp(facility, "LPR")) {+		return LOG_LPR;+	} else if (!strcasecmp(facility, "NEWS")) {+		return LOG_NEWS;+	} else if (!strcasecmp(facility, "UUCP")) {+		return LOG_UUCP;+	} else if (!strcasecmp(facility, "CRON")) {+		return LOG_CRON;+	} else if (!strcasecmp(facility, "LOCAL0")) {+		return LOG_LOCAL0;+	} else if (!strcasecmp(facility, "LOCAL1")) {+		return LOG_LOCAL1;+	} else if (!strcasecmp(facility, "LOCAL2")) {+		return LOG_LOCAL2;+	} else if (!strcasecmp(facility, "LOCAL3")) {+		return LOG_LOCAL3;+	} else if (!strcasecmp(facility, "LOCAL4")) {+		return LOG_LOCAL4;+	} else if (!strcasecmp(facility, "LOCAL5")) {+		return LOG_LOCAL5;+	} else if (!strcasecmp(facility, "LOCAL6")) {+		return LOG_LOCAL6;+	} else if (!strcasecmp(facility, "LOCAL7")) {+		return LOG_LOCAL7;+	}++	return -1;+}++int ast_map_syslog_priority(const char *priority)+{+	if (!strcasecmp(priority, "ALERT")) {+		return LOG_ALERT;+	} else if (!strcasecmp(priority, "CRIT")) {+		return LOG_CRIT;+	} else if (!strcasecmp(priority, "DEBUG")) {+		return LOG_DEBUG;+	} else if (!strcasecmp(priority, "EMERG")) {+		return LOG_EMERG;+	} else if (!strcasecmp(priority, "ERR")) {+		return LOG_ERR;+	} else if (!strcasecmp(priority, "INFO")) {+		return LOG_INFO;+	} else if (!strcasecmp(priority, "NOTICE")) {+		return LOG_NOTICE;+	} else if (!strcasecmp(priority, "WARNING")) {+		return LOG_WARNING;+	}++	return -1;+}Index: main/logger.c===================================================================--- main/logger.c	(revision 203378)+++ main/logger.c	(working copy)@@ -50,8 +50,6 @@ #define MAX_BACKTRACE_FRAMES 20 #endif -#define SYSLOG_NAMES /* so we can map syslog facilities names to their numeric values,-		        from <syslog.h> which is included by logger.h */ #include <syslog.h>  static const int syslog_level_map[] = {@@ -256,9 +254,6 @@ { 	struct logchannel *chan; 	char *facility;-#ifndef SOLARIS-	CODE *cptr;-#endif  	if (ast_strlen_zero(channel) || !(chan = ast_calloc(1, sizeof(*chan) + strlen(components) + 1))) 		return NULL;@@ -278,59 +273,7 @@ 			facility = "local0"; 		} -#ifndef SOLARIS-		/*- 		* Walk through the list of facilitynames (defined in sys/syslog.h)-		* to see if we can find the one we have been given-		*/-		chan->facility = -1;- 		cptr = facilitynames;-		while (cptr->c_name) {-			if (!strcasecmp(facility, cptr->c_name)) {-		 		chan->facility = cptr->c_val;-				break;-			}-			cptr++;-		}-#else-		chan->facility = -1;-		if (!strcasecmp(facility, "kern")) -			chan->facility = LOG_KERN;-		else if (!strcasecmp(facility, "USER")) -			chan->facility = LOG_USER;-		else if (!strcasecmp(facility, "MAIL")) -			chan->facility = LOG_MAIL;-		else if (!strcasecmp(facility, "DAEMON")) -			chan->facility = LOG_DAEMON;-		else if (!strcasecmp(facility, "AUTH")) -			chan->facility = LOG_AUTH;-		else if (!strcasecmp(facility, "SYSLOG")) -			chan->facility = LOG_SYSLOG;-		else if (!strcasecmp(facility, "LPR")) -			chan->facility = LOG_LPR;-		else if (!strcasecmp(facility, "NEWS")) -			chan->facility = LOG_NEWS;-		else if (!strcasecmp(facility, "UUCP")) -			chan->facility = LOG_UUCP;-		else if (!strcasecmp(facility, "CRON")) -			chan->facility = LOG_CRON;-		else if (!strcasecmp(facility, "LOCAL0")) -			chan->facility = LOG_LOCAL0;-		else if (!strcasecmp(facility, "LOCAL1")) -			chan->facility = LOG_LOCAL1;-		else if (!strcasecmp(facility, "LOCAL2")) -			chan->facility = LOG_LOCAL2;-		else if (!strcasecmp(facility, "LOCAL3")) -			chan->facility = LOG_LOCAL3;-		else if (!strcasecmp(facility, "LOCAL4")) -			chan->facility = LOG_LOCAL4;-		else if (!strcasecmp(facility, "LOCAL5")) -			chan->facility = LOG_LOCAL5;-		else if (!strcasecmp(facility, "LOCAL6")) -			chan->facility = LOG_LOCAL6;-		else if (!strcasecmp(facility, "LOCAL7")) -			chan->facility = LOG_LOCAL7;-#endif /* Solaris */+		chan->facility = convert_facility_name_to_int(facility);  		if (0 > chan->facility) { 			fprintf(stderr, "Logger Warning: bad syslog facility in logger.conf\n");