aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-06 10:53:17 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-06 10:53:17 +0100
commitaa4977d8e549d9fff2b2946f03d304e435eb20f1 (patch)
treebc7c7fe4ab64263a9f8356762cb8f7e77165de73
parent86350f8d5f5d5a1006cffe0bedccd625f012702f (diff)
downloadbusybox-w32-aa4977d8e549d9fff2b2946f03d304e435eb20f1.tar.gz
busybox-w32-aa4977d8e549d9fff2b2946f03d304e435eb20f1.tar.bz2
busybox-w32-aa4977d8e549d9fff2b2946f03d304e435eb20f1.zip
libunarchive: clean up dirty hacks. code shrank as a result
function old new delta cpio_main 526 539 +13 init_handle 57 58 +1 init_archive_deb_ar 34 35 +1 get_header_ar 408 409 +1 dpkg_main 3900 3901 +1 unpack_package 516 515 -1 rpm_main 1673 1672 -1 tar_main 774 767 -7 get_header_cpio 990 972 -18 data_extract_all 750 727 -23 get_header_tar 1631 1576 -55 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/6 up/down: 17/-105) Total: -88 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--archival/cpio.c6
-rw-r--r--archival/dpkg.c40
-rw-r--r--archival/dpkg_deb.c2
-rw-r--r--archival/libunarchive/data_extract_all.c8
-rw-r--r--archival/libunarchive/filter_accept_list_reassign.c6
-rw-r--r--archival/libunarchive/get_header_ar.c4
-rw-r--r--archival/libunarchive/get_header_cpio.c37
-rw-r--r--archival/libunarchive/get_header_tar.c29
-rw-r--r--archival/libunarchive/header_verbose_list.c4
-rw-r--r--include/unarchive.h61
10 files changed, 95 insertions, 102 deletions
diff --git a/archival/cpio.c b/archival/cpio.c
index 067d6e88d..b21ba6e79 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -412,14 +412,14 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
412 } 412 }
413 413
414 /* see get_header_cpio */ 414 /* see get_header_cpio */
415 archive_handle->ah_priv[2] = (void*) ~(ptrdiff_t)0; 415 archive_handle->cpio__blocks = (off_t)-1;
416 while (get_header_cpio(archive_handle) == EXIT_SUCCESS) 416 while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
417 continue; 417 continue;
418 418
419 if (archive_handle->ah_priv[2] != (void*) ~(ptrdiff_t)0 419 if (archive_handle->cpio__blocks != (off_t)-1
420 && !(opt & CPIO_OPT_QUIET) 420 && !(opt & CPIO_OPT_QUIET)
421 ) 421 )
422 printf("%lu blocks\n", (unsigned long)(ptrdiff_t)(archive_handle->ah_priv[2])); 422 printf("%"OFF_FMT"u blocks\n", archive_handle->cpio__blocks);
423 423
424 return EXIT_SUCCESS; 424 return EXIT_SUCCESS;
425} 425}
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 2e24541bf..616bce977 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -1446,7 +1446,7 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
1446#endif 1446#endif
1447 1447
1448 /* Assign the tar handle as a subarchive of the ar handle */ 1448 /* Assign the tar handle as a subarchive of the ar handle */
1449 ar_handle->sub_archive = tar_handle; 1449 ar_handle->dpkg__sub_archive = tar_handle;
1450} 1450}
1451 1451
1452static void init_archive_deb_data(archive_handle_t *ar_handle) 1452static void init_archive_deb_data(archive_handle_t *ar_handle)
@@ -1466,27 +1466,27 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
1466#endif 1466#endif
1467 1467
1468 /* Assign the tar handle as a subarchive of the ar handle */ 1468 /* Assign the tar handle as a subarchive of the ar handle */
1469 ar_handle->sub_archive = tar_handle; 1469 ar_handle->dpkg__sub_archive = tar_handle;
1470} 1470}
1471 1471
1472static void FAST_FUNC data_extract_to_buffer(archive_handle_t *archive_handle) 1472static void FAST_FUNC data_extract_to_buffer(archive_handle_t *archive_handle)
1473{ 1473{
1474 unsigned size = archive_handle->file_header->size; 1474 unsigned size = archive_handle->file_header->size;
1475 1475
1476 archive_handle->ah_buffer = xzalloc(size + 1); 1476 archive_handle->dpkg__buffer = xzalloc(size + 1);
1477 xread(archive_handle->src_fd, archive_handle->ah_buffer, size); 1477 xread(archive_handle->src_fd, archive_handle->dpkg__buffer, size);
1478} 1478}
1479 1479
1480static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, llist_t *myaccept) 1480static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, llist_t *myaccept)
1481{ 1481{
1482 ar_handle->sub_archive->action_data = data_extract_to_buffer; 1482 ar_handle->dpkg__sub_archive->action_data = data_extract_to_buffer;
1483 ar_handle->sub_archive->accept = myaccept; 1483 ar_handle->dpkg__sub_archive->accept = myaccept;
1484 ar_handle->sub_archive->filter = filter_accept_list; 1484 ar_handle->dpkg__sub_archive->filter = filter_accept_list;
1485 1485
1486 unpack_ar_archive(ar_handle); 1486 unpack_ar_archive(ar_handle);
1487 close(ar_handle->src_fd); 1487 close(ar_handle->src_fd);
1488 1488
1489 return ar_handle->sub_archive->ah_buffer; 1489 return ar_handle->dpkg__sub_archive->dpkg__buffer;
1490} 1490}
1491 1491
1492static void FAST_FUNC data_extract_all_prefix(archive_handle_t *archive_handle) 1492static void FAST_FUNC data_extract_all_prefix(archive_handle_t *archive_handle)
@@ -1495,7 +1495,7 @@ static void FAST_FUNC data_extract_all_prefix(archive_handle_t *archive_handle)
1495 1495
1496 name_ptr += strspn(name_ptr, "./"); 1496 name_ptr += strspn(name_ptr, "./");
1497 if (name_ptr[0] != '\0') { 1497 if (name_ptr[0] != '\0') {
1498 archive_handle->file_header->name = xasprintf("%s%s", archive_handle->ah_buffer, name_ptr); 1498 archive_handle->file_header->name = xasprintf("%s%s", archive_handle->dpkg__buffer, name_ptr);
1499 data_extract_all(archive_handle); 1499 data_extract_all(archive_handle);
1500 } 1500 }
1501} 1501}
@@ -1535,11 +1535,11 @@ static void unpack_package(deb_file_t *deb_file)
1535 llist_add_to(&accept_list, c); 1535 llist_add_to(&accept_list, c);
1536 i++; 1536 i++;
1537 } 1537 }
1538 archive_handle->sub_archive->accept = accept_list; 1538 archive_handle->dpkg__sub_archive->accept = accept_list;
1539 archive_handle->sub_archive->filter = filter_accept_list; 1539 archive_handle->dpkg__sub_archive->filter = filter_accept_list;
1540 archive_handle->sub_archive->action_data = data_extract_all_prefix; 1540 archive_handle->dpkg__sub_archive->action_data = data_extract_all_prefix;
1541 archive_handle->sub_archive->ah_buffer = info_prefix; 1541 archive_handle->dpkg__sub_archive->dpkg__buffer = info_prefix;
1542 archive_handle->sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD; 1542 archive_handle->dpkg__sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD;
1543 unpack_ar_archive(archive_handle); 1543 unpack_ar_archive(archive_handle);
1544 1544
1545 /* Run the preinst prior to extracting */ 1545 /* Run the preinst prior to extracting */
@@ -1548,19 +1548,19 @@ static void unpack_package(deb_file_t *deb_file)
1548 /* Extract data.tar.gz to the root directory */ 1548 /* Extract data.tar.gz to the root directory */
1549 archive_handle = init_archive_deb_ar(deb_file->filename); 1549 archive_handle = init_archive_deb_ar(deb_file->filename);
1550 init_archive_deb_data(archive_handle); 1550 init_archive_deb_data(archive_handle);
1551 archive_handle->sub_archive->action_data = data_extract_all_prefix; 1551 archive_handle->dpkg__sub_archive->action_data = data_extract_all_prefix;
1552 archive_handle->sub_archive->ah_buffer = (char*)"/"; /* huh? */ 1552 archive_handle->dpkg__sub_archive->dpkg__buffer = (char*)"/"; /* huh? */
1553 archive_handle->sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD; 1553 archive_handle->dpkg__sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD;
1554 unpack_ar_archive(archive_handle); 1554 unpack_ar_archive(archive_handle);
1555 1555
1556 /* Create the list file */ 1556 /* Create the list file */
1557 list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list"); 1557 list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
1558 out_stream = xfopen_for_write(list_filename); 1558 out_stream = xfopen_for_write(list_filename);
1559 while (archive_handle->sub_archive->passed) { 1559 while (archive_handle->dpkg__sub_archive->passed) {
1560 /* the leading . has been stripped by data_extract_all_prefix already */ 1560 /* the leading . has been stripped by data_extract_all_prefix already */
1561 fputs(archive_handle->sub_archive->passed->data, out_stream); 1561 fputs(archive_handle->dpkg__sub_archive->passed->data, out_stream);
1562 fputc('\n', out_stream); 1562 fputc('\n', out_stream);
1563 archive_handle->sub_archive->passed = archive_handle->sub_archive->passed->link; 1563 archive_handle->dpkg__sub_archive->passed = archive_handle->dpkg__sub_archive->passed->link;
1564 } 1564 }
1565 fclose(out_stream); 1565 fclose(out_stream);
1566 1566
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index f94c90c55..cfbd78420 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -28,7 +28,7 @@ int dpkg_deb_main(int argc, char **argv)
28 28
29 /* Setup an ar archive handle that refers to the gzip sub archive */ 29 /* Setup an ar archive handle that refers to the gzip sub archive */
30 ar_archive = init_handle(); 30 ar_archive = init_handle();
31 ar_archive->sub_archive = tar_archive; 31 ar_archive->dpkg__sub_archive = tar_archive;
32 ar_archive->filter = filter_accept_list_reassign; 32 ar_archive->filter = filter_accept_list_reassign;
33 33
34#if ENABLE_FEATURE_SEAMLESS_GZ 34#if ENABLE_FEATURE_SEAMLESS_GZ
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index 874d37d94..58b05335b 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -127,13 +127,13 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
127 uid_t uid = file_header->uid; 127 uid_t uid = file_header->uid;
128 gid_t gid = file_header->gid; 128 gid_t gid = file_header->gid;
129 129
130 if (file_header->uname) { 130 if (file_header->tar__uname) {
131//TODO: cache last name/id pair? 131//TODO: cache last name/id pair?
132 struct passwd *pwd = getpwnam(file_header->uname); 132 struct passwd *pwd = getpwnam(file_header->tar__uname);
133 if (pwd) uid = pwd->pw_uid; 133 if (pwd) uid = pwd->pw_uid;
134 } 134 }
135 if (file_header->gname) { 135 if (file_header->tar__gname) {
136 struct group *grp = getgrnam(file_header->gname); 136 struct group *grp = getgrnam(file_header->tar__gname);
137 if (grp) gid = grp->gr_gid; 137 if (grp) gid = grp->gr_gid;
138 } 138 }
139 /* GNU tar 1.15.1 uses chown, not lchown */ 139 /* GNU tar 1.15.1 uses chown, not lchown */
diff --git a/archival/libunarchive/filter_accept_list_reassign.c b/archival/libunarchive/filter_accept_list_reassign.c
index f1de4e803..060a2c72b 100644
--- a/archival/libunarchive/filter_accept_list_reassign.c
+++ b/archival/libunarchive/filter_accept_list_reassign.c
@@ -31,19 +31,19 @@ char FAST_FUNC filter_accept_list_reassign(archive_handle_t *archive_handle)
31 if (ENABLE_FEATURE_SEAMLESS_GZ 31 if (ENABLE_FEATURE_SEAMLESS_GZ
32 && strcmp(name_ptr, "gz") == 0 32 && strcmp(name_ptr, "gz") == 0
33 ) { 33 ) {
34 archive_handle->action_data_subarchive = get_header_tar_gz; 34 archive_handle->dpkg__action_data_subarchive = get_header_tar_gz;
35 return EXIT_SUCCESS; 35 return EXIT_SUCCESS;
36 } 36 }
37 if (ENABLE_FEATURE_SEAMLESS_BZ2 37 if (ENABLE_FEATURE_SEAMLESS_BZ2
38 && strcmp(name_ptr, "bz2") == 0 38 && strcmp(name_ptr, "bz2") == 0
39 ) { 39 ) {
40 archive_handle->action_data_subarchive = get_header_tar_bz2; 40 archive_handle->dpkg__action_data_subarchive = get_header_tar_bz2;
41 return EXIT_SUCCESS; 41 return EXIT_SUCCESS;
42 } 42 }
43 if (ENABLE_FEATURE_SEAMLESS_LZMA 43 if (ENABLE_FEATURE_SEAMLESS_LZMA
44 && strcmp(name_ptr, "lzma") == 0 44 && strcmp(name_ptr, "lzma") == 0
45 ) { 45 ) {
46 archive_handle->action_data_subarchive = get_header_tar_lzma; 46 archive_handle->dpkg__action_data_subarchive = get_header_tar_lzma;
47 return EXIT_SUCCESS; 47 return EXIT_SUCCESS;
48 } 48 }
49 } 49 }
diff --git a/archival/libunarchive/get_header_ar.c b/archival/libunarchive/get_header_ar.c
index e6d712d8d..2f38279cc 100644
--- a/archival/libunarchive/get_header_ar.c
+++ b/archival/libunarchive/get_header_ar.c
@@ -122,8 +122,8 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
122 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { 122 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
123 archive_handle->action_header(typed); 123 archive_handle->action_header(typed);
124#if ENABLE_DPKG || ENABLE_DPKG_DEB 124#if ENABLE_DPKG || ENABLE_DPKG_DEB
125 if (archive_handle->sub_archive) { 125 if (archive_handle->dpkg__sub_archive) {
126 while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS) 126 while (archive_handle->dpkg__action_data_subarchive(archive_handle->dpkg__sub_archive) == EXIT_SUCCESS)
127 continue; 127 continue;
128 } else 128 } else
129#endif 129#endif
diff --git a/archival/libunarchive/get_header_cpio.c b/archival/libunarchive/get_header_cpio.c
index 52854dff9..ddc49f70e 100644
--- a/archival/libunarchive/get_header_cpio.c
+++ b/archival/libunarchive/get_header_cpio.c
@@ -25,15 +25,6 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
25 int major, minor, nlink, mode, inode; 25 int major, minor, nlink, mode, inode;
26 unsigned size, uid, gid, mtime; 26 unsigned size, uid, gid, mtime;
27 27
28#define hardlinks_to_create (*(hardlinks_t **)(&archive_handle->ah_priv[0]))
29#define created_hardlinks (*(hardlinks_t **)(&archive_handle->ah_priv[1]))
30#define block_count (archive_handle->ah_priv[2])
31// if (!archive_handle->ah_priv_inited) {
32// archive_handle->ah_priv_inited = 1;
33// hardlinks_to_create = NULL;
34// created_hardlinks = NULL;
35// }
36
37 /* There can be padding before archive header */ 28 /* There can be padding before archive header */
38 data_align(archive_handle, 4); 29 data_align(archive_handle, 4);
39 30
@@ -86,7 +77,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
86 77
87 if (strcmp(file_header->name, "TRAILER!!!") == 0) { 78 if (strcmp(file_header->name, "TRAILER!!!") == 0) {
88 /* Always round up. ">> 9" divides by 512 */ 79 /* Always round up. ">> 9" divides by 512 */
89 block_count = (void*)(ptrdiff_t) ((archive_handle->offset + 511) >> 9); 80 archive_handle->cpio__blocks = (uoff_t)(archive_handle->offset + 511) >> 9;
90 goto create_hardlinks; 81 goto create_hardlinks;
91 } 82 }
92 83
@@ -112,13 +103,13 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
112 strcpy(new->name, file_header->name); 103 strcpy(new->name, file_header->name);
113 /* Put file on a linked list for later */ 104 /* Put file on a linked list for later */
114 if (size == 0) { 105 if (size == 0) {
115 new->next = hardlinks_to_create; 106 new->next = archive_handle->cpio__hardlinks_to_create;
116 hardlinks_to_create = new; 107 archive_handle->cpio__hardlinks_to_create = new;
117 return EXIT_SUCCESS; /* Skip this one */ 108 return EXIT_SUCCESS; /* Skip this one */
118 /* TODO: this breaks cpio -t (it does not show hardlinks) */ 109 /* TODO: this breaks cpio -t (it does not show hardlinks) */
119 } 110 }
120 new->next = created_hardlinks; 111 new->next = archive_handle->cpio__created_hardlinks;
121 created_hardlinks = new; 112 archive_handle->cpio__created_hardlinks = new;
122 } 113 }
123 file_header->device = makedev(major, minor); 114 file_header->device = makedev(major, minor);
124 115
@@ -142,11 +133,11 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
142 free(file_header->link_target); 133 free(file_header->link_target);
143 free(file_header->name); 134 free(file_header->name);
144 135
145 while (hardlinks_to_create) { 136 while (archive_handle->cpio__hardlinks_to_create) {
146 hardlinks_t *cur; 137 hardlinks_t *cur;
147 hardlinks_t *make_me = hardlinks_to_create; 138 hardlinks_t *make_me = archive_handle->cpio__hardlinks_to_create;
148 139
149 hardlinks_to_create = make_me->next; 140 archive_handle->cpio__hardlinks_to_create = make_me->next;
150 141
151 memset(file_header, 0, sizeof(*file_header)); 142 memset(file_header, 0, sizeof(*file_header));
152 file_header->mtime = make_me->mtime; 143 file_header->mtime = make_me->mtime;
@@ -158,7 +149,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
158 /*file_header->link_target = NULL;*/ 149 /*file_header->link_target = NULL;*/
159 150
160 /* Try to find a file we are hardlinked to */ 151 /* Try to find a file we are hardlinked to */
161 cur = created_hardlinks; 152 cur = archive_handle->cpio__created_hardlinks;
162 while (cur) { 153 while (cur) {
163 /* TODO: must match maj/min too! */ 154 /* TODO: must match maj/min too! */
164 if (cur->inode == make_me->inode) { 155 if (cur->inode == make_me->inode) {
@@ -176,14 +167,14 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
176 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) 167 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
177 archive_handle->action_data(archive_handle); 168 archive_handle->action_data(archive_handle);
178 /* Move to the list of created hardlinked files */ 169 /* Move to the list of created hardlinked files */
179 make_me->next = created_hardlinks; 170 make_me->next = archive_handle->cpio__created_hardlinks;
180 created_hardlinks = make_me; 171 archive_handle->cpio__created_hardlinks = make_me;
181 next_link: ; 172 next_link: ;
182 } 173 }
183 174
184 while (created_hardlinks) { 175 while (archive_handle->cpio__created_hardlinks) {
185 hardlinks_t *p = created_hardlinks; 176 hardlinks_t *p = archive_handle->cpio__created_hardlinks;
186 created_hardlinks = p->next; 177 archive_handle->cpio__created_hardlinks = p->next;
187 free(p); 178 free(p);
188 } 179 }
189 180
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index 1f799277b..982404d14 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -135,20 +135,13 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
135 int parse_names; 135 int parse_names;
136 136
137 /* Our "private data" */ 137 /* Our "private data" */
138#define p_end (*(smallint *)(&archive_handle->ah_priv[0]))
139#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS 138#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
140#define p_longname (*(char* *)(&archive_handle->ah_priv[1])) 139# define p_longname (archive_handle->tar__longname)
141#define p_linkname (*(char* *)(&archive_handle->ah_priv[2])) 140# define p_linkname (archive_handle->tar__linkname)
142#else 141#else
143#define p_longname 0 142# define p_longname 0
144#define p_linkname 0 143# define p_linkname 0
145#endif 144#endif
146// if (!archive_handle->ah_priv_inited) {
147// archive_handle->ah_priv_inited = 1;
148// p_end = 0;
149// IF_FEATURE_TAR_GNU_EXTENSIONS(p_longname = NULL;)
150// IF_FEATURE_TAR_GNU_EXTENSIONS(p_linkname = NULL;)
151// }
152 145
153 if (sizeof(tar) != 512) 146 if (sizeof(tar) != 512)
154 BUG_tar_header_size(); 147 BUG_tar_header_size();
@@ -190,7 +183,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
190 183
191 /* If there is no filename its an empty header */ 184 /* If there is no filename its an empty header */
192 if (tar.name[0] == 0 && tar.prefix[0] == 0) { 185 if (tar.name[0] == 0 && tar.prefix[0] == 0) {
193 if (p_end) { 186 if (archive_handle->tar__end) {
194 /* Second consecutive empty header - end of archive. 187 /* Second consecutive empty header - end of archive.
195 * Read until the end to empty the pipe from gz or bz2 188 * Read until the end to empty the pipe from gz or bz2
196 */ 189 */
@@ -198,10 +191,10 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
198 continue; 191 continue;
199 return EXIT_FAILURE; 192 return EXIT_FAILURE;
200 } 193 }
201 p_end = 1; 194 archive_handle->tar__end = 1;
202 return EXIT_SUCCESS; 195 return EXIT_SUCCESS;
203 } 196 }
204 p_end = 0; 197 archive_handle->tar__end = 0;
205 198
206 /* Check header has valid magic, "ustar" is for the proper tar, 199 /* Check header has valid magic, "ustar" is for the proper tar,
207 * five NULs are for the old tar format */ 200 * five NULs are for the old tar format */
@@ -301,8 +294,8 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
301 /* Will link_target be free()ed? */ 294 /* Will link_target be free()ed? */
302 } 295 }
303#if ENABLE_FEATURE_TAR_UNAME_GNAME 296#if ENABLE_FEATURE_TAR_UNAME_GNAME
304 file_header->uname = tar.uname[0] ? xstrndup(tar.uname, sizeof(tar.uname)) : NULL; 297 file_header->tar__uname = tar.uname[0] ? xstrndup(tar.uname, sizeof(tar.uname)) : NULL;
305 file_header->gname = tar.gname[0] ? xstrndup(tar.gname, sizeof(tar.gname)) : NULL; 298 file_header->tar__gname = tar.gname[0] ? xstrndup(tar.gname, sizeof(tar.gname)) : NULL;
306#endif 299#endif
307 /* mtime: rudimentally handle GNU tar's "base256 encoding" 300 /* mtime: rudimentally handle GNU tar's "base256 encoding"
308 * People report tarballs with NEGATIVE unix times encoded that way */ 301 * People report tarballs with NEGATIVE unix times encoded that way */
@@ -449,8 +442,8 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
449 free(file_header->link_target); 442 free(file_header->link_target);
450 /* Do not free(file_header->name)! (why?) */ 443 /* Do not free(file_header->name)! (why?) */
451#if ENABLE_FEATURE_TAR_UNAME_GNAME 444#if ENABLE_FEATURE_TAR_UNAME_GNAME
452 free(file_header->uname); 445 free(file_header->tar__uname);
453 free(file_header->gname); 446 free(file_header->tar__gname);
454#endif 447#endif
455 return EXIT_SUCCESS; 448 return EXIT_SUCCESS;
456} 449}
diff --git a/archival/libunarchive/header_verbose_list.c b/archival/libunarchive/header_verbose_list.c
index 102cd9e11..da21a15af 100644
--- a/archival/libunarchive/header_verbose_list.c
+++ b/archival/libunarchive/header_verbose_list.c
@@ -16,12 +16,12 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
16 char *user; 16 char *user;
17 char *group; 17 char *group;
18 18
19 user = file_header->uname; 19 user = file_header->tar__uname;
20 if (user == NULL) { 20 if (user == NULL) {
21 sprintf(uid, "%u", (unsigned)file_header->uid); 21 sprintf(uid, "%u", (unsigned)file_header->uid);
22 user = uid; 22 user = uid;
23 } 23 }
24 group = file_header->gname; 24 group = file_header->tar__gname;
25 if (group == NULL) { 25 if (group == NULL) {
26 /*sprintf(gid, "%u", (unsigned)file_header->gid);*/ 26 /*sprintf(gid, "%u", (unsigned)file_header->gid);*/
27 group = utoa(file_header->gid); 27 group = utoa(file_header->gid);
diff --git a/include/unarchive.h b/include/unarchive.h
index 68e83f01c..e3afb8af9 100644
--- a/include/unarchive.h
+++ b/include/unarchive.h
@@ -8,8 +8,8 @@ typedef struct file_header_t {
8 char *name; 8 char *name;
9 char *link_target; 9 char *link_target;
10#if ENABLE_FEATURE_TAR_UNAME_GNAME 10#if ENABLE_FEATURE_TAR_UNAME_GNAME
11 char *uname; 11 char *tar__uname;
12 char *gname; 12 char *tar__gname;
13#endif 13#endif
14 off_t size; 14 off_t size;
15 uid_t uid; 15 uid_t uid;
@@ -19,16 +19,25 @@ typedef struct file_header_t {
19 dev_t device; 19 dev_t device;
20} file_header_t; 20} file_header_t;
21 21
22struct hardlinks_t;
23
22typedef struct archive_handle_t { 24typedef struct archive_handle_t {
25 /* Flags. 1st since it is most used member */
26 unsigned ah_flags;
27
28 /* The raw stream as read from disk or stdin */
29 int src_fd;
30
23 /* Define if the header and data component should be processed */ 31 /* Define if the header and data component should be processed */
24 char FAST_FUNC (*filter)(struct archive_handle_t *); 32 char FAST_FUNC (*filter)(struct archive_handle_t *);
33 /* List of files that have been accepted */
25 llist_t *accept; 34 llist_t *accept;
26 /* List of files that have been rejected */ 35 /* List of files that have been rejected */
27 llist_t *reject; 36 llist_t *reject;
28 /* List of files that have successfully been worked on */ 37 /* List of files that have successfully been worked on */
29 llist_t *passed; 38 llist_t *passed;
30 39
31 /* Contains the processed header entry */ 40 /* Currently processed file's header */
32 file_header_t *file_header; 41 file_header_t *file_header;
33 42
34 /* Process the header component, e.g. tar -t */ 43 /* Process the header component, e.g. tar -t */
@@ -37,33 +46,33 @@ typedef struct archive_handle_t {
37 /* Process the data component, e.g. extract to filesystem */ 46 /* Process the data component, e.g. extract to filesystem */
38 void FAST_FUNC (*action_data)(struct archive_handle_t *); 47 void FAST_FUNC (*action_data)(struct archive_handle_t *);
39 48
40#if ENABLE_DPKG || ENABLE_DPKG_DEB
41 /* "subarchive" is used only by dpkg[-deb] applets */
42 /* How to process any sub archive, e.g. get_header_tar_gz */
43 char FAST_FUNC (*action_data_subarchive)(struct archive_handle_t *);
44 /* Contains the handle to a sub archive */
45 struct archive_handle_t *sub_archive;
46#endif
47
48 /* The raw stream as read from disk or stdin */
49 int src_fd;
50
51 /* Count the number of bytes processed */
52 off_t offset;
53
54 /* Function that skips data */ 49 /* Function that skips data */
55 void FAST_FUNC (*seek)(int fd, off_t amount); 50 void FAST_FUNC (*seek)(int fd, off_t amount);
56 51
57 /* Temporary storage */ 52 /* Count processed bytes */
58 char *ah_buffer; 53 off_t offset;
59
60 /* Flags and misc. stuff */
61 unsigned ah_flags;
62
63 /* "Private" storage for archivers */
64// unsigned char ah_priv_inited;
65 void *ah_priv[8];
66 54
55 /* Archiver specific. Can make it a union if it ever gets big */
56#if ENABLE_TAR
57 smallint tar__end;
58# if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
59 char* tar__longname;
60 char* tar__linkname;
61# endif
62#endif
63#if ENABLE_CPIO
64 uoff_t cpio__blocks;
65 struct hardlinks_t *cpio__hardlinks_to_create;
66 struct hardlinks_t *cpio__created_hardlinks;
67#endif
68#if ENABLE_DPKG || ENABLE_DPKG_DEB
69 /* Temporary storage */
70 char *dpkg__buffer;
71 /* How to process any sub archive, e.g. get_header_tar_gz */
72 char FAST_FUNC (*dpkg__action_data_subarchive)(struct archive_handle_t *);
73 /* Contains the handle to a sub archive */
74 struct archive_handle_t *dpkg__sub_archive;
75#endif
67} archive_handle_t; 76} archive_handle_t;
68/* bits in ah_flags */ 77/* bits in ah_flags */
69#define ARCHIVE_RESTORE_DATE (1 << 0) 78#define ARCHIVE_RESTORE_DATE (1 << 0)