19c2daa00SOllivier Robert#! @PATH_PERL@ -w 2*f5f40dd6SCy Schubert# @configure_input@ 39c2daa00SOllivier Robert 49c2daa00SOllivier Robert$found = 0; 59c2daa00SOllivier Robert$last = 0; 69c2daa00SOllivier Robert$debug = 0; 79c2daa00SOllivier Robert 89c2daa00SOllivier Robertwhile (<>) { 99c2daa00SOllivier Robert next if /^#/; 109c2daa00SOllivier Robert next if /^\s*$/; 112b15cb3dSCy Schubert if (/^typedef union req_data_u_tag/) { 129c2daa00SOllivier Robert $found = 1; 139c2daa00SOllivier Robert } 149c2daa00SOllivier Robert if (/^struct info_dns_assoc/) { 159c2daa00SOllivier Robert $last = 1; 169c2daa00SOllivier Robert } 179c2daa00SOllivier Robert if ($found) { 189c2daa00SOllivier Robert if (/^(struct\s*\w*)\s*{\s*$/) { 199c2daa00SOllivier Robert $type = $1; 209c2daa00SOllivier Robert print STDERR "type = '$type'\n" if $debug; 219c2daa00SOllivier Robert printf " printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n"; 229c2daa00SOllivier Robert next; 239c2daa00SOllivier Robert } 242b15cb3dSCy Schubert if (/^typedef (union\s*\w*)\s*{\s*$/) { 252b15cb3dSCy Schubert $type = $1; 262b15cb3dSCy Schubert print STDERR "union = '$type'\n" if $debug; 272b15cb3dSCy Schubert printf " printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n"; 282b15cb3dSCy Schubert next; 292b15cb3dSCy Schubert } 30ea906c41SOllivier Robert if (/\s*\w+\s+(\w*)\s*(\[.*\])?\s*;\s*$/) { 319c2daa00SOllivier Robert $field = $1; 329c2daa00SOllivier Robert print STDERR "\tfield = '$field'\n" if $debug; 339c2daa00SOllivier Robert printf " printf(\"offsetof($field) = %%d\\n\", \n\t (int) offsetof($type, $field));\n"; 349c2daa00SOllivier Robert next; 359c2daa00SOllivier Robert } 362b15cb3dSCy Schubert if (/^}\s*\w*\s*;\s*$/) { 379c2daa00SOllivier Robert printf " printf(\"\\n\");\n\n"; 389c2daa00SOllivier Robert $found = 0 if $last; 399c2daa00SOllivier Robert next; 409c2daa00SOllivier Robert } 419c2daa00SOllivier Robert print STDERR "Unmatched line: $_"; 429c2daa00SOllivier Robert exit 1; 439c2daa00SOllivier Robert } 449c2daa00SOllivier Robert} 45