1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * test-gzip2.c:
4 *
5 * Copyright (C) 2002-2003 Jody Goldberg (jody@gnome.org)
6 * Copyright (C) 2005-2006 Morten Welinder (terra@gnome.org)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of version 2.1 of the GNU Lesser General Public
10 * License as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20 * USA
21 */
22
23 #include <gsf/gsf-input-stdio.h>
24 #include <gsf/gsf-utils.h>
25 #include <gsf/gsf-input-gzip.h>
26
27 #include <stdio.h>
28
29 static int
test(int argc,char * argv[])30 test (int argc, char *argv[])
31 {
32 GsfInput *input;
33 GsfInput *gzip;
34 GError *err = NULL;
35 int i;
36
37 for (i = 1 ; i < argc ; i++) {
38 puts (argv[i]);
39 input = gsf_input_stdio_new (argv[i], &err);
40 if (input == NULL) {
41
42 g_return_val_if_fail (err != NULL, 1);
43
44 g_warning ("'%s' error: %s", argv[i], err->message);
45 g_error_free (err);
46 err = NULL;
47 continue;
48 }
49
50 /*
51 * We must know the length of the uncompressed file in advance.
52 * test-out-gzip2's output uncompresses to 90 bytes.
53 */
54 gzip = g_object_new (GSF_INPUT_GZIP_TYPE,
55 "source", input,
56 "raw", TRUE,
57 "uncompressed_size", (gsf_off_t)90,
58 NULL);
59 if (gzip == NULL) {
60 g_warning ("'%s' Not a GZip file: %s", argv[i], "???" /* err->message */);
61 g_error_free (err);
62 err = NULL;
63 g_object_unref (G_OBJECT (input));
64 continue;
65 }
66 gsf_input_dump (gzip, FALSE);
67
68 g_object_unref (G_OBJECT (gzip));
69 g_object_unref (G_OBJECT (input));
70 }
71
72 return 0;
73 }
74
75 int
main(int argc,char * argv[])76 main (int argc, char *argv[])
77 {
78 int res;
79
80 gsf_init ();
81 res = test (argc, argv);
82 gsf_shutdown ();
83
84 return res;
85 }
86