1132451Sroberto#! @PATH_PERL@ -w 2132451Sroberto 3132451Sroberto$found = 0; 4132451Sroberto$last = 0; 5132451Sroberto$debug = 0; 6132451Sroberto 7132451Srobertowhile (<>) { 8132451Sroberto next if /^#/; 9132451Sroberto next if /^\s*$/; 10280849Scy if (/^typedef union req_data_u_tag/) { 11132451Sroberto $found = 1; 12132451Sroberto } 13132451Sroberto if (/^struct info_dns_assoc/) { 14132451Sroberto $last = 1; 15132451Sroberto } 16132451Sroberto if ($found) { 17132451Sroberto if (/^(struct\s*\w*)\s*{\s*$/) { 18132451Sroberto $type = $1; 19132451Sroberto print STDERR "type = '$type'\n" if $debug; 20132451Sroberto printf " printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n"; 21132451Sroberto next; 22132451Sroberto } 23280849Scy if (/^typedef (union\s*\w*)\s*{\s*$/) { 24280849Scy $type = $1; 25280849Scy print STDERR "union = '$type'\n" if $debug; 26280849Scy printf " printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n"; 27280849Scy next; 28280849Scy } 29182007Sroberto if (/\s*\w+\s+(\w*)\s*(\[.*\])?\s*;\s*$/) { 30132451Sroberto $field = $1; 31132451Sroberto print STDERR "\tfield = '$field'\n" if $debug; 32132451Sroberto printf " printf(\"offsetof($field) = %%d\\n\", \n\t (int) offsetof($type, $field));\n"; 33132451Sroberto next; 34132451Sroberto } 35280849Scy if (/^}\s*\w*\s*;\s*$/) { 36132451Sroberto printf " printf(\"\\n\");\n\n"; 37132451Sroberto $found = 0 if $last; 38132451Sroberto next; 39132451Sroberto } 40132451Sroberto print STDERR "Unmatched line: $_"; 41132451Sroberto exit 1; 42132451Sroberto } 43132451Sroberto} 44