summaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
authorGlenn L McGrath2003-11-21 22:24:57 +0000
committerGlenn L McGrath2003-11-21 22:24:57 +0000
commit7ffe1338647d2b890df3ae46e526410b21a90d18 (patch)
treee949e5879a7083bac9e2da249363f9c613d0a409 /archival/libunarchive
parent1a2d75fd7273e8de936e5fd91462bdff381f9b62 (diff)
downloadbusybox-7ffe1338647d2b890df3ae46e526410b21a90d18.zip
busybox-7ffe1338647d2b890df3ae46e526410b21a90d18.tar.gz
As we no longer use function pointers for read in common archiving code
archive_xread can be replaced with bb_full_read, and archive_copy_file with bb_copyfd* bb_copyfd is split into two functions bb_copyfd_size and bb_copyfd_eof, they share a common backend.
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/Makefile.in3
-rw-r--r--archival/libunarchive/archive_copy_file.c44
-rw-r--r--archival/libunarchive/archive_xread.c33
-rw-r--r--archival/libunarchive/archive_xread_all.c2
-rw-r--r--archival/libunarchive/archive_xread_all_eof.c2
-rw-r--r--archival/libunarchive/data_extract_all.c2
-rw-r--r--archival/libunarchive/data_extract_to_stdout.c2
-rw-r--r--archival/libunarchive/get_header_tar.c2
-rw-r--r--archival/libunarchive/seek_by_char.c16
9 files changed, 7 insertions, 99 deletions
diff --git a/archival/libunarchive/Makefile.in b/archival/libunarchive/Makefile.in
index c9dec09..09b0571 100644
--- a/archival/libunarchive/Makefile.in
+++ b/archival/libunarchive/Makefile.in
@@ -37,15 +37,12 @@ LIBUNARCHIVE-y:= \
header_list.o \
header_verbose_list.o \
\
- archive_xread.o \
archive_xread_all.o \
archive_xread_all_eof.o \
\
seek_by_char.o \
seek_by_jump.o \
\
- archive_copy_file.o \
-\
data_align.o \
find_list_entry.o \
open_transformer.o \
diff --git a/archival/libunarchive/archive_copy_file.c b/archival/libunarchive/archive_copy_file.c
deleted file mode 100644
index 675bc6f..0000000
--- a/archival/libunarchive/archive_copy_file.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <unistd.h>
-
-#include "libbb.h"
-#include "unarchive.h"
-
-extern void archive_copy_file(const archive_handle_t *archive_handle, const int dst_fd)
-{
- char buffer[512];
- off_t chunksize = archive_handle->file_header->size;
-
- while (chunksize != 0) {
- size_t size;
- if (chunksize > 512) {
- size = 512;
- } else {
- size = chunksize;
- }
-// archive_xread_all(archive_handle, buffer, size);
- size = archive_xread(archive_handle, buffer, size);
-
- if (write(dst_fd, buffer, size) != size) {
- bb_error_msg_and_die ("Short write");
- }
- chunksize -= size;
- }
-
- return;
-}
diff --git a/archival/libunarchive/archive_xread.c b/archival/libunarchive/archive_xread.c
deleted file mode 100644
index 59b4d77..0000000
--- a/archival/libunarchive/archive_xread.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "unarchive.h"
-#include "libbb.h"
-
-extern ssize_t archive_xread(const archive_handle_t *archive_handle, unsigned char *buf, const size_t count)
-{
- ssize_t size;
-
- size = bb_full_read(archive_handle->src_fd, buf, count);
- if (size < 0) {
- bb_perror_msg_and_die("Read error");
- }
-
- return(size);
-}
diff --git a/archival/libunarchive/archive_xread_all.c b/archival/libunarchive/archive_xread_all.c
index cfe046b..ba9ade2 100644
--- a/archival/libunarchive/archive_xread_all.c
+++ b/archival/libunarchive/archive_xread_all.c
@@ -24,7 +24,7 @@ extern void archive_xread_all(const archive_handle_t *archive_handle, void *buf,
{
ssize_t size;
- size = archive_xread(archive_handle, buf, count);
+ size = bb_full_read(archive_handle->src_fd, buf, count);
if (size != count) {
bb_error_msg_and_die("Short read");
}
diff --git a/archival/libunarchive/archive_xread_all_eof.c b/archival/libunarchive/archive_xread_all_eof.c
index 23719cd..8084e35 100644
--- a/archival/libunarchive/archive_xread_all_eof.c
+++ b/archival/libunarchive/archive_xread_all_eof.c
@@ -24,7 +24,7 @@ extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned
{
ssize_t size;
- size = archive_xread(archive_handle, buf, count);
+ size = bb_full_read(archive_handle->src_fd, buf, count);
if ((size != 0) && (size != count)) {
bb_perror_msg_and_die("Short read, read %d of %d", size, count);
}
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index 4dccb81..bf3be5b 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -79,7 +79,7 @@ extern void data_extract_all(archive_handle_t *archive_handle)
case S_IFREG: {
/* Regular file */
dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL);
- archive_copy_file(archive_handle, dst_fd);
+ bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size);
close(dst_fd);
break;
}
diff --git a/archival/libunarchive/data_extract_to_stdout.c b/archival/libunarchive/data_extract_to_stdout.c
index 8be2fa2..ce5d4b8 100644
--- a/archival/libunarchive/data_extract_to_stdout.c
+++ b/archival/libunarchive/data_extract_to_stdout.c
@@ -18,5 +18,5 @@
extern void data_extract_to_stdout(archive_handle_t *archive_handle)
{
- archive_copy_file(archive_handle, fileno(stdout));
+ bb_copyfd_eof(archive_handle->src_fd, fileno(stdout));
}
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index d55189f..603535a 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -57,7 +57,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
/* Align header */
data_align(archive_handle, 512);
- if (archive_xread(archive_handle, tar.raw, 512) != 512) {
+ if (bb_full_read(archive_handle->src_fd, tar.raw, 512) != 512) {
/* Assume end of file */
return(EXIT_FAILURE);
}
diff --git a/archival/libunarchive/seek_by_char.c b/archival/libunarchive/seek_by_char.c
index 77da4ef..c031561 100644
--- a/archival/libunarchive/seek_by_char.c
+++ b/archival/libunarchive/seek_by_char.c
@@ -26,19 +26,7 @@
*/
extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
{
- unsigned int remaining = jump_size;
- unsigned int read_amount;
- RESERVE_CONFIG_BUFFER(buf, BUFSIZ);
-
- while (remaining > 0) {
- if (remaining > BUFSIZ) {
- read_amount = BUFSIZ;
- } else {
- read_amount = remaining;
- }
- read_amount = archive_xread(archive_handle, buf, read_amount);
- remaining -= read_amount;
+ if (jump_size) {
+ bb_full_fd_action(archive_handle->src_fd, -1, jump_size, NULL);
}
-
- RELEASE_CONFIG_BUFFER(buf);
}