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