summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Scorgie <dscorgie@src.gnome.org>2008-01-07 21:40:14 +0000
committerDon Scorgie <dscorgie@src.gnome.org>2008-01-07 21:40:14 +0000
commited523da10e8a8f3ff73712ef7c25088a60e3d497 (patch)
treeaf066704068687a976a9df97523d984baf490572
parentdfb5fbb9049ce034a53f5169ba2a2e7ed0f54481 (diff)
downloadyelp-ed523da10e8a8f3ff73712ef7c25088a60e3d497.tar.gz
Add LZMA support bug #470990 - Per Øyvind Karlsen
* configure.in: * src/yelp-io-channel.c: * src/yelp-info-parser.c: * src/yelp-utils.c: * src/Makefile.am: Add LZMA support bug #470990 - Per Øyvind Karlsen svn path=/trunk/; revision=3021
-rw-r--r--ChangeLog8
-rw-r--r--configure.in8
-rw-r--r--src/Makefile.am5
-rw-r--r--src/yelp-info-parser.c6
-rw-r--r--src/yelp-io-channel.c31
-rw-r--r--src/yelp-utils.c7
6 files changed, 59 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 88c744cb..5685f375 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2008-01-07 Don Scorgie <dscorgie@svn.gnome.org>
+ * configure.in:
+ * src/yelp-io-channel.c:
+ * src/yelp-info-parser.c:
+ * src/yelp-utils.c:
+ * src/Makefile.am:
+ Add LZMA support
+ bug #470990 - Per Øyvind Karlsen
+
* src/yelp-window.c:
Fix find bar up to look more like epiphany
Bug #483305 - Michael Monreal
diff --git a/configure.in b/configure.in
index c58f3781..2d6b1963 100644
--- a/configure.in
+++ b/configure.in
@@ -203,6 +203,14 @@ AC_CHECK_LIB(z, gzopen, [Z_LIBS=-lz
AC_SUBST(Z_LIBS)], AC_MSG_ERROR([*** zlib is required]))
dnl ====================================
+dnl = lzmadec for help converters
+dnl ====================================
+LZMADEC_LIBS=
+AC_CHECK_LIB(lzmadec, lzmadec_open, [LZMADEC_LIBS=-llzmadec
+ AC_DEFINE(HAVE_LIBLZMADEC, 1, [Compile with liblzmadec support])])
+AC_SUBST(LZMADEC_LIBS)
+
+dnl ====================================
dnl = Bzip2, for the help converters
dnl ====================================
BZ_LIBS=
diff --git a/src/Makefile.am b/src/Makefile.am
index 5c7fd3d7..731d423f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -86,6 +86,7 @@ yelp_LDADD = \
$(POPT_LIBS) \
$(Z_LIBS) \
$(BZ_LIBS) \
+ $(LZMADEC_LIBS) \
$(X_LIBS) \
$(MOZILLA_COMPONENT_LIBS) \
$(MOZILLA_EXTRA_LIBS) \
@@ -113,7 +114,7 @@ test_document_SOURCES = \
yelp-transform.c yelp-transform.h \
test-document.c
test_document_CFLAGS = $(YELP_CFLAGS) $(AM_CFLAGS) $(YELP_DEFINES)
-test_document_LDADD = $(YELP_LIBS) $(Z_LIBS) $(BZ_LIBS)
+test_document_LDADD = $(YELP_LIBS) $(Z_LIBS) $(BZ_LIBS) $(LZMADEC_LIBS)
test_document_LDFLAGS = $(AM_LDFLAGS)
test_man_parser_SOURCES = \
@@ -124,7 +125,7 @@ test_man_parser_SOURCES = \
test-man-parser.c
test_man_parser_CPPFLAGS = $(YELP_DEFINES) $(AM_CPPFLAGS)
test_man_parser_CFLAGS = $(YELP_CFLAGS) $(AM_CFLAGS)
-test_man_parser_LDADD = $(YELP_LIBS) $(Z_LIBS) $(BZ_LIBS)
+test_man_parser_LDADD = $(YELP_LIBS) $(Z_LIBS) $(BZ_LIBS) $(LZMADEC_LIBS)
test_man_parser_LDFLAGS = $(AM_LDFLAGS)
test_page_SOURCES = \
diff --git a/src/yelp-info-parser.c b/src/yelp-info-parser.c
index c1cbbf58..22966525 100644
--- a/src/yelp-info-parser.c
+++ b/src/yelp-info-parser.c
@@ -137,21 +137,25 @@ find_info_part (gchar *part_name, gchar *base)
*/
gchar *path;
gchar *tmp;
- gchar *bzfname, *gzfname;
+ gchar *bzfname, *gzfname, *lzfd;
gchar *uri = NULL;
tmp = g_strrstr (base, "/");
path = g_strndup (base, tmp-base);
bzfname = g_strconcat (path, "/", part_name, ".bz2", NULL);
gzfname = g_strconcat (path, "/", part_name, ".gz", NULL);
+ lzfd = g_strconcat (path, "/", part_name, ".lzma", NULL);
if (g_file_test (bzfname, G_FILE_TEST_EXISTS))
uri = g_strdup (bzfname);
else if (g_file_test (gzfname, G_FILE_TEST_EXISTS))
uri = g_strdup (gzfname);
+ else if (g_file_test (lzfd, G_FILE_TEST_EXISTS))
+ uri = g_strdup (lzfd);
g_free (bzfname);
g_free (gzfname);
+ g_free (lzfd);
g_free (path);
return uri;
diff --git a/src/yelp-io-channel.c b/src/yelp-io-channel.c
index 16c57509..80b1957e 100644
--- a/src/yelp-io-channel.c
+++ b/src/yelp-io-channel.c
@@ -31,6 +31,9 @@
#ifdef HAVE_LIBBZ2
#include <bzlib.h>
#endif
+#ifdef HAVE_LIBLZMADEC
+#include <lzmadec.h>
+#endif
#include <string.h>
#include "yelp-error.h"
@@ -43,6 +46,9 @@ struct _YelpIOChannel {
BZFILE *bzin;
#endif
gzFile gzin;
+#ifdef HAVE_LIBLZMADEC
+ lzmadec_FILE *lzin;
+#endif
};
static GIOStatus yelp_io_read (GIOChannel *channel,
@@ -91,13 +97,23 @@ yelp_io_channel_new_file (gchar *file,
channel->bzin = bzopen (file, "r");
else
#endif
+#ifdef HAVE_LIBLZMADEC
+ if (g_str_has_suffix (file, ".lzma"))
+ channel->lzin = lzmadec_open(file);
+ else
+#endif
+
channel->gzin = gzopen (file, "r");
+ if(
#ifdef HAVE_LIBBZ2
- if (!channel->bzin && !channel->gzin) {
-#else
- if (!channel->gzin) {
+ !channel->bzin &&
#endif
+#ifdef HAVE_LIBLZMADEC
+ !channel->lzin &&
+#endif
+ !channel->gzin) {
+
yelp_io_free (iochannel);
channel = (YelpIOChannel *) g_io_channel_new_file (file, "r", error);
@@ -141,6 +157,11 @@ yelp_io_read (GIOChannel *channel,
bytes = bzread (yelp_channel->bzin, buffer, count);
else
#endif
+#if HAVE_LIBLZMADEC
+ if (yelp_channel->lzin)
+ bytes = lzmadec_read (yelp_channel->lzin, buffer, count);
+ else
+#endif
bytes = gzread (yelp_channel->gzin, buffer, count);
*bytes_read = bytes;
@@ -163,6 +184,10 @@ yelp_io_close (GIOChannel *channel,
if (yelp_channel->bzin)
bzclose (yelp_channel->bzin);
#endif
+#ifdef HAVE_LIBLZMADEC
+ if (yelp_channel->lzin)
+ lzmadec_close (yelp_channel->lzin);
+#endif
if (yelp_channel->gzin)
gzclose (yelp_channel->gzin);
diff --git a/src/yelp-utils.c b/src/yelp-utils.c
index 5961c492..17e683ba 100644
--- a/src/yelp-utils.c
+++ b/src/yelp-utils.c
@@ -179,6 +179,13 @@ resolve_full_file (const gchar *path)
} else if (resolve_is_man_path (path, "bz2")) {
type = YELP_RRN_TYPE_MAN;
}
+ } else if (g_str_equal (mime_type, "application/x-lzma")) {
+ if (g_str_has_suffix (path, ".info.lzma")) {
+ type = YELP_RRN_TYPE_INFO;
+ } else if (resolve_is_man_path (path, "lzma")) {
+ type = YELP_RRN_TYPE_MAN;
+ }
+
} else if (g_str_equal (mime_type, "text/plain")) {
if (g_str_has_suffix (path, ".info")) {
type = YELP_RRN_TYPE_INFO;