1# This awk script parses C input files looking for lines marked "PUBLIC:" 2# and "EXTERN:". (PUBLIC lines are DB internal function prototypes and 3# #defines, EXTERN are DB external function prototypes and #defines.) 4# 5# PUBLIC lines are put into two versions of per-directory include files: 6# one file that contains the prototypes, and one file that contains a 7# #define for the name to be processed during configuration when creating 8# unique names for every global C-language symbol in the DB library. 9# 10# The EXTERN lines are put into two files: one of which contains prototypes 11# which are always appended to the db.h file, and one of which contains a 12# #define list for use when creating unique symbol names. 13# 14# Four arguments: 15# e_dfile list of EXTERN #defines 16# e_pfile include file that contains EXTERN prototypes 17# i_dfile list of internal (PUBLIC) #defines 18# i_pfile include file that contains internal (PUBLIC) prototypes 19/PUBLIC:/ { 20 sub("^.*PUBLIC:[ ][ ]*", "") 21 if ($0 ~ "^#if|^#ifdef|^#ifndef|^#else|^#endif") { 22 print $0 >> i_pfile 23 print $0 >> i_dfile 24 next 25 } 26 pline = sprintf("%s %s", pline, $0) 27 if (pline ~ "\\)\\);") { 28 sub("^[ ]*", "", pline) 29 print pline >> i_pfile 30 if (pline !~ db_version_unique_name) { 31 gsub("[ ][ ]*__P.*", "", pline) 32 sub("^.*[ ][*]*", "", pline) 33 printf("#define %s %s@DB_VERSION_UNIQUE_NAME@\n", 34 pline, pline) >> i_dfile 35 } 36 pline = "" 37 } 38} 39 40/EXTERN:/ { 41 sub("^.*EXTERN:[ ][ ]*", "") 42 if ($0 ~ "^#if|^#ifdef|^#ifndef|^#else|^#endif") { 43 print $0 >> e_pfile 44 print $0 >> e_dfile 45 next 46 } 47 eline = sprintf("%s %s", eline, $0) 48 if (eline ~ "\\)\\);") { 49 sub("^[ ]*", "", eline) 50 print eline >> e_pfile 51 if (eline !~ db_version_unique_name) { 52 gsub("[ ][ ]*__P.*", "", eline) 53 sub("^.*[ ][*]*", "", eline) 54 printf("#define %s %s@DB_VERSION_UNIQUE_NAME@\n", 55 eline, eline) >> e_dfile 56 } 57 eline = "" 58 } 59} 60