Commit | Line | Data |
---|---|---|
460b9539 | 1 | /* |
2 | * This file is part of DisOrder. | |
5aff007d | 3 | * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell |
460b9539 | 4 | * |
e7eb3a27 | 5 | * This program is free software: you can redistribute it and/or modify |
460b9539 | 6 | * it under the terms of the GNU General Public License as published by |
e7eb3a27 | 7 | * the Free Software Foundation, either version 3 of the License, or |
460b9539 | 8 | * (at your option) any later version. |
e7eb3a27 RK |
9 | * |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
460b9539 | 15 | * You should have received a copy of the GNU General Public License |
e7eb3a27 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
460b9539 | 17 | */ |
18 | ||
05b75f8d | 19 | #include "common.h" |
460b9539 | 20 | |
21 | #include <signal.h> | |
22 | #include <stddef.h> | |
23 | ||
24 | #include "table.h" | |
25 | #include "signame.h" | |
26 | ||
27 | static const struct sigtable { | |
28 | int signal; | |
29 | const char *name; | |
30 | } signals[] = { | |
31 | #define S(sig) { sig, #sig } | |
32 | /* table must be kept in lexical order */ | |
33 | #ifdef SIGABRT | |
34 | S(SIGABRT), | |
35 | #endif | |
36 | #ifdef SIGALRM | |
37 | S(SIGALRM), | |
38 | #endif | |
39 | #ifdef SIGBUS | |
40 | S(SIGBUS), | |
41 | #endif | |
42 | #ifdef SIGCHLD | |
43 | S(SIGCHLD), | |
44 | #endif | |
45 | #ifdef SIGCONT | |
46 | S(SIGCONT), | |
47 | #endif | |
48 | #ifdef SIGFPE | |
49 | S(SIGFPE), | |
50 | #endif | |
51 | #ifdef SIGHUP | |
52 | S(SIGHUP), | |
53 | #endif | |
54 | #ifdef SIGILL | |
55 | S(SIGILL), | |
56 | #endif | |
57 | #ifdef SIGINT | |
58 | S(SIGINT), | |
59 | #endif | |
60 | #ifdef SIGIO | |
61 | S(SIGIO), | |
62 | #endif | |
63 | #ifdef SIGIOT | |
64 | S(SIGIOT), | |
65 | #endif | |
66 | #ifdef SIGKILL | |
67 | S(SIGKILL), | |
68 | #endif | |
69 | #ifdef SIGPIPE | |
70 | S(SIGPIPE), | |
71 | #endif | |
72 | #ifdef SIGPOLL | |
73 | S(SIGPOLL), | |
74 | #endif | |
75 | #ifdef SIGPROF | |
76 | S(SIGPROF), | |
77 | #endif | |
78 | #ifdef SIGPWR | |
79 | S(SIGPWR), | |
80 | #endif | |
81 | #ifdef SIGQUIT | |
82 | S(SIGQUIT), | |
83 | #endif | |
84 | #ifdef SIGSEGV | |
85 | S(SIGSEGV), | |
86 | #endif | |
87 | #ifdef SIGSTKFLT | |
88 | S(SIGSTKFLT), | |
89 | #endif | |
90 | #ifdef SIGSTOP | |
91 | S(SIGSTOP), | |
92 | #endif | |
93 | #ifdef SIGSYS | |
94 | S(SIGSYS), | |
95 | #endif | |
96 | #ifdef SIGTERM | |
97 | S(SIGTERM), | |
98 | #endif | |
99 | #ifdef SIGTRAP | |
100 | S(SIGTRAP), | |
101 | #endif | |
102 | #ifdef SIGTSTP | |
103 | S(SIGTSTP), | |
104 | #endif | |
105 | #ifdef SIGTTIN | |
106 | S(SIGTTIN), | |
107 | #endif | |
108 | #ifdef SIGTTOU | |
109 | S(SIGTTOU), | |
110 | #endif | |
111 | #ifdef SIGURG | |
112 | S(SIGURG), | |
113 | #endif | |
114 | #ifdef SIGUSR1 | |
115 | S(SIGUSR1), | |
116 | #endif | |
117 | #ifdef SIGUSR2 | |
118 | S(SIGUSR2), | |
119 | #endif | |
120 | #ifdef SIGVTALRM | |
121 | S(SIGVTALRM), | |
122 | #endif | |
123 | #ifdef SIGWINCH | |
124 | S(SIGWINCH), | |
125 | #endif | |
126 | #ifdef SIGXCPU | |
127 | S(SIGXCPU), | |
128 | #endif | |
129 | #ifdef SIGXFSZ | |
130 | S(SIGXFSZ), | |
131 | #endif | |
132 | #undef S | |
133 | }; | |
134 | ||
135 | int find_signal(const char *s) { | |
136 | int n; | |
137 | ||
ba937f01 | 138 | if((n = TABLE_FIND(signals, name, s)) < 0) |
460b9539 | 139 | return -1; |
140 | return signals[n].signal; | |
141 | } | |
142 | ||
143 | /* | |
144 | Local Variables: | |
145 | c-basic-offset:2 | |
146 | comment-column:40 | |
147 | fill-column:79 | |
148 | indent-tabs-mode:nil | |
149 | End: | |
150 | */ |