glib-unix: New Unix-specific API
[platform/upstream/glib.git] / glib / glib-unix.h
1 /* glib-unix.h - Unix specific integration
2  * Copyright (C) 2011 Red Hat, Inc.
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #ifndef __G_UNIX_H__
21 #define __G_UNIX_H__
22
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).
28  */
29 #ifndef _GNU_SOURCE
30 #define _G_GNU_SOURCE_TEMPORARILY_DEFINED
31 #define _GNU_SOURCE
32 #endif
33 #ifdef HAVE_UNISTD_H
34 #include <unistd.h>
35 #endif
36 #include <errno.h>
37 #include <sys/wait.h>
38 #include <stdlib.h>
39 #include <fcntl.h>
40 #ifdef _G_GNU_SOURCE_TEMPORARILY_DEFINED
41 #undef _GNU_SOURCE
42 #undef _G_GNU_SOURCE_TEMPORARILY_DEFINED
43 #endif
44
45 #include <glib.h>
46
47 /**
48  * G_UNIX_ERROR:
49  * 
50  * Error domain for API in the "g_unix_" namespace.  Note that there
51  * is no exported enumeration mapping "errno".  Instead, all functions
52  * ensure that "errno" is relevant.  The code for all G_UNIX_ERROR is
53  * always 0, and the error message is always generated via
54  * g_strerror().
55  *
56  * It is expected that most code will not look at "errno" from these
57  * APIs. Important cases where one would want to differentiate between
58  * errors are already covered by existing cross-platform GLib API,
59  * such as e.g. GFile wrapping "ENOENT".  However, it is provided for
60  * completeness, at least.
61  */
62 #define G_UNIX_ERROR (g_unix_error_quark())
63
64 GQuark g_unix_error_quark (void);
65
66 gboolean g_unix_pipe_flags (int      *fds,
67                             int       flags,
68                             GError  **error);
69
70 #endif