summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Process
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-02-03 12:11:55 +0000
committerfukachan <fukachan>2002-02-03 12:11:55 +0000
commit338a420fd491504401968c0c8d06834215bdea0a (patch)
tree8e9b22c6e0990c5e98f56520fe939d4552d1cc26 /fml/lib/FML/Process
parentf76bdfb373ca7a63db75474937ac872eb8abf553 (diff)
downloadfml8-338a420fd491504401968c0c8d06834215bdea0a.tar.gz
fml8-338a420fd491504401968c0c8d06834215bdea0a.tar.bz2
fml8-338a420fd491504401968c0c8d06834215bdea0a.zip
ml_home_prefix() can recognize virtual domain.
modified to use it.
Diffstat (limited to 'fml/lib/FML/Process')
-rw-r--r--fml/lib/FML/Process/Utils.pm66
1 files changed, 60 insertions, 6 deletions
diff --git a/fml/lib/FML/Process/Utils.pm b/fml/lib/FML/Process/Utils.pm
index cbd71ec0..95abd8ec 100644
--- a/fml/lib/FML/Process/Utils.pm
+++ b/fml/lib/FML/Process/Utils.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: Utils.pm,v 1.8 2002/01/30 14:51:15 fukachan Exp $
+# $FML: Utils.pm,v 1.9 2002/02/02 15:18:00 fukachan Exp $
#
package FML::Process::Utils;
@@ -195,11 +195,58 @@ sub __ml_home_prefix_from_main_cf
my ($main_cf, $domain) = @_;
if (defined $domain) {
- warn("not implemented");
+ my ($virtual_maps) = __get_virtual_maps($main_cf);
+ if (@$virtual_maps) {
+ __ml_home_prefix_search_in_virtual_maps($main_cf, $domain, $virtual_maps);
+ }
+ else {
+
+ }
}
else {
- return $main_cf->{ ml_home_prefix };
+ if (defined $main_cf->{ ml_home_prefix }) {
+ return $main_cf->{ ml_home_prefix };
+ }
+ elsif (defined $main_cf->{ default_ml_home_prefix }) {
+ return $main_cf->{ default_ml_home_prefix };
+ }
+ else {
+ croak("\${default_,}ml_home_prefix is undefined.");
+ }
+ }
+}
+
+
+
+sub __ml_home_prefix_search_in_virtual_maps
+{
+ my ($main_cf, $virtual_domain, $virtual_maps) = @_;
+
+ if (@$virtual_maps) {
+ my $dir = '';
+ eval q{ use IO::Adapter; };
+ unless ($@) {
+ MAP:
+ for my $map (@$virtual_maps) {
+ my $obj = new IO::Adapter $map;
+ $obj->open();
+ $dir = $obj->find("^$virtual_domain");
+ last MAP if $dir;
+ }
+ ($virtual_domain, $dir) = split(/\s+/, $dir);
+ $dir =~ s/[\s\n]*$// if defined $dir;
+
+ # found
+ if ($dir) {
+ return $dir; # == $ml_home_prefix
+ }
+ }
+ else {
+ croak("cannot load IO::Adapter");
+ }
}
+
+ return undef;
}
@@ -225,11 +272,18 @@ return virtual maps.
sub get_virtual_maps
{
my ($curproc) = @_;
- my $args = $curproc->{ __parent_args }->{ main_cf };
+ my $main_cf = $curproc->{ __parent_args }->{ main_cf };
+ __get_virtual_maps($main_cf);
+}
+
+
+sub __get_virtual_maps
+{
+ my ($main_cf) = @_;
- if (defined $args->{ virtual_maps } && $args->{ virtual_maps }) {
+ if (defined $main_cf->{ virtual_maps } && $main_cf->{ virtual_maps }) {
my (@r) = ();
- my (@maps) = split(/\s+/, $args->{ virtual_maps });
+ my (@maps) = split(/\s+/, $main_cf->{ virtual_maps });
for (@maps) {
if (-f $_) { push(@r, $_);}
}