From d988a1820c05227409b8eb3c6713b947bfb3c04b Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 24 Feb 2004 23:15:33 +0000 Subject: [PATCH] 2004-02-25 Marcus Brinkmann * rungpg.c (gpg_cancel): New function. (gpg_release): Call it here. (_gpgme_engine_ops_gpg): Add it here. * engine-gpgsm.c (gpgsm_cancel): Fix last change. --- gpgme/ChangeLog | 11 +++++++++-- gpgme/engine-gpgsm.c | 4 +++- gpgme/rungpg.c | 40 +++++++++++++++++++++++++++------------- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 9000c172..e3eb8da7 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,13 +1,20 @@ +2004-02-25 Marcus Brinkmann + + * rungpg.c (gpg_cancel): New function. + (gpg_release): Call it here. + (_gpgme_engine_ops_gpg): Add it here. + * engine-gpgsm.c (gpgsm_cancel): Fix last change. + 2004-02-24 Marcus Brinkmann * gpgme.c (gpgme_cancel): New function. * engine-backend.h (struct engine_ops): New member cancel. * engine.h (_gpgme_engine_cancel): New prototype. * engine.c (_gpgme_engine_cancel): New function. - * engine-gpgsm.c: Add new member cancel. + * engine-gpgsm.c (_gpgme_engine_ops_gpgsm): Add new member cancel. (gpgsm_cancel): New function. (gpgsm_release): Use it. - * rungpg.c: Add new member cancel. + * rungpg.c (_gpgme_engine_ops_gpg): Add new member cancel. 2004-02-17 Werner Koch diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index 99812552..f2e51514 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -278,7 +278,7 @@ gpgsm_cancel (void *engine) engine_gpgsm_t gpgsm = engine; if (!gpgsm) - return; + return gpg_error (GPG_ERR_INV_VALUE); if (gpgsm->status_cb.fd != -1) _gpgme_io_close (gpgsm->status_cb.fd); @@ -290,6 +290,8 @@ gpgsm_cancel (void *engine) _gpgme_io_close (gpgsm->message_cb.fd); assuan_disconnect (gpgsm->assuan_ctx); + + return 0; } diff --git a/gpgme/rungpg.c b/gpgme/rungpg.c index 58c12f92..7cb4ae79 100644 --- a/gpgme/rungpg.c +++ b/gpgme/rungpg.c @@ -276,6 +276,30 @@ free_fd_data_map (struct fd_data_map_s *fd_data_map) } +static gpgme_error_t +gpg_cancel (void *engine) +{ + engine_gpg_t gpg = engine; + + if (!gpg) + return gpg_error (GPG_ERR_INV_VALUE); + + if (gpg->status.fd[0] != -1) + _gpgme_io_close (gpg->status.fd[0]); + if (gpg->status.fd[1] != -1) + _gpgme_io_close (gpg->status.fd[1]); + if (gpg->colon.fd[0] != -1) + _gpgme_io_close (gpg->colon.fd[0]); + if (gpg->colon.fd[1] != -1) + _gpgme_io_close (gpg->colon.fd[1]); + if (gpg->fd_data_map) + free_fd_data_map (gpg->fd_data_map); + if (gpg->cmd.fd != -1) + _gpgme_io_close (gpg->cmd.fd); + + return 0; +} + static void gpg_release (void *engine) { @@ -284,6 +308,8 @@ gpg_release (void *engine) if (!gpg) return; + gpg_cancel (engine); + while (gpg->arglist) { struct arg_and_data_s *next = gpg->arglist->next; @@ -302,18 +328,6 @@ gpg_release (void *engine) if (gpg->cmd.keyword) free (gpg->cmd.keyword); - if (gpg->status.fd[0] != -1) - _gpgme_io_close (gpg->status.fd[0]); - if (gpg->status.fd[1] != -1) - _gpgme_io_close (gpg->status.fd[1]); - if (gpg->colon.fd[0] != -1) - _gpgme_io_close (gpg->colon.fd[0]); - if (gpg->colon.fd[1] != -1) - _gpgme_io_close (gpg->colon.fd[1]); - if (gpg->fd_data_map) - free_fd_data_map (gpg->fd_data_map); - if (gpg->cmd.fd != -1) - _gpgme_io_close (gpg->cmd.fd); free (gpg); } @@ -1665,5 +1679,5 @@ struct engine_ops _gpgme_engine_ops_gpg = gpg_verify, gpg_set_io_cbs, gpg_io_event, - NULL + gpg_cancel };