ginputstream.h 8.9 KB

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