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