5 static int oneread(op,fd,buf,len)
15 if (r == -1) if (errno == error_intr) continue;
20 static int getthis(s,buf,len)
30 if (q > 0) { r = len; s->p = q; } else s->p = 0;
31 byte_copy(buf,r,s->x + s->n);
42 if (s->p) return s->p;
44 r = oneread(s->op,s->fd,s->x,q);
49 if (q > 0) /* damn, gotta shift */ byte_copyr(s->x + q,r,s->x);
53 int substdio_bget(s,buf,len)
60 if (s->p > 0) return getthis(s,buf,len);
61 r = s->n; if (r <= len) return oneread(s->op,s->fd,buf,r);
62 r = substdio_feed(s); if (r <= 0) return r;
63 return getthis(s,buf,len);
66 int substdio_get(s,buf,len)
73 if (s->p > 0) return getthis(s,buf,len);
74 if (s->n <= len) return oneread(s->op,s->fd,buf,len);
75 r = substdio_feed(s); if (r <= 0) return r;
76 return getthis(s,buf,len);
79 char *substdio_peek(s)
85 void substdio_seek(s,len)