aboutsummaryrefslogtreecommitdiff
path: root/archival/libunarchive
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 /archival/libunarchive
parent86350f8d5f5d5a1006cffe0bedccd625f012702f (diff)
downloadbusybox-aa4977d8e549d9fff2b2946f03d304e435eb20f1.tar.gz
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>
Diffstat (limited to 'archival/libunarchive')
-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
6 files changed, 36 insertions, 52 deletions
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)
uid_t uid = file_header->uid;
gid_t gid = file_header->gid;
- if (file_header->uname) {
+ if (file_header->tar__uname) {
//TODO: cache last name/id pair?
- struct passwd *pwd = getpwnam(file_header->uname);
+ struct passwd *pwd = getpwnam(file_header->tar__uname);
if (pwd) uid = pwd->pw_uid;
}
- if (file_header->gname) {
- struct group *grp = getgrnam(file_header->gname);
+ if (file_header->tar__gname) {
+ struct group *grp = getgrnam(file_header->tar__gname);
if (grp) gid = grp->gr_gid;
}
/* 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)
if (ENABLE_FEATURE_SEAMLESS_GZ
&& strcmp(name_ptr, "gz") == 0
) {
- archive_handle->action_data_subarchive = get_header_tar_gz;
+ archive_handle->dpkg__action_data_subarchive = get_header_tar_gz;
return EXIT_SUCCESS;
}
if (ENABLE_FEATURE_SEAMLESS_BZ2
&& strcmp(name_ptr, "bz2") == 0
) {
- archive_handle->action_data_subarchive = get_header_tar_bz2;
+ archive_handle->dpkg__action_data_subarchive = get_header_tar_bz2;
return EXIT_SUCCESS;
}
if (ENABLE_FEATURE_SEAMLESS_LZMA
&& strcmp(name_ptr, "lzma") == 0
) {
- archive_handle->action_data_subarchive = get_header_tar_lzma;
+ archive_handle->dpkg__action_data_subarchive = get_header_tar_lzma;
return EXIT_SUCCESS;
}
}
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)
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_header(typed);
#if ENABLE_DPKG || ENABLE_DPKG_DEB
- if (archive_handle->sub_archive) {
- while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS)
+ if (archive_handle->dpkg__sub_archive) {
+ while (archive_handle->dpkg__action_data_subarchive(archive_handle->dpkg__sub_archive) == EXIT_SUCCESS)
continue;
} else
#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)
int major, minor, nlink, mode, inode;
unsigned size, uid, gid, mtime;
-#define hardlinks_to_create (*(hardlinks_t **)(&archive_handle->ah_priv[0]))
-#define created_hardlinks (*(hardlinks_t **)(&archive_handle->ah_priv[1]))
-#define block_count (archive_handle->ah_priv[2])
-// if (!archive_handle->ah_priv_inited) {
-// archive_handle->ah_priv_inited = 1;
-// hardlinks_to_create = NULL;
-// created_hardlinks = NULL;
-// }
-
/* There can be padding before archive header */
data_align(archive_handle, 4);
@@ -86,7 +77,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
/* Always round up. ">> 9" divides by 512 */
- block_count = (void*)(ptrdiff_t) ((archive_handle->offset + 511) >> 9);
+ archive_handle->cpio__blocks = (uoff_t)(archive_handle->offset + 511) >> 9;
goto create_hardlinks;
}
@@ -112,13 +103,13 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
strcpy(new->name, file_header->name);
/* Put file on a linked list for later */
if (size == 0) {
- new->next = hardlinks_to_create;
- hardlinks_to_create = new;
+ new->next = archive_handle->cpio__hardlinks_to_create;
+ archive_handle->cpio__hardlinks_to_create = new;
return EXIT_SUCCESS; /* Skip this one */
/* TODO: this breaks cpio -t (it does not show hardlinks) */
}
- new->next = created_hardlinks;
- created_hardlinks = new;
+ new->next = archive_handle->cpio__created_hardlinks;
+ archive_handle->cpio__created_hardlinks = new;
}
file_header->device = makedev(major, minor);
@@ -142,11 +133,11 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
free(file_header->link_target);
free(file_header->name);
- while (hardlinks_to_create) {
+ while (archive_handle->cpio__hardlinks_to_create) {
hardlinks_t *cur;
- hardlinks_t *make_me = hardlinks_to_create;
+ hardlinks_t *make_me = archive_handle->cpio__hardlinks_to_create;
- hardlinks_to_create = make_me->next;
+ archive_handle->cpio__hardlinks_to_create = make_me->next;
memset(file_header, 0, sizeof(*file_header));
file_header->mtime = make_me->mtime;
@@ -158,7 +149,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
/*file_header->link_target = NULL;*/
/* Try to find a file we are hardlinked to */
- cur = created_hardlinks;
+ cur = archive_handle->cpio__created_hardlinks;
while (cur) {
/* TODO: must match maj/min too! */
if (cur->inode == make_me->inode) {
@@ -176,14 +167,14 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
archive_handle->action_data(archive_handle);
/* Move to the list of created hardlinked files */
- make_me->next = created_hardlinks;
- created_hardlinks = make_me;
+ make_me->next = archive_handle->cpio__created_hardlinks;
+ archive_handle->cpio__created_hardlinks = make_me;
next_link: ;
}
- while (created_hardlinks) {
- hardlinks_t *p = created_hardlinks;
- created_hardlinks = p->next;
+ while (archive_handle->cpio__created_hardlinks) {
+ hardlinks_t *p = archive_handle->cpio__created_hardlinks;
+ archive_handle->cpio__created_hardlinks = p->next;
free(p);
}
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)
int parse_names;
/* Our "private data" */
-#define p_end (*(smallint *)(&archive_handle->ah_priv[0]))
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
-#define p_longname (*(char* *)(&archive_handle->ah_priv[1]))
-#define p_linkname (*(char* *)(&archive_handle->ah_priv[2]))
+# define p_longname (archive_handle->tar__longname)
+# define p_linkname (archive_handle->tar__linkname)
#else
-#define p_longname 0
-#define p_linkname 0
+# define p_longname 0
+# define p_linkname 0
#endif
-// if (!archive_handle->ah_priv_inited) {
-// archive_handle->ah_priv_inited = 1;
-// p_end = 0;
-// IF_FEATURE_TAR_GNU_EXTENSIONS(p_longname = NULL;)
-// IF_FEATURE_TAR_GNU_EXTENSIONS(p_linkname = NULL;)
-// }
if (sizeof(tar) != 512)
BUG_tar_header_size();
@@ -190,7 +183,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
/* If there is no filename its an empty header */
if (tar.name[0] == 0 && tar.prefix[0] == 0) {
- if (p_end) {
+ if (archive_handle->tar__end) {
/* Second consecutive empty header - end of archive.
* Read until the end to empty the pipe from gz or bz2
*/
@@ -198,10 +191,10 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
continue;
return EXIT_FAILURE;
}
- p_end = 1;
+ archive_handle->tar__end = 1;
return EXIT_SUCCESS;
}
- p_end = 0;
+ archive_handle->tar__end = 0;
/* Check header has valid magic, "ustar" is for the proper tar,
* five NULs are for the old tar format */
@@ -301,8 +294,8 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
/* Will link_target be free()ed? */
}
#if ENABLE_FEATURE_TAR_UNAME_GNAME
- file_header->uname = tar.uname[0] ? xstrndup(tar.uname, sizeof(tar.uname)) : NULL;
- file_header->gname = tar.gname[0] ? xstrndup(tar.gname, sizeof(tar.gname)) : NULL;
+ file_header->tar__uname = tar.uname[0] ? xstrndup(tar.uname, sizeof(tar.uname)) : NULL;
+ file_header->tar__gname = tar.gname[0] ? xstrndup(tar.gname, sizeof(tar.gname)) : NULL;
#endif
/* mtime: rudimentally handle GNU tar's "base256 encoding"
* 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)
free(file_header->link_target);
/* Do not free(file_header->name)! (why?) */
#if ENABLE_FEATURE_TAR_UNAME_GNAME
- free(file_header->uname);
- free(file_header->gname);
+ free(file_header->tar__uname);
+ free(file_header->tar__gname);
#endif
return EXIT_SUCCESS;
}
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)
char *user;
char *group;
- user = file_header->uname;
+ user = file_header->tar__uname;
if (user == NULL) {
sprintf(uid, "%u", (unsigned)file_header->uid);
user = uid;
}
- group = file_header->gname;
+ group = file_header->tar__gname;
if (group == NULL) {
/*sprintf(gid, "%u", (unsigned)file_header->gid);*/
group = utoa(file_header->gid);