157 lines
4.3 KiB
Plaintext
157 lines
4.3 KiB
Plaintext
--- config.h.in
|
|
+++ config.h.in 2007-12-07 15:50:22.900940943 +0100
|
|
@@ -220,6 +220,9 @@
|
|
/* 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
|
|
+
|
|
/* Define to 1 if you have the <limits.h> header file. */
|
|
#undef HAVE_LIMITS_H
|
|
|
|
--- configure.ac
|
|
+++ configure.ac 2007-12-07 15:55:02.636618503 +0100
|
|
@@ -98,6 +98,18 @@ AC_ARG_WITH(config-file,
|
|
fi],
|
|
: ${config_file=\$\{sysconfdir\}/man_db.conf}
|
|
: ${config_file_basename=man_db.conf})
|
|
+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})
|
|
dnl
|
|
dnl Finish the argument parsing
|
|
dnl
|
|
@@ -271,6 +283,29 @@ AC_SUBST(gunzip)dnl
|
|
AC_SUBST(uncompress)dnl
|
|
AC_SUBST(bunzip2)dnl
|
|
AC_CHECK_LIB(z, gzopen)
|
|
+dnl Check for zlib and libbz2 libraries to use this together
|
|
+dnl with SuSE's libzio to open compressed info files.
|
|
+dnl
|
|
+if test "$zio" = "no" || test -n "$zio"
|
|
+then
|
|
+ AC_CHECK_HEADER(zlib.h,[
|
|
+ for lib in z gz
|
|
+ do
|
|
+ AC_CHECK_LIB($lib, gzopen, [LIBS="$LIBS -l$lib" ; LEXLIB="$LEXLIB -l$lib" ; break])
|
|
+ done])
|
|
+ AC_CHECK_HEADER(bzlib.h,[
|
|
+ for lib in bz2 bzip2
|
|
+ do
|
|
+ AC_CHECK_LIB($lib, BZ2_bzopen, [LIBS="$LIBS -l$lib" ; LEXLIB="$LEXLIB -l$lib" ; break])
|
|
+ done])
|
|
+ AC_CHECK_HEADER(zio.h,[
|
|
+ for lib in ${zio#lib} zio
|
|
+ do
|
|
+ AC_CHECK_LIB($lib, fzopen, [LIBS="$LIBS -l$lib" ; LEXLIB="$LEXLIB -l$lib"
|
|
+ AC_DEFINE([COMP_SRC],[],[])
|
|
+ AC_DEFINE([HAVE_ZIO],[],[])])
|
|
+ done])
|
|
+fi
|
|
dnl
|
|
dnl to add more decompressors just follow the scheme above.
|
|
dnl
|
|
--- lib/decompress.c
|
|
+++ lib/decompress.c 2007-12-07 18:22:47.940413890 +0100
|
|
@@ -46,6 +46,10 @@
|
|
# include "zlib.h"
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
+#ifdef HAVE_ZIO
|
|
+# include "zio.h"
|
|
+#endif /* HAVE_ZIO */
|
|
+
|
|
#include "manconfig.h"
|
|
#include "comp_src.h"
|
|
#include "pipeline.h"
|
|
@@ -76,6 +80,32 @@ static void decompress_zlib (void *data
|
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
+#ifdef HAVE_ZIO
|
|
+
|
|
+static void decompress_zio (void *data)
|
|
+{
|
|
+ const char *what = (const char*)data;
|
|
+ FILE *file;
|
|
+
|
|
+ file = fdzopen(dup (fileno (stdin)), "r", what);
|
|
+ if (!file)
|
|
+ return;
|
|
+
|
|
+ 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;
|
|
+ }
|
|
+
|
|
+ fclose(file);
|
|
+ return;
|
|
+}
|
|
+
|
|
+#endif /* HAVE_ZIO */
|
|
+
|
|
pipeline *decompress_open (const char *filename)
|
|
{
|
|
command *cmd;
|
|
@@ -87,9 +117,45 @@ pipeline *decompress_open (const char *f
|
|
char *ext;
|
|
struct compression *comp;
|
|
|
|
- if (stat (filename, &st) < 0 && !S_ISDIR (st.st_mode))
|
|
+ if (stat (filename, &st) < 0 || S_ISDIR (st.st_mode))
|
|
return NULL;
|
|
|
|
+#ifdef HAVE_ZIO
|
|
+ ext = strrchr(filename, '.');
|
|
+ if (ext && STREQ (ext, ".gz")) {
|
|
+ /* informational only; no shell quoting concerns */
|
|
+ char *name = strappend (NULL, "zcat < ", filename, NULL);
|
|
+ cmd = command_new_function (name, &decompress_zio, "g");
|
|
+ free (name);
|
|
+ p = pipeline_new_commands (cmd, NULL);
|
|
+ goto got_pipeline;
|
|
+ }
|
|
+ if (ext && STREQ (ext, ".z")) {
|
|
+ /* informational only; no shell quoting concerns */
|
|
+ char *name = strappend (NULL, "zcat < ", filename, NULL);
|
|
+ cmd = command_new_function (name, &decompress_zio, "z");
|
|
+ free (name);
|
|
+ p = pipeline_new_commands (cmd, NULL);
|
|
+ goto got_pipeline;
|
|
+ }
|
|
+ if (ext && STREQ (ext, ".bz2")) {
|
|
+ /* informational only; no shell quoting concerns */
|
|
+ char *name = strappend (NULL, "bzcat < ", filename, NULL);
|
|
+ cmd = command_new_function (name, &decompress_zio, "b");
|
|
+ free (name);
|
|
+ p = pipeline_new_commands (cmd, NULL);
|
|
+ goto got_pipeline;
|
|
+ }
|
|
+ if (ext && STREQ (ext, ".Z")) {
|
|
+ /* informational only; no shell quoting concerns */
|
|
+ char *name = strappend (NULL, "zcat < ", filename, NULL);
|
|
+ cmd = command_new_function (name, &decompress_zio, "Z");
|
|
+ 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")) {
|