char *textbuf, size_t textlen )
{
Attribute **tail;
+ int i;
if ( initial ) {
assert( (*e)->e_attrs == NULL );
if( attr != NULL ) {
#define SLURPD_FRIENDLY
#ifdef SLURPD_FRIENDLY
- ber_len_t i,j;
+ int j;
if ( !initial ) {
/*
return LDAP_SUCCESS;
}
- for( i=0; attr->a_vals[i].bv_val; i++ ) {
- /* count them */
- }
- for( j=0; mods->sml_values[j].bv_val; j++ ) {
- /* count them */
- }
+ i = attr->a_numvals;
+ j = mods->sml_numvals;
+ attr->a_numvals += j;
j++; /* NULL */
attr->a_vals = ch_realloc( attr->a_vals,
attr = attr_alloc( mods->sml_desc );
/* move values to attr structure */
+ i = mods->sml_numvals;
+ attr->a_numvals = mods->sml_numvals;
if ( dup ) {
- int i;
- for ( i = 0; mods->sml_values[i].bv_val; i++ ) /* EMPTY */;
attr->a_vals = (BerVarray) ch_calloc( i+1, sizeof( BerValue ));
for ( i = 0; mods->sml_values[i].bv_val; i++ ) {
ber_dupbv( &attr->a_vals[i], &mods->sml_values[i] );
if ( mods->sml_nvalues ) {
if ( dup ) {
- int i;
- for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) /* EMPTY */;
+ i = mods->sml_numvals;
attr->a_nvals = (BerVarray) ch_calloc( i+1, sizeof( BerValue ));
for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) {
ber_dupbv( &attr->a_nvals[i], &mods->sml_nvalues[i] );
mod->sml_type = a_new_desc->ad_cname;
- for ( count = 0; a_new->a_vals[count].bv_val; count++ ) /* EMPTY */;
+ count = a_new->a_numvals;
+ mod->sml_numvals = a_new->a_numvals;
mod->sml_values = (struct berval*) malloc(
(count+1) * sizeof( struct berval) );
a->a_comp_data = NULL;
#endif
a->a_flags = 0;
+ a->a_numvals = 0;
}
void
if ( a->a_vals != NULL ) {
int i;
- for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) {
- /* EMPTY */ ;
- }
-
- tmp->a_vals = ch_malloc( (i + 1) * sizeof(struct berval) );
- for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) {
+ tmp->a_numvals = a->a_numvals;
+ tmp->a_vals = ch_malloc( (tmp->a_numvals + 1) * sizeof(struct berval) );
+ for ( i = 0; i < tmp->a_numvals; i++ ) {
ber_dupbv( &tmp->a_vals[i], &a->a_vals[i] );
if ( BER_BVISNULL( &tmp->a_vals[i] ) ) break;
/* FIXME: error? */
if ( a->a_nvals != a->a_vals ) {
int j;
- tmp->a_nvals = ch_malloc( (i + 1) * sizeof(struct berval) );
+ tmp->a_nvals = ch_malloc( (tmp->a_numvals + 1) * sizeof(struct berval) );
for ( j = 0; !BER_BVISNULL( &a->a_nvals[j] ); j++ ) {
assert( j < i );
ber_dupbv( &tmp->a_nvals[j], &a->a_nvals[j] );
return anew;
}
+int
+attr_valadd(
+ Attribute *a,
+ BerVarray vals,
+ BerVarray nvals,
+ int nn )
+{
+ int i;
+ BerVarray v2;
+
+ v2 = (BerVarray) SLAP_REALLOC( (char *) a->a_vals,
+ (a->a_numvals + nn + 1) * sizeof(struct berval) );
+ if( v2 == NULL ) {
+ Debug(LDAP_DEBUG_TRACE,
+ "attr_valadd: SLAP_REALLOC failed.\n", 0, 0, 0 );
+ return LBER_ERROR_MEMORY;
+ }
+ a->a_vals = v2;
+ if ( nvals ) {
+ v2 = (BerVarray) SLAP_REALLOC( (char *) a->a_nvals,
+ (a->a_numvals + nn + 1) * sizeof(struct berval) );
+ if( v2 == NULL ) {
+ Debug(LDAP_DEBUG_TRACE,
+ "attr_valadd: SLAP_REALLOC failed.\n", 0, 0, 0 );
+ return LBER_ERROR_MEMORY;
+ }
+ a->a_nvals = v2;
+ } else {
+ a->a_nvals = a->a_vals;
+ }
+
+ v2 = &a->a_vals[a->a_numvals];
+ for ( i = 0 ; i < nn; i++ ) {
+ ber_dupbv( &v2[i], &vals[i] );
+ if ( BER_BVISNULL( &v2[i] ) ) break;
+ }
+ BER_BVZERO( &v2[i] );
+
+ if ( nvals ) {
+ v2 = &a->a_nvals[a->a_numvals];
+ for ( i = 0 ; i < nn; i++ ) {
+ ber_dupbv( &v2[i], &nvals[i] );
+ if ( BER_BVISNULL( &v2[i] ) ) break;
+ }
+ BER_BVZERO( &v2[i] );
+ }
+ a->a_numvals += i;
+ return 0;
+}
/*
* attr_merge - merge the given type and value with the list of
BerVarray vals,
BerVarray nvals )
{
- int rc;
+ int i = 0;
Attribute **a;
|| ( (*a)->a_nvals != (*a)->a_vals ) ) ) );
}
- rc = value_add( &(*a)->a_vals, vals );
-
- if ( rc == LDAP_SUCCESS ) {
- if ( nvals ) {
- rc = value_add( &(*a)->a_nvals, nvals );
- /* FIXME: what if rc != LDAP_SUCCESS ? */
- } else {
- (*a)->a_nvals = (*a)->a_vals;
- }
+ if ( vals != NULL ) {
+ for ( ; !BER_BVISNULL( &vals[i] ); i++ ) ;
}
-
- return rc;
+ return attr_valadd( *a, vals, nvals, i );
}
/*
struct berval *val,
struct berval *nval )
{
- int rc;
Attribute **a;
for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) {
*a = attr_alloc( desc );
}
- rc = value_add_one( &(*a)->a_vals, val );
-
- if ( rc == LDAP_SUCCESS ) {
- if ( nval ) {
- rc = value_add_one( &(*a)->a_nvals, nval );
- /* FIXME: what if rc != LDAP_SUCCESS ? */
- } else {
- (*a)->a_nvals = (*a)->a_vals;
- }
- }
- return rc;
+ return attr_valadd( *a, val, nval, 1 );
}
/*
}
a->a_desc = slap_schema.si_ad_objectClass;
- value_add_one( &a->a_vals, &oc_olmBDBDatabase->soc_cname );
- a->a_nvals = a->a_vals;
+ attr_valadd( a, &oc_olmBDBDatabase->soc_cname, NULL, 1 );
next = a->a_next;
{
struct berval bv = BER_BVC( "0" );
next->a_desc = ad_olmBDBEntryCache;
- value_add_one( &next->a_vals, &bv );
- next->a_nvals = next->a_vals;
+ attr_valadd( next, &bv, NULL, 1 );
next = next->a_next;
next->a_desc = ad_olmBDBDNCache;
- value_add_one( &next->a_vals, &bv );
- next->a_nvals = next->a_vals;
+ attr_valadd( next, &bv, NULL, 1 );
next = next->a_next;
next->a_desc = ad_olmBDBIDLCache;
- value_add_one( &next->a_vals, &bv );
- next->a_nvals = next->a_vals;
+ attr_valadd( next, &bv, NULL, 1 );
next = next->a_next;
}
next->a_desc = ad_olmDbDirectory;
next->a_vals = ch_calloc( sizeof( struct berval ), 2 );
next->a_vals[ 0 ] = bv;
+ next->a_numvals = 1;
if ( BER_BVISNULL( &nbv ) ) {
next->a_nvals = next->a_vals;
for ( last = 0; !BER_BVISNULL( &attr->a_vals[ last ] ); last++ )
/* just count vals */ ;
}
+ attr->a_numvals = last;
validate = attr->a_desc->ad_type->sat_syntax->ssyn_validate;
pretty = attr->a_desc->ad_type->sat_syntax->ssyn_pretty;
for ( last = 0; !BER_BVISNULL( &attr->a_vals[ last ] ); ++last )
;
}
+ attr->a_numvals = last;
validate = attr->a_desc->ad_type->sat_syntax->ssyn_validate;
pretty = attr->a_desc->ad_type->sat_syntax->ssyn_pretty;
/* Make space for the array of values */
attr = attr_alloc( at->bam_true_ad );
+ attr->a_numvals = count;
attr->a_vals = ch_calloc( count + 1, sizeof( struct berval ) );
if ( attr->a_vals == NULL ) {
Debug( LDAP_DEBUG_TRACE, "Out of memory!\n", 0,0,0 );
ch_free( attr );
return 1;
}
- memset( attr->a_vals, 0, ( count + 1 ) * sizeof( struct berval ) );
if ( normfunc ) {
attr->a_nvals = ch_calloc( count + 1, sizeof( struct berval ) );
if ( attr->a_nvals == NULL ) {
ch_free( attr );
return 1;
- } else {
- memset( attr->a_nvals, 0, ( count + 1 ) * sizeof( struct berval ) );
}
} else {
a = attr_alloc( desc );
+ a->a_numvals = 1;
a->a_vals = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
a->a_vals[ 0 ] = val;
BER_BVZERO( &a->a_vals[ 1 ] );
Attribute *a;
a = attr_alloc( slap_schema.si_ad_entryCSN );
+ a->a_numvals = 1;
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
BER_BVZERO( &a->a_vals[ 1 ] );
ber_bvarray_free( a->a_vals );
a->a_vals = NULL;
a->a_nvals = NULL;
+ a->a_numvals = 0;
}
oidm_unparse( &bv, NULL, NULL, 1 );
attr_merge_normalize( e, cfAd_om, bv, NULL );
ber_bvarray_free( a->a_vals );
a->a_vals = NULL;
a->a_nvals = NULL;
+ a->a_numvals = 0;
}
at_unparse( &bv, NULL, NULL, 1 );
attr_merge_normalize( e, cfAd_attr, bv, NULL );
ber_bvarray_free( a->a_vals );
a->a_vals = NULL;
a->a_nvals = NULL;
+ a->a_numvals = 0;
}
oc_unparse( &bv, NULL, NULL, 1 );
attr_merge_normalize( e, cfAd_oc, bv, NULL );
atail->a_next = attr_alloc( NULL );
atail = atail->a_next;
atail->a_flags = 0;
+ atail->a_numvals = attr_cnt;
atail->a_desc = ad_prev;
atail->a_vals = ch_malloc( (attr_cnt + 1) * sizeof(struct berval));
if( ad_prev->ad_type->sat_equality &&
*ptr++ = '\0';
if (a->a_vals) {
for (i=0; a->a_vals[i].bv_val; i++);
+ assert( i == a->a_numvals );
entry_putlen(&ptr, i);
for (i=0; a->a_vals[i].bv_val; i++) {
entry_putlen(&ptr, a->a_vals[i].bv_len);
int entry_decode(EntryHeader *eh, Entry **e)
#endif
{
- int i, j, count, nattrs, nvals;
+ int i, j, nattrs, nvals;
int rc;
Attribute *a;
Entry *x;
ptr += i + 1;
a->a_desc = ad;
a->a_flags = SLAP_ATTR_DONT_FREE_DATA | SLAP_ATTR_DONT_FREE_VALS;
- count = j = entry_getlen(&ptr);
+ j = entry_getlen(&ptr);
+ a->a_numvals = j;
a->a_vals = bptr;
while (j) {
dst->a_desc = src->a_desc;
dst->a_flags = SLAP_ATTR_DONT_FREE_DATA | SLAP_ATTR_DONT_FREE_VALS;
dst->a_vals = bvl;
+ dst->a_numvals = src->a_numvals;
for ( i=0; src->a_vals[i].bv_val; i++ ) {
bvl->bv_len = src->a_vals[i].bv_len;
bvl->bv_val = ptr;
ml->sml_values[nvals] = pval;
}
}
+ ml->sml_numvals = nvals;
/*
* a rough single value check... an additional check is needed
mod->sml_next = NULL;
BER_BVZERO( &mod->sml_type );
mod->sml_desc = slap_schema.si_ad_entryCSN;
+ mod->sml_numvals = 1;
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &csn );
BER_BVZERO( &mod->sml_values[1] );
mod->sml_next = NULL;
BER_BVZERO( &mod->sml_type );
mod->sml_desc = slap_schema.si_ad_modifiersName;
+ mod->sml_numvals = 1;
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &name );
BER_BVZERO( &mod->sml_values[1] );
mod->sml_next = NULL;
BER_BVZERO( &mod->sml_type );
mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
+ mod->sml_numvals = 1;
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], ×tamp );
BER_BVZERO( &mod->sml_values[1] );
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications ) );
mod_tmp->sml_desc = desc;
BER_BVZERO( &mod_tmp->sml_type );
+ mod_tmp->sml_numvals = 1;
mod_tmp->sml_values = ( BerVarray )ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod_tmp->sml_values[0], &new_rdn[a_cnt]->la_value );
mod_tmp->sml_values[1].bv_val = NULL;
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications ) );
mod_tmp->sml_desc = desc;
BER_BVZERO( &mod_tmp->sml_type );
+ mod_tmp->sml_numvals = 1;
mod_tmp->sml_values = ( BerVarray )ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod_tmp->sml_values[0], &old_rdn[d_cnt]->la_value );
mod_tmp->sml_values[1].bv_val = NULL;
free( a->a_nvals[j].bv_val );
a->a_nvals[j].bv_val = &dummy;
}
+ a->a_numvals--;
break;
}
a = attr_alloc( slap_schema.si_ad_subschemaSubentry );
+ a->a_numvals = 1;
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( a->a_vals, &frontendDB->be_schemadn );
a->a_vals[1].bv_len = 0;
a = attr_alloc( slap_schema.si_ad_entryDN );
+ a->a_numvals = 1;
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &a->a_vals[ 0 ], &e->e_name );
BER_BVZERO( &a->a_vals[ 1 ] );
val = hs ? slap_true_bv : slap_false_bv;
a = attr_alloc( slap_schema.si_ad_hasSubordinates );
+ a->a_numvals = 1;
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &a->a_vals[0], &val );
vals[i].bv_val = NULL;
vals[i].bv_len = 0;
a = attr_alloc( logop == LOG_EN_ADD ? ad_reqMod : ad_reqOld );
+ a->a_numvals = i;
a->a_vals = vals;
a->a_nvals = vals;
last_attr->a_next = a;
if ( i > 0 ) {
BER_BVZERO( &vals[i] );
a = attr_alloc( ad_reqMod );
+ a->a_numvals = i;
a->a_vals = vals;
a->a_nvals = vals;
last_attr->a_next = a;
vals[i].bv_val = NULL;
vals[i].bv_len = 0;
a = attr_alloc( ad_reqOld );
+ a->a_numvals = i;
a->a_vals = vals;
a->a_nvals = vals;
last_attr->a_next = a;
ad_inlist( ad_auditContext, rs->sr_attrs ) )
{
*ap = attr_alloc( ad_auditContext );
- value_add_one( &(*ap)->a_vals,
- &li->li_db->be_suffix[0] );
- value_add_one( &(*ap)->a_nvals,
- &li->li_db->be_nsuffix[0] );
+ attr_valadd( *ap,
+ &li->li_db->be_suffix[0],
+ &li->li_db->be_nsuffix[0], 1 );
}
}
tmpmod->sml_op = LDAP_MOD_REPLACE;
value_add_one( &tmpmod->sml_values, &bv );
value_add_one( &tmpmod->sml_nvalues, &bv );
+ tmpmod->sml_numvals = 1;
}
}
m->sml_flags = 0;
m->sml_type = ad_pwdFailureTime->ad_cname;
m->sml_desc = ad_pwdFailureTime;
+ m->sml_numvals = 1;
m->sml_values = ch_calloc( sizeof(struct berval), 2 );
m->sml_nvalues = ch_calloc( sizeof(struct berval), 2 );
m->sml_flags = 0;
m->sml_type = ad_pwdAccountLockedTime->ad_cname;
m->sml_desc = ad_pwdAccountLockedTime;
+ m->sml_numvals = 1;
m->sml_values = ch_calloc( sizeof(struct berval), 2 );
m->sml_nvalues = ch_calloc( sizeof(struct berval), 2 );
ber_dupbv( &m->sml_values[0], ×tamp );
m->sml_flags = 0;
m->sml_type = ad_pwdGraceUseTime->ad_cname;
m->sml_desc = ad_pwdGraceUseTime;
+ m->sml_numvals = 1;
m->sml_values = ch_calloc( sizeof(struct berval), 2 );
m->sml_nvalues = ch_calloc( sizeof(struct berval), 2 );
ber_dupbv( &m->sml_values[0], ×tamp );
ml->sml_flags = SLAP_MOD_INTERNAL;
ml->sml_type.bv_val = NULL;
ml->sml_desc = ad_pwdGraceUseTime;
+ ml->sml_numvals = 0;
ml->sml_values = NULL;
ml->sml_nvalues = NULL;
ml->sml_next = NULL;
ml->sml_flags = SLAP_MOD_INTERNAL;
ml->sml_type.bv_val = NULL;
ml->sml_desc = ad_pwdAccountLockedTime;
+ ml->sml_numvals = 0;
ml->sml_values = NULL;
ml->sml_nvalues = NULL;
ml->sml_next = NULL;
ml->sml_flags = SLAP_MOD_INTERNAL;
ml->sml_type.bv_val = NULL;
ml->sml_desc = ad_pwdFailureTime;
+ ml->sml_numvals = 0;
ml->sml_values = NULL;
ml->sml_nvalues = NULL;
ml->sml_next = NULL;
ml->sml_flags = SLAP_MOD_INTERNAL;
ml->sml_desc = pp.ad;
ml->sml_type = pp.ad->ad_cname;
+ ml->sml_numvals = 1;
ml->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &ml->sml_values[0], &oldpw );
BER_BVZERO( &ml->sml_values[1] );
mods->sml_desc = ad_pwdChangedTime;
if (pwmop != LDAP_MOD_DELETE) {
mods->sml_op = LDAP_MOD_REPLACE;
+ mods->sml_numvals = 1;
mods->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mods->sml_values[0], ×tamp );
BER_BVZERO( &mods->sml_values[1] );
mods->sml_op = LDAP_MOD_DELETE;
mods->sml_flags = SLAP_MOD_INTERNAL;
mods->sml_desc = ad_pwdHistory;
+ mods->sml_numvals = hsize - pp.pwdInHistory + 1;
mods->sml_values = ch_calloc( sizeof( struct berval ),
hsize - pp.pwdInHistory + 2 );
BER_BVZERO( &mods->sml_values[ hsize - pp.pwdInHistory + 1 ] );
mods->sml_type.bv_val = NULL;
mods->sml_desc = ad_pwdHistory;
mods->sml_nvalues = NULL;
+ mods->sml_numvals = 1;
mods->sml_values = ch_calloc( sizeof( struct berval ), 2 );
mods->sml_values[ 1 ].bv_val = NULL;
mods->sml_values[ 1 ].bv_len = 0;
ber_bvarray_add_x( &na->new_nvals, &newdn, op->o_tmpmemctx );
}
- /* count deteles */
+ /* count deletes */
if ( BER_BVISEMPTY( &rq->newdn ) ) {
deleted++;
}
m->sml_flags = SLAP_MOD_INTERNAL;
m->sml_desc = slap_schema.si_ad_modifiersName;
m->sml_type = m->sml_desc->ad_cname;
+ m->sml_numvals = 1;
m->sml_values = (BerVarray)(m+1);
m->sml_nvalues = m->sml_values+2;
BER_BVZERO( &m->sml_values[1] );
m->sml_nvalues = m->sml_values+2;
BER_BVZERO( &m->sml_values[1] );
BER_BVZERO( &m->sml_nvalues[1] );
+ m->sml_numvals = 1;
if ( BER_BVISEMPTY( &rq->newdn )) {
op->o_tmpfree( ra, op->o_tmpmemctx );
ra = dp->attrs;
mod.sm_op = LDAP_MOD_ADD;
mod.sm_desc = (*ap)->a_desc;
mod.sm_type = mod.sm_desc->ad_cname;
+ mod.sm_numvals = (*tap)->a_numvals;
mod.sm_values = (*tap)->a_vals;
mod.sm_nvalues = (*tap)->a_nvals;
a->a_nvals = NULL;
ber_bvarray_free( a->a_vals );
a->a_vals = NULL;
+ a->a_numvals = 0;
}
- ber_bvarray_dup_x( &a->a_vals, si->si_ctxcsn, NULL );
- ber_bvarray_dup_x( &a->a_nvals, si->si_ctxcsn, NULL );
+ attr_valadd( a, si->si_ctxcsn, si->si_ctxcsn, si->si_numcsns );
}
ldap_pvt_thread_rdwr_runlock( &si->si_csn_rwlock );
}
ber_dupbv(&e->e_nname, &ndn);
a = attr_alloc( slap_schema.si_ad_objectClass );
+ a->a_numvals = 2;
a->a_vals = ch_malloc(sizeof(struct berval) * 3);
ber_dupbv(&a->a_vals[0], &glue[0]);
ber_dupbv(&a->a_vals[1], &glue[1]);
e->e_attrs = a;
a = attr_alloc( slap_schema.si_ad_structuralObjectClass );
+ a->a_numvals = 1;
a->a_vals = ch_malloc(sizeof(struct berval) * 2);
ber_dupbv(&a->a_vals[0], &glue[1]);
ber_dupbv(&a->a_vals[1], &glue[2]);
atmp.a_desc = m->sml_desc;
atmp.a_vals = m->sml_values;
atmp.a_nvals = m->sml_nvalues ? m->sml_nvalues : atmp.a_vals;
+ atmp.a_numvals = m->sml_numvals;
+ atmp.a_flags = 0;
a = attr_dup( &atmp );
a->a_next = ax;
ax = a;
nhash = 1;
hashes = (char **)defhash;
}
+ ml->sml_numvals = nhash;
ml->sml_values = ch_malloc( (nhash+1)*sizeof(struct berval) );
for ( i=0; hashes[i]; i++ ) {
slap_passwd_hash_type( &qpw->rs_new, &hash, hashes[i], &rs->sr_text );
LDAP_SLAPD_F (Attribute *) attr_alloc LDAP_P(( AttributeDescription *ad ));
LDAP_SLAPD_F (Attribute *) attrs_alloc LDAP_P(( int num ));
LDAP_SLAPD_F (int) attr_prealloc LDAP_P(( int num ));
+LDAP_SLAPD_F (int) attr_valadd LDAP_P(( Attribute *a,
+ BerVarray vals,
+ BerVarray nvals,
+ int num ));
LDAP_SLAPD_F (int) attr_merge LDAP_P(( Entry *e,
AttributeDescription *desc,
BerVarray vals,
const char ** text ));
LDAP_SLAPD_F (void) ordered_value_renumber LDAP_P((
- Attribute *a,
- int vals ));
+ Attribute *a ));
LDAP_SLAPD_F (int) ordered_value_sort LDAP_P((
Attribute *a,
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_flags = 0;
ber_str2bv( pr[i].name, 0, 0, &mod->sml_type );
+ mod->sml_numvals = pr[i].nvalues;
mod->sml_values = (struct berval *)ch_malloc( (pr[i].nvalues + 1) *
sizeof(struct berval));
for (j=0; j<pr[i].nvalues; j++) {
ComponentData *a_comp_data; /* component values */
#endif
Attribute *a_next;
+ unsigned a_numvals; /* number of vals */
unsigned a_flags;
#define SLAP_ATTR_IXADD 0x1U
#define SLAP_ATTR_IXDEL 0x2U
#define SLAP_ATTR_DONT_FREE_DATA 0x4U
#define SLAP_ATTR_DONT_FREE_VALS 0x8U
+#define SLAP_ATTR_SORTED_VALS 0x10U
};
struct berval sm_type;
BerVarray sm_values;
BerVarray sm_nvalues;
+ unsigned sm_numvals;
};
struct Modifications {
#define sml_type sml_mod.sm_type
#define sml_values sml_mod.sm_values
#define sml_nvalues sml_mod.sm_nvalues
+#define sml_numvals sml_mod.sm_numvals
Modifications *sml_next;
};
-struct LDAPModList {
- LDAPMod ml_mod;
- LDAPModList *ml_next;
-#define ml_op ml_mod.mod_op
-#define ml_type ml_mod.mod_type
-#define ml_values ml_mod.mod_values
-};
-
/*
* represents an access control list
*/
i++;
}
}
+ mod->sml_numvals = i;
if ( i == 0 ) {
mod->sml_values = NULL;
mod->sml_type = ad->ad_cname;
mod->sml_values = NULL;
mod->sml_nvalues = NULL;
+ mod->sml_numvals = 0;
*modtail = mod;
modtail = &mod->sml_next;
bv.bv_len = vals[i].bv_len - ( bv.bv_val - vals[i].bv_val );
ber_dupbv( &bv2, &bv );
ber_bvarray_add( &mod->sml_values, &bv2 );
+ mod->sml_numvals++;
}
}
return modlist;
mod->sml_type = tmp.sml_type;
mod->sml_values = tmp.sml_values;
mod->sml_nvalues = NULL;
+ mod->sml_numvals = 0; /* slap_mods_check will set this */
*modtail = mod;
modtail = &mod->sml_next;
mod1.sml_flags = 0;
mod1.sml_desc = slap_schema.si_ad_objectClass;
mod1.sml_type = mod1.sml_desc->ad_cname;
+ mod1.sml_numvals = 2;
mod1.sml_values = &gcbva[0];
mod1.sml_nvalues = NULL;
mod1.sml_next = &mod2;
mod2.sml_flags = 0;
mod2.sml_desc = slap_schema.si_ad_structuralObjectClass;
mod2.sml_type = mod2.sml_desc->ad_cname;
+ mod1.sml_numvals = 1;
mod2.sml_values = &gcbva[1];
mod2.sml_nvalues = NULL;
mod2.sml_next = NULL;
a = attr_alloc( slap_schema.si_ad_objectClass );
+ a->a_numvals = 2;
a->a_vals = ch_calloc( 3, sizeof( struct berval ) );
ber_dupbv( &a->a_vals[0], &gcbva[0] );
ber_dupbv( &a->a_vals[1], &gcbva[1] );
a = attr_alloc( slap_schema.si_ad_structuralObjectClass );
+ a->a_numvals = 1;
a->a_vals = ch_calloc( 2, sizeof( struct berval ) );
ber_dupbv( &a->a_vals[0], &gcbva[1] );
ber_dupbv( &a->a_vals[1], &gcbva[2] );
mod->sml_flags = 0;
mod->sml_desc = old->a_desc;
mod->sml_type = mod->sml_desc->ad_cname;
+ mod->sml_numvals = no;
mod->sml_values = ch_malloc( ( no + 1 ) * sizeof(struct berval) );
if ( old->a_vals != old->a_nvals ) {
mod->sml_nvalues = ch_malloc( ( no + 1 ) * sizeof(struct berval) );
mod->sml_flags = 0;
mod->sml_desc = old->a_desc;
mod->sml_type = mod->sml_desc->ad_cname;
+ mod->sml_numvals = nn;
mod->sml_values = ch_malloc( ( nn + 1 ) * sizeof(struct berval) );
if ( old->a_vals != old->a_nvals ) {
mod->sml_nvalues = ch_malloc( ( nn + 1 ) * sizeof(struct berval) );
mod->sml_flags = 0;
mod->sml_desc = old->a_desc;
mod->sml_type = mod->sml_desc->ad_cname;
+ mod->sml_numvals = 0;
mod->sml_values = NULL;
mod->sml_nvalues = NULL;
*modtail = mod;
/* assign new indexes to an attribute's ordered values */
void
-ordered_value_renumber( Attribute *a, int vals )
+ordered_value_renumber( Attribute *a )
{
char *ptr, ibuf[64]; /* many digits */
struct berval ibv, tmp, vtmp;
ibv.bv_val = ibuf;
- for (i=0; i<vals; i++) {
+ for (i=0; i<a->a_numvals; i++) {
ibv.bv_len = sprintf(ibv.bv_val, "{%d}", i);
vtmp = a->a_vals[i];
if ( vtmp.bv_val[0] == '{' ) {
}
if ( do_renumber && renumber )
- ordered_value_renumber( a, vals );
+ ordered_value_renumber( a );
return 0;
}
vnum = i;
if ( a ) {
- for (i=0; !BER_BVISNULL( a->a_vals+i ); i++) ;
- anum = i;
ordered_value_sort( a, 0 );
} else {
Attribute **ap;
- anum = 0;
for ( ap=&e->e_attrs; *ap; ap = &(*ap)->a_next ) ;
a = attr_alloc( ad );
*ap = a;
}
+ anum = a->a_numvals;
new = ch_malloc( (anum+vnum+1) * sizeof(struct berval));
a->a_nvals = a->a_vals;
}
- ordered_value_renumber( a, anum );
+ a->a_numvals = anum;
+ ordered_value_renumber( a );
return 0;
}