Round one of SLAP_NVALUES code

This commit is contained in:
Kurt Zeilenga 2003-02-25 21:08:48 +00:00
parent 5b4e69a564
commit 8502301b00
13 changed files with 315 additions and 40 deletions

View File

@ -602,8 +602,14 @@ at_schema_info( Entry *e )
return -1; return -1;
} }
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_attributeTypes, vals, NULL /* FIXME */ ) )
#else
if( attr_merge( e, ad_attributeTypes, vals ) ) if( attr_merge( e, ad_attributeTypes, vals ) )
#endif
{
return -1; return -1;
}
ldap_memfree( vals[0].bv_val ); ldap_memfree( vals[0].bv_val );
} }
return 0; return 0;

View File

@ -32,6 +32,9 @@ void
attr_free( Attribute *a ) attr_free( Attribute *a )
{ {
ber_bvarray_free( a->a_vals ); ber_bvarray_free( a->a_vals );
#ifdef SLAP_NVALUES
ber_bvarray_free( a->a_nvals );
#endif
free( a ); free( a );
} }
@ -62,16 +65,29 @@ Attribute *attr_dup( Attribute *a )
} }
tmp->a_vals = ch_malloc((i+1) * sizeof(struct berval)); tmp->a_vals = ch_malloc((i+1) * sizeof(struct berval));
#ifdef SLAP_NVALUES
tmp->a_nvals = ch_malloc((i+1) * sizeof(struct berval));
#endif
for( i=0; a->a_vals[i].bv_val != NULL; i++ ) { for( i=0; a->a_vals[i].bv_val != NULL; i++ ) {
ber_dupbv( &tmp->a_vals[i], &a->a_vals[i] ); ber_dupbv( &tmp->a_vals[i], &a->a_vals[i] );
if( tmp->a_vals[i].bv_val == NULL ) break; 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;
#endif
} }
tmp->a_vals[i].bv_val = NULL; tmp->a_vals[i].bv_val = NULL;
#ifdef SLAP_NVALUES
tmp->a_nvals[i].bv_val = NULL;
#endif
} else { } else {
tmp->a_vals = NULL; tmp->a_vals = NULL;
#ifdef SLAP_NVALUES
tmp->a_nvals = NULL;
#endif
} }
tmp->a_desc = a->a_desc; tmp->a_desc = a->a_desc;
@ -112,8 +128,13 @@ int
attr_merge( attr_merge(
Entry *e, Entry *e,
AttributeDescription *desc, AttributeDescription *desc,
BerVarray vals ) BerVarray vals
{ #ifdef SLAP_NVALUES
, BerVarray nvals
#endif
) {
int rc;
Attribute **a; Attribute **a;
for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) { for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) {
@ -126,19 +147,32 @@ attr_merge(
*a = (Attribute *) ch_malloc( sizeof(Attribute) ); *a = (Attribute *) ch_malloc( sizeof(Attribute) );
(*a)->a_desc = desc; (*a)->a_desc = desc;
(*a)->a_vals = NULL; (*a)->a_vals = NULL;
#ifdef SLAP_NVALUES
(*a)->a_nvals = NULL;
#endif
(*a)->a_next = NULL; (*a)->a_next = NULL;
(*a)->a_flags = 0; (*a)->a_flags = 0;
} }
return( value_add( &(*a)->a_vals, vals ) ); rc = value_add( &(*a)->a_vals, vals );
#ifdef SLAP_NVALUES
if( !rc && nvals ) rc = value_add( &(*a)->a_nvals, nvals );
#endif
return rc;
} }
int int
attr_merge_one( attr_merge_one(
Entry *e, Entry *e,
AttributeDescription *desc, AttributeDescription *desc,
struct berval *val ) struct berval *val
{ #ifdef SLAP_NVALUES
, BerVarray nval
#endif
) {
int rc;
Attribute **a; Attribute **a;
for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) { for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) {
@ -151,11 +185,19 @@ attr_merge_one(
*a = (Attribute *) ch_malloc( sizeof(Attribute) ); *a = (Attribute *) ch_malloc( sizeof(Attribute) );
(*a)->a_desc = desc; (*a)->a_desc = desc;
(*a)->a_vals = NULL; (*a)->a_vals = NULL;
#ifdef SLAP_NVALUES
(*a)->a_nvals = NULL;
#endif
(*a)->a_next = NULL; (*a)->a_next = NULL;
(*a)->a_flags = 0; (*a)->a_flags = 0;
} }
return( value_add_one( &(*a)->a_vals, val ) ); rc = value_add_one( &(*a)->a_vals, val );
#ifdef SLAP_NVALUES
if( !rc && nval ) rc = value_add_one( &(*a)->a_nvals, nval );
#endif
return rc;
} }
/* /*

View File

@ -401,7 +401,8 @@ cr_schema_info( Entry *e )
struct berval vals[2]; struct berval vals[2];
ContentRule *cr; ContentRule *cr;
AttributeDescription *ad_ditContentRules = slap_schema.si_ad_ditContentRules; AttributeDescription *ad_ditContentRules
= slap_schema.si_ad_ditContentRules;
vals[1].bv_val = NULL; vals[1].bv_val = NULL;
@ -418,8 +419,14 @@ cr_schema_info( Entry *e )
Debug( LDAP_DEBUG_TRACE, "Merging cr [%ld] %s\n", Debug( LDAP_DEBUG_TRACE, "Merging cr [%ld] %s\n",
(long) vals[0].bv_len, vals[0].bv_val, 0 ); (long) vals[0].bv_len, vals[0].bv_val, 0 );
#endif #endif
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_ditContentRules, vals, NULL ) )
#else
if( attr_merge( e, ad_ditContentRules, vals ) ) if( attr_merge( e, ad_ditContentRules, vals ) )
#endif
{
return -1; return -1;
}
ldap_memfree( vals[0].bv_val ); ldap_memfree( vals[0].bv_val );
} }
#endif #endif

View File

@ -43,6 +43,9 @@ str2entry( char *s )
Entry *e; Entry *e;
char *type; char *type;
struct berval vals[2]; struct berval vals[2];
#ifdef SLAP_NVALUES
struct berval nvals[2];
#endif
AttributeDescription *ad; AttributeDescription *ad;
const char *text; const char *text;
char *next; char *next;
@ -233,7 +236,15 @@ str2entry( char *s )
} }
} }
rc = attr_merge( e, ad, vals ); #ifdef SLAP_NVALUES
/* normalize here */
#endif
rc = attr_merge( e, ad, vals
#ifdef SLAP_NVALUES
, nvals
#endif
);
if( rc != 0 ) { if( rc != 0 ) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1, LDAP_LOG( OPERATION, DETAIL1,
@ -250,6 +261,9 @@ str2entry( char *s )
free( type ); free( type );
free( vals[0].bv_val ); free( vals[0].bv_val );
#ifdef SLAP_NVALUES
free( nvals[0].bv_val );
#endif
} }
/* check to make sure there was a dn: line */ /* check to make sure there was a dn: line */

