1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000-2012 Jeffrey Stedfast
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1
8 * of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
22 #ifndef __GMIME_STREAM_H__
23 #define __GMIME_STREAM_H__
26 #include <glib-object.h>
29 #include <sys/types.h>
34 #define GMIME_TYPE_STREAM (g_mime_stream_get_type ())
35 #define GMIME_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_STREAM, GMimeStream))
36 #define GMIME_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_STREAM, GMimeStreamClass))
37 #define GMIME_IS_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_STREAM))
38 #define GMIME_IS_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_STREAM))
39 #define GMIME_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_STREAM, GMimeStreamClass))
41 typedef struct _GMimeStream GMimeStream;
42 typedef struct _GMimeStreamClass GMimeStreamClass;
47 * @GMIME_STREAM_SEEK_SET: Seek relative to the beginning of the stream.
48 * @GMIME_STREAM_SEEK_CUR: Seek relative to the current position in the stream.
49 * @GMIME_STREAM_SEEK_END: Seek relative to the end of the stream.
51 * Relative seek position.
54 GMIME_STREAM_SEEK_SET = SEEK_SET,
55 GMIME_STREAM_SEEK_CUR = SEEK_CUR,
56 GMIME_STREAM_SEEK_END = SEEK_END
61 * GMimeStreamIOVector:
62 * @data: data to pass to the I/O function.
63 * @len: length of the data, in bytes.
65 * An I/O vector for use with g_mime_stream_writev().
70 } GMimeStreamIOVector;
75 * @parent_object: parent #GObject
76 * @super_stream: parent stream if this is a substream
77 * @position: the current stream position
78 * @bound_start: start boundary of the stream
79 * @bound_end: end boundary of the stream
81 * Abstract I/O stream class.
84 GObject parent_object;
87 GMimeStream *super_stream;
94 struct _GMimeStreamClass {
95 GObjectClass parent_class;
97 ssize_t (* read) (GMimeStream *stream, char *buf, size_t len);
98 ssize_t (* write) (GMimeStream *stream, const char *buf, size_t len);
99 int (* flush) (GMimeStream *stream);
100 int (* close) (GMimeStream *stream);
101 gboolean (* eos) (GMimeStream *stream);
102 int (* reset) (GMimeStream *stream);
103 gint64 (* seek) (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
104 gint64 (* tell) (GMimeStream *stream);
105 gint64 (* length) (GMimeStream *stream);
106 GMimeStream * (* substream) (GMimeStream *stream, gint64 start, gint64 end);
110 GType g_mime_stream_get_type (void);
112 void g_mime_stream_construct (GMimeStream *stream, gint64 start, gint64 end);
116 ssize_t g_mime_stream_read (GMimeStream *stream, char *buf, size_t len);
117 ssize_t g_mime_stream_write (GMimeStream *stream, const char *buf, size_t len);
118 int g_mime_stream_flush (GMimeStream *stream);
119 int g_mime_stream_close (GMimeStream *stream);
120 gboolean g_mime_stream_eos (GMimeStream *stream);
121 int g_mime_stream_reset (GMimeStream *stream);
122 gint64 g_mime_stream_seek (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence);
123 gint64 g_mime_stream_tell (GMimeStream *stream);
124 gint64 g_mime_stream_length (GMimeStream *stream);
126 GMimeStream *g_mime_stream_substream (GMimeStream *stream, gint64 start, gint64 end);
128 void g_mime_stream_set_bounds (GMimeStream *stream, gint64 start, gint64 end);
130 ssize_t g_mime_stream_write_string (GMimeStream *stream, const char *str);
131 ssize_t g_mime_stream_printf (GMimeStream *stream, const char *fmt, ...) G_GNUC_PRINTF (2, 3);
133 ssize_t g_mime_stream_write_to_stream (GMimeStream *src, GMimeStream *dest);
135 ssize_t g_mime_stream_writev (GMimeStream *stream, GMimeStreamIOVector *vector, size_t count);
139 #endif /* __GMIME_STREAM_H__ */