2014-04-08 15:02:52 +02:00
|
|
|
---
|
2015-05-28 15:24:43 +02:00
|
|
|
config.h.in | 3 ++
|
|
|
|
configure.ac | 52 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
lib/decompress.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2014-04-08 15:02:52 +02:00
|
|
|
3 files changed, 120 insertions(+)
|
|
|
|
|
2012-10-02 19:06:04 +02:00
|
|
|
--- config.h.in
|
2018-11-26 12:53:50 +01:00
|
|
|
+++ config.h.in 2018-11-23 13:11:12.684900437 +0000
|
|
|
|
@@ -896,6 +896,9 @@
|
2012-10-02 19:06:04 +02:00
|
|
|
/* Define to 1 if you have the `z' library (-lz). */
|
|
|
|
#undef HAVE_LIBZ
|
|
|
|
|
|
|
|
+/* Define to 1 if you have libzio for opening compressed manuals */
|
|
|
|
+#undef HAVE_ZIO
|
|
|
|
+
|
2018-11-26 12:53:50 +01:00
|
|
|
/* Define to 1 if you have the <limits.h> header file. */
|
|
|
|
#undef HAVE_LIMITS_H
|
2012-10-02 19:06:04 +02:00
|
|
|
|
|
|
|
--- configure.ac
|
2018-11-26 12:53:50 +01:00
|
|
|
+++ configure.ac 2018-11-23 13:09:58.982262008 +0000
|
|
|
|
@@ -34,6 +34,18 @@ MAN_ARG_DEVICE
|
2015-05-28 15:24:43 +02:00
|
|
|
MAN_ARG_DB
|
|
|
|
MAN_ARG_CONFIG_FILE
|
|
|
|
MAN_ARG_SECTIONS
|
2012-10-02 19:06:04 +02:00
|
|
|
+AC_ARG_WITH([zio],
|
|
|
|
+[AS_HELP_STRING([--with-zio=LIBRARY], [use zlib/libbz2 wrapper library LIBRARY (libzio)])],
|
|
|
|
+ [if test -z "$withval" -o "$withval" = "yes"
|
|
|
|
+ then
|
|
|
|
+ zio=libzio
|
|
|
|
+ elif test "$withval" = "no"
|
|
|
|
+ then
|
|
|
|
+ AC_MSG_ERROR(--with-zio requires an argument)
|
|
|
|
+ else
|
|
|
|
+ zio=$withval
|
|
|
|
+ fi],
|
|
|
|
+ [: ${zio=no}])
|
2015-05-28 15:24:43 +02:00
|
|
|
MAN_ARG_AUTOMATIC_CREATE
|
|
|
|
MAN_ARG_AUTOMATIC_UPDATE
|
|
|
|
MAN_ARG_CATS
|
2018-11-26 12:53:50 +01:00
|
|
|
@@ -325,6 +337,46 @@ AC_SUBST([unlzma])
|
2012-10-02 19:06:04 +02:00
|
|
|
AC_SUBST([unxz])
|
|
|
|
AC_SUBST([unlzip])
|
|
|
|
MAN_COMPRESS_LIB([z], [gzopen])
|
|
|
|
+dnl Check for zlib and libbz2 libraries to use this together
|
2015-05-28 15:24:43 +02:00
|
|
|
+dnl with SUSE's libzio to open compressed info files.
|
2012-10-02 19:06:04 +02:00
|
|
|
+dnl
|
|
|
|
+if test "$zio" = "no" || test -n "$zio"
|
|
|
|
+then
|
2015-05-28 15:24:43 +02:00
|
|
|
+ AC_CHECK_HEADER(zio.h,[
|
|
|
|
+ for lib in ${zio#lib} zio
|
|
|
|
+ do
|
|
|
|
+ AC_CHECK_LIB($lib, fzopen, [LIBS="-l$lib $LIBS"; am_cv_libzio=yes])
|
|
|
|
+ done
|
|
|
|
+ ])
|
|
|
|
+ if test "$am_cv_libzio" = yes; then
|
|
|
|
+ AC_DEFINE([COMP_SRC],[],[Define if you have compressors and want to support compressed cat files.])
|
|
|
|
+ AC_DEFINE([HAVE_ZIO],[],[Define to 1 if you have libzio for opening compressed manuals])
|
|
|
|
+ AC_CHECK_HEADER(zlib.h,[
|
|
|
|
+ for lib in z gz
|
|
|
|
+ do
|
|
|
|
+ AC_CHECK_LIB($lib, gzopen, [LIBS="$LIBS -Wl,--no-as-needed -l$lib"; break])
|
|
|
|
+ done
|
|
|
|
+ ])
|
|
|
|
+ AC_CHECK_HEADER(bzlib.h,[
|
|
|
|
+ for lib in bz2 bzip2
|
|
|
|
+ do
|
|
|
|
+ AC_CHECK_LIB($lib, BZ2_bzopen, [LIBS="$LIBS -Wl,--no-as-needed -l$lib"; break])
|
|
|
|
+ done
|
|
|
|
+ ])
|
|
|
|
+ AC_CHECK_HEADER(lzmadec.h, [
|
|
|
|
+ for lib in lzma lzmadec
|
|
|
|
+ do
|
|
|
|
+ AC_CHECK_LIB($lib, lzmadec_open, [LIBS="$LIBS -Wl,--no-as-needed -l$lib"; break])
|
|
|
|
+ done
|
|
|
|
+ ])
|
|
|
|
+ AC_CHECK_HEADER(lzma.h, [
|
|
|
|
+ for lib in lzma
|
|
|
|
+ do
|
|
|
|
+ AC_CHECK_LIB($lib, lzma_easy_encoder, [LIBS="$LIBS -Wl,--no-as-needed -l$lib"; break])
|
|
|
|
+ done
|
|
|
|
+ ])
|
|
|
|
+ fi
|
2012-10-02 19:06:04 +02:00
|
|
|
+fi
|
|
|
|
dnl To add more decompressors just follow the scheme above.
|
|
|
|
|
2015-05-28 15:24:43 +02:00
|
|
|
# Check for various header files and associated libraries.
|
2012-10-02 19:06:04 +02:00
|
|
|
--- lib/decompress.c
|
2018-11-26 12:53:50 +01:00
|
|
|
+++ lib/decompress.c 2018-11-23 13:12:59.714923151 +0000
|
2014-04-08 15:02:52 +02:00
|
|
|
@@ -38,6 +38,10 @@
|
|
|
|
|
|
|
|
#include "xvasprintf.h"
|
2012-10-02 19:06:04 +02:00
|
|
|
|
|
|
|
+#ifdef HAVE_ZIO
|
|
|
|
+# include "zio.h"
|
|
|
|
+#endif /* HAVE_ZIO */
|
|
|
|
+
|
|
|
|
#include "manconfig.h"
|
|
|
|
#include "comp_src.h"
|
|
|
|
#include "pipeline.h"
|
2018-11-26 12:53:50 +01:00
|
|
|
@@ -69,6 +73,32 @@ static void decompress_zlib (void *data
|
2012-10-02 19:06:04 +02:00
|
|
|
|
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
|
|
|
|
+#ifdef HAVE_ZIO
|
|
|
|
+
|
|
|
|
+static void decompress_zio (void *data)
|
|
|
|
+{
|
|
|
|
+ const char *what = (const char*)data;
|
|
|
|
+ FILE *file;
|
2018-11-26 12:53:50 +01:00
|
|
|
+
|
2012-10-02 19:06:04 +02:00
|
|
|
+ file = fdzopen(dup (fileno (stdin)), "r", what);
|
|
|
|
+ if (!file)
|
|
|
|
+ return;
|
2018-11-26 12:53:50 +01:00
|
|
|
+
|
2012-10-02 19:06:04 +02:00
|
|
|
+ for (;;) {
|
|
|
|
+ char buffer[4096];
|
|
|
|
+ int r = fread(buffer, sizeof(char), sizeof(buffer), file);
|
|
|
|
+ if (r <= 0)
|
|
|
|
+ break;
|
|
|
|
+ if (fwrite (buffer, 1, (size_t) r, stdout) < (size_t) r)
|
|
|
|
+ break;
|
|
|
|
+ }
|
2018-11-26 12:53:50 +01:00
|
|
|
+
|
|
|
|
+ fclose(file);
|
2012-10-02 19:06:04 +02:00
|
|
|
+ return;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#endif /* HAVE_ZIO */
|
|
|
|
+
|
2018-11-26 12:53:50 +01:00
|
|
|
extern man_sandbox *sandbox;
|
|
|
|
|
2012-10-02 19:06:04 +02:00
|
|
|
pipeline *decompress_open (const char *filename)
|
2018-11-26 12:53:50 +01:00
|
|
|
@@ -85,6 +115,37 @@ pipeline *decompress_open (const char *f
|
2012-10-02 19:06:04 +02:00
|
|
|
if (stat (filename, &st) < 0 || S_ISDIR (st.st_mode))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
+#ifdef HAVE_ZIO
|
|
|
|
+ ext = strrchr (filename, '.');
|
|
|
|
+ if (ext) {
|
2012-10-02 19:32:58 +02:00
|
|
|
+ const char *opt;
|
2012-10-02 19:06:04 +02:00
|
|
|
+ char *name;
|
|
|
|
+
|
|
|
|
+ if (STREQ (ext, ".gz"))
|
2012-10-02 19:32:58 +02:00
|
|
|
+ opt = "g";
|
2012-10-02 19:06:04 +02:00
|
|
|
+ else if (STREQ (ext, ".z"))
|
2012-10-02 19:32:58 +02:00
|
|
|
+ opt = "z";
|
2012-10-02 19:06:04 +02:00
|
|
|
+ else if (STREQ (ext, ".bz2"))
|
2012-10-02 19:32:58 +02:00
|
|
|
+ opt = "b";
|
2012-10-02 19:06:04 +02:00
|
|
|
+ else if (STREQ (ext, ".xz"))
|
2012-10-02 19:32:58 +02:00
|
|
|
+ opt = "x";
|
2012-10-02 19:06:04 +02:00
|
|
|
+ else if (STREQ (ext, ".lzma"))
|
2012-10-02 19:32:58 +02:00
|
|
|
+ opt = "l";
|
2012-10-02 19:06:04 +02:00
|
|
|
+ else if (STREQ (ext, ".Z"))
|
2012-10-02 19:32:58 +02:00
|
|
|
+ opt = "Z";
|
2012-10-02 19:06:04 +02:00
|
|
|
+ else
|
|
|
|
+ goto nozio;
|
|
|
|
+
|
|
|
|
+ /* informational only; no shell quoting concerns */
|
|
|
|
+ name = appendstr (NULL, "libzio < ", filename, NULL);
|
|
|
|
+ cmd = pipecmd_new_function (name, &decompress_zio, NULL,
|
|
|
|
+ opt);
|
|
|
|
+ free (name);
|
|
|
|
+ p = pipeline_new_commands (cmd, NULL);
|
|
|
|
+ goto got_pipeline;
|
|
|
|
+ }
|
|
|
|
+#endif /* HAVE_ZIO */
|
|
|
|
+
|
|
|
|
#ifdef HAVE_LIBZ
|
|
|
|
filename_len = strlen (filename);
|
|
|
|
if (filename_len > 3 && STREQ (filename + filename_len - 3, ".gz")) {
|
2018-11-26 12:53:50 +01:00
|
|
|
@@ -96,7 +157,11 @@ pipeline *decompress_open (const char *f
|
2012-10-02 19:06:04 +02:00
|
|
|
}
|
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
|
|
|
|
+#ifdef HAVE_ZIO
|
|
|
|
+nozio:
|
|
|
|
+#else
|
|
|
|
ext = strrchr (filename, '.');
|
|
|
|
+#endif /* HAVE_LIBZ */
|
|
|
|
if (ext) {
|
|
|
|
++ext;
|
|
|
|
|