Actually implement flags for gpgme_op_spawn.
* src/spawn.c (gpgme_op_spawn_start, gpgme_op_spawn): Pass FLAGS dow to spawn_start and add FLAGS args along the call path. * src/engine-spawn.c (engspawn_start): Hack to automagically provide argv[0].
This commit is contained in:
parent
4f2d652e60
commit
d3bd8fff86
@ -5261,12 +5261,13 @@ with the GPGME API.
|
||||
|
||||
The function @code{gpgme_op_spawn} runs the program @var{file} with
|
||||
the arguments taken from the NULL terminated array @var{argv}. If no
|
||||
arguments are required @var{argv} may be given as @code{NULL} (in that
|
||||
case GPGME uses the basename of @var{file} for @code{argv[0]}). The
|
||||
file descriptors @code{stdin}, @code{stdout}, and @code{stderr} are
|
||||
connected to the data objects @var{datain}, @var{dataout}, and
|
||||
@var{dataerr}. If NULL is passed for one of these data objects the
|
||||
corresponding file descriptor is connected to @file{/dev/null}.
|
||||
arguments are required @var{argv} may be given as @code{NULL}. In the
|
||||
latter case or if @code{argv[0]} is the empty string, GPGME uses the
|
||||
basename of @var{file} for @code{argv[0]}. The file descriptors
|
||||
@code{stdin}, @code{stdout}, and @code{stderr} are connected to the
|
||||
data objects @var{datain}, @var{dataout}, and @var{dataerr}. If NULL
|
||||
is passed for one of these data objects the corresponding file
|
||||
descriptor is connected to @file{/dev/null}.
|
||||
|
||||
The value in @var{flags} is a bitwise-or combination of one or
|
||||
multiple of the following bit values:
|
||||
|
@ -130,7 +130,7 @@ struct engine_ops
|
||||
const char *file, const char *argv[],
|
||||
gpgme_data_t datain,
|
||||
gpgme_data_t dataout,
|
||||
gpgme_data_t dataerr);
|
||||
gpgme_data_t dataerr, unsigned int flags);
|
||||
|
||||
};
|
||||
|
||||
|
@ -231,6 +231,7 @@ engspawn_start (engine_spawn_t esp, const char *file, const char *argv[],
|
||||
struct spawn_fd_item_s *fd_list;
|
||||
pid_t pid;
|
||||
unsigned int spflags;
|
||||
const char *save_argv0 = NULL;
|
||||
|
||||
if (!esp || !file || !argv || !argv[0])
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
@ -264,8 +265,15 @@ engspawn_start (engine_spawn_t esp, const char *file, const char *argv[],
|
||||
fd_list[n].fd = -1;
|
||||
fd_list[n].dup_to = -1;
|
||||
|
||||
if (argv[0] && !*argv[0])
|
||||
{
|
||||
save_argv0 = argv[0];
|
||||
argv[0] = _gpgme_get_basename (file);
|
||||
}
|
||||
status = _gpgme_io_spawn (file, (char * const *)argv, spflags,
|
||||
fd_list, NULL, NULL, &pid);
|
||||
if (save_argv0)
|
||||
argv[0] = save_argv0;
|
||||
free (fd_list);
|
||||
if (status == -1)
|
||||
return gpg_error_from_syserror ();
|
||||
|
@ -944,7 +944,8 @@ gpgme_error_t
|
||||
_gpgme_engine_op_spawn (engine_t engine,
|
||||
const char *file, const char *argv[],
|
||||
gpgme_data_t datain,
|
||||
gpgme_data_t dataout, gpgme_data_t dataerr)
|
||||
gpgme_data_t dataout, gpgme_data_t dataerr,
|
||||
unsigned int flags)
|
||||
{
|
||||
if (!engine)
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
@ -953,5 +954,5 @@ _gpgme_engine_op_spawn (engine_t engine,
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->opspawn) (engine->engine, file, argv,
|
||||
datain, dataout, dataerr);
|
||||
datain, dataout, dataerr, flags);
|
||||
}
|
||||
|
@ -167,7 +167,8 @@ gpgme_error_t _gpgme_engine_op_spawn (engine_t engine,
|
||||
const char *file, const char *argv[],
|
||||
gpgme_data_t datain,
|
||||
gpgme_data_t dataout,
|
||||
gpgme_data_t dataerr);
|
||||
gpgme_data_t dataerr,
|
||||
unsigned int flags);
|
||||
|
||||
|
||||
#endif /* ENGINE_H */
|
||||
|
@ -34,7 +34,8 @@ static gpgme_error_t
|
||||
spawn_start (gpgme_ctx_t ctx, int synchronous,
|
||||
const char *file, const char *argv[],
|
||||
gpgme_data_t datain,
|
||||
gpgme_data_t dataout, gpgme_data_t dataerr)
|
||||
gpgme_data_t dataout, gpgme_data_t dataerr,
|
||||
unsigned int flags)
|
||||
{
|
||||
gpgme_error_t err;
|
||||
const char *tmp_argv[2];
|
||||
@ -54,7 +55,7 @@ spawn_start (gpgme_ctx_t ctx, int synchronous,
|
||||
}
|
||||
|
||||
return _gpgme_engine_op_spawn (ctx->engine, file, argv,
|
||||
datain, dataout, dataerr);
|
||||
datain, dataout, dataerr, flags);
|
||||
}
|
||||
|
||||
|
||||
@ -75,7 +76,7 @@ gpgme_op_spawn_start (gpgme_ctx_t ctx, const char *file, const char *argv[],
|
||||
if (!ctx)
|
||||
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
||||
|
||||
err = spawn_start (ctx, 0, file, argv, datain, dataout, dataerr);
|
||||
err = spawn_start (ctx, 0, file, argv, datain, dataout, dataerr, flags);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -97,7 +98,7 @@ gpgme_op_spawn (gpgme_ctx_t ctx, const char *file, const char *argv[],
|
||||
if (!ctx)
|
||||
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
||||
|
||||
err = spawn_start (ctx, 1, file, argv, datain, dataout, dataerr);
|
||||
err = spawn_start (ctx, 1, file, argv, datain, dataout, dataerr, flags);
|
||||
|
||||
if (!err)
|
||||
err = _gpgme_wait_one (ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user