summaryrefslogtreecommitdiff
path: root/archival/bbunzip.c
diff options
context:
space:
mode:
authorDenys Vlasenko2018-02-01 09:13:14 +0100
committerDenys Vlasenko2018-02-01 09:13:14 +0100
commitd6f0f03b68fc4cf9ffb8006e192e36f0ebf51ea6 (patch)
tree24b4adf0a28b91dbcd014cf99527ca07d492003d /archival/bbunzip.c
parent99ac1759dd429bd7995feff33dc683589c016c8e (diff)
downloadbusybox-d6f0f03b68fc4cf9ffb8006e192e36f0ebf51ea6.zip
busybox-d6f0f03b68fc4cf9ffb8006e192e36f0ebf51ea6.tar.gz
libarchive: move bbunpack constants to bb_archive.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/bbunzip.c')
-rw-r--r--archival/bbunzip.c57
1 files changed, 22 insertions, 35 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 944b397..a2ce0a1 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -21,19 +21,6 @@
#include "libbb.h"
#include "bb_archive.h"
-/* Note: must be kept in sync with archival/lzop.c */
-enum {
- OPT_STDOUT = 1 << 0,
- OPT_FORCE = 1 << 1,
- /* only some decompressors: */
- OPT_KEEP = 1 << 2,
- OPT_VERBOSE = 1 << 3,
- OPT_QUIET = 1 << 4,
- OPT_DECOMPRESS = 1 << 5,
- OPT_TEST = 1 << 6,
- SEAMLESS_MAGIC = (1 << 31) * ENABLE_ZCAT * SEAMLESS_COMPRESSION,
-};
-
static
int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
{
@@ -72,7 +59,7 @@ int FAST_FUNC bbunpack(char **argv,
/* Open src */
if (filename) {
- if (!(option_mask32 & SEAMLESS_MAGIC)) {
+ if (!(option_mask32 & BBUNPK_SEAMLESS_MAGIC)) {
if (stat(filename, &stat_buf) != 0) {
err_name:
bb_simple_perror_msg(filename);
@@ -91,15 +78,15 @@ int FAST_FUNC bbunpack(char **argv,
xmove_fd(fd, STDIN_FILENO);
}
} else
- if (option_mask32 & SEAMLESS_MAGIC) {
+ if (option_mask32 & BBUNPK_SEAMLESS_MAGIC) {
/* "clever zcat" on stdin */
if (setup_unzip_on_fd(STDIN_FILENO, /*fail_if_not_compressed*/ 1))
goto err;
}
/* Special cases: test, stdout */
- if (option_mask32 & (OPT_STDOUT|OPT_TEST)) {
- if (option_mask32 & OPT_TEST)
+ if (option_mask32 & (BBUNPK_OPT_STDOUT|BBUNPK_OPT_TEST)) {
+ if (option_mask32 & BBUNPK_OPT_TEST)
if (open_to_or_warn(STDOUT_FILENO, bb_dev_null, O_WRONLY, 0))
xfunc_die();
filename = NULL;
@@ -114,7 +101,7 @@ int FAST_FUNC bbunpack(char **argv,
}
/* -f: overwrite existing output files */
- if (option_mask32 & OPT_FORCE) {
+ if (option_mask32 & BBUNPK_OPT_FORCE) {
unlink(new_name);
}
@@ -126,12 +113,12 @@ int FAST_FUNC bbunpack(char **argv,
}
/* Check that the input is sane */
- if (!(option_mask32 & OPT_FORCE) && isatty(STDIN_FILENO)) {
+ if (!(option_mask32 & BBUNPK_OPT_FORCE) && isatty(STDIN_FILENO)) {
bb_error_msg_and_die("compressed data not read from terminal, "
"use -f to force it");
}
- if (!(option_mask32 & SEAMLESS_MAGIC)) {
+ if (!(option_mask32 & BBUNPK_SEAMLESS_MAGIC)) {
init_transformer_state(&xstate);
/*xstate.signature_skipped = 0; - already is */
/*xstate.src_fd = STDIN_FILENO; - already is */
@@ -145,7 +132,7 @@ int FAST_FUNC bbunpack(char **argv,
xfunc_die();
}
- if (!(option_mask32 & OPT_STDOUT))
+ if (!(option_mask32 & BBUNPK_OPT_STDOUT))
xclose(STDOUT_FILENO); /* with error check! */
if (filename) {
@@ -176,7 +163,7 @@ int FAST_FUNC bbunpack(char **argv,
}
/* Extreme bloat for gunzip compat */
/* Some users do want this info... */
- if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE)) {
+ if (ENABLE_DESKTOP && (option_mask32 & BBUNPK_OPT_VERBOSE)) {
unsigned percent = status
? ((uoff_t)stat_buf.st_size * 100u / (unsigned long long)status)
: 0;
@@ -188,7 +175,7 @@ int FAST_FUNC bbunpack(char **argv,
}
/* Delete _source_ file */
del = filename;
- if (option_mask32 & OPT_KEEP) /* ... unless -k */
+ if (option_mask32 & BBUNPK_OPT_KEEP) /* ... unless -k */
del = NULL;
}
if (del)
@@ -199,7 +186,7 @@ int FAST_FUNC bbunpack(char **argv,
}
} while (*argv && *++argv);
- if (option_mask32 & OPT_STDOUT)
+ if (option_mask32 & BBUNPK_OPT_STDOUT)
xclose(STDOUT_FILENO); /* with error check! */
return exitcode;
@@ -389,9 +376,9 @@ int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int gunzip_main(int argc UNUSED_PARAM, char **argv)
{
#if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS
- getopt32long(argv, "cfkvqdtn", gunzip_longopts);
+ getopt32long(argv, BBUNPK_OPTSTR "dtn", gunzip_longopts);
#else
- getopt32(argv, "cfkvqdtn");
+ getopt32(argv, BBUNPK_OPTSTR "dtn");
#endif
argv += optind;
@@ -400,7 +387,7 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
* But if seamless magic is enabled, then we are much more clever.
*/
if (ENABLE_ZCAT && (!ENABLE_GUNZIP || applet_name[1] == 'c'))
- option_mask32 |= OPT_STDOUT | SEAMLESS_MAGIC;
+ option_mask32 |= BBUNPK_OPT_STDOUT | BBUNPK_SEAMLESS_MAGIC;
return bbunpack(argv, unpack_gz_stream, make_new_name_gunzip, /*unused:*/ NULL);
}
@@ -453,10 +440,10 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
{
- getopt32(argv, "cfkvqdt");
+ getopt32(argv, BBUNPK_OPTSTR "dt");
argv += optind;
if (ENABLE_BZCAT && (!ENABLE_BUNZIP2 || applet_name[2] == 'c')) /* bzcat */
- option_mask32 |= OPT_STDOUT;
+ option_mask32 |= BBUNPK_OPT_STDOUT;
return bbunpack(argv, unpack_bz2_stream, make_new_name_generic, "bz2");
}
@@ -526,15 +513,15 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unlzma_main(int argc UNUSED_PARAM, char **argv)
{
- IF_LZMA(int opts =) getopt32(argv, "cfkvqdt");
+ IF_LZMA(int opts =) getopt32(argv, BBUNPK_OPTSTR "dt");
# if ENABLE_LZMA
/* lzma without -d or -t? */
- if (applet_name[2] == 'm' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
+ if (applet_name[2] == 'm' && !(opts & (BBUNPK_OPT_DECOMPRESS|BBUNPK_OPT_TEST)))
bb_show_usage();
# endif
/* lzcat? */
if (ENABLE_LZCAT && applet_name[2] == 'c')
- option_mask32 |= OPT_STDOUT;
+ option_mask32 |= BBUNPK_OPT_STDOUT;
argv += optind;
return bbunpack(argv, unpack_lzma_stream, make_new_name_generic, "lzma");
@@ -594,15 +581,15 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv)
int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unxz_main(int argc UNUSED_PARAM, char **argv)
{
- IF_XZ(int opts =) getopt32(argv, "cfkvqdt");
+ IF_XZ(int opts =) getopt32(argv, BBUNPK_OPTSTR "dt");
# if ENABLE_XZ
/* xz without -d or -t? */
- if (applet_name[2] == '\0' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
+ if (applet_name[2] == '\0' && !(opts & (BBUNPK_OPT_DECOMPRESS|BBUNPK_OPT_TEST)))
bb_show_usage();
# endif
/* xzcat? */
if (ENABLE_XZCAT && applet_name[2] == 'c')
- option_mask32 |= OPT_STDOUT;
+ option_mask32 |= BBUNPK_OPT_STDOUT;
argv += optind;
return bbunpack(argv, unpack_xz_stream, make_new_name_generic, "xz");