1
1
/* map.c - ldap backend mapping routines */
2
/* $OpenLDAP: pkg/ldap/servers/slapd/back-meta/map.c,v 1.15.2.18 2011/01/31 20:47:58 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5
5
* Copyright 1998-2011 The OpenLDAP Foundation.
173
173
ldap_back_map_attrs(
174
175
struct ldapmap *at_map,
175
176
AttributeName *an,
177
char ***mapped_attrs,
178
char ***mapped_attrs )
182
182
struct berval mapped;
184
if ( an == NULL && op->o_bd->be_extra_anlist == NULL ) {
185
185
*mapped_attrs = NULL;
186
186
return LDAP_SUCCESS;
189
for ( i = 0; !BER_BVISNULL( &an[i].an_name ); i++ )
192
na = (char **)ber_memcalloc_x( i + 1, sizeof(char *), memctx );
191
for ( ; !BER_BVISNULL( &an[i].an_name ); i++ )
196
if ( op->o_bd->be_extra_anlist != NULL ) {
197
for ( ; !BER_BVISNULL( &op->o_bd->be_extra_anlist[x].an_name ); x++ )
201
assert( i > 0 || x > 0 );
203
na = (char **)ber_memcalloc_x( i + x + 1, sizeof(char *), op->o_tmpmemctx );
193
204
if ( na == NULL ) {
194
205
*mapped_attrs = NULL;
195
206
return LDAP_NO_MEMORY;
198
for ( i = j = 0; !BER_BVISNULL( &an[i].an_name ); i++ ) {
199
ldap_back_map( at_map, &an[i].an_name, &mapped, remap );
200
if ( !BER_BVISNULL( &mapped ) && !BER_BVISEMPTY( &mapped ) ) {
201
na[j++] = mapped.bv_val;
204
if ( j == 0 && i != 0 ) {
211
for ( i = 0; !BER_BVISNULL( &an[i].an_name ); i++ ) {
212
ldap_back_map( at_map, &an[i].an_name, &mapped, remap );
213
if ( !BER_BVISNULL( &mapped ) && !BER_BVISEMPTY( &mapped ) ) {
214
na[j++] = mapped.bv_val;
220
for ( x = 0; !BER_BVISNULL( &op->o_bd->be_extra_anlist[x].an_name ); x++ ) {
221
if ( op->o_bd->be_extra_anlist[x].an_desc &&
222
ad_inlist( op->o_bd->be_extra_anlist[x].an_desc, an ) )
227
ldap_back_map( at_map, &op->o_bd->be_extra_anlist[x].an_name, &mapped, remap );
228
if ( !BER_BVISNULL( &mapped ) && !BER_BVISEMPTY( &mapped ) ) {
229
na[j++] = mapped.bv_val;
234
if ( j == 0 && ( i > 0 || x > 0 ) ) {
205
235
na[j++] = LDAP_NO_ATTRS;
209
239
*mapped_attrs = na;
210
241
return LDAP_SUCCESS;