| 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_INPUT_STREAM_H__ |
| 24 | #define __G_INPUT_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_INPUT_STREAM (g_input_stream_get_type ()) |
| 35 | #define G_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INPUT_STREAM, GInputStream)) |
| 36 | #define G_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INPUT_STREAM, GInputStreamClass)) |
| 37 | #define G_IS_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INPUT_STREAM)) |
| 38 | #define G_IS_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INPUT_STREAM)) |
| 39 | #define G_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INPUT_STREAM, GInputStreamClass)) |
| 40 | |
| 41 | typedef struct _GInputStreamClass GInputStreamClass; |
| 42 | typedef struct _GInputStreamPrivate GInputStreamPrivate; |
| 43 | |
| 44 | struct _GInputStream |
| 45 | { |
| 46 | GObject parent_instance; |
| 47 | |
| 48 | /*< private >*/ |
| 49 | GInputStreamPrivate *priv; |
| 50 | }; |
| 51 | |
| 52 | struct _GInputStreamClass |
| 53 | { |
| 54 | GObjectClass parent_class; |
| 55 | |
| 56 | /* Sync ops: */ |
| 57 | |
| 58 | gssize (* read_fn) (GInputStream *stream, |
| 59 | void *buffer, |
| 60 | gsize count, |
| 61 | GCancellable *cancellable, |
| 62 | GError **error); |
| 63 | gssize (* skip) (GInputStream *stream, |
| 64 | gsize count, |
| 65 | GCancellable *cancellable, |
| 66 | GError **error); |
| 67 | gboolean (* close_fn) (GInputStream *stream, |
| 68 | GCancellable *cancellable, |
| 69 | GError **error); |
| 70 | |
| 71 | /* Async ops: (optional in derived classes) */ |
| 72 | void (* read_async) (GInputStream *stream, |
| 73 | void *buffer, |
| 74 | gsize count, |
| 75 | int io_priority, |
| 76 | GCancellable *cancellable, |
| 77 | GAsyncReadyCallback callback, |
| 78 | gpointer user_data); |
| 79 | gssize (* read_finish) (GInputStream *stream, |
| 80 | GAsyncResult *result, |
| 81 | GError **error); |
| 82 | void (* skip_async) (GInputStream *stream, |
| 83 | gsize count, |
| 84 | int io_priority, |
| 85 | GCancellable *cancellable, |
| 86 | GAsyncReadyCallback callback, |
| 87 | gpointer user_data); |
| 88 | gssize (* skip_finish) (GInputStream *stream, |
| 89 | GAsyncResult *result, |
| 90 | GError **error); |
| 91 | void (* close_async) (GInputStream *stream, |
| 92 | int io_priority, |
| 93 | GCancellable *cancellable, |
| 94 | GAsyncReadyCallback callback, |
| 95 | gpointer user_data); |
| 96 | gboolean (* close_finish) (GInputStream *stream, |
| 97 | GAsyncResult *result, |
| 98 | GError **error); |
| 99 | |
| 100 | /*< private >*/ |
| 101 | /* Padding for future expansion */ |
| 102 | void (*_g_reserved1) (void); |
| 103 | void (*_g_reserved2) (void); |
| 104 | void (*_g_reserved3) (void); |
| 105 | void (*_g_reserved4) (void); |
| 106 | void (*_g_reserved5) (void); |
| 107 | }; |
| 108 | |
| 109 | GIO_AVAILABLE_IN_ALL |
| 110 | GType g_input_stream_get_type (void) G_GNUC_CONST; |
| 111 | |
| 112 | GIO_AVAILABLE_IN_ALL |
| 113 | gssize g_input_stream_read (GInputStream *stream, |
| 114 | void *buffer, |
| 115 | gsize count, |
| 116 | GCancellable *cancellable, |
| 117 | GError **error); |
| 118 | GIO_AVAILABLE_IN_ALL |
| 119 | gboolean g_input_stream_read_all (GInputStream *stream, |
| 120 | void *buffer, |
| 121 | gsize count, |
| 122 | gsize *bytes_read, |
| 123 | GCancellable *cancellable, |
| 124 | GError **error); |
| 125 | GIO_AVAILABLE_IN_2_34 |
| 126 | GBytes *g_input_stream_read_bytes (GInputStream *stream, |
| 127 | gsize count, |
| 128 | GCancellable *cancellable, |
| 129 | GError **error); |
| 130 | GIO_AVAILABLE_IN_ALL |
| 131 | gssize g_input_stream_skip (GInputStream *stream, |
| 132 | gsize count, |
| 133 | GCancellable *cancellable, |
| 134 | GError **error); |
| 135 | GIO_AVAILABLE_IN_ALL |
| 136 | gboolean g_input_stream_close (GInputStream *stream, |
| 137 | GCancellable *cancellable, |
| 138 | GError **error); |
| 139 | GIO_AVAILABLE_IN_ALL |
| 140 | void g_input_stream_read_async (GInputStream *stream, |
| 141 | void *buffer, |
| 142 | gsize count, |
| 143 | int io_priority, |
| 144 | GCancellable *cancellable, |
| 145 | GAsyncReadyCallback callback, |
| 146 | gpointer user_data); |
| 147 | GIO_AVAILABLE_IN_ALL |
| 148 | gssize g_input_stream_read_finish (GInputStream *stream, |
| 149 | GAsyncResult *result, |
| 150 | GError **error); |
| 151 | |
| 152 | GIO_AVAILABLE_IN_2_44 |
| 153 | void g_input_stream_read_all_async (GInputStream *stream, |
| 154 | void *buffer, |
| 155 | gsize count, |
| 156 | int io_priority, |
| 157 | GCancellable *cancellable, |
| 158 | GAsyncReadyCallback callback, |
| 159 | gpointer user_data); |
| 160 | GIO_AVAILABLE_IN_2_44 |
| 161 | gboolean g_input_stream_read_all_finish (GInputStream *stream, |
| 162 | GAsyncResult *result, |
| 163 | gsize *bytes_read, |
| 164 | GError **error); |
| 165 | |
| 166 | GIO_AVAILABLE_IN_2_34 |
| 167 | void g_input_stream_read_bytes_async (GInputStream *stream, |
| 168 | gsize count, |
| 169 | int io_priority, |
| 170 | GCancellable *cancellable, |
| 171 | GAsyncReadyCallback callback, |
| 172 | gpointer user_data); |
| 173 | GIO_AVAILABLE_IN_2_34 |
| 174 | GBytes *g_input_stream_read_bytes_finish (GInputStream *stream, |
| 175 | GAsyncResult *result, |
| 176 | GError **error); |
| 177 | GIO_AVAILABLE_IN_ALL |
| 178 | void g_input_stream_skip_async (GInputStream *stream, |
| 179 | gsize count, |
| 180 | int io_priority, |
| 181 | GCancellable *cancellable, |
| 182 | GAsyncReadyCallback callback, |
| 183 | gpointer user_data); |
| 184 | GIO_AVAILABLE_IN_ALL |
| 185 | gssize g_input_stream_skip_finish (GInputStream *stream, |
| 186 | GAsyncResult *result, |
| 187 | GError **error); |
| 188 | GIO_AVAILABLE_IN_ALL |
| 189 | void g_input_stream_close_async (GInputStream *stream, |
| 190 | int io_priority, |
| 191 | GCancellable *cancellable, |
| 192 | GAsyncReadyCallback callback, |
| 193 | gpointer user_data); |
| 194 | GIO_AVAILABLE_IN_ALL |
| 195 | gboolean g_input_stream_close_finish (GInputStream *stream, |
| 196 | GAsyncResult *result, |
| 197 | GError **error); |
| 198 | |
| 199 | /* For implementations: */ |
| 200 | |
| 201 | GIO_AVAILABLE_IN_ALL |
| 202 | gboolean g_input_stream_is_closed (GInputStream *stream); |
| 203 | GIO_AVAILABLE_IN_ALL |
| 204 | gboolean g_input_stream_has_pending (GInputStream *stream); |
| 205 | GIO_AVAILABLE_IN_ALL |
| 206 | gboolean g_input_stream_set_pending (GInputStream *stream, |
| 207 | GError **error); |
| 208 | GIO_AVAILABLE_IN_ALL |
| 209 | void g_input_stream_clear_pending (GInputStream *stream); |
| 210 | |
| 211 | G_END_DECLS |
| 212 | |
| 213 | #endif /* __G_INPUT_STREAM_H__ */ |
| 214 | |