From 7bfb16e0da721dcf50558f9104d3ed84efe03516 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 16 Nov 2025 14:26:41 +0100 Subject: Implement replacement functions for executing commands This commit implements replacement functions for the previous exec functions. The replacements are implemented in a more "pure" style, the do no longer receive pointer arguments which they will write to, but create the pointers themselves and should therefore be easier to use, since it is more obvious what goes in and what comes out. Also a essentialy unused variable was removed with this. --- lib/utils_cmd.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/utils_cmd.h') diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h index 3672cdc9..d3a8f14f 100644 --- a/lib/utils_cmd.h +++ b/lib/utils_cmd.h @@ -13,7 +13,6 @@ typedef struct { char *buf; /* output buffer */ size_t buflen; /* output buffer content length */ char **line; /* array of lines (points to buf) */ - size_t *lens; /* string lengths */ size_t lines; /* lines of output */ } output; @@ -22,6 +21,15 @@ int cmd_run(const char *, output *, output *, int); int cmd_run_array(char *const *, output *, output *, int); int cmd_file_read(const char *, output *, int); +typedef struct { + int error_code; + int cmd_error_code; + output stdout; + output stderr; +} cmd_run_result; +cmd_run_result cmd_run2(const char *cmd, int flags); +cmd_run_result cmd_run_array2(char * const *cmd, int flags); + /* only multi-threaded plugins need to bother with this */ void cmd_init(void); #define CMD_INIT cmd_init() -- cgit v1.2.3-74-g34f1