diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-11-16 14:26:41 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-11-16 14:26:41 +0100 |
| commit | 7bfb16e0da721dcf50558f9104d3ed84efe03516 (patch) | |
| tree | b04570308ac12cb1c1831c54be027a3a5cfc4d57 /lib/utils_cmd.h | |
| parent | 2510d9ad5851c669ace7cfc16ea3ff9bf2c86106 (diff) | |
| download | monitoring-plugins-7bfb16e0da721dcf50558f9104d3ed84efe03516.tar.gz | |
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.
Diffstat (limited to 'lib/utils_cmd.h')
| -rw-r--r-- | lib/utils_cmd.h | 10 |
1 files changed, 9 insertions, 1 deletions
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 { | |||
| 13 | char *buf; /* output buffer */ | 13 | char *buf; /* output buffer */ |
| 14 | size_t buflen; /* output buffer content length */ | 14 | size_t buflen; /* output buffer content length */ |
| 15 | char **line; /* array of lines (points to buf) */ | 15 | char **line; /* array of lines (points to buf) */ |
| 16 | size_t *lens; /* string lengths */ | ||
| 17 | size_t lines; /* lines of output */ | 16 | size_t lines; /* lines of output */ |
| 18 | } output; | 17 | } output; |
| 19 | 18 | ||
| @@ -22,6 +21,15 @@ int cmd_run(const char *, output *, output *, int); | |||
| 22 | int cmd_run_array(char *const *, output *, output *, int); | 21 | int cmd_run_array(char *const *, output *, output *, int); |
| 23 | int cmd_file_read(const char *, output *, int); | 22 | int cmd_file_read(const char *, output *, int); |
| 24 | 23 | ||
| 24 | typedef struct { | ||
| 25 | int error_code; | ||
| 26 | int cmd_error_code; | ||
| 27 | output stdout; | ||
| 28 | output stderr; | ||
| 29 | } cmd_run_result; | ||
| 30 | cmd_run_result cmd_run2(const char *cmd, int flags); | ||
| 31 | cmd_run_result cmd_run_array2(char * const *cmd, int flags); | ||
| 32 | |||
| 25 | /* only multi-threaded plugins need to bother with this */ | 33 | /* only multi-threaded plugins need to bother with this */ |
| 26 | void cmd_init(void); | 34 | void cmd_init(void); |
| 27 | #define CMD_INIT cmd_init() | 35 | #define CMD_INIT cmd_init() |
