static VALUE unixfdlist_get(VALUE self, VALUE index) { GError *error = NULL; gint fd; fd = g_unix_fd_list_get(_SELF(self), RVAL2GINT(index), &error); if (fd == -1) rbgio_raise_error(error); /* TODO: This fd must be closed properly. How do we deal with that? */ return FD2RVAL(fd); }
VALUE rbgio_fds_to_ary(const gint *fds) { int i, n; VALUE ary; for (i = n = 0; fds[i] != -1; i++) n++; ary = rb_ary_new2(n); for (i = 0; i < n; i++) RARRAY_PTR(ary)[i] = FD2RVAL(fds[i]); return ary; }
static VALUE rg_receive_fd(int argc, VALUE *argv, VALUE self) { VALUE cancellable; GError *error = NULL; gint fd; rb_scan_args(argc, argv, "01", &cancellable); fd = g_unix_connection_receive_fd(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error); if (fd == -1) rbgio_raise_error(error); return FD2RVAL(fd); }
static VALUE rg_fd(VALUE self) { return FD2RVAL(g_file_descriptor_based_get_fd(_SELF(self))); }