mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-23 22:16:16 +01:00
gio: more implementations of GFileDescriptorBased
Implement GFileDescriptorBased in GSocket{Input,Output}Stream and GUnix{Input,Output}Stream. https://bugzilla.gnome.org/show_bug.cgi?id=616852
This commit is contained in:
parent
f218353e04
commit
759c0e935d
@ -31,13 +31,20 @@
|
||||
#include "gcancellable.h"
|
||||
#include "gpollableinputstream.h"
|
||||
#include "gioerror.h"
|
||||
|
||||
#include "gfiledescriptorbased.h"
|
||||
|
||||
static void g_socket_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface);
|
||||
#ifdef G_OS_UNIX
|
||||
static void g_socket_input_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
||||
#endif
|
||||
|
||||
#define g_socket_input_stream_get_type _g_socket_input_stream_get_type
|
||||
G_DEFINE_TYPE_WITH_CODE (GSocketInputStream, g_socket_input_stream, G_TYPE_INPUT_STREAM,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM, g_socket_input_stream_pollable_iface_init)
|
||||
#ifdef G_OS_UNIX
|
||||
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED, g_socket_input_stream_file_descriptor_based_iface_init)
|
||||
#endif
|
||||
)
|
||||
|
||||
enum
|
||||
@ -248,6 +255,16 @@ g_socket_input_stream_pollable_read_nonblocking (GPollableInputStream *pollable
|
||||
NULL, error);
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
static int
|
||||
g_socket_input_stream_get_fd (GFileDescriptorBased *fd_based)
|
||||
{
|
||||
GSocketInputStream *input_stream = G_SOCKET_INPUT_STREAM (fd_based);
|
||||
|
||||
return g_socket_get_fd (input_stream->priv->socket);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
g_socket_input_stream_class_init (GSocketInputStreamClass *klass)
|
||||
{
|
||||
@ -272,6 +289,14 @@ g_socket_input_stream_class_init (GSocketInputStreamClass *klass)
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
static void
|
||||
g_socket_input_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
||||
{
|
||||
iface->get_fd = g_socket_input_stream_get_fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
g_socket_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface)
|
||||
{
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "goutputstream.h"
|
||||
#include "gsocketoutputstream.h"
|
||||
#include "gsocket.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gcancellable.h"
|
||||
@ -34,14 +35,20 @@
|
||||
#include "gpollableoutputstream.h"
|
||||
#include "gioerror.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
#include "gfiledescriptorbased.h"
|
||||
|
||||
static void g_socket_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface);
|
||||
#ifdef G_OS_UNIX
|
||||
static void g_socket_output_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
||||
#endif
|
||||
|
||||
#define g_socket_output_stream_get_type _g_socket_output_stream_get_type
|
||||
G_DEFINE_TYPE_WITH_CODE (GSocketOutputStream, g_socket_output_stream, G_TYPE_OUTPUT_STREAM,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_OUTPUT_STREAM, g_socket_output_stream_pollable_iface_init)
|
||||
)
|
||||
#ifdef G_OS_UNIX
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED, g_socket_output_stream_file_descriptor_based_iface_init)
|
||||
#endif
|
||||
);
|
||||
|
||||
enum
|
||||
{
|
||||
@ -251,6 +258,16 @@ g_socket_output_stream_pollable_write_nonblocking (GPollableOutputStream *polla
|
||||
NULL, error);
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
static int
|
||||
g_socket_output_stream_get_fd (GFileDescriptorBased *fd_based)
|
||||
{
|
||||
GSocketOutputStream *output_stream = G_SOCKET_OUTPUT_STREAM (fd_based);
|
||||
|
||||
return g_socket_get_fd (output_stream->priv->socket);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
g_socket_output_stream_class_init (GSocketOutputStreamClass *klass)
|
||||
{
|
||||
@ -275,6 +292,14 @@ g_socket_output_stream_class_init (GSocketOutputStreamClass *klass)
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
static void
|
||||
g_socket_output_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
||||
{
|
||||
iface->get_fd = g_socket_output_stream_get_fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
g_socket_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface)
|
||||
{
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "gunixinputstream.h"
|
||||
#include "gcancellable.h"
|
||||
#include "gasynchelper.h"
|
||||
#include "gfiledescriptorbased.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
|
||||
@ -61,11 +62,14 @@ enum {
|
||||
};
|
||||
|
||||
static void g_unix_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface);
|
||||
static void g_unix_input_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GUnixInputStream, g_unix_input_stream, G_TYPE_INPUT_STREAM,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
|
||||
g_unix_input_stream_pollable_iface_init)
|
||||
);
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED,
|
||||
g_unix_input_stream_file_descriptor_based_iface_init)
|
||||
)
|
||||
|
||||
struct _GUnixInputStreamPrivate {
|
||||
int fd;
|
||||
@ -189,6 +193,12 @@ g_unix_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface)
|
||||
iface->create_source = g_unix_input_stream_pollable_create_source;
|
||||
}
|
||||
|
||||
static void
|
||||
g_unix_input_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
||||
{
|
||||
iface->get_fd = (int (*) (GFileDescriptorBased *))g_unix_input_stream_get_fd;
|
||||
}
|
||||
|
||||
static void
|
||||
g_unix_input_stream_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "gcancellable.h"
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gasynchelper.h"
|
||||
#include "gfiledescriptorbased.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
|
||||
@ -61,11 +62,14 @@ enum {
|
||||
};
|
||||
|
||||
static void g_unix_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface);
|
||||
static void g_unix_output_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GUnixOutputStream, g_unix_output_stream, G_TYPE_OUTPUT_STREAM,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_OUTPUT_STREAM,
|
||||
g_unix_output_stream_pollable_iface_init)
|
||||
);
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED,
|
||||
g_unix_output_stream_file_descriptor_based_iface_init)
|
||||
)
|
||||
|
||||
struct _GUnixOutputStreamPrivate {
|
||||
int fd;
|
||||
@ -174,6 +178,12 @@ g_unix_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface)
|
||||
iface->create_source = g_unix_output_stream_pollable_create_source;
|
||||
}
|
||||
|
||||
static void
|
||||
g_unix_output_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
||||
{
|
||||
iface->get_fd = (int (*) (GFileDescriptorBased *))g_unix_output_stream_get_fd;
|
||||
}
|
||||
|
||||
static void
|
||||
g_unix_output_stream_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
|
Loading…
Reference in New Issue
Block a user