1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * test-textline.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-textline.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 GsfInputTextline *textline;
33 GError *err = NULL;
34 unsigned char *line;
35
36 if (argc < 2) {
37 fprintf (stderr, "Usage : %s <text_filename>\n", argv[0]);
38 return 1;
39 }
40
41 fprintf (stderr, "%s\n", argv[1]);
42 input = gsf_input_stdio_new (argv[1], &err);
43 if (input == NULL) {
44
45 g_return_val_if_fail (err != NULL, 1);
46
47 g_warning ("'%s' error: %s", argv[1], err->message);
48 g_error_free (err);
49 return 1;
50 }
51 textline = (GsfInputTextline *)gsf_input_textline_new (input);
52 if (textline == NULL) {
53 g_warning ("unable to create a textline");
54 return 2;
55 }
56
57 while (NULL != (line = gsf_input_textline_ascii_gets (textline)))
58 puts (line);
59
60 g_object_unref (G_OBJECT (input));
61
62 return 0;
63 }
64
65 int
main(int argc,char * argv[])66 main (int argc, char *argv[])
67 {
68 int res;
69
70 gsf_init ();
71 res = test (argc, argv);
72 gsf_shutdown ();
73
74 return res;
75 }
76