8 |
#include "libbb.h" |
#include "libbb.h" |
9 |
#include "unarchive.h" |
#include "unarchive.h" |
10 |
|
|
11 |
|
/* Built and used only if ENABLE_DPKG || ENABLE_DPKG_DEB */ |
12 |
|
|
13 |
/* |
/* |
14 |
* Reassign the subarchive metadata parser based on the filename extension |
* Reassign the subarchive metadata parser based on the filename extension |
15 |
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz |
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz |
16 |
* or if its a .tar.bz2 make archive_handle->sub_archive handle that |
* or if its a .tar.bz2 make archive_handle->sub_archive handle that |
17 |
*/ |
*/ |
18 |
char filter_accept_list_reassign(archive_handle_t *archive_handle) |
char FAST_FUNC filter_accept_list_reassign(archive_handle_t *archive_handle) |
19 |
{ |
{ |
20 |
/* Check the file entry is in the accept list */ |
/* Check the file entry is in the accept list */ |
21 |
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) { |
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) { |
22 |
const char *name_ptr; |
const char *name_ptr; |
23 |
|
|
24 |
/* Extract the last 2 extensions */ |
/* Find extension */ |
25 |
name_ptr = strrchr(archive_handle->file_header->name, '.'); |
name_ptr = strrchr(archive_handle->file_header->name, '.'); |
26 |
|
if (!name_ptr) |
27 |
|
return EXIT_FAILURE; |
28 |
|
name_ptr++; |
29 |
|
|
30 |
/* Modify the subarchive handler based on the extension */ |
/* Modify the subarchive handler based on the extension */ |
31 |
#ifdef CONFIG_FEATURE_DEB_TAR_GZ |
if (ENABLE_FEATURE_SEAMLESS_GZ |
32 |
if (strcmp(name_ptr, ".gz") == 0) { |
&& strcmp(name_ptr, "gz") == 0 |
33 |
|
) { |
34 |
archive_handle->action_data_subarchive = get_header_tar_gz; |
archive_handle->action_data_subarchive = get_header_tar_gz; |
35 |
return EXIT_SUCCESS; |
return EXIT_SUCCESS; |
36 |
} |
} |
37 |
#endif |
if (ENABLE_FEATURE_SEAMLESS_BZ2 |
38 |
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 |
&& strcmp(name_ptr, "bz2") == 0 |
39 |
if (strcmp(name_ptr, ".bz2") == 0) { |
) { |
40 |
archive_handle->action_data_subarchive = get_header_tar_bz2; |
archive_handle->action_data_subarchive = get_header_tar_bz2; |
41 |
return EXIT_SUCCESS; |
return EXIT_SUCCESS; |
42 |
} |
} |
43 |
#endif |
if (ENABLE_FEATURE_SEAMLESS_LZMA |
44 |
if (ENABLE_FEATURE_DEB_TAR_LZMA && !strcmp(name_ptr, ".lzma")) { |
&& strcmp(name_ptr, "lzma") == 0 |
45 |
|
) { |
46 |
archive_handle->action_data_subarchive = get_header_tar_lzma; |
archive_handle->action_data_subarchive = get_header_tar_lzma; |
47 |
return EXIT_SUCCESS; |
return EXIT_SUCCESS; |
48 |
} |
} |