]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mk-string-arrays.awk
1 # tested with gawk, mawk, and nawk.
2 # drop-in replacement for mk-string-arrays.pl.
3 # creates "enum.c" (on stdout) from "enum.h".
4 # invoke similarly: perl -f mk-string-arrays.pl enum.h
5 # --> awk -f mk-string-arrays.awk enum.h
7 # 2006 by Christopher Kerr.
9 # 2009 modified by Amos Jeffries
10 # Adapted to convert individual enum headers
15 print " * Auto-Generated File. Changes will be destroyed."
17 print "#include \"config.h\""
23 # when namespace is encountered store it
24 /^namespace
[a
-zA
-Z
]+/ {
25 nspath =
tolower($
2) "/" # nested folder
26 namespace = $
2 # code namespace reconstruct
30 # Skip all lines outside of typedef {}
31 /^typedef
/ { codeSkip =
0; next }
32 codeSkip ==
1 { next }
35 split($
1, t
, ",") # remove ,
41 split($
2, t
, ";") # remove ;
45 print "#include \"" nspath type
".h\""
47 # if namesapce is not empty ??
48 if (namespace
) print "namespace " namespace
49 if (namespace
) print "{"
51 print "\nconst char *" type
"_str[] = {"
52 for ( i =
1; i
< e
; ++i
)
53 print "\t\"" Element
[i
] "\","
54 print "\t\"" Element
[i
] "\""
56 if (namespace
) print "}; // namespace " namespace