Changes for kernel and Busybox
[tomato.git] / release / src / router / busybox / archival / libarchive / filter_accept_list_reassign.c
blob3d19abe448f0ebf0203e9b50d4af3f8fc791c583
1 /* vi: set sw=4 ts=4: */
2 /*
3 * Copyright (C) 2002 by Glenn McGrath
5 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
6 */
8 #include "libbb.h"
9 #include "bb_archive.h"
11 /* Built and used only if ENABLE_DPKG || ENABLE_DPKG_DEB */
14 * 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
16 * or if its a .tar.bz2 make archive_handle->sub_archive handle that
18 char FAST_FUNC filter_accept_list_reassign(archive_handle_t *archive_handle)
20 /* Check the file entry is in the accept list */
21 if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
22 const char *name_ptr;
24 /* Find extension */
25 name_ptr = strrchr(archive_handle->file_header->name, '.');
26 if (!name_ptr)
27 return EXIT_FAILURE;
28 name_ptr++;
30 /* Modify the subarchive handler based on the extension */
31 if (ENABLE_FEATURE_SEAMLESS_GZ
32 && strcmp(name_ptr, "gz") == 0
33 ) {
34 archive_handle->dpkg__action_data_subarchive = get_header_tar_gz;
35 return EXIT_SUCCESS;
37 if (ENABLE_FEATURE_SEAMLESS_BZ2
38 && strcmp(name_ptr, "bz2") == 0
39 ) {
40 archive_handle->dpkg__action_data_subarchive = get_header_tar_bz2;
41 return EXIT_SUCCESS;
43 if (ENABLE_FEATURE_SEAMLESS_LZMA
44 && strcmp(name_ptr, "lzma") == 0
45 ) {
46 archive_handle->dpkg__action_data_subarchive = get_header_tar_lzma;
47 return EXIT_SUCCESS;
50 return EXIT_FAILURE;