1## Copyright (C) 1996-2021 The Squid Software Foundation and contributors 2## 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. 6## 7 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 12# 13# 2006 by Christopher Kerr. 14 15BEGIN { Copyright = 0 16 print "#include \"squid.h\"" } 17 18Copyright != 1 && /^ \*\/$/ { Copyright = 1; print; next } 19Copyright != 1 { print; next } 20/SQUID_GLOBALS_H/ { next } 21 22# arrays defined elsewhere 23/\[\];/ { next } 24/^extern \"C\"/ { print; next } 25 26# 27# Check exactly for lines beginning with " extern", generated 28# from astyle (grrrrr ...) 29# 30/^ *extern / { # process "^extern " input lines. 31 # 0 1 2 ####### 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 ". 38 39 pos0 = index(str, ";") # position of ";". 40 pos1 = index(str, "/*") # position of "/*". 41 pos2 = index(str, "*/") # position of "*/". 42 43 if ( pos1 != 0 ) { # make assignment. 44 45 val = substr(str, pos1+3, pos2-pos1-4) # get comment value. 46 str = substr(str, 1, pos0-1) " = " val ";" # string to semi-colon. 47 } 48 print str; next # get next input line. 49} 50{ print } # C preprocessor lines. 51