1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
5 * Copyright (C) 2002-2006 Jody Goldberg (jody@gnome.org)
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.
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.
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
22 #include <gsf/gsf-input-stdio.h>
23 #include <gsf/gsf-utils.h>
24 #include <gsf/gsf-infile.h>
25 #include <gsf/gsf-infile-zip.h>
26 #include <gsf/gsf-input-textline.h>
32 dump_child (GsfInfile *infile, char const *childname)
34 GsfInput *child = gsf_infile_child_by_name (infile, childname);
35 GsfInputTextline *textinput;
40 printf ("not an OpenOffice document\n");
44 textinput = (GsfInputTextline *)gsf_input_textline_new (child);
45 if (textinput == NULL) {
46 printf ("Could not read lines from %s",
47 gsf_input_name (child));
52 res = gsf_input_textline_ascii_gets (textinput);
54 printf ("'%s'\n", res);
55 len += strlen (res) + 1;
59 printf ("Finished reading - %d bytes\n", len);
60 g_object_unref (G_OBJECT (textinput));
61 g_object_unref (G_OBJECT (child));
65 test (int argc, char *argv[])
73 input = gsf_input_stdio_new (argv[1], &err);
76 g_return_val_if_fail (err != NULL, 1);
78 g_warning ("'%s' error: %s", argv[1], err->message);
83 infile = gsf_infile_zip_new (input, &err);
86 g_return_val_if_fail (err != NULL, 1);
88 g_warning ("'%s' Not a Zip file: %s", argv[1], err->message);
90 g_object_unref (G_OBJECT (input));
94 for (i = 2 ; i < argc ; i++) {
95 dump_child (infile, argv[i]);
97 g_object_unref (G_OBJECT (infile));
98 g_object_unref (G_OBJECT (input));
104 main (int argc, char *argv[])
109 res = test (argc, argv);