Annotation of src/usr.bin/top/sigconv.awk, Revision 1.3
1.3 ! deraadt 1: #
! 2: # Top users/processes display for Unix
! 3: # Version 3
! 4: #
! 5: # Copyright (c) 1984, 1989, William LeFebvre, Rice University
! 6: # Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University
! 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: #
! 17: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 18: # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 19: # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 20: # IN NO EVENT SHALL THE AUTHOR OR HIS EMPLOYER BE LIABLE FOR ANY DIRECT, INDIRECT,
! 21: # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 22: # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 23: # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 24: # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 25: # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 26: # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 27:
1.1 downsj 28: BEGIN {
29: nsig = 0;
30: j = 0;
31: print "/* This file was automatically generated */"
1.2 downsj 32: print "/* by the awk script \"sigconv.awk\". */"
1.3 ! deraadt 33: print "/* $OpenBSD: sigconv.awk,v 1.2 1997/08/17 01:02:00 downsj Exp $ */\n"
1.1 downsj 34: print "struct sigdesc {"
35: print " char *name;"
36: print " int number;"
37: print "};\n"
38: print "struct sigdesc sigdesc[] = {"
39: }
40:
41: /^#define[ \t][ \t]*SIG[A-Z]/ {
42:
43: j = sprintf("%d", $3);
44: str = $2;
45:
46: if (nsig < j)
47: nsig = j;
48:
1.2 downsj 49: siglist[j] = sprintf("\"%s\",\t%2d", \
1.1 downsj 50: substr(str, 4), j);
51: }
52: /^#[ \t]*define[ \t][ \t]*SIG[A-Z]/ {
53:
54: j = sprintf("%d", $4);
55: str = $3;
56:
57: if (nsig < j)
58: nsig = j;
59:
1.2 downsj 60: siglist[j] = sprintf("\"%s\",\t%2d", \
1.1 downsj 61: substr(str, 4), j);
62: }
63: /^#[ \t]*define[ \t][ \t]*_SIG[A-Z]/ {
64:
65: j = sprintf("%d", $4);
66: str = $3;
67:
68: if (nsig < j)
69: nsig = j;
70:
1.2 downsj 71: siglist[j] = sprintf("\"%s\",\t%2d", \
1.1 downsj 72: substr(str, 5), j);
73: }
74:
75: END {
76: for (n = 1; n <= nsig; n++)
77: if (siglist[n] != "")
1.2 downsj 78: printf(" { %s },\n", siglist[n]);
1.1 downsj 79:
1.2 downsj 80: printf(" { NULL,\t 0 }\n};\n");
1.1 downsj 81: }