aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gpgtar.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-03-06 16:46:40 +0000
committerWerner Koch <[email protected]>2019-03-07 09:55:21 +0000
commit2e4151a3412c3fc553fbb7ad070dfffc68a04b35 (patch)
treec560fc28b0bd37ab821d91f41fb9f69300cbed67 /tools/gpgtar.c
parentgpg: Make invalid primary key algos obvious in key listings. (diff)
downloadgnupg-2e4151a3412c3fc553fbb7ad070dfffc68a04b35.tar.gz
gnupg-2e4151a3412c3fc553fbb7ad070dfffc68a04b35.zip
gpgtar: Improve error messages.
* tools/gpgtar.h (struct tarinfo_s): New. * tools/gpgtar.c (cmd, skip_crypto, files_from, null_names): Move global vars more to the top. (set_cmd): Rename 'cmd' to 'c'. * tools/gpgtar-list.c (parse_header): Add arg 'info' and improve error messages. (read_header): Add arg 'info' and update counter. (skip_data): Ditto. (gpgtar_list): Pass info object to read functions. (gpgtar_read_header): Add arg 'info'. * tools/gpgtar-extract.c (gpgtar_extract): add arg 'info' and pass on. (extract_regular): Add arg 'info' and update counter. -- This now prints the block number of a header with error. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 72feb8fa8280aba674573a1afc955a92e8065242)
Diffstat (limited to '')
-rw-r--r--tools/gpgtar.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/tools/gpgtar.c b/tools/gpgtar.c
index 2757ab011..77001dc91 100644
--- a/tools/gpgtar.c
+++ b/tools/gpgtar.c
@@ -136,6 +136,14 @@ static ARGPARSE_OPTS tar_opts[] = {
};
+/* Global flags. */
+enum cmd_and_opt_values cmd = 0;
+int skip_crypto = 0;
+const char *files_from = NULL;
+int null_names = 0;
+
+
+
/* Print usage information and provide strings for help. */
static const char *
@@ -169,23 +177,25 @@ my_strusage( int level )
static void
set_cmd (enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd)
{
- enum cmd_and_opt_values cmd = *ret_cmd;
-
- if (!cmd || cmd == new_cmd)
- cmd = new_cmd;
- else if (cmd == aSign && new_cmd == aEncrypt)
- cmd = aSignEncrypt;
- else if (cmd == aEncrypt && new_cmd == aSign)
- cmd = aSignEncrypt;
+ enum cmd_and_opt_values c = *ret_cmd;
+
+ if (!c || c == new_cmd)
+ c = new_cmd;
+ else if (c == aSign && new_cmd == aEncrypt)
+ c = aSignEncrypt;
+ else if (c == aEncrypt && new_cmd == aSign)
+ c = aSignEncrypt;
else
{
log_error (_("conflicting commands\n"));
exit (2);
}
- *ret_cmd = cmd;
+ *ret_cmd = c;
}
+
+
/* Shell-like argument splitting.
For compatibility with gpg-zip we accept arguments for GnuPG and
@@ -287,14 +297,9 @@ shell_parse_argv (const char *s, int *r_argc, char ***r_argv)
gpgrt_annotate_leaked_object (*r_argv);
return 0;
}
-
-/* Global flags. */
-enum cmd_and_opt_values cmd = 0;
-int skip_crypto = 0;
-const char *files_from = NULL;
-int null_names = 0;
+
/* Command line parsing. */
static void
parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)