1 | /* GIO - GLib Input, Output and Streaming Library |
2 | * |
3 | * Copyright (C) 2006-2007 Red Hat, Inc. |
4 | * |
5 | * SPDX-License-Identifier: LGPL-2.1-or-later |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Lesser General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2.1 of the License, or (at your option) any later version. |
11 | * |
12 | * This library is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Lesser General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Lesser General |
18 | * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. |
19 | * |
20 | * Author: Alexander Larsson <alexl@redhat.com> |
21 | */ |
22 | |
23 | #ifndef __G_OUTPUT_STREAM_H__ |
24 | #define __G_OUTPUT_STREAM_H__ |
25 | |
26 | #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) |
27 | #error "Only <gio/gio.h> can be included directly." |
28 | #endif |
29 | |
30 | #include <gio/giotypes.h> |
31 | |
32 | G_BEGIN_DECLS |
33 | |
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)) |
40 | |
41 | typedef struct _GOutputStreamClass GOutputStreamClass; |
42 | typedef struct _GOutputStreamPrivate GOutputStreamPrivate; |
43 | |
44 | struct _GOutputStream |
45 | { |
46 | GObject parent_instance; |
47 | |
48 | /*< private >*/ |
49 | GOutputStreamPrivate *priv; |
50 | }; |
51 | |
52 | |
53 | struct _GOutputStreamClass |
54 | { |
55 | GObjectClass parent_class; |
56 | |
57 | /* Sync ops: */ |
58 | |
59 | gssize (* write_fn) (GOutputStream *stream, |
60 | const void *buffer, |
61 | gsize count, |
62 | GCancellable *cancellable, |
63 | GError **error); |
64 | gssize (* splice) (GOutputStream *stream, |
65 | GInputStream *source, |
66 | GOutputStreamSpliceFlags flags, |
67 | GCancellable *cancellable, |
68 | GError **error); |
69 | gboolean (* flush) (GOutputStream *stream, |
70 | GCancellable *cancellable, |
71 | GError **error); |
72 | gboolean (* close_fn) (GOutputStream *stream, |
73 | GCancellable *cancellable, |
74 | GError **error); |
75 | |
76 | /* Async ops: (optional in derived classes) */ |
77 | |
78 | void (* write_async) (GOutputStream *stream, |
79 | const void *buffer, |
80 | gsize count, |
81 | int io_priority, |
82 | GCancellable *cancellable, |
83 | GAsyncReadyCallback callback, |
84 | gpointer user_data); |
85 | gssize (* write_finish) (GOutputStream *stream, |
86 | GAsyncResult *result, |
87 | GError **error); |
88 | void (* splice_async) (GOutputStream *stream, |
89 | GInputStream *source, |
90 | GOutputStreamSpliceFlags flags, |
91 | int io_priority, |
92 | GCancellable *cancellable, |
93 | GAsyncReadyCallback callback, |
94 | gpointer user_data); |
95 | gssize (* splice_finish) (GOutputStream *stream, |
96 | GAsyncResult *result, |
97 | GError **error); |
98 | void (* flush_async) (GOutputStream *stream, |
99 | int io_priority, |
100 | GCancellable *cancellable, |
101 | GAsyncReadyCallback callback, |
102 | gpointer user_data); |
103 | gboolean (* flush_finish) (GOutputStream *stream, |
104 | GAsyncResult *result, |
105 | GError **error); |
106 | void (* close_async) (GOutputStream *stream, |
107 | int io_priority, |
108 | GCancellable *cancellable, |
109 | GAsyncReadyCallback callback, |
110 | gpointer user_data); |
111 | gboolean (* close_finish) (GOutputStream *stream, |
112 | GAsyncResult *result, |
113 | GError **error); |
114 | |
115 | gboolean (* writev_fn) (GOutputStream *stream, |
116 | const GOutputVector *vectors, |
117 | gsize n_vectors, |
118 | gsize *bytes_written, |
119 | GCancellable *cancellable, |
120 | GError **error); |
121 | |
122 | void (* writev_async) (GOutputStream *stream, |
123 | const GOutputVector *vectors, |
124 | gsize n_vectors, |
125 | int io_priority, |
126 | GCancellable *cancellable, |
127 | GAsyncReadyCallback callback, |
128 | gpointer user_data); |
129 | |
130 | gboolean (* writev_finish) (GOutputStream *stream, |
131 | GAsyncResult *result, |
132 | gsize *bytes_written, |
133 | GError **error); |
134 | |
135 | /*< private >*/ |
136 | /* Padding for future expansion */ |
137 | void (*_g_reserved4) (void); |
138 | void (*_g_reserved5) (void); |
139 | void (*_g_reserved6) (void); |
140 | void (*_g_reserved7) (void); |
141 | void (*_g_reserved8) (void); |
142 | }; |
143 | |
144 | GIO_AVAILABLE_IN_ALL |
145 | GType g_output_stream_get_type (void) G_GNUC_CONST; |
146 | |
147 | GIO_AVAILABLE_IN_ALL |
148 | gssize g_output_stream_write (GOutputStream *stream, |
149 | const void *buffer, |
150 | gsize count, |
151 | GCancellable *cancellable, |
152 | GError **error); |
153 | GIO_AVAILABLE_IN_ALL |
154 | gboolean g_output_stream_write_all (GOutputStream *stream, |
155 | const void *buffer, |
156 | gsize count, |
157 | gsize *bytes_written, |
158 | GCancellable *cancellable, |
159 | GError **error); |
160 | |
161 | GIO_AVAILABLE_IN_2_60 |
162 | gboolean g_output_stream_writev (GOutputStream *stream, |
163 | const GOutputVector *vectors, |
164 | gsize n_vectors, |
165 | gsize *bytes_written, |
166 | GCancellable *cancellable, |
167 | GError **error); |
168 | GIO_AVAILABLE_IN_2_60 |
169 | gboolean g_output_stream_writev_all (GOutputStream *stream, |
170 | GOutputVector *vectors, |
171 | gsize n_vectors, |
172 | gsize *bytes_written, |
173 | GCancellable *cancellable, |
174 | GError **error); |
175 | |
176 | GIO_AVAILABLE_IN_2_40 |
177 | gboolean g_output_stream_printf (GOutputStream *stream, |
178 | gsize *bytes_written, |
179 | GCancellable *cancellable, |
180 | GError **error, |
181 | const gchar *format, |
182 | ...) G_GNUC_PRINTF (5, 6); |
183 | GIO_AVAILABLE_IN_2_40 |
184 | gboolean g_output_stream_vprintf (GOutputStream *stream, |
185 | gsize *bytes_written, |
186 | GCancellable *cancellable, |
187 | GError **error, |
188 | const gchar *format, |
189 | va_list args) G_GNUC_PRINTF (5, 0); |
190 | GIO_AVAILABLE_IN_2_34 |
191 | gssize g_output_stream_write_bytes (GOutputStream *stream, |
192 | GBytes *bytes, |
193 | GCancellable *cancellable, |
194 | GError **error); |
195 | GIO_AVAILABLE_IN_ALL |
196 | gssize g_output_stream_splice (GOutputStream *stream, |
197 | GInputStream *source, |
198 | GOutputStreamSpliceFlags flags, |
199 | GCancellable *cancellable, |
200 | GError **error); |
201 | GIO_AVAILABLE_IN_ALL |
202 | gboolean g_output_stream_flush (GOutputStream *stream, |
203 | GCancellable *cancellable, |
204 | GError **error); |
205 | GIO_AVAILABLE_IN_ALL |
206 | gboolean g_output_stream_close (GOutputStream *stream, |
207 | GCancellable *cancellable, |
208 | GError **error); |
209 | GIO_AVAILABLE_IN_ALL |
210 | void g_output_stream_write_async (GOutputStream *stream, |
211 | const void *buffer, |
212 | gsize count, |
213 | int io_priority, |
214 | GCancellable *cancellable, |
215 | GAsyncReadyCallback callback, |
216 | gpointer user_data); |
217 | GIO_AVAILABLE_IN_ALL |
218 | gssize g_output_stream_write_finish (GOutputStream *stream, |
219 | GAsyncResult *result, |
220 | GError **error); |
221 | |
222 | GIO_AVAILABLE_IN_2_44 |
223 | void g_output_stream_write_all_async (GOutputStream *stream, |
224 | const void *buffer, |
225 | gsize count, |
226 | int io_priority, |
227 | GCancellable *cancellable, |
228 | GAsyncReadyCallback callback, |
229 | gpointer user_data); |
230 | |
231 | GIO_AVAILABLE_IN_2_44 |
232 | gboolean g_output_stream_write_all_finish (GOutputStream *stream, |
233 | GAsyncResult *result, |
234 | gsize *bytes_written, |
235 | GError **error); |
236 | |
237 | GIO_AVAILABLE_IN_2_60 |
238 | void g_output_stream_writev_async (GOutputStream *stream, |
239 | const GOutputVector *vectors, |
240 | gsize n_vectors, |
241 | int io_priority, |
242 | GCancellable *cancellable, |
243 | GAsyncReadyCallback callback, |
244 | gpointer user_data); |
245 | GIO_AVAILABLE_IN_2_60 |
246 | gboolean g_output_stream_writev_finish (GOutputStream *stream, |
247 | GAsyncResult *result, |
248 | gsize *bytes_written, |
249 | GError **error); |
250 | |
251 | GIO_AVAILABLE_IN_2_60 |
252 | void g_output_stream_writev_all_async (GOutputStream *stream, |
253 | GOutputVector *vectors, |
254 | gsize n_vectors, |
255 | int io_priority, |
256 | GCancellable *cancellable, |
257 | GAsyncReadyCallback callback, |
258 | gpointer user_data); |
259 | |
260 | GIO_AVAILABLE_IN_2_60 |
261 | gboolean g_output_stream_writev_all_finish (GOutputStream *stream, |
262 | GAsyncResult *result, |
263 | gsize *bytes_written, |
264 | GError **error); |
265 | |
266 | GIO_AVAILABLE_IN_2_34 |
267 | void g_output_stream_write_bytes_async (GOutputStream *stream, |
268 | GBytes *bytes, |
269 | int io_priority, |
270 | GCancellable *cancellable, |
271 | GAsyncReadyCallback callback, |
272 | gpointer user_data); |
273 | GIO_AVAILABLE_IN_2_34 |
274 | gssize g_output_stream_write_bytes_finish (GOutputStream *stream, |
275 | GAsyncResult *result, |
276 | GError **error); |
277 | GIO_AVAILABLE_IN_ALL |
278 | void g_output_stream_splice_async (GOutputStream *stream, |
279 | GInputStream *source, |
280 | GOutputStreamSpliceFlags flags, |
281 | int io_priority, |
282 | GCancellable *cancellable, |
283 | GAsyncReadyCallback callback, |
284 | gpointer user_data); |
285 | GIO_AVAILABLE_IN_ALL |
286 | gssize g_output_stream_splice_finish (GOutputStream *stream, |
287 | GAsyncResult *result, |
288 | GError **error); |
289 | GIO_AVAILABLE_IN_ALL |
290 | void g_output_stream_flush_async (GOutputStream *stream, |
291 | int io_priority, |
292 | GCancellable *cancellable, |
293 | GAsyncReadyCallback callback, |
294 | gpointer user_data); |
295 | GIO_AVAILABLE_IN_ALL |
296 | gboolean g_output_stream_flush_finish (GOutputStream *stream, |
297 | GAsyncResult *result, |
298 | GError **error); |
299 | GIO_AVAILABLE_IN_ALL |
300 | void g_output_stream_close_async (GOutputStream *stream, |
301 | int io_priority, |
302 | GCancellable *cancellable, |
303 | GAsyncReadyCallback callback, |
304 | gpointer user_data); |
305 | GIO_AVAILABLE_IN_ALL |
306 | gboolean g_output_stream_close_finish (GOutputStream *stream, |
307 | GAsyncResult *result, |
308 | GError **error); |
309 | |
310 | GIO_AVAILABLE_IN_ALL |
311 | gboolean g_output_stream_is_closed (GOutputStream *stream); |
312 | GIO_AVAILABLE_IN_ALL |
313 | gboolean g_output_stream_is_closing (GOutputStream *stream); |
314 | GIO_AVAILABLE_IN_ALL |
315 | gboolean g_output_stream_has_pending (GOutputStream *stream); |
316 | GIO_AVAILABLE_IN_ALL |
317 | gboolean g_output_stream_set_pending (GOutputStream *stream, |
318 | GError **error); |
319 | GIO_AVAILABLE_IN_ALL |
320 | void g_output_stream_clear_pending (GOutputStream *stream); |
321 | |
322 | |
323 | G_END_DECLS |
324 | |
325 | #endif /* __G_OUTPUT_STREAM_H__ */ |
326 | |