Annotation of src/usr.bin/top/sigconv.awk, Revision 1.4
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.4 ! deraadt 28: BEGIN {
! 29: nsig = 0;
! 30: j = 0;
! 31: print "/* This file was automatically generated */"
! 32: print "/* by the awk script \"sigconv.awk\". */"
! 33: print "/* $OpenBSD: sigconv.awk,v 1.3 2002/07/15 17:20:36 deraadt Exp $ */\n"
! 34: print "struct sigdesc {"
! 35: print " char *name;"
! 36: print " int number;"
! 37: print "};\n"
! 38: print "struct sigdesc sigdesc[] = {"
! 39: }
1.1 downsj 40:
41: /^#define[ \t][ \t]*SIG[A-Z]/ {
42:
1.4 ! deraadt 43: j = sprintf("%d", $3);
! 44: str = $2;
! 45: if (nsig < j)
! 46: nsig = j;
! 47: siglist[j] = sprintf("\"%s\",\t%2d", substr(str, 4), j);
! 48: }
1.1 downsj 49:
50: /^#[ \t]*define[ \t][ \t]*SIG[A-Z]/ {
51:
1.4 ! deraadt 52: j = sprintf("%d", $4);
! 53: str = $3;
! 54: if (nsig < j)
! 55: nsig = j;
! 56: siglist[j] = sprintf("\"%s\",\t%2d", substr(str, 4), j);
! 57: }
1.1 downsj 58:
59: /^#[ \t]*define[ \t][ \t]*_SIG[A-Z]/ {
60:
1.4 ! deraadt 61: j = sprintf("%d", $4);
! 62: str = $3;
! 63: if (nsig < j)
! 64: nsig = j;
! 65:
! 66: siglist[j] = sprintf("\"%s\",\t%2d", substr(str, 5), j);
! 67: }
! 68:
! 69: END {
! 70: for (n = 1; n <= nsig; n++)
! 71: if (siglist[n] != "")
! 72: printf(" { %s },\n", siglist[n]);
1.1 downsj 73:
1.4 ! deraadt 74: printf(" { NULL,\t 0 }\n};\n");
! 75: }
1.1 downsj 76: