#!/usr/bin/perl -w

###########################################################################
#
# newsrc.pl -- creates new blank source files
# A component of the Greenstone digital library software
# from the New Zealand Digital Library Project at the 
# University of Waikato, New Zealand.
#
# Copyright (C) 1999 New Zealand Digital Library Project
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
###########################################################################

foreach $filename (@ARGV) {
    if (-e "$filename.cpp") {
	print STDERR "$filename.cpp already exists\n";
	next;
    }
    if (-e "$filename.h") {
	print STDERR "$filename.h already exists\n";
	next;
    }

    $upperfilename = $filename;
    $upperfilename =~ tr/a-z/A-Z/;
    $upperfilename =~ s/[^A-Z]/_/g;

    print STDERR "Creating $filename.cpp\n";

    open (CPPFILE, ">$filename.cpp") || die "Couldn't write $filename.cpp";
    
    print CPPFILE "/**********************************************************************\n";
    print CPPFILE " *\n";
    print CPPFILE " * $filename.cpp -- \n";
    print CPPFILE " * A component of the Greenstone digital library software\n";
    print CPPFILE " * from the New Zealand Digital Library Project at the\n";
    print CPPFILE " * University of Waikato, New Zealand.\n";
    print CPPFILE " *\n";
    print CPPFILE " * Copyright (C) 2000  The New Zealand Digital Library Project\n";
    print CPPFILE " *\n";
    print CPPFILE " * This program is free software; you can redistribute it and/or modify\n";
    print CPPFILE " * it under the terms of the GNU General Public License as published by\n";
    print CPPFILE " * the Free Software Foundation; either version 2 of the License, or\n";
    print CPPFILE " * (at your option) any later version.\n";
    print CPPFILE " *\n";
    print CPPFILE " * This program is distributed in the hope that it will be useful,\n";
    print CPPFILE " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
    print CPPFILE " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n";
    print CPPFILE " * GNU General Public License for more details.\n";
    print CPPFILE " *\n";
    print CPPFILE " * You should have received a copy of the GNU General Public License\n";
    print CPPFILE " * along with this program; if not, write to the Free Software\n";
    print CPPFILE " * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n";
    print CPPFILE " *\n";
    print CPPFILE " *********************************************************************/\n";
    print CPPFILE "\n";
    print CPPFILE "\n";
    print CPPFILE "#include \"$filename.h\"\n";
    print CPPFILE "\n";

    close (CPPFILE);


    print STDERR "Creating $filename.h\n";

    open (HFILE, ">$filename.h") || die "Couldn't write $filename.h";

    print HFILE "/**********************************************************************\n";
    print HFILE " *\n";
    print HFILE " * $filename.h -- \n";
    print HFILE " * A component of the Greenstone digital library software\n";
    print HFILE " * from the New Zealand Digital Library Project at the\n";
    print HFILE " * University of Waikato, New Zealand.\n";
    print HFILE " *\n";
    print HFILE " * Copyright (C) 2000  The New Zealand Digital Library Project\n";
    print HFILE " *\n";
    print HFILE " * This program is free software; you can redistribute it and/or modify\n";
    print HFILE " * it under the terms of the GNU General Public License as published by\n";
    print HFILE " * the Free Software Foundation; either version 2 of the License, or\n";
    print HFILE " * (at your option) any later version.\n";
    print HFILE " *\n";
    print HFILE " * This program is distributed in the hope that it will be useful,\n";
    print HFILE " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
    print HFILE " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n";
    print HFILE " * GNU General Public License for more details.\n";
    print HFILE " *\n";
    print HFILE " * You should have received a copy of the GNU General Public License\n";
    print HFILE " * along with this program; if not, write to the Free Software\n";
    print HFILE " * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n";
    print HFILE " *\n";
    print HFILE " *********************************************************************/\n";
    print HFILE "\n";
    print HFILE "\n";
    print HFILE "\#ifndef ${upperfilename}_H\n";
    print HFILE "\#define ${upperfilename}_H\n";
    print HFILE "\n";
    print HFILE "\n";
    print HFILE "\n";
    print HFILE "\n";
    print HFILE "\#endif\n";

    close (HFILE);
}

