Index: ossp-pkg/sio/sio.c RCS File: /v/ossp/cvs/ossp-pkg/sio/sio.c,v rcsdiff -q -kk '-r1.13' '-r1.14' -u '/v/ossp/cvs/ossp-pkg/sio/sio.c,v' 2>/dev/null --- 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); Index: ossp-pkg/sio/sio.h RCS File: /v/ossp/cvs/ossp-pkg/sio/sio.h,v rcsdiff -q -kk '-r1.7' '-r1.8' -u '/v/ossp/cvs/ossp-pkg/sio/sio.h,v' 2>/dev/null --- 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); Index: ossp-pkg/sio/sio.pod RCS File: /v/ossp/cvs/ossp-pkg/sio/sio.pod,v rcsdiff -q -kk '-r1.6' '-r1.7' -u '/v/ossp/cvs/ossp-pkg/sio/sio.pod,v' 2>/dev/null --- 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. The object is invalid after this call succeeded. -=item sio_rc_t B(sio_t *I, al_t *I, size_t limit); +=item sio_rc_t B(sio_t *I, al_t *I, size_t limit, al_label_t label); Pull data from stream object I, the data is appended to the assembly line I and will contain no more than I 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_t *I, al_t *I);