Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2015-01-21 16:21:25 +0300
committerFelix Fietkau <nbd@openwrt.org>2015-01-21 22:00:39 +0300
commit60236c485387d33e1d02398a953a0834ad125161 (patch)
treeca3c355aad62de5fc0041dcb4a003924adf829cc /ustream.h
parentf1c794b29e2dac52ec25869bf8c37b3e230fb2a2 (diff)
ustream: add function ustream_read().
It can be used to fill caller-specified buffer with data already in ustream read buffer. Useful in the following use pattern. int available = ustream_pending_data(s, false); if (available >= sizeof(struct msghdr)) { struct msghdr h; ustream_read(s, &h, sizeof(h)); } Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Diffstat (limited to 'ustream.h')
-rw-r--r--ustream.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/ustream.h b/ustream.h
index 6431744..53e0828 100644
--- a/ustream.h
+++ b/ustream.h
@@ -143,6 +143,11 @@ 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, ...);