From: Pierangelo Masarati Date: Fri, 23 Aug 2002 08:49:19 +0000 (+0000) Subject: added attr_merge/value_add functions that dela with single attribute; bervals for... X-Git-Tag: NO_SLAP_OP_BLOCKS~1197 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a038ef68e618e9f8f43220af52c2729c7c7b36c9;p=openldap added attr_merge/value_add functions that dela with single attribute; bervals for '*', '+' and '1.1' made available --- diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 39c2594189..ab9c56511e 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -133,6 +133,31 @@ attr_merge( return( value_add( &(*a)->a_vals, vals ) ); } +int +attr_merge_one( + Entry *e, + AttributeDescription *desc, + struct berval *val ) +{ + Attribute **a; + + for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) { + if ( ad_cmp( (*a)->a_desc, desc ) == 0 ) { + break; + } + } + + if ( *a == NULL ) { + *a = (Attribute *) ch_malloc( sizeof(Attribute) ); + (*a)->a_desc = desc; + (*a)->a_vals = NULL; + (*a)->a_next = NULL; + (*a)->a_flags = 0; + } + + return( value_add_one( &(*a)->a_vals, val ) ); +} + /* * attrs_find - find attribute(s) by AttributeDescription * returns next attribute which is subtype of provided description. diff --git a/servers/slapd/init.c b/servers/slapd/init.c index b860b3f673..d091c4fe07 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -14,6 +14,7 @@ #include #include "slap.h" +#include "lber_pvt.h" /* * read-only global variables or variables only written by the listener @@ -33,6 +34,10 @@ int ldap_syslog_level = LOG_DEBUG; BerVarray default_referral = NULL; +struct berval AllUser = BER_BVC( LDAP_ALL_USER_ATTRIBUTES ); +struct berval AllOper = BER_BVC( LDAP_ALL_OPERATIONAL_ATTRIBUTES ); +struct berval NoAttrs = BER_BVC( LDAP_NO_ATTRS ); + /* * global variables that need mutex protection */ diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 6282ee2848..fe3b1546df 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -123,6 +123,9 @@ LDAP_SLAPD_F (Attribute *) attr_dup LDAP_P(( Attribute *a )); 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 )); LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P(( Attribute *a, AttributeDescription *desc )); LDAP_SLAPD_F (Attribute *) attr_find LDAP_P(( @@ -998,6 +1001,9 @@ LDAP_SLAPD_F (int) value_find_ex LDAP_P(( LDAP_SLAPD_F (int) value_add LDAP_P(( BerVarray *vals, BerVarray addvals )); +LDAP_SLAPD_F (int) value_add_one LDAP_P(( + BerVarray *vals, + struct berval *addval )); /* * Other... @@ -1073,6 +1079,10 @@ LDAP_SLAPD_V (ber_socket_t) dtblsize; LDAP_SLAPD_V (int) use_reverse_lookup; +LDAP_SLAPD_V (struct berval) AllUser; +LDAP_SLAPD_V (struct berval) AllOper; +LDAP_SLAPD_V (struct berval) NoAttrs; + /* * operations */ diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 3551b745ed..ccc1de3083 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -645,11 +645,6 @@ send_search_result( } } -static struct berval AllUser = { sizeof(LDAP_ALL_USER_ATTRIBUTES)-1, - LDAP_ALL_USER_ATTRIBUTES }; -static struct berval AllOper = { sizeof(LDAP_ALL_OPERATIONAL_ATTRIBUTES)-1, - LDAP_ALL_OPERATIONAL_ATTRIBUTES }; - int send_search_entry( Backend *be, @@ -726,7 +721,7 @@ send_search_entry( Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); #endif ber_free_buf( ber ); - return; + return( 1 ); } } if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2) { diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 002a105ab3..3aa2adfa50 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -53,6 +53,36 @@ value_add( return LDAP_SUCCESS; } +int +value_add_one( + BerVarray *vals, + struct berval *addval +) +{ + int n; + BerVarray v2; + + if ( *vals == NULL ) { + *vals = (BerVarray) ch_malloc( 2 * sizeof(struct berval) ); + n = 0; + } else { + for ( n = 0; (*vals)[n].bv_val != NULL; n++ ) { + ; /* Empty */ + } + *vals = (BerVarray) ch_realloc( (char *) *vals, + (n + 2) * sizeof(struct berval) ); + } + + v2 = *vals + n; + ber_dupbv(v2, addval); + + v2++; + v2->bv_val = NULL; + v2->bv_len = 0; + + return LDAP_SUCCESS; +} + int value_validate( MatchingRule *mr,