OSSP CVS Repository

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

Check-in Number: 2920
Date: 2002-Nov-28 17:39:40 (local)
2002-Nov-28 16:39:40 (UTC)
User:mlelstv
Branch:
Comment: use new sio_input facility in sio_read

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

Tickets:
Inspections:
Files:
ossp-pkg/sio/sio.c      1.14 -> 1.15     12 inserted, 32 deleted

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

--- sio.c        2002/11/28 16:29:37     1.14
+++ sio.c        2002/11/28 16:39:40     1.15
@@ -96,7 +96,6 @@
     sio_labelnum_t              label_eof;
     int                         eof_flag;     /* accumulating flags        */
     int                         error_flag;
-    char                       *dst;       /* write pointer for sio_read   */
 };
 
 /*
@@ -659,32 +658,6 @@
 }
 
 /*
- * callback used by sio_read to scan through
- * reader assembly line
- *
- * data chunks are copied to the destination buffer
- * error chunks set the error flag
- * eof chunks set the eof flag
- */
-static al_rc_t sio_readchunk(al_chunk_t *alc, void *u)
-{
-    sio_t *sio = (sio_t *)u;
-    size_t len;
-
-    if (al_same_label(alc, SIO_LABEL_DATA(sio))) {
-        len = al_chunk_len(alc);
-        memcpy(sio->dst, al_chunk_ptr(alc,0), len);
-        sio->dst += len;
-    } else if (al_same_label(alc, SIO_LABEL_ERROR(sio))) {
-        sio->error_flag = 1;
-    } else if (al_same_label(alc, SIO_LABEL_EOF(sio))) {
-        sio->eof_flag = 1;
-    }
-
-    return AL_OK;
-}
-
-/*
  * retrieve data from the pipe into a buffer much like read()
  *
  * handles error and eof signals
@@ -702,11 +675,18 @@
     arc = al_create(&al);
     if (arc != AL_OK) return SIO_RC(SIO_ERR_INT);
 
-    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);
-        *actualp = sio->dst - dst;
+    rc = sio_input(sio, al, n, SIO_LABEL_DATA(sio));
+    if (rc == SIO_OK && al_bytes(al) > 0)
+        al_flatten(al, 0, n, AL_FORWARD, NULL, dst, actualp);
+    else {
+        rc = sio_input(sio, al, n, SIO_LABEL_ERROR(sio));
+        if (rc == SIO_OK && al_bytes(al) > 0)
+            sio->error_flag = 1;
+        else {
+            rc = sio_input(sio, al, n, SIO_LABEL_EOF(sio));
+            if (rc == SIO_OK && al_bytes(al) > 0)
+                sio->eof_flag = 1;
+        }
     }
 
     arc = al_destroy(al);

CVSTrac 2.0.1