#!/usr/local/bin/perl
require "cgi-lib.pl";
sub CgiDie
{
&CgiError(@_);
exit 1;
}
sub ptext
{
local ($key, $size) = @_;
return "\n";
}
sub pradio
{
local ($key, $value) = @_;
$c = ($data{$key} eq $value) ? "CHECKED" : "";
return "";
}
sub pselect
{
local ($key, @options) = @_;
local ($retval);
$retval = "";
return $retval;
}
sub pcbox
{
local ($key) = @_;
$c = ($data{$key} eq "on") ? "CHECKED" : "";
return "";
}
@seniorCourses = ("CS 401: Senior Independent Work",
"CS 410: Advanced Software Systems",
"CS 420: Introduction to Parallel Computing",
"CS 440: Nonnumeric Computation",
"CS 450: Computer Architecture I",
"CS 480: Introduction to Computer Graphics",
"CS 491/2: Directed Study",
"CS 511: Software Engineering",
"CS 512: Parallel Algorithms and Programs",
"CS 520: Programming Languages",
"CS 525: Compiler Design Theory",
"CS 530: Analysis of Algorithms",
"CS 535: Complexity Theory",
"CS 537: Probability in Computing",
"CS 538: Cryptography and Cryptanalysis",
"CS 540: Artificial Intelligence",
"CS 542: Logic Programming",
"CS 545: Natural Language Processing",
"CS 550: Computer Architecture II",
"CS 552: Introduction to Operating Systems",
"CS 555: Data Communications",
"CS 560: Introduction to Database Systems",
"CS 591: Topics in Computer Science");
sub writeform
{
local(*data) = @_;
print "\n";
print "
\n";
print "CLA Computer Science Concentration Checklist\n";
print "\n";
print "\n";
print "\n";
print "
College Program for Liberal Arts
\n";
print " with Concentration in Computer Science
\n";
print "For Students Entering CLA before September 1995
\n";
print "\n";
print "
\n";
print "\n";
print "\n";
print "Mark Crovella\n";
print "\n";
print "\n";
}
# modifiable parameters
$fpath = "/home/crovella/student-files/";
$ci = "/home/crovella/bin/ci";
$co = "/home/crovella/bin/co";
# start by parsing input into array "input"
if (! &ReadParse(*input))
{
&CgiError("No input");
exit 1;
}
# some simple error checking
@required = ("login-id");
undef $errmsg;
$errmsg[0] = "Error: required field(s) not filled in";
foreach $field (@required)
{
if ($input{$field} eq '')
{
@errmsg = (@errmsg, "The $field field was empty.");
}
}
&CgiDie(@errmsg) if ($#errmsg != 0);
# now check in a new copy of the file record
$fname = $fpath . $input{'login-id'};
$rcsname = $fpath . "RCS/" . $input{'login-id'} . ",v";
# if file exists, check it out
if (-r $rcsname)
{
$retval = system("$co -u $fname");
$retval /= 256;
&CgiDie("File checkout failed with status $retval") if ($retval != 0);
}
else # file doesn't exist; create it
{
open (DATAFILE,"> $fname") || &CgiDie("Can't create file $fname");
print DATAFILE "login-id\`$input{'login-id'}\|\n";
close DATAFILE;
$retval = system("$ci -t-StudentRecordFile -u $fname");
$retval /= 256;
&CgiDie("File creation failed with status $retval") if ($retval != 0);
}
open (DATAFILE, $fname) || &CgiDie("Can't open file $file");
# need to fix this to handle newlines in the "Comments" field
$input = ;
@items = split(/\|/,$input);
print &PrintHeader;
foreach $f (0..$#items)
{
($label, $contents) = split(/\`/, $items[$f]);
$data{$label} = $contents;
}
# fix newlines in Comments
if (defined ($data{"Comments"}))
{
$data{"Comments"} =~ s/%NL%/\n/;
$data{"Comments"} =~ s/%CR%/\r/;
}
&writeform(*data);
# exit 0;