Lines Matching refs:wbuf

20 static int wbuf_flush(struct json_write_buf *wbuf, int full);
22 static int wbuf_init(struct json_write_buf *wbuf, BIO *bio, size_t alloc) in wbuf_init() argument
24 wbuf->buf = OPENSSL_malloc(alloc); in wbuf_init()
25 if (wbuf->buf == NULL) in wbuf_init()
28 wbuf->cur = 0; in wbuf_init()
29 wbuf->alloc = alloc; in wbuf_init()
30 wbuf->bio = bio; in wbuf_init()
34 static void wbuf_cleanup(struct json_write_buf *wbuf) in wbuf_cleanup() argument
36 OPENSSL_free(wbuf->buf); in wbuf_cleanup()
37 wbuf->buf = NULL; in wbuf_cleanup()
38 wbuf->alloc = 0; in wbuf_cleanup()
41 static void wbuf_set0_bio(struct json_write_buf *wbuf, BIO *bio) in wbuf_set0_bio() argument
43 wbuf->bio = bio; in wbuf_set0_bio()
47 static ossl_inline void wbuf_clean(struct json_write_buf *wbuf) in wbuf_clean() argument
49 wbuf->cur = 0; in wbuf_clean()
53 static ossl_inline size_t wbuf_avail(struct json_write_buf *wbuf) in wbuf_avail() argument
55 return wbuf->alloc - wbuf->cur; in wbuf_avail()
59 static ossl_inline int wbuf_write_char(struct json_write_buf *wbuf, char c) in wbuf_write_char() argument
61 if (wbuf_avail(wbuf) == 0) { in wbuf_write_char()
62 if (!wbuf_flush(wbuf, /*full=*/0)) in wbuf_write_char()
66 wbuf->buf[wbuf->cur++] = c; in wbuf_write_char()
73 static int wbuf_write_str(struct json_write_buf *wbuf, const char *s) in wbuf_write_str() argument
78 if (!wbuf_write_char(wbuf, c)) in wbuf_write_str()
85 static int wbuf_flush(struct json_write_buf *wbuf, int full) in wbuf_flush() argument
89 while (total_written < wbuf->cur) { in wbuf_flush()
90 if (!BIO_write_ex(wbuf->bio, in wbuf_flush()
91 wbuf->buf + total_written, in wbuf_flush()
92 wbuf->cur - total_written, in wbuf_flush()
94 memmove(wbuf->buf, in wbuf_flush()
95 wbuf->buf + total_written, in wbuf_flush()
96 wbuf->cur - total_written); in wbuf_flush()
97 wbuf->cur = 0; in wbuf_flush()
104 wbuf->cur = 0; in wbuf_flush()
107 (void)BIO_flush(wbuf->bio); /* best effort */ in wbuf_flush()
242 if (!wbuf_init(&json->wbuf, bio, 4096)) in ossl_json_init()
251 wbuf_cleanup(&json->wbuf); in ossl_json_cleanup()
269 wbuf_clean(&json->wbuf); in ossl_json_reset()
278 return wbuf_flush(&json->wbuf, /*full=*/1); in ossl_json_flush()
283 wbuf_set0_bio(&json->wbuf, bio); in ossl_json_set0_sink()
319 if (!wbuf_write_char(&json->wbuf, ch)) in json_write_char()
329 if (!wbuf_write_str(&json->wbuf, s)) in json_write_str()