#!/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_add_app_data";
my $VERSION="1.1.4.1";
if (@ARGV == 0) {
&useage;
exit 202;
}
sub useage {
print "Useage: $PRGM \"\" \"\" ";
print "\"\" \"\" \"\" ";
print " [\"\"]\n";
}
my $a_args="a";
my $acctgrp="all";
my $aexec="a";
my $aicon="a";
my $alabel="a";
my $aname="a";
my $appstr="a";
my $ascope="a";
my $arg1;
my $flag="false";
my $coedat;
my $COEDAT;
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 {
$alabel=$arg1;
$aname=cleanString(shift,3);
$acctgrp=cleanString(shift,3);
$aicon=cleanString(shift,3);
$aexec=cleanString(shift,3);
$ascope=cleanString(shift,1);
$a_args=cleanString(shift,3);
}
}
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# do simple sanity checks
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# is this a legal scope ?
if ( "$ascope" eq "l" || "$ascope" eq "local" ) {
$ascope="local";
} elsif ("$ascope" eq "g" || "$ascope" eq "global") {
$ascope="global";
} else {
&useage;
exit 202;
}
# does this acct group exist?
# does the file in the exec path exist?
# does the file in the icon path exist?
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# define some stuff
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# path for the AppData data file
$coedat=coeFileConv "COE_USER/$ascope/Profiles/.AppData.dat";
# AppData.dat == menu:name:acctgrp:exec:$icon:arg
$appstr="$alabel:$aname:$acctgrp:$aexec:$a_args:$aicon\n";
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# if the application label and acct group are unique, append it to the file
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
#open file, "$APPDAT" || die "Cannot open file $APPDAT: $!\n";
#$COEDAT = readFile $coedat;
$COEDAT = readFile $coedat;
while (<$COEDAT>) { if (/^$alabel:.*:$acctgrp/) { $flag="true"; }}
close $COEDAT;
if ("$flag" eq "false") {
#open file, (">>$APPDAT") || die "Cannot open file $coedat: $!\n";
open COEDAT, (">>$coedat") || die "Cannot open file $coedat: $!\n";
print COEDAT "$appstr";
close COEDAT;
}
exit 0;