#!/local/bin/perl
#
# A script to convert from Westlund's list to fspshell list.
#
# BEWARE: This is unsuported software !
#
################################################################################
#
# Copyright (c) Ove Ruben R Olsen (Gnarfer from hell)
#
# Permission to use, copy, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation.
# This also apply your own incarnations of any or all of this code.
# If you use portions of this code, you MUST include a apropriate notice
# where you "stole" it from.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# Email:  Ruben@uib.no
#
################################################################################

while (<>) {
  $flagg = 1 if /GRAVEYARD/;
  print , next if /^$/ ;
  chop ;
  if (/\s+(\d+\.\d+\.\d+\.\d+)\s+(\d+)\s+(.+)/) {
    $a = $3 ;
    $a = "* $3" if ($flagg == 1); 
    ($alias) = ($3 =~ /(\S+)/);

    print &SPCstr($1,20," ",l), 
          &SPCstr($2,7," ",l),
          &SPCstr($alias,10," ",l)," / $a\n";
  } else {
    print "#$_\n";
  }
}

exit (0) ; # Just in case.

sub SPCstr { # Str, len, fchar, type => string
  # Retruns justifyed string
  #
  # Copyright Ove Ruben R Olsen (c) 1992
  #
  local ($a, $b, $c);
  $b = " " ;
  $c = 'r' ;
  $a = substr(@_[0],0,@_[1]);
  $b = @_[2] if (defined @_[2] );
  $c = @_[3] if (defined @_[3] );

  return $a, $b x ( @_[1] - length (@_[0] ) )  if ($c eq 'l');
  return " " x ( @_[1] - length ($a)), $a      if ($c eq 'r');
  return " " x ( @_[1] - length (@_[0] ) )     if ($c eq 'n' );

}

