From 9cd3ccffd5372dfde3af478e3f832f18db4be3f1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:41 +0200 Subject: tagging tags --- ychat-0.7.2/scripts/README | 6 ++ ychat-0.7.2/scripts/buildnr.pl | 26 ++++++ ychat-0.7.2/scripts/config.sh | 152 ++++++++++++++++++++++++++++++++++++ ychat-0.7.2/scripts/makeyhttpd.pl | 133 +++++++++++++++++++++++++++++++ ychat-0.7.2/scripts/mergeconf.pl | 104 ++++++++++++++++++++++++ ychat-0.7.2/scripts/modules/file.pm | 28 +++++++ ychat-0.7.2/scripts/screen.sh | 3 + ychat-0.7.2/scripts/setglobvals.pl | 32 ++++++++ ychat-0.7.2/scripts/stats.pl | 97 +++++++++++++++++++++++ 9 files changed, 581 insertions(+) create mode 100644 ychat-0.7.2/scripts/README create mode 100755 ychat-0.7.2/scripts/buildnr.pl create mode 100755 ychat-0.7.2/scripts/config.sh create mode 100644 ychat-0.7.2/scripts/makeyhttpd.pl create mode 100755 ychat-0.7.2/scripts/mergeconf.pl create mode 100755 ychat-0.7.2/scripts/modules/file.pm create mode 100755 ychat-0.7.2/scripts/screen.sh create mode 100755 ychat-0.7.2/scripts/setglobvals.pl create mode 100755 ychat-0.7.2/scripts/stats.pl (limited to 'ychat-0.7.2/scripts') diff --git a/ychat-0.7.2/scripts/README b/ychat-0.7.2/scripts/README new file mode 100644 index 0000000..189b169 --- /dev/null +++ b/ychat-0.7.2/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.2/scripts/buildnr.pl b/ychat-0.7.2/scripts/buildnr.pl new file mode 100755 index 0000000..e691a11 --- /dev/null +++ b/ychat-0.7.2/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 = ; +close MSGS; + +foreach (@msgs) +{ + if ( /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.2/scripts/config.sh b/ychat-0.7.2/scripts/config.sh new file mode 100755 index 0000000..373fad4 --- /dev/null +++ b/ychat-0.7.2/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 <; + 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 = ; + 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 = ; + 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.2/scripts/makeyhttpd.pl b/ychat-0.7.2/scripts/makeyhttpd.pl new file mode 100644 index 0000000..2805360 --- /dev/null +++ b/ychat-0.7.2/scripts/makeyhttpd.pl @@ -0,0 +1,133 @@ +#!/usr/bin/perl + +# The yChat & yhttpd Project (2004) +# +# 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/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 "Deleting CVS directories\n"; +system("find . -name CVS | xargs rm -Rf"); + +print "Creating new dirs\n->"; +foreach (@createdir) { + print " $_"; + system("mkdir $_"); +} + +print "Renaming 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 !~ /\/\/<>/; + } + &fwrite($_, @newfile); + } elsif ( -d $_ ) { + &remove_marked_lines($_); + } + } + chdir('..'); +} + +print "\n"; + diff --git a/ychat-0.7.2/scripts/mergeconf.pl b/ychat-0.7.2/scripts/mergeconf.pl new file mode 100755 index 0000000..85e76cb --- /dev/null +++ b/ychat-0.7.2/scripts/mergeconf.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl + +# The yChat Project (2003) +# +# This script merges configuration files + +use strict; + +use scripts::modules::file; + +my @files = ('conf.txt','lang/en.txt','lang/de.txt'); + +foreach my $filename ( @files ) +{ + next if ( ! -f $filename || ! -f "$filename.old" ); + + print "=> Merge $filename\n"; + my @newoptions = &merge("$filename.old",$filename ); + if (defined $newoptions[0]) + { + print " => Modified $filename. Edit to set the new values [or leave standard]\n => New options are:"; + foreach (@newoptions) + { + print " $_"; + } + print "\n"; + } +} + +sub merge +{ + my ($oldfile,$newfile) = @_; + my @oldfile = fopen($oldfile); + my @newfile = fopen($newfile); + my %oldfile = get_options(@oldfile); + my %newfile = get_options(@newfile); + my @newoptions; + + foreach my $option (keys %newfile) + { + unless (defined $oldfile{$option}) + { + push @newoptions, $option; + my $_comment = $newfile{$option}[0]; + my $_value = $newfile{$option}[1]; + my $_comment_b = $newfile{$option}[2]; + my $_behind = $newfile{$option}[3]; + print " => Adding to $newfile\n => New option is $option\n" + ." => Adding it after option $_behind\n"; + + my $added = 0; + my $insert = $_comment . "$option=\"$_value\";$_comment_b\n"; + foreach (@oldfile) + { + if (/^$_behind.+$/) + { + $_ .= $insert; + $added = 1; + last; + } + } + if ( $added == 0 ) + { + print " => Adding new option at EOF\n"; + push @oldfile, $insert; + } + } + } + + &fwrite($newfile,@oldfile); + + return @newoptions; +} + +sub get_options +{ + my @file = @_; + my %options; + my $option_comment; + my $option_before = ''; + + foreach (@file) + { + if (/(^.+)="(.+)";(.*)/) + { + my $option = $1; + my $option_value = $2; + my $option_comment_behind = $3; + my @values = ($option_comment, + $option_value, + $option_comment_behind, + $option_before); + $options{$option} = \@values; + $option_comment = ''; + $option_before = $option; + } + else + { + $option_comment .= $_; + } + } + + return %options; +} diff --git a/ychat-0.7.2/scripts/modules/file.pm b/ychat-0.7.2/scripts/modules/file.pm new file mode 100755 index 0000000..b11e2b3 --- /dev/null +++ b/ychat-0.7.2/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 = ; + 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.2/scripts/screen.sh b/ychat-0.7.2/scripts/screen.sh new file mode 100755 index 0000000..6d5b7aa --- /dev/null +++ b/ychat-0.7.2/scripts/screen.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +screen -S ychat ./bin/ychat diff --git a/ychat-0.7.2/scripts/setglobvals.pl b/ychat-0.7.2/scripts/setglobvals.pl new file mode 100755 index 0000000..13288a5 --- /dev/null +++ b/ychat-0.7.2/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.2/scripts/stats.pl b/ychat-0.7.2/scripts/stats.pl new file mode 100755 index 0000000..38cc67c --- /dev/null +++ b/ychat-0.7.2/scripts/stats.pl @@ -0,0 +1,97 @@ +#!/usr/bin/perl + +# The yChat Project (2003 - 2004) +# +# This script generates source code and project statistics + +use strict; + +use scripts::modules::file; + +my %stats; + +&recursive("."); + +$stats{"Lines total"} = $stats{"Lines of source"} + + $stats{"Lines of scripts"} + + $stats{"Lines of text"} + + $stats{"Lines of HTML"}; + +my $bool = 0; +foreach ( sort keys %stats ) +{ + if ($bool == 0) + { + print "$_ = " . $stats{$_} . "\n"; + $bool = 1; + } + else + { + print "$_ = " . $stats{$_} . "\n"; + $bool = 0; + } +} + +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; +} -- cgit v1.2.3