1 | ######################################################################### |
---|
2 | # |
---|
3 | # Component: RDBG |
---|
4 | # Module: awk.svc |
---|
5 | # |
---|
6 | # Synopsis: AWK script which transforms the server skeleton produced |
---|
7 | # by rpcgen(1) into something suitable for RDB servers. |
---|
8 | # |
---|
9 | ######################################################################### |
---|
10 | # |
---|
11 | # $Id$ |
---|
12 | # |
---|
13 | BEGIN { |
---|
14 | headerstarted = 0 |
---|
15 | withinproc = 0 |
---|
16 | brack = 0 |
---|
17 | } |
---|
18 | |
---|
19 | $1 ~ /^\/\*HEADER_START\*\/$/ { |
---|
20 | headerstarted = 1 |
---|
21 | printf("#include <rpc/types.h>\n"); |
---|
22 | printf("#include <rpc/rpc.h>\n"); |
---|
23 | printf("#include <stdio.h>\n"); |
---|
24 | printf("#include <stdlib.h>\n"); |
---|
25 | printf("#include <string.h>\n"); |
---|
26 | printf("#include <bsp.h>\n"); |
---|
27 | printf("#include <rdbg/servrpc.h>\n"); |
---|
28 | printf("#include <rdbg/%s>\n", THEPROG); |
---|
29 | printf("#define fprintf(a,b) printf(b)\n"); |
---|
30 | } |
---|
31 | |
---|
32 | $1 ~ /^\/\*HEADER_END\*\/$/ { |
---|
33 | headerstarted = 0 |
---|
34 | } |
---|
35 | |
---|
36 | { |
---|
37 | if (headerstarted == 1) { |
---|
38 | print $0 |
---|
39 | } else if ($1 ~ /.*_2.*/) { |
---|
40 | withinproc = 1 |
---|
41 | printf("void\n"); |
---|
42 | print $0 |
---|
43 | } else if (withinproc == 1) { |
---|
44 | if ($1 == "switch") { |
---|
45 | print "\tDPRINTF ((\"remotedeb_2: %s (%d)\\n\", " |
---|
46 | print "\t\t(unsigned) rqstp->rq_proc < " |
---|
47 | print "\t\t(unsigned) (sizeof names / sizeof names[0]) ?" |
---|
48 | print "\t\tnames [rqstp->rq_proc] : \"???\", " |
---|
49 | print "\t\t(int) rqstp->rq_proc));\n" |
---|
50 | } |
---|
51 | for (i = 1; i <= NF; i++) { |
---|
52 | if ($i == "{") { |
---|
53 | brack++; |
---|
54 | } else if ($i == "}") { |
---|
55 | brack--; |
---|
56 | if (brack == 0) { |
---|
57 | withinproc = 0; |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|
61 | if ($1 != "_rpcsvcdirty" ) { |
---|
62 | print $0 |
---|
63 | } |
---|
64 | } |
---|
65 | } |
---|