1cdf0e10cSrcweir: # -*- perl -*-
2*2123d757SAndrew Rist#**************************************************************
3*2123d757SAndrew Rist#
4*2123d757SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
5*2123d757SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
6*2123d757SAndrew Rist#  distributed with this work for additional information
7*2123d757SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
8*2123d757SAndrew Rist#  to you under the Apache License, Version 2.0 (the
9*2123d757SAndrew Rist#  "License"); you may not use this file except in compliance
10*2123d757SAndrew Rist#  with the License.  You may obtain a copy of the License at
11*2123d757SAndrew Rist#
12*2123d757SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
13*2123d757SAndrew Rist#
14*2123d757SAndrew Rist#  Unless required by applicable law or agreed to in writing,
15*2123d757SAndrew Rist#  software distributed under the License is distributed on an
16*2123d757SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17*2123d757SAndrew Rist#  KIND, either express or implied.  See the License for the
18*2123d757SAndrew Rist#  specific language governing permissions and limitations
19*2123d757SAndrew Rist#  under the License.
20*2123d757SAndrew Rist#
21*2123d757SAndrew Rist#**************************************************************
22cdf0e10cSrcweir
23cdf0e10cSrcweir# generates of the component schema list an ldap schema in ldif format
24cdf0e10cSrcweir
25cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}'
26cdf0e10cSrcweir	if 0;
27cdf0e10cSrcweir
28cdf0e10cSrcweir#creating the output file
29cdf0e10cSrcweiropen(OUTFILE, ">$ARGV[0]") or die "can't open >$ARGV[0]";
30cdf0e10cSrcweir
31cdf0e10cSrcweir#open the makefile
32cdf0e10cSrcweiropen(INFILE, "makefile.mk") or die "can't open makefile.mk";
33cdf0e10cSrcweir
34cdf0e10cSrcweir$inxcs=0;
35cdf0e10cSrcweir
36cdf0e10cSrcweir#search all schemas in the makefile except userprofile and format them as e.g org.openoffice.Inet
37cdf0e10cSrcweirwhile(<INFILE>) {
38cdf0e10cSrcweir	tr/\r\n//d;
39cdf0e10cSrcweir
40cdf0e10cSrcweir	if (/^\s*XCSFILES/) {
41cdf0e10cSrcweir		$inxcs++;
42cdf0e10cSrcweir	}
43cdf0e10cSrcweir	next unless $inxcs;
44cdf0e10cSrcweir
45cdf0e10cSrcweir	if ($inxcs) {
46cdf0e10cSrcweir
47cdf0e10cSrcweir		$inxcs=0 unless /\\$/;
48cdf0e10cSrcweir
49cdf0e10cSrcweir		next if (/^\s*XCSFILES/);
50cdf0e10cSrcweir		next if (/UserProfile/);
51cdf0e10cSrcweir
52cdf0e10cSrcweir		s/^\s+//;
53cdf0e10cSrcweir		s/\s*\\$//;
54cdf0e10cSrcweir		s/\.xcs.*$//;
55cdf0e10cSrcweir		s#\$/#.#g;
56cdf0e10cSrcweir
57cdf0e10cSrcweir		push(@comp_names, $_);
58cdf0e10cSrcweir	}
59cdf0e10cSrcweir}
60cdf0e10cSrcweirclose(INFILE);
61cdf0e10cSrcweir
62cdf0e10cSrcweir# generate the schema in ldif format
63cdf0e10cSrcweirforeach (@comp_names) {
64cdf0e10cSrcweir
65cdf0e10cSrcweir	s#org.openoffice.#oo-#g;
66cdf0e10cSrcweir	s#\.#-#g;
67cdf0e10cSrcweir
68cdf0e10cSrcweir	$myLdapName=lc $_;
69cdf0e10cSrcweir
70cdf0e10cSrcweir	print OUTFILE "dn: cn=schema\n";
71cdf0e10cSrcweir	print OUTFILE "attributetypes: ($myLdapName-attr-oid NAME '$myLdapName-attr' DESC '$myLdapName attribute' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE_VALUE )\n\n";
72cdf0e10cSrcweir
73cdf0e10cSrcweir	print OUTFILE "dn: cn=schema\n";
74cdf0e10cSrcweir	print OUTFILE "objectclasses: ($myLdapName-class-oid NAME '$myLdapName-class' DESC '$myLdapName objclass' SUP 'top' MAY ($myLdapName-attr \$ ))\n\n";
75cdf0e10cSrcweir}
76cdf0e10cSrcweir
77cdf0e10cSrcweirclose(OUTFILE);
78cdf0e10cSrcweir
79cdf0e10cSrcweirexit 0;
80