chiark / gitweb /
Don't attempt to set the database version if TRACKDB_READ_ONLY.
[disorder] / lib / signame.c
1 /*
2  * This file is part of DisOrder.
3  * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
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 3 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,
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  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 /** @file lib/signame.c
19  * @brief Signal names
20  */
21 #include "common.h"
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 /** @brief Map a signal name to its number
138  * @param s Signal name e.g. "SIGINT"
139  * @return Signal value or -1 if not found
140  */
141 int find_signal(const char *s) {
142   int n;
143
144   if((n = TABLE_FIND(signals, name, s)) < 0)
145     return -1;
146   return signals[n].signal;
147 }
148
149 /*
150 Local Variables:
151 c-basic-offset:2
152 comment-column:40
153 fill-column:79
154 indent-tabs-mode:nil
155 End:
156 */