1
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3
* test-msole1.c: test program to list content and dump raw stream data
5
* Copyright (C) 2002-2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22
#include <gsf/gsf-input-stdio.h>
23
#include <gsf/gsf-utils.h>
24
#include <gsf/gsf-infile.h>
25
#include <gsf/gsf-infile-msole.h>
32
static gboolean dump_as_hex = FALSE;
35
ls_R (GsfInput *input)
38
char const *name = gsf_input_name (GSF_INPUT (input));
39
gboolean is_dir = GSF_IS_INFILE (input) &&
40
(gsf_infile_num_children (GSF_INFILE (input)) >= 0);
42
printf ("%c '%s'\t\t%" GSF_OFF_T_FORMAT "\n",
44
(name != NULL) ? name : "",
45
gsf_input_size (GSF_INPUT (input)));
49
for (i = 0 ; i < gsf_infile_num_children (GSF_INFILE (input)) ; i++)
50
ls_R (gsf_infile_child_by_index (GSF_INFILE (input), i));
54
g_object_unref (G_OBJECT (input));
58
test (int argc, char *argv[])
64
fprintf (stderr, "%s\n", argv [1]);
65
input = GSF_INPUT (gsf_input_stdio_new (argv[1], &err));
68
g_return_val_if_fail (err != NULL, 1);
70
g_warning ("'%s' error: %s", argv[1], err->message);
75
input = gsf_input_uncompress (input);
76
infile = GSF_INFILE (gsf_infile_msole_new (input, &err));
77
g_object_unref (G_OBJECT (input));
80
g_return_val_if_fail (err != NULL, 1);
82
g_warning ("'%s' Not an OLE file: %s", argv[1], err->message);
89
GsfInput *child, *ptr = GSF_INPUT (infile);
90
for (i = 2 ; i < argc && ptr != NULL; i++, ptr = child) {
91
fprintf (stderr, "--> '%s'\n", argv [i]);
92
if (GSF_IS_INFILE (ptr) &&
93
gsf_infile_num_children (GSF_INFILE (ptr)) >= 0) {
94
child = gsf_infile_child_by_name (GSF_INFILE (ptr), argv [i]);
97
g_warning ("No child named '%s'", argv [i]);
102
g_warning ("stream is not a directory '%s'", argv [i]);
106
g_object_unref (G_OBJECT (ptr));
109
if (GSF_IS_INFILE (ptr) &&
110
gsf_infile_num_children (GSF_INFILE (ptr)) >= 0)
111
ls_R (ptr); /* unrefs infile */
113
gsf_input_dump (GSF_INPUT (ptr), dump_as_hex);
114
g_object_unref (G_OBJECT (ptr));
118
ls_R (GSF_INPUT (infile)); /* unrefs infile */
124
main (int argc, char *argv[])
129
fprintf (stderr, "%s : file [--hex] stream stream ...\n", argv [0]);
133
if (argv[1] != NULL && 0 == strcmp (argv[1], "--hex")) {
140
res = test (argc, argv);