1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 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
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Alexander Larsson <alexl@redhat.com>
23 #ifndef __G_OUTPUT_STREAM_H__
24 #define __G_OUTPUT_STREAM_H__
26 #include <glib-object.h>
27 #include <gio/gioerror.h>
28 #include <gio/gasyncresult.h>
29 #include <gio/gcancellable.h>
30 #include <gio/ginputstream.h>
34 #define G_TYPE_OUTPUT_STREAM (g_output_stream_get_type ())
35 #define G_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_OUTPUT_STREAM, GOutputStream))
36 #define G_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
37 #define G_IS_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_OUTPUT_STREAM))
38 #define G_IS_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_OUTPUT_STREAM))
39 #define G_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
42 G_OUTPUT_STREAM_SPLICE_FLAGS_NONE = 0,
43 G_OUTPUT_STREAM_SPLICE_FLAGS_CLOSE_SOURCE = 1 << 0,
44 G_OUTPUT_STREAM_SPLICE_FLAGS_CLOSE_TARGET = 1 << 1
45 } GOutputStreamSpliceFlags;
47 typedef struct _GOutputStream GOutputStream;
48 typedef struct _GOutputStreamClass GOutputStreamClass;
49 typedef struct _GOutputStreamPrivate GOutputStreamPrivate;
56 GOutputStreamPrivate *priv;
60 struct _GOutputStreamClass
62 GObjectClass parent_class;
66 gssize (* write) (GOutputStream *stream,
69 GCancellable *cancellable,
71 gssize (* splice) (GOutputStream *stream,
73 GOutputStreamSpliceFlags flags,
74 GCancellable *cancellable,
76 gboolean (* flush) (GOutputStream *stream,
77 GCancellable *cancellable,
79 gboolean (* close) (GOutputStream *stream,
80 GCancellable *cancellable,
83 /* Async ops: (optional in derived classes) */
85 void (* write_async) (GOutputStream *stream,
89 GCancellable *cancellable,
90 GAsyncReadyCallback callback,
92 gssize (* write_finish) (GOutputStream *stream,
95 void (* splice_async) (GOutputStream *stream,
97 GOutputStreamSpliceFlags flags,
99 GCancellable *cancellable,
100 GAsyncReadyCallback callback,
102 gssize (* splice_finish)(GOutputStream *stream,
103 GAsyncResult *result,
105 void (* flush_async) (GOutputStream *stream,
107 GCancellable *cancellable,
108 GAsyncReadyCallback callback,
110 gboolean (* flush_finish) (GOutputStream *stream,
111 GAsyncResult *result,
113 void (* close_async) (GOutputStream *stream,
115 GCancellable *cancellable,
116 GAsyncReadyCallback callback,
118 gboolean (* close_finish) (GOutputStream *stream,
119 GAsyncResult *result,
122 /* Padding for future expansion */
123 void (*_g_reserved1) (void);
124 void (*_g_reserved2) (void);
125 void (*_g_reserved3) (void);
126 void (*_g_reserved4) (void);
127 void (*_g_reserved5) (void);
128 void (*_g_reserved6) (void);
129 void (*_g_reserved7) (void);
130 void (*_g_reserved8) (void);
133 GType g_output_stream_get_type (void) G_GNUC_CONST;
135 gssize g_output_stream_write (GOutputStream *stream,
138 GCancellable *cancellable,
140 gboolean g_output_stream_write_all (GOutputStream *stream,
143 gsize *bytes_written,
144 GCancellable *cancellable,
146 gssize g_output_stream_splice (GOutputStream *stream,
147 GInputStream *source,
148 GOutputStreamSpliceFlags flags,
149 GCancellable *cancellable,
151 gboolean g_output_stream_flush (GOutputStream *stream,
152 GCancellable *cancellable,
154 gboolean g_output_stream_close (GOutputStream *stream,
155 GCancellable *cancellable,
157 void g_output_stream_write_async (GOutputStream *stream,
161 GCancellable *cancellable,
162 GAsyncReadyCallback callback,
164 gssize g_output_stream_write_finish (GOutputStream *stream,
165 GAsyncResult *result,
167 void g_output_stream_splice_async (GOutputStream *stream,
168 GInputStream *source,
169 GOutputStreamSpliceFlags flags,
171 GCancellable *cancellable,
172 GAsyncReadyCallback callback,
174 gssize g_output_stream_splice_finish (GOutputStream *stream,
175 GAsyncResult *result,
177 void g_output_stream_flush_async (GOutputStream *stream,
179 GCancellable *cancellable,
180 GAsyncReadyCallback callback,
182 gboolean g_output_stream_flush_finish (GOutputStream *stream,
183 GAsyncResult *result,
185 void g_output_stream_close_async (GOutputStream *stream,
187 GCancellable *cancellable,
188 GAsyncReadyCallback callback,
190 gboolean g_output_stream_close_finish (GOutputStream *stream,
191 GAsyncResult *result,
194 gboolean g_output_stream_is_closed (GOutputStream *stream);
195 gboolean g_output_stream_has_pending (GOutputStream *stream);
196 void g_output_stream_set_pending (GOutputStream *stream,
202 #endif /* __G_OUTPUT_STREAM_H__ */