common: Rework the simple password query module.
[gnupg.git] / tools / gpgtar-extract.c
index 728737d..cee609c 100644 (file)
@@ -28,8 +28,9 @@
 #include <assert.h>
 
 #include "i18n.h"
-#include "../common/call-gpg.h"
+#include "../common/exectool.h"
 #include "../common/sysutils.h"
+#include "../common/ccparray.h"
 #include "gpgtar.h"
 
 
@@ -281,7 +282,7 @@ gpgtar_extract (const char *filename, int decrypt)
   if (filename)
     {
       if (!strcmp (filename, "-"))
-        stream = es_stdout;
+        stream = es_stdin;
       else
         stream = es_fopen (filename, "rb");
       if (!stream)
@@ -299,6 +300,10 @@ gpgtar_extract (const char *filename, int decrypt)
 
   if (decrypt)
     {
+      strlist_t arg;
+      ccparray_t ccp;
+      const char **argv;
+
       cipher_stream = stream;
       stream = es_fopenmem (0, "rwb");
       if (! stream)
@@ -306,8 +311,24 @@ gpgtar_extract (const char *filename, int decrypt)
           err = gpg_error_from_syserror ();
           goto leave;
         }
-      err = gpg_decrypt_stream (NULL, opt.gpg_program, opt.gpg_arguments,
-                                cipher_stream, stream);
+
+      ccparray_init (&ccp, 0);
+
+      ccparray_put (&ccp, "--decrypt");
+      for (arg = opt.gpg_arguments; arg; arg = arg->next)
+        ccparray_put (&ccp, arg->d);
+
+      ccparray_put (&ccp, NULL);
+      argv = ccparray_get (&ccp, NULL);
+      if (!argv)
+        {
+          err = gpg_error_from_syserror ();
+          goto leave;
+        }
+
+      err = gnupg_exec_tool_stream (opt.gpg_program, argv,
+                                    cipher_stream, NULL, stream, NULL, NULL);
+      xfree (argv);
       if (err)
         goto leave;