dpkg
1.22.7-3-g89f48
Loading...
Searching...
No Matches
lib
dpkg
tarfn.h
Go to the documentation of this file.
1
/*
2
* libdpkg - Debian packaging suite library routines
3
* tarfn.h - tar archive extraction functions
4
*
5
* Copyright © 1995 Bruce Perens
6
* Copyright © 2009-2014, 2017 Guillem Jover <guillem@debian.org>
7
*
8
* This is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
12
*
13
* This is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20
*/
21
22
#ifndef LIBDPKG_TARFN_H
23
#define LIBDPKG_TARFN_H
24
25
#include <sys/types.h>
26
27
#include <stdint.h>
28
29
#include <
dpkg/error.h
>
30
#include <
dpkg/file.h
>
31
32
DPKG_BEGIN_DECLS
33
40
#define TARBLKSZ 512
41
42
enum
tar_format
{
43
TAR_FORMAT_UNKNOWN
,
44
TAR_FORMAT_OLD
,
45
TAR_FORMAT_GNU
,
46
TAR_FORMAT_USTAR
,
47
TAR_FORMAT_PAX
,
48
};
49
50
enum
tar_filetype
{
52
TAR_FILETYPE_FILE0
=
'\0'
,
53
TAR_FILETYPE_FILE
=
'0'
,
54
TAR_FILETYPE_HARDLINK
=
'1'
,
55
TAR_FILETYPE_SYMLINK
=
'2'
,
56
TAR_FILETYPE_CHARDEV
=
'3'
,
57
TAR_FILETYPE_BLOCKDEV
=
'4'
,
58
TAR_FILETYPE_DIR
=
'5'
,
59
TAR_FILETYPE_FIFO
=
'6'
,
60
TAR_FILETYPE_CONTIG
=
'7'
,
61
TAR_FILETYPE_GNU_LONGLINK
=
'K'
,
62
TAR_FILETYPE_GNU_LONGNAME
=
'L'
,
63
TAR_FILETYPE_GNU_VOLUME
=
'V'
,
64
TAR_FILETYPE_GNU_MULTIVOL
=
'M'
,
65
TAR_FILETYPE_GNU_DUMPDIR
=
'D'
,
66
TAR_FILETYPE_GNU_SPARSE
=
'S'
,
67
TAR_FILETYPE_PAX_GLOBAL
=
'g'
,
68
TAR_FILETYPE_PAX_EXTENDED
=
'x'
,
69
TAR_FILETYPE_SOLARIS_EXTENDED
=
'X'
,
70
TAR_FILETYPE_SOLARIS_ACL
=
'A'
,
71
};
72
73
struct
tar_entry
{
75
enum
tar_format
format
;
77
enum
tar_filetype
type
;
79
char
*
name
;
81
char
*
linkname
;
83
off_t
size
;
85
intmax_t
mtime
;
87
dev_t
dev
;
88
89
struct
file_stat
stat
;
90
};
91
92
struct
tar_archive
;
93
94
typedef
int
tar_read_func
(
struct
tar_archive
*tar,
char
*buffer,
int
length);
95
typedef
int
tar_make_func
(
struct
tar_archive
*tar,
struct
tar_entry
*h);
96
97
struct
tar_operations
{
98
tar_read_func
*
read
;
99
100
tar_make_func
*
extract_file
;
101
tar_make_func
*
link
;
102
tar_make_func
*
symlink
;
103
tar_make_func
*
mkdir
;
104
tar_make_func
*
mknod
;
105
};
106
107
struct
tar_archive
{
108
/* Global tar archive error. */
109
struct
dpkg_error
err
;
110
112
enum
tar_format
format
;
113
114
/* Operation functions and context. */
115
const
struct
tar_operations
*
ops
;
116
void
*
ctx
;
117
};
118
119
uintmax_t
120
tar_atoul
(
const
char
*s,
size_t
size, uintmax_t
max
);
121
intmax_t
122
tar_atosl
(
const
char
*s,
size_t
size, intmax_t
min
, intmax_t
max
);
123
124
void
125
tar_entry_update_from_system
(
struct
tar_entry
*te);
126
127
int
128
tar_extractor
(
struct
tar_archive
*tar);
129
132
DPKG_END_DECLS
133
134
#endif
error.h
file.h
DPKG_BEGIN_DECLS
#define DPKG_BEGIN_DECLS
Definition
macros.h:164
min
#define min(a, b)
Definition
macros.h:217
DPKG_END_DECLS
#define DPKG_END_DECLS
Definition
macros.h:165
max
#define max(a, b)
Definition
macros.h:221
tar_atoul
uintmax_t tar_atoul(const char *s, size_t size, uintmax_t max)
Definition
tarfn.c:181
tar_format
tar_format
Definition
tarfn.h:42
tar_entry_update_from_system
void tar_entry_update_from_system(struct tar_entry *te)
Update the tar entry from system information.
Definition
tarfn.c:434
tar_make_func
int tar_make_func(struct tar_archive *tar, struct tar_entry *h)
Definition
tarfn.h:95
tar_extractor
int tar_extractor(struct tar_archive *tar)
Definition
tarfn.c:452
tar_filetype
tar_filetype
Definition
tarfn.h:50
tar_read_func
int tar_read_func(struct tar_archive *tar, char *buffer, int length)
Definition
tarfn.h:94
tar_atosl
intmax_t tar_atosl(const char *s, size_t size, intmax_t min, intmax_t max)
Definition
tarfn.c:192
TAR_FORMAT_GNU
@ TAR_FORMAT_GNU
Definition
tarfn.h:45
TAR_FORMAT_PAX
@ TAR_FORMAT_PAX
Definition
tarfn.h:47
TAR_FORMAT_UNKNOWN
@ TAR_FORMAT_UNKNOWN
Definition
tarfn.h:43
TAR_FORMAT_USTAR
@ TAR_FORMAT_USTAR
Definition
tarfn.h:46
TAR_FORMAT_OLD
@ TAR_FORMAT_OLD
Definition
tarfn.h:44
TAR_FILETYPE_GNU_LONGLINK
@ TAR_FILETYPE_GNU_LONGLINK
Definition
tarfn.h:61
TAR_FILETYPE_FIFO
@ TAR_FILETYPE_FIFO
Definition
tarfn.h:59
TAR_FILETYPE_GNU_MULTIVOL
@ TAR_FILETYPE_GNU_MULTIVOL
Definition
tarfn.h:64
TAR_FILETYPE_FILE
@ TAR_FILETYPE_FILE
Definition
tarfn.h:53
TAR_FILETYPE_SOLARIS_ACL
@ TAR_FILETYPE_SOLARIS_ACL
Definition
tarfn.h:70
TAR_FILETYPE_GNU_SPARSE
@ TAR_FILETYPE_GNU_SPARSE
Definition
tarfn.h:66
TAR_FILETYPE_HARDLINK
@ TAR_FILETYPE_HARDLINK
Definition
tarfn.h:54
TAR_FILETYPE_SYMLINK
@ TAR_FILETYPE_SYMLINK
Definition
tarfn.h:55
TAR_FILETYPE_PAX_GLOBAL
@ TAR_FILETYPE_PAX_GLOBAL
Definition
tarfn.h:67
TAR_FILETYPE_FILE0
@ TAR_FILETYPE_FILE0
For compatibility with decades-old bug.
Definition
tarfn.h:52
TAR_FILETYPE_GNU_VOLUME
@ TAR_FILETYPE_GNU_VOLUME
Definition
tarfn.h:63
TAR_FILETYPE_GNU_DUMPDIR
@ TAR_FILETYPE_GNU_DUMPDIR
Definition
tarfn.h:65
TAR_FILETYPE_DIR
@ TAR_FILETYPE_DIR
Definition
tarfn.h:58
TAR_FILETYPE_CONTIG
@ TAR_FILETYPE_CONTIG
Definition
tarfn.h:60
TAR_FILETYPE_BLOCKDEV
@ TAR_FILETYPE_BLOCKDEV
Definition
tarfn.h:57
TAR_FILETYPE_SOLARIS_EXTENDED
@ TAR_FILETYPE_SOLARIS_EXTENDED
Definition
tarfn.h:69
TAR_FILETYPE_CHARDEV
@ TAR_FILETYPE_CHARDEV
Definition
tarfn.h:56
TAR_FILETYPE_GNU_LONGNAME
@ TAR_FILETYPE_GNU_LONGNAME
Definition
tarfn.h:62
TAR_FILETYPE_PAX_EXTENDED
@ TAR_FILETYPE_PAX_EXTENDED
Definition
tarfn.h:68
dpkg_error
Definition
error.h:42
file_stat
Definition
file.h:40
tar_archive
Definition
tarfn.h:107
tar_archive::ops
const struct tar_operations * ops
Definition
tarfn.h:115
tar_archive::err
struct dpkg_error err
Definition
tarfn.h:109
tar_archive::ctx
void * ctx
Definition
tarfn.h:116
tar_archive::format
enum tar_format format
Tar archive format.
Definition
tarfn.h:112
tar_entry
Definition
tarfn.h:73
tar_entry::name
char * name
File name.
Definition
tarfn.h:79
tar_entry::stat
struct file_stat stat
Definition
tarfn.h:89
tar_entry::linkname
char * linkname
Symlink or hardlink name.
Definition
tarfn.h:81
tar_entry::mtime
intmax_t mtime
Last-modified time.
Definition
tarfn.h:85
tar_entry::format
enum tar_format format
Tar entry format.
Definition
tarfn.h:75
tar_entry::type
enum tar_filetype type
File type.
Definition
tarfn.h:77
tar_entry::size
off_t size
File size.
Definition
tarfn.h:83
tar_entry::dev
dev_t dev
Special device for mknod().
Definition
tarfn.h:87
tar_operations
Definition
tarfn.h:97
tar_operations::symlink
tar_make_func * symlink
Definition
tarfn.h:102
tar_operations::mkdir
tar_make_func * mkdir
Definition
tarfn.h:103
tar_operations::read
tar_read_func * read
Definition
tarfn.h:98
tar_operations::extract_file
tar_make_func * extract_file
Definition
tarfn.h:100
tar_operations::mknod
tar_make_func * mknod
Definition
tarfn.h:104
tar_operations::link
tar_make_func * link
Definition
tarfn.h:101
Generated by
1.9.8