Support old-style compress (.Z) files via libbb / unzip( ) calls
(configurable) - When enabled an applet "uncompress" is also made available (oddname to gunzip)
This commit is contained in:
parent
7ac868460a
commit
f6495eb767
@ -65,8 +65,13 @@ static char *license_msg[] = {
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef CONFIG_FEATURE_UNCOMPRESS
|
||||
int uncompress ( FILE *in, FILE *out );
|
||||
#endif
|
||||
|
||||
static FILE *in_file, *out_file;
|
||||
|
||||
/* these are freed by gz_close */
|
||||
@ -911,6 +916,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
||||
unsigned char flags; /* compression flags */
|
||||
typedef void (*sig_type) (int);
|
||||
unsigned short i;
|
||||
unsigned char magic [2];
|
||||
|
||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
|
||||
(void) signal(SIGINT, (sig_type) abort_gzip);
|
||||
@ -926,8 +932,18 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
||||
}
|
||||
#endif
|
||||
|
||||
magic [0] = fgetc(l_in_file);
|
||||
magic [1] = fgetc(l_in_file);
|
||||
|
||||
#ifdef CONFIG_FEATURE_UNCOMPRESS
|
||||
/* Magic header for compress files, 1F 9d = \037\235 */
|
||||
if (( magic [0] == 0x1F ) && ( magic [1] == 0x9d)) {
|
||||
return uncompress ( l_in_file, l_out_file );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Magic header for gzip files, 1F 8B = \037\213 */
|
||||
if ((fgetc(l_in_file) != 0x1F) || (fgetc(l_in_file) != 0x8b)) {
|
||||
if (( magic [0] != 0x1F ) || ( magic [1] != 0x8b)) {
|
||||
error_msg("Invalid gzip magic");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -65,8 +65,13 @@ static char *license_msg[] = {
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef CONFIG_FEATURE_UNCOMPRESS
|
||||
int uncompress ( FILE *in, FILE *out );
|
||||
#endif
|
||||
|
||||
static FILE *in_file, *out_file;
|
||||
|
||||
/* these are freed by gz_close */
|
||||
@ -911,6 +916,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
||||
unsigned char flags; /* compression flags */
|
||||
typedef void (*sig_type) (int);
|
||||
unsigned short i;
|
||||
unsigned char magic [2];
|
||||
|
||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
|
||||
(void) signal(SIGINT, (sig_type) abort_gzip);
|
||||
@ -926,8 +932,18 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
||||
}
|
||||
#endif
|
||||
|
||||
magic [0] = fgetc(l_in_file);
|
||||
magic [1] = fgetc(l_in_file);
|
||||
|
||||
#ifdef CONFIG_FEATURE_UNCOMPRESS
|
||||
/* Magic header for compress files, 1F 9d = \037\235 */
|
||||
if (( magic [0] == 0x1F ) && ( magic [1] == 0x9d)) {
|
||||
return uncompress ( l_in_file, l_out_file );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Magic header for gzip files, 1F 8B = \037\213 */
|
||||
if ((fgetc(l_in_file) != 0x1F) || (fgetc(l_in_file) != 0x8b)) {
|
||||
if (( magic [0] != 0x1F ) || ( magic [1] != 0x8b)) {
|
||||
error_msg("Invalid gzip magic");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -467,6 +467,11 @@
|
||||
#ifdef CONFIG_UNAME
|
||||
APPLET(uname, uname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef CONFIG_GUNZIP
|
||||
# ifdef CONFIG_FEATURE_UNCOMPRESS
|
||||
APPLET_ODDNAME("uncompress", gunzip_main, _BB_DIR_BIN, gunzip)
|
||||
# endif
|
||||
#endif
|
||||
#ifdef CONFIG_UNIQ
|
||||
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
|
@ -34,7 +34,7 @@ LIBBB_SRC:= \
|
||||
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 vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \
|
||||
trim.c unzip.c uncompress.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.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 \
|
||||
|
@ -65,8 +65,13 @@ static char *license_msg[] = {
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef CONFIG_FEATURE_UNCOMPRESS
|
||||
int uncompress ( FILE *in, FILE *out );
|
||||
#endif
|
||||
|
||||
static FILE *in_file, *out_file;
|
||||
|
||||
/* these are freed by gz_close */
|
||||
@ -911,6 +916,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
||||
unsigned char flags; /* compression flags */
|
||||
typedef void (*sig_type) (int);
|
||||
unsigned short i;
|
||||
unsigned char magic [2];
|
||||
|
||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
|
||||
(void) signal(SIGINT, (sig_type) abort_gzip);
|
||||
@ -926,8 +932,18 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
||||
}
|
||||
#endif
|
||||
|
||||
magic [0] = fgetc(l_in_file);
|
||||
magic [1] = fgetc(l_in_file);
|
||||
|
||||
#ifdef CONFIG_FEATURE_UNCOMPRESS
|
||||
/* Magic header for compress files, 1F 9d = \037\235 */
|
||||
if (( magic [0] == 0x1F ) && ( magic [1] == 0x9d)) {
|
||||
return uncompress ( l_in_file, l_out_file );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Magic header for gzip files, 1F 8B = \037\213 */
|
||||
if ((fgetc(l_in_file) != 0x1F) || (fgetc(l_in_file) != 0x8b)) {
|
||||
if (( magic [0] != 0x1F ) || ( magic [1] != 0x8b)) {
|
||||
error_msg("Invalid gzip magic");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ bool 'Show verbose applet usage messages' CONFIG_FEATURE_VERBOSE_USAGE
|
||||
bool 'Support --install [-s] to install applet links at runtime' CONFIG_FEATURE_INSTALLER
|
||||
bool 'Enable locale support (system needs locale for this to work)' CONFIG_LOCALE_SUPPORT
|
||||
bool 'Support for devfs' CONFIG_FEATURE_DEVFS
|
||||
bool 'Support compress format (.Z) in unzip operations' CONFIG_FEATURE_UNCOMPRESS
|
||||
bool 'Clean up all memory before exiting (usually not needed)' CONFIG_FEATURE_CLEAN_UP
|
||||
endmenu
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user