diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2002-11-03 14:05:15 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2002-11-03 14:05:15 +0000 |
commit | 237ae42fc96ede945d28d9054f045b73e419d089 (patch) | |
tree | 3fb6a9c10150303aca3c218b47aaf327a186382a /archival/unzip.c | |
parent | 2fc54a9258c3aa5dad2ce9807ba85cf29af2668e (diff) | |
download | busybox-237ae42fc96ede945d28d9054f045b73e419d089.tar.gz |
Abstract read and seek in unarchiving code, convert bunzip to file descriptors, support tar -j
Diffstat (limited to 'archival/unzip.c')
-rw-r--r-- | archival/unzip.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/archival/unzip.c b/archival/unzip.c index 5a22d242a..4c1e5ce40 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -136,13 +136,14 @@ extern int unzip_main(int argc, char **argv) if (*argv[optind] == '-') { archive_handle->src_fd = fileno(stdin); - } else { + archive_handle->seek = seek_by_char; + } else { archive_handle->src_fd = xopen(argv[optind++], O_RDONLY); - } + } if ((base_dir) && (chdir(base_dir))) { perror_msg_and_die("Couldnt chdir"); - } + } while (optind < argc) { archive_handle->filter = filter_accept_list; @@ -155,7 +156,7 @@ extern int unzip_main(int argc, char **argv) int dst_fd; /* TODO Endian issues */ - xread_all(archive_handle->src_fd, &magic, 4); + archive_xread_all(archive_handle, &magic, 4); archive_handle->offset += 4; if (magic == ZIP_CDS_MAGIC) { @@ -166,7 +167,7 @@ extern int unzip_main(int argc, char **argv) } /* Read the file header */ - xread_all(archive_handle->src_fd, zip_header.raw, 26); + archive_xread_all(archive_handle, zip_header.raw, 26); archive_handle->offset += 26; archive_handle->file_header->mode = S_IFREG | 0777; @@ -176,7 +177,7 @@ extern int unzip_main(int argc, char **argv) /* Read filename */ archive_handle->file_header->name = xmalloc(zip_header.formated.filename_len + 1); - xread_all(archive_handle->src_fd, archive_handle->file_header->name, zip_header.formated.filename_len); + archive_xread_all(archive_handle, archive_handle->file_header->name, zip_header.formated.filename_len); archive_handle->offset += zip_header.formated.filename_len; archive_handle->file_header->name[zip_header.formated.filename_len] = '\0'; @@ -228,7 +229,7 @@ extern int unzip_main(int argc, char **argv) /* skip over duplicate crc, compressed size and uncompressed size */ unsigned short i; for (i = 0; i != 12; i++) { - xread_char(archive_handle->src_fd); + archive_xread_char(archive_handle); } archive_handle->offset += 12; } |