+//config:config UNZIP
+//config: bool "unzip"
+//config: default y
+//config: help
+//config: unzip will list or extract files from a ZIP archive,
+//config: commonly found on DOS/WIN systems. The default behavior
+//config: (with no options) is to extract the archive into the
+//config: current directory.
+//config:
+//config:config FEATURE_UNZIP_CDF
+//config: bool "Read and use Central Directory data"
+//config: default y
+//config: depends on UNZIP
+//config: help
+//config: If you know that you only need to deal with simple
+//config: ZIP files without deleted/updated files, SFX archives etc,
+//config: you can reduce code size by unselecting this option.
+//config: To support less trivial ZIPs, say Y.
+//config:
+//config:config FEATURE_UNZIP_BZIP2
+//config: bool "Support compression method 12 (bzip2)"
+//config: default y
+//config: depends on FEATURE_UNZIP_CDF && DESKTOP
+// FEATURE_UNZIP_CDF is needed, otherwise we can't find start of next file
+// DESKTOP is needed to get back uncompressed length
+//config:
+//config:config FEATURE_UNZIP_LZMA
+//config: bool "Support compression method 14 (lzma)"
+//config: default y
+//config: depends on FEATURE_UNZIP_CDF && DESKTOP
+//config:
+//config:config FEATURE_UNZIP_XZ
+//config: bool "Support compression method 95 (xz)"
+//config: default y
+//config: depends on FEATURE_UNZIP_CDF && DESKTOP
+
+//applet:IF_UNZIP(APPLET(unzip, BB_DIR_USR_BIN, BB_SUID_DROP))
+//kbuild:lib-$(CONFIG_UNZIP) += unzip.o
+
+//usage:#define unzip_trivial_usage
+//usage: "[-lnopq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]"
+//usage:#define unzip_full_usage "\n\n"
+//usage: "Extract FILEs from ZIP archive\n"
+//usage: "\n -l List contents (with -q for short form)"
+//usage: "\n -n Never overwrite files (default: ask)"
+//usage: "\n -o Overwrite"
+//usage: "\n -p Print to stdout"
+//usage: "\n -q Quiet"
+//usage: "\n -x FILE Exclude FILEs"
+//usage: "\n -d DIR Extract into DIR"
+
+#include "libbb.h"
+#include "bb_archive.h"
+
+#if 0
+# define dbg(...) bb_error_msg(__VA_ARGS__)
+#else
+# define dbg(...) ((void)0)
+#endif
+
+enum {
+#if BB_BIG_ENDIAN
+ ZIP_FILEHEADER_MAGIC = 0x504b0304,
+ ZIP_CDF_MAGIC = 0x504b0102, /* CDF item */
+ ZIP_CDE_MAGIC = 0x504b0506, /* End of CDF */
+ ZIP_DD_MAGIC = 0x504b0708,
+#else
+ ZIP_FILEHEADER_MAGIC = 0x04034b50,
+ ZIP_CDF_MAGIC = 0x02014b50,
+ ZIP_CDE_MAGIC = 0x06054b50,
+ ZIP_DD_MAGIC = 0x08074b50,
+#endif
+};
+
+#define ZIP_HEADER_LEN 26