[Xorp-cvs] SF.net SVN: xorp:[11537] trunk/xorp/libxorp/xlog.c
bms_fbsd at users.sourceforge.net
bms_fbsd at users.sourceforge.net
Wed Sep 2 17:59:36 PDT 2009
Revision: 11537
http://xorp.svn.sourceforge.net/xorp/?rev=11537&view=rev
Author: bms_fbsd
Date: 2009-09-03 00:59:35 +0000 (Thu, 03 Sep 2009)
Log Message:
-----------
In callback handler for XLOG syslog output, pass facility to syslog().
To facilitate this, cast facility using C99 types (intptr_t) before
adding the xlog callback. In callback, cast back using C99 integer types.
Use a int8_t for the array index in xlog_parse_syslog_spec(), this
should optimize to an index register on x86.
Bugzilla URL: http://bugzilla.xorp.net/show_bug.cgi?id=1084
Reported by: Jose Calhariz
Modified Paths:
--------------
trunk/xorp/libxorp/xlog.c
Modified: trunk/xorp/libxorp/xlog.c
===================================================================
--- trunk/xorp/libxorp/xlog.c 2009-09-02 22:29:14 UTC (rev 11536)
+++ trunk/xorp/libxorp/xlog.c 2009-09-03 00:59:35 UTC (rev 11537)
@@ -1283,7 +1283,7 @@
#if defined(HAVE_SYSLOG_H) && defined(HAVE_SYSLOG)
typedef struct _code {
const char *c_name;
- int c_val;
+ int32_t c_val;
} SYSLOG_CODE;
static SYSLOG_CODE prioritynames[] = {
@@ -1319,7 +1319,7 @@
{ NULL, -1, }
};
-static int
+static int32_t
xlog_level_to_syslog_priority(xlog_level_t xloglevel)
{
@@ -1349,12 +1349,12 @@
static int
xlog_syslog_output_func(void *obj, xlog_level_t level, const char *msg)
{
- int priority = xlog_level_to_syslog_priority(level);
+ int32_t facility = (intptr_t)obj;
+ int32_t priority = xlog_level_to_syslog_priority(level);
- syslog(priority, "%s", msg);
+ syslog(facility|priority, "%s", msg);
return (0);
- UNUSED(obj);
}
/*
@@ -1363,7 +1363,9 @@
static int
xlog_parse_syslog_spec(const char *syslogspec, int *facility, int *priority)
{
- int i, retval, xfacility, xpriority;
+ int retval;
+ int8_t i;
+ int32_t xfacility, xpriority;
char *facname, *priname, *tmpspec;
SYSLOG_CODE* sc;
@@ -1415,14 +1417,14 @@
int
xlog_add_syslog_output(const char *syslogspec)
{
- int facility = -1;
- int priority = -1;
+ int32_t facility = -1;
+ int32_t priority = -1;
if (-1 == xlog_parse_syslog_spec(syslogspec, &facility, &priority))
return (-1);
openlog("xorp", LOG_PID | LOG_NDELAY | LOG_CONS, facility);
- xlog_add_output_func(xlog_syslog_output_func, NULL);
+ xlog_add_output_func(xlog_syslog_output_func, (void *)(intptr_t)facility);
return (0);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Xorp-cvs
mailing list