]> git.sur5r.net Git - openldap/commitdiff
Split schema_prep() from schema_init.c
authorKurt Zeilenga <kurt@openldap.org>
Thu, 25 May 2000 01:49:21 +0000 (01:49 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 25 May 2000 01:49:21 +0000 (01:49 +0000)
servers/slapd/Makefile.in
servers/slapd/proto-slap.h
servers/slapd/schema_init.c
servers/slapd/schema_prep.c [new file with mode: 0644]
servers/slapd/tools/Makefile.in

index ebbde713efcd965f83d079aabce2d9435bdb56f3..6da5b9f2790a54b8b6de1a10a02759ce6376e9c8 100644 (file)
@@ -15,8 +15,8 @@ SRCS  = main.c daemon.c connection.c search.c filter.c add.c charray.c \
                value.c ava.c bind.c unbind.c abandon.c filterentry.c \
                phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
                repl.c lock.c controls.c extended.c kerberos.c passwd.c \
-               schema.c schema_check.c schema_init.c schemaparse.c \
-               ad.c at.c mr.c syntax.c oc.c \
+               schema.c schema_check.c schema_init.c schema_prep.c \
+               schemaparse.c ad.c at.c mr.c syntax.c oc.c \
                monitor.c configinfo.c starttls.c \
                root_dse.c sasl.c module.c suffixalias.c $(@PLAT@_SRCS)
 
@@ -26,8 +26,8 @@ OBJS  = main.o daemon.o connection.o search.o filter.o add.o charray.o \
                value.o ava.o bind.o unbind.o abandon.o filterentry.o \
                phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
                repl.o lock.o controls.o extended.o kerberos.o passwd.o \
-               schema.o schema_check.o schema_init.o schemaparse.o \
-               ad.o at.o mr.o syntax.o oc.o \
+               schema.o schema_check.o schema_init.o schema_prep.o \
+               schemaparse.o ad.o at.o mr.o syntax.o oc.o \
                monitor.o configinfo.o starttls.o \
                root_dse.o sasl.o module.o suffixalias.o $(@PLAT@_OBJS)
 
index 63a24f7cda70ff8582bdfbd5d9bd4994eed5c0e4..3338ebdc25326397046b59348bc7db0524bbe889 100644 (file)
@@ -12,6 +12,7 @@ LDAP_BEGIN_DECL
 
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
 LIBSLAPD_F( struct slap_internal_schema ) slap_schema;
+LIBSLAPD_F( int ) schema_init_done;
 
 LIBSLAPD_F (int) slap_str2ad LDAP_P((
        const char *,
index 3e98b7f7a238f7441b769d690d58db69b97f3616..a812c925575fa7d102b10ad49fd9b35a692e08e0 100644 (file)
@@ -329,22 +329,6 @@ caseIgnoreIA5Match(
        return LDAP_SUCCESS;
 }
 
-static int
-objectClassMatch(
-       int *match,
-       unsigned use,
-       Syntax *syntax,
-       MatchingRule *mr,
-       struct berval *value,
-       void *assertedValue )
-{
-       ObjectClass *oc = oc_find( value->bv_val );
-       ObjectClass *asserted = oc_find( ((struct berval *) assertedValue)->bv_val );
-
-       *match = ( oc == NULL || oc != asserted );
-       return LDAP_SUCCESS;
-}
-
 struct syntax_defs_rec {
        char *sd_desc;
        int sd_flags;
@@ -684,8 +668,6 @@ struct mrule_defs_rec mrule_defs[] = {
        {NULL, SLAP_MR_NONE, NULL, NULL, NULL}
 };
 
-static int schema_init_done = 0;
-
 int
 schema_init( void )
 {
@@ -742,135 +724,3 @@ schema_init( void )
        schema_init_done = 1;
        return LDAP_SUCCESS;
 }
-
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
-struct slap_internal_schema slap_schema;
-
-struct slap_schema_oc_map {
-       char *ssom_name;
-       size_t ssom_offset;
-} oc_map[] = {
-       { "alias", offsetof(struct slap_internal_schema, si_oc_alias) },
-       { "referral", offsetof(struct slap_internal_schema, si_oc_referral) },
-       { NULL, 0 }
-};
-
-struct slap_schema_ad_map {
-       char *ssam_name;
-       slap_mr_match_func *ssam_match;
-       size_t ssam_offset;
-} ad_map[] = {
-       { "objectClass", objectClassMatch,
-               offsetof(struct slap_internal_schema, si_ad_objectClass) },
-
-       { "creatorsName", NULL,
-               offsetof(struct slap_internal_schema, si_ad_creatorsName) },
-       { "createTimestamp", NULL,
-               offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
-       { "modifiersName", NULL,
-               offsetof(struct slap_internal_schema, si_ad_modifiersName) },
-       { "modifyTimestamp", NULL,
-               offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
-
-       { "subschemaSubentry", NULL,
-               offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
-
-       { "namingContexts", NULL,
-               offsetof(struct slap_internal_schema, si_ad_namingContexts) },
-       { "supportedControl", NULL,
-               offsetof(struct slap_internal_schema, si_ad_supportedControl) },
-       { "supportedExtension", NULL,
-               offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
-       { "supportedLDAPVersion", NULL,
-               offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
-       { "supportedACIMechanisms", NULL,
-               offsetof(struct slap_internal_schema, si_ad_supportedACIMechanisms) },
-
-#endif
-       { "supportedSASLMechanisms", NULL,
-               offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
-
-       { "attributeTypes", NULL,
-               offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
-       { "ldapSyntaxes", NULL,
-               offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
-       { "matchingRules", NULL,
-               offsetof(struct slap_internal_schema, si_ad_matchingRules) },
-       { "objectClasses", NULL,
-               offsetof(struct slap_internal_schema, si_ad_objectClasses) },
-
-       { "ref", NULL,
-               offsetof(struct slap_internal_schema, si_ad_ref) },
-
-       { "entry", NULL,
-               offsetof(struct slap_internal_schema, si_ad_entry) },
-       { "children", NULL,
-               offsetof(struct slap_internal_schema, si_ad_children) },
-
-       { "userPassword", NULL,
-               offsetof(struct slap_internal_schema, si_ad_userPassword) },
-       { "authPassword", NULL,
-               offsetof(struct slap_internal_schema, si_ad_authPassword) },
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
-       { "krbName", NULL,
-               offsetof(struct slap_internal_schema, si_ad_krbName) },
-#endif
-
-       { NULL, NULL, 0 }
-};
-
-#endif
-
-int
-schema_prep( void )
-{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
-       int i;
-#endif
-       /* we should only be called once after schema_init() was called */
-       assert( schema_init_done == 1 );
-
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
-       for( i=0; oc_map[i].ssom_name; i++ ) {
-               ObjectClass ** ocp = (ObjectClass **)
-                       &(((char *) &slap_schema)[oc_map[i].ssom_offset]);
-
-               *ocp = oc_find( oc_map[i].ssom_name );
-
-               if( *ocp == NULL ) {
-                       fprintf( stderr,
-                               "No objectClass \"%s\" defined in schema\n",
-                               oc_map[i].ssom_name );
-                       return LDAP_OBJECT_CLASS_VIOLATION;
-               }
-       }
-
-       for( i=0; ad_map[i].ssam_name; i++ ) {
-               int rc;
-               const char *text;
-
-               AttributeDescription ** adp = (AttributeDescription **)
-                       &(((char *) &slap_schema)[ad_map[i].ssam_offset]);
-
-               *adp = NULL;
-
-               rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
-
-               if( rc != LDAP_SUCCESS ) {
-                       fprintf( stderr,
-                               "No attribute \"%s\" defined in schema\n",
-                               ad_map[i].ssam_name );
-                       return rc;
-               }
-
-               if( ad_map[i].ssam_match ) {
-                       /* install custom matching routine */
-                       (*adp)->ad_type->sat_equality->smr_match = ad_map[i].ssam_match;
-               }
-       }
-#endif
-
-       ++schema_init_done;
-       return LDAP_SUCCESS;
-}
diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c
new file mode 100644 (file)
index 0000000..086b1a2
--- /dev/null
@@ -0,0 +1,167 @@
+/* schema_init.c - init builtin schema */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "ldap_pvt.h"
+
+int schema_init_done = 0;
+
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+struct slap_internal_schema slap_schema;
+
+static int
+objectClassMatch(
+       int *match,
+       unsigned use,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *value,
+       void *assertedValue )
+{
+       ObjectClass *oc = oc_find( value->bv_val );
+       ObjectClass *asserted = oc_find( ((struct berval *) assertedValue)->bv_val );
+
+       *match = ( oc == NULL || oc != asserted );
+       return LDAP_SUCCESS;
+}
+
+struct slap_schema_oc_map {
+       char *ssom_name;
+       size_t ssom_offset;
+} oc_map[] = {
+       { "alias", offsetof(struct slap_internal_schema, si_oc_alias) },
+       { "referral", offsetof(struct slap_internal_schema, si_oc_referral) },
+       { NULL, 0 }
+};
+
+struct slap_schema_ad_map {
+       char *ssam_name;
+       slap_mr_match_func *ssam_match;
+       size_t ssam_offset;
+} ad_map[] = {
+       { "objectClass", objectClassMatch,
+               offsetof(struct slap_internal_schema, si_ad_objectClass) },
+
+       { "creatorsName", NULL,
+               offsetof(struct slap_internal_schema, si_ad_creatorsName) },
+       { "createTimestamp", NULL,
+               offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
+       { "modifiersName", NULL,
+               offsetof(struct slap_internal_schema, si_ad_modifiersName) },
+       { "modifyTimestamp", NULL,
+               offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
+
+       { "subschemaSubentry", NULL,
+               offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
+
+       { "namingContexts", NULL,
+               offsetof(struct slap_internal_schema, si_ad_namingContexts) },
+       { "supportedControl", NULL,
+               offsetof(struct slap_internal_schema, si_ad_supportedControl) },
+       { "supportedExtension", NULL,
+               offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
+       { "supportedLDAPVersion", NULL,
+               offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
+       { "supportedACIMechanisms", NULL,
+               offsetof(struct slap_internal_schema, si_ad_supportedACIMechanisms) },
+
+#endif
+       { "supportedSASLMechanisms", NULL,
+               offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
+
+       { "attributeTypes", NULL,
+               offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
+       { "ldapSyntaxes", NULL,
+               offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
+       { "matchingRules", NULL,
+               offsetof(struct slap_internal_schema, si_ad_matchingRules) },
+       { "objectClasses", NULL,
+               offsetof(struct slap_internal_schema, si_ad_objectClasses) },
+
+       { "ref", NULL,
+               offsetof(struct slap_internal_schema, si_ad_ref) },
+
+       { "entry", NULL,
+               offsetof(struct slap_internal_schema, si_ad_entry) },
+       { "children", NULL,
+               offsetof(struct slap_internal_schema, si_ad_children) },
+
+       { "userPassword", NULL,
+               offsetof(struct slap_internal_schema, si_ad_userPassword) },
+       { "authPassword", NULL,
+               offsetof(struct slap_internal_schema, si_ad_authPassword) },
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
+       { "krbName", NULL,
+               offsetof(struct slap_internal_schema, si_ad_krbName) },
+#endif
+
+       { NULL, NULL, 0 }
+};
+
+#endif
+
+int
+schema_prep( void )
+{
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+       int i;
+#endif
+       /* we should only be called once after schema_init() was called */
+       assert( schema_init_done == 1 );
+
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+       for( i=0; oc_map[i].ssom_name; i++ ) {
+               ObjectClass ** ocp = (ObjectClass **)
+                       &(((char *) &slap_schema)[oc_map[i].ssom_offset]);
+
+               *ocp = oc_find( oc_map[i].ssom_name );
+
+               if( *ocp == NULL ) {
+                       fprintf( stderr,
+                               "No objectClass \"%s\" defined in schema\n",
+                               oc_map[i].ssom_name );
+                       return LDAP_OBJECT_CLASS_VIOLATION;
+               }
+       }
+
+       for( i=0; ad_map[i].ssam_name; i++ ) {
+               int rc;
+               const char *text;
+
+               AttributeDescription ** adp = (AttributeDescription **)
+                       &(((char *) &slap_schema)[ad_map[i].ssam_offset]);
+
+               *adp = NULL;
+
+               rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
+
+               if( rc != LDAP_SUCCESS ) {
+                       fprintf( stderr,
+                               "No attribute \"%s\" defined in schema\n",
+                               ad_map[i].ssam_name );
+                       return rc;
+               }
+
+               if( ad_map[i].ssam_match ) {
+                       /* install custom matching routine */
+                       (*adp)->ad_type->sat_equality->smr_match = ad_map[i].ssam_match;
+               }
+       }
+#endif
+
+       ++schema_init_done;
+       return LDAP_SUCCESS;
+}
index 7b897ce186dd04fc820732a3012db7527db6ab30..436ee3c1a6f7c9590483faac69c5bfb15ecbf9de 100644 (file)
@@ -53,8 +53,8 @@ BDB2SRCS =
 QUIPUSRCS      = edb2ldif.c ldapsyntax.c chlog2replog.c
 SLAPD_OBJS = ../config.o ../ch_malloc.o ../backend.o ../charray.o \
                ../module.o ../aclparse.o ../filterentry.o \
-               ../schema.o ../schema_check.o ../schema_init.o ../schemaparse.o \
-               ../ad.o ../at.o ../mr.o ../oc.o ../syntax.o \
+               ../schema.o ../schema_check.o ../schema_init.o ../schema_parse.o \
+               ../schemaparse.o ../ad.o ../at.o ../mr.o ../oc.o ../syntax.o \
                ../acl.o ../phonetic.o ../attr.o ../value.o ../entry.o \
                ../dn.o ../filter.o ../str2filter.o ../ava.o ../init.o \
                ../controls.o ../kerberos.o ../passwd.o \