# -- perl -- 

#*************************************************
#****************** Wrapper for route.pl *********
#*************************************************

$i=0;
$flag=0;
$user="";
@opt;

if (@ARGV[0] eq "--help")
{
    &ExtendedHelp;
    exit;
}

while($ARGV[$i])
{
    @Option=split(//,@ARGV[$i]);
    if ($Option[0] eq "-")
    {
    	&CheckOptions(@ARGV[$i]);
    	push(@opt,$ARGV[$i]);
    }
    else
    {
		$flag=1;
		$user=@ARGV[$i];
    }
    $i=$i+1;
}


print `/sbin/route -ee @opt | <BINDIR>/route_filter.pl $flag $user`;

#*************************************************
#****************** PROCEDURES *******************
#*************************************************

sub CheckOptions {
    my($Option)=@_;
    foreach $char (split(//,$Option))
    {
         if ($char=~ /[^-n]/)
         { 
   	   	&Help;
	   	   exit;            
         }
    }
}

sub Help {
    print("\nUSAGE: route [-n]\n");
    print("\nUSAGE: route [-n] ID\n");
    print("\nUSAGE: route --help\n");
}

sub ExtendedHelp
{
    print("route - Show i.p. routing table\n"); 
    print("Options\n");
    print("id   : Give me info on i.p.\n"); 
    print("       with that id\n");
    print("-n   : print i.p. in numeric format\n");
}