View File

@ -444,7 +444,12 @@ modify_add_values(
} }
/* no - add them */ /* no - add them */
if( attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) { #ifdef SLAP_NVALUES
if( attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues ) != 0 )
#else
if( attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 )
#endif
{
/* this should return result of attr_merge */ /* this should return result of attr_merge */
*text = textbuf; *text = textbuf;
snprintf( textbuf, textlen, snprintf( textbuf, textlen,
@ -669,12 +674,11 @@ slap_mod_free(
int freeit int freeit
) )
{ {
#if 0 if ( mod->sm_values != NULL ) ber_bvarray_free( mod->sm_values );
if ( mod->sm_type.bv_val)
free( mod->sm_type.bv_val ); #ifdef SLAP_NVALUES
if ( mod->sm_nvalues != NULL ) ber_bvarray_free( mod->sm_nvalues );
#endif #endif
if ( mod->sm_bvalues != NULL )
ber_bvarray_free( mod->sm_bvalues );
if( freeit ) if( freeit )
free( mod ); free( mod );

View File

@ -461,8 +461,14 @@ int mr_schema_info( Entry *e )
Debug( LDAP_DEBUG_TRACE, "Merging mr [%lu] %s\n", Debug( LDAP_DEBUG_TRACE, "Merging mr [%lu] %s\n",
mr->smr_str.bv_len, mr->smr_str.bv_val, 0 ); mr->smr_str.bv_len, mr->smr_str.bv_val, 0 );
#endif #endif
#ifdef SLAP_NVALUES
if( attr_merge_one( e, ad_matchingRules, &mr->smr_str, NULL /* FIXME */ ) )
#else
if( attr_merge_one( e, ad_matchingRules, &mr->smr_str ) ) if( attr_merge_one( e, ad_matchingRules, &mr->smr_str ) )
#endif
{
return -1; return -1;
}
} }
return 0; return 0;
} }
@ -489,8 +495,14 @@ int mru_schema_info( Entry *e )
Debug( LDAP_DEBUG_TRACE, "Merging mru [%lu] %s\n", Debug( LDAP_DEBUG_TRACE, "Merging mru [%lu] %s\n",
mru->smru_str.bv_len, mru->smru_str.bv_val, 0 ); mru->smru_str.bv_len, mru->smru_str.bv_val, 0 );
#endif #endif
#ifdef SLAP_NVALUES
if( attr_merge_one( e, ad_matchingRuleUse, &mru->smru_str, NULL /* FIXME */ ) )
#else
if( attr_merge_one( e, ad_matchingRuleUse, &mru->smru_str ) ) if( attr_merge_one( e, ad_matchingRuleUse, &mru->smru_str ) )
#endif
{
return -1; return -1;
}
} }
return 0; return 0;
} }

