#!/usr/bin/perl -w # The ToME Stepladder Project # (c) 2004 Scott Bigham # Distributed under the GNU General Public License (below). =pod =head1 NAME stepladder - The ToME Stepladder Project =head1 SYNTAX stepladder init stepladder add_dump [retire] [] stepladder add_comment [] stepladder add_screenshot [] [<descr-file|+>] stepladder add_cmovie <tag> <cmov-file> [<title>] [<descr-file|+>] stepladder add_extra <tag> [all] <dest-base> <title> <descr-line> stepladder link_ladder <tag> <num> stepladder touch [force] [all | <tag> [<tag> ...]] =head1 DESCRIPTION The C<stepladder> program implements the ToME Stepladder Project, a utility for creating and maintaining a "mini-ladder" of current and previous character dumps from the computer game ToME (C<http://www.t-o-m-e.net>). Note that C<stepladder> is not a CGI script; it maintains and updates a collection of static HTML files. There is no Web-side interface for adding characters or comments; all such modifications are made from the command line with this program. The file structure generated by C<stepladder> is designed around the author's ToME play style: playing multiple incarnations of a particular race/subrace/class combination (or a few combinations... or more than a few.. C<:-}>), starting a new instance each time it dies. Thus, files will be organized into one or more character directories, each containing dumps for one or more incarnations of the associated character (one of which, the "current" incarnation, will be listed in the main character index) and a "lineage" list linking to all the incarnations. The directory name will typically be the same as the identifying tag used with ToME's C<-u> option to load the character, and hence will typically be referred to herein as the character's 'tag'. Separate directories for screenshots, cmovies and other files are shared among all characters. =head1 INSTALLATION Since this is just a utility program rather than a CGI script, you don't really have to install it anywhere in particular. There are, however, a few variables whose values you will want to customize for your site; these are listed below this documentation. =head1 COMMANDS =over 4 =item C<init> Creates the base directory for all C<stepladder>-generated files (as specified by the $BASE_DIR variable below) and the shared screenshot, cmovie and extra files subdirectories thereof. =item C<add_dump E<lt>tagE<gt> [retire] E<lt>dump-fileE<gt> [E<lt>comment-file|+E<gt>]> Add a character dump, with an optional associated comment. I<tag> is the tag for this character; a new character directory will be created if necessary. Normally, the dump file specified will replace the current dump for the current incarnation of this character; if said dump is of a winner or a dead character, you will be prompted to retire this character and start a new current incarnation with the given dump (you can also retire a character with the 'C<retire>' option, as specified above). I<comment-file> is a text file containing a comment associated with this dump. If the name is given as 'C<+>', a text editor (as specified by the $EDITOR variable below) will be started on a temporary file for you to enter a comment; if no name is give, you will be prompted to enter a comment directly. =item C<add_comment E<lt>tagE<gt> [E<lt>comment-file|+E<gt>]> Add a comment to the dump of the current incarnation of the specified character. The I<comment-file> and 'C<+>' options are used in the same way as in C<add_dump>. =item C<add_screenshot E<lt>tagE<gt> E<lt>scrn-fileE<gt> [E<lt>titleE<gt>] [E<lt>comment-file|+E<gt>]> Add an associated screenshot (as generated by the in-game ToME command 'C<^]>') to the dump of the current incarnation of the specified character, with a title and optional comment. The I<comment-file> and 'C<+>' options are used in the same way as in C<add_dump>. =item C<add_cmovie E<lt>tagE<gt> E<lt>cmov-fileE<gt> [E<lt>titleE<gt>] [E<lt>comment-file|+E<gt>]> Add an associated cmovie (as generated by the in-game ToME command 'C<|>') to the dump of the current incarnation of the specified character, with a title and optional comment. The I<comment-file> and 'C<+>' options are used in the same way as in C<add_dump>. You will need to separately download the Java cmovie player used by the Angband Ladder (C<http://angband.oook.cz/cmovie.jar>) and place it in the C<cmov/> subdirectory of your ladder directory. [This player was written by C<magua@speakeasy.net>, who has made it available to use freely, provided its credits are retained; see C<http://www.t-o-m-e.net/forum/viewtopic.php?p=24520#24520>.] =item C<add_extra E<lt>tagE<gt> [all] E<lt>dest-baseE<gt> E<lt>titleE<gt> E<lt>descr-lineE<gt>> Added an associated file of unspecified type to the dump of the current incarnation of the specified character, with a title and description line. If the 'C<all>' option is specified, this file will be associated with all incarnations of this character. This command is intended for general character-related information generated from outside the game itself --- a drawing or story about the character, for instance. Since the type of information is not known in advance, only minimal management can be done automatically. An HTML template file named C<I<dest-base>.html> is generated in the C<xtra/> subdirectory of your ladder directory; you will need to edit this file to add the desired information, as appropriate. I<descr-line> is a short one-line description of the file, which will appear alongside the title in the global extra files list and in the associated-links listing in the character dump. This is different from the longer descriptions provided to C<add_screenshot> and C<add_cmovie>; if you want something like that, you can add it to the template file manually. =item C<link_ladder E<lt>tagE<gt> E<lt>numE<gt>> If your character is also on the Angband Ladder (C<http://angband.oook.cz/ladder.php>), you can include a link to the Ladder dump in the Stepladder entry for your character with this command. The URL for the ladder dump should look like "C<http://angband.oook.cz/ladder-show.php?id=NNNN>"; the number C<NNNN> is what you want to use for the I<num> argument of this command. Note that Ladder dump links follow a particular incarnation of the character; if you overwrite the Ladder dump of a retired character with a dump of a new character under the same name, you'll have to repeat this command to link the Ladder dump to the new Stepladder incarnation (or rename the underlying file containing the link information). =item C<touch [force] [all | E<lt>tagE<gt> [E<lt>tagE<gt> ...]]> Updates or recreates various generated HTML files that are missing or out of date. Automatically performed internally by all the other commands (except C<init>, since there's nothing to update then anyway...); typically you will only need to do this when you have manually modified one of the underlying data files outside of C<stepladder>'s control. C<touch> updates the main list of current characters, the indexes of the screenshot, cmovie and extra files directories, and the lineage file and all dumps of all specified characters; specifying 'C<all>' will cause all characters to be udpated. The C<force> option causes all selected HTML files to be regenerated, whether they're out of date or not. =back =item TODO Potential future plans for the ToME Stepladder Project include: =over 4 =item More interesting layout; the author, alas, is not an artist... =item Possibly an interface to upload files to whatever webhosting arrangement the user has. Not likely, though; too many permutations. =back =head1 LICENSE The ToME Stepladder Project (c) 2004 Scott Bigham This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. There should be a copy of the GNU General Public License attached to the end of this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =head1 SEE ALSO =over 4 =item ToME: Tales of Middle Earth: E<lt>C<http://www.t-o-m-e.net/>E<gt> =item The Angband Ladder: E<lt>C<http://angband.oook.cz/>E<gt> =item The ToME Stepladder Project: E<lt>C<http://www.killerbunnies.org/angband/tome-stepladder.pl>E<gt> =item Other ToME-related material: E<lt>C<http://www.killerbunnies.org/angband/#tome>E<gt> =back =head1 DISCLAIMER The ToME Stepladder Project is in no way associated with the Angband Ladder, beyond shamelessly cribbing^W^W drawing inspiration from their page layouts. =cut # Changelog: # # 2006-04-08: # Fixed an HTML-generation bug in the extra-files output. # 2005-08-14: # Adjusted dump parsing for changes in the 2.3.x character sheet. # # 2005-03-18: # Adjusted dump parsing for new versions that have "Character Sheet" # instead of "Character Dump" in the first line of the dump. # # 2004-07-04: # New command 'add_extra' to add additional files like stories or # drawings associated with a character. # # 2004-02-15: # Adjusted dump parsing to account for dead Necromancers with "Max Death # Points" in the dump. # # 2004-02-12: # - Tweaks to gen_screenshot_html() to accommodate differences in HTML # dump file format between 2.1.x and 2.2.x. # - Add credits mention to the docs for the add_cmovie command (and take # out the bit that says cmovies aren't implemented). # # 2004-02-01: # Preliminary cmovie support. # # 2004-01-31: # Initial release. use strict; use vars qw(@all_screen @all_cmov @all_xtra); use File::Path; use File::Copy; use POSIX qw(strftime); # Stuff to customize for your site: # The base directory, where all the files live. my $BASE_DIR = "$ENV{HOME}/ladder"; # The editor to use when entering comments. my $EDITOR = $ENV{EDITOR} || 'vi'; # The name to go in the "ToME Stepladder" title, in possessive form. my $TITLE_MY = 'My'; # The name that should appear in page copyright statements. my $COPYRIGHT_NAME = 'Unknown Person'; # An intro paragraph put at the top of the main page. my $intro = <<HTML; Welcome to $TITLE_MY ToME Stepladder. The maintainer of this stepladder apparently has not customized her installation of The ToME Stepladder Project, which is unlikely to be a good thing. HTML # General global variables. my %current = (); # Index of current dumps in character dirs. my $copy_yr_range = 'DUMMY'; # Year range of files in base directory. @all_screen = (); # Cache of global screenshot list. @all_cmov = (); # Cache of global cmovie list. @all_xtra = (); # Cache of extra files list. # Assorted boilerplate HTML pieces. my $CSS = <<HTML; <STYLE TYPE="text/css"> HTML { font-family: Tahoma, Verdana, helvetica, sans-serif; font-size: 10pt; } BODY { margin: 0.5em; color: black; background-color: #d8a86a; } DIV.content { color: black; background-color: #f8ffd0; border-width: medium; border-color: black; padding: 0.5em; } H1 { font-family: Verdana, Tahoma, helvetica, sans-serif; font-size: 150%; font-weight: bold; text-align: center; } H2 { font-family: Verdana, Tahoma, helvetica, sans-serif; font-size: 120%; font-weight: bold; } TABLE,TR,TD { font-size: 100%; } TABLE.grid TH, TABLE.key TH { font-weight: bold; text-align: center; background-color: #d8a86a; } TABLE.grid, TABLE.key { margin-top: 1em; margin-bottom: 1em; } TABLE.key { font-size: 80%; } TABLE.grid TR.winner, TABLE.key TD.winner { background-color: #d4ffb0; } TABLE.grid TR.dead, TABLE.key TD.dead { background-color: #f8ffa0; } PRE.dump { font-family: Courier, Andale, 'Andale mono', misc-fixed, monospace; color: black; background-color: white; } PRE.screen { font-family: Courier, Andale, 'Andale mono', 'misc-fixed', monospace; font-size: 110%; color: white; background-color: black; } P.comment { font-size: 80%; } SPAN.name { color: blue; } SPAN.comment { color: darkgreen; } </STYLE> HTML my $PROJ_URL = 'http://www.killerbunnies.org/angband/tome-stepladder.pl'; my $DISCLAIMER = <<HTML; <P> <SMALL>All contents of this site are copyright © $copy_yr_range $COPYRIGHT_NAME, unless otherwise indicated.</SMALL> <P> <SMALL>The <A HREF="$PROJ_URL">ToME Stepladder Project</A> is in no way associated with <A HREF="http://angband.oook.cz/ladder.php">The Angband Ladder</A>, beyond <DEL>shamelessly cribbing</DEL> drawing inspiration from their page layouts. $TITLE_MY ToME Stepladder is not associated with either, beyond using the former's code to generate pages.</SMALL> HTML my $TABLE_COLS = <<HTML; <TR> <TH>Name</TH> <TH>Race/class</TH> <TH>Level</TH> <TH>Experience</TH> <TH>Module, version</TH> <TH>Last update</TH> <TH>Last comment</TH> </TR> HTML my $TABLE_KEY = <<HTML; <TABLE CLASS="key" ALIGN=CENTER BORDER=1> <TR> <TH COLSPAN=3>Key:</TH> </TR> <TR> <TD CLASS="winner">winner</TD> <TD>alive</TD> <TD CLASS="dead">dead</TD> </TR> </TABLE> HTML # by_level_desc() -- Sorts character dumps in decreasing order of level and # experience. sub by_level_desc { return $$b{level} <=> $$a{level} || $$b{exper} <=> $$a{exper} || $$b{name} <=> $$a{name}; } # by_lineage_desc() -- Sorts character dumps in reverse posting order. sub by_lineage_desc () { return $$b{subtag} <=> $$a{subtag}; } # yesno() -- Prints a provided question and gets a y/n response from the # user. sub yesno ($) { my $prompt = $_[0]; print STDERR "$prompt "; local $_ = <STDIN>; return /^[Yy]/ ? 1 : 0; } # prompt() -- Prints a provided question and gets a text response from the # user. sub prompt ($) { my $prompt = $_[0]; print STDERR "$prompt: "; local $_ = <STDIN>; chomp; return $_; } # get_input_lines() -- Get one or more lines from the user by way of # standard input, a specified file, or a temporary file edited by the # user's preferred editor. sub get_input_lines ($;$); sub get_input_lines ($;$) { my ($file, $discard_eol) = @_; my @lines; if (!$file) { # Read from stdin. print STDERR "Enter comment, followed by ^D at start of line.\n"; print STDERR "Enter a single line containing just '+' to enter the editor\n"; while (<STDIN>) { chomp if $discard_eol; push @lines, $_; } return get_input_lines '+' if $#lines == 0 && $lines[0] =~ /^\+$/m; return @lines; } my $unlink_tmp = 0; if ($file eq '+') { # Fire up the editor to create a temp file. $file = "/tmp/stepladder-$$"; system("$EDITOR $file") == 0 or die "$EDITOR $file failed: $?\n"; return () if ! -e $file; $unlink_tmp = 1; } # Now read the file, either specified or temporary. open IN, "<$file" or die "Cannot read ${file}: $!\n"; while (<IN>) { chomp if $discard_eol; push @lines, $_; } close IN; unlink $file if $unlink_tmp; # Strip off leading and trailing blank lines, and collapse multiple blank # lines into a single blank line. shift @lines while $#lines >= 0 && !$lines[0]; pop @lines while $#lines >= 0 && !$lines[-1]; for (my $i = 0; $i < $#lines; $i++) { splice @lines, $i--, 1 if !$lines[$i] && !$lines[$i+1]; } return @lines; } # get_current_tag() -- Read the index of the current dump for the specified # character from the corresponding current.tag file. sub get_current_tag ($;$) { local $_; my ($tag, $die_if_absent) = @_; if (open IN, "$BASE_DIR/$tag/current.tag") { $_ = <IN>; close IN; chomp; return $_; } elsif ($die_if_absent) { die "Cannot read $BASE_DIR/$tag/current.tag: $!\n"; } else { return undef; } } # write_current_tag() -- Write a new dump index value to the specified # character's current.tag file. sub write_current_tag ($$) { my ($tag, $current) = @_; open OUT, ">$BASE_DIR/$tag/current.tag" or die "Cannot write $BASE_DIR/$tag/current.tag: $!\n"; print OUT "$current\n"; close OUT; } # get_char_dirs() -- Read in a list of all character directories (that is, # all directories containing a current.tag file), and store them in a hash # with their corresponding current dump indexes. sub get_char_dirs () { opendir DIR, $BASE_DIR or die "opendir($BASE_DIR) failed: $!\n"; my @ls = readdir DIR; closedir DIR; my @dirs = grep { -d "$BASE_DIR/$_" && -e "$BASE_DIR/$_/current.tag" } @ls; for my $tag (@dirs) { $current{$tag} = get_current_tag $tag, 1 } } # get_copyright_range() -- Check the dates of all files in the ladder # directory and compute a year range covering all of them, for use in the # copyright statement at the bottom of the page. sub get_copyright_range (;$); sub get_copyright_range (;$) { my $dir = $_[0] || $BASE_DIR; my $Max = strftime '%Y', localtime time; my $Min = undef; opendir DIR, $dir or die "opendir($dir) failed: $!\n"; my @files = readdir DIR; closedir DIR; for my $file (@files) { my $File = "$dir/$file"; my ($min, $max); if (-d $File) { # For subdirectories, we call ourself recursively to get the max and # min year for said directory's contents. Watch out for the '.' and # '..' placeholders, though... next if $file eq '.' || $file eq '..'; ($min, $max) = get_copyright_range $File; } else { next if $file eq 'cmovie.jar'; my $tz = (stat $File)[9]; $min = $max = strftime '%Y', localtime $tz; } $Min = $min if !$Min || $min < $Min; $Max = $max if !$Max || $max > $Max; } $Min ||= $Max; return ($Min, $Max) if $_[0]; # Since the disclaimer text was interpolated before this variable had a # meaningful value, we have to put it in manually. my $dummy = $copy_yr_range; $copy_yr_range = ($Min eq $Max ? $Max : "$Min-$Max"); $DISCLAIMER =~ s/$dummy/$copy_yr_range/; } # load_file_list() -- Read a list of tab-separated auxiliary file # specifications from the specified file. Returns a list of hash refs # describing the aux files. sub load_file_list ($;$) { local $_; my ($file, $pfx) = @_; my @ret = (); # If a prefix is specified, there will be four fields in the line; the # filename will be synthesized from the prefix and the index into the # list. If no prefix is given, there will be six fields; the extra two # fields are the actual filename and a short description of the file. my $nf = (!$pfx ? 6 : 4); open IN, "<$file" or return (); while (<IN>) { chomp; my @F = split /\t/, $_; my $n = scalar @F; my %entry = (); warn "Possible malformed entry '$_' in $file" . " (expected $nf records, found $n)\n" if $n != $nf; @entry{qw(title tag subtag timestamp)} = @F[0..3]; if ($pfx) { $entry{file} = "$pfx${\(2+$#ret)}.html"; } else { @entry{qw(file description)} = @F[4..5]; } push @ret, \%entry; } return @ret; } # match_file_list() -- Return a list of all aux file entries in the given # list that are associated with a particular character dump, specified by # tag and subtag. sub match_file_list (\@$$) { my ($list, $tag, $subtag) = @_; my @ret = (); for my $entry (@$list) { push @ret, { %$entry } if $$entry{tag} eq $tag && ($$entry{subtag} eq $subtag || $$entry{subtag} eq '*'); } return @ret; } # read_dump() -- Read and parse information from a ToME character dump # file. The provided tag and subtag identify the dump within the # stepladder system. sub read_dump ($$;$) { local $_; my ($tag, $subtag, $dump_file) = @_; if ($dump_file) { # If the tag and subtag aren't specified, try to back them out of the # filename. if ($dump_file =~ m#^$BASE_DIR/([^/]+)/\1_(.+)\.txt$#) { $tag ||= $1; $subtag ||= $2; } else { die "Missing dir or subtag for dump file '$dump_file'\n" if !$tag || !$subtag; } } else { # If the filename isn't specified, bulid it from the tag and subtag. $subtag = $current{$tag} if $subtag eq 'current'; $dump_file = "$BASE_DIR/$tag/${tag}_$subtag.txt"; } my @lines = (); my @comments = (); my @cmt_lines = (); my %data = ( tag => $tag, subtag => $subtag, lines => \@lines, comments => \@comments, inline_comments => \@cmt_lines ); my $comment_file = "$BASE_DIR/$tag/${tag}_$subtag.cmt"; my $link_file = "$BASE_DIR/$tag/${tag}_$subtag.ldr"; stat $dump_file or die "Cannot stat ${dump_file}: $!\n"; my $tz = (stat(_))[9]; $data{lastmod} = strftime '%Y-%m-%d %l:%M%P %Z', localtime $tz; # The dump file has to be there, and it has to be a character sheet. open IN, "<$dump_file" or die "Cannot read ${dump_file}: $!\n"; $_ = <IN>; chomp; die "$dump_file does not appear to be a ToME character sheet\n" unless /\[(\S.*\S) (\S+) Character (?:Dump|Sheet)\]/; @data{qw(module version)} = ($1, $2); push @lines, $_; while (<IN>) { chomp; # Find all the lines on which dump comments begin or end. In the HTML # dump, we'll patch in appropriate <SPAN> markup around these. push @cmt_lines, [ 1+$#lines, 1+$#lines ] if m[^//] && ($#lines < 0 || $lines[-1] !~ m[^//]); $cmt_lines[-1][1] = $#lines if !m[^//] && $#lines >= 0 && $lines[-1] =~ m[^//]; # Extract useful information. $data{name} = $1 if /Name : (\S.*\S)\s+Age\s+\d+/; $data{race} = $1 if /Race : (\S.*\S)\s+Weight\s+\d+/; $data{class} = $1 if /Class : (\S.*\S)\s+Social Class\s+\d+/; $data{level} = $1 if /Level\s+(\d+)\s+(?:Max|Hit|Death)/; $data{exper} = $1 if /Experience\s+(\d+)\s+(?:Cur|Spell)/; $data{state} = 'winner' if /You saved Arda and became a famed/; $data{state} = 'dead' if /You are dead/; push @lines, $_; } close IN; if (-e $comment_file) { # Load the comments associated with this dump. my $comment = undef; open IN, "<$comment_file" or die "Cannot read ${comment_file}: $!\n"; while (<IN>) { chomp; if (/^-#- (.*)$/) { push @comments, $comment if $comment; $comment = { timestamp => $1, lines => [] }; } else { s/^\s*(.*)\s*$/$1/; push @{$$comment{lines}}, $_; } } close IN; push @comments, $comment if $comment; } # Get all the screenshots associated with this dump. We patch in the # link field for later processing. my @scrn = match_file_list @all_screen, $data{tag}, $data{subtag}; if (scalar @scrn > 0) { for (@scrn) { $$_{link} = "../screen/$$_{file}" } $data{screenshots} = \@scrn; } # Similarly for cmovies associated with the dump. my @cmov = match_file_list @all_cmov, $data{tag}, $data{subtag}; if (scalar @cmov > 0) { for (@cmov) { $$_{link} = "../cmov/$$_{file}" } $data{cmovies} = \@cmov; } # And for additional files associated with the dump. my @xtra = match_file_list @all_xtra, $data{tag}, $data{subtag}; if (scalar @xtra > 0) { for (@xtra) { $$_{link} = "../xtra/$$_{file}" } $data{extras} = \@xtra; } if (-e $link_file) { # Check for a ladder link. open IN, "<$link_file" or die "Cannot read ${link_file}: $!\n"; my $link = <IN>; close IN; chomp $link; $data{ladder_link} = $link; } # And we're done. return \%data; } # write_dump_txt() -- Writes the dump file in text form to the standard # location for the dump's tag and subtag. Should generate a file identical # to the originally loaded dump file. sub write_dump_txt ($) { my $data = $_[0]; my $dump_file = "$BASE_DIR/$$data{tag}/$$data{tag}_$$data{subtag}.txt"; open OUT, ">$dump_file" or die "Cannot write ${dump_file}: $!\n"; for (@{$$data{lines}}) { print OUT "$_\n" } close OUT; } # write_dump_html() -- Writes the dump file in HTMl form to the standard # location for the dump's tag and subtag. sub write_dump_html ($) { my $data = $_[0]; my $dump_file = "$BASE_DIR/$$data{tag}/$$data{tag}_$$data{subtag}.html"; my %cmt_start = map { ($$_[0] => 1) } @{$$data{inline_comments}}; my %cmt_end = map { ($$_[1] => 1) } @{$$data{inline_comments}}; open OUT, ">$dump_file" or die "Cannot write ${dump_file}: $!\n"; print OUT <<HTML; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <TITLE>$TITLE_MY ToME Stepladder: $$data{name} $CSS

