diff options
author | Robert Griebl <griebl@gmx.de> | 2002-05-15 22:13:47 +0000 |
---|---|---|
committer | Robert Griebl <griebl@gmx.de> | 2002-05-15 22:13:47 +0000 |
commit | f6495eb7670063c0e9040c3eb3a0f1087d762a6a (patch) | |
tree | a53533813c8dc4c953532a679fc34d6903e0c3a0 /archival/libunarchive | |
parent | 7ac868460a90e1de4a2f45229f22f1cd07370c05 (diff) | |
download | busybox-f6495eb7670063c0e9040c3eb3a0f1087d762a6a.tar.gz |
Support old-style compress (.Z) files via libbb / unzip( ) calls
(configurable) - When enabled an applet "uncompress" is also made
available (oddname to gunzip)
Diffstat (limited to 'archival/libunarchive')
-rw-r--r-- | archival/libunarchive/decompress_unzip.c | 18 | ||||
-rw-r--r-- | archival/libunarchive/unzip.c | 18 |
2 files changed, 34 insertions, 2 deletions
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c index 9f6ed2ebe..cde16d067 100644 --- a/archival/libunarchive/decompress_unzip.c +++ b/archival/libunarchive/decompress_unzip.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; } diff --git a/archival/libunarchive/unzip.c b/archival/libunarchive/unzip.c index 9f6ed2ebe..cde16d067 100644 --- a/archival/libunarchive/unzip.c +++ b/archival/libunarchive/unzip.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; } |