[evolution-ews] Allow upstream libmspack to be used, if it's new enough



commit be622f12d46e39e6217992ac213caa40c386e555
Author: David Woodhouse <David Woodhouse intel com>
Date:   Wed May 15 15:18:38 2013 +0100

    Allow upstream libmspack to be used, if it's new enough

 configure.ac                             |   18 +++++++++
 src/addressbook/lzx/Makefile.am          |   15 +++++--
 src/addressbook/lzx/ews-oal-decompress.c |   60 ++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fc3327f..d46e6d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -221,6 +221,24 @@ dnl ****************************
 EVO_KRB5_SUPPORT
 
 dnl ****************************
+dnl Check for libmspack with OAB support
+dnl ****************************
+PKG_CHECK_MODULES(MSPACK, libmspack,
+                 [oldLIBS="$LIBS"
+                  oldCFLAGS="$CFLAGS"
+                  LIBS="$LIBS $MSPACK_LIBS"
+                  CFLAGS="$CFLAGS $MSPACK_CFLAGS"
+                  AC_CHECK_FUNC(mspack_create_oab_decompressor,
+                                [have_mspack=yes
+                                 AC_DEFINE(USE_MSPACK, [1],
+                                           [libmspack has OAB support])],
+                                [have_mspack=no])
+                  LIBS="$oldLIBS"
+                  CFLAGS="$oldCFLAGS"],
+                 [have_mspack=no])
+AM_CONDITIONAL(HAVE_MSPACK, [test "$have_mspack" = "yes"])
+
+dnl ****************************
 dnl Check for libsoup's SOUP_MESSAGE_IDEMPOTENT SoupMessage flag
 dnl ****************************
 AC_MSG_CHECKING([libsoup SOUP_MESSAGE_IDEMPOTENT flag])
diff --git a/src/addressbook/lzx/Makefile.am b/src/addressbook/lzx/Makefile.am
index 2dbe221..d259aba 100644
--- a/src/addressbook/lzx/Makefile.am
+++ b/src/addressbook/lzx/Makefile.am
@@ -2,18 +2,23 @@ NULL =
 
 lib_LTLIBRARIES = liblzx.la
 
+if HAVE_MSPACK
+USE_MSPACK_CFLAGS = $(MSPACK_CFLAGS)
+USE_MSPACK_LIBS = $(MSPACK_LIBS)
+else
+MSPACK_SRCS = lzx.h lzxd.c readbits.h readhuff.h
+endif
+
 liblzx_la_CPPFLAGS = \
        $(AM_CPPFLAGS) \
        $(GNOME_PLATFORM_CFLAGS) \
+       $(USE_MSPACK_CFLAGS) \
        $(NULL)
 
 liblzx_la_SOURCES = \
-       lzx.h \
        ews-oal-decompress.h \
-       lzxd.c \
        ews-oal-decompress.c \
-       readbits.h \
-       readhuff.h \
+       $(MSPACK_SRCS) \
        $(NULL)
 
 liblzx_la_LDFLAGS = $(NO_UNDEFINED)
@@ -21,6 +26,7 @@ liblzx_la_LDFLAGS = $(NO_UNDEFINED)
 liblzx_la_LIBADD = \
        $(GNOME_PLATFORM_LIBS) \
        $(LIBM) \
+       $(USE_MSPACK_LIBS) \
        $(NULL)
 
 noinst_PROGRAMS = gal-lzx-decompress-test
@@ -28,6 +34,7 @@ noinst_PROGRAMS = gal-lzx-decompress-test
 gal_lzx_decompress_test_CPPFLAGS = \
        $(AM_CPPFLAGS) \
        $(GNOME_PLATFORM_CFLAGS) \
+       $(USE_MSPACK_CFLAGS) \
        $(NULL)
 
 gal_lzx_decompress_test_SOURCES = \
diff --git a/src/addressbook/lzx/ews-oal-decompress.c b/src/addressbook/lzx/ews-oal-decompress.c
index 96872a2..cb45b91 100644
--- a/src/addressbook/lzx/ews-oal-decompress.c
+++ b/src/addressbook/lzx/ews-oal-decompress.c
@@ -31,9 +31,68 @@
 #include <unistd.h>
 #include <glib.h>
 #include <glib/gstdio.h>
+#ifdef USE_MSPACK
+#include <mspack.h>
+#else
 #include "lzx.h"
+#endif
 #include "ews-oal-decompress.h"
 
+#ifdef USE_MSPACK
+
+gboolean
+oal_decompress_v4_full_detail_file (const gchar *filename,
+                                    const gchar *output_filename,
+                                    GError **error)
+{
+       struct msoab_decompressor *msoab;
+       int ret;
+
+       msoab = mspack_create_oab_decompressor (NULL);
+       if (!msoab) {
+               g_set_error_literal (error, g_quark_from_string ("lzx"), 1,
+                                    "Unable to create msoab decompressor");
+               return FALSE;
+       }
+       ret = msoab->decompress (msoab, filename, output_filename);
+       mspack_destroy_oab_decompressor (msoab);
+       if (ret != MSPACK_ERR_OK) {
+               g_set_error (error, g_quark_from_string ("lzx"), 1,
+                            "Failed to decompress LZX file: %d", ret);
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+
+gboolean
+oal_apply_binpatch (const gchar *filename, const gchar *orig_filename,
+                   const gchar *output_filename, GError **error)
+{
+       struct msoab_decompressor *msoab;
+       int ret;
+
+       msoab = mspack_create_oab_decompressor (NULL);
+       if (!msoab) {
+               g_set_error_literal (error, g_quark_from_string ("lzx"), 1,
+                                    "Unable to create msoab decompressor");
+               return FALSE;
+       }
+       ret = msoab->decompress_incremental (msoab, filename,
+                                            orig_filename, output_filename);
+       mspack_destroy_oab_decompressor (msoab);
+       if (ret != MSPACK_ERR_OK) {
+               g_set_error (error, g_quark_from_string ("lzx"), 1,
+                            "Failed to apply LZX patch file: %d", ret);
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+#else /* USE_MSPACK */
+
 /* endian-neutral reading of little-endian data */
 #define __egi32(a,n) ( ((((unsigned char *) a)[n+3]) << 24) | \
                        ((((guchar *) a)[n + 2]) << 16) | \
@@ -480,3 +539,4 @@ exit:
 
        return ret;
 }
+#endif /* USE_MSPACK */


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