aboutsummaryrefslogtreecommitdiff
path: root/include/unarchive.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/unarchive.h')
-rw-r--r--include/unarchive.h109
1 files changed, 77 insertions, 32 deletions
diff --git a/include/unarchive.h b/include/unarchive.h
index ffddc89f4..e564e9572 100644
--- a/include/unarchive.h
+++ b/include/unarchive.h
@@ -1,21 +1,19 @@
1#include <stdio.h> /* for FILE */ 1#ifndef __UNARCHIVE_H__
2#include <unistd.h> /* for off_t */ 2#define __UNARCHIVE_H__
3 3
4enum extract_functions_e { 4#define ARCHIVE_PRESERVE_DATE 1
5 extract_verbose_list = 1, 5#define ARCHIVE_CREATE_LEADING_DIRS 2
6 extract_list = 2, 6#define ARCHIVE_EXTRACT_UNCONDITIONAL 4
7 extract_one_to_buffer = 4, 7#define ARCHIVE_EXTRACT_QUIET 8
8 extract_to_stdout = 8, 8
9 extract_all_to_fs = 16, 9#include <sys/types.h>
10 extract_preserve_date = 32, 10
11 extract_data_tar_gz = 64, 11typedef struct gunzip_s {
12 extract_control_tar_gz = 128, 12 unsigned short buffer_count;
13 extract_unzip_only = 256, 13 unsigned char *buffer;
14 extract_unconditional = 512, 14 unsigned int crc;
15 extract_create_leading_dirs = 1024, 15 unsigned int count;
16 extract_quiet = 2048, 16} gunzip_t;
17 extract_exclude_list = 4096
18};
19 17
20typedef struct file_headers_s { 18typedef struct file_headers_s {
21 char *name; 19 char *name;
@@ -26,23 +24,70 @@ typedef struct file_headers_s {
26 mode_t mode; 24 mode_t mode;
27 time_t mtime; 25 time_t mtime;
28 dev_t device; 26 dev_t device;
29 int (*extract_func) (FILE *, FILE *);
30} file_header_t; 27} file_header_t;
31 28
32file_header_t *get_header_ar(FILE * in_file); 29typedef struct llist_s {
33file_header_t *get_header_cpio(FILE * src_stream); 30 const char *data;
34file_header_t *get_header_tar(FILE * tar_stream); 31 const struct llist_s *link;
35file_header_t *get_header_zip(FILE * zip_stream); 32} llist_t;
33
34typedef struct archive_handle_s {
35 /* define if the header and data compenent should processed */
36 char (*filter)(const llist_t *, const llist_t *, const char *);
37 const llist_t *accept;
38 const llist_t *reject;
39
40 /* Contains the processed header entry */
41 file_header_t *file_header;
42
43 /* process the header component, e.g. tar -t */
44 void (*action_header)(const file_header_t *);
45
46 /* process the data componenet, e.g. extract to filesystem */
47 void (*action_data)(struct archive_handle_s *);
48 char (*action_data_subarchive)(struct archive_handle_s *);
49
50 /* Contains the handle to a sub archive */
51 struct archive_handle_s *sub_archive;
52
53 /* The raw stream as read from disk or stdin */
54 int src_fd;
55
56 /* Count the number of bytes processed */
57 off_t offset;
58
59 /* Misc. stuff */
60 unsigned char flags;
61
62} archive_handle_t;
63
64extern archive_handle_t *init_handle(void);
65
66extern char filter_accept_all(const llist_t *accept_list, const llist_t *reject_list, const char *key);
67extern char filter_accept_list(const llist_t *accept_list, const llist_t *reject_list, const char *key);
68extern char filter_accept_reject_list(const llist_t *accept_list, const llist_t *reject_list, const char *key);
69
70extern void unpack_ar_archive(archive_handle_t *ar_archive);
71
72extern void data_gunzip(archive_handle_t *archive_handle);
73extern void data_skip(archive_handle_t *archive_handle);
74extern void data_extract_all(archive_handle_t *archive_handle);
75extern void data_extract_to_stdout(archive_handle_t *archive_handle);
76
77extern void header_skip(const file_header_t *file_header);
78extern void header_list(const file_header_t *file_header);
79extern void header_verbose_list(const file_header_t *file_header);
36 80
37void seek_sub_file(FILE * src_stream, const int count); 81extern void check_header_gzip(int src_fd);
82extern void check_trailer_gzip(int src_fd);
38 83
39extern off_t archive_offset; 84extern char get_header_ar(archive_handle_t *archive_handle);
85extern char get_header_tar(archive_handle_t *archive_handle);
86extern char get_header_tar_gz(archive_handle_t *archive_handle);
40 87
41char *unarchive(FILE * src_stream, FILE * out_stream, 88//extern void seek_sub_file(int src_fd, unsigned int amount);
42 file_header_t * (*get_headers) (FILE *), 89extern const unsigned short data_align(const int src_fd, const unsigned int offset, const unsigned short align_to);
43 const int extract_function, const char *prefix, 90extern const llist_t *add_to_list(const llist_t *old_head, const char *new_item);
44 char **include_name, char **exclude_name); 91extern int copy_file_chunk_fd(int src_fd, int dst_fd, unsigned long long chunksize);
45 92
46char *deb_extract(const char *package_filename, FILE * out_stream, 93#endif
47 const int extract_function, const char *prefix,
48 const char *filename);