- simplify findhole() for use for 1 page only
[minix.git] / commands / ash / mksignames.c
blobb7878613328c5c4bf9c286f637b8c2e56d7fed7a
1 /*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
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.
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.
37 #ifndef lint
38 static char copyright[] =
39 "@(#) Copyright (c) 1991, 1993\n\
40 The Regents of the University of California. All rights reserved.\n";
41 #endif /* not lint */
43 #ifndef lint
44 static char sccsid[] = "@(#)mksignames.c 8.1 (Berkeley) 5/31/93";
45 #endif /* not lint */
48 * This program generates the signames.h and signames.c files.
50 #include <stdio.h>
51 #include <stdlib.h>
52 #include <signal.h>
54 int main(int argc, char *argv[]);
56 struct sig {
57 int signo; /* signal number */
58 char *name; /* signal name (without leading "SIG") */
59 char *mesg; /* description */
63 struct 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 #ifdef SIGSYS
83 SIGSYS, "SYS", "Bad system call",
84 #endif
85 SIGPIPE, "PIPE", "Broken pipe", /* normally don't print message */
86 SIGALRM, "ALRM", "Alarm call",
87 SIGTERM, "TERM", "Terminated",
88 #ifdef SIGUSR1
89 SIGUSR1, "USR1", "User signal 1",
90 #endif
91 #ifdef SIGUSR2
92 SIGUSR2, "USR2", "User signal 2",
93 #endif
94 #ifdef SIGCLD
95 SIGCLD, "CLD", NULL,
96 #endif
97 #if defined(SIGCHLD) && ! defined(SIGCLD)
98 SIGCHLD, "CLD", NULL,
99 #endif
100 #ifdef SIGPWR
101 SIGPWR, "PWR", "Power fail",
102 #endif
103 #ifdef SIGPOLL
104 SIGPOLL, "POLL", "Poll",
105 #endif
106 /* Now for the BSD signals */
107 #ifdef SIGURG
108 SIGURG, "URG", NULL,
109 #endif
110 #ifdef SIGSTOP
111 SIGSTOP, "STOP", "Stopped",
112 #endif
113 #ifdef SIGTSTP
114 SIGTSTP, "TSTP", "Stopped",
115 #endif
116 #ifdef SIGCONT
117 SIGCONT, "CONT", NULL,
118 #endif
119 #ifdef SIGTTIN
120 SIGTTIN, "TTIN", "Stopped (input)",
121 #endif
122 #ifdef SIGTTOU
123 SIGTTOU, "TTOU", "Stopped (output)",
124 #endif
125 #ifdef SIGIO
126 SIGIO, "IO", NULL,
127 #endif
128 #ifdef SIGXCPU
129 SIGXCPU, "XCPU", "Time limit exceeded",
130 #endif
131 #ifdef SIGXFSZ
132 SIGXFSZ, "XFSZ", NULL,
133 #endif
134 #ifdef SIGVTALRM
135 SIGVTALRM, "VTALARM", "Virtual alarm",
136 #endif
137 #ifdef SIGPROF
138 SIGPROF, "PROF", "Profiling alarm",
139 #endif
140 #ifdef SIGWINCH
141 SIGWINCH, "WINCH", NULL,
142 #endif
143 0, NULL, NULL
147 #define MAXSIG 64
150 char *sigmesg[MAXSIG + 1];
153 char writer[] = "\
154 /*\n\
155 * This file was generated by the mksignames program.\n\
156 */\n\
157 \n";
161 main(argc, argv) char **argv; {
162 FILE *cfile, *hfile;
163 struct sig *sigp;
164 int maxsig;
165 int i;
167 if ((cfile = fopen("signames.c", "w")) == NULL) {
168 fputs("Can't create signames.c\n", stderr);
169 exit(2);
171 if ((hfile = fopen("signames.h", "w")) == NULL) {
172 fputs("Can't create signames.h\n", stderr);
173 exit(2);
175 maxsig = 0;
176 for (sigp = sigtab ; sigp->signo != 0 ; sigp++) {
177 if (sigp->signo < 0 || sigp->signo > MAXSIG)
178 continue;
179 sigmesg[sigp->signo] = sigp->mesg;
180 if (maxsig < sigp->signo)
181 maxsig = sigp->signo;
184 fputs(writer, hfile);
185 fprintf(hfile, "#define MAXSIG %d\n\n", maxsig);
186 fprintf(hfile, "extern char *const sigmesg[MAXSIG+1];\n");
188 fputs(writer, cfile);
189 fprintf(cfile, "#include \"shell.h\"\n\n");
190 fprintf(cfile, "char *const sigmesg[%d] = {\n", maxsig + 1);
191 for (i = 0 ; i <= maxsig ; i++) {
192 if (sigmesg[i] == NULL) {
193 fprintf(cfile, " 0,\n");
194 } else {
195 fprintf(cfile, " \"%s\",\n", sigmesg[i]);
198 fprintf(cfile, "};\n");
199 exit(0);
203 * $PchId: mksignames.c,v 1.2 2001/05/14 19:22:26 philip Exp $