1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

common: Add a stream interface to 'sh-exectool'.

* common/sh-exectool.c (struct copy_buffer): Add infrastructure for
copying between streams.
(copy_buffer_{init,shred,do_copy,flush}): New functions.
(sh_exec_tool_stream): Rework 'sh_exec_tool' to operate on streams.
(nop_free): New function.
(sh_exec_tool): Express this in terms of 'sh_exec_tool_stream'.
* common/sh-exectool.h (sh_exec_tool_stream): New prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2015-11-30 14:23:02 +01:00
parent d955cb5e07
commit a81aca6e1c
2 changed files with 218 additions and 87 deletions

View file

@ -20,6 +20,8 @@
#ifndef GNUPG_COMMON_SH_EXECTOOL_H
#define GNUPG_COMMON_SH_EXECTOOL_H
#include <gpg-error.h>
/* Run the program PGMNAME with the command line arguments given in
the NULL terminates array ARGV. If INPUT_STRING is not NULL it
will be fed to stdin of the process. stderr is logged using
@ -32,4 +34,13 @@ gpg_error_t sh_exec_tool (const char *pgmname, const char *argv[],
const char *input_string,
char **result, size_t *resultlen);
/* Run the program PGMNAME with the command line arguments given in
the NULL terminates array ARGV. If INPUT is not NULL it will be
fed to stdin of the process. stderr is logged using log_info and
the process' stdout is written to OUTPUT. On error a diagnostic is
printed, and an error code returned. */
gpg_error_t sh_exec_tool_stream (const char *pgmname, const char *argv[],
estream_t input,
estream_t output);
#endif /* GNUPG_COMMON_SH_EXECTOOL_H */