1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright © 2008, 2009 Codethink Limited
4 * Copyright © 2009 Red Hat, Inc.
5 *
6 * SPDX-License-Identifier: LGPL-2.1-or-later
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * See the included COPYING file for more information.
14 *
15 * Authors: Ryan Lortie <desrt@desrt.ca>
16 * Alexander Larsson <alexl@redhat.com>
17 */
18
19#ifndef __G_IO_STREAM_H__
20#define __G_IO_STREAM_H__
21
22#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
23#error "Only <gio/gio.h> can be included directly."
24#endif
25
26#include <gio/ginputstream.h>
27#include <gio/goutputstream.h>
28#include <gio/gcancellable.h>
29#include <gio/gioerror.h>
30
31G_BEGIN_DECLS
32
33#define G_TYPE_IO_STREAM (g_io_stream_get_type ())
34#define G_IO_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_IO_STREAM, GIOStream))
35#define G_IO_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_IO_STREAM, GIOStreamClass))
36#define G_IS_IO_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_IO_STREAM))
37#define G_IS_IO_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_IO_STREAM))
38#define G_IO_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_IO_STREAM, GIOStreamClass))
39
40typedef struct _GIOStreamPrivate GIOStreamPrivate;
41typedef struct _GIOStreamClass GIOStreamClass;
42
43struct _GIOStream
44{
45 GObject parent_instance;
46
47 /*< private >*/
48 GIOStreamPrivate *priv;
49};
50
51struct _GIOStreamClass
52{
53 GObjectClass parent_class;
54
55 GInputStream * (*get_input_stream) (GIOStream *stream);
56 GOutputStream * (*get_output_stream) (GIOStream *stream);
57
58 gboolean (* close_fn) (GIOStream *stream,
59 GCancellable *cancellable,
60 GError **error);
61 void (* close_async) (GIOStream *stream,
62 int io_priority,
63 GCancellable *cancellable,
64 GAsyncReadyCallback callback,
65 gpointer user_data);
66 gboolean (* close_finish) (GIOStream *stream,
67 GAsyncResult *result,
68 GError **error);
69 /*< private >*/
70 /* Padding for future expansion */
71 void (*_g_reserved1) (void);
72 void (*_g_reserved2) (void);
73 void (*_g_reserved3) (void);
74 void (*_g_reserved4) (void);
75 void (*_g_reserved5) (void);
76 void (*_g_reserved6) (void);
77 void (*_g_reserved7) (void);
78 void (*_g_reserved8) (void);
79 void (*_g_reserved9) (void);
80 void (*_g_reserved10) (void);
81};
82
83GIO_AVAILABLE_IN_ALL
84GType g_io_stream_get_type (void) G_GNUC_CONST;
85
86GIO_AVAILABLE_IN_ALL
87GInputStream * g_io_stream_get_input_stream (GIOStream *stream);
88GIO_AVAILABLE_IN_ALL
89GOutputStream *g_io_stream_get_output_stream (GIOStream *stream);
90
91GIO_AVAILABLE_IN_ALL
92void g_io_stream_splice_async (GIOStream *stream1,
93 GIOStream *stream2,
94 GIOStreamSpliceFlags flags,
95 int io_priority,
96 GCancellable *cancellable,
97 GAsyncReadyCallback callback,
98 gpointer user_data);
99
100GIO_AVAILABLE_IN_ALL
101gboolean g_io_stream_splice_finish (GAsyncResult *result,
102 GError **error);
103
104GIO_AVAILABLE_IN_ALL
105gboolean g_io_stream_close (GIOStream *stream,
106 GCancellable *cancellable,
107 GError **error);
108
109GIO_AVAILABLE_IN_ALL
110void g_io_stream_close_async (GIOStream *stream,
111 int io_priority,
112 GCancellable *cancellable,
113 GAsyncReadyCallback callback,
114 gpointer user_data);
115GIO_AVAILABLE_IN_ALL
116gboolean g_io_stream_close_finish (GIOStream *stream,
117 GAsyncResult *result,
118 GError **error);
119
120GIO_AVAILABLE_IN_ALL
121gboolean g_io_stream_is_closed (GIOStream *stream);
122GIO_AVAILABLE_IN_ALL
123gboolean g_io_stream_has_pending (GIOStream *stream);
124GIO_AVAILABLE_IN_ALL
125gboolean g_io_stream_set_pending (GIOStream *stream,
126 GError **error);
127GIO_AVAILABLE_IN_ALL
128void g_io_stream_clear_pending (GIOStream *stream);
129
130G_END_DECLS
131
132#endif /* __G_IO_STREAM_H__ */
133