Commit a038ef68 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

added attr_merge/value_add functions that dela with single attribute; bervals...

added attr_merge/value_add functions that dela with single attribute; bervals for '*', '+' and '1.1' made available
parent ff4edfa0
......@@ -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.
......
......@@ -14,6 +14,7 @@
#include <ac/time.h>
#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
*/
......
......@@ -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
*/
......
......@@ -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) {
......
......@@ -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,
......
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