You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

208 line
9.3 KiB

  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright (C) 2006-2007 Red Hat, Inc.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General
  16. * Public License along with this library; if not, write to the
  17. * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  18. * Boston, MA 02111-1307, USA.
  19. *
  20. * Author: Alexander Larsson <alexl@redhat.com>
  21. */
  22. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  23. #error "Only <gio/gio.h> can be included directly."
  24. #endif
  25. #ifndef __G_OUTPUT_STREAM_H__
  26. #define __G_OUTPUT_STREAM_H__
  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. /**
  36. * GOutputStream:
  37. *
  38. * Base class for writing output.
  39. *
  40. * All classes derived from GOutputStream should implement synchronous
  41. * writing, splicing, flushing and closing streams, but may implement
  42. * asynchronous versions.
  43. **/
  44. typedef struct _GOutputStreamClass GOutputStreamClass;
  45. typedef struct _GOutputStreamPrivate GOutputStreamPrivate;
  46. struct _GOutputStream
  47. {
  48. GObject parent_instance;
  49. /*< private >*/
  50. GOutputStreamPrivate *priv;
  51. };
  52. struct _GOutputStreamClass
  53. {
  54. GObjectClass parent_class;
  55. /* Sync ops: */
  56. gssize (* write_fn) (GOutputStream *stream,
  57. const void *buffer,
  58. gsize count,
  59. GCancellable *cancellable,
  60. GError **error);
  61. gssize (* splice) (GOutputStream *stream,
  62. GInputStream *source,
  63. GOutputStreamSpliceFlags flags,
  64. GCancellable *cancellable,
  65. GError **error);
  66. gboolean (* flush) (GOutputStream *stream,
  67. GCancellable *cancellable,
  68. GError **error);
  69. gboolean (* close_fn) (GOutputStream *stream,
  70. GCancellable *cancellable,
  71. GError **error);
  72. /* Async ops: (optional in derived classes) */
  73. void (* write_async) (GOutputStream *stream,
  74. const void *buffer,
  75. gsize count,
  76. int io_priority,
  77. GCancellable *cancellable,
  78. GAsyncReadyCallback callback,
  79. gpointer user_data);
  80. gssize (* write_finish) (GOutputStream *stream,
  81. GAsyncResult *result,
  82. GError **error);
  83. void (* splice_async) (GOutputStream *stream,
  84. GInputStream *source,
  85. GOutputStreamSpliceFlags flags,
  86. int io_priority,
  87. GCancellable *cancellable,
  88. GAsyncReadyCallback callback,
  89. gpointer data);
  90. gssize (* splice_finish) (GOutputStream *stream,
  91. GAsyncResult *result,
  92. GError **error);
  93. void (* flush_async) (GOutputStream *stream,
  94. int io_priority,
  95. GCancellable *cancellable,
  96. GAsyncReadyCallback callback,
  97. gpointer user_data);
  98. gboolean (* flush_finish) (GOutputStream *stream,
  99. GAsyncResult *result,
  100. GError **error);
  101. void (* close_async) (GOutputStream *stream,
  102. int io_priority,
  103. GCancellable *cancellable,
  104. GAsyncReadyCallback callback,
  105. gpointer user_data);
  106. gboolean (* close_finish) (GOutputStream *stream,
  107. GAsyncResult *result,
  108. GError **error);
  109. /*< private >*/
  110. /* Padding for future expansion */
  111. void (*_g_reserved1) (void);
  112. void (*_g_reserved2) (void);
  113. void (*_g_reserved3) (void);
  114. void (*_g_reserved4) (void);
  115. void (*_g_reserved5) (void);
  116. void (*_g_reserved6) (void);
  117. void (*_g_reserved7) (void);
  118. void (*_g_reserved8) (void);
  119. };
  120. GType g_output_stream_get_type (void) G_GNUC_CONST;
  121. gssize g_output_stream_write (GOutputStream *stream,
  122. const void *buffer,
  123. gsize count,
  124. GCancellable *cancellable,
  125. GError **error);
  126. gboolean g_output_stream_write_all (GOutputStream *stream,
  127. const void *buffer,
  128. gsize count,
  129. gsize *bytes_written,
  130. GCancellable *cancellable,
  131. GError **error);
  132. gssize g_output_stream_splice (GOutputStream *stream,
  133. GInputStream *source,
  134. GOutputStreamSpliceFlags flags,
  135. GCancellable *cancellable,
  136. GError **error);
  137. gboolean g_output_stream_flush (GOutputStream *stream,
  138. GCancellable *cancellable,
  139. GError **error);
  140. gboolean g_output_stream_close (GOutputStream *stream,
  141. GCancellable *cancellable,
  142. GError **error);
  143. void g_output_stream_write_async (GOutputStream *stream,
  144. const void *buffer,
  145. gsize count,
  146. int io_priority,
  147. GCancellable *cancellable,
  148. GAsyncReadyCallback callback,
  149. gpointer user_data);
  150. gssize g_output_stream_write_finish (GOutputStream *stream,
  151. GAsyncResult *result,
  152. GError **error);
  153. void g_output_stream_splice_async (GOutputStream *stream,
  154. GInputStream *source,
  155. GOutputStreamSpliceFlags flags,
  156. int io_priority,
  157. GCancellable *cancellable,
  158. GAsyncReadyCallback callback,
  159. gpointer user_data);
  160. gssize g_output_stream_splice_finish (GOutputStream *stream,
  161. GAsyncResult *result,
  162. GError **error);
  163. void g_output_stream_flush_async (GOutputStream *stream,
  164. int io_priority,
  165. GCancellable *cancellable,
  166. GAsyncReadyCallback callback,
  167. gpointer user_data);
  168. gboolean g_output_stream_flush_finish (GOutputStream *stream,
  169. GAsyncResult *result,
  170. GError **error);
  171. void g_output_stream_close_async (GOutputStream *stream,
  172. int io_priority,
  173. GCancellable *cancellable,
  174. GAsyncReadyCallback callback,
  175. gpointer user_data);
  176. gboolean g_output_stream_close_finish (GOutputStream *stream,
  177. GAsyncResult *result,
  178. GError **error);
  179. gboolean g_output_stream_is_closed (GOutputStream *stream);
  180. gboolean g_output_stream_is_closing (GOutputStream *stream);
  181. gboolean g_output_stream_has_pending (GOutputStream *stream);
  182. gboolean g_output_stream_set_pending (GOutputStream *stream,
  183. GError **error);
  184. void g_output_stream_clear_pending (GOutputStream *stream);
  185. G_END_DECLS
  186. #endif /* __G_OUTPUT_STREAM_H__ */