2006-07-03 01:17:05 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
2002-11-05 08:26:57 +05:30
|
|
|
/*
|
|
|
|
* Copyright (C) 2002 by Glenn McGrath
|
|
|
|
*
|
2006-07-12 13:26:04 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
2002-11-05 08:26:57 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libbb.h"
|
|
|
|
#include "unarchive.h"
|
|
|
|
|
2008-07-11 04:36:00 +05:30
|
|
|
/* Built and used only if ENABLE_DPKG || ENABLE_DPKG_DEB */
|
|
|
|
|
2002-11-05 08:26:57 +05:30
|
|
|
/*
|
2006-12-22 06:15:27 +05:30
|
|
|
* Reassign the subarchive metadata parser based on the filename extension
|
|
|
|
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
|
|
|
|
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
|
2002-11-05 08:26:57 +05:30
|
|
|
*/
|
2008-06-27 08:22:20 +05:30
|
|
|
char FAST_FUNC filter_accept_list_reassign(archive_handle_t *archive_handle)
|
2002-11-05 08:26:57 +05:30
|
|
|
{
|
|
|
|
/* Check the file entry is in the accept list */
|
|
|
|
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
|
|
|
|
const char *name_ptr;
|
|
|
|
|
2008-07-11 04:36:00 +05:30
|
|
|
/* Find extension */
|
2002-11-05 08:26:57 +05:30
|
|
|
name_ptr = strrchr(archive_handle->file_header->name, '.');
|
|
|
|
|
|
|
|
/* Modify the subarchive handler based on the extension */
|
2008-07-11 04:36:00 +05:30
|
|
|
if (ENABLE_FEATURE_DEB_TAR_GZ
|
|
|
|
&& strcmp(name_ptr, ".gz") == 0
|
|
|
|
) {
|
2002-11-05 08:26:57 +05:30
|
|
|
archive_handle->action_data_subarchive = get_header_tar_gz;
|
2006-11-27 22:19:31 +05:30
|
|
|
return EXIT_SUCCESS;
|
2002-11-05 08:26:57 +05:30
|
|
|
}
|
2008-07-11 04:36:00 +05:30
|
|
|
if (ENABLE_FEATURE_DEB_TAR_BZ2
|
|
|
|
&& strcmp(name_ptr, ".bz2") == 0
|
|
|
|
) {
|
2003-11-08 03:01:58 +05:30
|
|
|
archive_handle->action_data_subarchive = get_header_tar_bz2;
|
2006-11-27 22:19:31 +05:30
|
|
|
return EXIT_SUCCESS;
|
2002-11-05 08:26:57 +05:30
|
|
|
}
|
2008-07-11 04:36:00 +05:30
|
|
|
if (ENABLE_FEATURE_DEB_TAR_LZMA
|
|
|
|
&& strcmp(name_ptr, ".lzma") == 0
|
|
|
|
) {
|
2006-01-20 23:58:50 +05:30
|
|
|
archive_handle->action_data_subarchive = get_header_tar_lzma;
|
2006-11-27 22:19:31 +05:30
|
|
|
return EXIT_SUCCESS;
|
2006-01-20 23:58:50 +05:30
|
|
|
}
|
2002-11-05 08:26:57 +05:30
|
|
|
}
|
2006-11-27 22:19:31 +05:30
|
|
|
return EXIT_FAILURE;
|
2002-11-05 08:26:57 +05:30
|
|
|
}
|