diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2001-07-14 08:49:53 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2001-07-14 08:49:53 +0000 |
commit | a868ec89e8272c0cdf27e062785c4b5c6dcf66c5 (patch) | |
tree | fe1823623d327a9954d6c09e57c9d42f4fb575b1 /archival | |
parent | 58a5bd187dd69ed9ba761e8ea755fd9ff4e97ce6 (diff) | |
download | busybox-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 'archival')
-rw-r--r-- | archival/ar.c | 10 | ||||
-rw-r--r-- | archival/cpio.c | 15 |
2 files changed, 14 insertions, 11 deletions
diff --git a/archival/ar.c b/archival/ar.c index 2a764ff5e..7f3396c8c 100644 --- a/archival/ar.c +++ b/archival/ar.c | |||
@@ -70,17 +70,17 @@ extern int ar_main(int argc, char **argv) | |||
70 | 70 | ||
71 | /* check ar magic */ | 71 | /* check ar magic */ |
72 | fread(ar_magic, 1, 8, src_stream); | 72 | fread(ar_magic, 1, 8, src_stream); |
73 | archive_offset = 8; | ||
73 | if (strncmp(ar_magic,"!<arch>",7) != 0) { | 74 | if (strncmp(ar_magic,"!<arch>",7) != 0) { |
74 | error_msg_and_die("invalid magic"); | 75 | error_msg_and_die("invalid magic"); |
75 | } | 76 | } |
76 | archive_offset = 8; | ||
77 | 77 | ||
78 | extract_names = malloc(sizeof(char *)); | 78 | /* Create a list of files to extract */ |
79 | extract_names[0] = NULL; | ||
80 | while (optind < argc) { | 79 | while (optind < argc) { |
80 | extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2)); | ||
81 | extract_names[num_of_entries] = xstrdup(argv[optind]); | ||
81 | num_of_entries++; | 82 | num_of_entries++; |
82 | *extract_names = realloc(*extract_names, num_of_entries); | 83 | extract_names[num_of_entries] = NULL; |
83 | extract_names[num_of_entries - 1] = xstrdup(argv[optind]); | ||
84 | optind++; | 84 | optind++; |
85 | } | 85 | } |
86 | 86 | ||
diff --git a/archival/cpio.c b/archival/cpio.c index 12a4340bd..7f68715eb 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -68,25 +68,28 @@ extern int cpio_main(int argc, char **argv) | |||
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | if (extract_function & extract_all_to_fs && extract_function & extract_list) { | 71 | if ((extract_function & extract_all_to_fs) && (extract_function & extract_list)) { |
72 | extract_function ^= extract_all_to_fs; /* If specify t, don't extract*/ | 72 | extract_function ^= extract_all_to_fs; /* If specify t, don't extract*/ |
73 | } | 73 | } |
74 | 74 | ||
75 | if (extract_function & extract_all_to_fs && extract_function & extract_verbose_list) { /* The meaning of v changes on extract */ | 75 | if ((extract_function & extract_all_to_fs) && (extract_function & extract_verbose_list)) { |
76 | /* The meaning of v changes on extract */ | ||
76 | extract_function ^= extract_verbose_list; | 77 | extract_function ^= extract_verbose_list; |
77 | extract_function |= extract_list; | 78 | extract_function |= extract_list; |
78 | } | 79 | } |
79 | 80 | ||
80 | extract_names = malloc(4); | ||
81 | while (optind < argc) { | 81 | while (optind < argc) { |
82 | extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2)); | ||
83 | extract_names[num_of_entries] = xstrdup(argv[optind]); | ||
82 | num_of_entries++; | 84 | num_of_entries++; |
83 | *extract_names = realloc(*extract_names, num_of_entries); | 85 | extract_names[num_of_entries] = NULL; |
84 | extract_names[num_of_entries - 1] = xstrdup(argv[optind]); | ||
85 | optind++; | 86 | optind++; |
86 | } | 87 | } |
87 | 88 | ||
88 | unarchive(src_stream, stdout, &get_header_cpio, extract_function, "./", extract_names); | 89 | unarchive(src_stream, stdout, &get_header_cpio, extract_function, "./", extract_names); |
89 | if (oldmask) umask(oldmask); /* Restore umask if we changed it */ | 90 | if (oldmask) { |
91 | umask(oldmask); /* Restore umask if we changed it */ | ||
92 | } | ||
90 | return EXIT_SUCCESS; | 93 | return EXIT_SUCCESS; |
91 | } | 94 | } |
92 | 95 | ||