$TITLE_MY ToME Stepladder

$$data{name}, the $$data{race} $$data{class}

HTML print OUT "
";
  for my $n (0..$#{$$data{lines}}) {
    my $line = $$data{lines}[$n];
    $line = ''.$line if exists $cmt_start{$n};
    $line .= '' if exists $cmt_end{$n};
    print OUT "$line\n";
  }
  print OUT <

Last updated $$data{lastmod}

  • Download this dump
  • Lineage of $$data{name}
  • All current characters HTML if (exists $$data{ladder_link}) { my $link = "http://angband.oook.cz/ladder-show.php?id=$$data{ladder_link}"; print OUT < $$data{name} on the Angband Ladder HTML } if (exists $$data{screenshots}) { print OUT "
  • Screenshots for this character:\n
      \n"; for my $scrn (@{$$data{screenshots}}) { print OUT "
    • $$scrn{title}\n"; } print OUT "
    \n"; } if (exists $$data{cmovies}) { print OUT "
  • Cmovies for this character:\n
      \n"; for my $cmov (@{$$data{cmovies}}) { print OUT "
    • $$cmov{title}\n"; } print OUT "
    \n"; } if (exists $$data{extras}) { print OUT "
  • Additional information related to this character:\n" . "
      \n"; for my $xtra (@{$$data{extras}}) { print OUT "
    • $$xtra{title}: " . "$$xtra{description}\n"; } print OUT "
    \n"; } print OUT <

    Comments

    HTML print "

    There are no comments for this dump.\n" if scalar @{$$data{comments}} == 0; for my $comment (@{$$data{comments}}) { print OUT "

    $$comment{timestamp}:
    \n"; for (@{$$comment{lines}}) { print OUT "$_\n" if $_; print OUT "

    \n" if !$_; } } print OUT <

$DISCLAIMER HTML close IN; } # write_table_row() -- Writes a row of the main character table or # character lineage table corresponding to the given dump. The optional # parameter specifies the table type. Assumes that the filehandle OUT is # open for writing to the HTML file being created. sub write_table_row ($;$) { my ($dump, $lineage) = @_; my $row_class = (exists $$dump{state} ? " CLASS=\"$$dump{state}\"" : ''); my $comments = $$dump{comments}; my $last_cmt = ($#$comments >= 0 ? $$comments[-1]{timestamp} : 'none'); my $link = "$$dump{tag}_$$dump{subtag}.html"; $link = "$$dump{tag}/$link" if !$lineage; print OUT < $$dump{name} $$dump{race} $$dump{class} $$dump{level} $$dump{exper} $$dump{module} $$dump{version} $$dump{lastmod} $last_cmt HTML } # write_main_table() -- Writes the main HTML page listing all current # characters. sub write_main_table () { my @dumps = sort by_level_desc map { read_dump $_, 'current' } keys %current; my $has_screens = -e "$BASE_DIR/screen/index.html"; my $has_cmov = -e "$BASE_DIR/cmov/index.html"; my $has_xtra = -e "$BASE_DIR/xtra/index.html"; open OUT, ">$BASE_DIR/index.html" or die "Cannot write $BASE_DIR/index.html: $!\n"; print OUT < $TITLE_MY ToME Stepladder $CSS

