# $Id: MSGaliases.pm,v 1.2 1999/10/04 17:25:27 v2kea318 Exp $
# $Log: MSGaliases.pm,v $
# Revision 1.2  1999/10/04  17:25:27  v2kea318
# Make the data base have unique key values.
#
# Revision 1.1  1999/08/11  19:59:00  v2kea318
# Initial revision
#
#***************************************************************************

=head1 NAME

MSGaliases - an interface to the .msg_aliases file.

=head1 DESCRIPTION

This class provides an interface to the .msg_aliases data base, 
which provides email aliases for the msg system.  

=head1 DERIVED FROM

This class is derived from F<SystemInfoDB>.  

=head1 DB format

The data base is assumed to have the format

   alias   email_address

Comments are indicated by the # character and extend to the end of the
line.

=head1 Methods

  expand_alias($)        Translate an alias to the (truncated) email
	                 address.  The truncated address is just the 
                         user name, I<e.g.>, the truncated version of
                         I<dr_saaron@yahoo.com> is I<dr_saaron>.
  expand_alias_full($)   Translate an alias to the full email address.

=cut

#***************************************************************************

# class name.
package MSGaliases;

# OO stuff.
use SystemInfoDB;
@ISA = qw(SystemInfoDB);

#***************************************************************************
# Constructor.
#***************************************************************************

sub new {
  my $pkg = shift();

  # build the object.
  my $obj = SystemInfoDB::new($pkg, $ENV{HOME} . "/.msg_aliases", 
			      '#', '\s+', 1);

  # bless it.
  bless $obj, $pkg;
}

#***************************************************************************

sub expand_alias_full($) {
  my ($obj, $key) = @_;
  return $obj->getIndex($key, 1);
}

#***************************************************************************

sub expand_alias($) {
  my ($obj, $key) = @_;
  my $falias = $obj->expand_alias_full($key);
  return undef unless (defined($falias));

  # fix the address.
  $falias =~ s/@[^ ]*//;
  return $falias;
}

#***************************************************************************

1;
