SET(BSDCPIO_VERSION_STRING "${VERSION}")
SET(BSDTAR_VERSION_STRING "${VERSION}")
SET(BSDCAT_VERSION_STRING "${VERSION}")
+SET(BSDUNZIP_VERSION_STRING "${VERSION}")
SET(LIBARCHIVE_VERSION_NUMBER "${_version_number}")
SET(LIBARCHIVE_VERSION_STRING "${VERSION}")
LA_CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H)
LA_CHECK_INCLUDE_FILE("fnmatch.h" HAVE_FNMATCH_H)
+LA_CHECK_INCLUDE_FILE("getopt.h" HAVE_GETOPT_H)
LA_CHECK_INCLUDE_FILE("grp.h" HAVE_GRP_H)
LA_CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
LA_CHECK_INCLUDE_FILE("io.h" HAVE_IO_H)
unzip/test/test_q.c \
unzip/test/test_t.c \
unzip/test/test_t_bad.c \
+ unzip/test/test_version.c \
unzip/test/test_x.c \
unzip/test/test_Z1.c \
unzip/test/test_P_encryption.c
/* Version number of bsdcat */
#cmakedefine BSDCAT_VERSION_STRING "@BSDCAT_VERSION_STRING@"
+/* Version number of bsdunzip */
+#cmakedefine BSDUNZIP_VERSION_STRING "@BSDUNZIP_VERSION_STRING@"
+
/* Define to 1 if you have the `acl_create_entry' function. */
#cmakedefine HAVE_ACL_CREATE_ENTRY 1
/* Define to 1 if you have the `getline' function. */
#cmakedefine HAVE_GETLINE 1
+/* Define to 1 if you have the <getopt.h> header file. */
+#cmakedefine HAVE_GETOPT_H 1
+
/* Define to 1 if platform uses `optreset` to reset `getopt` */
#cmakedefine HAVE_GETOPT_OPTRESET 1
m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
m4_define([BSDCPIO_VERSION_S],LIBARCHIVE_VERSION_S())
m4_define([BSDCAT_VERSION_S],LIBARCHIVE_VERSION_S())
+m4_define([BSDUNZIP_VERSION_S],LIBARCHIVE_VERSION_S())
AC_PREREQ([2.71])
[Version number of bsdtar])
AC_DEFINE([BSDCAT_VERSION_STRING],"BSDTAR_VERSION_S()",
[Version number of bsdcat])
+AC_DEFINE([BSDUNZIP_VERSION_STRING],"BSDUNZIP_VERSION_S()",
+ [Version number of bsdunzip])
# The shell variables here must be the same as the AC_SUBST() variables
# below, but the shell variable names apparently cannot be the same as
BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
BSDCAT_VERSION_STRING=BSDCAT_VERSION_S()
+BSDUNZIP_VERSION_STRING=BSDUNZIP_VERSION_S()
LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
AC_SUBST(BSDCPIO_VERSION_STRING)
AC_SUBST(BSDTAR_VERSION_STRING)
AC_SUBST(BSDCAT_VERSION_STRING)
+AC_SUBST(BSDUNZIP_VERSION_STRING)
AC_SUBST(LIBARCHIVE_VERSION_STRING)
AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h])
AC_CHECK_HEADERS([copyfile.h ctype.h])
-AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h fnmatch.h grp.h])
+AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h fnmatch.h getopt.h grp.h])
AC_CACHE_CHECK([whether EXT2_IOC_GETFLAGS is usable],
[ac_cv_have_decl_EXT2_IOC_GETFLAGS],
#ifdef HAVE_FNMATCH_H
#include <fnmatch.h>
#endif
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
static int v_opt; /* verbose/list */
static const char *y_str = ""; /* 4 digit year */
static int Z1_opt; /* zipinfo mode list files only */
+static int version_opt; /* version string */
/* debug flag */
static int unzip_debug;
exit(EXIT_FAILURE);
}
+static void
+version(void)
+{
+ printf("bsdunzip %s - %s \n",
+ BSDUNZIP_VERSION_STRING,
+ archive_version_details());
+ exit(0);
+}
+
static int
getopts(int argc, char *argv[])
{
int opt;
+ static struct option longopts[] = {
+ { "version", no_argument, &version_opt, 1 },
+ { 0, 0, 0, 0}
+ };
+
optind = 1;
#ifdef HAVE_GETOPT_OPTRESET
optreset = 1;
#endif
- while ((opt = getopt(argc, argv, "aCcd:fI:jLlnO:opP:qtuvx:yZ1")) != -1)
+ while ((opt = getopt_long(argc, argv,
+ "aCcd:fI:jLlnO:opP:qtuvx:yZ1", longopts, NULL)) != -1) {
switch (opt) {
+ case 0:
+ break;
case '1':
Z1_opt = 1;
break;
default:
usage();
}
-
+ }
return (optind);
}
const char *zipfile;
int nopts;
+ lafe_setprogname(*argv, "bsdunzip");
+
if (isatty(STDOUT_FILENO))
tty = 1;
*/
nopts = getopts(argc, argv);
+ if (version_opt == 1) {
+ version();
+ exit(EXIT_SUCCESS);
+ }
+
/*
* When more of the zipinfo mode options are implemented, this
* will need to change.
test_q.c
test_t.c
test_t_bad.c
+ test_version.c
test_x.c
test_Z1.c
test_P_encryption.c
#undef EXTRA_DUMP /* How to dump extra data */
#undef EXTRA_ERRNO /* How to dump errno */
/* How to generate extra version info. */
-#define EXTRA_VERSION (systemf("%s -v", testprog) ? "" : "")
+#define EXTRA_VERSION (systemf("%s --version", testprog) ? "" : "")
#include "test_common.h"
--- /dev/null
+/*-
+ * Copyright (c) 2003-2017 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+
+/*
+ * Test that --version option works and generates reasonable output.
+ */
+
+DEFINE_TEST(test_version)
+{
+ assertVersion(testprog, "bsdunzip");
+}