#include <stdarg.h>
#include "uloop.h"
Go to the source code of this file.
|
void | ustream_fd_init (struct ustream_fd *s, int fd) |
|
void | ustream_free (struct ustream *s) |
|
void | ustream_consume (struct ustream *s, int len) |
|
int | ustream_read (struct ustream *s, char *buf, int buflen) |
|
int | ustream_write (struct ustream *s, const char *buf, int len, bool more) |
|
int | ustream_printf (struct ustream *s, const char *format,...) __attribute__((format(printf |
|
int int | ustream_vprintf (struct ustream *s, const char *format, va_list arg) __attribute__((format(printf |
|
int int char * | ustream_get_read_buf (struct ustream *s, int *buflen) |
|
void | ustream_set_read_blocked (struct ustream *s, bool set) |
|
static bool | ustream_read_blocked (struct ustream *s) |
|
static int | ustream_pending_data (struct ustream *s, bool write) |
|
static bool | ustream_read_buf_full (struct ustream *s) |
|
void | ustream_init_defaults (struct ustream *s) |
|
char * | ustream_reserve (struct ustream *s, int len, int *maxlen) |
|
void | ustream_fill_read (struct ustream *s, int len) |
|
bool | ustream_write_pending (struct ustream *s) |
|
static void | ustream_state_change (struct ustream *s) |
|
static bool | ustream_poll (struct ustream *s) |
|
◆ read_blocked_reason
Enumerator |
---|
READ_BLOCKED_USER | |
READ_BLOCKED_FULL | |
Definition at line 28 of file ustream.h.
◆ ustream_consume()
void ustream_consume |
( |
struct ustream * |
s, |
|
|
int |
len |
|
) |
| |
Definition at line 214 of file ustream.c.
221 s->r.data_bytes -= len;
222 if (s->r.data_bytes < 0)
227 int buf_len = buf->
tail - buf->
data;
struct ustream_buf * next
enum read_blocked_reason read_blocked
static void ustream_free_buf(struct ustream_buf_list *l, struct ustream_buf *buf)
static void __ustream_set_read_blocked(struct ustream *s, unsigned char val)
◆ ustream_fd_init()
void ustream_fd_init |
( |
struct ustream_fd * |
s, |
|
|
int |
fd |
|
) |
| |
Definition at line 160 of file ustream-fd.c.
int(* write)(struct ustream *s, const char *buf, int len, bool more)
void(* set_read_blocked)(struct ustream *s)
void(* free)(struct ustream *s)
bool(* poll)(struct ustream *s)
static void ustream_fd_set_uloop(struct ustream *s, bool write)
static int ustream_fd_write(struct ustream *s, const char *buf, int buflen, bool more)
static bool ustream_fd_poll(struct ustream *s)
static void ustream_fd_free(struct ustream *s)
static void ustream_fd_set_read_blocked(struct ustream *s)
static void ustream_uloop_cb(struct uloop_fd *fd, unsigned int events)
void ustream_init_defaults(struct ustream *s)
◆ ustream_fill_read()
void ustream_fill_read |
( |
struct ustream * |
s, |
|
|
int |
len |
|
) |
| |
Definition at line 301 of file ustream.c.
307 s->r.data_bytes += len;
320 s->r.data_tail = buf;
void(* notify_read)(struct ustream *s, int bytes_new)
static void ustream_fixup_string(struct ustream *s, struct ustream_buf *buf)
◆ ustream_free()
void ustream_free |
( |
struct ustream * |
s | ) |
|
Definition at line 92 of file ustream.c.
struct ustream_buf_list r w
struct uloop_timeout state_change
int uloop_timeout_cancel(struct uloop_timeout *timeout)
static void ustream_free_buffers(struct ustream_buf_list *l)
◆ ustream_get_read_buf()
int int char* ustream_get_read_buf |
( |
struct ustream * |
s, |
|
|
int * |
buflen |
|
) |
| |
Definition at line 328 of file ustream.c.
334 len = s->r.head->tail - s->r.head->data;
336 data = s->r.head->data;
◆ ustream_init_defaults()
void ustream_init_defaults |
( |
struct ustream * |
s | ) |
|
Definition at line 112 of file ustream.c.
114 #define DEFAULT_SET(_f, _default) \
int(* alloc)(struct ustream *s, struct ustream_buf_list *l)
static int ustream_alloc_default(struct ustream *s, struct ustream_buf_list *l)
#define DEFAULT_SET(_f, _default)
static void ustream_state_change_cb(struct uloop_timeout *t)
◆ ustream_pending_data()
static int ustream_pending_data |
( |
struct ustream * |
s, |
|
|
bool |
write |
|
) |
| |
|
inlinestatic |
Definition at line 173 of file ustream.h.
176 return b->data_bytes;
◆ ustream_poll()
static bool ustream_poll |
( |
struct ustream * |
s | ) |
|
|
inlinestatic |
◆ ustream_printf()
int ustream_printf |
( |
struct ustream * |
s, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
◆ ustream_read()
int ustream_read |
( |
struct ustream * |
s, |
|
|
char * |
buf, |
|
|
int |
buflen |
|
) |
| |
Definition at line 345 of file ustream.c.
355 if (chunk_len > buflen - len)
356 chunk_len = buflen - len;
357 memcpy(buf + len, chunk, chunk_len);
360 }
while (len < buflen);
void ustream_consume(struct ustream *s, int len)
char * ustream_get_read_buf(struct ustream *s, int *buflen)
◆ ustream_read_blocked()
static bool ustream_read_blocked |
( |
struct ustream * |
s | ) |
|
|
inlinestatic |
◆ ustream_read_buf_full()
static bool ustream_read_buf_full |
( |
struct ustream * |
s | ) |
|
|
inlinestatic |
Definition at line 179 of file ustream.h.
183 s->r.buffers == s->r.max_buffers;
◆ ustream_reserve()
char* ustream_reserve |
( |
struct ustream * |
s, |
|
|
int |
len, |
|
|
int * |
maxlen |
|
) |
| |
Definition at line 286 of file ustream.c.
296 buf = s->r.data_tail;
297 *maxlen = buf->
end - buf->
tail;
static bool ustream_prepare_buf(struct ustream *s, struct ustream_buf_list *l, int len)
◆ ustream_set_read_blocked()
void ustream_set_read_blocked |
( |
struct ustream * |
s, |
|
|
bool |
set |
|
) |
| |
◆ ustream_state_change()
static void ustream_state_change |
( |
struct ustream * |
s | ) |
|
|
inlinestatic |
Definition at line 208 of file ustream.h.
int uloop_timeout_set(struct uloop_timeout *timeout, int msecs)
◆ ustream_vprintf()
int int ustream_vprintf |
( |
struct ustream * |
s, |
|
|
const char * |
format, |
|
|
va_list |
arg |
|
) |
| |
◆ ustream_write()
int ustream_write |
( |
struct ustream * |
s, |
|
|
const char * |
buf, |
|
|
int |
len, |
|
|
bool |
more |
|
) |
| |
Definition at line 440 of file ustream.c.
static void ustream_write_error(struct ustream *s)
static int ustream_write_buffered(struct ustream *s, const char *data, int len, int wr)
◆ ustream_write_pending()
bool ustream_write_pending |
( |
struct ustream * |
s | ) |
|
Definition at line 372 of file ustream.c.
struct ustream_buf * head
void(* notify_write)(struct ustream *s, int bytes)
static void ustream_state_change(struct ustream *s)