OSSP CVS Repository

ossp - Check-in [2919]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2919
Date: 2002-Nov-28 17:29:37 (local)
2002-Nov-28 16:29:37 (UTC)
User:mlelstv
Branch:
Comment: changed sio_input API to support label filtering

PR: Submitted by: Reviewed by: Approved by: Obtained from:

Tickets:
Inspections:
Files:
ossp-pkg/sio/sio.c      1.13 -> 1.14     22 inserted, 8 deleted
ossp-pkg/sio/sio.h      1.7 -> 1.8     1 inserted, 1 deleted
ossp-pkg/sio/sio.pod      1.6 -> 1.7     4 inserted, 1 deleted

ossp-pkg/sio/sio.c 1.13 -> 1.14

--- sio.c        2002/11/24 19:36:48     1.13
+++ sio.c        2002/11/28 16:29:37     1.14
@@ -487,12 +487,10 @@
         sios->module->shutdown(sio, sios->userdata) == SIO_OK) {
 
         if (sios->rw == SIO_MODE_WRITE || sios->rw == SIO_MODE_READWRITE) {
-printf("final output\n");
             rc = sio_strategy(sio, HEAD(&sio->writers,hd));
             if (rc != SIO_OK) return SIO_RC(rc);
         }
         if (sios->rw == SIO_MODE_READ || sios->rw == SIO_MODE_READWRITE) {
-printf("final input\n");
             sio_strategy(sio, HEAD(&sio->readers,hd));
             if (rc != SIO_OK) return SIO_RC(rc);
         }
@@ -532,17 +530,21 @@
  *
  * if there is no data in the reader assembly line
  *  then schedule the input side of the pipe once
+ *  if this still doesn't retrieve data then raise
+ *  a SIO_ERR_EOF error.
  *
  * retrieve data from the reader assembly line up to
- * the specified byte limit
+ * the specified byte limit for the first span of
+ * the specified label or any data if label == NULL
  *
  */
-sio_rc_t sio_input(sio_t *sio, al_t *al, size_t limit)
+sio_rc_t sio_input(sio_t *sio, al_t *al, size_t limit, al_label_t label)
 {
     sio_rc_t rc;
     sio_halfduplex_t *h;
     al_t *src;
     size_t n;
+    size_t datastart, datasize;
 
     /* argument sanity check(s) */
     if (sio == NULL || al == NULL)
@@ -565,10 +567,22 @@
 
     }
 
-    if (n > limit)
-        n = limit;
+    if (label == NULL) {
+        datastart = 0;
+        datasize  = n;
+    } else if (al_spanlabel(src, 0, n, label, &datastart, &datasize) != AL_OK) {
+        datastart = 0;
+        datasize  = 0;
+    }
+
+    /*
+     * clamp to requested size
+     */
+    if (datasize > n)
+        datasize = n;
 
-    (void) al_splice(src, 0, n, NULL, al); /* XXX - error handling ? */
+    /* XXX - error handling ? */
+    (void) al_splice(src, datastart, datasize, NULL, al);
 
     return SIO_OK;
 }
@@ -688,7 +702,7 @@
     arc = al_create(&al);
     if (arc != AL_OK) return SIO_RC(SIO_ERR_INT);
 
-    rc = sio_input(sio, al, n);
+    rc = sio_input(sio, al, n, NULL);
     if (rc == SIO_OK) {
         sio->dst = dst;
         al_traverse_cb(al, 0, n, AL_FORWARD, NULL, sio_readchunk, (void*)sio);


ossp-pkg/sio/sio.h 1.7 -> 1.8

--- sio.h        2002/11/24 19:36:48     1.7
+++ sio.h        2002/11/28 16:29:37     1.8
@@ -77,7 +77,7 @@
 sio_rc_t    sio_attach         (sio_t  *sio, sio_stage_t *sios, sio_mode_t rw);
 sio_rc_t    sio_detach         (sio_t  *sio, sio_stage_t *sios);
 
-sio_rc_t    sio_input          (sio_t  *sio, al_t *al, size_t limit);
+sio_rc_t    sio_input          (sio_t  *sio, al_t *al, size_t limit, al_label_t label);
 sio_rc_t    sio_output         (sio_t  *sio, al_t *al);
 
 sio_rc_t    sio_read           (sio_t  *sio, char *dst, size_t n, size_t *actualp);


ossp-pkg/sio/sio.pod 1.6 -> 1.7

--- sio.pod      2002/11/24 19:47:08     1.6
+++ sio.pod      2002/11/28 16:29:37     1.7
@@ -192,10 +192,13 @@
 Destroy the stream object I<sio>. The object is invalid after this
 call succeeded.
 
-=item sio_rc_t B<sio_input>(sio_t *I<sio>, al_t *I<al>, size_t limit);
+=item sio_rc_t B<sio_input>(sio_t *I<sio>, al_t *I<al>, size_t limit, al_label_t label);
 
 Pull data from stream object I<sio>, the data is appended to the
 assembly line I<al> and will contain no more than I<limit> bytes.
+If label != NULL then only data that is tagged with this label
+will be pulled from the stream. However, finally all data must
+be pulled from the stream before new I/O operations are scheduled.
 
 =item sio_rc_t B<sio_output>(sio_t *I<sio>, al_t *I<al>);
 

CVSTrac 2.0.1