Appendix E

lpquota Simulator Source Code

#!/usr/local/bin/perl
#Takes arguments in string like this:
#lpquote -f0 -P100lez -i 500 dduck
#Sean Korb's mock lpquota program

$infile = "quotaData";
open(INPUT,"<$infile");

$i = 0;
$j = 0;

if (@ARGV[2] eq "-i") {
$username = @ARGV[4];
}else{$username = @ARGV[1];}
#Gets the nasties out of the file and indexes the names into an array
#and indexes the grades into an array indexed by names.
while () {
$i = $i + 1;
chop $_;
$file[$i] = $_;
if (($_ eq $username) && ($j == 0)) {
$loginID[$j] = $_ ;
$j = $j + 1;
 }
 elsif (($loginID[0] eq $username) && ($j == 1)){
 $loginID[$j] = $_ ;
$j = $j + 1;
 }
 elsif (($loginID[0] eq $username) && ($j == 2)){
 $loginID[$j] = $_ ;
$j = $j + 1;
 }
 elsif (($loginID[0] eq $username) && ($j == 3)){
 $loginID[$j] = $_ ;
 $update = $i;
$j = $j + 1;
 }


}
close (INPUT);
if ($j == 0){print"No such user";
exit;}
$endi = $i;

$userID = $username;
$usage = $loginID[1];
$arguments = @ARGV[0];
$limit = $loginID[2];

#$userID = "spkorb";
#$usage = 59.740;
#$limit = 50.00;
#print $arguments;
#if ($arguments =~ /(.*\-i.*)/ ){
if (@ARGV[2] eq "-i"){ 
$limit = $limit + 5.00;
$file[$update - 1] = $limit;
}
if ( ($loginID[3] == 1) || (@ARGV[0] eq "-f1") ){
$printing_allowed = "Printing is allowed";
if ($loginID[3] == 0){
$file[$update] = 1;

}
}
else{ $printing_allowed = "Printing is disabled"; }

open(OUTPUT,">$infile");
$i = 0;

while ($i < $endi) {
$i = $i+1;
print OUTPUT $file[$i],"\n";
}
close(OUTPUT);


print "Username        : $userID,\@EOS.NCSU.EDU\n";
print "Service         : eos\n";
print "Usage: \$",$usage,"		Limit: \$",$limit,"\n";#"\.00\n";
print "Last bill: \$0.00        Ytd billed: \$0.00\n";
print $printing_allowed,"\n";

Data for lpquota

kcvoorhe
137.26
120.00
0
spkorb
54.44
55.00
1
fflintst
20.26
18.00
0
brubble
15.22
9.00
0
wflintst
30.32
9.00
0
berubble
8.34
9.00
1
gjetson
2.54
9.00
1
wecyote
58.00
9.00
0
ejfudd
22.38
14.00
0
bbunny
5.56
9.00
1
dduck
85.22
0.00
0
sgonzale
9.00
9.00
1
mmartian
0.00
0.36
0