chiark / gitweb /
manager: when isolating undo all pending jobs, too
[elogind.git] / src / exit-status.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2010 Lennart Poettering
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   General Public License for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <stdlib.h>
23
24 #include "exit-status.h"
25
26 const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
27
28         /* We cast to int here, so that -Wenum doesn't complain that
29          * EXIT_SUCCESS/EXIT_FAILURE aren't in the enum */
30
31         switch ((int) status) {
32
33         case EXIT_SUCCESS:
34                 return "SUCCESS";
35
36         case EXIT_FAILURE:
37                 return "FAILURE";
38         }
39
40
41         if (level == EXIT_STATUS_SYSTEMD || level == EXIT_STATUS_LSB) {
42                 switch ((int) status) {
43
44                 case EXIT_CHDIR:
45                         return "CHDIR";
46
47                 case EXIT_NICE:
48                         return "NICE";
49
50                 case EXIT_FDS:
51                         return "FDS";
52
53                 case EXIT_EXEC:
54                         return "EXEC";
55
56                 case EXIT_MEMORY:
57                         return "MEMORY";
58
59                 case EXIT_LIMITS:
60                         return "LIMITS";
61
62                 case EXIT_OOM_ADJUST:
63                         return "OOM_ADJUST";
64
65                 case EXIT_SIGNAL_MASK:
66                         return "SIGNAL_MASK";
67
68                 case EXIT_STDIN:
69                         return "STDIN";
70
71                 case EXIT_STDOUT:
72                         return "STDOUT";
73
74                 case EXIT_CHROOT:
75                         return "CHROOT";
76
77                 case EXIT_IOPRIO:
78                         return "IOPRIO";
79
80                 case EXIT_TIMERSLACK:
81                         return "TIMERSLACK";
82
83                 case EXIT_SECUREBITS:
84                         return "SECUREBITS";
85
86                 case EXIT_SETSCHEDULER:
87                         return "SETSCHEDULER";
88
89                 case EXIT_CPUAFFINITY:
90                         return "CPUAFFINITY";
91
92                 case EXIT_GROUP:
93                         return "GROUP";
94
95                 case EXIT_USER:
96                         return "USER";
97
98                 case EXIT_CAPABILITIES:
99                         return "CAPABILITIES";
100
101                 case EXIT_CGROUP:
102                         return "CGROUP";
103
104                 case EXIT_SETSID:
105                         return "SETSID";
106
107                 case EXIT_CONFIRM:
108                         return "CONFIRM";
109
110                 case EXIT_STDERR:
111                         return "STDERR";
112
113                 case EXIT_TCPWRAP:
114                         return "TCPWRAP";
115
116                 case EXIT_PAM:
117                         return "PAM";
118                 }
119         }
120
121         if (level == EXIT_STATUS_LSB) {
122                 switch ((int) status) {
123
124                 case EXIT_INVALIDARGUMENT:
125                         return "INVALIDARGUMENT";
126
127                 case EXIT_NOTIMPLEMENTED:
128                         return "NOTIMPLEMENTED";
129
130                 case EXIT_NOPERMISSION:
131                         return "NOPERMISSION";
132
133                 case EXIT_NOTINSTALLED:
134                         return "NOTINSSTALLED";
135
136                 case EXIT_NOTCONFIGURED:
137                         return "NOTCONFIGURED";
138
139                 case EXIT_NOTRUNNING:
140                         return "NOTRUNNING";
141                 }
142         }
143
144         return NULL;
145 }