1 #ifndef __UNARCHIVE_H__
2 #define __UNARCHIVE_H__
4 #define ARCHIVE_PRESERVE_DATE 1
5 #define ARCHIVE_CREATE_LEADING_DIRS 2
6 #define ARCHIVE_EXTRACT_UNCONDITIONAL 4
7 #define ARCHIVE_EXTRACT_QUIET 8
11 typedef struct gunzip_s {
12 unsigned short buffer_count;
13 unsigned char *buffer;
18 typedef struct file_headers_s {
29 typedef struct llist_s {
31 const struct llist_s *link;
34 typedef 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 const llist_t *passed; /* List of files that have successfully been worked on */
41 /* Contains the processed header entry */
42 file_header_t *file_header;
44 /* process the header component, e.g. tar -t */
45 void (*action_header)(const file_header_t *);
47 /* process the data componenet, e.g. extract to filesystem */
48 void (*action_data)(struct archive_handle_s *);
49 char (*action_data_subarchive)(struct archive_handle_s *);
51 /* Contains the handle to a sub archive */
52 struct archive_handle_s *sub_archive;
54 /* The raw stream as read from disk or stdin */
57 /* Count the number of bytes processed */
65 extern archive_handle_t *init_handle(void);
67 extern char filter_accept_all(const llist_t *accept_list, const llist_t *reject_list, const char *key);
68 extern char filter_accept_list(const llist_t *accept_list, const llist_t *reject_list, const char *key);
69 extern char filter_accept_reject_list(const llist_t *accept_list, const llist_t *reject_list, const char *key);
71 extern void unpack_ar_archive(archive_handle_t *ar_archive);
73 extern void data_gunzip(archive_handle_t *archive_handle);
74 extern void data_skip(archive_handle_t *archive_handle);
75 extern void data_extract_all(archive_handle_t *archive_handle);
76 extern void data_extract_to_stdout(archive_handle_t *archive_handle);
78 extern void header_skip(const file_header_t *file_header);
79 extern void header_list(const file_header_t *file_header);
80 extern void header_verbose_list(const file_header_t *file_header);
82 extern void check_header_gzip(int src_fd);
83 extern void check_trailer_gzip(int src_fd);
85 extern char get_header_ar(archive_handle_t *archive_handle);
86 extern char get_header_tar(archive_handle_t *archive_handle);
87 extern char get_header_tar_gz(archive_handle_t *archive_handle);
89 extern void seek_sub_file(int src_fd, unsigned int amount);
90 extern const unsigned short data_align(const int src_fd, const unsigned int offset, const unsigned short align_to);
91 extern const llist_t *add_to_list(const llist_t *old_head, const char *new_item);
92 extern int copy_file_chunk_fd(int src_fd, int dst_fd, unsigned long long chunksize);
93 extern const llist_t *find_list_entry(const llist_t *list, const char *filename);