summaryrefslogtreecommitdiffstats
path: root/tools/gpgtar.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2019-03-06 17:46:40 +0100
committerWerner Koch <wk@gnupg.org>2019-03-06 17:46:40 +0100
commit72feb8fa8280aba674573a1afc955a92e8065242 (patch)
treedb50444e2af494ac8842f1a864953bdcf3da2e73 /tools/gpgtar.h
parentagent: Default to extended key format. (diff)
downloadgnupg2-72feb8fa8280aba674573a1afc955a92e8065242.tar.xz
gnupg2-72feb8fa8280aba674573a1afc955a92e8065242.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 <wk@gnupg.org>
Diffstat (limited to 'tools/gpgtar.h')
-rw-r--r--tools/gpgtar.h26
1 files changed, 18 insertions, 8 deletions
diff --git a/tools/gpgtar.h b/tools/gpgtar.h
index 28d3d88b1..1a1b913d7 100644
--- a/tools/gpgtar.h
+++ b/tools/gpgtar.h
@@ -41,12 +41,21 @@ struct
} opt;
+/* An info structure to avoid global variables. */
+struct tarinfo_s
+{
+ unsigned long long nblocks; /* Count of processed blocks. */
+ unsigned long long headerblock; /* Number of current header block. */
+};
+typedef struct tarinfo_s *tarinfo_t;
+
+
/* The size of a tar record. All IO is done in chunks of this size.
Note that we don't care about blocking because this version of tar
is not expected to be used directly on a tape drive in fact it is
used in a pipeline with GPG and thus any blocking would be
useless. */
-#define RECORDSIZE 512
+#define RECORDSIZE 512
/* Description of the USTAR header format. */
@@ -64,16 +73,16 @@ struct ustar_raw_header
char magic[6];
char version[2];
char uname[32];
- char gname[32];
- char devmajor[8];
+ char gname[32];
+ char devmajor[8];
char devminor[8];
- char prefix[155];
+ char prefix[155];
char pad[12];
};
/* Filetypes as defined by USTAR. */
-typedef enum
+typedef enum
{
TF_REGULAR,
TF_HARDLINK,
@@ -93,7 +102,7 @@ struct tar_header_s;
typedef struct tar_header_s *tar_header_t;
struct tar_header_s
{
- tar_header_t next; /* Used to build a linked list iof entries. */
+ tar_header_t next; /* Used to build a linked list of entries. */
unsigned long mode; /* The file mode. */
unsigned long nlink; /* Number of hard links. */
@@ -106,7 +115,7 @@ struct tar_header_s
that 32 bit and thus allows tracking
times beyond 2106. */
typeflag_t typeflag; /* The type of the file. */
-
+
unsigned long long nrecords; /* Number of data records. */
@@ -126,7 +135,8 @@ gpg_error_t gpgtar_extract (const char *filename, int decrypt);
/*-- gpgtar-list.c --*/
gpg_error_t gpgtar_list (const char *filename, int decrypt);
-gpg_error_t gpgtar_read_header (estream_t stream, tar_header_t *r_header);
+gpg_error_t gpgtar_read_header (estream_t stream, tarinfo_t info,
+ tar_header_t *r_header);
void gpgtar_print_header (tar_header_t header, estream_t out);