File: gpgtar.h

package info (click to toggle)
gnupg2 2.0.26-6%2Bdeb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 41,744 kB
  • sloc: ansic: 148,708; sh: 7,943; makefile: 825; perl: 196; awk: 126; sed: 16
file content (132 lines) | stat: -rw-r--r-- 3,748 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* gpgtar.h - Global definitions for gpgtar
 * Copyright (C) 2010 Free Software Foundation, Inc.
 *
 * This file is part of GnuPG.
 *
 * GnuPG is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * GnuPG is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#ifndef GPGTAR_H
#define GPGTAR_H

#include "../common/util.h"
#include "../common/estream.h"

/* We keep all global options in the structure OPT.  */
struct
{
  int verbose;
  int quiet;
  const char *outfile;
  int symmetric;
  const char *filename;
} opt;


/* 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 


/* Description of the USTAR header format.  */
struct ustar_raw_header
{
  char name[100];
  char mode[8];
  char uid[8];
  char gid[8];
  char size[12];
  char mtime[12];
  char checksum[8];
  char typeflag[1];
  char linkname[100];
  char magic[6];
  char version[2];
  char uname[32];
  char gname[32];   
  char devmajor[8]; 
  char devminor[8];
  char prefix[155]; 
  char pad[12];
};


/* Filetypes as defined by USTAR.  */
typedef enum 
  {
    TF_REGULAR,
    TF_HARDLINK,
    TF_SYMLINK,
    TF_CHARDEV,
    TF_BLOCKDEV,
    TF_DIRECTORY,
    TF_FIFO,
    TF_RESERVED,
    TF_UNKNOWN,    /* Needs to be treated as regular file.  */
    TF_NOTSUP      /* Not supported (used with --create).  */
  } typeflag_t;


/* The internal represenation of a TAR header.  */
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.  */

  unsigned long mode;       /* The file mode.  */
  unsigned long nlink;      /* Number of hard links.  */
  unsigned long uid;        /* The user id of the file.  */
  unsigned long gid;        /* The group id of the file.  */
  unsigned long long size;  /* The size of the file.  */
  unsigned long long mtime; /* Modification time since Epoch.  Note
                               that we don't use time_t here but a
                               type which is more likely to be larger
                               that 32 bit and thus allows to track
                               times beyond 2106.  */
  typeflag_t typeflag;      /* The type of the file.  */
  

  unsigned long long nrecords; /* Number of data records.  */

  char name[1];             /* Filename (dynamically extended).  */
};


/*-- gpgtar.c --*/
gpg_error_t read_record (estream_t stream, void *record);
gpg_error_t write_record (estream_t stream, const void *record);

int gnupg_mkdir (const char *name, const char *modestr);
#ifdef HAVE_W32_SYSTEM
char *wchar_to_utf8 (const wchar_t *string);
wchar_t *utf8_to_wchar (const char *string);
#endif

/*-- gpgtar-create.c --*/
void gpgtar_create (char **inpattern);

/*-- gpgtar-extract.c --*/
void gpgtar_extract (const char *filename);

/*-- gpgtar-list.c --*/
void gpgtar_list (const char *filename);
tar_header_t gpgtar_read_header (estream_t stream);
void gpgtar_print_header (tar_header_t header, estream_t out);


#endif /*GPGTAR_H*/