1#Saluton Emacson! Bonvolu elekti -*- mode: awk; -*-. Dankon. 2 3BEGIN{ 4 headerfile="wrapped.h"; 5 deffile="wrapdef.h"; 6 structfile="wrapstruct.h"; 7 tmpffile="wraptmpf.h"; 8 FS=";"; 9 WARNING="/* Automatically generated file. Do not edit. Edit wrapawk/wrapfunc.inp. */"; 10 print WARNING > headerfile; 11 print "#ifndef WRAPPED_H" > headerfile; 12 print "#define WRAPPED_H" > headerfile; 13 print WARNING > deffile; 14 print "#ifndef WRAPDEF_H" > deffile; 15 print "#define WRAPDEF_H" > deffile; 16 print WARNING > tmpffile; 17 print "#ifndef WRAPTMPF_H" > tmpffile; 18 print "#define WRAPTMPF_H" > tmpffile; 19 print WARNING > structfile; 20 print "#ifndef WRAPSTRUCT_H" > structfile; 21 print "#define WRAPSTRUCT_H" > structfile; 22 print "struct next_wrap_st next_wrap[]= {" > structfile; 23} 24 25/\/\*/{ 26} 27/^(\#)/{ 28 print $0 > structfile; 29 print $0 > tmpffile; 30 print $0 > deffile; 31 print $0 > headerfile; 32 33} 34/^[^\/].*;.*;.*;/{ 35 name=$1; 36 ret=$2; 37 argtype=$3; 38 argname=$4; 39 MACRO=$5; 40 if(MACRO){ 41 print " {(void(*))&NEXT_" MACRO "_NOARG, " name "_QUOTE}," > structfile; 42 print "extern " ret " (*NEXT_" MACRO "_NOARG)" argtype ";" > headerfile; 43 print ret " (*NEXT_" MACRO "_NOARG)" argtype "=TMP_" MACRO ";"> deffile; 44 45 print ret " TMP_" MACRO, argtype "{" > tmpffile; 46 print " load_library_symbols();" > tmpffile; 47 print " return NEXT_" MACRO "_NOARG " argname ";" > tmpffile; 48 print "}" > tmpffile; 49 print "" > tmpffile; 50 } else { 51 print " {(void(*))&next_" name ", \"" name "\"}," > structfile; 52 print "extern " ret " (*next_" name ")" argtype ";" > headerfile; 53 print ret " (*next_" name ")" argtype "=tmp_" name ";"> deffile; 54 55 print ret " tmp_" name, argtype "{" > tmpffile; 56 print " load_library_symbols();" > tmpffile; 57 print " return next_" name, argname ";" > tmpffile; 58 print "}" > tmpffile; 59 print "" > tmpffile; 60 } 61} 62 63/^ *$/{ 64 print > structfile; 65 print > headerfile; 66 print > deffile; 67 print > tmpffile; 68} 69 70END{ 71 print " {NULL, NULL}," > structfile; 72 print "};" > structfile; 73 print "#endif" > structfile; 74 print "#endif" > tmpffile; 75 print "#endif" > deffile; 76 print "#endif" > headerfile; 77} 78