]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mk-globals-c.awk
b9532b3f0d5d3d5b8ab4f20f11340aba0f433c14
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 # modified to work with Solaris awk (junk).
10 # creates "globals.c" (on stdout) from "globals.h".
11 # when invoked: awk -f mk-globals-c.awk globals.h
13 # 2006 by Christopher Kerr.
16 print "#include \"squid.h\"" }
18 Copyright
!= 1 && /^ \
*\
/$
/ { Copyright =
1; print; next }
19 Copyright
!= 1 { print; next }
20 /SQUID_GLOBALS_H
/ { next }
22 # arrays defined elsewhere
24 /^extern
\"C
\"/ { print; next }
27 # Check exactly for lines beginning with " extern", generated
28 # from astyle (grrrrr ...)
30 /^
*extern
/ { # process "^extern " input lines.
32 # extern int variable; /* val */ --> int variable; /* val */ #######
33 ##########################################################################
34 pos0 =
index($
0,"extern") #find how much whitespeace there is
35 str =
substr($
0,pos0
,length($
0))
36 len =
length(str
) - length("extern ") # sub(/extern /, "")
37 str =
substr($
0, length("extern ")+1, len
) # strip "^extern ".
39 pos0 =
index(str
, ";") # position of ";".
40 pos1 =
index(str
, "/*") # position of "/*".
41 pos2 =
index(str
, "*/") # position of "*/".
43 if ( pos1
!= 0 ) { # make assignment.
45 val =
substr(str
, pos1
+3, pos2
-pos1
-4) # get comment value.
46 str =
substr(str
, 1, pos0
-1) " = " val
";" # string to semi-colon.
48 print str
; next # get next input line.
50 { print } # C preprocessor lines.