1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
5 * Copyright (C) 2002-2006 Jon K Hellan (hellan@acm.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-utils.h>
23 #include <gsf/gsf-output-stdio.h>
24 #include <gsf/gsf-outfile.h>
25 #include <gsf/gsf-outfile-zip.h>
31 test_write_once (GsfOutput *output)
33 char const *str = "The cat sat on the mat. 2 cats sat on the mat. The quick brown fox is afraid of the cats.\n";
35 return gsf_output_write (output, strlen (str), str);
39 test (int argc, char *argv[])
47 fprintf (stderr, "Usage : %s outfile\n", argv[0]);
51 output = gsf_output_stdio_new (argv[1], &err);
53 g_return_val_if_fail (err != NULL, 1);
55 g_warning ("'%s' error: %s", argv[1], err->message);
59 outfile = gsf_outfile_zip_new (output, &err);
61 g_return_val_if_fail (err != NULL, 1);
63 g_warning ("'%s' error: %s",
64 "gsf_outfile_zip_new", err->message);
68 g_object_unref (G_OBJECT (output));
69 child = gsf_outfile_new_child (outfile, "child", FALSE);
71 if (!test_write_once (child))
73 if (!gsf_output_close ((GsfOutput *) child))
75 if (!gsf_output_close ((GsfOutput *) outfile))
77 g_object_unref (G_OBJECT (outfile));
78 g_object_unref (child);
84 main (int argc, char *argv[])
89 res = test (argc, argv);