1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * test-input1.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-utils.h>
23 #include <gsf/gsf-output-stdio.h>
24
25 #include <stdio.h>
26
27 static int
test(int argc,char * argv[])28 test (int argc, char *argv[])
29 {
30 GsfOutput *output;
31 GError *err = NULL;
32
33 if (argc != 2) {
34 fprintf (stderr, "Usage : %s outfile\n", argv[0]);
35 return 1;
36 }
37
38 output = gsf_output_stdio_new (argv[1], &err);
39 if (output == NULL) {
40 g_return_val_if_fail (err != NULL, 1);
41
42 g_warning ("'%s' error: %s", argv[1], err->message);
43 g_error_free (err);
44 return 1;
45 }
46
47 if (!gsf_output_printf (output,
48 "The %s sat on the %s.\n", "cat", "mat"))
49 return 1;
50 if (!gsf_output_printf (output, "%d %ss sat on the %s.\n",
51 2, "cat", "mat"))
52 return 1;
53 if (!gsf_output_puts (output,
54 "The quick brown fox is afraid of the cats.\n"))
55 return 1;
56 if (!gsf_output_close (output))
57 return 1;
58 g_object_unref (G_OBJECT (output));
59
60 return 0;
61 }
62
63 int
main(int argc,char * argv[])64 main (int argc, char *argv[])
65 {
66 int res;
67
68 gsf_init ();
69 res = test (argc, argv);
70 gsf_shutdown ();
71
72 return res;
73 }
74