diff --git a/src/messenger/tools/header.txt b/src/messenger/tools/header.txt new file mode 100644 index 00000000..433e8cb4 --- /dev/null +++ b/src/messenger/tools/header.txt @@ -0,0 +1,14 @@ +This file is part of Mibew Messenger project. + +Copyright (c) 2005-2009 Mibew Messenger Community +All rights reserved. The contents of this file are subject to the terms of +the Eclipse Public License v1.0 which accompanies this distribution, and +is available at http://www.eclipse.org/legal/epl-v10.html + +Alternatively, the contents of this file may be used under the terms of +the GNU General Public License Version 2 or later (the "GPL"), in which case +the provisions of the GPL are applicable instead of those above. If you wish +to allow use of your version of this file only under the terms of the GPL, and +not to allow others to use your version of this file under the terms of the +EPL, indicate your decision by deleting the provisions above and replace them +with the notice and other provisions required by the GPL. \ No newline at end of file diff --git a/src/messenger/tools/header_update.pl b/src/messenger/tools/header_update.pl new file mode 100755 index 00000000..69ce5e92 --- /dev/null +++ b/src/messenger/tools/header_update.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl + +$sourceFolder = "../webim"; + +sub file_content($) { + my $input = $_[0]; + open( IN1, "< $input" ) or die "cannot find file $input"; + $/ = EOI; + $content = ; + $content =~ s/\r//g; + close( IN1 ); + return $content; +} + +$php_header = file_content("header.txt"); +$php_header =~ s/\s+$//; + +@allfiles = (); + +sub process_folder($) { + my($from) = @_; + + opendir(DIR, $from) || die "can't opendir $from: $!"; + my @content = readdir(DIR); + closedir DIR; + + for(grep { -f "$from/$_" && ($_ !~ /^\./ || $_ eq ".htaccess") } @content) { + push @allfiles, "$from/$_"; + } + for(grep { -d "$from/$_" && $_ !~ /^\./ } @content) { + process_folder("$from/$_"); + } +} + +process_folder($sourceFolder); + +P: for $phpfile (grep { /\.php$/ } @allfiles) { + $content = file_content($phpfile); + $content =~ s/\s+$//g; + die "not a php: $phpfile" unless $content =~ /^<\?php\n(\/\*.*?\*\/)?/s; + die "no comment in $phpfile" unless defined($1); + $comment = $1; + if($comment =~ /\[external\]/) { + next P; + }; + die "no contributors in $phpfile" unless $comment =~ /Contributors:/; + $newcomment = $comment; + $newcomment =~ s/\s\*\s//g; + $newcomment =~ s/^\/\*//; + $newcomment =~ s/\*\/$//; + $newcomment =~ s/.*(Contributors:)/$1/s; + $newcomment =~ s/^\s+//; + $newcomment =~ s/\s+$//; + $newcomment = "$php_header\n\n$newcomment"; + $newcomment =~ s/^/ * /gm; + $newcomment = "/*\n$newcomment\n */"; + + $content =~ s/^(<\?php\n)\/\*.*?\*\//$1$newcomment/s; + + open( OUT, "> $phpfile" ) or die "cannot write file: $phpfile\n"; + print OUT $content; + close( OUT ); +}