core: Remove cruft from the engine-gpg code.
* src/engine-gpg.c (read_status): Remove the handling of GPGME_STATUS_END_STREAM; this was used only by the former experimental --pipemode of gpg but that is not even anymore invoked here. (struct engine_gpg): Remove cmd.linked_data and .linked_idx. (build_argv): Remove code for linked_data. (gpg_new): Ditto. (gpg_set_command_handler): Remove arr linked_data. * src/engine-backend.h (engine_ops): Remove arg data from set_command_handler. * src/engine.c (_gpgme_engine_set_command_handler): Remove arg linked_data and adjust all callers. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
2219fc19d5
commit
e2aa38b56a
@ -74,7 +74,7 @@ decrypt_verify_start (gpgme_ctx_t ctx, int synchronous,
|
|||||||
if (ctx->passphrase_cb)
|
if (ctx->passphrase_cb)
|
||||||
{
|
{
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -510,7 +510,7 @@ _gpgme_decrypt_start (gpgme_ctx_t ctx, int synchronous,
|
|||||||
if (ctx->passphrase_cb)
|
if (ctx->passphrase_cb)
|
||||||
{
|
{
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -139,8 +139,7 @@ interact_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t key,
|
|||||||
opd->fnc_old = NULL;
|
opd->fnc_old = NULL;
|
||||||
opd->fnc_value = fnc_value;
|
opd->fnc_value = fnc_value;
|
||||||
|
|
||||||
err = _gpgme_engine_set_command_handler (ctx->engine, command_handler,
|
err = _gpgme_engine_set_command_handler (ctx->engine, command_handler, ctx);
|
||||||
ctx, out);
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -219,8 +218,7 @@ edit_start (gpgme_ctx_t ctx, int synchronous, int type, gpgme_key_t key,
|
|||||||
opd->fnc_old = fnc;
|
opd->fnc_old = fnc;
|
||||||
opd->fnc_value = fnc_value;
|
opd->fnc_value = fnc_value;
|
||||||
|
|
||||||
err = _gpgme_engine_set_command_handler (ctx->engine, command_handler,
|
err = _gpgme_engine_set_command_handler (ctx->engine, command_handler, ctx);
|
||||||
ctx, out);
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ encrypt_sign_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t recp[],
|
|||||||
if (ctx->passphrase_cb)
|
if (ctx->passphrase_cb)
|
||||||
{
|
{
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ encrypt_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t recp[],
|
|||||||
{
|
{
|
||||||
/* Symmetric encryption requires a passphrase. */
|
/* Symmetric encryption requires a passphrase. */
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ struct engine_ops
|
|||||||
void *fnc_value);
|
void *fnc_value);
|
||||||
gpgme_error_t (*set_command_handler) (void *engine,
|
gpgme_error_t (*set_command_handler) (void *engine,
|
||||||
engine_command_handler_t fnc,
|
engine_command_handler_t fnc,
|
||||||
void *fnc_value, gpgme_data_t data);
|
void *fnc_value);
|
||||||
gpgme_error_t (*set_colon_line_handler) (void *engine,
|
gpgme_error_t (*set_colon_line_handler) (void *engine,
|
||||||
engine_colon_line_handler_t fnc,
|
engine_colon_line_handler_t fnc,
|
||||||
void *fnc_value);
|
void *fnc_value);
|
||||||
|
@ -135,10 +135,6 @@ struct engine_gpg
|
|||||||
char *keyword; /* what has been requested (malloced) */
|
char *keyword; /* what has been requested (malloced) */
|
||||||
engine_command_handler_t fnc;
|
engine_command_handler_t fnc;
|
||||||
void *fnc_value;
|
void *fnc_value;
|
||||||
/* The kludges never end. This is used to couple command handlers
|
|
||||||
with output data in edit key mode. */
|
|
||||||
gpgme_data_t linked_data;
|
|
||||||
int linked_idx;
|
|
||||||
} cmd;
|
} cmd;
|
||||||
|
|
||||||
struct gpgme_io_cbs io_cbs;
|
struct gpgme_io_cbs io_cbs;
|
||||||
@ -502,8 +498,6 @@ gpg_new (void **engine, const char *file_name, const char *home_dir,
|
|||||||
gpg->colon.fd[1] = -1;
|
gpg->colon.fd[1] = -1;
|
||||||
gpg->cmd.fd = -1;
|
gpg->cmd.fd = -1;
|
||||||
gpg->cmd.idx = -1;
|
gpg->cmd.idx = -1;
|
||||||
gpg->cmd.linked_data = NULL;
|
|
||||||
gpg->cmd.linked_idx = -1;
|
|
||||||
|
|
||||||
/* Allocate the read buffer for the status pipe. */
|
/* Allocate the read buffer for the status pipe. */
|
||||||
gpg->status.bufsize = 1024;
|
gpg->status.bufsize = 1024;
|
||||||
@ -792,14 +786,14 @@ command_handler (void *opaque, int fd)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* The Fnc will be called to get a value for one of the commands with
|
/* The FNC will be called to get a value for one of the commands with
|
||||||
a key KEY. If the Code passed to FNC is 0, the function may release
|
* a key KEY. If the code passed to FNC is 0, the function may
|
||||||
resources associated with the returned value from another call. To
|
* release resources associated with the returned value from another
|
||||||
match such a second call to a first call, the returned value from
|
* call. To match such a second call to a first call, the returned
|
||||||
the first call is passed as keyword. */
|
* value from the first call is passed as keyword. */
|
||||||
static gpgme_error_t
|
static gpgme_error_t
|
||||||
gpg_set_command_handler (void *engine, engine_command_handler_t fnc,
|
gpg_set_command_handler (void *engine, engine_command_handler_t fnc,
|
||||||
void *fnc_value, gpgme_data_t linked_data)
|
void *fnc_value)
|
||||||
{
|
{
|
||||||
engine_gpg_t gpg = engine;
|
engine_gpg_t gpg = engine;
|
||||||
gpgme_error_t rc;
|
gpgme_error_t rc;
|
||||||
@ -818,7 +812,6 @@ gpg_set_command_handler (void *engine, engine_command_handler_t fnc,
|
|||||||
gpg->cmd.fnc = fnc;
|
gpg->cmd.fnc = fnc;
|
||||||
gpg->cmd.cb_data = (void *) &gpg->cmd;
|
gpg->cmd.cb_data = (void *) &gpg->cmd;
|
||||||
gpg->cmd.fnc_value = fnc_value;
|
gpg->cmd.fnc_value = fnc_value;
|
||||||
gpg->cmd.linked_data = linked_data;
|
|
||||||
gpg->cmd.used = 1;
|
gpg->cmd.used = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1076,11 +1069,6 @@ build_argv (engine_gpg_t gpg, const char *pgmname)
|
|||||||
assert (gpg->cmd.idx == -1);
|
assert (gpg->cmd.idx == -1);
|
||||||
gpg->cmd.idx = datac;
|
gpg->cmd.idx = datac;
|
||||||
}
|
}
|
||||||
else if (gpg->cmd.linked_data == a->data)
|
|
||||||
{
|
|
||||||
assert (gpg->cmd.linked_idx == -1);
|
|
||||||
gpg->cmd.linked_idx = datac;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fd_data_map[datac].data = a->data;
|
fd_data_map[datac].data = a->data;
|
||||||
@ -1267,44 +1255,6 @@ read_status (engine_gpg_t gpg)
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r == GPGME_STATUS_END_STREAM)
|
|
||||||
{
|
|
||||||
if (gpg->cmd.used)
|
|
||||||
{
|
|
||||||
/* Before we can actually add the
|
|
||||||
command fd, we might have to flush
|
|
||||||
the linked output data pipe. */
|
|
||||||
if (gpg->cmd.linked_idx != -1
|
|
||||||
&& gpg->fd_data_map[gpg->cmd.linked_idx].fd
|
|
||||||
!= -1)
|
|
||||||
{
|
|
||||||
struct io_select_fd_s fds;
|
|
||||||
fds.fd =
|
|
||||||
gpg->fd_data_map[gpg->cmd.linked_idx].fd;
|
|
||||||
fds.for_read = 1;
|
|
||||||
fds.for_write = 0;
|
|
||||||
fds.opaque = NULL;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
fds.signaled = 0;
|
|
||||||
_gpgme_io_select (&fds, 1, 1);
|
|
||||||
if (fds.signaled)
|
|
||||||
_gpgme_data_inbound_handler
|
|
||||||
(gpg->cmd.linked_data, fds.fd);
|
|
||||||
}
|
|
||||||
while (fds.signaled);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX We must check if there are any
|
|
||||||
more fds active after removing this
|
|
||||||
one. */
|
|
||||||
(*gpg->io_cbs.remove)
|
|
||||||
(gpg->fd_data_map[gpg->cmd.idx].tag);
|
|
||||||
gpg->cmd.fd = gpg->fd_data_map[gpg->cmd.idx].fd;
|
|
||||||
gpg->fd_data_map[gpg->cmd.idx].fd = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* To reuse the buffer for the next line we have to
|
/* To reuse the buffer for the next line we have to
|
||||||
|
@ -596,8 +596,7 @@ _gpgme_engine_set_status_handler (engine_t engine,
|
|||||||
gpgme_error_t
|
gpgme_error_t
|
||||||
_gpgme_engine_set_command_handler (engine_t engine,
|
_gpgme_engine_set_command_handler (engine_t engine,
|
||||||
engine_command_handler_t fnc,
|
engine_command_handler_t fnc,
|
||||||
void *fnc_value,
|
void *fnc_value)
|
||||||
gpgme_data_t linked_data)
|
|
||||||
{
|
{
|
||||||
if (!engine)
|
if (!engine)
|
||||||
return gpg_error (GPG_ERR_INV_VALUE);
|
return gpg_error (GPG_ERR_INV_VALUE);
|
||||||
@ -605,8 +604,7 @@ _gpgme_engine_set_command_handler (engine_t engine,
|
|||||||
if (!engine->ops->set_command_handler)
|
if (!engine->ops->set_command_handler)
|
||||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||||
|
|
||||||
return (*engine->ops->set_command_handler) (engine->engine,
|
return (*engine->ops->set_command_handler) (engine->engine, fnc, fnc_value);
|
||||||
fnc, fnc_value, linked_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gpgme_error_t
|
gpgme_error_t
|
||||||
|
@ -78,8 +78,7 @@ void _gpgme_engine_set_status_handler (engine_t engine,
|
|||||||
void *fnc_value);
|
void *fnc_value);
|
||||||
gpgme_error_t _gpgme_engine_set_command_handler (engine_t engine,
|
gpgme_error_t _gpgme_engine_set_command_handler (engine_t engine,
|
||||||
engine_command_handler_t fnc,
|
engine_command_handler_t fnc,
|
||||||
void *fnc_value,
|
void *fnc_value);
|
||||||
gpgme_data_t data);
|
|
||||||
gpgme_error_t
|
gpgme_error_t
|
||||||
_gpgme_engine_set_colon_line_handler (engine_t engine,
|
_gpgme_engine_set_colon_line_handler (engine_t engine,
|
||||||
engine_colon_line_handler_t fnc,
|
engine_colon_line_handler_t fnc,
|
||||||
|
@ -259,7 +259,7 @@ genkey_start (gpgme_ctx_t ctx, int synchronous, const char *parms,
|
|||||||
if (ctx->passphrase_cb)
|
if (ctx->passphrase_cb)
|
||||||
{
|
{
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ createkey_start (gpgme_ctx_t ctx, int synchronous,
|
|||||||
if (ctx->passphrase_cb)
|
if (ctx->passphrase_cb)
|
||||||
{
|
{
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -433,7 +433,7 @@ createsubkey_start (gpgme_ctx_t ctx, int synchronous,
|
|||||||
if (ctx->passphrase_cb)
|
if (ctx->passphrase_cb)
|
||||||
{
|
{
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -519,7 +519,7 @@ addrevuid_start (gpgme_ctx_t ctx, int synchronous, int extraflags,
|
|||||||
if (ctx->passphrase_cb)
|
if (ctx->passphrase_cb)
|
||||||
{
|
{
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ keysign_start (gpgme_ctx_t ctx, int synchronous,
|
|||||||
if (ctx->passphrase_cb)
|
if (ctx->passphrase_cb)
|
||||||
{
|
{
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ passwd_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t key,
|
|||||||
if (ctx->passphrase_cb)
|
if (ctx->passphrase_cb)
|
||||||
{
|
{
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,7 @@ sign_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t plain,
|
|||||||
if (ctx->passphrase_cb)
|
if (ctx->passphrase_cb)
|
||||||
{
|
{
|
||||||
err = _gpgme_engine_set_command_handler
|
err = _gpgme_engine_set_command_handler
|
||||||
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user