$TITLE_MY ToME Stepladder

HTML print OUT "

\n$INTRO\n" if $INTRO; print OUT < $TABLE_COLS HTML for my $dump (@dumps) { write_table_row $dump } print OUT "\n"; if ($has_screens || $has_cmov) { print OUT "

\nCharacter-related data:\n

\n"; } print OUT < $DISCLAIMER HTML close OUT; } # write_lineage_table() -- Writes the lineage page for the character group # specified by the given tag. sub write_lineage_table ($) { my $tag = $_[0]; my @dumps = sort by_lineage_desc map { read_dump undef, undef, $_ } glob "$BASE_DIR/$tag/${tag}_*.txt"; die "No dumps in char directory '$tag'?\n" if scalar @dumps == 0; die "Newest '$tag' dump isn't current dump?" . " ($current{$tag} vs. $dumps[0]{subtag})\n" if $current{$tag} ne $dumps[0]{subtag}; my $cur_dump_link = "${tag}_$current{$tag}.html"; open OUT, ">$BASE_DIR/$tag/index.html" or die "Cannot write $BASE_DIR/$tag/index.html: $!\n"; print OUT < $TITLE_MY ToME Stepladder: Lineage of $dumps[0]{name} $CSS

$TITLE_MY ToME Stepladder: Lineage of $dumps[0]{name}

