--- l2_ch_syslog.c 2001/09/06 14:43:25 1.16
+++ l2_ch_syslog.c 2001/09/06 16:10:05 1.17
@@ -65,14 +65,10 @@
/* configure channel */
static l2_result_t hook_configure(l2_context_t *ctx, l2_channel_t *ch, const char *fmt, va_list ap)
{
- l2_ch_syslog_t *cfg;
+ l2_ch_syslog_t *cfg = (l2_ch_syslog_t *)ctx->vp;
l2_param_t pa[6];
l2_result_t rv;
- /* parameter checks */
- if ((cfg = (l2_ch_syslog_t *)ctx->vp) == NULL)
- return L2_ERR_ARG;
-
/* feed and call generic parameter parsing engine */
L2_PARAM_SET(pa[0], ident, CHARPTR, &cfg->pszIdent);
L2_PARAM_SET(pa[1], logopts, INT, &cfg->iLogopt);
@@ -88,11 +84,7 @@
/* open channel */
static l2_result_t hook_open(l2_context_t *ctx, l2_channel_t *ch)
{
- l2_ch_syslog_t *cfg;
-
- /* parameter checks */
- if ((cfg = (l2_ch_syslog_t *)ctx->vp) == NULL)
- return L2_ERR_ARG;
+ l2_ch_syslog_t *cfg = (l2_ch_syslog_t *)ctx->vp;
/* open channel syslog */
openlog(cfg->pszIdent, cfg->iLogopt, cfg->iFacility);
@@ -105,11 +97,7 @@
static l2_result_t hook_write(l2_context_t *ctx, l2_channel_t *ch,
const char *buf, size_t buf_size)
{
- l2_ch_syslog_t *cfg;
-
- /* parameter checks */
- if ((cfg = (l2_ch_syslog_t *)ctx->vp) == NULL)
- return L2_ERR_ARG;
+ l2_ch_syslog_t *cfg = (l2_ch_syslog_t *)ctx->vp;
/* write message to channel syslog */
syslog(cfg->iPriority, buf);
@@ -120,11 +108,7 @@
/* close channel */
static l2_result_t hook_close(l2_context_t *ctx, l2_channel_t *ch)
{
- l2_ch_syslog_t *cfg;
-
- /* parameter checks */
- if ((cfg = (l2_ch_syslog_t *)ctx->vp) == NULL)
- return L2_ERR_ARG;
+ l2_ch_syslog_t *cfg = (l2_ch_syslog_t *)ctx->vp;
/* close channel syslog */
closelog();
@@ -135,12 +119,10 @@
/* destroy channel */
static l2_result_t hook_destroy(l2_context_t *ctx, l2_channel_t *ch)
{
- /* parameter checks */
- if (ctx->vp == NULL)
- return L2_ERR_ARG;
+ l2_ch_syslog_t *cfg = (l2_ch_syslog_t *)ctx->vp;
/* destroy channel configuration */
- free(ctx->vp);
+ free(cfg);
return L2_OK;
}
|