goutputstream.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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_OUTPUT_STREAM_H__
  23. #define __G_OUTPUT_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_OUTPUT_STREAM (g_output_stream_get_type ())
  30. #define G_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_OUTPUT_STREAM, GOutputStream))
  31. #define G_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
  32. #define G_IS_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_OUTPUT_STREAM))
  33. #define G_IS_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_OUTPUT_STREAM))
  34. #define G_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
  35. typedef struct _GOutputStreamClass GOutputStreamClass;
  36. typedef struct _GOutputStreamPrivate GOutputStreamPrivate;
  37. struct _GOutputStream
  38. {
  39. GObject parent_instance;
  40. /*< private >*/
  41. GOutputStreamPrivate *priv;
  42. };
  43. struct _GOutputStreamClass
  44. {
  45. GObjectClass parent_class;
  46. /* Sync ops: */
  47. gssize (* write_fn) (GOutputStream *stream,
  48. const void *buffer,
  49. gsize count,
  50. GCancellable *cancellable,
  51. GError **error);
  52. gssize (* splice) (GOutputStream *stream,
  53. GInputStream *source,
  54. GOutputStreamSpliceFlags flags,
  55. GCancellable *cancellable,
  56. GError **error);
  57. gboolean (* flush) (GOutputStream *stream,
  58. GCancellable *cancellable,
  59. GError **error);
  60. gboolean (* close_fn) (GOutputStream *stream,
  61. GCancellable *cancellable,
  62. GError **error);
  63. /* Async ops: (optional in derived classes) */
  64. void (* write_async) (GOutputStream *stream,
  65. const void *buffer,
  66. gsize count,
  67. int io_priority,
  68. GCancellable *cancellable,
  69. GAsyncReadyCallback callback,
  70. gpointer user_data);
  71. gssize (* write_finish) (GOutputStream *stream,
  72. GAsyncResult *result,
  73. GError **error);
  74. void (* splice_async) (GOutputStream *stream,
  75. GInputStream *source,
  76. GOutputStreamSpliceFlags flags,
  77. int io_priority,
  78. GCancellable *cancellable,
  79. GAsyncReadyCallback callback,
  80. gpointer user_data);
  81. gssize (* splice_finish) (GOutputStream *stream,
  82. GAsyncResult *result,
  83. GError **error);
  84. void (* flush_async) (GOutputStream *stream,
  85. int io_priority,
  86. GCancellable *cancellable,
  87. GAsyncReadyCallback callback,
  88. gpointer user_data);
  89. gboolean (* flush_finish) (GOutputStream *stream,
  90. GAsyncResult *result,
  91. GError **error);
  92. void (* close_async) (GOutputStream *stream,
  93. int io_priority,
  94. GCancellable *cancellable,
  95. GAsyncReadyCallback callback,
  96. gpointer user_data);
  97. gboolean (* close_finish) (GOutputStream *stream,
  98. GAsyncResult *result,
  99. GError **error);
  100. gboolean (* writev_fn) (GOutputStream *stream,
  101. const GOutputVector *vectors,
  102. gsize n_vectors,
  103. gsize *bytes_written,
  104. GCancellable *cancellable,
  105. GError **error);
  106. void (* writev_async) (GOutputStream *stream,
  107. const GOutputVector *vectors,
  108. gsize n_vectors,
  109. int io_priority,
  110. GCancellable *cancellable,
  111. GAsyncReadyCallback callback,
  112. gpointer user_data);
  113. gboolean (* writev_finish) (GOutputStream *stream,
  114. GAsyncResult *result,
  115. gsize *bytes_written,
  116. GError **error);
  117. /*< private >*/
  118. /* Padding for future expansion */
  119. void (*_g_reserved4) (void);
  120. void (*_g_reserved5) (void);
  121. void (*_g_reserved6) (void);
  122. void (*_g_reserved7) (void);
  123. void (*_g_reserved8) (void);
  124. };
  125. GIO_AVAILABLE_IN_ALL
  126. GType g_output_stream_get_type (void) G_GNUC_CONST;
  127. GIO_AVAILABLE_IN_ALL
  128. gssize g_output_stream_write (GOutputStream *stream,
  129. const void *buffer,
  130. gsize count,
  131. GCancellable *cancellable,
  132. GError **error);
  133. GIO_AVAILABLE_IN_ALL
  134. gboolean g_output_stream_write_all (GOutputStream *stream,
  135. const void *buffer,
  136. gsize count,
  137. gsize *bytes_written,
  138. GCancellable *cancellable,
  139. GError **error);
  140. GIO_AVAILABLE_IN_2_60
  141. gboolean g_output_stream_writev (GOutputStream *stream,
  142. const GOutputVector *vectors,
  143. gsize n_vectors,
  144. gsize *bytes_written,
  145. GCancellable *cancellable,
  146. GError **error);
  147. GIO_AVAILABLE_IN_2_60
  148. gboolean g_output_stream_writev_all (GOutputStream *stream,
  149. GOutputVector *vectors,
  150. gsize n_vectors,
  151. gsize *bytes_written,
  152. GCancellable *cancellable,
  153. GError **error);
  154. GIO_AVAILABLE_IN_2_40
  155. gboolean g_output_stream_printf (GOutputStream *stream,
  156. gsize *bytes_written,
  157. GCancellable *cancellable,
  158. GError **error,
  159. const gchar *format,
  160. ...) G_GNUC_PRINTF (5, 6);
  161. GIO_AVAILABLE_IN_2_40
  162. gboolean g_output_stream_vprintf (GOutputStream *stream,
  163. gsize *bytes_written,
  164. GCancellable *cancellable,
  165. GError **error,
  166. const gchar *format,
  167. va_list args) G_GNUC_PRINTF (5, 0);
  168. GIO_AVAILABLE_IN_2_34
  169. gssize g_output_stream_write_bytes (GOutputStream *stream,
  170. GBytes *bytes,
  171. GCancellable *cancellable,
  172. GError **error);
  173. GIO_AVAILABLE_IN_ALL
  174. gssize g_output_stream_splice (GOutputStream *stream,
  175. GInputStream *source,
  176. GOutputStreamSpliceFlags flags,
  177. GCancellable *cancellable,
  178. GError **error);
  179. GIO_AVAILABLE_IN_ALL
  180. gboolean g_output_stream_flush (GOutputStream *stream,
  181. GCancellable *cancellable,
  182. GError **error);
  183. GIO_AVAILABLE_IN_ALL
  184. gboolean g_output_stream_close (GOutputStream *stream,
  185. GCancellable *cancellable,
  186. GError **error);
  187. GIO_AVAILABLE_IN_ALL
  188. void g_output_stream_write_async (GOutputStream *stream,
  189. const void *buffer,
  190. gsize count,
  191. int io_priority,
  192. GCancellable *cancellable,
  193. GAsyncReadyCallback callback,
  194. gpointer user_data);
  195. GIO_AVAILABLE_IN_ALL
  196. gssize g_output_stream_write_finish (GOutputStream *stream,
  197. GAsyncResult *result,
  198. GError **error);
  199. GIO_AVAILABLE_IN_2_44
  200. void g_output_stream_write_all_async (GOutputStream *stream,
  201. const void *buffer,
  202. gsize count,
  203. int io_priority,
  204. GCancellable *cancellable,
  205. GAsyncReadyCallback callback,
  206. gpointer user_data);
  207. GIO_AVAILABLE_IN_2_44
  208. gboolean g_output_stream_write_all_finish (GOutputStream *stream,
  209. GAsyncResult *result,
  210. gsize *bytes_written,
  211. GError **error);
  212. GIO_AVAILABLE_IN_2_60
  213. void g_output_stream_writev_async (GOutputStream *stream,
  214. const GOutputVector *vectors,
  215. gsize n_vectors,
  216. int io_priority,
  217. GCancellable *cancellable,
  218. GAsyncReadyCallback callback,
  219. gpointer user_data);
  220. GIO_AVAILABLE_IN_2_60
  221. gboolean g_output_stream_writev_finish (GOutputStream *stream,
  222. GAsyncResult *result,
  223. gsize *bytes_written,
  224. GError **error);
  225. GIO_AVAILABLE_IN_2_60
  226. void g_output_stream_writev_all_async (GOutputStream *stream,
  227. GOutputVector *vectors,
  228. gsize n_vectors,
  229. int io_priority,
  230. GCancellable *cancellable,
  231. GAsyncReadyCallback callback,
  232. gpointer user_data);
  233. GIO_AVAILABLE_IN_2_60
  234. gboolean g_output_stream_writev_all_finish (GOutputStream *stream,
  235. GAsyncResult *result,
  236. gsize *bytes_written,
  237. GError **error);
  238. GIO_AVAILABLE_IN_2_34
  239. void g_output_stream_write_bytes_async (GOutputStream *stream,
  240. GBytes *bytes,
  241. int io_priority,
  242. GCancellable *cancellable,
  243. GAsyncReadyCallback callback,
  244. gpointer user_data);
  245. GIO_AVAILABLE_IN_2_34
  246. gssize g_output_stream_write_bytes_finish (GOutputStream *stream,
  247. GAsyncResult *result,
  248. GError **error);
  249. GIO_AVAILABLE_IN_ALL
  250. void g_output_stream_splice_async (GOutputStream *stream,
  251. GInputStream *source,
  252. GOutputStreamSpliceFlags flags,
  253. int io_priority,
  254. GCancellable *cancellable,
  255. GAsyncReadyCallback callback,
  256. gpointer user_data);
  257. GIO_AVAILABLE_IN_ALL
  258. gssize g_output_stream_splice_finish (GOutputStream *stream,
  259. GAsyncResult *result,
  260. GError **error);
  261. GIO_AVAILABLE_IN_ALL
  262. void g_output_stream_flush_async (GOutputStream *stream,
  263. int io_priority,
  264. GCancellable *cancellable,
  265. GAsyncReadyCallback callback,
  266. gpointer user_data);
  267. GIO_AVAILABLE_IN_ALL
  268. gboolean g_output_stream_flush_finish (GOutputStream *stream,
  269. GAsyncResult *result,
  270. GError **error);
  271. GIO_AVAILABLE_IN_ALL
  272. void g_output_stream_close_async (GOutputStream *stream,
  273. int io_priority,
  274. GCancellable *cancellable,
  275. GAsyncReadyCallback callback,
  276. gpointer user_data);
  277. GIO_AVAILABLE_IN_ALL
  278. gboolean g_output_stream_close_finish (GOutputStream *stream,
  279. GAsyncResult *result,
  280. GError **error);
  281. GIO_AVAILABLE_IN_ALL
  282. gboolean g_output_stream_is_closed (GOutputStream *stream);
  283. GIO_AVAILABLE_IN_ALL
  284. gboolean g_output_stream_is_closing (GOutputStream *stream);
  285. GIO_AVAILABLE_IN_ALL
  286. gboolean g_output_stream_has_pending (GOutputStream *stream);
  287. GIO_AVAILABLE_IN_ALL
  288. gboolean g_output_stream_set_pending (GOutputStream *stream,
  289. GError **error);
  290. GIO_AVAILABLE_IN_ALL
  291. void g_output_stream_clear_pending (GOutputStream *stream);
  292. G_END_DECLS
  293. #endif /* __G_OUTPUT_STREAM_H__ */