Example #1
0
/**
 * g_unix_fd_source_new:
 * @fd: a file descriptor
 * @condition: IO conditions to watch for on @fd
 *
 * Creates a #GSource to watch for a particular IO condition on a file
 * descriptor.
 *
 * The source will never close the fd -- you must do it yourself.
 *
 * Returns: the newly created #GSource
 *
 * Since: 2.36
 **/
GSource *
g_unix_fd_source_new (gint         fd,
                      GIOCondition condition)
{
  GUnixFDSource *fd_source;
  GSource *source;

  source = g_source_new (&g_unix_fd_source_funcs, sizeof (GUnixFDSource));
  fd_source = (GUnixFDSource *) source;

  fd_source->fd = fd;
  fd_source->tag = g_source_add_unix_fd (source, fd, condition);

  return source;
}
Example #2
0
gpointer hinawa_context_add_src(GSource *src, gint fd, GIOCondition event,
				GError **exception)
{
	GMainContext *ctx;

	ctx = get_my_context(exception);
	if (*exception != NULL)
		return NULL;
	running = TRUE;

	/* NOTE: The returned ID is never used. */
	g_source_attach(src, ctx);

	return g_source_add_unix_fd(src, fd, event);
}
Example #3
0
GWaterNlSource *
g_water_nl_source_new_for_cache_mngr(GMainContext *context, struct nl_cache_mngr *cache_mngr)
{
    g_return_val_if_fail(cache_mngr != NULL, NULL);

    GSource *source;
    GWaterNlSource *self;

    source = g_source_new(&_g_water_nl_source_funcs, sizeof(GWaterNlSource));
    self = (GWaterNlSource *)source;
    self->cache_mngr = cache_mngr;

    self->fd = g_source_add_unix_fd(source, nl_cache_mngr_get_fd(self->cache_mngr), G_IO_IN | G_IO_ERR | G_IO_HUP);

    g_source_attach(source, context);

    return self;
}
Example #4
0
/**
 * g_unix_fd_source_new:
 * @fd: a file descriptor
 * @condition: IO conditions to watch for on @fd
 *
 * Creates a #GSource to watch for a particular IO condition on a file
 * descriptor.
 *
 * The source will never close the fd -- you must do it yourself.
 *
 * Returns: the newly created #GSource
 *
 * Since: 2.36
 **/
GSource *
g_unix_fd_source_new (gint         fd,
                      GIOCondition condition)
{
  static GSourceFuncs source_funcs = {
    NULL, NULL, g_unix_fd_source_dispatch, NULL
  };
  GUnixFDSource *fd_source;
  GSource *source;

  source = g_source_new (&source_funcs, sizeof (GUnixFDSource));
  fd_source = (GUnixFDSource *) source;

  fd_source->fd = fd;
  fd_source->tag = g_source_add_unix_fd (source, fd, condition);

  return source;
}
Example #5
0
GWaterNlSource *
g_water_nl_source_new_for_sock(GMainContext *context, struct nl_sock *sock)
{
    g_return_val_if_fail(sock != NULL, NULL);

    GSource *source;
    GWaterNlSource *self;

    source = g_source_new(&_g_water_nl_source_funcs, sizeof(GWaterNlSource));
    self = (GWaterNlSource *)source;
    self->sock = sock;

    nl_socket_set_nonblocking(self->sock);

    self->fd = g_source_add_unix_fd(source, nl_socket_get_fd(self->sock), G_IO_IN | G_IO_ERR | G_IO_HUP);

    g_source_attach(source, context);

    return self;
}