Debian Codegraph @

src/EWS/addressbook/ews-oab-decompress.c

raw
1 /*
2 * SPDX-FileCopyrightText: (C) 1999-2008 Novell, Inc. (www.novell.com)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6 #include "evolution-ews-config.h"
7
8 #include <glib.h>
9 #include "ews-oab-decompress.h"
10 #include <mspack.h>
11
12 /* This contains the minimal implementation of these functions, for use with
13 a sufficiently up-to-date version of libmspack. For the full implementation
14 for use without libmspack, see the lzx/ directory. */
15
16 gboolean
17 ews_oab_decompress_full (const gchar *filename, const gchar *output_filename,
18 GError **error)
19 {
20 struct msoab_decompressor *msoab;
21 int ret;
22
23 msoab = mspack_create_oab_decompressor (NULL);
24 if (!msoab) {
25 g_set_error_literal (error, g_quark_from_string ("lzx"), 1,
26 "Unable to create msoab decompressor");
27 return FALSE;
28 }
29 ret = msoab->decompress (msoab, filename, output_filename);
30 mspack_destroy_oab_decompressor (msoab);
31 if (ret != MSPACK_ERR_OK) {
32 g_set_error (error, g_quark_from_string ("lzx"), 1,
33 "Failed to decompress LZX file: %d", ret);
34 return FALSE;
35 }
36
37 return TRUE;
38 }
39
40
41 gboolean
42 ews_oab_decompress_patch (const gchar *filename, const gchar *orig_filename,
43 const gchar *output_filename, GError **error)
44 {
45 struct msoab_decompressor *msoab;
46 int ret;
47
48 msoab = mspack_create_oab_decompressor (NULL);
49 if (!msoab) {
50 g_set_error_literal (error, g_quark_from_string ("lzx"), 1,
51 "Unable to create msoab decompressor");
52 return FALSE;
53 }
54 ret = msoab->decompress_incremental (msoab, filename,
55 orig_filename, output_filename);
56 mspack_destroy_oab_decompressor (msoab);
57 if (ret != MSPACK_ERR_OK) {
58 g_set_error (error, g_quark_from_string ("lzx"), 1,
59 "Failed to apply LZX patch file: %d", ret);
60 return FALSE;
61 }
62
63 return TRUE;
64 }
65