File: mkproto.pl

package info (click to toggle)
rsync 3.1.3-6
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 3,888 kB
  • sloc: ansic: 40,820; sh: 5,508; perl: 1,932; makefile: 326; python: 83
file content (48 lines) | stat: -rw-r--r-- 974 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# generate prototypes for rsync

$old_protos = '';
if (open(IN, 'proto.h')) {
    $old_protos = join('', <IN>);
    close IN;
}

%FN_MAP = (
    BOOL => 'BOOL ',
    CHAR => 'char ',
    INTEGER => 'int ',
    STRING => 'char *',
);

$inheader = 0;
$protos = qq|/* This file is automatically generated with "make proto". DO NOT EDIT */\n\n|;

while (<>) {
    if ($inheader) {
	if (/[)][ \t]*$/) {
	    $inheader = 0;
	    s/$/;/;
	}
	$protos .= $_;
    } elsif (/^FN_(LOCAL|GLOBAL)_([^(]+)\(([^,()]+)/) {
	$ret = $FN_MAP{$2};
	$func = $3;
	$arg = $1 eq 'LOCAL' ? 'int module_id' : 'void';
	$protos .= "$ret$func($arg);\n";
    } elsif (/^static|^extern/ || /[;]/ || !/^[A-Za-z][A-Za-z0-9_]* /) {
	;
    } elsif (/[(].*[)][ \t]*$/) {
	s/$/;/;
	$protos .= $_;
    } elsif (/[(]/) {
	$inheader = 1;
	$protos .= $_;
    }
}

if ($old_protos ne $protos) {
    open(OUT, '>proto.h') or die $!;
    print OUT $protos;
    close OUT;
}

open(OUT, '>proto.h-tstamp') and close OUT;