--- l2_ch_buffer.c 2001/09/04 14:54:03 1.11
+++ l2_ch_buffer.c 2001/09/04 15:41:17 1.12
@@ -40,7 +40,7 @@
} l2_ch_buffer_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_buffer_t *cfg;
@@ -60,7 +60,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_buffer_t *cfg;
l2_param_t pa[2];
@@ -80,9 +80,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_buffer_t *cfg;
+ l2_channel_t *downstream;
/* parameter checks */
if ((cfg = (l2_ch_buffer_t *)ctx->vp) == NULL)
@@ -96,7 +97,7 @@
}
/* 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;
@@ -104,7 +105,7 @@
}
/* 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 bufsize)
{
l2_ch_buffer_t *cfg;
@@ -123,9 +124,10 @@
}
/* 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_ch_buffer_t *cfg;
+ l2_channel_t *downstream;
/* parameter checks */
if ((cfg = (l2_ch_buffer_t *)ctx->vp) == NULL)
@@ -133,14 +135,14 @@
/* write the buffer contents downstream */
if (cfg->bufpos > 0) {
- if (downstream != NULL)
+ if ((downstream = l2_channel_downstream(ch)) != NULL)
if (l2_channel_write(downstream, cfg->buf, cfg->bufpos) == L2_ERROR)
return L2_ERROR;
cfg->bufpos = 0;
}
/* 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;
@@ -148,9 +150,10 @@
}
/* 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_buffer_t *cfg;
+ l2_channel_t *downstream;
/* parameter checks */
if ((cfg = (l2_ch_buffer_t *)ctx->vp) == NULL)
@@ -158,14 +161,14 @@
/* write stale data before closing down */
if (cfg->bufpos > 0) {
- if (downstream != NULL)
+ if ((downstream = l2_channel_downstream(ch)) != NULL)
if (l2_channel_write(downstream, cfg->buf, cfg->bufpos) == L2_ERROR)
return L2_ERROR;
cfg->bufpos = 0;
}
/* 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;
@@ -179,7 +182,7 @@
}
/* destroy channel */
-static int hook_destroy(l2_context_t *ctx)
+static int hook_destroy(l2_context_t *ctx, l2_channel_t *ch)
{
l2_ch_buffer_t *cfg;
@@ -201,6 +204,7 @@
/* exported channel handler structure */
l2_handler_t l2_handler_buffer = {
+ L2_CHANNEL_FILTER,
hook_create,
hook_configure,
hook_open,
|