#!/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_app_data";
my $VERSION="1.1.4.1";

if (@ARGV == 0) {
	&useage;
	exit 202;
} 

sub useage {
	print "Usage: COE_get_app_data [options]  \"\"\n";
}

my $ascope="a";
my $acctgrp="all";
my $arg1;
my @a;
my @app;
my $coedat;
my $COEDAT;
my $COEERR;
my $i;

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 {
		$ascope=$arg1;
		$acctgrp=cleanString(shift,1);
	}
}

if ("$ascope" eq "l" || "$ascope" eq "local") {
	$ascope="local";
} elsif ("$ascope" eq "g" || "$ascope" eq "global") {
	$ascope="global";
} else {
	useage;
	exit 201;
}

$coedat=coeFileConv "COE_USER/$ascope/Profiles/.AppData.dat";

# AppData.dat foramt::  menu:name:acctgrp:icon:exec:arg
# Output => menu:name:acctgrp::exec:arg:icon

# get the apps that match the acctgrp

$i=0;
$COEDAT=readFile($coedat);
while (<$COEDAT>) { if (/:$acctgrp:/) { $app[$i++]=cleanString($_,3); }}
close $COEDAT;

#- set err to NO_SUCH_APP_DATA
$COEERR=205;

foreach (@app) {
	@a=split(':');
	print "$a[0]:$a[1]:$a[2]:$a[5]:$a[3]:$a[4]\n";
	#- success
	$COEERR=0;
}	

exit $COEERR;