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