[Pkg-gnupg-commit] [gnupg2] 176/241: tools/gpgtar: Handle '--directory' argument.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed Dec 9 20:32:13 UTC 2015
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit 127aba9a4d6c1aabb4a18a74b16d3bddc6eb5c54
Author: Justus Winter <justus at g10code.com>
Date: Wed Nov 25 18:29:22 2015 +0100
tools/gpgtar: Handle '--directory' argument.
* tools/gpgtar-extract.c (gpgtar_extract): Only generate a directory
name if none is given via arguments.
* tools/gpgtar.c (enum cmd_and_opt_values): New constant.
(opts): Add argument.
(main): Parse argument.
* tools/gpgtar.h (opt): New field 'directory'.
Signed-off-by: Justus Winter <justus at g10code.com>
---
tools/gpgtar-extract.c | 49 +++++++++++++++++++++++++++----------------------
tools/gpgtar.c | 4 ++++
tools/gpgtar.h | 1 +
3 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/tools/gpgtar-extract.c b/tools/gpgtar-extract.c
index 92346b0..fa2f362 100644
--- a/tools/gpgtar-extract.c
+++ b/tools/gpgtar-extract.c
@@ -312,31 +312,36 @@ gpgtar_extract (const char *filename, int decrypt)
goto leave;
}
- if (filename)
- {
- dirprefix = strrchr (filename, '/');
- if (dirprefix)
- dirprefix++;
- else
- dirprefix = filename;
- }
- else if (opt.filename)
+ if (opt.directory)
+ dirname = xtrystrdup (opt.directory);
+ else
{
- dirprefix = strrchr (opt.filename, '/');
- if (dirprefix)
- dirprefix++;
- else
- dirprefix = opt.filename;
- }
+ if (filename)
+ {
+ dirprefix = strrchr (filename, '/');
+ if (dirprefix)
+ dirprefix++;
+ else
+ dirprefix = filename;
+ }
+ else if (opt.filename)
+ {
+ dirprefix = strrchr (opt.filename, '/');
+ if (dirprefix)
+ dirprefix++;
+ else
+ dirprefix = opt.filename;
+ }
- if (!dirprefix || !*dirprefix)
- dirprefix = "GPGARCH";
+ if (!dirprefix || !*dirprefix)
+ dirprefix = "GPGARCH";
- dirname = create_directory (dirprefix);
- if (!dirname)
- {
- err = gpg_error (GPG_ERR_GENERAL);
- goto leave;
+ dirname = create_directory (dirprefix);
+ if (!dirname)
+ {
+ err = gpg_error (GPG_ERR_GENERAL);
+ goto leave;
+ }
}
if (opt.verbose)
diff --git a/tools/gpgtar.c b/tools/gpgtar.c
index c4bf855..991fbed 100644
--- a/tools/gpgtar.c
+++ b/tools/gpgtar.c
@@ -58,6 +58,7 @@ enum cmd_and_opt_values
oRecipient = 'r',
oUser = 'u',
oOutput = 'o',
+ oDirectory = 'C',
oQuiet = 'q',
oVerbose = 'v',
oFilesFrom = 'T',
@@ -89,6 +90,8 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_s_s (oUser, "local-user",
N_("|USER-ID|use USER-ID to sign or decrypt")),
ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")),
+ ARGPARSE_s_s (oDirectory, "directory",
+ N_("|DIRECTORY|extract files into DIRECTORY")),
ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")),
ARGPARSE_s_s (oGpgProgram, "gpg", "@"),
@@ -194,6 +197,7 @@ main (int argc, char **argv)
switch (pargs.r_opt)
{
case oOutput: opt.outfile = pargs.r.ret_str; break;
+ case oDirectory: opt.directory = pargs.r.ret_str; break;
case oSetFilename: opt.filename = pargs.r.ret_str; break;
case oQuiet: opt.quiet = 1; break;
case oVerbose: opt.verbose++; break;
diff --git a/tools/gpgtar.h b/tools/gpgtar.h
index 98fd51c..66a8ae1 100644
--- a/tools/gpgtar.h
+++ b/tools/gpgtar.h
@@ -35,6 +35,7 @@ struct
const char *user;
int symmetric;
const char *filename;
+ const char *directory;
} opt;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list