-#define MY_TYPE_IO_STREAM (my_io_stream_get_type ())
-#define MY_IO_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MY_TYPE_IO_STREAM, MyIOStream))
-#define MY_IS_IO_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MY_TYPE_IO_STREAM))
-
-typedef struct
-{
- GIOStream parent_instance;
- GInputStream *input_stream;
- GOutputStream *output_stream;
-} MyIOStream;
-
-typedef struct
-{
- GIOStreamClass parent_class;
-} MyIOStreamClass;
-
-static GType my_io_stream_get_type (void) G_GNUC_CONST;
-
-G_DEFINE_TYPE (MyIOStream, my_io_stream, G_TYPE_IO_STREAM);
-
-static void
-my_io_stream_finalize (GObject *object)
-{
- MyIOStream *stream = MY_IO_STREAM (object);
- g_object_unref (stream->input_stream);
- g_object_unref (stream->output_stream);
- G_OBJECT_CLASS (my_io_stream_parent_class)->finalize (object);
-}
-
-static void
-my_io_stream_init (MyIOStream *stream)
-{
-}
-
-static GInputStream *
-my_io_stream_get_input_stream (GIOStream *_stream)
-{
- MyIOStream *stream = MY_IO_STREAM (_stream);
- return stream->input_stream;
-}
-
-static GOutputStream *
-my_io_stream_get_output_stream (GIOStream *_stream)
-{
- MyIOStream *stream = MY_IO_STREAM (_stream);
- return stream->output_stream;
-}
-
-static void
-my_io_stream_class_init (MyIOStreamClass *klass)
-{
- GObjectClass *gobject_class;
- GIOStreamClass *giostream_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = my_io_stream_finalize;
-
- giostream_class = G_IO_STREAM_CLASS (klass);
- giostream_class->get_input_stream = my_io_stream_get_input_stream;
- giostream_class->get_output_stream = my_io_stream_get_output_stream;
-}
-
-static GIOStream *
-my_io_stream_new (GInputStream *input_stream,
- GOutputStream *output_stream)
-{
- MyIOStream *stream;
- g_return_val_if_fail (G_IS_INPUT_STREAM (input_stream), NULL);
- g_return_val_if_fail (G_IS_OUTPUT_STREAM (output_stream), NULL);
- stream = MY_IO_STREAM (g_object_new (MY_TYPE_IO_STREAM, NULL));
- stream->input_stream = g_object_ref (input_stream);
- stream->output_stream = g_object_ref (output_stream);
- return G_IO_STREAM (stream);
-}
-
-static GIOStream *
-my_io_stream_new_for_fds (gint fd_in, gint fd_out)
-{
- GIOStream *stream;
- GInputStream *input_stream;
- GOutputStream *output_stream;
-
- input_stream = g_unix_input_stream_new (fd_in, TRUE);
- output_stream = g_unix_output_stream_new (fd_out, TRUE);
- stream = my_io_stream_new (input_stream, output_stream);
- g_object_unref (input_stream);
- g_object_unref (output_stream);
- return stream;
-}