core: Remove cruft from the engine-gpg code.
authorWerner Koch <wk@gnupg.org>
Thu, 31 May 2018 22:13:18 +0000 (00:13 +0200)
committerWerner Koch <wk@gnupg.org>
Thu, 31 May 2018 22:13:53 +0000 (00:13 +0200)
* 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>
13 files changed:
src/decrypt-verify.c
src/decrypt.c
src/edit.c
src/encrypt-sign.c
src/encrypt.c
src/engine-backend.h
src/engine-gpg.c
src/engine.c
src/engine.h
src/genkey.c
src/keysign.c
src/passwd.c
src/sign.c

index 17f79ac..ce4a7a9 100644 (file)
@@ -74,7 +74,7 @@ decrypt_verify_start (gpgme_ctx_t ctx, int synchronous,
   if (ctx->passphrase_cb)
     {
       err = _gpgme_engine_set_command_handler
-       (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+       (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
        return err;
     }
index ecd9c14..7dbc6fd 100644 (file)
@@ -510,7 +510,7 @@ _gpgme_decrypt_start (gpgme_ctx_t ctx, int synchronous,
   if (ctx->passphrase_cb)
     {
       err = _gpgme_engine_set_command_handler
-       (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+       (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
        return err;
     }
index ca4d595..2867efb 100644 (file)
@@ -139,8 +139,7 @@ interact_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t key,
   opd->fnc_old = NULL;
   opd->fnc_value = fnc_value;
 
-  err = _gpgme_engine_set_command_handler (ctx->engine, command_handler,
-                                          ctx, out);
+  err = _gpgme_engine_set_command_handler (ctx->engine, command_handler, ctx);
   if (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_value = fnc_value;
 
-  err = _gpgme_engine_set_command_handler (ctx->engine, command_handler,
-                                          ctx, out);
+  err = _gpgme_engine_set_command_handler (ctx->engine, command_handler, ctx);
   if (err)
     return err;
 
index 4db46e2..cc34fbd 100644 (file)
@@ -93,7 +93,7 @@ encrypt_sign_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t recp[],
   if (ctx->passphrase_cb)
     {
       err = _gpgme_engine_set_command_handler
-       (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+       (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
        return err;
     }
index 2318497..a27a53a 100644 (file)
@@ -242,7 +242,7 @@ encrypt_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t recp[],
     {
       /* Symmetric encryption requires a passphrase.  */
       err = _gpgme_engine_set_command_handler
-       (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+       (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
        return err;
     }
index f692666..4f33da1 100644 (file)
@@ -55,7 +55,7 @@ struct engine_ops
                              void *fnc_value);
   gpgme_error_t (*set_command_handler) (void *engine,
                                        engine_command_handler_t fnc,
-                                       void *fnc_value, gpgme_data_t data);
+                                       void *fnc_value);
   gpgme_error_t (*set_colon_line_handler) (void *engine,
                                           engine_colon_line_handler_t fnc,
                                           void *fnc_value);
index e955820..43d49fe 100644 (file)
@@ -135,10 +135,6 @@ struct engine_gpg
     char *keyword;       /* what has been requested (malloced) */
     engine_command_handler_t fnc;
     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;
 
   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->cmd.fd = -1;
   gpg->cmd.idx = -1;
-  gpg->cmd.linked_data = NULL;
-  gpg->cmd.linked_idx = -1;
 
   /* Allocate the read buffer for the status pipe.  */
   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
-   a key KEY.  If the Code passed to FNC is 0, the function may release
-   resources associated with the returned value from another call.  To
-   match such a second call to a first call, the returned value from
  the first call is passed as keyword.  */
+/* 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 resources associated with the returned value from another
+ * call.  To match such a second call to a first call, the returned
* value from the first call is passed as keyword.  */
 static gpgme_error_t
 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;
   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.cb_data = (void *) &gpg->cmd;
   gpg->cmd.fnc_value = fnc_value;
-  gpg->cmd.linked_data = linked_data;
   gpg->cmd.used = 1;
   return 0;
 }
@@ -1076,11 +1069,6 @@ build_argv (engine_gpg_t gpg, const char *pgmname)
                  assert (gpg->cmd.idx == -1);
                  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;
@@ -1267,44 +1255,6 @@ read_status (engine_gpg_t gpg)
                          if (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
index b716ca2..b629bea 100644 (file)
@@ -596,8 +596,7 @@ _gpgme_engine_set_status_handler (engine_t engine,
 gpgme_error_t
 _gpgme_engine_set_command_handler (engine_t engine,
                                   engine_command_handler_t fnc,
-                                  void *fnc_value,
-                                  gpgme_data_t linked_data)
+                                  void *fnc_value)
 {
   if (!engine)
     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)
     return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
 
-  return (*engine->ops->set_command_handler) (engine->engine,
-                                             fnc, fnc_value, linked_data);
+  return (*engine->ops->set_command_handler) (engine->engine, fnc, fnc_value);
 }
 
 gpgme_error_t
index 8b692f2..c512a25 100644 (file)
@@ -78,8 +78,7 @@ void _gpgme_engine_set_status_handler (engine_t engine,
                                       void *fnc_value);
 gpgme_error_t _gpgme_engine_set_command_handler (engine_t engine,
                                                 engine_command_handler_t fnc,
-                                                void *fnc_value,
-                                                gpgme_data_t data);
+                                                void *fnc_value);
 gpgme_error_t
 _gpgme_engine_set_colon_line_handler (engine_t engine,
                                      engine_colon_line_handler_t fnc,
index 16484ec..ffca7e8 100644 (file)
@@ -259,7 +259,7 @@ genkey_start (gpgme_ctx_t ctx, int synchronous, const char *parms,
   if (ctx->passphrase_cb)
     {
       err = _gpgme_engine_set_command_handler
-        (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+        (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
         return err;
     }
@@ -345,7 +345,7 @@ createkey_start (gpgme_ctx_t ctx, int synchronous,
   if (ctx->passphrase_cb)
     {
       err = _gpgme_engine_set_command_handler
-        (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+        (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
         return err;
     }
@@ -433,7 +433,7 @@ createsubkey_start (gpgme_ctx_t ctx, int synchronous,
   if (ctx->passphrase_cb)
     {
       err = _gpgme_engine_set_command_handler
-        (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+        (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
         return err;
     }
@@ -519,7 +519,7 @@ addrevuid_start (gpgme_ctx_t ctx, int synchronous, int extraflags,
   if (ctx->passphrase_cb)
     {
       err = _gpgme_engine_set_command_handler
-        (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+        (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
         return err;
     }
index c2fcabb..5e49793 100644 (file)
@@ -171,7 +171,7 @@ keysign_start (gpgme_ctx_t ctx, int synchronous,
   if (ctx->passphrase_cb)
     {
       err = _gpgme_engine_set_command_handler
-        (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+        (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
         return err;
     }
index 5bd67a5..6c03002 100644 (file)
@@ -151,7 +151,7 @@ passwd_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t key,
   if (ctx->passphrase_cb)
     {
       err = _gpgme_engine_set_command_handler
-        (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+        (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
         return err;
     }
index bfd9ad1..ab4109e 100644 (file)
@@ -449,7 +449,7 @@ sign_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t plain,
   if (ctx->passphrase_cb)
     {
       err = _gpgme_engine_set_command_handler
-       (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+       (ctx->engine, _gpgme_passphrase_command_handler, ctx);
       if (err)
        return err;
     }