This commit is contained in:
leif 1998-07-23 05:31:22 +00:00
Родитель 22f50e14db
Коммит be692e043a
1 изменённых файлов: 147 добавлений и 2 удалений

Просмотреть файл

@ -1,5 +1,5 @@
#############################################################################
# $Id: LDIF.pm,v 1.1 1998/07/21 02:29:25 leif Exp $
# $Id: LDIF.pm,v 1.2 1998/07/23 05:31:22 leif Exp $
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (the "License"); you may not use this file except in
@ -11,7 +11,7 @@
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is PerlDap. The Initial Developer of the Original
# The Original Code is PerlDAP. The Initial Developer of the Original
# Code is Netscape Communications Corp. and Clayton Donley. Portions
# created by Netscape are Copyright (C) Netscape Communications
# Corp., portions created by Clayton Donley are Copyright (C) Clayton
@ -25,3 +25,148 @@
#############################################################################
package Mozilla::LDAP::LDIF;
#############################################################################
# Read the next $entry from an ::LDIF object.
#
sub readEntry
{
my($fh) = @_;
my($attr, $val, $entry, $base64);
local $_;
# Skip leading empty lines.
$entry = new Ldapp::Entry;
while (<$fh>)
{
chop;
last unless /^\s*$/;
}
return if /^$/; # EOF
$base64 = 0;
do
{
# See if it's a continuation line.
if (/^ /o)
{
$val .= substr($_, 1);
}
else
{
if ($attr eq "dn")
{
$entry->setDN($val);
}
elsif ($attr && $val)
{
$val = decode_base64($val) if $base64;
$entry->addValue($attr, "$val");
}
($attr, $val) = split(/:\s+/, $_, 2);
$attr = lc $attr;
# Handle base-64'ed data.
if ($attr =~ /:$/o)
{
$base64 = 1;
chop($attr);
}
else
{
$base64 = 0;
}
}
$_ = <$fh>;
chop;
} until /^\s*$/;
# Do the last attribute...
if ($attr && ($attr ne "dn"))
{
$val = decode_base64($val) if $base64;
$entry->addValue($attr, $val);
}
return $entry;
}
#############################################################################
# Mandatory TRUE return value.
#
1;
#############################################################################
# POD documentation...
#
__END__
=head1 NAME
Mozilla::LDAP::LDIF - Read, write and modify LDIF files.
=head1 SYNOPSIS
use Mozilla::LDAP::LDIF;
=head1 ABSTRACT
This package is the...
=head1 DESCRIPTION
LDIF rules...
=head1 EXAMPLES
There are plenty of examples to look at, in the is-ldap/perl directory. If
you don't have these files, get the distribution from one of the sites below.
=head1 INSTALLATION
Installing this package is part of the Makefile supplied in the
package. To install and use this module, you'll first need to download and
install the LDAP SDK (e.g. from http://developer.netscape.com). To build
the Perl modules, just do
perl5 Makefile.PL
make
make install
You'll get some questions during the first step, asking you to specify
where your LDAP SDK installed, and how to configure the package.
=head1 AVAILABILITY
The latest version of this script, and other related packages, are
available from
=head1 AUTHOR INFORMATION
Address bug reports and comments to:
=head1 CREDITS
=head1 BUGS and TODO
None :).
=over 4
=item *
Finish it.
=back
=head1 SEE ALSO
L<Mozilla::LDAP::API>, L<Mozilla::LDAP::Entry> and L<Perl>
=cut