View File

@ -497,8 +497,14 @@ oc_schema_info( Entry *e )
Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n", Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n",
(long) vals[0].bv_len, vals[0].bv_val, 0 ); (long) vals[0].bv_len, vals[0].bv_val, 0 );
#endif #endif
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_objectClasses, vals, NULL /* FIXME */ ) )
#else
if( attr_merge( e, ad_objectClasses, vals ) ) if( attr_merge( e, ad_objectClasses, vals ) )
#endif
{
return -1; return -1;
}
ldap_memfree( vals[0].bv_val ); ldap_memfree( vals[0].bv_val );
} }
return 0; return 0;

View File

@ -132,12 +132,23 @@ LDAP_SLAPD_F (int) at_next LDAP_P(( AttributeType **at ));
LDAP_SLAPD_F (void) attr_free LDAP_P(( Attribute *a )); LDAP_SLAPD_F (void) attr_free LDAP_P(( Attribute *a ));
LDAP_SLAPD_F (Attribute *) attr_dup LDAP_P(( Attribute *a )); LDAP_SLAPD_F (Attribute *) attr_dup LDAP_P(( Attribute *a ));
#ifdef SLAP_NVALUES
LDAP_SLAPD_F (int) attr_merge LDAP_P(( Entry *e,
AttributeDescription *desc,
BerVarray vals,
BerVarray nvals ));
LDAP_SLAPD_F (int) attr_merge_one LDAP_P(( Entry *e,
AttributeDescription *desc,
struct berval *val,
struct berval *nval ));
#else
LDAP_SLAPD_F (int) attr_merge LDAP_P(( Entry *e, LDAP_SLAPD_F (int) attr_merge LDAP_P(( Entry *e,
AttributeDescription *desc, AttributeDescription *desc,
BerVarray vals )); BerVarray vals ));
LDAP_SLAPD_F (int) attr_merge_one LDAP_P(( Entry *e, LDAP_SLAPD_F (int) attr_merge_one LDAP_P(( Entry *e,
AttributeDescription *desc, AttributeDescription *desc,
struct berval *val )); struct berval *val ));
#endif
LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P(( LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P((
Attribute *a, AttributeDescription *desc )); Attribute *a, AttributeDescription *desc ));
LDAP_SLAPD_F (Attribute *) attr_find LDAP_P(( LDAP_SLAPD_F (Attribute *) attr_find LDAP_P((

View File

@ -42,7 +42,10 @@ root_dse_info(
const char **text ) const char **text )
{ {
Entry *e; Entry *e;
struct berval vals[2], *bv; struct berval vals[2], *bv;
#ifdef SLAP_NVALUES
struct berval nvals[2];
#endif
int i, j; int i, j;
char ** supportedSASLMechanisms; char ** supportedSASLMechanisms;
@ -68,6 +71,9 @@ root_dse_info(
= slap_schema.si_ad_ref; = slap_schema.si_ad_ref;
vals[1].bv_val = NULL; vals[1].bv_val = NULL;
#ifdef SLAP_NVALUES
nvals[1].bv_val = NULL;
#endif
e = (Entry *) SLAP_CALLOC( 1, sizeof(Entry) ); e = (Entry *) SLAP_CALLOC( 1, sizeof(Entry) );
@ -96,21 +102,41 @@ root_dse_info(
vals[0].bv_val = "top"; vals[0].bv_val = "top";
vals[0].bv_len = sizeof("top")-1; vals[0].bv_len = sizeof("top")-1;
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_objectClass, vals, vals ) )
#else
if( attr_merge( e, ad_objectClass, vals ) ) if( attr_merge( e, ad_objectClass, vals ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
vals[0].bv_val = "OpenLDAProotDSE"; vals[0].bv_val = "OpenLDAProotDSE";
vals[0].bv_len = sizeof("OpenLDAProotDSE")-1; vals[0].bv_len = sizeof("OpenLDAProotDSE")-1;
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_objectClass, vals, vals ) )
#else
if( attr_merge( e, ad_objectClass, vals ) ) if( attr_merge( e, ad_objectClass, vals ) )
#endif
return LDAP_OTHER; return LDAP_OTHER;
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_structuralObjectClass, vals, vals ) )
#else
if( attr_merge( e, ad_structuralObjectClass, vals ) ) if( attr_merge( e, ad_structuralObjectClass, vals ) )
#endif
return LDAP_OTHER; return LDAP_OTHER;
for ( i = 0; i < nbackends; i++ ) { for ( i = 0; i < nbackends; i++ ) {
if ( backends[i].be_flags & SLAP_BFLAG_MONITOR ) { if ( backends[i].be_flags & SLAP_BFLAG_MONITOR ) {
vals[0] = backends[i].be_suffix[0]; vals[0] = backends[i].be_suffix[0];
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_monitorContext, vals, nvals ) )
#else
if( attr_merge( e, ad_monitorContext, vals ) ) if( attr_merge( e, ad_monitorContext, vals ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
continue; continue;
} }
if ( backends[i].be_flags & SLAP_BFLAG_GLUE_SUBORDINATE ) { if ( backends[i].be_flags & SLAP_BFLAG_GLUE_SUBORDINATE ) {
@ -118,8 +144,14 @@ root_dse_info(
} }
for ( j = 0; backends[i].be_suffix[j].bv_val != NULL; j++ ) { for ( j = 0; backends[i].be_suffix[j].bv_val != NULL; j++ ) {
vals[0] = backends[i].be_suffix[j]; vals[0] = backends[i].be_suffix[j];
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_namingContexts, vals, NULL ) )
#else
if( attr_merge( e, ad_namingContexts, vals ) ) if( attr_merge( e, ad_namingContexts, vals ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
} }
} }
@ -128,28 +160,54 @@ root_dse_info(
/* supportedControl */ /* supportedControl */
for ( i=0; (vals[0].bv_val = get_supported_ctrl(i)) != NULL; i++ ) { for ( i=0; (vals[0].bv_val = get_supported_ctrl(i)) != NULL; i++ ) {
vals[0].bv_len = strlen( vals[0].bv_val ); vals[0].bv_len = strlen( vals[0].bv_val );
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedControl, vals, NULL ) )
#else
if( attr_merge( e, ad_supportedControl, vals ) ) if( attr_merge( e, ad_supportedControl, vals ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
} }
/* supportedExtension */ /* supportedExtension */
for ( i=0; (bv = get_supported_extop(i)) != NULL; i++ ) { for ( i=0; (bv = get_supported_extop(i)) != NULL; i++ ) {
vals[0] = *bv; vals[0] = *bv;
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedExtension, vals, NULL ) )
#else
if( attr_merge( e, ad_supportedExtension, vals ) ) if( attr_merge( e, ad_supportedExtension, vals ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
} }
#ifdef LDAP_SLAPI #ifdef LDAP_SLAPI
/* netscape supportedExtension */ /* netscape supportedExtension */
for ( i = 0; (bv = ns_get_supported_extop(i)) != NULL; i++ ) { for ( i = 0; (bv = ns_get_supported_extop(i)) != NULL; i++ ) {
vals[0] = *bv; vals[0] = *bv;
attr_merge( e, ad_supportedExtension, vals ); #ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedExtension, vals, NULL ))
#else
if( attr_merge( e, ad_supportedExtension, vals ))
#endif
{
return LDAP_OTHER;
}
} }
#endif /* LDAP_SLAPI */ #endif /* LDAP_SLAPI */
/* supportedFeatures */ /* supportedFeatures */
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedFeatures,
supportedFeatures, supportedFeatures ) )
#else
if( attr_merge( e, ad_supportedFeatures, supportedFeatures ) ) if( attr_merge( e, ad_supportedFeatures, supportedFeatures ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
/* supportedLDAPVersion */ /* supportedLDAPVersion */
for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) { for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) {
@ -163,8 +221,14 @@ root_dse_info(
snprintf(buf, sizeof buf, "%d", i); snprintf(buf, sizeof buf, "%d", i);
vals[0].bv_val = buf; vals[0].bv_val = buf;
vals[0].bv_len = strlen( vals[0].bv_val ); vals[0].bv_len = strlen( vals[0].bv_val );
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedLDAPVersion, vals, NULL ) )
#else
if( attr_merge( e, ad_supportedLDAPVersion, vals ) ) if( attr_merge( e, ad_supportedLDAPVersion, vals ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
} }
/* supportedSASLMechanism */ /* supportedSASLMechanism */
@ -174,22 +238,40 @@ root_dse_info(
for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) { for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
vals[0].bv_val = supportedSASLMechanisms[i]; vals[0].bv_val = supportedSASLMechanisms[i];
vals[0].bv_len = strlen( vals[0].bv_val ); vals[0].bv_len = strlen( vals[0].bv_val );
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedSASLMechanisms, vals, NULL ) )
#else
if( attr_merge( e, ad_supportedSASLMechanisms, vals ) ) if( attr_merge( e, ad_supportedSASLMechanisms, vals ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
} }
ldap_charray_free( supportedSASLMechanisms ); ldap_charray_free( supportedSASLMechanisms );
} }
if ( default_referral != NULL ) { if ( default_referral != NULL ) {
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_ref, default_referral, NULL /* FIXME */ ) )
#else
if( attr_merge( e, ad_ref, default_referral ) ) if( attr_merge( e, ad_ref, default_referral ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
} }
if( usr_attr != NULL) { if( usr_attr != NULL) {
Attribute *a; Attribute *a;
for( a = usr_attr->e_attrs; a != NULL; a = a->a_next ) { for( a = usr_attr->e_attrs; a != NULL; a = a->a_next ) {
#ifdef SLAP_NVALUES
if( attr_merge( e, a->a_desc, a->a_vals, a->a_nvals ) )
#else
if( attr_merge( e, a->a_desc, a->a_vals ) ) if( attr_merge( e, a->a_desc, a->a_vals ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
} }
} }
@ -260,8 +342,14 @@ int read_root_dse_file( const char *fname )
*/ */
for(a = e->e_attrs; a != NULL; a = a->a_next) { for(a = e->e_attrs; a != NULL; a = a->a_next) {
#ifdef SLAP_NVALUES
if( attr_merge( usr_attr, a->a_desc, a->a_vals, a->a_nvals ) )
#else
if( attr_merge( usr_attr, a->a_desc, a->a_vals ) ) if( attr_merge( usr_attr, a->a_desc, a->a_vals ) )
#endif
{
return LDAP_OTHER; return LDAP_OTHER;
}
} }
entry_free( e ); entry_free( e );

View File

@ -32,6 +32,9 @@ schema_info( Entry **entry, const char **text )
Entry *e; Entry *e;
struct berval vals[5]; struct berval vals[5];
#ifdef SLAP_NVALUES
struct berval nvals[5];
#endif
e = (Entry *) SLAP_CALLOC( 1, sizeof(Entry) ); e = (Entry *) SLAP_CALLOC( 1, sizeof(Entry) );
if( e == NULL ) { if( e == NULL ) {
@ -57,7 +60,12 @@ schema_info( Entry **entry, const char **text )
vals[0].bv_val = "subentry"; vals[0].bv_val = "subentry";
vals[0].bv_len = sizeof("subentry")-1; vals[0].bv_len = sizeof("subentry")-1;
if( attr_merge_one( e, ad_structuralObjectClass, vals ) ) { #ifdef SLAP_NVALUES
if( attr_merge_one( e, ad_structuralObjectClass, vals, vals ) )
#else
if( attr_merge_one( e, ad_structuralObjectClass, vals ) )
#endif
{
/* Out of memory, do something about it */ /* Out of memory, do something about it */
entry_free( e ); entry_free( e );
*text = "out of memory"; *text = "out of memory";
@ -73,7 +81,12 @@ schema_info( Entry **entry, const char **text )
vals[3].bv_val = "extensibleObject"; vals[3].bv_val = "extensibleObject";
vals[3].bv_len = sizeof("extensibleObject")-1; vals[3].bv_len = sizeof("extensibleObject")-1;
vals[4].bv_val = NULL; vals[4].bv_val = NULL;
if( attr_merge( e, ad_objectClass, vals ) ) { #ifdef SLAP_NVALUES
if( attr_merge( e, ad_objectClass, vals, vals ) )
#else
if( attr_merge( e, ad_objectClass, vals ) )
#endif
{
/* Out of memory, do something about it */ /* Out of memory, do something about it */
entry_free( e ); entry_free( e );
*text = "out of memory"; *text = "out of memory";
@ -103,7 +116,17 @@ schema_info( Entry **entry, const char **text )
return LDAP_OTHER; return LDAP_OTHER;
} }
if( attr_merge_one( e, desc, vals ) ) { #ifdef SLAP_NVALUES
nvals[0].bv_val = strchr( global_schemandn.bv_val, '=' );
nvals[0].bv_val++;
nvals[0].bv_len = global_schemandn.bv_len -
(nvals[0].bv_val - global_schemandn.bv_val);
if( attr_merge_one( e, desc, vals, nvals ) )
#else
if( attr_merge_one( e, desc, vals ) )
#endif
{
/* Out of memory, do something about it */ /* Out of memory, do something about it */
entry_free( e ); entry_free( e );
*text = "out of memory"; *text = "out of memory";
@ -134,13 +157,23 @@ schema_info( Entry **entry, const char **text )
vals[0].bv_val = timebuf; vals[0].bv_val = timebuf;
vals[0].bv_len = strlen( timebuf ); vals[0].bv_len = strlen( timebuf );
if( attr_merge_one( e, ad_createTimestamp, vals ) ) { #ifdef SLAP_NVALUES
if( attr_merge_one( e, ad_createTimestamp, vals, vals ) )
#else
if( attr_merge_one( e, ad_createTimestamp, vals ) )
#endif
{
/* Out of memory, do something about it */ /* Out of memory, do something about it */
entry_free( e ); entry_free( e );
*text = "out of memory"; *text = "out of memory";
return LDAP_OTHER; return LDAP_OTHER;
} }
if( attr_merge_one( e, ad_modifyTimestamp, vals ) ) { #ifdef SLAP_NVALUES
if( attr_merge_one( e, ad_modifyTimestamp, vals, vals ) )
#else
if( attr_merge_one( e, ad_modifyTimestamp, vals ) )
#endif
{
/* Out of memory, do something about it */ /* Out of memory, do something about it */
entry_free( e ); entry_free( e );
*text = "out of memory"; *text = "out of memory";

View File

@ -36,6 +36,7 @@
#include "ldap_queue.h" #include "ldap_queue.h"
#ifdef LDAP_DEVEL #ifdef LDAP_DEVEL
/* #define SLAP_NVALUES 1 */
#define SLAP_EXTENDED_SCHEMA 1 #define SLAP_EXTENDED_SCHEMA 1
#endif #endif
@ -882,7 +883,10 @@ typedef struct slap_valuesreturnfilter {
*/ */
typedef struct slap_attr { typedef struct slap_attr {
AttributeDescription *a_desc; AttributeDescription *a_desc;
BerVarray a_vals; BerVarray a_vals; /* preserved values */
#ifdef SLAP_NVALUES
BerVarray a_nvals; /* normalized values */
#endif
struct slap_attr *a_next; struct slap_attr *a_next;
unsigned a_flags; unsigned a_flags;
#define SLAP_ATTR_IXADD 0x1U #define SLAP_ATTR_IXADD 0x1U
@ -931,7 +935,11 @@ typedef struct slap_mod {
int sm_op; int sm_op;
AttributeDescription *sm_desc; AttributeDescription *sm_desc;
struct berval sm_type; struct berval sm_type;
BerVarray sm_bvalues; #define sm_bvalues sm_values
BerVarray sm_values;
#ifdef SLAP_NVALUES
BerVarray sm_nvalues;
#endif
} Modification; } Modification;
typedef struct slap_mod_list { typedef struct slap_mod_list {

View File

@ -238,8 +238,14 @@ syn_schema_info( Entry *e )
#endif #endif
#endif #endif
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_ldapSyntaxes, vals, NULL /* FIXME */ ) )
#else
if( attr_merge( e, ad_ldapSyntaxes, vals ) ) if( attr_merge( e, ad_ldapSyntaxes, vals ) )
#endif
{
return -1; return -1;
}
ldap_memfree( vals[0].bv_val ); ldap_memfree( vals[0].bv_val );
} }
return 0; return 0;

View File

@ -136,8 +136,12 @@ main( int argc, char **argv )
} }
vals[1].bv_val = NULL; vals[1].bv_val = NULL;
attr_merge( e, slap_schema.si_ad_structuralObjectClass, #ifdef SLAP_NVALUES
vals ); attr_merge( e, slap_schema.si_ad_structuralObjectClass, vals,
NULL /* FIXME */ );
#else
attr_merge( e, slap_schema.si_ad_structuralObjectClass, vals );
#endif
} }
/* check schema */ /* check schema */
@ -160,9 +164,22 @@ main( int argc, char **argv )
struct berval vals[ 2 ]; struct berval vals[ 2 ];
struct berval name, timestamp, csn; struct berval name, timestamp, csn;
#ifdef SLAP_NVALUES
struct berval nvals[ 2 ];
struct berval nname;
#endif
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ]; char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ]; char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
vals[1].bv_len = 0;
vals[1].bv_val = NULL;
#ifdef SLAP_NVALUES
nvals[1].bv_len = 0;
nvals[1].bv_val = NULL;
#endif
ltm = gmtime(&now); ltm = gmtime(&now);
lutil_gentime( timebuf, sizeof(timebuf), ltm ); lutil_gentime( timebuf, sizeof(timebuf), ltm );
@ -175,8 +192,15 @@ main( int argc, char **argv )
if ( be->be_rootndn.bv_len == 0 ) { if ( be->be_rootndn.bv_len == 0 ) {
name.bv_val = SLAPD_ANONYMOUS; name.bv_val = SLAPD_ANONYMOUS;
name.bv_len = sizeof(SLAPD_ANONYMOUS) - 1; name.bv_len = sizeof(SLAPD_ANONYMOUS) - 1;
#ifdef SLAP_NVALUES
nname.bv_val = SLAPD_ANONYMOUS;
nname.bv_len = sizeof(SLAPD_ANONYMOUS) - 1;
#endif
} else { } else {
name = be->be_rootndn; name = be->be_rootdn;
#ifdef SLAP_NVALUES
nname = be->be_rootndn;
#endif
} }
if( attr_find( e->e_attrs, slap_schema.si_ad_entryUUID ) if( attr_find( e->e_attrs, slap_schema.si_ad_entryUUID )
@ -184,54 +208,68 @@ main( int argc, char **argv )
{ {
vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) ); vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
vals[0].bv_val = uuidbuf; vals[0].bv_val = uuidbuf;
vals[1].bv_len = 0; #ifdef SLAP_NVALUES
vals[1].bv_val = NULL; attr_merge( e, slap_schema.si_ad_entryUUID, vals, vals );
#else
attr_merge( e, slap_schema.si_ad_entryUUID, vals ); attr_merge( e, slap_schema.si_ad_entryUUID, vals );
#endif
} }
if( attr_find( e->e_attrs, slap_schema.si_ad_creatorsName ) if( attr_find( e->e_attrs, slap_schema.si_ad_creatorsName )
== NULL ) == NULL )
{ {
vals[0] = name; vals[0] = name;
vals[1].bv_len = 0; #ifdef SLAP_NVALUES
vals[1].bv_val = NULL; nvals[0] = nname;
attr_merge( e, slap_schema.si_ad_creatorsName, vals); attr_merge( e, slap_schema.si_ad_creatorsName, vals, nvals );
#else
attr_merge( e, slap_schema.si_ad_creatorsName, vals );
#endif
} }
if( attr_find( e->e_attrs, slap_schema.si_ad_modifiersName ) if( attr_find( e->e_attrs, slap_schema.si_ad_modifiersName )
== NULL ) == NULL )
{ {
vals[0] = name; vals[0] = name;
vals[1].bv_len = 0; #ifdef SLAP_NVALUES
vals[1].bv_val = NULL; nvals[0] = nname;
attr_merge( e, slap_schema.si_ad_modifiersName, vals); attr_merge( e, slap_schema.si_ad_modifiersName, vals, nvals );
#else
attr_merge( e, slap_schema.si_ad_modifiersName, vals );
#endif
} }
if( attr_find( e->e_attrs, slap_schema.si_ad_createTimestamp ) if( attr_find( e->e_attrs, slap_schema.si_ad_createTimestamp )
== NULL ) == NULL )
{ {
vals[0] = timestamp; vals[0] = timestamp;
vals[1].bv_len = 0; #ifdef SLAP_NVALUES
vals[1].bv_val = NULL; attr_merge( e, slap_schema.si_ad_createTimestamp, vals, NULL );
#else
attr_merge( e, slap_schema.si_ad_createTimestamp, vals ); attr_merge( e, slap_schema.si_ad_createTimestamp, vals );
#endif
} }
if( attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp ) if( attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp )
== NULL ) == NULL )
{ {
vals[0] = timestamp; vals[0] = timestamp;
vals[1].bv_len = 0; #ifdef SLAP_NVALUES
vals[1].bv_val = NULL; attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals, NULL );
#else
attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals ); attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals );
#endif
} }
if( attr_find( e->e_attrs, slap_schema.si_ad_entryCSN ) if( attr_find( e->e_attrs, slap_schema.si_ad_entryCSN )
== NULL ) == NULL )
{ {
vals[0] = csn; vals[0] = csn;
vals[1].bv_len = 0; #ifdef SLAP_NVALUES
vals[1].bv_val = NULL; attr_merge( e, slap_schema.si_ad_entryCSN, vals, NULL );
#else
attr_merge( e, slap_schema.si_ad_entryCSN, vals ); attr_merge( e, slap_schema.si_ad_entryCSN, vals );
#endif
} }
} }