dpkg 1.21.11
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
33
40#define TARBLKSZ 512
41
48};
49
71};
72
73struct tar_entry {
79 char *name;
81 char *linkname;
83 off_t size;
85 intmax_t mtime;
87 dev_t dev;
88
90};
91
92struct tar_archive;
93
94typedef int tar_read_func(struct tar_archive *tar, char *buffer, int length);
95typedef int tar_make_func(struct tar_archive *tar, struct tar_entry *h);
96
99
105};
106
108 /* Global tar archive error. */
110
113
114 /* Operation functions and context. */
115 const struct tar_operations *ops;
116 void *ctx;
117};
118
119uintmax_t
120tar_atoul(const char *s, size_t size, uintmax_t max);
121intmax_t
122tar_atosl(const char *s, size_t size, intmax_t min, intmax_t max);
123
124void
126
127int
128tar_extractor(struct tar_archive *tar);
129
133
134#endif
#define DPKG_BEGIN_DECLS
Definition: macros.h:86
#define min(a, b)
Definition: macros.h:139
#define DPKG_END_DECLS
Definition: macros.h:87
#define max(a, b)
Definition: macros.h:143
uintmax_t tar_atoul(const char *s, size_t size, uintmax_t max)
Definition: tarfn.c:184
tar_format
Definition: tarfn.h:42
void tar_entry_update_from_system(struct tar_entry *te)
Update the tar entry from system information.
Definition: tarfn.c:426
int tar_make_func(struct tar_archive *tar, struct tar_entry *h)
Definition: tarfn.h:95
int tar_extractor(struct tar_archive *tar)
Definition: tarfn.c:444
tar_filetype
Definition: tarfn.h:50
int tar_read_func(struct tar_archive *tar, char *buffer, int length)
Definition: tarfn.h:94
intmax_t tar_atosl(const char *s, size_t size, intmax_t min, intmax_t max)
Definition: tarfn.c:195
@ TAR_FORMAT_GNU
Definition: tarfn.h:45
@ TAR_FORMAT_PAX
Definition: tarfn.h:47
@ TAR_FORMAT_UNKNOWN
Definition: tarfn.h:43
@ TAR_FORMAT_USTAR
Definition: tarfn.h:46
@ TAR_FORMAT_OLD
Definition: tarfn.h:44
@ TAR_FILETYPE_GNU_LONGLINK
Definition: tarfn.h:61
@ TAR_FILETYPE_FIFO
Definition: tarfn.h:59
@ TAR_FILETYPE_GNU_MULTIVOL
Definition: tarfn.h:64
@ TAR_FILETYPE_FILE
Definition: tarfn.h:53
@ TAR_FILETYPE_SOLARIS_ACL
Definition: tarfn.h:70
@ TAR_FILETYPE_GNU_SPARSE
Definition: tarfn.h:66
@ TAR_FILETYPE_HARDLINK
Definition: tarfn.h:54
@ TAR_FILETYPE_SYMLINK
Definition: tarfn.h:55
@ TAR_FILETYPE_PAX_GLOBAL
Definition: tarfn.h:67
@ TAR_FILETYPE_FILE0
For compatibility with decades-old bug.
Definition: tarfn.h:52
@ TAR_FILETYPE_GNU_VOLUME
Definition: tarfn.h:63
@ TAR_FILETYPE_GNU_DUMPDIR
Definition: tarfn.h:65
@ TAR_FILETYPE_DIR
Definition: tarfn.h:58
@ TAR_FILETYPE_CONTIG
Definition: tarfn.h:60
@ TAR_FILETYPE_BLOCKDEV
Definition: tarfn.h:57
@ TAR_FILETYPE_SOLARIS_EXTENDED
Definition: tarfn.h:69
@ TAR_FILETYPE_CHARDEV
Definition: tarfn.h:56
@ TAR_FILETYPE_GNU_LONGNAME
Definition: tarfn.h:62
@ TAR_FILETYPE_PAX_EXTENDED
Definition: tarfn.h:68
Definition: error.h:42
Definition: file.h:40
Definition: tarfn.h:107
const struct tar_operations * ops
Definition: tarfn.h:115
struct dpkg_error err
Definition: tarfn.h:109
void * ctx
Definition: tarfn.h:116
enum tar_format format
Tar archive format.
Definition: tarfn.h:112
Definition: tarfn.h:73
char * name
File name.
Definition: tarfn.h:79
struct file_stat stat
Definition: tarfn.h:89
char * linkname
Symlink or hardlink name.
Definition: tarfn.h:81
intmax_t mtime
Last-modified time.
Definition: tarfn.h:85
enum tar_format format
Tar entry format.
Definition: tarfn.h:75
enum tar_filetype type
File type.
Definition: tarfn.h:77
off_t size
File size.
Definition: tarfn.h:83
dev_t dev
Special device for mknod().
Definition: tarfn.h:87
Definition: tarfn.h:97
tar_make_func * symlink
Definition: tarfn.h:102
tar_make_func * mkdir
Definition: tarfn.h:103
tar_read_func * read
Definition: tarfn.h:98
tar_make_func * extract_file
Definition: tarfn.h:100
tar_make_func * mknod
Definition: tarfn.h:104
tar_make_func * link
Definition: tarfn.h:101