"Initial commit to Gerrit"
[profile/ivi/libgsf.git] / gsf / gsf-output.h
1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * gsf-output.h: interface for storing data
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 #ifndef GSF_OUTPUT_H
23 #define GSF_OUTPUT_H
24
25 #include <gsf/gsf.h>
26 #include <sys/types.h>
27 #include <glib-object.h>
28
29 G_BEGIN_DECLS
30
31 typedef struct {
32         GObjectClass g_object_class;
33
34         gboolean (*Close)   (GsfOutput *output);
35         gboolean (*Seek)    (GsfOutput *output,
36                              gsf_off_t offset, GSeekType whence);
37         gboolean (*Write)   (GsfOutput *output,
38                              size_t num_bytes, guint8 const *data);
39         gsf_off_t (*Vprintf) (GsfOutput *output,
40                              char const *format, va_list args)
41                              G_GNUC_PRINTF (2, 0);
42 } GsfOutputClass;
43 #define GSF_OUTPUT_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST ((k), GSF_OUTPUT_TYPE, GsfOutputClass))
44 #define GSF_IS_OUTPUT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSF_OUTPUT_TYPE))
45
46 struct _GsfOutput {
47         GObject g_object;
48
49         /*< protected >*/
50         gsf_off_t   cur_size, cur_offset;
51         char       *name;
52         GObject    *wrapped_by;
53         GsfOutfile *container;
54         GError     *err;
55         gboolean    is_closed;
56
57         char       *printf_buf;
58         int         printf_buf_size;
59 };
60 #define GSF_OUTPUT_TYPE        (gsf_output_get_type ())
61 #define GSF_OUTPUT(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), GSF_OUTPUT_TYPE, GsfOutput))
62 #define GSF_IS_OUTPUT(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSF_OUTPUT_TYPE))
63
64 GType gsf_output_get_type      (void) G_GNUC_CONST;
65 /* void  gsf_output_register_type (GTypeModule *module); glib dynamic types are not thread safe */
66
67 char const   *gsf_output_name      (GsfOutput const *output);
68 GsfOutfile   *gsf_output_container (GsfOutput const *output);
69
70 GError const *gsf_output_error     (GsfOutput const *output);
71 gboolean gsf_output_set_error      (GsfOutput *output,
72                                     gint        code,
73                                     char const *format,
74                                     ...) G_GNUC_PRINTF (3, 4);
75
76 gsf_off_t     gsf_output_size      (GsfOutput *output);
77 gboolean      gsf_output_close     (GsfOutput *output);
78 gboolean      gsf_output_is_closed (GsfOutput const *output);
79 gsf_off_t     gsf_output_tell      (GsfOutput *output);
80 gboolean      gsf_output_seek      (GsfOutput *output,
81                                     gsf_off_t offset, GSeekType whence);
82 gboolean      gsf_output_write     (GsfOutput *output,
83                                     size_t num_bytes, guint8 const *data);
84
85 gboolean gsf_output_wrap   (GObject *wrapper, GsfOutput *wrapee);
86 gboolean gsf_output_unwrap (GObject *wrapper, GsfOutput *wrapee);
87
88 GQuark gsf_output_error_id (void);
89
90 gboolean gsf_output_printf (GsfOutput *output, char const *format,
91                             ...) G_GNUC_PRINTF (2, 3);
92 gsf_off_t gsf_output_vprintf (GsfOutput *output, char const *format,
93                               va_list args) G_GNUC_PRINTF (2, 0);
94 gboolean gsf_output_puts (GsfOutput *output, char const *line);
95
96 G_END_DECLS
97
98 #endif /* GSF_OUTPUT_H */