|
From: Graham B. <gb...@us...> - 2004-01-01 09:43:22
|
Update of /cvsroot/perl-ldap/ldap/lib/Net/LDAP
In directory sc8-pr-cvs1:/tmp/cvs-serv2223
Modified Files:
LDIF.pm LDIF.pod
Log Message:
Patch from Peter Marschall to Net::LDAP::LDIF
* it separates the "version: 1" line from the first entry by a blank line
* it allows the version() method to set the version number and documents it.
* it makes the option "change" to the constructor explicit and documents it
in Net::LDAP::LDIF.pod (defaulting to the current change => 0)
* it allows entries with changetype "moddn" to be treated correctly
(current version treats them as modifies)
* it allows the "deleteoldrdn" attribute in the entry to be missing
and treats the absent attribute as 0. (in the current version
scalar chokes if the entry does not contain a deleteoldrdn attribute)
Index: LDIF.pm
===================================================================
RCS file: /cvsroot/perl-ldap/ldap/lib/Net/LDAP/LDIF.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- LDIF.pm 24 Oct 2002 13:04:45 -0000 1.19
+++ LDIF.pm 1 Jan 2004 09:43:19 -0000 1.20
@@ -9,7 +9,7 @@
require Net::LDAP::Entry;
use vars qw($VERSION);
-$VERSION = "0.13";
+$VERSION = "0.14";
my %mode = qw(w > r < a >>);
@@ -51,9 +51,9 @@
$opt{'onerror'} = 'die' unless exists $opt{'onerror'};
$opt{'lowercase'} ||= 0;
+ $opt{'change'} ||= 0;
my $self = {
- change => 0,
changetype => "modify",
modify => 'add',
wrap => 78,
@@ -376,7 +376,7 @@
print "\n";
}
else {
- print "version: $self->{version}\n" if defined $self->{version};
+ print "version: $self->{version}\n\n" if defined $self->{version};
}
_write_dn($entry->dn,$self->{'encode'},$wrap);
@@ -389,9 +389,10 @@
_write_attrs($entry,$wrap,$lower);
next;
}
- elsif ($type eq 'modrdn') {
+ elsif ($type =~ /modr?dn/o) {
+ my $deleteoldrdn = $entry->get_value('deleteoldrdn') || 0;
print _write_attr('newrdn',$entry->get_value('newrdn', asref => 1),$wrap,$lower);
- print 'deleteoldrdn: ', scalar $entry->get_value('deleteoldrdn'),"\n";
+ print 'deleteoldrdn: ', $deleteoldrdn,"\n";
my $ns = $entry->get_value('newsuperior', asref => 1);
print _write_attr('newsuperior',$ns,$wrap,$lower) if defined $ns;
next;
@@ -419,7 +420,7 @@
print "\n";
}
else {
- print "version: $self->{version}\n" if defined $self->{version};
+ print "version: $self->{version}\n\n" if defined $self->{version};
}
_write_dn($entry->dn,$self->{'encode'},$wrap);
_write_attrs($entry,$wrap,$lower);
@@ -523,7 +524,8 @@
sub version {
my $self = shift;
- $self->{version};
+ return $self->{version} unless @_;
+ $self->{version} = shift;
}
sub next_lines {
Index: LDIF.pod
===================================================================
RCS file: /cvsroot/perl-ldap/ldap/lib/Net/LDAP/LDIF.pod,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- LDIF.pod 10 Dec 2003 20:31:46 -0000 1.9
+++ LDIF.pod 1 Jan 2004 09:43:19 -0000 1.10
@@ -68,8 +68,6 @@
=back
-=back
-
=item onerror =E<gt> 'die' | 'warn' | undef
Specify what happens when an error is detected.
@@ -89,6 +87,21 @@
C<Net::LDAP::LDIF> will warn with an appropriate message if C<-w> is
in effect. The method that was called will return C<undef>.
+=item change =E<gt> 1
+
+Write entry changes to the LDIF file instead of the entries itself.
+I.e. write LDAP operations acting on the entries to the file instead of the entries contents.
+
+=item version =E<gt> '1'
+
+Set the LDIF version to write to the resulting LDIF file.
+
+According to RFC 2849 currently the only legal value for this option is I<1>.
+
+The default is I<undef> meaning no version information is written to the LDIF file.
+
+=back
+
=back
=item change =E<gt> 1
@@ -113,6 +126,14 @@
=item write_entry ( ENTRIES )
Write the entries to the LDIF file.
+
+=item version ( [ VERSION ] )
+
+If called without arguments it returns the version of the LDIF file
+or undef if no version has been set.
+If called with an argument it sets the LDIF version to VERSION.
+
+According to RFC 2849 currently the only legal value for VERSION is I<1>.
=item done ( )
|