xref: /freebsd/contrib/ntp/ntpdc/nl.pl.in (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1#! @PATH_PERL@ -w
2# @configure_input@
3
4$found = 0;
5$last = 0;
6$debug = 0;
7
8while (<>) {
9    next if /^#/;
10    next if /^\s*$/;
11    if (/^typedef union req_data_u_tag/) {
12	$found = 1;
13    }
14    if (/^struct info_dns_assoc/) {
15	$last = 1;
16    }
17    if ($found) {
18	if (/^(struct\s*\w*)\s*{\s*$/) {
19	    $type = $1;
20	    print STDERR "type = '$type'\n" if $debug;
21	    printf "  printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n";
22	    next;
23	}
24	if (/^typedef (union\s*\w*)\s*{\s*$/) {
25	    $type = $1;
26	    print STDERR "union = '$type'\n" if $debug;
27	    printf "  printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n";
28	    next;
29	}
30	if (/\s*\w+\s+(\w*)\s*(\[.*\])?\s*;\s*$/) {
31	    $field = $1;
32	    print STDERR "\tfield = '$field'\n" if $debug;
33	    printf "  printf(\"offsetof($field) = %%d\\n\", \n\t (int) offsetof($type, $field));\n";
34	    next;
35	}
36	if (/^}\s*\w*\s*;\s*$/) {
37	    printf "  printf(\"\\n\");\n\n";
38	    $found = 0 if $last;
39	    next;
40	}
41	print STDERR "Unmatched line: $_";
42	exit 1;
43    }
44}
45