aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2001-10-13 19:43:46 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2001-10-13 19:43:46 +0000
commit4bef7b41861f02874bce4ac6ab0c8c2484d41d07 (patch)
tree68cc6368c5bdca2b2d34213bc66b978fd7a26b03 /libbb
parent051eee6ed3056145edeee14d7ab4de9e2f723164 (diff)
downloadbusybox-w32-4bef7b41861f02874bce4ac6ab0c8c2484d41d07.tar.gz
busybox-w32-4bef7b41861f02874bce4ac6ab0c8c2484d41d07.tar.bz2
busybox-w32-4bef7b41861f02874bce4ac6ab0c8c2484d41d07.zip
unarchive function changed to support both exclude and include lists, applets that use unarchive changed to match.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/libbb.h4
-rw-r--r--libbb/unarchive.c35
2 files changed, 20 insertions, 19 deletions
diff --git a/libbb/libbb.h b/libbb/libbb.h
index bbdbc6c86..3ef0278f8 100644
--- a/libbb/libbb.h
+++ b/libbb/libbb.h
@@ -245,8 +245,8 @@ enum extract_functions_e {
245 extract_quiet = 2048, 245 extract_quiet = 2048,
246 extract_exclude_list = 4096 246 extract_exclude_list = 4096
247}; 247};
248char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *), 248char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers)(FILE *),
249 const int extract_function, const char *prefix, char **extract_names); 249 const int extract_function, const char *prefix, char **include_name, char **exclude_name);
250char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, 250char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function,
251 const char *prefix, const char *filename); 251 const char *prefix, const char *filename);
252int read_package_field(const char *package_buffer, char **field_name, char **field_value); 252int read_package_field(const char *package_buffer, char **field_name, char **field_value);
diff --git a/libbb/unarchive.c b/libbb/unarchive.c
index 37ab67aff..9c599a415 100644
--- a/libbb/unarchive.c
+++ b/libbb/unarchive.c
@@ -230,35 +230,36 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
230 230
231#ifdef L_unarchive 231#ifdef L_unarchive
232char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers)(FILE *), 232char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers)(FILE *),
233 const int extract_function, const char *prefix, char **extract_names) 233 const int extract_function, const char *prefix, char **include_name, char **exclude_name)
234{ 234{
235 file_header_t *file_entry; 235 file_header_t *file_entry;
236 int extract_flag; 236 int extract_flag = TRUE;
237 int i; 237 int i;
238 char *buffer = NULL; 238 char *buffer = NULL;
239 239
240 archive_offset = 0; 240 archive_offset = 0;
241 while ((file_entry = get_headers(src_stream)) != NULL) { 241 while ((file_entry = get_headers(src_stream)) != NULL) {
242 extract_flag = TRUE; 242
243 if (extract_names != NULL) { 243 if (include_name != NULL) {
244 int found_flag = FALSE; 244 extract_flag = FALSE;
245 for(i = 0; extract_names[i] != 0; i++) { 245 for(i = 0; include_name[i] != 0; i++) {
246 if (fnmatch(extract_names[i], file_entry->name, FNM_LEADING_DIR) == 0) { 246 if (fnmatch(include_name[i], file_entry->name, FNM_LEADING_DIR) == 0) {
247 found_flag = TRUE; 247 extract_flag = TRUE;
248 break; 248 break;
249 } 249 }
250 } 250 }
251 if (extract_function & extract_exclude_list) { 251 } else {
252 if (found_flag == TRUE) { 252 extract_flag = TRUE;
253 extract_flag = FALSE; 253 }
254 } 254
255 } else { 255 /* If the file entry is in the exclude list dont extract it */
256 /* If its not found in the include list dont extract it */ 256 if (exclude_name != NULL) {
257 if (found_flag == FALSE) { 257 for(i = 0; exclude_name[i] != 0; i++) {
258 if (fnmatch(exclude_name[i], file_entry->name, FNM_LEADING_DIR) == 0) {
258 extract_flag = FALSE; 259 extract_flag = FALSE;
260 break;
259 } 261 }
260 } 262 }
261
262 } 263 }
263 264
264 if (extract_flag == TRUE) { 265 if (extract_flag == TRUE) {
@@ -607,7 +608,7 @@ char *deb_extract(const char *package_filename, FILE *out_stream,
607 /* open a stream of decompressed data */ 608 /* open a stream of decompressed data */
608 uncompressed_stream = gz_open(deb_stream, &gunzip_pid); 609 uncompressed_stream = gz_open(deb_stream, &gunzip_pid);
609 archive_offset = 0; 610 archive_offset = 0;
610 output_buffer = unarchive(uncompressed_stream, out_stream, get_header_tar, extract_function, prefix, file_list); 611 output_buffer = unarchive(uncompressed_stream, out_stream, get_header_tar, extract_function, prefix, file_list, NULL);
611 } 612 }
612 seek_sub_file(deb_stream, ar_header->size); 613 seek_sub_file(deb_stream, ar_header->size);
613 free(ar_header->name); 614 free(ar_header->name);