OSSP CVS Repository

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

ossp-pkg/l2/l2_channel.c 1.11 -> 1.12

--- l2_channel.c 2001/09/04 13:52:59     1.11
+++ l2_channel.c 2001/09/04 15:41:17     1.12
@@ -45,24 +45,13 @@
     ch->downstream = NULL;
     memset(&ch->context, 0, sizeof(l2_context_t));
     memcpy(&ch->handler, h, sizeof(l2_handler_t));
-    if (ch->handler.create(&ch->context) == L2_ERROR) {
+    if (ch->handler.create(&ch->context, ch) == L2_ERROR) {
         free(ch);
         return NULL;
     }
     return ch;
 }
 
-l2_result_t l2_channel_stack(l2_channel_t *ch, l2_channel_t *chTop)
-{
-    if (ch == NULL || chTop == NULL)
-        return L2_ERROR;
-    if (   ch->state    != L2_CHSTATE_CREATED
-        || chTop->state != L2_CHSTATE_CREATED)
-        return L2_ERROR;
-    chTop->downstream = ch;
-    return L2_OK;
-}
-
 l2_result_t l2_channel_configure(l2_channel_t *ch, const char *fmt, ...)
 {
     l2_result_t rv;
@@ -73,7 +62,7 @@
     if (ch->state != L2_CHSTATE_CREATED)
         return L2_ERROR;
     va_start(ap, fmt);
-    rv = ch->handler.configure(&ch->context, fmt, ap);
+    rv = ch->handler.configure(&ch->context, ch, fmt, ap);
     va_end(ap);
     return rv;
 }
@@ -90,7 +79,7 @@
         ch = ch->downstream;
     if (ch == NULL)
         return L2_ERROR;
-    rv = ch->handler.open(&ch->context, ch->downstream);
+    rv = ch->handler.open(&ch->context, ch);
     if (rv == L2_OK)
         ch->state = L2_CHSTATE_OPENED;
     return rv;
@@ -112,7 +101,7 @@
         ch = ch->downstream;
     if (ch == NULL)
         return L2_ERROR;
-    rv = ch->handler.write(&ch->context, ch->downstream, buf, bufsize);
+    rv = ch->handler.write(&ch->context, ch, buf, bufsize);
     return rv;
 }
 
@@ -128,7 +117,7 @@
         ch = ch->downstream;
     if (ch == NULL)
         return L2_ERROR;
-    rv = ch->handler.flush(&ch->context, ch->downstream);
+    rv = ch->handler.flush(&ch->context, ch);
     return rv;
 }
 
@@ -144,7 +133,7 @@
         ch = ch->downstream;
     if (ch == NULL)
         return L2_ERROR;
-    rv = ch->handler.close(&ch->context, ch->downstream);
+    rv = ch->handler.close(&ch->context, ch);
     if (rv == L2_OK)
         ch->state = L2_CHSTATE_CREATED;
     return rv;
@@ -162,10 +151,37 @@
     while (ch != NULL && ch->handler.destroy == NULL)
         ch = ch->downstream;
     if (ch != NULL)
-        rv = ch->handler.destroy(&ch->context);
+        rv = ch->handler.destroy(&ch->context, ch);
     else
         rv = L2_OK;
     free(ch);
     return rv;
 }
 
+l2_result_t l2_channel_stack(l2_channel_t *ch, l2_channel_t *chTop)
+{
+    if (ch == NULL || chTop == NULL)
+        return L2_ERROR;
+    if (   ch->state    != L2_CHSTATE_CREATED
+        || chTop->state != L2_CHSTATE_CREATED)
+        return L2_ERROR;
+    if (chTop->handler.type != L2_CHANNEL_FILTER)
+        return L2_ERROR;
+    chTop->downstream = ch;
+    return L2_OK;
+}
+
+l2_channel_t *l2_channel_downstream(l2_channel_t *ch)
+{
+    if (ch == NULL)
+        return NULL;
+    return ch->downstream;
+}
+
+l2_chtype_t l2_channel_type(l2_channel_t *ch)
+{
+    if (ch == NULL)
+        return NULL;
+    return ch->handler.type;
+}
+

CVSTrac 2.0.1