summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-01-28 13:08:15 +0000
committerfukachan <fukachan>2001-01-28 13:08:15 +0000
commit653d890ecebb2827e05836fc50f75678c01bac93 (patch)
tree2be0e74cc27eaa2e26b547e348e18561495792db
parentb9397db8eec7bf2f61cb3974dd1fb39dbc31a2f4 (diff)
downloadfml8-653d890ecebb2827e05836fc50f75678c01bac93.tar.gz
fml8-653d890ecebb2827e05836fc50f75678c01bac93.tar.bz2
fml8-653d890ecebb2827e05836fc50f75678c01bac93.zip
move initialization codes on NIS and etc/group to each subclass
-rw-r--r--fml/lib/IO/Adapter/NIS.pm67
-rw-r--r--fml/lib/IO/Adapter/UnixGroup.pm66
-rw-r--r--fml/lib/IO/MapAdapter.pm21
3 files changed, 138 insertions, 16 deletions
diff --git a/fml/lib/IO/Adapter/NIS.pm b/fml/lib/IO/Adapter/NIS.pm
new file mode 100644
index 00000000..60a59ca3
--- /dev/null
+++ b/fml/lib/IO/Adapter/NIS.pm
@@ -0,0 +1,67 @@
+#-*- perl -*-
+#
+# Copyright (C) 2001 Ken'ichi Fukamachi
+# All rights reserved. This program is free software; you can
+# redistribute it and/or modify it under the same terms as Perl itself.
+#
+# $Id$
+# $FML$
+#
+
+package IO::Adapter::NIS;
+
+use strict;
+use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
+use Carp;
+use IO::Adapter::Array;
+
+@ISA = qw(IO::Adapter::Array);
+
+sub configure
+{
+ my ($self, $me) = @_;
+ my ($type) = ref($self) || $self;
+
+ # emulate an array on memory
+ my $key = $me->{_name};
+ my (@x) = split(/:/, `ypmatch $key group.byname`);
+ my (@members) = split ',', $x[3];
+ $me->{_array_reference} = \@members;
+}
+
+
+
+=head1 NAME
+
+IO::Adapter::NIS.pm - what is this
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+=head1 CLASSES
+
+=head1 METHODS
+
+=item C<new()>
+
+... what is this ...
+
+=head1 AUTHOR
+
+Ken'ichi Fukamachi
+
+=head1 COPYRIGHT
+
+Copyright (C) 2001 Ken'ichi Fukamachi
+
+All rights reserved. This program is free software; you can
+redistribute it and/or modify it under the same terms as Perl itself.
+
+=head1 HISTORY
+
+IO::Adapter::NIS.pm appeared in fml5.
+
+=cut
+
+1;
diff --git a/fml/lib/IO/Adapter/UnixGroup.pm b/fml/lib/IO/Adapter/UnixGroup.pm
new file mode 100644
index 00000000..f12e03d6
--- /dev/null
+++ b/fml/lib/IO/Adapter/UnixGroup.pm
@@ -0,0 +1,66 @@
+#-*- perl -*-
+#
+# Copyright (C) 2001 Ken'ichi Fukamachi
+# All rights reserved. This program is free software; you can
+# redistribute it and/or modify it under the same terms as Perl itself.
+#
+# $Id$
+# $FML$
+#
+
+package IO::Adapter::UnixGroup;
+
+use strict;
+use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
+use Carp;
+use IO::Adapter::Array;
+
+@ISA = qw(IO::Adapter::Array);
+
+sub configure
+{
+ my ($self, $me) = @_;
+ my ($type) = ref($self) || $self;
+
+ # emulate an array on memory
+ my (@x) = getgrnam( $me->{_name} );
+ my (@members) = split ' ', $x[3];
+ $me->{_array_reference} = \@members;
+}
+
+
+
+=head1 NAME
+
+IO::Adapter::UnixGroup.pm - what is this
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+=head1 CLASSES
+
+=head1 METHODS
+
+=item C<new()>
+
+... what is this ...
+
+=head1 AUTHOR
+
+Ken'ichi Fukamachi
+
+=head1 COPYRIGHT
+
+Copyright (C) 2001 Ken'ichi Fukamachi
+
+All rights reserved. This program is free software; you can
+redistribute it and/or modify it under the same terms as Perl itself.
+
+=head1 HISTORY
+
+IO::Adapter::UnixGroup.pm appeared in fml5.
+
+=cut
+
+1;
diff --git a/fml/lib/IO/MapAdapter.pm b/fml/lib/IO/MapAdapter.pm
index d5dcc40c..63fdc553 100644
--- a/fml/lib/IO/MapAdapter.pm
+++ b/fml/lib/IO/MapAdapter.pm
@@ -103,30 +103,19 @@ sub new
}
else {
if ($map =~ /file:(\S+)/ || $map =~ m@^(/\S+)@) {
- $pkg = 'IO::Adapter::File';
$me->{_file} = $1;
$me->{_type} = 'file';
+ $pkg = 'IO::Adapter::File';
}
elsif ($map =~ /unix\.group:(\S+)/) {
- $pkg = 'IO::Adapter::Array';
$me->{_name} = $1;
$me->{_type} = 'unix.group';
-
- # emulate an array on memory
- my (@x) = getgrnam( $me->{_name} );
- my (@members) = split ' ', $x[3];
- $me->{_array_reference} = \@members;
+ $pkg = 'IO::Adapter::UnixGroup';
}
elsif ($map =~ /nis\.group:(\S+)/) {
- my $key = $1;
- $pkg = 'IO::Adapter::Array';
- $me->{_name} = $key;
+ $me->{_name} = $1;
$me->{_type} = 'nis.group';
-
- # emulate an array on memory
- my (@x) = `ypmatch $key group.byname`;
- my (@members) = split ',', $x[3];
- $me->{_array_reference} = \@members;
+ $pkg = 'IO::Adapter::NIS';
}
elsif ($map =~ /(ldap|mysql|postgresql):(\S+)/) {
$me->{_type} = $1;
@@ -135,13 +124,13 @@ sub new
}
else {
my $s = "IO::MapAdapter::new: args='$map' is unknown.";
- print STDERR $s, "\n";
_error_reason($me, $s);
}
}
unshift(@ISA, $pkg);
eval qq{ require $pkg; $pkg->import();};
+ $pkg->configure($me) if $pkg->can('configure');
_error_reason($me, $@) if $@;
return bless $me, $type;