]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mk-string-arrays.awk
1 ## Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 ## Squid software is distributed under GPLv2+ license and includes
4 ## contributions from numerous individuals and organizations.
5 ## Please see the COPYING and CONTRIBUTORS files for details.
8 # tested with gawk, mawk, and nawk.
9 # drop-in replacement for mk-string-arrays.pl.
10 # creates "enum.c" (on stdout) from "enum.h".
11 # invoke similarly: perl -f mk-string-arrays.pl enum.h
12 # --> awk -f mk-string-arrays.awk enum.h
14 # 2006 by Christopher Kerr.
16 # 2009 modified by Amos Jeffries
17 # Adapted to convert individual enum headers
22 print " * Auto-Generated File. Changes will be destroyed."
24 print "#include \"squid.h\""
30 # when namespace is encountered store it
31 /^namespace
*[a
-zA
-Z
]+/ {
32 nspath =
tolower($
2) "/" # nested folder
33 namespace = $
2 # code namespace reconstruct
37 # Skip all lines outside of typedef {}
38 /^typedef
/ { codeSkip =
0; next }
39 codeSkip ==
1 { next }
42 split($
1, t
, ",") # remove ,
43 if (sbuf
) Element
[++e
] =
"SBuf(\"" t
[1] "\")"
44 else Element
[++e
] =
"\"" t
[1] "\""
56 split($
2, t
, ";") # remove ;
60 if (sbuf
) print "#include \"SBuf.h\""
61 print "#include \"" nspath type
".h\""
63 # if namesapce is not empty ??
64 if (namespace
) print "namespace " namespace
65 if (namespace
) print "{"
67 if (sbuf
) print "\nconst SBuf " type
"_sb[] = {"
68 else print "\nconst char * " type
"_str[] = {"
69 for ( i =
1; i
< e
; ++i
)
70 if (Wrapper
[i
]) print Wrapper
[i
]
71 else print "\t" Element
[i
] ","
75 if (namespace
) print "}; // namespace " namespace