summaryrefslogtreecommitdiffstats
path: root/c/src/librdbg/src/awk.svc
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/librdbg/src/awk.svc')
-rw-r--r--c/src/librdbg/src/awk.svc65
1 files changed, 65 insertions, 0 deletions
diff --git a/c/src/librdbg/src/awk.svc b/c/src/librdbg/src/awk.svc
new file mode 100644
index 0000000000..79e24a9d90
--- /dev/null
+++ b/c/src/librdbg/src/awk.svc
@@ -0,0 +1,65 @@
+#########################################################################
+#
+# Component: RDBG
+# Module: awk.svc
+#
+# Synopsis: AWK script which transforms the server skeleton produced
+# by rpcgen(1) into something suitable for RDB servers.
+#
+#########################################################################
+
+BEGIN {
+ headerstarted = 0
+ withinproc = 0
+ brack = 0
+}
+
+$1 ~ /^\/\*HEADER_START\*\/$/ {
+ headerstarted = 1
+ printf("#include <rpc/types.h>\n");
+ printf("#include <rpc/rpc.h>\n");
+ printf("#include <stdio.h>\n");
+ printf("#include <stdlib.h>\n");
+ printf("#include <string.h>\n");
+ printf("#include <bsp.h>\n");
+ printf("#include <rdbg/servrpc.h>\n");
+ printf("#include <rdbg/%s>\n", THEPROG);
+ printf("#define fprintf(a,b) printf(b)\n");
+ printf("#define msgout(a) printf(a)\n")
+ printf("#define _msgout(a) fprintf(stderr,a)\n");
+}
+
+$1 ~ /^\/\*HEADER_END\*\/$/ {
+ headerstarted = 0
+}
+
+{
+ if (headerstarted == 1) {
+ print $0
+ } else if ($1 ~ /.*_2.*/) {
+ withinproc = 1
+ printf("void\n");
+ print $0
+ } else if (withinproc == 1) {
+ if ($1 == "switch") {
+ print "\tDPRINTF ((\"remotedeb_2: %s (%d)\\n\", "
+ print "\t\t(unsigned) rqstp->rq_proc < "
+ print "\t\t(unsigned) (sizeof names / sizeof names[0]) ?"
+ print "\t\tnames [rqstp->rq_proc] : \"???\", "
+ print "\t\t(int) rqstp->rq_proc));\n"
+ }
+ for (i = 1; i <= NF; i++) {
+ if ($i == "{") {
+ brack++;
+ } else if ($i == "}") {
+ brack--;
+ if (brack == 0) {
+ withinproc = 0;
+ }
+ }
+ }
+ if ($1 != "_rpcsvcdirty" ) {
+ print $0
+ }
+ }
+}