Move unzip, gz_open, gz_close to libbb

This commit is contained in:
Glenn L McGrath 2001-04-11 03:11:33 +00:00
parent d22e560ad6
commit 7fd92949d0
13 changed files with 3138 additions and 2005 deletions

View File

@ -240,13 +240,13 @@ concat_path_file.c copy_file.c copy_file_chunk.c create_path.c daemon.c \
deb_extract.c device_open.c error_msg.c error_msg_and_die.c \ deb_extract.c device_open.c error_msg.c error_msg_and_die.c \
find_mount_point.c find_pid_by_name.c find_root_device.c full_read.c \ find_mount_point.c find_pid_by_name.c find_root_device.c full_read.c \
full_write.c get_ar_headers.c get_console.c get_last_path_component.c \ full_write.c get_ar_headers.c get_console.c get_last_path_component.c \
get_line_from_file.c human_readable.c inode_hash.c isdirectory.c \ get_line_from_file.c gz_open.c human_readable.c inode_hash.c \
kernel_version.c loop.c mode_string.c module_syscalls.c mtab.c mtab_file.c \ isdirectory.c kernel_version.c loop.c mode_string.c module_syscalls.c mtab.c \
my_getgrnam.c my_getgrgid.c my_getpwnam.c my_getpwnamegid.c my_getpwuid.c \ mtab_file.c my_getgrnam.c my_getgrgid.c my_getpwnam.c my_getpwnamegid.c \
parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c print_file.c \ my_getpwuid.c parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \
process_escape_sequence.c recursive_action.c safe_read.c safe_strncpy.c \ print_file.c process_escape_sequence.c recursive_action.c safe_read.c \
syscalls.c syslog_msg_with_name.c time_string.c trim.c vdprintf.c verror_msg.c \ safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c trim.c unzip.c \
vperror_msg.c wfopen.c xfuncs.c xgetcwd.c xregcomp.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c xgetcwd.c xregcomp.c
LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC)) LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
LIBBB_CFLAGS = -I$(LIBBB) LIBBB_CFLAGS = -I$(LIBBB)

File diff suppressed because it is too large Load Diff

View File

@ -278,7 +278,6 @@ extern int zip (int in, int out);
extern int file_read (char *buf, unsigned size); extern int file_read (char *buf, unsigned size);
/* in unzip.c */ /* in unzip.c */
extern int unzip (int in, int out);
extern int check_zipfile (int in); extern int check_zipfile (int in);
/* in unpack.c */ /* in unpack.c */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -56,12 +56,6 @@
#define bb_need_name_longer_than_foo #define bb_need_name_longer_than_foo
#include "messages.c" #include "messages.c"
#ifdef BB_FEATURE_TAR_GZIP
extern int unzip(int in, int out);
extern int gz_open(FILE *compressed_file, int *pid);
extern void gz_close(int gunzip_pid);
#endif
/* Tar file constants */ /* Tar file constants */
#ifndef MAJOR #ifndef MAJOR
#define MAJOR(dev) (((dev)>>8)&0xff) #define MAJOR(dev) (((dev)>>8)&0xff)

999
gunzip.c

File diff suppressed because it is too large Load Diff

1
gzip.c
View File

@ -278,7 +278,6 @@ extern int zip (int in, int out);
extern int file_read (char *buf, unsigned size); extern int file_read (char *buf, unsigned size);
/* in unzip.c */ /* in unzip.c */
extern int unzip (int in, int out);
extern int check_zipfile (int in); extern int check_zipfile (int in);
/* in unpack.c */ /* in unpack.c */

View File

@ -227,4 +227,8 @@ typedef struct ar_headers_s {
} ar_headers_t; } ar_headers_t;
extern ar_headers_t get_ar_headers(int srcFd); extern ar_headers_t get_ar_headers(int srcFd);
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename); extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename);
extern int unzip(FILE *l_in_file, FILE *l_out_file);
extern void gz_close(int gunzip_pid);
extern int gz_open(FILE *compressed_file, int *pid);
#endif /* __LIBBB_H__ */ #endif /* __LIBBB_H__ */

34
libbb/gz_open.c Normal file
View File

@ -0,0 +1,34 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libbb.h"
extern int gz_open(FILE *compressed_file, int *pid)
{
int unzip_pipe[2];
if (pipe(unzip_pipe)!=0) {
error_msg("pipe error");
return(EXIT_FAILURE);
}
if ((*pid = fork()) == -1) {
error_msg("fork failured");
return(EXIT_FAILURE);
}
if (*pid==0) {
/* child process */
close(unzip_pipe[0]);
unzip(compressed_file, fdopen(unzip_pipe[1], "w"));
printf("finished unzipping\n");
fflush(NULL);
fclose(compressed_file);
close(unzip_pipe[1]);
exit(EXIT_SUCCESS);
}
close(unzip_pipe[1]);
return(unzip_pipe[0]);
}

View File

@ -227,4 +227,8 @@ typedef struct ar_headers_s {
} ar_headers_t; } ar_headers_t;
extern ar_headers_t get_ar_headers(int srcFd); extern ar_headers_t get_ar_headers(int srcFd);
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename); extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename);
extern int unzip(FILE *l_in_file, FILE *l_out_file);
extern void gz_close(int gunzip_pid);
extern int gz_open(FILE *compressed_file, int *pid);
#endif /* __LIBBB_H__ */ #endif /* __LIBBB_H__ */

1025
libbb/unzip.c Normal file

File diff suppressed because it is too large Load Diff

6
tar.c
View File

@ -56,12 +56,6 @@
#define bb_need_name_longer_than_foo #define bb_need_name_longer_than_foo
#include "messages.c" #include "messages.c"
#ifdef BB_FEATURE_TAR_GZIP
extern int unzip(int in, int out);
extern int gz_open(FILE *compressed_file, int *pid);
extern void gz_close(int gunzip_pid);
#endif
/* Tar file constants */ /* Tar file constants */
#ifndef MAJOR #ifndef MAJOR
#define MAJOR(dev) (((dev)>>8)&0xff) #define MAJOR(dev) (((dev)>>8)&0xff)