Commit | Line | Data |
---|---|---|
0c270e48 WD |
1 | # generate prototypes for rsync |
2 | use strict; | |
3 | ||
4 | my $old_protos = ''; | |
5 | if (open(IN, '<', 'proto.h')) { | |
6 | $old_protos = join('', <IN>); | |
7 | close IN; | |
8 | } | |
9 | ||
10 | my %FN_MAP = ( | |
11 | BOOL => 'BOOL ', | |
12 | CHAR => 'char ', | |
13 | INTEGER => 'int ', | |
14 | STRING => 'char *', | |
15 | ); | |
16 | ||
17 | my $inheader = 0; | |
18 | my $protos = qq|/* This file is automatically generated with "make proto". DO NOT EDIT */\n\n|; | |
19 | ||
20 | while (<>) { | |
21 | if ($inheader) { | |
22 | if (/[)][ \t]*$/) { | |
23 | $inheader = 0; | |
24 | s/$/;/; | |
25 | } | |
26 | $protos .= $_; | |
27 | } | |
28 | ||
29 | if (/^FN_(LOCAL|GLOBAL)_([^(]+)\(([^,()]+)/) { | |
30 | my $ret = $FN_MAP{$2}; | |
31 | my $func = $3; | |
32 | my $arg = $1 eq 'LOCAL' ? 'int ' : 'void'; | |
33 | $protos .= "$ret$func($arg);\n"; | |
34 | } elsif (/^static|^extern/ || /[;]/) { | |
35 | ; | |
36 | } elsif (!/^[A-Za-z][A-Za-z0-9_]* /) { | |
37 | ; | |
38 | } elsif (/[(].*[)][ \t]*$/) { | |
39 | s/$/;/; | |
40 | $protos .= $_; | |
41 | } elsif (/[(]/) { | |
42 | $inheader = 1; | |
43 | $protos .= $_; | |
44 | } | |
45 | } | |
46 | ||
47 | if ($old_protos ne $protos) { | |
48 | open(OUT, '>', 'proto.h') or die $!; | |
49 | print OUT $protos; | |
50 | close OUT; | |
51 | } |