chiark / gitweb /
Some minor debianization fixes
[disorder] / lib / signame.c
... / ...
CommitLineData
1/*
2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005 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 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
21#include <config.h>
22#include "types.h"
23
24#include <signal.h>
25#include <stddef.h>
26
27#include "table.h"
28#include "signame.h"
29
30static const struct sigtable {
31 int signal;
32 const char *name;
33} signals[] = {
34#define S(sig) { sig, #sig }
35 /* table must be kept in lexical order */
36#ifdef SIGABRT
37 S(SIGABRT),
38#endif
39#ifdef SIGALRM
40 S(SIGALRM),
41#endif
42#ifdef SIGBUS
43 S(SIGBUS),
44#endif
45#ifdef SIGCHLD
46 S(SIGCHLD),
47#endif
48#ifdef SIGCONT
49 S(SIGCONT),
50#endif
51#ifdef SIGFPE
52 S(SIGFPE),
53#endif
54#ifdef SIGHUP
55 S(SIGHUP),
56#endif
57#ifdef SIGILL
58 S(SIGILL),
59#endif
60#ifdef SIGINT
61 S(SIGINT),
62#endif
63#ifdef SIGIO
64 S(SIGIO),
65#endif
66#ifdef SIGIOT
67 S(SIGIOT),
68#endif
69#ifdef SIGKILL
70 S(SIGKILL),
71#endif
72#ifdef SIGPIPE
73 S(SIGPIPE),
74#endif
75#ifdef SIGPOLL
76 S(SIGPOLL),
77#endif
78#ifdef SIGPROF
79 S(SIGPROF),
80#endif
81#ifdef SIGPWR
82 S(SIGPWR),
83#endif
84#ifdef SIGQUIT
85 S(SIGQUIT),
86#endif
87#ifdef SIGSEGV
88 S(SIGSEGV),
89#endif
90#ifdef SIGSTKFLT
91 S(SIGSTKFLT),
92#endif
93#ifdef SIGSTOP
94 S(SIGSTOP),
95#endif
96#ifdef SIGSYS
97 S(SIGSYS),
98#endif
99#ifdef SIGTERM
100 S(SIGTERM),
101#endif
102#ifdef SIGTRAP
103 S(SIGTRAP),
104#endif
105#ifdef SIGTSTP
106 S(SIGTSTP),
107#endif
108#ifdef SIGTTIN
109 S(SIGTTIN),
110#endif
111#ifdef SIGTTOU
112 S(SIGTTOU),
113#endif
114#ifdef SIGURG
115 S(SIGURG),
116#endif
117#ifdef SIGUSR1
118 S(SIGUSR1),
119#endif
120#ifdef SIGUSR2
121 S(SIGUSR2),
122#endif
123#ifdef SIGVTALRM
124 S(SIGVTALRM),
125#endif
126#ifdef SIGWINCH
127 S(SIGWINCH),
128#endif
129#ifdef SIGXCPU
130 S(SIGXCPU),
131#endif
132#ifdef SIGXFSZ
133 S(SIGXFSZ),
134#endif
135#undef S
136};
137
138int find_signal(const char *s) {
139 int n;
140
141 if((n = TABLE_FIND(signals, struct sigtable, name, s)) < 0)
142 return -1;
143 return signals[n].signal;
144}
145
146/*
147Local Variables:
148c-basic-offset:2
149comment-column:40
150fill-column:79
151indent-tabs-mode:nil
152End:
153*/