#!/usr/local/bin/perl
#
# zaplist - format list of accounts to zap from sf.kill file
#
# usage: zaplist config [files]
if ($#ARGV<0)
  {print STDERR "Usage: zaplist config [files]\n";exit 1;}

# find the numbers of the alias, id, and CCSO-accounts fields.
$aliasnum = $idnum = $CCSOnum = -1;
$config=shift;
open (CONFIG,$config) || die "$config: $!\n";
while (<CONFIG>)
{
  if (/:alias:/) {($aliasnum)=(split(':'))[0];}
  elsif (/:id:/) {($idnum)=(split(':'))[0];}
  elsif (/:CCSO-accounts:/) {($CCSOnum)=(split(':'))[0];}
}
close(CONFIG);

while (<>)
{
  chop;
  $id = $alias = $CCSO = "";
  if (/^$idnum:([^	]*)/) {$id = $1;}
  if (/\t$aliasnum:([^	]*)/) {$alias = $1;}
  if (/\t$CCSOnum:([^	]*)/) {$CCSO = $1;}

  if ($CCSO ne "") { print("$CCSO\t$id\t$alias\n"); }
}
