summaryrefslogtreecommitdiff
path: root/mcon/U/sig_name.U
diff options
context:
space:
mode:
authorrmanfredi <rmanfredi@190e5f8e-a817-0410-acf6-e9863daed9af>2006-08-24 12:32:52 +0000
committerrmanfredi <rmanfredi@190e5f8e-a817-0410-acf6-e9863daed9af>2006-08-24 12:32:52 +0000
commit8bfc5756fb68e0b13d7e7c0073ad5b9a4790d1b6 (patch)
treedee05e98bc53766d609ef2a3a07a5672627d812c /mcon/U/sig_name.U
Moving project to sourceforge.
git-svn-id: https://dist.svn.sourceforge.net/svnroot/dist/trunk/dist@1 190e5f8e-a817-0410-acf6-e9863daed9af
Diffstat (limited to 'mcon/U/sig_name.U')
-rw-r--r--mcon/U/sig_name.U157
1 files changed, 157 insertions, 0 deletions
diff --git a/mcon/U/sig_name.U b/mcon/U/sig_name.U
new file mode 100644
index 0000000..b18e30b
--- /dev/null
+++ b/mcon/U/sig_name.U
@@ -0,0 +1,157 @@
+?RCS: $Id$
+?RCS:
+?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
+?RCS:
+?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic Licence; a copy of which may be found at the root
+?RCS: of the source tree for dist 4.0.
+?RCS:
+?RCS: $Log: sig_name.U,v $
+?RCS: Revision 3.0.1.5 1997/02/28 16:21:25 ram
+?RCS: patch61: brand new algorithm for sig_name and (new!) sig_num
+?RCS:
+?RCS: Revision 3.0.1.4 1995/07/25 14:14:54 ram
+?RCS: patch56: added <asm/signal.h> lookup for linux
+?RCS:
+?RCS: Revision 3.0.1.3 1995/05/12 12:24:11 ram
+?RCS: patch54: now looks for <linux/signal.h> too (ADO)
+?RCS:
+?RCS: Revision 3.0.1.2 1994/06/20 07:06:57 ram
+?RCS: patch30: final echo was missing to close awk-printed string
+?RCS:
+?RCS: Revision 3.0.1.1 1994/05/06 15:17:55 ram
+?RCS: patch23: signal list now formatted to avoid scroll-ups (ADO)
+?RCS:
+?RCS: Revision 3.0 1993/08/18 12:09:47 ram
+?RCS: Baseline for dist 3.0 netwide release.
+?RCS:
+?MAKE:sig_name sig_name_init sig_num sig_num_init sig_count sig_size: \
+ awk Signal Oldconfig rm
+?MAKE: -pick add $@ %<
+?S:sig_name:
+?S: This variable holds the signal names, space separated. The leading
+?S: SIG in signal name is removed. A ZERO is prepended to the
+?S: list. This is currently not used.
+?S:.
+?S:sig_name_init:
+?S: This variable holds the signal names, enclosed in double quotes and
+?S: separated by commas, suitable for use in the SIG_NAME definition
+?S: below. A "ZERO" is prepended to the list, and the list is
+?S: terminated with a plain 0. The leading SIG in signal names
+?S: is removed. See sig_num.
+?S:.
+?S:sig_num:
+?S: This variable holds the signal numbers, space separated. A ZERO is
+?S: prepended to the list (corresponding to the fake SIGZERO), and
+?S: the list is terminated with a 0. Those numbers correspond to
+?S: the value of the signal listed in the same place within the
+?S: sig_name list.
+?S:.
+?S:sig_num_init:
+?S: This variable holds the signal numbers, enclosed in double quotes and
+?S: separated by commas, suitable for use in the SIG_NUM definition
+?S: below. A "ZERO" is prepended to the list, and the list is
+?S: terminated with a plain 0.
+?S:.
+?S:sig_count (sig_name.U):
+?S: This variable holds a number larger than the largest valid
+?S: signal number. This is usually the same as the NSIG macro.
+?S:.
+?S:sig_size:
+?S: This variable contains the number of elements of the sig_name
+?S: and sig_num arrays, excluding the final NULL entry.
+?S:.
+?C:SIG_NAME:
+?C: This symbol contains a list of signal names in order of
+?C: signal number. This is intended
+?C: to be used as a static array initialization, like this:
+?C: char *sig_name[] = { SIG_NAME };
+?C: The signals in the list are separated with commas, and each signal
+?C: is surrounded by double quotes. There is no leading SIG in the signal
+?C: name, i.e. SIGQUIT is known as "QUIT".
+?C: Gaps in the signal numbers (up to NSIG) are filled in with NUMnn,
+?C: etc., where nn is the actual signal number (e.g. NUM37).
+?C: The signal number for sig_name[i] is stored in sig_num[i].
+?C: The last element is 0 to terminate the list with a NULL. This
+?C: corresponds to the 0 at the end of the sig_num list.
+?C:.
+?C:SIG_NUM:
+?C: This symbol contains a list of signal numbers, in the same order as the
+?C: SIG_NAME list. It is suitable for static array initialization, as in:
+?C: int sig_num[] = { SIG_NUM };
+?C: The signals in the list are separated with commas, and the indices
+?C: within that list and the SIG_NAME list match, so it's easy to compute
+?C: the signal name from a number or vice versa at the price of a small
+?C: dynamic linear lookup.
+?C: Duplicates are allowed, but are moved to the end of the list.
+?C: The signal number corresponding to sig_name[i] is sig_number[i].
+?C: if (i < NSIG) then sig_number[i] == i.
+?C: The last element is 0, corresponding to the 0 at the end of
+?C: the sig_name list.
+?C:.
+?C:SIG_COUNT:
+?C: This variable contains a number larger than the largest
+?C: signal number. This is usually the same as the NSIG macro.
+?C:.
+?C:SIG_SIZE:
+?C: This variable contains the number of elements of the sig_name
+?C: and sig_num arrays, excluding the final NULL entry.
+?C:.
+?H:#define SIG_NAME $sig_name_init /**/
+?H:#define SIG_NUM $sig_num_init /**/
+?H:#define SIG_COUNT $sig_count /**/
+?H:#define SIG_SIZE $sig_size /**/
+?H:.
+?T:i doinit
+?F:!= !signal_cmd
+?X: signal.cmd creates a file signal.lst which has two columns:
+?X: NAME number, e.g.
+?X: HUP 1
+?X: The list is sorted on signal number, with duplicates moved to
+?X: the end..
+: generate list of signal names
+echo " "
+case "$sig_name_init" in
+'') doinit=yes ;;
+*) case "$sig_num_init" in
+ ''|*,*) doinit=yes ;;
+ esac ;;
+esac
+case "$doinit" in
+yes)
+ echo "Generating a list of signal names and numbers..." >&4
+ . ./signal_cmd
+ sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
+ sig_name=`$awk 'BEGIN { printf "ZERO " }
+ !/^NSIG/ { printf "%s ", $1 }' signal.lst`
+ sig_num=`$awk 'BEGIN { printf "0 " }
+ !/^NSIG/ { printf "%d ", $2 }' signal.lst`
+ sig_name_init=`$awk 'BEGIN { printf "\"ZERO\", " }
+ !/^NSIG/ { printf "\"%s\", ", $1 }
+ END { printf "0\n" }' signal.lst`
+ sig_num_init=`$awk 'BEGIN { printf "0, " }
+ !/^NSIG/ { printf "%d, ", $2}
+ END { printf "0\n"}' signal.lst`
+ ;;
+esac
+echo "The following $sig_count signals are available:"
+echo " "
+echo $sig_name | $awk \
+'BEGIN { linelen = 0 }
+{
+ for (i = 1; i <= NF; i++) {
+ name = "SIG" $i " "
+ linelen = linelen + length(name)
+ if (linelen > 70) {
+ printf "\n"
+ linelen = length(name)
+ }
+ printf "%s", name
+ }
+ printf "\n"
+}'
+sig_size=`echo $sig_name | awk '{print NF}'`
+$rm -f signal signal.c signal.awk signal.lst signal_cmd
+