#!/usu/bin/perl
#
# it is perl, Ultrix doesn't like the above line to be longer than ~30
# characters, so I softlinked p to perl.
#
# this munches on the headers of each file for each archive, and is
# rather useless for anything else.
#
# -Brandon

select(STDOUT); $|=1;

@months = ("Jan","Feb","Mar","Apr","May","Jun",
           "Jul","Aug","Sep","Oct","Nov","Dec");

###############################
# get the head
$head = <<END;
/*
// ColdMUD was created and is copyright 1993, 1994 by Greg Hudson
//
// ColdX is a derivitive work, and is copyright 1995 by the ColdX Project.
// Full copyright information can be found in the file doc/CREDITS
//
END

###############################
# get the version
open(FILE, "../etc/version");
$ver = <FILE>;
chop $ver;
close(FILE);

###############################
# Loop n stuff
for (@ARGV) {
    $file = $_;
    print "$file...\n";

    rename("$file", "$file.orig");

    open(IN, "$file.orig");
    open(OUT, ">$file");

    # Date is rather useless, but cute.
    @stuff = stat(IN);
    @time = localtime($stuff[9]);
    $date = "$time[3] $months[$time[4]] 19$time[5]";

    $line = <IN>;

    if ($line =~ /^\/\* \@\@\@HEAD\@\@\@.*$/) {
        print OUT $head;
        print OUT<<END;
// File:        $file
// Version:     $ver
// Last Edited: $date
//
// ---
//
END
    }

    while (<IN>) {
        print(OUT);
    }

    close(IN);
    close(OUT);
}