GObject: substantially rework g_object_new()
[glib.git] / glib / glib-unix.h
blob66ccf74cd6ef5c8eab78e7a31ce9e84f8993aa2e
1 /* glib-unix.h - Unix specific integration
2 * Copyright (C) 2011 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __G_UNIX_H__
21 #define __G_UNIX_H__
23 /* We need to include the UNIX headers needed to use the APIs below,
24 * but we also take this opportunity to include a wide selection of
25 * other UNIX headers. If one of the headers below is broken on some
26 * system, work around it here (or better, fix the system or tell
27 * people to use a better one).
29 #include <unistd.h>
30 #include <errno.h>
31 #include <sys/wait.h>
32 #include <stdlib.h>
33 #include <fcntl.h>
35 #include <glib.h>
37 #ifndef G_OS_UNIX
38 #error "This header may only be used on UNIX"
39 #endif
41 G_BEGIN_DECLS
43 /**
44 * G_UNIX_ERROR:
46 * Error domain for API in the "g_unix_" namespace. Note that there is
47 * no exported enumeration mapping %errno. Instead, all functions
48 * ensure that %errno is relevant. The code for all #G_UNIX_ERROR is
49 * always <literal>0</literal>, and the error message is always
50 * generated via g_strerror().
52 * It is expected that most code will not look at %errno from these
53 * APIs. Important cases where one would want to differentiate between
54 * errors are already covered by existing cross-platform GLib API,
55 * such as e.g. #GFile wrapping <literal>ENOENT</literal>. However, it is
56 * provided for completeness, at least.
58 #define G_UNIX_ERROR (g_unix_error_quark())
60 GLIB_AVAILABLE_IN_2_30
61 GQuark g_unix_error_quark (void);
63 GLIB_AVAILABLE_IN_2_30
64 gboolean g_unix_open_pipe (gint *fds,
65 gint flags,
66 GError **error);
68 GLIB_AVAILABLE_IN_2_30
69 gboolean g_unix_set_fd_nonblocking (gint fd,
70 gboolean nonblock,
71 GError **error);
73 GLIB_AVAILABLE_IN_2_30
74 GSource *g_unix_signal_source_new (gint signum);
76 GLIB_AVAILABLE_IN_2_30
77 guint g_unix_signal_add_full (gint priority,
78 gint signum,
79 GSourceFunc handler,
80 gpointer user_data,
81 GDestroyNotify notify);
83 GLIB_AVAILABLE_IN_2_30
84 guint g_unix_signal_add (gint signum,
85 GSourceFunc handler,
86 gpointer user_data);
88 /**
89 * GUnixFDSourceFunc:
90 * @fd: the fd that triggered the event
91 * @condition: the IO conditions reported on @fd
92 * @user_data: user data passed to g_unix_fd_add()
94 * The type of functions to be called when a UNIX fd watch source
95 * triggers.
97 * Returns: %FALSE if the source should be removed
98 **/
99 typedef gboolean (*GUnixFDSourceFunc) (gint fd,
100 GIOCondition condition,
101 gpointer user_data);
103 GLIB_AVAILABLE_IN_2_36
104 GSource *g_unix_fd_source_new (gint fd,
105 GIOCondition condition);
107 GLIB_AVAILABLE_IN_2_36
108 guint g_unix_fd_add_full (gint priority,
109 gint fd,
110 GIOCondition condition,
111 GUnixFDSourceFunc function,
112 gpointer user_data,
113 GDestroyNotify notify);
115 GLIB_AVAILABLE_IN_2_36
116 guint g_unix_fd_add (gint fd,
117 GIOCondition condition,
118 GUnixFDSourceFunc function,
119 gpointer user_data);
121 G_END_DECLS
123 #endif /* __G_UNIX_H__ */