OSSP CVS Repository

ossp - Difference in ossp-pkg/l2/l2_ch_file.c versions 1.15 and 1.16
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/l2/l2_ch_file.c 1.15 -> 1.16

--- l2_ch_file.c 2001/09/06 14:43:25     1.15
+++ l2_ch_file.c 2001/09/06 16:10:05     1.16
@@ -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_file_t *cfg;
+    l2_ch_file_t *cfg = (l2_ch_file_t *)ctx->vp;
     l2_param_t pa[4]; 
     l2_result_t rv;
 
-    /* parameter checks */
-    if ((cfg = (l2_ch_file_t *)ctx->vp) == NULL)
-        return L2_ERR_ARG;
-
     /* feed and call generic parameter parsing engine */
     L2_PARAM_SET(pa[0], path,   CHARPTR, &cfg->path);
     L2_PARAM_SET(pa[1], append, INT,     &cfg->append);
@@ -86,12 +82,10 @@
 /* open channel */
 static l2_result_t hook_open(l2_context_t *ctx, l2_channel_t *ch)
 {
-    l2_ch_file_t *cfg;
+    l2_ch_file_t *cfg = (l2_ch_file_t *)ctx->vp;
     int mode;
 
-    /* parameter checks */
-    if ((cfg = (l2_ch_file_t *)ctx->vp) == NULL)
-        return L2_ERR_ARG;
+    /* make sure a path was set */
     if (cfg->path == NULL)
         return L2_ERR_USE;
 
@@ -109,14 +103,8 @@
 static l2_result_t hook_write(l2_context_t *ctx, l2_channel_t *ch, 
                       const char *buf, size_t buf_size)
 {
-    l2_ch_file_t *cfg;
-
-    /* parameter checks */
-    if ((cfg = (l2_ch_file_t *)ctx->vp) == NULL)
-        return L2_ERR_ARG;
-    if (cfg->fd == -1)
-        return L2_ERR_USE;
-
+    l2_ch_file_t *cfg = (l2_ch_file_t *)ctx->vp;
+    
     /* write message to channel file */
     if (write(cfg->fd, buf, buf_size) == -1)
         return L2_ERR_SYS;
@@ -127,13 +115,7 @@
 /* close channel */
 static l2_result_t hook_close(l2_context_t *ctx, l2_channel_t *ch)
 {
-    l2_ch_file_t *cfg;
-
-    /* parameter checks */
-    if ((cfg = (l2_ch_file_t *)ctx->vp) == NULL)
-        return L2_ERR_ARG;
-    if (cfg->fd == -1)
-        return L2_ERR_USE;
+    l2_ch_file_t *cfg = (l2_ch_file_t *)ctx->vp;
 
     /* close channel file */
     close(cfg->fd);
@@ -145,12 +127,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_file_t *cfg = (l2_ch_file_t *)ctx->vp;
 
     /* destroy channel configuration */
-    free(ctx->vp);
+    free(cfg);
 
     return L2_OK;
 }

CVSTrac 2.0.1