yelp r3021 - in trunk: . src



Author: dscorgie
Date: Mon Jan  7 21:40:14 2008
New Revision: 3021
URL: http://svn.gnome.org/viewvc/yelp?rev=3021&view=rev

Log:
* 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


Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/Makefile.am
   trunk/src/yelp-info-parser.c
   trunk/src/yelp-io-channel.c
   trunk/src/yelp-utils.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Mon Jan  7 21:40:14 2008
@@ -203,6 +203,14 @@
 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=

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Mon Jan  7 21:40:14 2008
@@ -86,6 +86,7 @@
 	$(POPT_LIBS)			\
 	$(Z_LIBS)			\
 	$(BZ_LIBS)			\
+	$(LZMADEC_LIBS)			\
 	$(X_LIBS)			\
 	$(MOZILLA_COMPONENT_LIBS)	\
 	$(MOZILLA_EXTRA_LIBS)		\
@@ -113,7 +114,7 @@
 	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.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 =					\

Modified: trunk/src/yelp-info-parser.c
==============================================================================
--- trunk/src/yelp-info-parser.c	(original)
+++ trunk/src/yelp-info-parser.c	Mon Jan  7 21:40:14 2008
@@ -137,21 +137,25 @@
    */
   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;
 

Modified: trunk/src/yelp-io-channel.c
==============================================================================
--- trunk/src/yelp-io-channel.c	(original)
+++ trunk/src/yelp-io-channel.c	Mon Jan  7 21:40:14 2008
@@ -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 @@
     BZFILE     *bzin;
 #endif
     gzFile      gzin;
+#ifdef HAVE_LIBLZMADEC
+    lzmadec_FILE *lzin;
+#endif
 };
 
 static GIOStatus    yelp_io_read          (GIOChannel    *channel,
@@ -91,13 +97,23 @@
 	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 @@
 	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 @@
     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);
 

Modified: trunk/src/yelp-utils.c
==============================================================================
--- trunk/src/yelp-utils.c	(original)
+++ trunk/src/yelp-utils.c	Mon Jan  7 21:40:14 2008
@@ -179,6 +179,13 @@
 	} 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]