#!/usr/bin/perl # from http://ispman.sf.net unless ( $ARGV[0] || ( -e $ARGV[0] && -f $ARGV[0] ) ) { print "Usage: $0 schema_file type\n"; print "type: ibm|iplanet\n"; exit; } $vendor = $ARGV[1] || "iplanet"; print "dn: cn=schema\n" if $type eq "iplanet"; $c = -1; for (<>) { s/^ //g; next unless /\S/; next if /^#/; #print; if (/^\s*objectclass/i) { $c++; $type = "objectclass"; } if (/^\s*attributetype/i) { $c++; $type = "attribute"; } $data->{$type}[$c] .= $_; } $oc->{'iplanet'} = "objectClass:"; $oc->{'ibm'} = "objectClass="; $at->{'iplanet'} = "attributeTypes:"; $at->{'ibm'} = "attributeTypes="; for $type ( keys %$data ) { $array = $data->{$type}; ELEMENT: for $element (@$array) { $element =~ s/\n/ /g; $element =~ s/\t/ /g; $element =~ s/ {2}/ /g; $element =~ s/^objectclass\s*\(\s*/$oc->{$vendor} ( /gi; $element =~ s/^attributetype\s*\(\s*/$at->{$vendor} ( /gi; $element =~ s/ $//g; $element =~ s/\)$/ \)/; next ELEMENT unless $element =~ /\S/; print "$element\n"; } }