]> git.sur5r.net Git - openldap/commitdiff
System loading can now be done in one place...
authorKurt Zeilenga <kurt@openldap.org>
Sat, 30 Mar 2002 01:28:34 +0000 (01:28 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 30 Mar 2002 01:28:34 +0000 (01:28 +0000)
servers/slapd/schema_prep.c

index 7893b884afa39e478cac43616246e3075bb8aded..8097a10315b4299e6304d22f6d4b7846989f7ab5 100644 (file)
@@ -596,8 +596,42 @@ int
 slap_schema_load( void )
 {
        int i;
+
+       for( i=0; syn_map[i].sssm_name; i++ ) {
+               Syntax ** synp = (Syntax **)
+                       &(((char *) &slap_schema)[syn_map[i].sssm_offset]);
+
+               assert( *synp == NULL );
+
+               *synp = syn_find( syn_map[i].sssm_name );
+
+               if( *synp == NULL ) {
+                       fprintf( stderr, "slap_schema_check: "
+                               "No syntax \"%s\" defined in schema\n",
+                               syn_map[i].sssm_name );
+                       return LDAP_INVALID_SYNTAX;
+               }
+       }
+
+       for( i=0; mr_map[i].ssmm_name; i++ ) {
+               MatchingRule ** mrp = (MatchingRule **)
+                       &(((char *) &slap_schema)[mr_map[i].ssmm_offset]);
+
+               assert( *mrp == NULL );
+
+               *mrp = mr_find( mr_map[i].ssmm_name );
+
+               if( *mrp == NULL ) {
+                       fprintf( stderr, "slap_schema_check: "
+                               "No matching rule \"%s\" defined in schema\n",
+                               mr_map[i].ssmm_name );
+                       return LDAP_INAPPROPRIATE_MATCHING;
+               }
+       }
+
        for( i=0; ad_map[i].ssam_name; i++ ) {
-               if( ad_map[i].ssam_defn != NULL ) {
+               assert( ad_map[i].ssam_defn != NULL );
+               {
                        LDAPAttributeType *at;
                        int             code;
                        const char      *err;
@@ -627,10 +661,40 @@ slap_schema_load( void )
                        }
                        ldap_memfree( at );
                }
+               {
+                       int rc;
+                       const char *text;
+
+                       AttributeDescription ** adp = (AttributeDescription **)
+                               &(((char *) &slap_schema)[ad_map[i].ssam_offset]);
+
+                       assert( *adp == NULL );
+
+                       rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
+                       if( rc != LDAP_SUCCESS ) {
+                               fprintf( stderr, "slap_schema_check: "
+                                       "No attribute \"%s\" defined in schema\n",
+                                       ad_map[i].ssam_name );
+                               return rc;
+                       }
+
+                       if( ad_map[i].ssam_check ) {
+                               /* install check routine */
+                               (*adp)->ad_type->sat_check = ad_map[i].ssam_check;
+                       }
+                       /* install flags */
+                       (*adp)->ad_type->sat_flags |= ad_map[i].ssam_flags;
+
+                       if( ad_map[i].ssam_match ) {
+                               /* install custom matching routine */
+                               (*adp)->ad_type->sat_equality->smr_match = ad_map[i].ssam_match;
+                       }
+               }
        }
 
        for( i=0; oc_map[i].ssom_name; i++ ) {
-               if( oc_map[i].ssom_defn != NULL ) {
+               assert( oc_map[i].ssom_defn != NULL );
+               {
                        LDAPObjectClass *oc;
                        int             code;
                        const char      *err;
@@ -661,104 +725,40 @@ slap_schema_load( void )
 
                        ldap_memfree(oc);
                }
-       }
-
-       return LDAP_SUCCESS;
-}
-
-int
-slap_schema_check( void )
-{
-       int i;
-       /* we should only be called once after schema_init() was called */
-       assert( schema_init_done == 1 );
-
-       for( i=0; syn_map[i].sssm_name; i++ ) {
-               Syntax ** synp = (Syntax **)
-                       &(((char *) &slap_schema)[syn_map[i].sssm_offset]);
-
-               assert( *synp == NULL );
-
-               *synp = syn_find( syn_map[i].sssm_name );
-
-               if( *synp == NULL ) {
-                       fprintf( stderr, "slap_schema_check: "
-                               "No syntax \"%s\" defined in schema\n",
-                               syn_map[i].sssm_name );
-                       return LDAP_INVALID_SYNTAX;
-               }
-       }
+               {
+                       ObjectClass ** ocp = (ObjectClass **)
+                               &(((char *) &slap_schema)[oc_map[i].ssom_offset]);
 
-       for( i=0; mr_map[i].ssmm_name; i++ ) {
-               MatchingRule ** mrp = (MatchingRule **)
-                       &(((char *) &slap_schema)[mr_map[i].ssmm_offset]);
+                       assert( *ocp == NULL );
 
-               assert( *mrp == NULL );
-
-               *mrp = mr_find( mr_map[i].ssmm_name );
+                       *ocp = oc_find( oc_map[i].ssom_name );
+                       if( *ocp == NULL ) {
+                               fprintf( stderr, "slap_schema_check: "
+                                       "No objectClass \"%s\" defined in schema\n",
+                                       oc_map[i].ssom_name );
+                               return LDAP_OBJECT_CLASS_VIOLATION;
+                       }
 
-               if( *mrp == NULL ) {
-                       fprintf( stderr, "slap_schema_check: "
-                               "No matching rule \"%s\" defined in schema\n",
-                               mr_map[i].ssmm_name );
-                       return LDAP_INAPPROPRIATE_MATCHING;
+                       if( oc_map[i].ssom_check ) {
+                               /* install check routine */
+                               (*ocp)->soc_check = oc_map[i].ssom_check;
+                       }
+                       /* install flags */
+                       (*ocp)->soc_flags |= oc_map[i].ssom_flags;
                }
        }
 
        slap_at_undefined.sat_syntax = slap_schema.si_syn_distinguishedName;
        slap_schema.si_at_undefined = &slap_at_undefined;
 
-       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]);
-
-               assert( *adp == NULL );
-
-               rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
-               if( rc != LDAP_SUCCESS ) {
-                       fprintf( stderr, "slap_schema_check: "
-                               "No attribute \"%s\" defined in schema\n",
-                               ad_map[i].ssam_name );
-                       return rc;
-               }
-
-               if( ad_map[i].ssam_check ) {
-                       /* install check routine */
-                       (*adp)->ad_type->sat_check = ad_map[i].ssam_check;
-               }
-               /* install flags */
-               (*adp)->ad_type->sat_flags |= ad_map[i].ssam_flags;
-
-               if( ad_map[i].ssam_match ) {
-                       /* install custom matching routine */
-                       (*adp)->ad_type->sat_equality->smr_match = ad_map[i].ssam_match;
-               }
-       }
-
-       for( i=0; oc_map[i].ssom_name; i++ ) {
-               ObjectClass ** ocp = (ObjectClass **)
-                       &(((char *) &slap_schema)[oc_map[i].ssom_offset]);
-
-               assert( *ocp == NULL );
-
-               *ocp = oc_find( oc_map[i].ssom_name );
-               if( *ocp == NULL ) {
-                       fprintf( stderr, "slap_schema_check: "
-                               "No objectClass \"%s\" defined in schema\n",
-                               oc_map[i].ssom_name );
-                       return LDAP_OBJECT_CLASS_VIOLATION;
-               }
+       return LDAP_SUCCESS;
+}
 
-               if( oc_map[i].ssom_check ) {
-                       /* install check routine */
-                       (*ocp)->soc_check = oc_map[i].ssom_check;
-               }
-               /* install flags */
-               (*ocp)->soc_flags |= oc_map[i].ssom_flags;
-       }
+int
+slap_schema_check( void )
+{
+       /* we should only be called once after schema_init() was called */
+       assert( schema_init_done == 1 );
 
        ++schema_init_done;
        return LDAP_SUCCESS;