Blame glib/glib-unix.h

Packit ae235b
/* glib-unix.h - Unix specific integration
Packit ae235b
 * Copyright (C) 2011 Red Hat, Inc.
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General Public License
Packit ae235b
 * along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 */
Packit ae235b
Packit ae235b
#ifndef __G_UNIX_H__
Packit ae235b
#define __G_UNIX_H__
Packit ae235b
Packit ae235b
/* We need to include the UNIX headers needed to use the APIs below,
Packit ae235b
 * but we also take this opportunity to include a wide selection of
Packit ae235b
 * other UNIX headers.  If one of the headers below is broken on some
Packit ae235b
 * system, work around it here (or better, fix the system or tell
Packit ae235b
 * people to use a better one).
Packit ae235b
 */
Packit ae235b
#include <unistd.h>
Packit ae235b
#include <errno.h>
Packit ae235b
#include <sys/wait.h>
Packit ae235b
#include <stdlib.h>
Packit ae235b
#include <fcntl.h>
Packit ae235b
Packit ae235b
#include <glib.h>
Packit ae235b
Packit ae235b
#ifndef G_OS_UNIX
Packit ae235b
#error "This header may only be used on UNIX"
Packit ae235b
#endif
Packit ae235b
Packit ae235b
G_BEGIN_DECLS
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_UNIX_ERROR:
Packit ae235b
 *
Packit ae235b
 * Error domain for API in the g_unix_ namespace. Note that there is no
Packit ae235b
 * exported enumeration mapping %errno. Instead, all functions ensure that
Packit ae235b
 * %errno is relevant. The code for all #G_UNIX_ERROR is always 0, and the
Packit ae235b
 * error message is always generated via g_strerror().
Packit ae235b
 *
Packit ae235b
 * It is expected that most code will not look at %errno from these APIs.
Packit ae235b
 * Important cases where one would want to differentiate between errors are
Packit ae235b
 * already covered by existing cross-platform GLib API, such as e.g. #GFile
Packit ae235b
 * wrapping `ENOENT`. However, it is provided for completeness, at least.
Packit ae235b
 */
Packit ae235b
#define G_UNIX_ERROR (g_unix_error_quark())
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_30
Packit ae235b
GQuark g_unix_error_quark (void);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_30
Packit ae235b
gboolean g_unix_open_pipe (gint    *fds,
Packit ae235b
                           gint     flags,
Packit ae235b
                           GError **error);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_30
Packit ae235b
gboolean g_unix_set_fd_nonblocking (gint       fd,
Packit ae235b
                                    gboolean   nonblock,
Packit ae235b
                                    GError   **error);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_30
Packit ae235b
GSource *g_unix_signal_source_new  (gint signum);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_30
Packit ae235b
guint    g_unix_signal_add_full    (gint           priority,
Packit ae235b
                                    gint           signum,
Packit ae235b
                                    GSourceFunc    handler,
Packit ae235b
                                    gpointer       user_data,
Packit ae235b
                                    GDestroyNotify notify);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_30
Packit ae235b
guint    g_unix_signal_add         (gint        signum,
Packit ae235b
                                    GSourceFunc handler,
Packit ae235b
                                    gpointer    user_data);
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GUnixFDSourceFunc:
Packit ae235b
 * @fd: the fd that triggered the event
Packit ae235b
 * @condition: the IO conditions reported on @fd
Packit ae235b
 * @user_data: user data passed to g_unix_fd_add()
Packit ae235b
 *
Packit ae235b
 * The type of functions to be called when a UNIX fd watch source
Packit ae235b
 * triggers.
Packit ae235b
 *
Packit ae235b
 * Returns: %FALSE if the source should be removed
Packit ae235b
 **/
Packit ae235b
typedef gboolean (*GUnixFDSourceFunc) (gint         fd,
Packit ae235b
                                       GIOCondition condition,
Packit ae235b
                                       gpointer     user_data);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_36
Packit ae235b
GSource *g_unix_fd_source_new      (gint         fd,
Packit ae235b
                                    GIOCondition condition);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_36
Packit ae235b
guint    g_unix_fd_add_full        (gint              priority,
Packit ae235b
                                    gint              fd,
Packit ae235b
                                    GIOCondition      condition,
Packit ae235b
                                    GUnixFDSourceFunc function,
Packit ae235b
                                    gpointer          user_data,
Packit ae235b
                                    GDestroyNotify    notify);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_36
Packit ae235b
guint    g_unix_fd_add             (gint              fd,
Packit ae235b
                                    GIOCondition      condition,
Packit ae235b
                                    GUnixFDSourceFunc function,
Packit ae235b
                                    gpointer          user_data);
Packit ae235b
Packit ae235b
G_END_DECLS
Packit ae235b
Packit ae235b
#endif  /* __G_UNIX_H__ */