diff options
author | Wayne Davison <wayned@samba.org> | 2007-11-09 17:40:56 +0000 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2007-11-09 17:40:56 +0000 |
commit | 0c270e48afc4efa03ebb27a514bca9ef869cc910 (patch) | |
tree | 5c42ec0d2f610ed2b1bdb02d1a6f3a98e854d4f9 /mkproto.pl | |
parent | 8aeac05d981687e0e267a52e0e3bd7a5df634de5 (diff) | |
download | android_external_rsync-0c270e48afc4efa03ebb27a514bca9ef869cc910.tar.gz android_external_rsync-0c270e48afc4efa03ebb27a514bca9ef869cc910.tar.bz2 android_external_rsync-0c270e48afc4efa03ebb27a514bca9ef869cc910.zip |
Let's try using perl for building proto.h.
Diffstat (limited to 'mkproto.pl')
-rw-r--r-- | mkproto.pl | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/mkproto.pl b/mkproto.pl new file mode 100644 index 00000000..f453501b --- /dev/null +++ b/mkproto.pl @@ -0,0 +1,51 @@ +# generate prototypes for rsync +use strict; + +my $old_protos = ''; +if (open(IN, '<', 'proto.h')) { + $old_protos = join('', <IN>); + close IN; +} + +my %FN_MAP = ( + BOOL => 'BOOL ', + CHAR => 'char ', + INTEGER => 'int ', + STRING => 'char *', +); + +my $inheader = 0; +my $protos = qq|/* This file is automatically generated with "make proto". DO NOT EDIT */\n\n|; + +while (<>) { + if ($inheader) { + if (/[)][ \t]*$/) { + $inheader = 0; + s/$/;/; + } + $protos .= $_; + } + + if (/^FN_(LOCAL|GLOBAL)_([^(]+)\(([^,()]+)/) { + my $ret = $FN_MAP{$2}; + my $func = $3; + my $arg = $1 eq 'LOCAL' ? 'int ' : 'void'; + $protos .= "$ret$func($arg);\n"; + } elsif (/^static|^extern/ || /[;]/) { + ; + } elsif (!/^[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; +} |