aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2001-07-14 08:49:53 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2001-07-14 08:49:53 +0000
commita868ec89e8272c0cdf27e062785c4b5c6dcf66c5 (patch)
treefe1823623d327a9954d6c09e57c9d42f4fb575b1 /libbb
parent58a5bd187dd69ed9ba761e8ea755fd9ff4e97ce6 (diff)
downloadbusybox-w32-a868ec89e8272c0cdf27e062785c4b5c6dcf66c5.tar.gz
busybox-w32-a868ec89e8272c0cdf27e062785c4b5c6dcf66c5.tar.bz2
busybox-w32-a868ec89e8272c0cdf27e062785c4b5c6dcf66c5.zip
Allow the unarchive() extract_list variable to be NULL, meaning extract all
Diffstat (limited to 'libbb')
-rw-r--r--libbb/unarchive.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/libbb/unarchive.c b/libbb/unarchive.c
index d10e60cbb..78260d2d6 100644
--- a/libbb/unarchive.c
+++ b/libbb/unarchive.c
@@ -232,25 +232,24 @@ char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers
232 int i; 232 int i;
233 char *buffer = NULL; 233 char *buffer = NULL;
234 234
235 if (extract_names == NULL) {
236 return(NULL);
237 }
238 archive_offset = 0; 235 archive_offset = 0;
239 while ((file_entry = get_headers(src_stream)) != NULL) { 236 while ((file_entry = get_headers(src_stream)) != NULL) {
240 found = FALSE; 237 found = FALSE;
241 if (extract_names[0] != NULL) { 238 if (extract_names == NULL) {
239 found = TRUE;
240 } else {
242 for(i = 0; extract_names[i] != 0; i++) { 241 for(i = 0; extract_names[i] != 0; i++) {
243 if (strcmp(extract_names[i], file_entry->name) == 0) { 242 if (strcmp(extract_names[i], file_entry->name) == 0) {
244 found = TRUE; 243 found = TRUE;
245 } 244 }
246 } 245 }
247 if (!found) {
248 /* seek past the data entry */
249 seek_sub_file(src_stream, file_entry->size);
250 continue;
251 }
252 } 246 }
253 buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix); 247 if (found) {
248 buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix);
249 } else {
250 /* seek past the data entry */
251 seek_sub_file(src_stream, file_entry->size);
252 }
254 } 253 }
255 return(buffer); 254 return(buffer);
256} 255}
@@ -544,17 +543,14 @@ char *deb_extract(const char *package_filename, FILE *out_stream,
544 FILE *deb_stream; 543 FILE *deb_stream;
545 FILE *uncompressed_stream = NULL; 544 FILE *uncompressed_stream = NULL;
546 file_header_t *ar_header = NULL; 545 file_header_t *ar_header = NULL;
546 char **file_list = NULL;
547 char *output_buffer = NULL; 547 char *output_buffer = NULL;
548 char *ared_file = NULL; 548 char *ared_file = NULL;
549 char ar_magic[8]; 549 char ar_magic[8];
550 char **file_list;
551 int gunzip_pid; 550 int gunzip_pid;
552 551
553 if (filename == NULL) { 552 if (filename != NULL) {
554 file_list = xmalloc(sizeof(char *)); 553 file_list = xmalloc(sizeof(char *) * 2);
555 file_list[0] = NULL;
556 } else {
557 file_list = xmalloc(sizeof(char *) * 3);
558 file_list[0] = xstrdup(filename); 554 file_list[0] = xstrdup(filename);
559 file_list[1] = NULL; 555 file_list[1] = NULL;
560 } 556 }