$TABLE_COLS HTML for my $dump (sort by_lineage_desc @dumps) { write_table_row $dump, 1 } print OUT < $TABLE_KEY $DISCLAIMER HTML close OUT; } # write_file_table() -- writes an index page for a given type of auxiliary # data, identified by the given prefix. sub write_file_table ($$) { my ($pfx, $sec_title) = @_; my @list; { no strict 'refs'; @list = reverse @{"main::all_$pfx"}; } return if scalar @list == 0; my $table = "$BASE_DIR/$pfx/index.html"; my $DESC = (exists $list[0]{description} ? "\n" : ''); open OUT, ">$table" or die "Cannot write ${table}: $!\n"; print OUT < $TITLE_MY ToME Stepladder, $sec_title $CSS

$TITLE_MY ToME Stepladder

$sec_title

Description
$DESC HTML for my $entry (@list) { my $subtag = $$entry{subtag}; $subtag = $current{$$entry{tag}} if $subtag eq '*'; my $dump = read_dump $$entry{tag}, $subtag; my $dump_link = "../$$entry{tag}/$$entry{tag}_$subtag.html"; $DESC = "\n" if exists $$entry{description}; print OUT < $DESC HTML } print OUT < $DISCLAIMER HTML close OUT; } # gen_screenshot_html() -- Writes an HTML page containing the screenshot # from the given file. The screenshot HTML document in it original form is # not kept in the ladder directory tree. sub gen_screenshot_html ($$$$$) { local $_; my ($in_file, $title, $dump, $comment_file, $timestamp) = @_; my $dump_link = "../$$dump{tag}/$$dump{tag}_$$dump{subtag}.html"; my $idx = scalar @all_screen + 1; my $dest_html = "$BASE_DIR/screen/screen$idx.html"; open OUT, ">$dest_html" or die "Cannot write to ${dest_html}: $!\n"; print OUT < $TITLE_MY ToME Stepladder, Screenshot Gallery: $title $CSS

