return -1;
}
+#ifdef SLAP_NVALUES
+ if( attr_merge( e, ad_attributeTypes, vals, NULL /* FIXME */ ) )
+#else
if( attr_merge( e, ad_attributeTypes, vals ) )
+#endif
+ {
return -1;
+ }
ldap_memfree( vals[0].bv_val );
}
return 0;
attr_free( Attribute *a )
{
ber_bvarray_free( a->a_vals );
+#ifdef SLAP_NVALUES
+ ber_bvarray_free( a->a_nvals );
+#endif
free( a );
}
}
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++ ) {
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;
+#endif
}
tmp->a_vals[i].bv_val = NULL;
+#ifdef SLAP_NVALUES
+ tmp->a_nvals[i].bv_val = NULL;
+#endif
} else {
tmp->a_vals = NULL;
+#ifdef SLAP_NVALUES
+ tmp->a_nvals = NULL;
+#endif
}
tmp->a_desc = a->a_desc;
attr_merge(
Entry *e,
AttributeDescription *desc,
- BerVarray vals )
-{
+ BerVarray vals
+#ifdef SLAP_NVALUES
+ , BerVarray nvals
+#endif
+) {
+ int rc;
+
Attribute **a;
for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) {
*a = (Attribute *) ch_malloc( sizeof(Attribute) );
(*a)->a_desc = desc;
(*a)->a_vals = NULL;
+#ifdef SLAP_NVALUES
+ (*a)->a_nvals = NULL;
+#endif
(*a)->a_next = NULL;
(*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
attr_merge_one(
Entry *e,
AttributeDescription *desc,
- struct berval *val )
-{
+ struct berval *val
+#ifdef SLAP_NVALUES
+ , BerVarray nval
+#endif
+) {
+ int rc;
Attribute **a;
for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) {
*a = (Attribute *) ch_malloc( sizeof(Attribute) );
(*a)->a_desc = desc;
(*a)->a_vals = NULL;
+#ifdef SLAP_NVALUES
+ (*a)->a_nvals = NULL;
+#endif
(*a)->a_next = NULL;
(*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;
}
/*
struct berval vals[2];
ContentRule *cr;
- AttributeDescription *ad_ditContentRules = slap_schema.si_ad_ditContentRules;
+ AttributeDescription *ad_ditContentRules
+ = slap_schema.si_ad_ditContentRules;
vals[1].bv_val = NULL;
Debug( LDAP_DEBUG_TRACE, "Merging cr [%ld] %s\n",
(long) vals[0].bv_len, vals[0].bv_val, 0 );
#endif
+#ifdef SLAP_NVALUES
+ if( attr_merge( e, ad_ditContentRules, vals, NULL ) )
+#else
if( attr_merge( e, ad_ditContentRules, vals ) )
+#endif
+ {
return -1;
+ }
ldap_memfree( vals[0].bv_val );
}
#endif
Entry *e;
char *type;
struct berval vals[2];
+#ifdef SLAP_NVALUES
+ struct berval nvals[2];
+#endif
AttributeDescription *ad;
const char *text;
char *next;
}
}
- 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 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1,
free( type );
free( vals[0].bv_val );
+#ifdef SLAP_NVALUES
+ free( nvals[0].bv_val );
+#endif
}
/* check to make sure there was a dn: line */
}
/* 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 */
*text = textbuf;
snprintf( textbuf, textlen,
int freeit
)
{
-#if 0
- if ( mod->sm_type.bv_val)
- free( mod->sm_type.bv_val );
+ if ( mod->sm_values != NULL ) ber_bvarray_free( mod->sm_values );
+
+#ifdef SLAP_NVALUES
+ if ( mod->sm_nvalues != NULL ) ber_bvarray_free( mod->sm_nvalues );
#endif
- if ( mod->sm_bvalues != NULL )
- ber_bvarray_free( mod->sm_bvalues );
if( freeit )
free( mod );
Debug( LDAP_DEBUG_TRACE, "Merging mr [%lu] %s\n",
mr->smr_str.bv_len, mr->smr_str.bv_val, 0 );
#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 ) )
+#endif
+ {
return -1;
+ }
}
return 0;
}
Debug( LDAP_DEBUG_TRACE, "Merging mru [%lu] %s\n",
mru->smru_str.bv_len, mru->smru_str.bv_val, 0 );
#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 ) )
+#endif
+ {
return -1;
+ }
}
return 0;
}
Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n",
(long) vals[0].bv_len, vals[0].bv_val, 0 );
#endif
+#ifdef SLAP_NVALUES
+ if( attr_merge( e, ad_objectClasses, vals, NULL /* FIXME */ ) )
+#else
if( attr_merge( e, ad_objectClasses, vals ) )
+#endif
+ {
return -1;
+ }
ldap_memfree( vals[0].bv_val );
}
return 0;
LDAP_SLAPD_F (void) attr_free 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,
AttributeDescription *desc,
BerVarray vals ));
LDAP_SLAPD_F (int) attr_merge_one LDAP_P(( Entry *e,
AttributeDescription *desc,
struct berval *val ));
+#endif
LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P((
Attribute *a, AttributeDescription *desc ));
LDAP_SLAPD_F (Attribute *) attr_find LDAP_P((
const char **text )
{
Entry *e;
- struct berval vals[2], *bv;
+ struct berval vals[2], *bv;
+#ifdef SLAP_NVALUES
+ struct berval nvals[2];
+#endif
int i, j;
char ** supportedSASLMechanisms;
= slap_schema.si_ad_ref;
vals[1].bv_val = NULL;
+#ifdef SLAP_NVALUES
+ nvals[1].bv_val = NULL;
+#endif
e = (Entry *) SLAP_CALLOC( 1, sizeof(Entry) );
vals[0].bv_val = "top";
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 ) )
+#endif
+ {
return LDAP_OTHER;
+ }
vals[0].bv_val = "OpenLDAProotDSE";
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 ) )
+#endif
return LDAP_OTHER;
+#ifdef SLAP_NVALUES
+ if( attr_merge( e, ad_structuralObjectClass, vals, vals ) )
+#else
if( attr_merge( e, ad_structuralObjectClass, vals ) )
+#endif
return LDAP_OTHER;
for ( i = 0; i < nbackends; i++ ) {
if ( backends[i].be_flags & SLAP_BFLAG_MONITOR ) {
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 ) )
+#endif
+ {
return LDAP_OTHER;
+ }
continue;
}
if ( backends[i].be_flags & SLAP_BFLAG_GLUE_SUBORDINATE ) {
}
for ( j = 0; backends[i].be_suffix[j].bv_val != NULL; 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 ) )
+#endif
+ {
return LDAP_OTHER;
+ }
}
}
/* supportedControl */
for ( i=0; (vals[0].bv_val = get_supported_ctrl(i)) != NULL; i++ ) {
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 ) )
+#endif
+ {
return LDAP_OTHER;
+ }
}
/* supportedExtension */
for ( i=0; (bv = get_supported_extop(i)) != NULL; i++ ) {
vals[0] = *bv;
+#ifdef SLAP_NVALUES
+ if( attr_merge( e, ad_supportedExtension, vals, NULL ) )
+#else
if( attr_merge( e, ad_supportedExtension, vals ) )
+#endif
+ {
return LDAP_OTHER;
+ }
}
#ifdef LDAP_SLAPI
/* netscape supportedExtension */
for ( i = 0; (bv = ns_get_supported_extop(i)) != NULL; i++ ) {
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 */
/* supportedFeatures */
+#ifdef SLAP_NVALUES
+ if( attr_merge( e, ad_supportedFeatures,
+ supportedFeatures, supportedFeatures ) )
+#else
if( attr_merge( e, ad_supportedFeatures, supportedFeatures ) )
+#endif
+ {
return LDAP_OTHER;
+ }
/* supportedLDAPVersion */
for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) {
snprintf(buf, sizeof buf, "%d", i);
vals[0].bv_val = buf;
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 ) )
+#endif
+ {
return LDAP_OTHER;
+ }
}
/* supportedSASLMechanism */
for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
vals[0].bv_val = supportedSASLMechanisms[i];
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 ) )
+#endif
+ {
return LDAP_OTHER;
+ }
}
ldap_charray_free( supportedSASLMechanisms );
}
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 ) )
+#endif
+ {
return LDAP_OTHER;
+ }
}
if( usr_attr != NULL) {
Attribute *a;
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 ) )
+#endif
+ {
return LDAP_OTHER;
+ }
}
}
*/
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 ) )
+#endif
+ {
return LDAP_OTHER;
+ }
}
entry_free( e );
Entry *e;
struct berval vals[5];
+#ifdef SLAP_NVALUES
+ struct berval nvals[5];
+#endif
e = (Entry *) SLAP_CALLOC( 1, sizeof(Entry) );
if( e == NULL ) {
vals[0].bv_val = "subentry";
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 */
entry_free( e );
*text = "out of memory";
vals[3].bv_val = "extensibleObject";
vals[3].bv_len = sizeof("extensibleObject")-1;
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 */
entry_free( e );
*text = "out of memory";
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 */
entry_free( e );
*text = "out of memory";
vals[0].bv_val = 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 */
entry_free( e );
*text = "out of memory";
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 */
entry_free( e );
*text = "out of memory";
#include "ldap_queue.h"
#ifdef LDAP_DEVEL
+/* #define SLAP_NVALUES 1 */
#define SLAP_EXTENDED_SCHEMA 1
#endif
*/
typedef struct slap_attr {
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;
unsigned a_flags;
#define SLAP_ATTR_IXADD 0x1U
int sm_op;
AttributeDescription *sm_desc;
struct berval sm_type;
- BerVarray sm_bvalues;
+#define sm_bvalues sm_values
+ BerVarray sm_values;
+#ifdef SLAP_NVALUES
+ BerVarray sm_nvalues;
+#endif
} Modification;
typedef struct slap_mod_list {
#endif
#endif
+#ifdef SLAP_NVALUES
+ if( attr_merge( e, ad_ldapSyntaxes, vals, NULL /* FIXME */ ) )
+#else
if( attr_merge( e, ad_ldapSyntaxes, vals ) )
+#endif
+ {
return -1;
+ }
ldap_memfree( vals[0].bv_val );
}
return 0;
}
vals[1].bv_val = NULL;
- attr_merge( e, slap_schema.si_ad_structuralObjectClass,
- vals );
+#ifdef SLAP_NVALUES
+ attr_merge( e, slap_schema.si_ad_structuralObjectClass, vals,
+ NULL /* FIXME */ );
+#else
+ attr_merge( e, slap_schema.si_ad_structuralObjectClass, vals );
+#endif
}
/* check schema */
struct berval vals[ 2 ];
struct berval name, timestamp, csn;
+
+#ifdef SLAP_NVALUES
+ struct berval nvals[ 2 ];
+ struct berval nname;
+#endif
char timebuf[ LDAP_LUTIL_GENTIME_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);
lutil_gentime( timebuf, sizeof(timebuf), ltm );
if ( be->be_rootndn.bv_len == 0 ) {
name.bv_val = SLAPD_ANONYMOUS;
name.bv_len = sizeof(SLAPD_ANONYMOUS) - 1;
+#ifdef SLAP_NVALUES
+ nname.bv_val = SLAPD_ANONYMOUS;
+ nname.bv_len = sizeof(SLAPD_ANONYMOUS) - 1;
+#endif
} 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 )
{
vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
vals[0].bv_val = uuidbuf;
- vals[1].bv_len = 0;
- vals[1].bv_val = NULL;
+#ifdef SLAP_NVALUES
+ attr_merge( e, slap_schema.si_ad_entryUUID, vals, vals );
+#else
attr_merge( e, slap_schema.si_ad_entryUUID, vals );
+#endif
}
if( attr_find( e->e_attrs, slap_schema.si_ad_creatorsName )
== NULL )
{
vals[0] = name;
- vals[1].bv_len = 0;
- vals[1].bv_val = NULL;
- attr_merge( e, slap_schema.si_ad_creatorsName, vals);
+#ifdef SLAP_NVALUES
+ nvals[0] = nname;
+ 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 )
== NULL )
{
vals[0] = name;
- vals[1].bv_len = 0;
- vals[1].bv_val = NULL;
- attr_merge( e, slap_schema.si_ad_modifiersName, vals);
+#ifdef SLAP_NVALUES
+ nvals[0] = nname;
+ 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 )
== NULL )
{
vals[0] = timestamp;
- vals[1].bv_len = 0;
- vals[1].bv_val = NULL;
+#ifdef SLAP_NVALUES
+ attr_merge( e, slap_schema.si_ad_createTimestamp, vals, NULL );
+#else
attr_merge( e, slap_schema.si_ad_createTimestamp, vals );
+#endif
}
if( attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp )
== NULL )
{
vals[0] = timestamp;
- vals[1].bv_len = 0;
- vals[1].bv_val = NULL;
+#ifdef SLAP_NVALUES
+ attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals, NULL );
+#else
attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals );
+#endif
}
if( attr_find( e->e_attrs, slap_schema.si_ad_entryCSN )
== NULL )
{
vals[0] = csn;
- vals[1].bv_len = 0;
- vals[1].bv_val = NULL;
+#ifdef SLAP_NVALUES
+ attr_merge( e, slap_schema.si_ad_entryCSN, vals, NULL );
+#else
attr_merge( e, slap_schema.si_ad_entryCSN, vals );
+#endif
}
}