| 1 | #ifndef _LIB_BUFIO_H |
| 2 | #define _LIB_BUFIO_H |
| 3 | |
| 4 | struct bufioops { |
| 5 | ssize_t (*read)(void *pdata, void *buf, size_t len); |
| 6 | ssize_t (*write)(void *pdata, const void *buf, size_t len); |
| 7 | int (*close)(void *pdata); |
| 8 | }; |
| 9 | |
| 10 | struct bufio { |
| 11 | struct charbuf rbuf, wbuf; |
| 12 | size_t rh, wh, bufhint; |
| 13 | int err, eof; |
| 14 | void *pdata; |
| 15 | struct bufioops *ops; |
| 16 | }; |
| 17 | |
| 18 | struct bufio *bioopen(void *pdata, struct bufioops *ops); |
| 19 | int bioclose(struct bufio *bio); |
| 20 | |
| 21 | size_t biordata(struct bufio *bio); |
| 22 | size_t biorspace(struct bufio *bio); |
| 23 | int bioeof(struct bufio *bio); |
| 24 | ssize_t biorensure(struct bufio *bio, size_t bytes); |
| 25 | ssize_t biofillsome(struct bufio *bio); |
| 26 | int biogetc(struct bufio *bio); |
| 27 | ssize_t bioreadsome(struct bufio *bio, void *buf, size_t len); |
| 28 | |
| 29 | size_t biowdata(struct bufio *bio); |
| 30 | size_t biowspace(struct bufio *bio); |
| 31 | int bioflush(struct bufio *bio); |
| 32 | int bioflushsome(struct bufio *bio); |
| 33 | ssize_t biowensure(struct bufio *bio, size_t bytes); |
| 34 | int bioputc(struct bufio *bio, int c); |
| 35 | ssize_t biowrite(struct bufio *bio, const void *data, size_t len); |
| 36 | ssize_t biowritesome(struct bufio *bio, const void *data, size_t len); |
| 37 | int bioprintf(struct bufio *bio, const char *format, ...); |
| 38 | ssize_t biocopysome(struct bufio *dst, struct bufio *src); |
| 39 | ssize_t biocopybuf(struct bufio *dst, struct bufio *src); |
| 40 | |
| 41 | #endif |