X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=ustream.h;h=9a306180bc20f7ac87ee95b426fddbbba7f05055;hb=1db3e7df31d9f0ab24bcaa3fd17e81a9f3104615;hp=15f1ba10e8d7430271d071d9c3fa2f4e870f67ef;hpb=7a117988d9f75c7ccf7eeca7b59e61a4b5b5c3e4;p=oweals%2Flibubox.git diff --git a/ustream.h b/ustream.h index 15f1ba1..9a30618 100644 --- a/ustream.h +++ b/ustream.h @@ -143,10 +143,17 @@ void ustream_free(struct ustream *s); /* ustream_consume: remove data from the head of the read buffer */ void ustream_consume(struct ustream *s, int len); +/* + * ustream_read: read and consume data in read buffer into caller-specified + * area. Return length of data read. + */ +int ustream_read(struct ustream *s, char *buf, int buflen); /* ustream_write: add data to the write buffer */ int ustream_write(struct ustream *s, const char *buf, int len, bool more); -int ustream_printf(struct ustream *s, const char *format, ...); -int ustream_vprintf(struct ustream *s, const char *format, va_list arg); +int ustream_printf(struct ustream *s, const char *format, ...) + __attribute__ ((format (printf, 2, 3))); +int ustream_vprintf(struct ustream *s, const char *format, va_list arg) + __attribute__ ((format (printf, 2, 0))); /* ustream_get_read_buf: get a pointer to the next read buffer data */ char *ustream_get_read_buf(struct ustream *s, int *buflen); @@ -171,7 +178,9 @@ static inline int ustream_pending_data(struct ustream *s, bool write) static inline bool ustream_read_buf_full(struct ustream *s) { - return ustream_pending_data(s, false) == s->r.buffer_len; + struct ustream_buf *buf = s->r.data_tail; + return buf && buf->data == buf->head && buf->tail == buf->end && + s->r.buffers == s->r.max_buffers; } /*** --- functions only used by ustream implementations --- ***/