libarchive: move bbunpack constants to bb_archive.h

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
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 @@
 
 		/* 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 @@
 				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 @@
 			}
 
 			/* -f: overwrite existing output files */
-			if (option_mask32 & OPT_FORCE) {
+			if (option_mask32 & BBUNPK_OPT_FORCE) {
 				unlink(new_name);
 			}
 
@@ -126,12 +113,12 @@
 		}
 
 		/* 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 @@
 				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 @@
 				}
 				/* 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 @@
 				}
 				/* 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 @@
 		}
 	} 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 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 @@
 	 * 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 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 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 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");