]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mk-globals-c.awk
1 ## Copyright (C) 1996-2023 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
26 # Check exactly for lines beginning with " extern", generated
27 # from astyle (grrrrr ...)
29 /^
*extern
/ { # process "^extern " input lines.
31 # extern int variable; /* val */ --> int variable; /* val */ #######
32 ##########################################################################
33 pos0 =
index($
0,"extern") #find how much whitespeace there is
34 str =
substr($
0,pos0
,length($
0))
35 len =
length(str
) - length("extern ") # sub(/extern /, "")
36 str =
substr($
0, length("extern ")+1, len
) # strip "^extern ".
38 pos0 =
index(str
, ";") # position of ";".
39 pos1 =
index(str
, "/*") # position of "/*".
40 pos2 =
index(str
, "*/") # position of "*/".
42 if ( pos1
!= 0 ) { # make assignment.
44 val =
substr(str
, pos1
+3, pos2
-pos1
-4) # get comment value.
45 str =
substr(str
, 1, pos0
-1) " = " val
";" # string to semi-colon.
47 print str
; next # get next input line.
49 { print } # C preprocessor lines.