#!/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_deassign_app_from_profile";
my $VERSION="1.1.4.1";
if (@ARGV == 0) {
&useage;
exit 202;
}
sub useage {
print "Useage: $PRGM [options] \"\" ";
print "\"\"\n";
}
my $applabel="a";
my $profile="a";
my $coedatstr;
my $coedat;
my $COEDAT;
my $pscope="a";
my $arg1;
my $flag="false";
my $i;
my @readline;
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 {
$profile=$arg1;
$pscope=cleanString(shift,1);
$applabel=cleanString(shift,1);
}
}
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# do some simple sanity checks
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# check global scope
if ( "$pscope" eq "l" || "$pscope" eq "local" ) {
$pscope="local";
} elsif ( "$pscope" eq "g" || "$pscope" eq "global") {
$pscope="global";
} else {
&useage;
exit 202;
}
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# define some stuff
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# path for the AppData data file
$coedat=coeFileConv "COE_USER/$pscope/Profiles/.ProfileApp.dat";
# ProfileApp.dat == profile:applabel
$coedatstr="$profile:$applabel\n";
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# if it exists, remove this entry from the file
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
$i=0;
$COEDAT=readFile ($coedat);
while (<$COEDAT>) {
if (! /^$coedatstr/) {
$readline[$i++]=cleanString($_,3);
} else {
$flag="true";
}
}
close $COEDAT;
# only rewrite if we have to
if ("$flag" eq "true") {
open COEDAT, (">$coedat") || die "Cannot open file $coedat: $!\n";
foreach (@readline) {
print COEDAT "$_\n";
}
close COEDAT;
exit 0;
} else {
#- exit with no such Profile/App data
exit 209;
}