source: trunk/minix/commands/ash/mksignames.c@ 22

Last change on this file since 22 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 5.2 KB
Line 
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
44static char sccsid[] = "@(#)mksignames.c 5.1 (Berkeley) 3/7/91";
45#endif /* not lint */
46
47/*
48 * This program generates the signames.h and signames.c files.
49 */
50#include <sys/types.h>
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#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 SIGVTALARM
135 SIGVTALARM, "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
144};
145
146
147#define MAXSIG 64
148
149
150char *sigmesg[MAXSIG + 1];
151
152
153char writer[] = "\
154/*\n\
155 * This file was generated by the mksignames program.\n\
156 */\n\
157\n";
158
159
160
161main(argc, argv) char **argv; {
162 FILE *cfile, *hfile;
163 struct sig *sigp;
164 int maxsig;
165 int i;
166
167 if ((cfile = fopen("signames.c", "w")) == NULL) {
168 fputs("Can't create signames.c\n", stderr);
169 exit(2);
170 }
171 if ((hfile = fopen("signames.h", "w")) == NULL) {
172 fputs("Can't create signames.h\n", stderr);
173 exit(2);
174 }
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;
182 }
183
184 fputs(writer, hfile);
185 fprintf(hfile, "#define MAXSIG %d\n\n", maxsig);
186 fprintf(hfile, "extern char *const sigmesg[MAXSIG+1];\n");
187
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]);
196 }
197 }
198 fprintf(cfile, "};\n");
199 exit(0);
200}
Note: See TracBrowser for help on using the repository browser.