Imported Upstream version 2.74.3
[platform/upstream/glib.git] / glib / gspawn-private.h
1 /* gspawn.c - Process launching
2  *
3  *  Copyright 2000 Red Hat, Inc.
4  *  g_execvpe implementation based on GNU libc execvp:
5  *   Copyright 1991, 92, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
6  *
7  * SPDX-License-Identifier: LGPL-2.1-or-later
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #include "config.h"
24
25 #include <errno.h>
26
27 #include "gspawn.h"
28
29 static inline gint
30 _g_spawn_exec_err_to_g_error (gint en)
31 {
32   switch (en)
33     {
34 #ifdef EACCES
35     case EACCES:
36       return G_SPAWN_ERROR_ACCES;
37 #endif
38
39 #ifdef EPERM
40     case EPERM:
41       return G_SPAWN_ERROR_PERM;
42 #endif
43
44 #ifdef E2BIG
45     case E2BIG:
46       return G_SPAWN_ERROR_TOO_BIG;
47 #endif
48
49 #ifdef ENOEXEC
50     case ENOEXEC:
51       return G_SPAWN_ERROR_NOEXEC;
52 #endif
53
54 #ifdef ENAMETOOLONG
55     case ENAMETOOLONG:
56       return G_SPAWN_ERROR_NAMETOOLONG;
57 #endif
58
59 #ifdef ENOENT
60     case ENOENT:
61       return G_SPAWN_ERROR_NOENT;
62 #endif
63
64 #ifdef ENOMEM
65     case ENOMEM:
66       return G_SPAWN_ERROR_NOMEM;
67 #endif
68
69 #ifdef ENOTDIR
70     case ENOTDIR:
71       return G_SPAWN_ERROR_NOTDIR;
72 #endif
73
74 #ifdef ELOOP
75     case ELOOP:
76       return G_SPAWN_ERROR_LOOP;
77 #endif
78
79 #ifdef ETXTBUSY
80     case ETXTBUSY:
81       return G_SPAWN_ERROR_TXTBUSY;
82 #endif
83
84 #ifdef EIO
85     case EIO:
86       return G_SPAWN_ERROR_IO;
87 #endif
88
89 #ifdef ENFILE
90     case ENFILE:
91       return G_SPAWN_ERROR_NFILE;
92 #endif
93
94 #ifdef EMFILE
95     case EMFILE:
96       return G_SPAWN_ERROR_MFILE;
97 #endif
98
99 #ifdef EINVAL
100     case EINVAL:
101       return G_SPAWN_ERROR_INVAL;
102 #endif
103
104 #ifdef EISDIR
105     case EISDIR:
106       return G_SPAWN_ERROR_ISDIR;
107 #endif
108
109 #ifdef ELIBBAD
110     case ELIBBAD:
111       return G_SPAWN_ERROR_LIBBAD;
112 #endif
113
114     default:
115       return G_SPAWN_ERROR_FAILED;
116     }
117 }