summaryrefslogtreecommitdiff
path: root/fml/lib
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-06-29 05:57:32 +0000
committerfukachan <fukachan>2001-06-29 05:57:32 +0000
commit98892cfb949baeaa4a3412351a178ff1c022f908 (patch)
treee9ac7c60626c707d29806cb3df5ee22bb6557209 /fml/lib
parentc9f8e684bdb41ac67be448162863a23df9507b4a (diff)
downloadfml8-98892cfb949baeaa4a3412351a178ff1c022f908.tar.gz
fml8-98892cfb949baeaa4a3412351a178ff1c022f908.tar.bz2
fml8-98892cfb949baeaa4a3412351a178ff1c022f908.zip
modify IO::Adapter::find() method to accpet options "all"
my $addrs = $obj->find( $user , { all => 1 }); FML::Credential is modified to get all addresses which match /^$user/ once and search it within them. 1. get all entries match /^$user/ from $map. 2. try each address in the result matches $address to check. 3. is_same_address() conceals matching algorithm details.
Diffstat (limited to 'fml/lib')
-rw-r--r--fml/lib/FML/Credential.pm21
-rw-r--r--fml/lib/IO/Adapter.pm25
2 files changed, 33 insertions, 13 deletions
diff --git a/fml/lib/FML/Credential.pm b/fml/lib/FML/Credential.pm
index b40c5e8d..d7921ebf 100644
--- a/fml/lib/FML/Credential.pm
+++ b/fml/lib/FML/Credential.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: Credential.pm,v 1.10 2001/05/28 16:17:12 fukachan Exp $
+# $FML: Credential.pm,v 1.11 2001/05/29 16:21:15 fukachan Exp $
#
package FML::Credential;
@@ -116,16 +116,25 @@ sub is_member
my ($user, $domain) = split(/\@/, $address);
use IO::Adapter;
+
+ MAP:
for my $map (split(/\s+/, $member_maps)) {
if ($map) {
my $obj = new IO::Adapter $map;
- my $x = $obj->find( $user );
- my ($r) = split(/\s+/, $x);
- if ($self->is_same_address($r, $address)) {
- $status = 1; # found
+ # 1. get all entries match /^$user/ from $map.
+ my $addrs = $obj->find( $user , { all => 1 });
+
+ # 2. try each address in the result matches $address to check.
+ for my $x (@$addrs) {
+ my ($r) = split(/\s+/, $x);
+
+ # 3. is_same_address() conceals matching algorithm details.
+ if ($self->is_same_address($r, $address)) {
+ $status = 1; # found
+ last MAP;
+ }
}
- last if $x;
}
}
diff --git a/fml/lib/IO/Adapter.pm b/fml/lib/IO/Adapter.pm
index 8f3dff30..43bc558e 100644
--- a/fml/lib/IO/Adapter.pm
+++ b/fml/lib/IO/Adapter.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: Adapter.pm,v 1.3 2001/06/09 10:55:49 fukachan Exp $
+# $FML: Adapter.pm,v 1.4 2001/06/09 14:27:39 fukachan Exp $
#
package IO::Adapter;
@@ -343,15 +343,20 @@ You can change the search behaviour by C<$args> (HASH REFERENCE).
$args = {
case_sensitive => 1, # case senssitive
+ all => 1, # get all entries matching $regexp as ARRAY REF
};
+Normaly the result is given as a string.
+If you specify C<all>, you get the result(s) as ARRAY REFERENCE.
+
=cut
sub find
{
my ($self, $regexp, $args) = @_;
my $case_sensitive = $args->{ case_sensitive } ? 1 : 0;
- my $x;
+ my $show_all = $args->{ all } ? 1 : 0;
+ my (@buf, $x);
# forward the request to SUPER class
if ($self->SUPER::can('_find')) { $self->_find($regexp, $args);}
@@ -359,17 +364,23 @@ sub find
# search regexp by reading the specified map.
$self->open;
while (defined ($x = $self->get_next_value())) {
- if ($case_sensitive) {
- last if $x =~ /$regexp/;
+ if ($show_all) {
+ push(@buf, $x) if $x =~ /$regexp/;
}
else {
- last if $x =~ /$regexp/i;
+ if ($case_sensitive) {
+ last if $x =~ /$regexp/;
+ }
+ else {
+ last if $x =~ /$regexp/i;
+ }
}
}
+
$self->close;
- $x;
-}
+ $show_all ? \@buf : $x;
+}
# Descriptions: destructor