chiark / gitweb /
asshelp.c: add a lot of debug logging
[gnupg2.git] / tools / gpgtar.h
1 /* gpgtar.h - Global definitions for gpgtar
2  * Copyright (C) 2010 Free Software Foundation, Inc.
3  *
4  * This file is part of GnuPG.
5  *
6  * GnuPG is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GnuPG is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <https://www.gnu.org/licenses/>.
18  */
19
20 #ifndef GPGTAR_H
21 #define GPGTAR_H
22
23 #include "../common/util.h"
24 #include "../common/strlist.h"
25
26 /* We keep all global options in the structure OPT.  */
27 struct
28 {
29   int verbose;
30   unsigned int debug_level;
31   int quiet;
32   int dry_run;
33   const char *gpg_program;
34   strlist_t gpg_arguments;
35   const char *outfile;
36   strlist_t recipients;
37   const char *user;
38   int symmetric;
39   const char *filename;
40   const char *directory;
41 } opt;
42
43
44 /* The size of a tar record.  All IO is done in chunks of this size.
45    Note that we don't care about blocking because this version of tar
46    is not expected to be used directly on a tape drive in fact it is
47    used in a pipeline with GPG and thus any blocking would be
48    useless.  */
49 #define RECORDSIZE 512 
50
51
52 /* Description of the USTAR header format.  */
53 struct ustar_raw_header
54 {
55   char name[100];
56   char mode[8];
57   char uid[8];
58   char gid[8];
59   char size[12];
60   char mtime[12];
61   char checksum[8];
62   char typeflag[1];
63   char linkname[100];
64   char magic[6];
65   char version[2];
66   char uname[32];
67   char gname[32];   
68   char devmajor[8]; 
69   char devminor[8];
70   char prefix[155]; 
71   char pad[12];
72 };
73
74
75 /* Filetypes as defined by USTAR.  */
76 typedef enum 
77   {
78     TF_REGULAR,
79     TF_HARDLINK,
80     TF_SYMLINK,
81     TF_CHARDEV,
82     TF_BLOCKDEV,
83     TF_DIRECTORY,
84     TF_FIFO,
85     TF_RESERVED,
86     TF_UNKNOWN,    /* Needs to be treated as regular file.  */
87     TF_NOTSUP      /* Not supported (used with --create).  */
88   } typeflag_t;
89
90
91 /* The internal represenation of a TAR header.  */
92 struct tar_header_s;
93 typedef struct tar_header_s *tar_header_t;
94 struct tar_header_s
95 {
96   tar_header_t next;        /* Used to build a linked list iof entries.  */
97
98   unsigned long mode;       /* The file mode.  */
99   unsigned long nlink;      /* Number of hard links.  */
100   unsigned long uid;        /* The user id of the file.  */
101   unsigned long gid;        /* The group id of the file.  */
102   unsigned long long size;  /* The size of the file.  */
103   unsigned long long mtime; /* Modification time since Epoch.  Note
104                                that we don't use time_t here but a
105                                type which is more likely to be larger
106                                that 32 bit and thus allows tracking
107                                times beyond 2106.  */
108   typeflag_t typeflag;      /* The type of the file.  */
109   
110
111   unsigned long long nrecords; /* Number of data records.  */
112
113   char name[1];             /* Filename (dynamically extended).  */
114 };
115
116
117 /*-- gpgtar.c --*/
118 gpg_error_t read_record (estream_t stream, void *record);
119 gpg_error_t write_record (estream_t stream, const void *record);
120
121 /*-- gpgtar-create.c --*/
122 gpg_error_t gpgtar_create (char **inpattern, int encrypt, int sign);
123
124 /*-- gpgtar-extract.c --*/
125 gpg_error_t gpgtar_extract (const char *filename, int decrypt);
126
127 /*-- gpgtar-list.c --*/
128 gpg_error_t gpgtar_list (const char *filename, int decrypt);
129 gpg_error_t gpgtar_read_header (estream_t stream, tar_header_t *r_header);
130 void gpgtar_print_header (tar_header_t header, estream_t out);
131
132
133 #endif /*GPGTAR_H*/