$TITLE_MY ToME Stepladder

Screenshot Gallery: $title

Associated character: $$dump{name}

TitleCharacter Added
$$entry{description}$$entry{title}$$dump{name} $$entry{timestamp}
HTML open IN, "<$in_file" or die "Cannot read ${in_file}: $!\n"; while () { last if /
//;
  s/]*>/
/i;
  print OUT $_;
  while () { last if /<\/PRE>/i; print OUT $_ }
  close IN;

  my $close_FONT = (/<\/FONT>/i ? '' : '');
  print OUT <

See all screenshots

Comment:

$timestamp
HTML my @lines = get_input_lines $comment_file; for (@lines) { s/^\s*(.*)\s*$/$1/; print OUT "$_\n" if $_; print OUT "

\n" if !$_; } close IN; print OUT <

$DISCLAIMER HTML close OUT; } # gen_cmovie_html() -- Writes an HTML page containing the given cmovie. # Also copies the cmovie to its final location in the cmov/ subdirectory. sub gen_cmovie_html ($$$$$) { local $_; my ($cmov_file, $title, $dump, $comment_file, $timestamp) = @_; my $dump_link = "../$$dump{tag}/$$dump{tag}_$$dump{subtag}.html"; my $idx = scalar @all_cmov + 1; my $dest_html = "$BASE_DIR/cmov/cmov$idx.html"; my $sfx = ($cmov_file =~ /\.gz$/ ? '.gz' : ''); my $dest_cmov_base = "cmov$idx.cmv$sfx"; my $dest_cmov = "$BASE_DIR/cmov/$dest_cmov_base"; my $PLYR_CVS_URL = 'http://angband.oook.cz/cgi-bin/cvsweb.cgi/cmovie_applet/?cvsroot=tome'; copy $cmov_file, $dest_cmov or die "Cannot copy $cmov_file to ${dest_cmov}: $!\n"; open OUT, ">$dest_html" or die "Cannot write to ${dest_html}: $!\n"; print OUT < $TITLE_MY ToME Stepladder, Cmovie Repository: $title $CSS

