--- l2_ch_syslog.c 2001/09/04 13:52:59 1.9
+++ l2_ch_syslog.c 2001/09/04 15:41:17 1.10
@@ -42,7 +42,7 @@
} l2_ch_syslog_t;
/* create channel */
-static int hook_create(l2_context_t *ctx)
+static int hook_create(l2_context_t *ctx, l2_channel_t *ch)
{
l2_ch_syslog_t *cfg;
@@ -64,7 +64,7 @@
}
/* configure channel */
-static int hook_configure(l2_context_t *ctx, const char *fmt, va_list ap)
+static int hook_configure(l2_context_t *ctx, l2_channel_t *ch, const char *fmt, va_list ap)
{
l2_ch_syslog_t *cfg;
l2_param_t pa[3];
@@ -87,9 +87,10 @@
}
/* open channel */
-static int hook_open(l2_context_t *ctx, l2_channel_t *downstream)
+static int hook_open(l2_context_t *ctx, l2_channel_t *ch)
{
l2_ch_syslog_t *cfg;
+ l2_channel_t *downstream;
/* parameter checks */
if ((cfg = (l2_ch_syslog_t *)ctx->vp) == NULL)
@@ -100,7 +101,7 @@
setlogmask(cfg->iMaskpri);
/* optionally open downstream channel, too */
- if (downstream != NULL)
+ if ((downstream = l2_channel_downstream(ch)) != NULL)
if (l2_channel_open(downstream) == L2_ERROR)
return L2_ERROR;
@@ -108,10 +109,11 @@
}
/* write to channel */
-static int hook_write(l2_context_t *ctx, l2_channel_t *downstream,
+static int hook_write(l2_context_t *ctx, l2_channel_t *ch,
const char *buf, size_t buf_size)
{
l2_ch_syslog_t *cfg;
+ l2_channel_t *downstream;
/* parameter checks */
if ((cfg = (l2_ch_syslog_t *)ctx->vp) == NULL)
@@ -121,7 +123,7 @@
syslog(cfg->iPriority, buf);
/* optionally write to downstream channel, too */
- if (downstream != NULL)
+ if ((downstream = l2_channel_downstream(ch)) != NULL)
if (l2_channel_write(downstream, buf, buf_size) == L2_ERROR)
return L2_ERROR;
@@ -129,12 +131,14 @@
}
/* flush channel */
-static int hook_flush(l2_context_t *ctx, l2_channel_t *downstream)
+static int hook_flush(l2_context_t *ctx, l2_channel_t *ch)
{
+ l2_channel_t *downstream;
+
/* Noop for this channel, because syslog entries are unbuffered */
/* optionally flush downstream channel, too */
- if (downstream != NULL)
+ if ((downstream = l2_channel_downstream(ch)) != NULL)
if (l2_channel_flush(downstream) == L2_ERROR)
return L2_ERROR;
@@ -142,12 +146,13 @@
}
/* close channel */
-static int hook_close(l2_context_t *ctx, l2_channel_t *downstream)
+static int hook_close(l2_context_t *ctx, l2_channel_t *ch)
{
l2_ch_syslog_t *cfg;
+ l2_channel_t *downstream;
/* optionally close downstream channel, too */
- if (downstream != NULL)
+ if ((downstream = l2_channel_downstream(ch)) != NULL)
if (l2_channel_close(downstream) == L2_ERROR)
return L2_ERROR;
@@ -162,7 +167,7 @@
}
/* destroy channel */
-static int hook_destroy(l2_context_t *ctx)
+static int hook_destroy(l2_context_t *ctx, l2_channel_t *ch)
{
/* parameter checks */
if (ctx->vp == NULL)
@@ -176,6 +181,7 @@
/* exported channel handler structure */
l2_handler_t l2_handler_syslog = {
+ L2_CHANNEL_OUTPUT,
hook_create,
hook_configure,
hook_open,
|