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
|
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2002-11-05 08:26:57 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libbb.h"
|
2010-11-03 07:08:31 +05:30
|
|
|
#include "archive.h"
|
2002-11-05 08:26:57 +05:30
|
|
|
|
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, '.');
|
2008-08-05 18:40:34 +05:30
|
|
|
if (!name_ptr)
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
name_ptr++;
|
2002-11-05 08:26:57 +05:30
|
|
|
|
|
|
|
/* Modify the subarchive handler based on the extension */
|
2008-08-05 18:40:34 +05:30
|
|
|
if (ENABLE_FEATURE_SEAMLESS_GZ
|
|
|
|
&& strcmp(name_ptr, "gz") == 0
|
2008-07-11 04:36:00 +05:30
|
|
|
) {
|
2010-01-06 15:23:17 +05:30
|
|
|
archive_handle->dpkg__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-08-05 18:40:34 +05:30
|
|
|
if (ENABLE_FEATURE_SEAMLESS_BZ2
|
|
|
|
&& strcmp(name_ptr, "bz2") == 0
|
2008-07-11 04:36:00 +05:30
|
|
|
) {
|
2010-01-06 15:23:17 +05:30
|
|
|
archive_handle->dpkg__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-08-05 18:40:34 +05:30
|
|
|
if (ENABLE_FEATURE_SEAMLESS_LZMA
|
|
|
|
&& strcmp(name_ptr, "lzma") == 0
|
2008-07-11 04:36:00 +05:30
|
|
|
) {
|
2010-01-06 15:23:17 +05:30
|
|
|
archive_handle->dpkg__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
|
|
|
}
|