$TITLE_MY ToME Stepladder

Cmovie Repository: $title

Associated character: $$dump{name}

Java cmovie player written by magua\@speakeasy.net

  • Download this cmovie
  • See all cmovies

    Comment:

    $timestamp
    HTML my @lines = get_input_lines $comment_file; for (@lines) { s/^\s*(.*)\s*$/$1/; print OUT "$_\n" if $_; print OUT "

    \n" if !$_; } close IN; print OUT <

$DISCLAIMER HTML close OUT; } # gen_xtra_html_tmpl() -- Writes an HTML template page for the user to add # extra character information. sub gen_xtra_html_tmpl ($$$$$) { my ($basename, $title, $descr, $dump, $timestamp) = @_; my $dump_link = "../$$dump{tag}/"; my $dest_html = "$BASE_DIR/xtra/$basename.html"; open OUT, ">$dest_html" or die "Cannot write to ${dest_html}: $!\n"; print OUT < $TITLE_MY ToME Stepladder: $title $CSS

$TITLE_MY ToME Stepladder

$title: $descr

Associated character: $$dump{name}

$DISCLAIMER HTML } # The commands: # cmd_init() -- Implements the 'init' command. sub cmd_init (@) { my @dirs = ($BASE_DIR, "$BASE_DIR/screen", "$BASE_DIR/cmov", "$BASE_DIR/xtra"); mkpath \@dirs, 1, 0755; } # cmd_touch() -- Implements the 'touch' command. sub cmd_touch (@); sub cmd_touch (@) { # Catch the 'force' option. my $force = (scalar @_ > 0 && $_[0] eq 'force'); shift @_ if $force; # Catch the 'all' tag, to touch all characters. if (scalar @_ > 0 && $_[0] eq 'all') { my @all = keys %current; unshift @all, 'force' if $force; cmd_touch @all; return; } # Touch all specified characters. for my $tag (@_) { warn "No character directory '$tag'\n" and next unless exists $current{$tag}; # Update the current-dump index. my $current = get_current_tag $tag; if (!$current || $current < $current{$tag}) { write_current_tag $tag, $current{$tag}; } my $lineage_table = "$BASE_DIR/$tag/index.html"; my $touch_lineage = $force || ! -e $lineage_table; for my $subtag (1..$current{$tag}) { my $dump_txt = "$BASE_DIR/$tag/${tag}_$subtag.txt"; my $dump_html = "$BASE_DIR/$tag/${tag}_$subtag.html"; my $comment_file = "$BASE_DIR/$tag/${tag}_$subtag.cmt"; my $link_file = "$BASE_DIR/$tag/${tag}_$subtag.ldr"; warn "No such dump file '$dump_txt'\n" and next unless -e $dump_txt; # The HTML dump needs to be regenerated if it doesn't exist, or if # it's older than the text dump, the comments file, or any associated # auxiliary file. my $touch_dump = ($force || ! -e $dump_html || -M $dump_txt < -M $dump_html || (-e $comment_file && -M $comment_file < -M $dump_html) || (-e $link_file && -M $link_file < -M $dump_html)); for (match_file_list @all_screen, $tag, $subtag) { my $scrn_file = "$BASE_DIR/screen/$$_{file}"; $touch_dump ||= (-M $scrn_file < -M $dump_html); } for (match_file_list @all_cmov, $tag, $subtag) { my $cmov_file = "$BASE_DIR/cmov/$$_{file}"; $touch_dump ||= (-M $cmov_file < -M $dump_html); } for (match_file_list @all_xtra, $tag, $subtag) { my $xtra_file = "$BASE_DIR/xtra/$$_{file}"; $touch_dump ||= (-M $xtra_file < -M $dump_html); } if ($touch_dump) { my $dump = read_dump $tag, $subtag; write_dump_html $dump; } # The lineage file for this character needs to be regenerated if it # doesn't exist or if it's older than any of the HTML dumps. $touch_lineage ||= (-M $dump_html < -M $lineage_table); } write_lineage_table $tag if $touch_lineage; } # The screenshot index needs to be updated if it doesn't exist or if it's # older than the screenshot list file. my $scrn_list = "$BASE_DIR/screen/list"; my $scrn_table = "$BASE_DIR/screen/index.html"; if ($force || -e $scrn_list && (! -e $scrn_table || -M $scrn_list < -M $scrn_table)) { write_file_table 'screen', 'Screenshot Gallery'; } # Similarly for the cmovie index. my $cmov_list = "$BASE_DIR/cmov/list"; my $cmov_table = "$BASE_DIR/cmov/index.html"; if ($force || -e $cmov_list && (! -e $cmov_table || -M $cmov_list < -M $cmov_table)) { write_file_table 'cmov', 'Cmovie Repository'; } # And for the extra files index. my $xtra_list = "$BASE_DIR/xtra/list"; my $xtra_table = "$BASE_DIR/xtra/index.html"; if ($force || -e $xtra_list && (! -e $xtra_table || -M $xtra_list < -M $xtra_table)) { write_file_table 'xtra', 'Additional character-related information'; } # The main table needs to be regenerated if it doesn't exist, or if it's # older than any of the current HTML dumps or any of the auxiliary file # indexes. my $main_table = "$BASE_DIR/index.html"; my $touch_main = $force || ! -e $main_table; for my $tag (keys %current) { my $dump_html = "$BASE_DIR/$tag/${tag}_$current{$tag}.html"; $touch_main ||= (-M $dump_html < -M $main_table); } $touch_main ||= (-e $scrn_table && -M $scrn_table < -M $main_table); $touch_main ||= (-e $cmov_table && -M $cmov_table < -M $main_table); $touch_main ||= (-e $xtra_table && -M $xtra_table < -M $main_table); write_main_table if $touch_main; } # cmd_add_comment() -- Implements the 'add_comment' command. sub cmd_add_comment (@) { local $_; # cmd_add_dump() will call us with the 'add_only' flag to add a comment # with a new dump; we won't need to call cmd_touch() in that case. my $add_only = (scalar @_ > 0 && $_[0] eq 'add_only'); shift @_ if $add_only; die "No character tag specified for add_comment\n" if scalar @_ == 0; my $tag = shift @_; die "No character directory '$tag'\n" unless exists $current{$tag}; return if $add_only && scalar @_ == 0 && !yesno 'Add comment?'; my $timestamp = strftime '%Y-%m-%d %l:%M%P %Z', localtime time; my $file = (scalar @_ == 0 ? '' : shift @_); my @lines = get_input_lines $file; print STDERR "No comment entered\n" and return if scalar @lines == 0; my $comment_file = "$BASE_DIR/$tag/${tag}_$current{$tag}.cmt"; open OUT, ">>$comment_file" or die "Cannot append to ${comment_file}: $!\n"; print OUT "-#- $timestamp\n"; for (@lines) { print OUT $_ } close OUT; cmd_touch $tag if !$add_only; } # cmd_add_dump() -- Implements the 'add_dump' command. sub cmd_add_dump (@) { die "No character tag specified for add_dump\n" if scalar @_ == 0; my $tag = shift @_; my $retire = (scalar @_ > 0 && $_[0] eq 'retire'); shift @_ if $retire; die "No dump file specified for add_dump\n" if scalar @_ == 0; my $dump_file = shift @_; die "File '$dump_file' does not exists\n" unless -e $dump_file; if (exists $current{$tag}) { # If the current dump is dead, maybe retire it and start a new one. my $cur_dump = read_dump $tag, 'current'; if ($retire || (exists $$cur_dump{state} && yesno "Current '$tag' dump is $$cur_dump{state}; start new dump?")) { $current{$tag}++; } } elsif (yesno "No existing character directory '$tag'; create?") { # Create directory for new character if necessary. mkdir "$BASE_DIR/$tag", 0755 or die "Cannot create directory $BASE_DIR/${tag}: $!\n"; $current{$tag} = 1; } else { return; } cmd_add_comment 'add_only', $tag, @_; my $dump = read_dump $tag, $current{$tag}, $dump_file; write_dump_txt $dump; write_dump_html $dump; cmd_touch $tag; } # cmd_add_screenshot() -- Implements the 'add_screenshot' command. sub cmd_add_screenshot (@) { die "No character tag specified for add_screenshot\n" if scalar @_ == 0; my $tag = shift @_; die "No character directory '$tag'\n" unless exists $current{$tag}; die "No screenshot file specified for add_screenshot\n" if scalar @_ == 0; my $file = shift @_; die "Screenshot file '$file' not found\n" unless -e $file; my $title; if (scalar @_ == 0 || -e $_[0] || $_[0] eq '+') { $title = prompt 'Enter a title for the screenshot'; } else { $title = shift @_; } my $comment_file = (scalar @_ == 0 ? '' : shift @_); my $dump = read_dump $tag, 'current'; my $timestamp = strftime '%Y-%m-%d %l:%M%P %Z', localtime time; gen_screenshot_html $file, $title, $dump, $comment_file, $timestamp; my $scrn_list = "$BASE_DIR/screen/list"; open OUT, ">>$scrn_list" or die "Cannot append to ${scrn_list}: $!\n"; print OUT "$title\t$tag\t$current{$tag}\t$timestamp\n"; close OUT; @all_screen = load_file_list $scrn_list, 'screen'; cmd_touch $tag; } # cmd_add_cmovie() -- Implements the 'add_cmovie' command. sub cmd_add_cmovie (@) { die "No character tag specified for add_cmovie\n" if scalar @_ == 0; my $tag = shift @_; die "No character directory '$tag'\n" unless exists $current{$tag}; die "No cmovie file specified for add_cmovie\n" if scalar @_ == 0; my $file = shift @_; die "Cmovie file '$file' not found\n" unless -e $file; my $title; if (scalar @_ == 0 || -e $_[0] || $_[0] eq '+') { $title = prompt 'Enter a title for the cmovie'; } else { $title = shift @_; } my $comment_file = (scalar @_ == 0 ? '' : shift @_); my $dump = read_dump $tag, 'current'; my $timestamp = strftime '%Y-%m-%d %l:%M%P %Z', localtime time; gen_cmovie_html $file, $title, $dump, $comment_file, $timestamp; my $cmov_list = "$BASE_DIR/cmov/list"; open OUT, ">>$cmov_list" or die "Cannot append to ${cmov_list}: $!\n"; print OUT "$title\t$tag\t$current{$tag}\t$timestamp\n"; close OUT; @all_cmov = load_file_list $cmov_list, 'cmov'; cmd_touch $tag; } # cmd_add_extra() -- Implements the 'add_xtra' command. sub cmd_add_extra (@) { die "No character tag specified for add_extra\n" if scalar @_ == 0; my $tag = shift @_; die "No character directory '$tag'\n" unless exists $current{$tag}; my $all = (scalar @_ > 0 && $_[0] eq 'all'); shift @_ if $all; die "No base filename specified for add_extra\n" if scalar @_ == 0; my $basename = shift @_; die "No title specified for add_extra\n" if scalar @_ == 0; my $title = shift @_; die "No description line specified for add_extra\n" if scalar @_ == 0; my $descr = shift @_; my $dump = read_dump $tag, 'current'; my $timestamp = strftime '%Y-%m-%d %l:%M%P %Z', localtime time; gen_xtra_html_tmpl $basename, $title, $descr, $dump, $timestamp; my $xtra_list = "$BASE_DIR/xtra/list"; my $which = ($all ? '*' : $current{$tag}); open OUT, ">>$xtra_list" or die "Cannot append to ${xtra_list}: $!\n"; print OUT "$title\t$tag\t$which\t$timestamp\t$basename.html\t$descr\n"; close OUT; @all_xtra = load_file_list "$BASE_DIR/xtra/list"; cmd_touch $tag; } # cmd_link_ladder() -- Implements the 'link_ladder' command. sub cmd_link_ladder (@) { die "No character tag specified for link_ladder\n" if scalar @_ == 0; my $tag = shift @_; die "No character directory '$tag'\n" unless exists $current{$tag}; die "No Ladder link number given for character '$tag'\n" if scalar @_ == 0; my $link = shift @_; die "Malformed Ladder link number '$link'\n" if $link !~ /^\d+$/; my $link_file = "$BASE_DIR/$tag/${tag}_$current{$tag}.ldr"; open OUT, ">$link_file" or die "Cannot write ${link_file}: $!\n"; print OUT "$link\n"; close OUT; cmd_touch $tag; } # "And so it begins..." my %cmds = ( init => \&cmd_init, add_dump => \&cmd_add_dump, add_comment => \&cmd_add_comment, add_screenshot => \&cmd_add_screenshot, add_cmovie => \&cmd_add_cmovie, add_extra => \&cmd_add_extra, link_ladder => \&cmd_link_ladder, touch => \&cmd_touch, ); die "No command specified\n" if scalar @ARGV == 0; my $cmd = shift; die "Unrecognized command '$cmd'\n" unless exists $cmds{$cmd}; # Some things we can't do until we've created the ladder directory tree # with the 'init' command. if ($cmd ne 'init') { get_char_dirs; get_copyright_range; @all_screen = load_file_list "$BASE_DIR/screen/list", 'screen'; @all_cmov = load_file_list "$BASE_DIR/cmov/list", 'cmov'; @all_xtra = load_file_list "$BASE_DIR/xtra/list"; } &{$cmds{$cmd}}(@ARGV); __END__ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.