From c56b57fc58c73e96def91f4904d5b6e7c50e3de9 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 22 May 2024 11:37:50 +0200 Subject: support piping a buffer to an external process Currently only Text objects can be piped to external commands. This is tedious if data not available in any file should be passed to an external process (e.g. building options and passing them to vis-menu). This adds the option to pass a buffer to _vis_pipe and provides wrapper functions for the original behavior and the new one. --- vis.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'vis.h') diff --git a/vis.h b/vis.h index eb8ec92..1a249ee 100644 --- a/vis.h +++ b/vis.h @@ -882,6 +882,20 @@ int vis_pipe(Vis*, File*, Filerange*, const char *argv[], */ int vis_pipe_collect(Vis*, File*, Filerange*, const char *argv[], char **out, char **err, bool fullscreen); +/** + * Pipe a buffer to an external process, return its exit status and capture + * everything that is written to stdout/stderr. + * @param argv Argument list, must be ``NULL`` terminated. + * @param out Data written to ``stdout``, will be ``NUL`` terminated. + * @param err Data written to ``stderr``, will be ``NUL`` terminated. + * @param fullscreen Whether the external process is a fullscreen program (e.g. curses based) + * @rst + * .. warning:: The pointers stored in ``out`` and ``err`` need to be `free(3)`-ed + * by the caller. + * @endrst + */ +int vis_pipe_buf_collect(Vis*, const char*, const char *argv[], char **out, char **err, bool fullscreen); + /** * @} * @defgroup vis_keys -- cgit v1.2.3