summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-12-18 04:12:47 +0000
committerfukachan <fukachan>2002-12-18 04:12:47 +0000
commit1e832a14f7feb5790042335e53bb9717df8e17ed (patch)
treef74b944425ef236adc988073baf9ac6afd926c91
parent56a1da7b72af251c24760fcec8e78b565010c96c (diff)
downloadfml8-1e832a14f7feb5790042335e53bb9717df8e17ed.tar.gz
fml8-1e832a14f7feb5790042335e53bb9717df8e17ed.tar.bz2
fml8-1e832a14f7feb5790042335e53bb9717df8e17ed.zip
clean up comments.
define is_valid_mta-type() and modified to use it.
-rw-r--r--fml/lib/FML/MTAControl.pm131
1 files changed, 59 insertions, 72 deletions
diff --git a/fml/lib/FML/MTAControl.pm b/fml/lib/FML/MTAControl.pm
index b3ae5336..d181ce43 100644
--- a/fml/lib/FML/MTAControl.pm
+++ b/fml/lib/FML/MTAControl.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: MTAControl.pm,v 1.12 2002/09/11 23:18:03 fukachan Exp $
+# $FML: MTAControl.pm,v 1.13 2002/09/22 14:56:41 fukachan Exp $
#
package FML::MTAControl;
@@ -25,12 +25,10 @@ my $debug = 0;
=head1 NAME
-FML::MTAControl - postfix utilities
+FML::MTAControl - utilities to handle MTA specific configurations
=head1 SYNOPSIS
- nothing implemented yet.
-
=head1 DESCRIPTION
=head1 METHODS
@@ -41,11 +39,18 @@ FML::MTAControl - postfix utilities
mta_type => 'postfix',
};
-C<postfix> as C<mta_type> is available now.
+C<mta_type> is one of
+ C<postfix>,
+ C<qmail>
+and
+ C<procmail>.
=cut
+my $default_mta = 'postfix';
+
+
# Descriptions: ordinary constructor
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: none
@@ -56,15 +61,33 @@ sub new
my ($type) = ref($self) || $self;
my $me = {};
- # default values
- $me->{ mta_type } =
- defined $args->{ mta_type } ? $args->{ mta_type } : 'postfix';
+ # default mta is postfix.
+ $me->{ mta_type } = $args->{ mta_type } || $default_mta;
return bless $me, $type;
}
-# Descriptions: install configuration temaplate alias
+# Descriptions: $mta_type is valid or not.
+# Arguments: OBJ($self) STR($mta_type)
+# Side Effects: none
+# Return Value: NUM(1 or 0)
+sub is_valid_mta_type
+{
+ my ($self, $mta_type) = @_;
+
+ if ($mta_type eq 'postfix' ||
+ $mta_type eq 'qmail' ||
+ $mta_type eq 'procmail') {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+
+# Descriptions: install configuration template files
# Arguments: OBJ($self)
# HASH_REF($curproc) HASH_REF($params) HASH_REF($optargs)
# Side Effects: update aliases
@@ -72,13 +95,9 @@ sub new
sub setup
{
my ($self, $curproc, $params, $optargs) = @_;
- my $mta_type =
- defined $optargs->{ mta_type } ? $optargs->{ mta_type } :
- $self->{ mta_type };
+ my $mta_type = $optargs->{ mta_type } || $self->{ mta_type };
- if ($mta_type eq 'postfix' ||
- $mta_type eq 'qmail' ||
- $mta_type eq 'procmail') {
+ if ($self->is_valid_mta_type($mta_type)) {
my $method = "${mta_type}_setup";
$self->$method($curproc, $params, $optargs);
}
@@ -88,20 +107,16 @@ sub setup
}
-# Descriptions: update alias
+# Descriptions: update alias.db from alias file
# Arguments: OBJ($self) HASH_REF($curproc) HASH_REF($optargs)
# Side Effects: update aliases
# Return Value: none
sub update_alias
{
my ($self, $curproc, $params, $optargs) = @_;
- my $mta_type =
- defined $optargs->{ mta_type } ? $optargs->{ mta_type } :
- $self->{ mta_type };
+ my $mta_type = $optargs->{ mta_type } || $self->{ mta_type };
- if ($mta_type eq 'postfix' ||
- $mta_type eq 'qmail' ||
- $mta_type eq 'procmail') {
+ if ($self->is_valid_mta_type($mta_type)) {
my $method = "${mta_type}_update_alias";
$self->$method($curproc, $params, $optargs);
}
@@ -111,21 +126,17 @@ sub update_alias
}
-# Descriptions: find key
+# Descriptions: find key in alias maps
# Arguments: OBJ($self) HASH_REF($curproc) HASH_REF($optargs)
# Side Effects: none
# Return Value: none
sub find_key_in_alias_maps
{
my ($self, $curproc, $params, $optargs) = @_;
- my $mta_type =
- defined $optargs->{ mta_type } ? $optargs->{ mta_type } :
- $self->{ mta_type };
+ my $mta_type = $optargs->{ mta_type } || $self->{ mta_type };
my $key = $optargs->{ key };
- if ($mta_type eq 'postfix' ||
- $mta_type eq 'qmail' ||
- $mta_type eq 'procmail') {
+ if ($self->is_valid_mta_type($mta_type)) {
my $method = "${mta_type}_find_key_in_alias_maps";
$self->$method($curproc, $params, $optargs);
}
@@ -135,20 +146,16 @@ sub find_key_in_alias_maps
}
-# Descriptions: find key
+# Descriptions: return aliases as HASH_REF
# Arguments: OBJ($self) HASH_REF($curproc) HASH_REF($optargs)
# Side Effects: none
-# Return Value: none
+# Return Value: HASH_REF
sub get_aliases_as_hash_ref
{
my ($self, $curproc, $params, $optargs) = @_;
- my $mta_type =
- defined $optargs->{ mta_type } ? $optargs->{ mta_type } :
- $self->{ mta_type };
+ my $mta_type = $optargs->{ mta_type } || $self->{ mta_type };
- if ($mta_type eq 'postfix' ||
- $mta_type eq 'qmail' ||
- $mta_type eq 'procmail') {
+ if ($self->is_valid_mta_type($mta_type)) {
my $method = "${mta_type}_get_aliases_as_hash_ref";
$self->$method($curproc, $params, $optargs);
}
@@ -158,7 +165,7 @@ sub get_aliases_as_hash_ref
}
-# Descriptions: install configuration temaplate alias
+# Descriptions: install alias file
# Arguments: OBJ($self)
# HASH_REF($curproc) HASH_REF($params) HASH_REF($optargs)
# Side Effects: update aliases
@@ -166,13 +173,9 @@ sub get_aliases_as_hash_ref
sub install_alias
{
my ($self, $curproc, $params, $optargs) = @_;
- my $mta_type =
- defined $optargs->{ mta_type } ? $optargs->{ mta_type } :
- $self->{ mta_type };
+ my $mta_type = $optargs->{ mta_type } || $self->{ mta_type };
- if ($mta_type eq 'postfix' ||
- $mta_type eq 'qmail' ||
- $mta_type eq 'procmail') {
+ if ($self->is_valid_mta_type($mta_type)) {
my $method = "${mta_type}_install_alias";
$self->$method($curproc, $params, $optargs);
}
@@ -182,7 +185,7 @@ sub install_alias
}
-# Descriptions: remove configuration temaplate alias
+# Descriptions: remove entry in alias maps
# Arguments: OBJ($self)
# HASH_REF($curproc) HASH_REF($params) HASH_REF($optargs)
# Side Effects: update aliases
@@ -190,13 +193,9 @@ sub install_alias
sub remove_alias
{
my ($self, $curproc, $params, $optargs) = @_;
- my $mta_type =
- defined $optargs->{ mta_type } ? $optargs->{ mta_type } :
- $self->{ mta_type };
+ my $mta_type = $optargs->{ mta_type } || $self->{ mta_type };
- if ($mta_type eq 'postfix' ||
- $mta_type eq 'qmail' ||
- $mta_type eq 'procmail') {
+ if ($self->is_valid_mta_type($mta_type)) {
my $method = "${mta_type}_remove_alias";
$self->$method($curproc, $params, $optargs);
}
@@ -206,7 +205,7 @@ sub remove_alias
}
-# Descriptions: install configuration temaplate alias
+# Descriptions: install/update virtual map file
# Arguments: OBJ($self)
# HASH_REF($curproc) HASH_REF($params) HASH_REF($optargs)
# Side Effects: update aliases
@@ -214,13 +213,9 @@ sub remove_alias
sub install_virtual_map
{
my ($self, $curproc, $params, $optargs) = @_;
- my $mta_type =
- defined $optargs->{ mta_type } ? $optargs->{ mta_type } :
- $self->{ mta_type };
+ my $mta_type = $optargs->{ mta_type } || $self->{ mta_type };
- if ($mta_type eq 'postfix' ||
- $mta_type eq 'qmail' ||
- $mta_type eq 'procmail') {
+ if ($self->is_valid_mta_type($mta_type)) {
my $method = "${mta_type}_install_virtual_map";
$self->$method($curproc, $params, $optargs);
}
@@ -230,7 +225,7 @@ sub install_virtual_map
}
-# Descriptions: remove configuration temaplate alias
+# Descriptions: remove entry in virtual maps
# Arguments: OBJ($self)
# HASH_REF($curproc) HASH_REF($params) HASH_REF($optargs)
# Side Effects: update aliases
@@ -238,13 +233,9 @@ sub install_virtual_map
sub remove_virtual_map
{
my ($self, $curproc, $params, $optargs) = @_;
- my $mta_type =
- defined $optargs->{ mta_type } ? $optargs->{ mta_type } :
- $self->{ mta_type };
+ my $mta_type = $optargs->{ mta_type } || $self->{ mta_type };
- if ($mta_type eq 'postfix' ||
- $mta_type eq 'qmail' ||
- $mta_type eq 'procmail') {
+ if ($self->is_valid_mta_type($mta_type)) {
my $method = "${mta_type}_remove_virtual_map";
$self->$method($curproc, $params, $optargs);
}
@@ -261,13 +252,9 @@ sub remove_virtual_map
sub update_virtual_map
{
my ($self, $curproc, $params, $optargs) = @_;
- my $mta_type =
- defined $optargs->{ mta_type } ? $optargs->{ mta_type } :
- $self->{ mta_type };
+ my $mta_type = $optargs->{ mta_type } || $self->{ mta_type };
- if ($mta_type eq 'postfix' ||
- $mta_type eq 'qmail' ||
- $mta_type eq 'procmail') {
+ if ($self->is_valid_mta_type($mta_type)) {
my $method = "${mta_type}_update_virtual_map";
$self->$method($curproc, $params, $optargs);
}
@@ -277,7 +264,7 @@ sub update_virtual_map
}
-# Descriptions: install file $dst with variable expansion of $src
+# Descriptions: install file $to dst with variable expansion of $src
# Arguments: OBJ($self) STR($src) STR($dst) HASH_REF($config)
# Side Effects: create $dst
# Return Value: none