This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.0'.
[unix-history] / bin / sh / mksignames.c
CommitLineData
15637ed4
RG
1/*-
2 * Copyright (c) 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
38char copyright[] =
39"@(#) Copyright (c) 1991 The Regents of the University of California.\n\
40 All rights reserved.\n";
41#endif /* not lint */
42
43#ifndef lint
78ed81a3 44/*static char sccsid[] = "from: @(#)mksignames.c 5.1 (Berkeley) 3/7/91";*/
45static char rcsid[] = "mksignames.c,v 1.4 1993/08/01 18:58:07 mycroft Exp";
15637ed4
RG
46#endif /* not lint */
47
48/*
49 * This program generates the signames.h and signames.c files.
50 */
51#include <stdio.h>
52#include <signal.h>
53
54
55
56struct sig {
57 int signo; /* signal number */
58 char *name; /* signal name (without leading "SIG") */
59 char *mesg; /* description */
60};
61
62
63struct sig sigtab[] = {
64 SIGHUP, "HUP", "Hangup",
65 SIGINT, "INT", "Interrupt", /* normally don't print message */
66 SIGQUIT, "QUIT", "Quit",
67 SIGILL, "ILL", "Illegal instruction",
68 SIGTRAP, "TRAP", "Trace/BPT trap",
69#ifdef SIGABRT
70 SIGABRT, "ABRT", "abort",
71#endif
72#if defined(SIGIOT) && (! defined(SIGABRT) || SIGABRT != SIGIOT)
73 SIGIOT, "IOT", "abort",
74#endif
75#ifdef SIGEMT
76 SIGEMT, "EMT", "EMT trap",
77#endif
78 SIGFPE, "FPE", "Floating exception",
79 SIGKILL, "KILL", "Killed",
80 SIGBUS, "BUS", "Bus error",
81 SIGSEGV, "SEGV", "Memory fault",
82 SIGSYS, "SYS", "Bad system call",
83 SIGPIPE, "PIPE", "Broken pipe", /* normally don't print message */
84 SIGALRM, "ALRM", "Alarm call",
85 SIGTERM, "TERM", "Terminated",
86#ifdef SIGUSR1
87 SIGUSR1, "USR1", "User signal 1",
88#endif
89#ifdef SIGUSR2
90 SIGUSR2, "USR2", "User signal 2",
91#endif
92#ifdef SIGCLD
93 SIGCLD, "CLD", NULL,
94#endif
95#if defined(SIGCHLD) && ! defined(SIGCLD)
96 SIGCHLD, "CLD", NULL,
97#endif
98#ifdef SIGPWR
99 SIGPWR, "PWR", "Power fail",
100#endif
101#ifdef SIGPOLL
102 SIGPOLL, "POLL", "Poll",
103#endif
104 /* Now for the BSD signals */
105#ifdef SIGURG
106 SIGURG, "URG", NULL,
107#endif
108#ifdef SIGSTOP
109 SIGSTOP, "STOP", "Stopped",
110#endif
111#ifdef SIGTSTP
112 SIGTSTP, "TSTP", "Stopped",
113#endif
114#ifdef SIGCONT
115 SIGCONT, "CONT", NULL,
116#endif
117#ifdef SIGTTIN
118 SIGTTIN, "TTIN", "Stopped (input)",
119#endif
120#ifdef SIGTTOU
121 SIGTTOU, "TTOU", "Stopped (output)",
122#endif
123#ifdef SIGIO
124 SIGIO, "IO", NULL,
125#endif
126#ifdef SIGXCPU
127 SIGXCPU, "XCPU", "Time limit exceeded",
128#endif
129#ifdef SIGXFSZ
130 SIGXFSZ, "XFSZ", NULL,
131#endif
132#ifdef SIGVTALARM
133 SIGVTALARM, "VTALARM", "Virtual alarm",
134#endif
135#ifdef SIGPROF
136 SIGPROF, "PROF", "Profiling alarm",
137#endif
138#ifdef SIGWINCH
139 SIGWINCH, "WINCH", NULL,
140#endif
141 0, NULL, NULL
142};
143
144
145#define MAXSIG 64
146
147
148char *sigmesg[MAXSIG + 1];
149
150
151char writer[] = "\
152/*\n\
153 * This file was generated by the mksignames program.\n\
154 */\n\
155\n";
156
157
158
159main(argc, argv) char **argv; {
160 FILE *cfile, *hfile;
161 struct sig *sigp;
162 int maxsig;
163 int i;
164
165 if ((cfile = fopen("signames.c", "w")) == NULL) {
166 fputs("Can't create signames.c\n", stderr);
167 exit(2);
168 }
169 if ((hfile = fopen("signames.h", "w")) == NULL) {
170 fputs("Can't create signames.h\n", stderr);
171 exit(2);
172 }
173 maxsig = 0;
174 for (sigp = sigtab ; sigp->signo != 0 ; sigp++) {
175 if (sigp->signo < 0 || sigp->signo > MAXSIG)
176 continue;
177 sigmesg[sigp->signo] = sigp->mesg;
178 if (maxsig < sigp->signo)
179 maxsig = sigp->signo;
180 }
181
182 fputs(writer, hfile);
183 fprintf(hfile, "#define MAXSIG %d\n\n", maxsig);
184 fprintf(hfile, "extern char *const sigmesg[MAXSIG+1];\n");
185
186 fputs(writer, cfile);
187 fprintf(cfile, "#include \"shell.h\"\n\n");
188 fprintf(cfile, "char *const sigmesg[%d] = {\n", maxsig + 1);
189 for (i = 0 ; i <= maxsig ; i++) {
190 if (sigmesg[i] == NULL) {
191 fprintf(cfile, " 0,\n");
192 } else {
193 fprintf(cfile, " \"%s\",\n", sigmesg[i]);
194 }
195 }
196 fprintf(cfile, "};\n");
197 exit(0);
198}