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