New common unarchive code.

This commit is contained in:
Glenn L McGrath
2002-09-25 02:47:48 +00:00
parent ecfa290cfd
commit 7ca04f328e
36 changed files with 2436 additions and 1914 deletions

View File

@@ -28,20 +28,22 @@ LIBBB_SRC:= \
copy_file_chunk.c dump.c libc5.c device_open.c error_msg.c \
error_msg_and_die.c fgets_str.c find_mount_point.c find_pid_by_name.c \
find_root_device.c full_read.c full_write.c get_console.c \
get_last_path_component.c get_line_from_file.c gz_open.c human_readable.c \
isdirectory.c kernel_version.c loop.c mode_string.c module_syscalls.c mtab.c \
mtab_file.c my_getgrnam.c my_getgrgid.c my_getpwnam.c my_getpwnamegid.c \
my_getpwuid.c parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \
print_file.c process_escape_sequence.c read_package_field.c recursive_action.c \
safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \
trim.c unzip.c uncompress.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c \
xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c \
simplify_path.c inet_common.c inode_hash.c obscure.c pwd2spwd.c xfuncs.c \
correct_password.c change_identity.c setup_environment.c run_shell.c \
pw_encrypt.c restricted_shell.c xgethostbyname2.c create_icmp6_socket.c \
xconnect.c bb_asprintf.c
get_last_path_component.c get_line_from_file.c \
human_readable.c isdirectory.c kernel_version.c loop.c \
mode_string.c module_syscalls.c mtab.c mtab_file.c my_getgrnam.c \
my_getgrgid.c my_getpwnam.c my_getpwnamegid.c my_getpwuid.c \
parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \
print_file.c process_escape_sequence.c read_package_field.c \
recursive_action.c safe_read.c safe_strncpy.c syscalls.c \
syslog_msg_with_name.c time_string.c trim.c unzip.c uncompress.c \
vdprintf.c verror_msg.c vperror_msg.c wfopen.c xgetcwd.c xreadlink.c \
xregcomp.c interface.c remove_file.c last_char_is.c copyfd.c \
vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
dirname.c make_directory.c create_icmp_socket.c u_signal_names.c \
arith.c simplify_path.c inet_common.c inode_hash.c obscure.c \
pwd2spwd.c xfuncs.c correct_password.c change_identity.c \
setup_environment.c run_shell.c pw_encrypt.c restricted_shell.c \
xgethostbyname2.c create_icmp6_socket.c xconnect.c bb_asprintf.c
LIBBB_OBJS=$(patsubst %.c,$(LIBBB_DIR)%.o, $(LIBBB_SRC))

File diff suppressed because it is too large Load Diff

View File

@@ -19,10 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "libbb.h"
@@ -85,6 +88,59 @@ FILE *xfopen(const char *path, const char *mode)
return fp;
}
extern int xopen(const char *pathname, int flags)
{
int ret;
ret = open(pathname, flags);
if (ret == -1) {
perror_msg_and_die("%s", pathname);
}
return ret;
}
extern ssize_t xread(int fd, void *buf, size_t count)
{
ssize_t size;
size = read(fd, buf, count);
if (size == -1) {
perror_msg_and_die("Read error");
}
return(size);
}
extern void xread_all(int fd, void *buf, size_t count)
{
ssize_t size;
size = xread(fd, buf, count);
if (size != count) {
error_msg_and_die("Short read");
}
return;
}
extern ssize_t xread_all_eof(int fd, void *buf, size_t count)
{
ssize_t size;
size = xread(fd, buf, count);
if ((size != 0) && (size != count)) {
error_msg_and_die("Short read");
}
return(size);
}
extern unsigned char xread_char(int fd)
{
char tmp;
xread_all(fd, &tmp, 1);
return(tmp);
}
/* Stupid gcc always includes its own builtin strlen()... */
#undef strlen
size_t xstrlen(const char *string)