1 | # |
---|
2 | # sigmsg.awk -- awk/nawk/gawk script to generate sigmsg.h |
---|
3 | # |
---|
4 | # provided by Geoff Wing <mason@werple.apana.org.au> |
---|
5 | # |
---|
6 | # $Id: sigmsg.awk,v 1.1.1.1 1999-02-07 18:14:11 danw Exp $ |
---|
7 | # |
---|
8 | # On SunOS 4.1.3 - user-functions don't work properly, also \" problems |
---|
9 | # Without 0 + hacks some nawks compare numbers as strings |
---|
10 | # |
---|
11 | /^[\t ]*#[\t ]*define[\t _]*SIG[A-Z][A-Z0-9]*[\t ]*[1-9][0-9]*/ { |
---|
12 | sigindex = index($0, "SIG") |
---|
13 | sigtail = substr($0, sigindex, 80) |
---|
14 | split(sigtail, tmp) |
---|
15 | signam = substr(tmp[1], 4, 20) |
---|
16 | signum = tmp[2] |
---|
17 | if (sig[signum] == "") { |
---|
18 | sig[signum] = signam |
---|
19 | if (0 + max < 0 + signum && signum < 60) |
---|
20 | max = signum |
---|
21 | if (signam == "ABRT") { msg[signum] = "abort" } |
---|
22 | if (signam == "ALRM") { msg[signum] = "alarm" } |
---|
23 | if (signam == "BUS") { msg[signum] = "bus error" } |
---|
24 | if (signam == "CHLD") { msg[signum] = "death of child" } |
---|
25 | if (signam == "CLD") { msg[signum] = "death of child" } |
---|
26 | if (signam == "CONT") { msg[signum] = "continued" } |
---|
27 | if (signam == "EMT") { msg[signum] = "EMT instruction" } |
---|
28 | if (signam == "FPE") { msg[signum] = "floating point exception" } |
---|
29 | if (signam == "HUP") { msg[signum] = "hangup" } |
---|
30 | if (signam == "ILL") { msg[signum] = "illegal hardware instruction" } |
---|
31 | if (signam == "INFO") { msg[signum] = "status request from keyboard" } |
---|
32 | if (signam == "INT") { msg[signum] = "interrupt" } |
---|
33 | if (signam == "IO") { msg[signum] = "i/o ready" } |
---|
34 | if (signam == "IOT") { msg[signum] = "IOT instruction" } |
---|
35 | if (signam == "KILL") { msg[signum] = "killed" } |
---|
36 | if (signam == "LOST") { msg[signum] = "resource lost" } |
---|
37 | if (signam == "PIPE") { msg[signum] = "broken pipe" } |
---|
38 | if (signam == "POLL") { msg[signum] = "pollable event occurred" } |
---|
39 | if (signam == "PROF") { msg[signum] = "profile signal" } |
---|
40 | if (signam == "PWR") { msg[signum] = "power fail" } |
---|
41 | if (signam == "QUIT") { msg[signum] = "quit" } |
---|
42 | if (signam == "SEGV") { msg[signum] = "segmentation fault" } |
---|
43 | if (signam == "SYS") { msg[signum] = "invalid system call" } |
---|
44 | if (signam == "TERM") { msg[signum] = "terminated" } |
---|
45 | if (signam == "TRAP") { msg[signum] = "trace trap" } |
---|
46 | if (signam == "URG") { msg[signum] = "urgent condition" } |
---|
47 | if (signam == "USR1") { msg[signum] = "user-defined signal 1" } |
---|
48 | if (signam == "USR2") { msg[signum] = "user-defined signal 2" } |
---|
49 | if (signam == "VTALRM") { msg[signum] = "virtual time alarm" } |
---|
50 | if (signam == "WINCH") { msg[signum] = "window size changed" } |
---|
51 | if (signam == "XCPU") { msg[signum] = "cpu limit exceeded" } |
---|
52 | if (signam == "XFSZ") { msg[signum] = "file size limit exceeded" } |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | END { |
---|
57 | ps = "%s" |
---|
58 | ifdstr = sprintf("\t%cstopped%s%c,\n", 34, ps, 34) |
---|
59 | |
---|
60 | print "\n/*" |
---|
61 | print " * sigmsg.h -- architecture-customized signal messages for nmh" |
---|
62 | print " *" |
---|
63 | print " * automatically generated by sigmsg.awk" |
---|
64 | print " */\n" |
---|
65 | printf("%s %d\n\n", "#define SIGCOUNT", max) |
---|
66 | print "char *sigmsg[SIGCOUNT+2] = {" |
---|
67 | print "\tNULL," |
---|
68 | |
---|
69 | for (i = 1; i <= 0 + max; i++) |
---|
70 | if (msg[i] == "") { |
---|
71 | if (sig[i] == "") |
---|
72 | printf("\tNULL,\n") |
---|
73 | else if (sig[i] == "STOP") |
---|
74 | printf ifdstr, " (signal)", " (signal)" |
---|
75 | else if (sig[i] == "TSTP") |
---|
76 | printf ifdstr, "", "" |
---|
77 | else if (sig[i] == "TTIN") |
---|
78 | printf ifdstr, " (tty input)", " (tty input)" |
---|
79 | else if (sig[i] == "TTOU") |
---|
80 | printf ifdstr, " (tty output)", " (tty output)" |
---|
81 | else |
---|
82 | printf("\t%cSIG%s%c,\n", 34, sig[i], 34) |
---|
83 | } else |
---|
84 | printf("\t%c%s%c,\n", 34, msg[i], 34) |
---|
85 | print "\tNULL" |
---|
86 | print "};" |
---|
87 | } |
---|