2006-10-10 14:15:34 +00:00
|
|
|
/* mksignames.c -- Create and write `signames.h', which contains an array of
|
1996-08-26 18:22:31 +00:00
|
|
|
signal names. */
|
|
|
|
|
|
2006-10-10 14:15:34 +00:00
|
|
|
/* Copyright (C) 1992-2006 Free Software Foundation, Inc.
|
1996-08-26 18:22:31 +00:00
|
|
|
|
|
|
|
|
This file is part of GNU Bash, the Bourne Again SHell.
|
|
|
|
|
|
|
|
|
|
Bash is free software; you can redistribute it and/or modify it under
|
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
2000-03-17 21:46:59 +00:00
|
|
|
Software Foundation; either version 2, or (at your option) any later
|
1996-08-26 18:22:31 +00:00
|
|
|
version.
|
|
|
|
|
|
|
|
|
|
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
|
with Bash; see the file COPYING. If not, write to the Free Software
|
2000-03-17 21:46:59 +00:00
|
|
|
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
1996-08-26 18:22:31 +00:00
|
|
|
|
2002-07-17 14:10:11 +00:00
|
|
|
#include <config.h>
|
2001-11-13 17:56:06 +00:00
|
|
|
|
1996-08-26 18:22:31 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <signal.h>
|
2006-10-10 14:15:34 +00:00
|
|
|
|
|
|
|
|
#include <stdio.h>
|
1996-08-26 18:22:31 +00:00
|
|
|
#if defined (HAVE_STDLIB_H)
|
|
|
|
|
# include <stdlib.h>
|
|
|
|
|
#else
|
|
|
|
|
# include "ansi_stdlib.h"
|
|
|
|
|
#endif /* HAVE_STDLIB_H */
|
|
|
|
|
|
2006-10-10 14:15:34 +00:00
|
|
|
/* Duplicated from signames.c */
|
1996-08-26 18:22:31 +00:00
|
|
|
#if !defined (NSIG)
|
|
|
|
|
# define NSIG 64
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-07-27 13:29:18 +00:00
|
|
|
#define LASTSIG NSIG+2
|
2001-11-13 17:56:06 +00:00
|
|
|
|
2006-10-10 14:15:34 +00:00
|
|
|
/* Imported from signames.c */
|
|
|
|
|
extern void initialize_signames ();
|
|
|
|
|
extern char *signal_names[];
|
2001-04-06 19:14:31 +00:00
|
|
|
|
1996-08-26 18:22:31 +00:00
|
|
|
char *progname;
|
|
|
|
|
|
1996-12-23 17:02:34 +00:00
|
|
|
void
|
1996-08-26 18:22:31 +00:00
|
|
|
write_signames (stream)
|
|
|
|
|
FILE *stream;
|
|
|
|
|
{
|
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
|
|
fprintf (stream, "/* This file was automatically created by %s.\n",
|
|
|
|
|
progname);
|
2006-10-10 14:15:34 +00:00
|
|
|
fprintf (stream, " Do not edit. Edit support/signames.c instead. */\n\n");
|
1996-08-26 18:22:31 +00:00
|
|
|
fprintf (stream,
|
|
|
|
|
"/* A translation list so we can be polite to our users. */\n");
|
2006-10-10 14:15:34 +00:00
|
|
|
#if defined (CROSS_COMPILING)
|
|
|
|
|
fprintf (stream, "extern char *signal_names[];\n\n");
|
|
|
|
|
fprintf (stream, "extern void initialize_signames __P((void));\n\n");
|
|
|
|
|
#else
|
2004-07-27 13:29:18 +00:00
|
|
|
fprintf (stream, "char *signal_names[NSIG + 4] = {\n");
|
1996-08-26 18:22:31 +00:00
|
|
|
|
2001-11-13 17:56:06 +00:00
|
|
|
for (i = 0; i <= LASTSIG; i++)
|
1996-08-26 18:22:31 +00:00
|
|
|
fprintf (stream, " \"%s\",\n", signal_names[i]);
|
|
|
|
|
|
2001-11-13 17:56:06 +00:00
|
|
|
fprintf (stream, " (char *)0x0\n");
|
2006-10-10 14:15:34 +00:00
|
|
|
fprintf (stream, "};\n\n");
|
|
|
|
|
fprintf (stream, "#define initialize_signames()\n\n");
|
|
|
|
|
#endif
|
1996-08-26 18:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
1996-12-23 17:02:34 +00:00
|
|
|
int
|
1996-08-26 18:22:31 +00:00
|
|
|
main (argc, argv)
|
|
|
|
|
int argc;
|
|
|
|
|
char **argv;
|
|
|
|
|
{
|
|
|
|
|
char *stream_name;
|
|
|
|
|
FILE *stream;
|
|
|
|
|
|
|
|
|
|
progname = argv[0];
|
|
|
|
|
|
|
|
|
|
if (argc == 1)
|
|
|
|
|
{
|
|
|
|
|
stream_name = "stdout";
|
|
|
|
|
stream = stdout;
|
|
|
|
|
}
|
|
|
|
|
else if (argc == 2)
|
|
|
|
|
{
|
|
|
|
|
stream_name = argv[1];
|
|
|
|
|
stream = fopen (stream_name, "w");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Usage: %s [output-file]\n", progname);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!stream)
|
|
|
|
|
{
|
1996-12-23 17:02:34 +00:00
|
|
|
fprintf (stderr, "%s: %s: cannot open for writing\n",
|
1996-08-26 18:22:31 +00:00
|
|
|
progname, stream_name);
|
|
|
|
|
exit (2);
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-10 14:15:34 +00:00
|
|
|
#if !defined (CROSS_COMPILING)
|
1996-08-26 18:22:31 +00:00
|
|
|
initialize_signames ();
|
2006-10-10 14:15:34 +00:00
|
|
|
#endif
|
1996-08-26 18:22:31 +00:00
|
|
|
write_signames (stream);
|
|
|
|
|
exit (0);
|
|
|
|
|
}
|