+
+ /**
+ * GUnixInputStream:fd:
+ *
+ * The file descriptor that the stream reads from.
+ *
+ * Since: 2.20
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_FD,
+ g_param_spec_int ("fd",
+ P_("File descriptor"),
+ P_("The file descriptor to read from"),
+ G_MININT, G_MAXINT, -1,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+ /**
+ * GUnixInputStream:close-fd:
+ *
+ * Whether to close the file descriptor when the stream is closed.
+ *
+ * Since: 2.20
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_CLOSE_FD,
+ g_param_spec_boolean ("close-fd",
+ P_("Close file descriptor"),
+ P_("Whether to close the file descriptor when the stream is closed"),
+ TRUE,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+}
+
+static void
+g_unix_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface)
+{
+ iface->can_poll = g_unix_input_stream_pollable_can_poll;
+ iface->is_readable = g_unix_input_stream_pollable_is_readable;
+ 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,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GUnixInputStream *unix_stream;
+
+ unix_stream = G_UNIX_INPUT_STREAM (object);
+
+ switch (prop_id)
+ {
+ case PROP_FD:
+ unix_stream->priv->fd = g_value_get_int (value);
+ if (lseek (unix_stream->priv->fd, 0, SEEK_CUR) == -1 && errno == ESPIPE)
+ unix_stream->priv->is_pipe_or_socket = TRUE;
+ else
+ unix_stream->priv->is_pipe_or_socket = FALSE;
+ break;
+ case PROP_CLOSE_FD:
+ unix_stream->priv->close_fd = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+g_unix_input_stream_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GUnixInputStream *unix_stream;
+
+ unix_stream = G_UNIX_INPUT_STREAM (object);
+
+ switch (prop_id)
+ {
+ case PROP_FD:
+ g_value_set_int (value, unix_stream->priv->fd);
+ break;
+ case PROP_CLOSE_FD:
+ g_value_set_boolean (value, unix_stream->priv->close_fd);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }