2006-07-02 19:47:05 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
2002-11-05 02:56:57 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2002 by Glenn McGrath
|
|
|
|
*
|
2006-07-12 07:56:04 +00:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
2002-11-05 02:56:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libbb.h"
|
|
|
|
#include "unarchive.h"
|
|
|
|
|
|
|
|
/*
|
2006-12-22 00:45:27 +00:00
|
|
|
* 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 02:56:57 +00:00
|
|
|
*/
|
2006-03-06 20:47:33 +00:00
|
|
|
char filter_accept_list_reassign(archive_handle_t *archive_handle)
|
2002-11-05 02:56:57 +00:00
|
|
|
{
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* Extract the last 2 extensions */
|
|
|
|
name_ptr = strrchr(archive_handle->file_header->name, '.');
|
|
|
|
|
|
|
|
/* Modify the subarchive handler based on the extension */
|
2007-08-13 10:36:25 +00:00
|
|
|
#if ENABLE_FEATURE_DEB_TAR_GZ
|
2002-11-05 02:56:57 +00:00
|
|
|
if (strcmp(name_ptr, ".gz") == 0) {
|
|
|
|
archive_handle->action_data_subarchive = get_header_tar_gz;
|
2006-11-27 16:49:31 +00:00
|
|
|
return EXIT_SUCCESS;
|
2002-11-05 02:56:57 +00:00
|
|
|
}
|
|
|
|
#endif
|
2007-08-13 10:36:25 +00:00
|
|
|
#if ENABLE_FEATURE_DEB_TAR_BZ2
|
2002-11-05 02:56:57 +00:00
|
|
|
if (strcmp(name_ptr, ".bz2") == 0) {
|
2003-11-07 21:31:58 +00:00
|
|
|
archive_handle->action_data_subarchive = get_header_tar_bz2;
|
2006-11-27 16:49:31 +00:00
|
|
|
return EXIT_SUCCESS;
|
2002-11-05 02:56:57 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-01-20 18:28:50 +00:00
|
|
|
if (ENABLE_FEATURE_DEB_TAR_LZMA && !strcmp(name_ptr, ".lzma")) {
|
|
|
|
archive_handle->action_data_subarchive = get_header_tar_lzma;
|
2006-11-27 16:49:31 +00:00
|
|
|
return EXIT_SUCCESS;
|
2006-01-20 18:28:50 +00:00
|
|
|
}
|
2002-11-05 02:56:57 +00:00
|
|
|
}
|
2006-11-27 16:49:31 +00:00
|
|
|
return EXIT_FAILURE;
|
2002-11-05 02:56:57 +00:00
|
|
|
}
|