From: Pierangelo Masarati Date: Fri, 4 Jan 2002 17:51:20 +0000 (+0000) Subject: hide mapping initialization X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~297 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bd535be5cb4938356509fac5c2e81c6cdde9d96e;p=openldap hide mapping initialization --- diff --git a/servers/slapd/back-ldap/back-ldap.h b/servers/slapd/back-ldap/back-ldap.h index 4a4f782063..ed34a21b3c 100644 --- a/servers/slapd/back-ldap/back-ldap.h +++ b/servers/slapd/back-ldap/back-ldap.h @@ -101,6 +101,7 @@ extern int ldap_back_conn_dup( void *c1, void *c2 ); int mapping_cmp (const void *, const void *); int mapping_dup (void *, void *); +void ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping ** ); void ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *m, int remap ); char * diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c index 6d6890919c..8f041a117e 100644 --- a/servers/slapd/back-ldap/config.c +++ b/servers/slapd/back-ldap/config.c @@ -318,6 +318,33 @@ mapping_dup ( void *c1, void *c2 ) return( ( strcasecmp(map1->src.bv_val, map2->src.bv_val) == 0 ) ? -1 : 0 ); } +void +ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping **m ) +{ + struct ldapmapping *mapping; + + assert( m ); + + *m = NULL; + + mapping = (struct ldapmapping *)ch_calloc( 2, + sizeof( struct ldapmapping ) ); + if ( mapping == NULL ) { + return; + } + + ber_str2bv( "objectclass", sizeof("objectclass")-1, 1, &mapping->src); + ber_dupbv( &mapping->dst, &mapping->src ); + mapping[1].src = mapping->src; + mapping[1].dst = mapping->dst; + + avl_insert( &lm->map, (caddr_t)mapping, + mapping_cmp, mapping_dup ); + avl_insert( &lm->remap, (caddr_t)&mapping[1], + mapping_cmp, mapping_dup ); + *m = mapping; +} + void ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *bv, int remap ) diff --git a/servers/slapd/back-ldap/init.c b/servers/slapd/back-ldap/init.c index 37749d3300..13c9e237b8 100644 --- a/servers/slapd/back-ldap/init.c +++ b/servers/slapd/back-ldap/init.c @@ -120,18 +120,7 @@ ldap_back_db_init( ldap_pvt_thread_mutex_init( &li->conn_mutex ); - mapping = (struct ldapmapping *)ch_calloc( 2, sizeof(struct ldapmapping) ); - if ( mapping != NULL ) { - ber_str2bv( "objectclass", sizeof("objectclass")-1, 1, &mapping->src); - ber_dupbv( &mapping->dst, &mapping->src ); - mapping[1].src = mapping->src; - mapping[1].dst = mapping->dst; - - avl_insert( &li->at_map.map, (caddr_t)mapping, - mapping_cmp, mapping_dup ); - avl_insert( &li->at_map.remap, (caddr_t)&mapping[1], - mapping_cmp, mapping_dup ); - } + ldap_back_map_init( &li->at_map, &mapping ); be->be_private = li; diff --git a/servers/slapd/back-meta/config.c b/servers/slapd/back-meta/config.c index 3c2f67bf51..332b285d4b 100644 --- a/servers/slapd/back-meta/config.c +++ b/servers/slapd/back-meta/config.c @@ -99,20 +99,7 @@ new_target( void ) return NULL; } - mapping = ch_calloc( 2, sizeof( struct ldapmapping ) ); - if ( mapping == NULL ) { - free( lt ); - return NULL; - } - ber_str2bv( "objectClass", 0, 1, &mapping->src ); - ber_str2bv( "objectClass", 0, 1, &mapping->dst ); - mapping[ 1 ].src = mapping->src; - mapping[ 1 ].dst = mapping->dst; - - avl_insert( <->at_map.map, ( caddr_t )mapping, - mapping_cmp, mapping_dup ); - avl_insert( <->at_map.remap, ( caddr_t )&mapping[ 1 ], - mapping_cmp, mapping_dup ); + ldap_back_map_init( <->at_map, &mapping ); return lt; } @@ -261,9 +248,11 @@ meta_back_db_config( ldap_free_urldesc( ludp ); +#if 0 fprintf(stderr, "%s: line %d: URI \"%s\", suffix \"%s\"\n", fname, lineno, li->targets[ i ]->uri, li->targets[ i ]->psuffix.bv_val ); +#endif /* default target directive */ } else if ( strcasecmp( argv[ 0 ], "default-target" ) == 0 ) {