From f9766f684b43d6d2f2e0542c1ed487d10b1e7c00 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 30 Mar 2002 01:28:34 +0000 Subject: [PATCH] System loading can now be done in one place... --- servers/slapd/schema_prep.c | 180 ++++++++++++++++++------------------ 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 7893b884af..8097a10315 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -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; -- 2.39.5