]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mk-string-arrays.awk
1 ## Copyright (C) 1996-2017 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 # creates "enum.c" (on stdout) from "enum.h".
10 # when invoked: awk -f mk-string-arrays.awk enum.h
12 # 2006 by Christopher Kerr.
14 # 2009 modified by Amos Jeffries
15 # Adapted to convert individual enum headers
20 print " * Auto-Generated File. Changes will be destroyed."
22 print "#include \"squid.h\""
28 # when namespace is encountered store it
29 /^namespace
*[a
-zA
-Z
]+/ {
30 nspath =
tolower($
2) "/" # nested folder
31 namespace = $
2 # code namespace reconstruct
35 # Skip all lines outside of typedef {}
36 /^typedef
/ { codeSkip =
0; next }
47 codeSkip ==
1 { next }
50 split($
1, t
, ",") # remove ,
51 if (sbuf
) Element
[++e
] =
"SBuf(\"" t
[1] "\")"
52 else Element
[++e
] =
"\"" t
[1] "\""
68 split($
2, t
, ";") # remove ;
76 if (sbuf
) print "#include \"sbuf/SBuf.h\""
77 print "#include \"" nspath type
".h\""
79 # if namespace is not empty ??
80 if (namespace
) print "namespace " namespace
81 if (namespace
) print "{"
83 if (sbuf
) print "\nconst SBuf " type
"_sb[] = {"
84 else print "\nconst char * " type
"_str[] = {"
85 for ( i =
1; i
< e
; ++i
)
86 if (Wrapper
[i
]) print Wrapper
[i
]
87 else print "\t" Element
[i
] ","
91 if (namespace
) print "}; // namespace " namespace