Bash
5.0-beta2
Bash - Bourne Again shell
mksignames.c
Go to the documentation of this file.
1
/* mksignames.c -- Create and write `signames.h', which contains an array of
2
signal names. */
3
4
/* Copyright (C) 1992-2006 Free Software Foundation, Inc.
5
6
This file is part of GNU Bash, the Bourne Again SHell.
7
8
Bash is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
12
13
Bash is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with Bash. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#include <config.h>
23
24
#include <sys/types.h>
25
#include <signal.h>
26
27
#include <stdio.h>
28
#if defined (HAVE_STDLIB_H)
29
# include <stdlib.h>
30
#else
31
# include "ansi_stdlib.h"
32
#endif
/* HAVE_STDLIB_H */
33
34
/* Duplicated from signames.c */
35
#if !defined (NSIG)
36
# define NSIG 64
37
#endif
38
39
#define LASTSIG NSIG+2
40
41
/* Imported from signames.c */
42
extern
void
initialize_signames
();
43
extern
char
*
signal_names
[];
44
45
char
*
progname
;
46
47
void
48
write_signames
(stream)
49
FILE *stream;
50
{
51
register
int
i
;
52
53
fprintf (stream,
"/* This file was automatically created by %s.\n"
,
54
progname
);
55
fprintf (stream,
" Do not edit. Edit support/mksignames.c instead. */\n\n"
);
56
fprintf (stream,
57
"/* A translation list so we can be polite to our users. */\n"
);
58
#if defined (CROSS_COMPILING)
59
fprintf (stream,
"extern char *signal_names[];\n\n"
);
60
fprintf (stream,
"extern void initialize_signames __P((void));\n\n"
);
61
#else
62
fprintf (stream,
"char *signal_names[NSIG + 4] = {\n"
);
63
64
for
(i = 0; i <=
LASTSIG
; i++)
65
fprintf (stream,
" \"%s\",\n"
,
signal_names
[i]);
66
67
fprintf (stream,
" (char *)0x0\n"
);
68
fprintf (stream,
"};\n\n"
);
69
fprintf (stream,
"#define initialize_signames()\n\n"
);
70
#endif
71
}
72
73
int
74
main
(
argc
,
argv
)
75
int
argc
;
76
char
**
argv
;
77
{
78
char
*stream_name;
79
FILE *stream;
80
81
progname
=
argv
[0];
82
83
if
(
argc
== 1)
84
{
85
stream_name =
"stdout"
;
86
stream = stdout;
87
}
88
else
if
(
argc
== 2)
89
{
90
stream_name =
argv
[1];
91
stream = fopen (stream_name,
"w"
);
92
}
93
else
94
{
95
fprintf (stderr,
"Usage: %s [output-file]\n"
,
progname
);
96
exit
(1);
97
}
98
99
if
(!stream)
100
{
101
fprintf (stderr,
"%s: %s: cannot open for writing\n"
,
102
progname
, stream_name);
103
exit
(2);
104
}
105
106
#if !defined (CROSS_COMPILING)
107
initialize_signames
();
108
#endif
109
write_signames
(stream);
110
exit
(0);
111
}
argv
static char ** argv
Definition:
test.c:110
signal_names
char * signal_names[]
Definition:
signames.c:47
progname
char * progname
Definition:
mksignames.c:45
i
static nls_uint32 nls_uint32 i
Definition:
gettextP.h:74
LASTSIG
#define LASTSIG
Definition:
mksignames.c:39
initialize_signames
void initialize_signames()
Definition:
signames.c:70
exit
void exit()
argc
static int argc
Definition:
test.c:109
write_signames
void write_signames(FILE *stream)
Definition:
mksignames.c:48
main
int main(int argc, char **argv)
Definition:
mksignames.c:74
bash-5.0-beta2
support
mksignames.c
Generated on Sat Dec 1 2018 00:27:28 for Bash by
1.8.13