32 memset(buf, 0,
sizeof(*buf));
114 #define DEFAULT_SET(_f, _default) \
159 if (offset > maxlen / 2)
163 if (buf->
tail - buf->
data < 32 && offset > maxlen / 4)
171 return (buf->
end - buf->
tail < len);
221 s->r.data_bytes -= len;
222 if (s->r.data_bytes < 0)
227 int buf_len = buf->
tail - buf->
data;
279 if (l->
alloc(s, l) < 0)
296 buf = s->r.data_tail;
297 *maxlen = buf->
end - buf->
tail;
307 s->r.data_bytes += len;
320 s->r.data_tail = buf;
334 len = s->r.head->tail - s->r.head->data;
336 data = s->r.head->data;
355 if (chunk_len > buflen - len)
356 chunk_len = buflen - len;
357 memcpy(buf + len, chunk, chunk_len);
360 }
while (len < buflen);
465 #define MAX_STACK_BUFLEN 256
472 int wr, maxlen, buflen;
483 wr = s->
write(s, buf, maxlen,
false);
495 buf = malloc(maxlen + 1);
498 wr = vsnprintf(buf, maxlen + 1, format, arg);
512 maxlen = vsnprintf(buf, buflen, format, arg2);
524 buf = malloc(maxlen + 1);
527 maxlen = vsnprintf(buf, maxlen + 1, format, arg);
542 va_start(arg, format);
#define container_of(ptr, type, member)
int(* alloc)(struct ustream *s, struct ustream_buf_list *l)
struct ustream_buf * tail
struct ustream_buf * head
struct ustream_buf * data_tail
struct ustream_buf * next
struct ustream_buf_list r w
void(* notify_write)(struct ustream *s, int bytes)
int(* write)(struct ustream *s, const char *buf, int len, bool more)
void(* set_read_blocked)(struct ustream *s)
void(* notify_read)(struct ustream *s, int bytes_new)
void(* free)(struct ustream *s)
void(* notify_state)(struct ustream *s)
struct uloop_timeout state_change
enum read_blocked_reason read_blocked
int uloop_timeout_cancel(struct uloop_timeout *timeout)
static int ustream_alloc_default(struct ustream *s, struct ustream_buf_list *l)
static bool ustream_should_move(struct ustream_buf_list *l, struct ustream_buf *buf, int len)
static bool ustream_prepare_buf(struct ustream *s, struct ustream_buf_list *l, int len)
int ustream_write(struct ustream *s, const char *data, int len, bool more)
static void ustream_free_buffers(struct ustream_buf_list *l)
static void ustream_init_buf(struct ustream_buf *buf, int len)
static void ustream_fixup_string(struct ustream *s, struct ustream_buf *buf)
void ustream_init_defaults(struct ustream *s)
void ustream_free(struct ustream *s)
int ustream_printf(struct ustream *s, const char *format,...)
int ustream_vprintf(struct ustream *s, const char *format, va_list arg)
static void ustream_free_buf(struct ustream_buf_list *l, struct ustream_buf *buf)
static void ustream_add_buf(struct ustream_buf_list *l, struct ustream_buf *buf)
static void __ustream_set_read_blocked(struct ustream *s, unsigned char val)
void ustream_consume(struct ustream *s, int len)
bool ustream_write_pending(struct ustream *s)
#define DEFAULT_SET(_f, _default)
static void ustream_write_error(struct ustream *s)
static bool ustream_can_alloc(struct ustream_buf_list *l)
void ustream_fill_read(struct ustream *s, int len)
static void ustream_state_change_cb(struct uloop_timeout *t)
char * ustream_get_read_buf(struct ustream *s, int *buflen)
char * ustream_reserve(struct ustream *s, int len, int *maxlen)
void ustream_set_read_blocked(struct ustream *s, bool set)
int ustream_read(struct ustream *s, char *buf, int buflen)
static int ustream_write_buffered(struct ustream *s, const char *data, int len, int wr)
static void ustream_state_change(struct ustream *s)