1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

gpgtar: Simplify code by using ccparray.

* tools/gpgtar-create.c (gpgtar_create): Use ccparray functions.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-05-24 15:54:48 +02:00
parent 2421f7f7ed
commit 91bc783383
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
3 changed files with 49 additions and 53 deletions

View file

@ -30,6 +30,7 @@
#include "i18n.h"
#include "../common/exectool.h"
#include "../common/sysutils.h"
#include "../common/ccparray.h"
#include "gpgtar.h"
@ -299,8 +300,8 @@ gpgtar_extract (const char *filename, int decrypt)
if (decrypt)
{
int i;
strlist_t arg;
ccparray_t ccp;
const char **argv;
cipher_stream = stream;
@ -311,19 +312,19 @@ gpgtar_extract (const char *filename, int decrypt)
goto leave;
}
argv = xtrycalloc (strlist_length (opt.gpg_arguments) + 2,
sizeof *argv);
if (argv == NULL)
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;
}
i = 0;
argv[i++] = "--decrypt";
for (arg = opt.gpg_arguments; arg; arg = arg->next)
argv[i++] = arg->d;
argv[i++] = NULL;
assert (i == strlist_length (opt.gpg_arguments) + 2);
err = gnupg_exec_tool_stream (opt.gpg_program, argv,
cipher_stream, stream);