diff options
Diffstat (limited to 'osdep/subprocess.h')
-rw-r--r-- | osdep/subprocess.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/osdep/subprocess.h b/osdep/subprocess.h index 14d4896c58..4bf2dc32dd 100644 --- a/osdep/subprocess.h +++ b/osdep/subprocess.h @@ -22,9 +22,18 @@ #include <stddef.h> #include <stdint.h> +#include "misc/bstr.h" + struct mp_cancel; +// Incrementally called with data that was read. Buffer valid only during call. +// size==0 means EOF. typedef void (*subprocess_read_cb)(void *ctx, char *data, size_t size); +// Incrementally called to refill *mp_subprocess_fd.write_buf, whenever write_buf +// has length 0 and the pipe is writable. While writing, *write_buf is adjusted +// to contain only the not yet written data. +// Not filling the buffer means EOF. +typedef void (*subprocess_write_cb)(void *ctx); void mp_devnull(void *ctx, char *data, size_t size); @@ -37,6 +46,9 @@ struct mp_subprocess_fd { // Note: "neutral" initialization requires setting src_fd=-1. subprocess_read_cb on_read; // if not NULL, serve reads void *on_read_ctx; // for on_read(on_read_ctx, ...) + subprocess_write_cb on_write; // if not NULL, serve writes + void *on_write_ctx; // for on_write(on_write_ctx, ...) + bstr *write_buf; // must be !=NULL if on_write is set int src_fd; // if >=0, dup this FD to target FD }; |