From 263b632288c0662ae4ef08925291f8d1a55c1311 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 2 Jan 2004 22:09:35 +0000 Subject: this stuff works great git-svn-id: file:///home/lennart/svn/public/ivam2/trunk@10 dbf6933d-3bce-0310-9bcc-ed052ba35b35 --- src/buffio.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'src/buffio.h') diff --git a/src/buffio.h b/src/buffio.h index e0a2d0a..a41ec76 100644 --- a/src/buffio.h +++ b/src/buffio.h @@ -4,6 +4,15 @@ #include #include +enum buffio_sched_cb { + BUFFIO_SCHED_CB_IDLE = 0, + BUFFIO_SCHED_CB_INPUT_READY = 1, + BUFFIO_SCHED_CB_OUTPUT_EMPTY = 2, + BUFFIO_SCHED_CB_EOF = 4, + BUFFIO_SCHED_CB_EPIPE = 8, + BUFFIO_SCHED_CB_ERROR = 16 +}; + struct buffio { int ifd; int ofd; @@ -18,9 +27,21 @@ struct buffio { void *user; - void (*eof_cb) (struct buffio *b, void *user); - void (*output_empty_cb) (struct buffio *b, void *user); - void (*input_ready_cb) (struct buffio *b, void *user); + int readable; + int writable; + + int (*input_ready_cb) (struct buffio *b, void *user); + int (*output_empty_cb) (struct buffio *b, void *user); + int (*eof_cb) (struct buffio *b, void *user); + int (*epipe_cb) (struct buffio *b, void *user); + int (*error_cb) (struct buffio *b, void *user); + + enum buffio_sched_cb sched_cb; + + uint32_t output_delay_usec; + uint32_t output_latency_usec; + int delaying; + struct timeval finish_tv, timeout_tv; }; struct buffio* buffio_new(int ifd, int ofd); @@ -29,11 +50,34 @@ void buffio_free(struct buffio *b); int buffio_write(struct buffio *b, const uint8_t *d, size_t l); int buffio_print(struct buffio *b, const char *s); -int buffio_command(struct buffio *b, const char *c); void buffio_flush_input(struct buffio *b); +void buffio_flush_output(struct buffio *b); + +int buffio_command(struct buffio *b, const char *c); int buffio_find_input(struct buffio *b, const char *c); char *buffio_read_line(struct buffio *b, char *c, size_t l); void buffio_dump(struct buffio *b); +void buffio_set_input_watermark(struct buffio *b, ssize_t w); +void buffio_set_output_watermark(struct buffio *b, ssize_t w); + +const uint8_t* buffio_read_ptr(struct buffio *b, size_t *l); +void buffio_read_ptr_inc(struct buffio *b, size_t l); + +uint8_t* buffio_write_ptr(struct buffio *b, size_t *l); +void buffio_write_ptr_inc(struct buffio *b, size_t l); + +void buffio_close_input_fd(struct buffio *b); +void buffio_close_output_fd(struct buffio *b); + +int buffio_output_is_empty(struct buffio *b); +void buffio_dump_lines(struct buffio *b); + +void buffio_set_fds(struct buffio *b, int ifd, int ofd); + +void buffio_set_delay_usec(struct buffio *b, unsigned long usec, unsigned long latency); + +int buffio_can_write(struct buffio *b, size_t l); + #endif -- cgit