chiark / gitweb /
Trivial resampler fixes
[disorder] / lib / signame.c
CommitLineData
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 */
132a5a4a
RK
18/** @file lib/signame.c
19 * @brief Signal names
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
29static 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
132a5a4a
RK
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 */
460b9539 141int find_signal(const char *s) {
142 int n;
143
ba937f01 144 if((n = TABLE_FIND(signals, name, s)) < 0)
460b9539 145 return -1;
146 return signals[n].signal;
147}
148
149/*
150Local Variables:
151c-basic-offset:2
152comment-column:40
153fill-column:79
154indent-tabs-mode:nil
155End:
156*/