File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / rsync / mkproto.pl
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Fri Feb 17 15:09:30 2012 UTC (12 years, 4 months ago) by misho
Branches: rsync, MAIN
CVS tags: v3_1_2p5, rsync3_0_9p0, RSYNC3_1_0, RSYNC3_0_9, HEAD
rsync

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>