diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:41 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:41 +0200 |
| commit | 9cd3ccffd5372dfde3af478e3f832f18db4be3f1 (patch) | |
| tree | 631c295a4a4a16b57502b847626763a279bf6df7 /ychat-0.7.4.1/scripts | |
| parent | 13aaf70af703748fe096e0664c305cd202637ad2 (diff) | |
tagging tags
Diffstat (limited to 'ychat-0.7.4.1/scripts')
| -rw-r--r-- | ychat-0.7.4.1/scripts/README | 6 | ||||
| -rwxr-xr-x | ychat-0.7.4.1/scripts/astyle.sh | 14 | ||||
| -rwxr-xr-x | ychat-0.7.4.1/scripts/buildnr.pl | 26 | ||||
| -rwxr-xr-x | ychat-0.7.4.1/scripts/config.sh | 152 | ||||
| -rw-r--r-- | ychat-0.7.4.1/scripts/makeyhttpd.pl | 135 | ||||
| -rwxr-xr-x | ychat-0.7.4.1/scripts/modules/file.pm | 28 | ||||
| -rwxr-xr-x | ychat-0.7.4.1/scripts/screen.sh | 3 | ||||
| -rwxr-xr-x | ychat-0.7.4.1/scripts/setglobvals.pl | 32 | ||||
| -rwxr-xr-x | ychat-0.7.4.1/scripts/stats.pl | 95 | ||||
| -rwxr-xr-x | ychat-0.7.4.1/scripts/version.sh | 11 |
10 files changed, 502 insertions, 0 deletions
diff --git a/ychat-0.7.4.1/scripts/README b/ychat-0.7.4.1/scripts/README new file mode 100644 index 0000000..189b169 --- /dev/null +++ b/ychat-0.7.4.1/scripts/README @@ -0,0 +1,6 @@ +All scripts should be run from the yChat main directory, example: + +./scripts/makeyhttpd.pl + + +A ./makeyhttpd.pl WILL NOT work :) diff --git a/ychat-0.7.4.1/scripts/astyle.sh b/ychat-0.7.4.1/scripts/astyle.sh new file mode 100755 index 0000000..4376887 --- /dev/null +++ b/ychat-0.7.4.1/scripts/astyle.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# The yChat Project (2004) +# +# This uses "astyle" to format C++ code into a specific code style! + +for f in h cpp tmpl +do + for i in `find . -name "*.$f"` + do + echo $i + astyle --style=gnu $i + rm -f $i.orig + done +done diff --git a/ychat-0.7.4.1/scripts/buildnr.pl b/ychat-0.7.4.1/scripts/buildnr.pl new file mode 100755 index 0000000..ee3d3e2 --- /dev/null +++ b/ychat-0.7.4.1/scripts/buildnr.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl + +# The yChat Project (2003) +# +# This script increases the BUILNR of msgs,h each time the yChat +# gets recompiled! + +use strict; + +open MSGS, "src/msgs.h"; +my @msgs = <MSGS>; +close MSGS; + +foreach (@msgs) +{ + if ( /define BUILDNR/ ) + { + s/(BUILDNR )(.+)$/$1.($2+1)/e; + print; + next; + } +} + +open MSGS, ">src/msgs.h"; +print MSGS @msgs; +close MSGS; diff --git a/ychat-0.7.4.1/scripts/config.sh b/ychat-0.7.4.1/scripts/config.sh new file mode 100755 index 0000000..373fad4 --- /dev/null +++ b/ychat-0.7.4.1/scripts/config.sh @@ -0,0 +1,152 @@ +#!/bin/sh +# The yChat Project (2004) +# +# This script modifues the src/glob.h file. + +if ! which perl >/dev/null +then + echo You need to have Perl in your PATH + exit 1 +fi + +perl -e ' + use strict; + + use scripts::modules::file; + +print <<END; +Welcome to the yChat configurator! +You may also edit the src/glob.h file manually instead of using +this configurator option. Please also notice that this are only +before-compile options. All setups which can be made after com- +iling are placed in the yChat configuration file. +END + + my $sep = "================================================================\n"; my $stdin; + +for (;;) + { + print "$sep Do you want to use the default before-compile options?\n"; + print " (yes/no) [default is NO] "; + $stdin = <STDIN>; + chomp $stdin; + prove_if_default(\$stdin); + print "\n"; + + + if ( $stdin eq "yes") + { + print " You chose to use all the default before-compile options. Exiti-\n"; + print " ng the configurator now!\n"; + print $sep; + exit(0); + } + last if $stdin eq "no" or $stdin eq ""; + print " Wrong input: You need to specify yes or no!\n"; + } # for + + `cp src/glob.h src/glob.h.org` + unless -f "src/glob.h.org"; + + my @glob = fopen("src/glob.h.org"); + my $flag = 0; + + foreach( @glob ) + { + if ( $flag == 0 && /- CONFIG -/ ) + { + print $sep; + $flag = 1; + next; + } + + elsif ( $flag == 1 ) + { + if ( /\*\// ) + { + $flag = 2; + } + + else + { + print; + } + + next; + } + + elsif ( $flag == 2 ) + { + if ( /#define (.+) (.+)/ ) + { + my $def = $1; + my $val = $2; + my $flg = 0; + + $flg = 1 if $val =~ s/"//g; + + print " [Press enter to use default value: $val] "; + $stdin = <STDIN>; + chomp $stdin; + + unless ( prove_if_default(\$stdin) ) + { + $stdin = "\"$stdin\"" if $flg == 1; + $_ = "#define $def $stdin\n"; + } + + print "\n"; + $flag = 0; + next; + } + + elsif ( /#define .+/ ) + { + my $default = "true"; + my $stdin; + + for (;;) + { + $default = "false" if /\/\/#define/; + + print " [Press enter to use default value: $default] "; + $stdin = <STDIN>; + chomp $stdin; + + last if $stdin eq "" || $stdin eq "true" || $stdin eq "false"; + print " Wrong input: You need to specify true or false!\n"; + } + + if ( $default eq "true" ) + { + $_ = "//$_" + unless prove_if_default(\$stdin); + } + + else + { + s/^\/\/// + unless prove_if_default(\$stdin); + } + + print "\n"; + $flag = 0; + next; + } + } + } // foreach + + fwrite("src/glob.h", @glob); + + sub prove_if_default + { + my $val = shift; + if ( $$val eq "" ) + { + print " -> Using default option!\n"; + return 1; + } + print " -> Using new option $$val!\n"; + return 0; + } +' diff --git a/ychat-0.7.4.1/scripts/makeyhttpd.pl b/ychat-0.7.4.1/scripts/makeyhttpd.pl new file mode 100644 index 0000000..101343a --- /dev/null +++ b/ychat-0.7.4.1/scripts/makeyhttpd.pl @@ -0,0 +1,135 @@ +#!/usr/bin/perl + +# The yChat & yhttpd Project (2004, 2005) +# +# This scripts modifies the yChat sources to yhttpd sources. + +use strict; +use scripts::modules::file; + +my @delete = ( + 'ChangeLog', + 'g++.version', + 'TODO', + 'NEWS', + 'docs', + 'src/chat', + 'src/data', + 'src/irc', + 'src/contrib/crypt', + 'src/modl.h', + 'src/modl.cpp', + 'src/mods', + 'src/mods/commands', + 'src/mods/irc', + 'obj', + 'mods', + 'html', + 'log/rooms', + 'scripts/makeyhttpd.pl', + 'scripts/mergeconf.pl', + 'bin/ychat', + 'bin/ychat.old', +); + +my @createdir = ( + 'html' +); + +my %substituate = ( + 'ychat' => 'yhttpd', + 'yChat' => 'yhttpd', + 'YCHAT' => 'YHTTPD', + 'CHAT' => 'HTTPD', + '//>>' => '' +); + +if ( -d "../yhttpd" ) { + print "Removing ../yhttpd\n"; + system("rm -Rf ../yhttpd"); +} + +print "Creating new ../yhttpd\n"; +system("cp -Rp ../ychat ../yhttpd"); + +chdir("../yhttpd"); +system("gmake clean"); + +my @deletelines; +foreach (@delete) { + next unless -d $_; + foreach (dopen($_)) { + next unless /\.h$/; + push @deletelines, $_; + } +} + +print "Moving html templates\n"; +system("mv html/test.cgi ."); +system("mv html/demo.html ."); +system("mv html/style.css ."); +system("mv html/notfound.html ."); + +print "Removing dirs and files\n->"; +foreach (@delete) { + next unless -f $_ || -d $_; + print " $_"; + system("rm -Rf $_"); +} + +print "\nDeleting CVS directories\n"; +system("find . -name CVS | xargs rm -Rf"); + +print "Creating new dirs\n->"; +foreach (@createdir) { + print " $_"; + system("mkdir $_"); +} + +print "\nRenaming config file\n"; +system("mv etc/ychat.conf etc/yhttpd.conf"); + +print "Moving html templates\n"; +system("mv demo.html html/index.html"); +system("mv test.cgi notfound.html style.css html"); + +print "Removing marked lines of code\n->"; +&remove_marked_lines('.'); + +sub remove_marked_lines { + my $dir = shift; + chdir($dir); + foreach (&dopen(".")) { + next if /^\.+$/; + print " $_"; + if ( -f $_ ) { + my @newfile; + my $flag = 0; + foreach my $line (fopen($_)) { + $flag = 1 if $line =~ /\/\/<<\*/; + if ($flag == 0 && $line !~ /\/\/<</) { + foreach ( @deletelines ) { + if ($line =~ /$_/) { + $flag = 3; + last; + } + } + if ($flag != 3 ) { + map { $line =~ s/$_/$substituate{$_}/eg } keys %substituate; + push @newfile, $line; + } else { + $flag = 0; + } + } + $flag = 0 if $line =~ /\/\/\*>>/; + } + &fwrite($_, @newfile); + } elsif ( -d $_ ) { + &remove_marked_lines($_); + } + } + chdir('..'); +} + +print "\n"; + diff --git a/ychat-0.7.4.1/scripts/modules/file.pm b/ychat-0.7.4.1/scripts/modules/file.pm new file mode 100755 index 0000000..b11e2b3 --- /dev/null +++ b/ychat-0.7.4.1/scripts/modules/file.pm @@ -0,0 +1,28 @@ +sub dopen +{ + my $shift = shift; + opendir DIR, $shift or die "$shift: $!\n"; + my @dir = readdir(DIR); + closedir DIR; + return @dir; +} + +sub fopen +{ + my $shift = shift; + open FILE, $shift or die "$shift: $!\n"; + my @file = <FILE>; + close FILE; + return @file; +} + +sub fwrite +{ + my $shift = shift; + my @file = @_; + open FILE, ">$shift" or die "$shift: $!\n"; + print FILE @file; + close FILE; +} + +1; diff --git a/ychat-0.7.4.1/scripts/screen.sh b/ychat-0.7.4.1/scripts/screen.sh new file mode 100755 index 0000000..6d5b7aa --- /dev/null +++ b/ychat-0.7.4.1/scripts/screen.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +screen -S ychat ./bin/ychat diff --git a/ychat-0.7.4.1/scripts/setglobvals.pl b/ychat-0.7.4.1/scripts/setglobvals.pl new file mode 100755 index 0000000..13288a5 --- /dev/null +++ b/ychat-0.7.4.1/scripts/setglobvals.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl + +# The yChat Project (2003) +# +# This script sets up some variables in src/glob.h + +use strict; + +use scripts::modules::file; + +my $file = 'src/glob.h'; +my $gmake = `which gmake`; +my @glob = fopen($file); +chomp($gmake); + +print "-> Setting values in $file\n"; + +my $modified = 0; +foreach (@glob) +{ + if (/^(#define GMAKE) "(.*)"/) + { + if ($2 ne "$gmake \\0") + { + s/^$1 "$2"/#define GMAKE "$gmake \\0"/; + print " -> Set $gmake\n"; + fwrite($file,@glob); + last; + } + } +} + diff --git a/ychat-0.7.4.1/scripts/stats.pl b/ychat-0.7.4.1/scripts/stats.pl new file mode 100755 index 0000000..e5cc2b3 --- /dev/null +++ b/ychat-0.7.4.1/scripts/stats.pl @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# The yChat Project (2003 - 2004) +# +# This script generates source code and project statistics + +use strict; + +use scripts::modules::file; + +my %stats; +my $param = shift; + +&recursive("."); + +$stats{"Lines total"} = $stats{"Lines of source"} + + $stats{"Lines of scripts"} + + $stats{"Lines of text"} + + $stats{"Lines of HTML"}; + +unless (defined $param) { + + print "$_ = " . $stats{$_} . "\n" + for ( sort keys %stats ); + +} else { + + print $stats{$_} . " " + for sort keys %stats; + +} + +print "\n"; + +sub recursive +{ + my $shift = shift; + my @dir = &dopen($shift); + + foreach (@dir) + { + next if /^\.$/ or /^\.{2}$/; + + if ( -f "$shift/$_" ) + { + $stats{"Number of files total"}++; + &filestats("$shift/$_"); + } + elsif ( -d "$shift/$_" ) + { + $stats{"Number of dirs total"}++; + &recursive("$shift/$_"); + } + } +} + +sub filestats +{ + my $shift = shift; + if ( $shift =~ /\.(cpp|h|tmpl)$/ ) + { + $stats{"Number of source files"}++; + $stats{"Lines of source"} += countlines($shift); + } + elsif ( $shift =~ /\.(html|css)$/ ) + { + $stats{"Number of HTML files"}++; + $stats{"Lines of HTML"} += countlines($shift); + } + elsif ( $shift =~ /\.(gif|png|jpg)$/ ) + { + $stats{"Number of gfx files"}++; + } + elsif ( $shift =~ /(\.pl|\.sh|configure.*|Makefile.*)$/ ) + { + $stats{"Number of script files"}++; + $stats{"Lines of scripts"} += countlines($shift); + } + elsif ( $shift =~ /(\.txt|README|INSTALL|COPYING|NEWS|SNAPSHOT|ChangeLog)$/ ) + { + $stats{"Number of text files"}++; + $stats{"Lines of text"} += countlines($shift); + } + elsif ( $shift =~ /\.so$/ ) + { + $stats{"Number of compiled module files"}++; + } +} + +sub countlines +{ + my $shift = shift; + my @file = fopen($shift); + return $#file; +} diff --git a/ychat-0.7.4.1/scripts/version.sh b/ychat-0.7.4.1/scripts/version.sh new file mode 100755 index 0000000..46b9fc5 --- /dev/null +++ b/ychat-0.7.4.1/scripts/version.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# The yChat Project (2005) +# +# This script shows yChat VERSION-BRANCH Build BUILDNUMBER + +version=`grep VERSION src/msgs.h | head -n 1 | cut -d'"' -f2` +branch=`grep BRANCH src/msgs.h | head -n 1 | cut -d'"' -f2` +build=`grep BUILD src/msgs.h | tail -n 1 | cut -d' ' -f3` +echo "yChat $version-$branch Build $build" + + |
