#!/h/COE/Comp/PERL5/bin/perl -T -I/h/COE/lib -w
#-
# Copyright (C) 2002, Federal Linux Systems
# License: GNU Lesser General Public License, v2.1
#-
use strict;
use Coe;
my $PRGM="COE_get_error_string";
my $VERSION="1.1.4.1";
if (@ARGV != 1) {
&useage;
exit 202;
}
sub useage {
print "Useage: COE_get_error_string [options] Error_Code\n";
}
my $errdat=coeFileConv("COE_COMP/UserMgmt/data/COE_error_strings.dat");
my $errnum=-1;
my $errstr="dummy";
my $ERRDAT;
my $arg1;
while ( @ARGV > 0 ){
$arg1=cleanString(shift,1);
if ("$arg1" eq "-h") {
useage;
exit 0;
} elsif ("$arg1" eq "-H") {
coeMan("COE_COMP/UserMgmt/docs/man/$PRGM");
exit 0;
} elsif ("$arg1" eq "-V") {
print "VERSION: $VERSION\n";
exit 0;
} else {
$errnum=$arg1;
}
}
# verify that the argument is a number
$_=$errnum;
if (!/^\d+$/) {
useage;
exit 202;
}
# add logic to prevent writing data twice
$ERRDAT=readFile($errdat);
while (<$ERRDAT>) { if (/^$errnum /) {s/$errnum //;$errstr=$_;}}
close $ERRDAT;
if ("$errstr" ne "dummy" && "$errstr" ne "\n") {
print "$errstr";
exit 0;
} else {
print "Error string not defined: $errnum\n";
exit 201;
}
exit 0;