Commit 6390e947 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

SLAP_NVALUES, round 2

parent 2a8dec95
......@@ -113,7 +113,11 @@ do_add( Connection *conn, Operation *op )
Modifications *mod;
ber_tag_t rtag;
rtag = ber_scanf( ber, "{m{W}}", &tmp.sml_type, &tmp.sml_bvalues );
#ifdef SLAP_NVALUES
tmp.sml_nvalues = NULL;
#endif
rtag = ber_scanf( ber, "{m{W}}", &tmp.sml_type, &tmp.sml_values );
if ( rtag == LBER_ERROR ) {
#ifdef NEW_LOGGING
......@@ -128,7 +132,7 @@ do_add( Connection *conn, Operation *op )
goto done;
}
if ( tmp.sml_bvalues == NULL ) {
if ( tmp.sml_values == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO,
"do_add: conn %d no values for type %s\n",
......@@ -141,13 +145,16 @@ do_add( Connection *conn, Operation *op )
NULL, "no values for attribute type", NULL, NULL );
goto done;
}
mod = (Modifications *) ch_malloc( sizeof(Modifications) );
mod->sml_op = LDAP_MOD_ADD;
mod->sml_next = NULL;
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
mod->sml_bvalues = tmp.sml_bvalues;
mod->sml_values = tmp.sml_values;
#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
#endif
*modtail = mod;
modtail = &mod->sml_next;
......@@ -476,8 +483,12 @@ slap_mods2entry(
/* move values to attr structure */
/* should check for duplicates */
attr->a_vals = mods->sml_bvalues;
mods->sml_bvalues = NULL;
attr->a_vals = mods->sml_values;
mods->sml_values = NULL;
#ifdef SLAP_NVALUES
attr->a_nvals = mods->sml_nvalues;
mods->sml_nvalues = NULL;
#endif
*tail = attr;
tail = &attr->a_next;
......
......@@ -66,21 +66,30 @@ Attribute *attr_dup( Attribute *a )
tmp->a_vals = ch_malloc((i+1) * sizeof(struct berval));
#ifdef SLAP_NVALUES
tmp->a_nvals = ch_malloc((i+1) * sizeof(struct berval));
if( a->a_nvals != NULL ) {
tmp->a_nvals = ch_malloc((i+1) * sizeof(struct berval));
}
#endif
for( i=0; a->a_vals[i].bv_val != NULL; i++ ) {
ber_dupbv( &tmp->a_vals[i], &a->a_vals[i] );
if( tmp->a_vals[i].bv_val == NULL ) break;
#ifdef SLAP_NVALUES
ber_dupbv( &tmp->a_nvals[i], &a->a_nvals[i] );
if( tmp->a_nvals[i].bv_val == NULL ) break;
if( a->a_nvals ) {
ber_dupbv( &tmp->a_nvals[i], &a->a_nvals[i] );
if( tmp->a_nvals[i].bv_val == NULL ) break;
} else {
tmp->a_nvals = NULL;
}
#endif
}
tmp->a_vals[i].bv_val = NULL;
#ifdef SLAP_NVALUES
tmp->a_nvals[i].bv_val = NULL;
if( tmp->a_nvals != NULL ) {
tmp->a_nvals[i].bv_val = NULL;
}
#endif
} else {
......
......@@ -215,7 +215,10 @@ retry: /* transaction retry */
vals[1].bv_val = NULL;
ml.sml_desc = slap_schema.si_ad_userPassword;
ml.sml_bvalues = vals;
ml.sml_values = vals;
#ifdef SLAP_VALUES
ml.sml_nvalues = vals;
#endif
ml.sml_op = LDAP_MOD_REPLACE;
ml.sml_next = NULL;
......
......@@ -24,7 +24,9 @@ static int emaxsize;/* max size of ebuf */
/*
* Empty root entry
*/
const Entry slap_entry_root = { NOID, { 0, "" }, { 0, "" }, NULL, 0, { 0, "" }, NULL };
const Entry slap_entry_root = {
NOID, { 0, "" }, { 0, "" }, NULL, 0, { 0, "" }, NULL
};
int entry_destroy(void)
{
......@@ -237,7 +239,33 @@ str2entry( char *s )
}
#ifdef SLAP_NVALUES
/* normalize here */
if( ad->ad_type->sat_syntax->ssyn_normalize ) {
rc = ad->ad_type->sat_syntax->ssyn_normalize(
ad->ad_type->sat_syntax,
&vals[0], &nvals[0] );
if( rc ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1,
"str2entry: NULL (ssyn_normalize %d)\n" , rc, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY,
"<= str2entry NULL (ssyn_normalize %d)\n", rc, 0, 0 );
entry_free( e );
free( vals[0].bv_val );
free( type );
return NULL;
}
#endif
} else {
nvals[0].bv_len = 0;
nvals[0].bv_val = NULL;
}
nvals[1].bv_len = 0;
nvals[1].bv_val = NULL;
#endif
rc = attr_merge( e, ad, vals
......@@ -276,7 +304,7 @@ str2entry( char *s )
(long) e->e_id, 0, 0 );
#endif
entry_free( e );
return( NULL );
return NULL;
}
#ifdef NEW_LOGGING
......
......@@ -109,9 +109,12 @@ do_modify(
ber_int_t mop;
Modifications tmp, *mod;
#ifdef SLAP_NVALUES
tmp.sml_nvalues = NULL;
#endif
if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
&tmp.sml_type, &tmp.sml_bvalues )
&tmp.sml_type, &tmp.sml_values )
== LBER_ERROR )
{
send_ldap_disconnect( conn, op,
......@@ -123,14 +126,17 @@ do_modify(
mod = (Modifications *) ch_malloc( sizeof(Modifications) );
mod->sml_op = mop;
mod->sml_type = tmp.sml_type;
mod->sml_bvalues = tmp.sml_bvalues;
mod->sml_values = tmp.sml_values;
#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
#endif
mod->sml_desc = NULL;
mod->sml_next = NULL;
*modtail = mod;
switch( mop ) {
case LDAP_MOD_ADD:
if ( mod->sml_bvalues == NULL ) {
if ( mod->sml_values == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
"do_modify: modify/add operation (%ld) requires values\n",
......@@ -239,11 +245,11 @@ do_modify(
"add" : (tmp->sml_op == LDAP_MOD_DELETE ?
"delete" : "replace"), tmp->sml_type.bv_val, 0 );
if ( tmp->sml_bvalues == NULL ) {
if ( tmp->sml_values == NULL ) {
LDAP_LOG( OPERATION, DETAIL1, "\t\tno values", 0, 0, 0 );
} else if ( tmp->sml_bvalues[0].bv_val == NULL ) {
} else if ( tmp->sml_values[0].bv_val == NULL ) {
LDAP_LOG( OPERATION, DETAIL1, "\t\tzero values", 0, 0, 0 );
} else if ( tmp->sml_bvalues[1].bv_val == NULL ) {
} else if ( tmp->sml_values[1].bv_val == NULL ) {
LDAP_LOG( OPERATION, DETAIL1, "\t\tone value", 0, 0, 0 );
} else {
LDAP_LOG( OPERATION, DETAIL1, "\t\tmultiple values", 0, 0, 0 );
......@@ -255,15 +261,15 @@ do_modify(
? "add" : (tmp->sml_op == LDAP_MOD_DELETE
? "delete" : "replace"), tmp->sml_type.bv_val, 0 );
if ( tmp->sml_bvalues == NULL ) {
if ( tmp->sml_values == NULL ) {
Debug( LDAP_DEBUG_ARGS, "%s\n",
"\t\tno values", NULL, NULL );
} else if ( tmp->sml_bvalues[0].bv_val == NULL ) {
} else if ( tmp->sml_values[0].bv_val == NULL ) {
Debug( LDAP_DEBUG_ARGS, "%s\n",
"\t\tzero values", NULL, NULL );
} else if ( tmp->sml_bvalues[1].bv_val == NULL ) {
} else if ( tmp->sml_values[1].bv_val == NULL ) {
Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
"\t\tone value", (long) tmp->sml_bvalues[0].bv_len, NULL );
"\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
} else {
Debug( LDAP_DEBUG_ARGS, "%s\n",
"\t\tmultiple values", NULL, NULL );
......@@ -540,7 +546,7 @@ int slap_mods_check(
}
if ( is_at_obsolete( ad->ad_type ) &&
( ml->sml_op == LDAP_MOD_ADD || ml->sml_bvalues != NULL ) )
( ml->sml_op == LDAP_MOD_ADD || ml->sml_values != NULL ) )
{
/*
* attribute is obsolete,
......@@ -676,10 +682,13 @@ int slap_mods_opattrs(
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_bvalues[0], &tmpval );
mod->sml_bvalues[1].bv_val = NULL;
assert( mod->sml_bvalues[0].bv_val );
#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &tmpval );
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
}
......@@ -694,10 +703,13 @@ int slap_mods_opattrs(
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_entryUUID;
mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_bvalues[0], &tmpval );
mod->sml_bvalues[1].bv_val = NULL;
assert( mod->sml_bvalues[0].bv_val );
#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &tmpval );
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
......@@ -705,10 +717,13 @@ int slap_mods_opattrs(
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_creatorsName;
mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_bvalues[0], &name );
mod->sml_bvalues[1].bv_val = NULL;
assert( mod->sml_bvalues[0].bv_val );
#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &name );
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
......@@ -716,10 +731,13 @@ int slap_mods_opattrs(
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_createTimestamp;
mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_bvalues[0], &timestamp );
mod->sml_bvalues[1].bv_val = NULL;
assert( mod->sml_bvalues[0].bv_val );
#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &timestamp );
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
}
......@@ -730,10 +748,13 @@ int slap_mods_opattrs(
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_entryCSN;
mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_bvalues[0], &csn );
mod->sml_bvalues[1].bv_val = NULL;
assert( mod->sml_bvalues[0].bv_val );
#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &csn );
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
......@@ -741,10 +762,13 @@ int slap_mods_opattrs(
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_modifiersName;
mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_bvalues[0], &name );
mod->sml_bvalues[1].bv_val = NULL;
assert( mod->sml_bvalues[0].bv_val );
#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &name );
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
......@@ -752,10 +776,13 @@ int slap_mods_opattrs(
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_bvalues[0], &timestamp );
mod->sml_bvalues[1].bv_val = NULL;
assert( mod->sml_bvalues[0].bv_val );
#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &timestamp );
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
}
......
......@@ -490,9 +490,12 @@ slap_modrdn2mods(
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ 2 * sizeof( struct berval ) );
mod_tmp->sml_desc = desc;
mod_tmp->sml_bvalues = ( BerVarray )( mod_tmp + 1 );
mod_tmp->sml_bvalues[ 0 ] = new_rdn[ 0 ][ a_cnt ]->la_value;
mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
mod_tmp->sml_values = ( BerVarray )( mod_tmp + 1 );
mod_tmp->sml_values[ 0 ] = new_rdn[ 0 ][ a_cnt ]->la_value;
mod_tmp->sml_values[ 1 ].bv_val = NULL;
#ifdef SLAP_NVALUES
mod_tmp->sml_nvalues = NULL;
#endif
mod_tmp->sml_op = SLAP_MOD_SOFTADD;
mod_tmp->sml_next = mod;
mod = mod_tmp;
......@@ -549,10 +552,13 @@ slap_modrdn2mods(
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ 2 * sizeof ( struct berval ) );
mod_tmp->sml_desc = desc;
mod_tmp->sml_bvalues = ( BerVarray )(mod_tmp+1);
mod_tmp->sml_bvalues[ 0 ]
mod_tmp->sml_values = ( BerVarray )(mod_tmp+1);
mod_tmp->sml_values[ 0 ]
= old_rdn[ 0 ][ d_cnt ]->la_value;
mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
mod_tmp->sml_values[ 1 ].bv_val = NULL;
#ifdef SLAP_NVALUES
mod_tmp->sml_nvalues = NULL;
#endif
mod_tmp->sml_op = LDAP_MOD_DELETE;
mod_tmp->sml_next = mod;
mod = mod_tmp;
......
......@@ -26,8 +26,13 @@ slap_operational_subschemaSubentry( Backend *be )
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( a->a_vals, &global_schemadn );
a->a_vals[1].bv_len = 0;
a->a_vals[1].bv_val = NULL;
#ifdef SLAP_NVALUES
a->a_nvals = NULL;
#endif
a->a_next = NULL;
a->a_flags = 0;
......@@ -58,6 +63,10 @@ slap_operational_hasSubordinate( int hs )
ber_str2bv( val, len, 1, a->a_vals );
a->a_vals[1].bv_val = NULL;
#ifdef SLAP_NVALUES
a->a_nvals = NULL;
#endif
a->a_next = NULL;
a->a_flags = 0;
......
......@@ -935,8 +935,8 @@ typedef struct slap_mod {
int sm_op;
AttributeDescription *sm_desc;
struct berval sm_type;
#define sm_bvalues sm_values
BerVarray sm_values;
#define sm_bvalues sm_values
#ifdef SLAP_NVALUES
BerVarray sm_nvalues;
#endif
......@@ -947,7 +947,9 @@ typedef struct slap_mod_list {
#define sml_op sml_mod.sm_op
#define sml_desc sml_mod.sm_desc
#define sml_type sml_mod.sm_type
#define sml_bvalues sml_mod.sm_bvalues
#define sml_bvalues sml_mod.sm_values
#define sml_values sml_mod.sm_values
#define sml_nvalues sml_mod.sm_nvalues
struct slap_mod_list *sml_next;
} Modifications;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment