OSSP CVS Repository

ossp - Difference in ossp-pkg/sio/sio_sio.c versions 1.1 and 1.2
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/sio/sio_sio.c 1.1 -> 1.2

--- sio_sio.c    2002/11/28 17:45:15     1.1
+++ sio_sio.c    2002/11/29 13:00:19     1.2
@@ -8,7 +8,9 @@
 
 typedef struct {
     sio_t      *upstream;
-    al_label_t  label;
+    al_label_t  my_data_label;
+    al_label_t  my_eof_label;
+    al_label_t  my_error_label;
     al_label_t  data_label;
     al_label_t  eof_label;
     al_label_t  error_label;
@@ -29,9 +31,11 @@
     if (my == NULL)
         return SIO_ERR_MEM;
 
-    my->upstream = NULL;
-    my->label    = NULL;
-    my->eof      = '\0';
+    my->upstream         = NULL;
+    my->my_data_label    = NULL;
+    my->my_error_label   = NULL;
+    my->my_eof_label     = NULL;
+    my->eof              = '\0';
 
     sio_label(sio, SIO_LN_DATA,  &my->data_label);
     sio_label(sio, SIO_LN_ERROR, &my->error_label);
@@ -55,8 +59,12 @@
 
     if (!strcmp(name, "upstream")) {
         my->upstream = (sio_t *)val;
-    } else if (!strcmp(name, "label")) {
-        my->label = (al_label_t)val;
+    } else if (!strcmp(name, "mydatalabel")) {
+        my->my_data_label = (al_label_t)val;
+    } else if (!strcmp(name, "myerrorlabel")) {
+        my->my_error_label = (al_label_t)val;
+    } else if (!strcmp(name, "myeoflabel")) {
+        my->my_eof_label = (al_label_t)val;
     } else {
         return SIO_ERR_ARG;
     }
@@ -82,8 +90,7 @@
 {
     private_t *my = (private_t *)u;
 
-    if (my->upstream == NULL ||
-        my->label    == NULL)
+    if (my->upstream == NULL)
         return SIO_ERR_ARG;
 
     return SIO_OK;
@@ -100,8 +107,7 @@
 {
     private_t *my = (private_t *)u;
 
-    if (my->upstream == NULL ||
-        my->label    == NULL)
+    if (my->upstream == NULL)
         return SIO_ERR_ARG;
 
     return SIO_OK;
@@ -114,32 +120,54 @@
 }
 
 static
-sio_rc_t siosio_input(sio_t *sio, al_t *al, void *u)
+sio_rc_t siosio_input(sio_t *sio, al_t *al, void *u, sio_rc_t orc)
 {
     private_t *my = (private_t *)u;
 
     if (al_bytes(al) == 0) {
-        sio_input(my->upstream, al, SIZE_T_MAX, my->label);
-        if (al_bytes(al) > 0) {
-            if (my->label != my->data_label)
-                al_setlabel(al, 0, al_bytes(al), my->label, my->data_label);
-        } else
-            al_append_bytes(al, &my->eof, sizeof(my->eof), my->eof_label);
+        if (my->my_data_label != NULL) {
+            sio_input(my->upstream, al, SIZE_T_MAX, my->my_data_label);
+            if (my->my_data_label != my->data_label)
+                al_setlabel(al, 0, al_bytes(al),
+                            my->my_data_label, my->data_label);
+        }
+
+        if (my->my_error_label != NULL) {
+            sio_input(my->upstream, al, SIZE_T_MAX, my->my_error_label);
+            if (my->my_error_label != my->error_label)
+                al_setlabel(al, 0, al_bytes(al),
+                            my->my_error_label, my->error_label);
+        }
+
+        if (my->my_eof_label != NULL) {
+            sio_input(my->upstream, al, SIZE_T_MAX, my->my_eof_label);
+            if (my->my_eof_label != my->eof_label)
+                al_setlabel(al, 0, al_bytes(al),
+                            my->my_eof_label, my->eof_label);
+        }
     }
 
     return SIO_SCHED_DOWN;
 }
 
 static
-sio_rc_t siosio_output(sio_t *sio, al_t *al, void *u)
+sio_rc_t siosio_output(sio_t *sio, al_t *al, void *u, sio_rc_t orc)
 {
     private_t *my = (private_t *)u;
 
     if (al_bytes(al) > 0) {
-        /* recolor data */
-        if (my->label != my->data_label)
-            al_setlabel(al, 0, al_bytes(al), my->data_label, my->label);
-        /* send out */
+        if (my->my_data_label != NULL && my->my_data_label != my->data_label)
+            al_setlabel(al, 0, al_bytes(al),
+                        my->data_label, my->my_data_label);
+
+        if (my->my_error_label != NULL && my->my_error_label != my->error_label)
+            al_setlabel(al, 0, al_bytes(al),
+                        my->error_label, my->my_error_label);
+
+        if (my->my_eof_label != NULL && my->my_eof_label != my->eof_label)
+            al_setlabel(al, 0, al_bytes(al),
+                        my->eof_label, my->my_eof_label);
+
         /* XXX error handling ? */
         sio_output(my->upstream, al);
     }

CVSTrac 2.0.1