--- /dev/null
+# tested with gawk, mawk, and nawk.
+# drop-in replacement for mk-globals-c.pl.
+# modified to work with Solaris awk (junk).
+# creates "globals.c" (on stdout) from "globals.h".
+# invoke similarly: perl -f mk-globals-c.pl globals.h
+# --> awk -f mk-globals-c.awk globals.h
+#
+# 2006 by Christopher Kerr.
+
+BEGIN { Copyright = 0
+ print "#include \"squid.h\"" }
+
+Copyright != 1 && /^ \*\/$/ { Copyright = 1; print; next }
+Copyright != 1 { print; next }
+/SQUID_GLOBALS_H/ { next }
+
+# arrays defined elsewhere
+/\[\];/ { next }
+
+/^extern / { # process "^extern " input lines.
+ # 0 1 2 #######
+ # extern int variable; /* val */ --> int variable; /* val */ #######
+ ##########################################################################
+ len = length($0) - 7 # sub(/extern /, "")
+ str = substr($0, 8, len) # strip "^extern ".
+
+ pos0 = index(str, ";") # position of ";".
+ pos1 = index(str, "/*") # position of "/*".
+ pos2 = index(str, "*/") # position of "*/".
+
+ if ( pos1 != 0 ) { # make assignment.
+
+ val = substr(str, pos1+3, pos2-pos1-4) # get comment value.
+ str = substr(str, 1, pos0-1) " = " val ";" # string to semi-colon.
+ }
+ print str; next # get next input line.
+}
+{ print } # C preprocessor lines.
--- /dev/null
+# tested with gawk, mawk, and nawk.
+# drop-in replacement for mk-string-arrays.pl.
+# creates "enum.c" (on stdout) from "enum.h".
+# invoke similarly: perl -f mk-string-arrays.pl enum.h
+# --> awk -f mk-string-arrays.awk enum.h
+#
+# 2006 by Christopher Kerr.
+
+BEGIN { # converted to "const char *"TypedefEnum[?]"_str[]"
+ TypedefEnum["err_type"] = 1
+ TypedefEnum["lookup_t"] = 1
+ TypedefEnum["icp_opcode"] = 1
+ TypedefEnum["swap_log_op"] = 1
+}
+
+/^ \*\/$/ && Copyright != 1 { Copyright = 1; print; next }
+Copyright != 1 { print; next }
+/^typedef/ { e = 0; next }
+
+/^[ \t]*[A-Z]/ {
+ split($1, t, ",") # remove ,
+ Element[++e] = t[1]
+ next
+}
+
+/^} / {
+ split($2, t, ";") # remove ;
+ type = t[1]
+ if (TypedefEnum[type]) {
+ print "\nconst char *" type "_str[] = {"
+ for ( i = 1; i < e; ++i)
+ print "\t\"" Element[i] "\","
+ print "\t\"" Element[i] "\""
+ print "};"
+ }
+ next
+}
+