Commit ac1332cd authored by Howard Chu's avatar Howard Chu
Browse files

Renamed BVarray to BerVarray. Moved slapd:bvarray_{add,free} to

liblber:ber_bvarray_{add,free}.
parent e43fe624
......@@ -201,7 +201,7 @@ typedef struct berval {
char *bv_val;
} BerValue;
typedef BerValue *BVarray; /* To distinguish from a single bv */
typedef BerValue *BerVarray; /* To distinguish from a single bv */
/* this should be moved to lber-int.h */
......@@ -574,6 +574,12 @@ LBER_F( char * )
ber_strdup LDAP_P((
LDAP_CONST char * ));
LBER_F( void )
ber_bvarray_free LDAP_P(( BerVarray p ));
LBER_F( int )
ber_bvarray_add LDAP_P(( BerVarray *p, BerValue *bv ));
/*
* error.c
*/
......
......@@ -309,7 +309,7 @@ typedef struct bgbvr {
ber_len_t off;
union {
char ***c;
BVarray *ba;
BerVarray *ba;
struct berval ***bv;
} res;
} bgbvr;
......@@ -395,7 +395,7 @@ ber_get_stringbvr( bgbvr *b, int n )
*bvp = bv;
break;
case BvOff:
*(BVarray)((long)(*b->res.ba)+n*b->siz+b->off) = bv;
*(BerVarray)((long)(*b->res.ba)+n*b->siz+b->off) = bv;
}
} else {
/* Failure will propagate up and free in reverse
......@@ -884,7 +884,7 @@ ber_scanf ( BerElement *ber,
case 'v': /* sequence of strings */
case 'V': /* sequence of strings + lengths */
case 'W': /* BVarray */
case 'W': /* BerVarray */
case 'm': /* berval in-place */
case 'M': /* BVoff array in-place */
case 'n': /* null */
......
......@@ -781,8 +781,8 @@ ber_printf( BerElement *ber, LDAP_CONST char *fmt, ... )
}
break;
case 'W': /* BVarray */
if ( (bv = va_arg( ap, BVarray )) == NULL )
case 'W': /* BerVarray */
if ( (bv = va_arg( ap, BerVarray )) == NULL )
break;
for ( i = 0; bv[i].bv_val != NULL; i++ ) {
if ( (rc = ber_put_berval( ber, &bv[i],
......
......@@ -603,3 +603,57 @@ ber_strndup__( LDAP_CONST char *s, size_t l )
p[ len ] = '\0';
return p;
}
void
ber_bvarray_free( BerVarray a )
{
int i;
ber_int_options.lbo_valid = LBER_INITIALIZED;
if (a) {
BER_MEM_VALID( a );
for (i=0; a[i].bv_val; i++) {
LBER_FREE(a[i].bv_val);
}
LBER_FREE(a);
}
}
int
ber_bvarray_add( BerVarray *a, BerValue *bv )
{
int n;
ber_int_options.lbo_valid = LBER_INITIALIZED;
if ( *a == NULL ) {
if (bv == NULL) {
return 0;
}
n = 0;
*a = (BerValue *) LBER_MALLOC( 2 * sizeof(BerValue) );
} else {
BER_MEM_VALID( a );
for ( n = 0; *a != NULL && (*a)[n].bv_val != NULL; n++ ) {
; /* NULL */
}
if (bv == NULL) {
return n;
}
*a = (BerValue *) LBER_REALLOC( (char *) *a,
(n + 2) * sizeof(BerValue) );
}
if ( *a == NULL ) {
return -1;
}
(*a)[n++] = *bv;
(*a)[n].bv_val = NULL;
return n;
}
......@@ -58,7 +58,7 @@ typedef struct AciSetCookie {
Operation *op;
} AciSetCookie;
BVarray aci_set_gather (void *cookie, char *name, struct berval *attr);
BerVarray aci_set_gather (void *cookie, char *name, struct berval *attr);
static int aci_match_set ( struct berval *subj, Backend *be,
Entry *e, Connection *conn, Operation *op, int setref );
......@@ -1199,11 +1199,11 @@ aci_get_part(
return(bv->bv_len);
}
BVarray
BerVarray
aci_set_gather (void *cookie, char *name, struct berval *attr)
{
AciSetCookie *cp = cookie;
BVarray bvals = NULL;
BerVarray bvals = NULL;
struct berval bv, ndn;
/* this routine needs to return the bervals instead of
......@@ -1244,7 +1244,7 @@ aci_match_set (
} else {
struct berval subjdn, ndn = { 0, NULL };
struct berval setat;
BVarray bvals;
BerVarray bvals;
const char *text;
AttributeDescription *desc = NULL;
......@@ -1281,7 +1281,7 @@ aci_match_set (
bvals[0].bv_val = bvals[i-1].bv_val;
bvals[i-1].bv_val = NULL;
}
bvarray_free(bvals);
ber_bvarray_free(bvals);
}
}
if (ndn.bv_val)
......
......@@ -212,13 +212,13 @@ do_add( Connection *conn, Operation *op )
*/
be = select_backend( &e->e_nname, manageDSAit, 0 );
if ( be == NULL ) {
BVarray ref = referral_rewrite( default_referral,
BerVarray ref = referral_rewrite( default_referral,
NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
NULL, NULL, ref ? ref : default_referral, NULL );
if ( ref ) bvarray_free( ref );
if ( ref ) ber_bvarray_free( ref );
goto done;
}
......@@ -299,15 +299,15 @@ do_add( Connection *conn, Operation *op )
#ifndef SLAPD_MULTIMASTER
} else {
BVarray defref = be->be_update_refs
BerVarray defref = be->be_update_refs
? be->be_update_refs : default_referral;
BVarray ref = referral_rewrite( defref,
BerVarray ref = referral_rewrite( defref,
NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
ref ? ref : defref, NULL );
if ( ref ) bvarray_free( ref );
if ( ref ) ber_bvarray_free( ref );
#endif
}
} else {
......
......@@ -29,7 +29,7 @@ static void at_index_print( void ) {};
void
attr_free( Attribute *a )
{
bvarray_free( a->a_vals );
ber_bvarray_free( a->a_vals );
free( a );
}
......@@ -110,7 +110,7 @@ int
attr_merge(
Entry *e,
AttributeDescription *desc,
BVarray vals )
BerVarray vals )
{
Attribute **a;
......
......@@ -124,7 +124,7 @@ retry: rc = txn_abort( ltid );
if ( p == NULL ) {
char *matched_dn = NULL;
BVarray refs;
BerVarray refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
......@@ -145,7 +145,7 @@ retry: rc = txn_abort( ltid );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
ch_free( matched_dn );
goto done;
......@@ -182,7 +182,7 @@ retry: rc = txn_abort( ltid );
if ( is_entry_referral( p ) ) {
/* parent is a referral, don't allow add */
char *matched_dn = ch_strdup( p->e_dn );
BVarray refs = is_entry_referral( p )
BerVarray refs = is_entry_referral( p )
? get_entry_referrals( be, conn, op, p )
: NULL;
......@@ -192,7 +192,7 @@ retry: rc = txn_abort( ltid );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
free( matched_dn );
goto done;
}
......
......@@ -28,13 +28,13 @@ bdb_attribute(
Entry *target,
struct berval *entry_ndn,
AttributeDescription *entry_at,
BVarray *vals )
BerVarray *vals )
{
struct bdbinfo *li = (struct bdbinfo *) be->be_private;
Entry *e;
int i, j, rc;
Attribute *attr;
BVarray v;
BerVarray v;
const char *entry_at_name = entry_at->ad_cname.bv_val;
#ifdef NEW_LOGGING
......@@ -163,7 +163,7 @@ bdb_attribute(
/* count them */
}
v = (BVarray) ch_malloc( sizeof(struct berval) * (i+1) );
v = (BerVarray) ch_malloc( sizeof(struct berval) * (i+1) );
for ( i=0, j=0; attr->a_vals[i].bv_val != NULL; i++ ) {
if( conn != NULL
......
......@@ -58,7 +58,7 @@ bdb_bind(
/* get entry with reader lock */
if ( e == NULL ) {
char *matched_dn = NULL;
BVarray refs;
BerVarray refs;
if( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
......@@ -100,7 +100,7 @@ bdb_bind(
NULL, NULL, NULL, NULL );
}
bvarray_free( refs );
ber_bvarray_free( refs );
free( matched_dn );
return rc;
......@@ -123,7 +123,7 @@ bdb_bind(
if ( is_entry_referral( e ) ) {
/* entry is a referral, don't allow bind */
BVarray refs = get_entry_referrals( be,
BerVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
......@@ -138,7 +138,7 @@ bdb_bind(
NULL, NULL, NULL, NULL );
}
bvarray_free( refs );
ber_bvarray_free( refs );
goto done;
}
......
......@@ -46,7 +46,7 @@ bdb_compare(
if ( e == NULL ) {
char *matched_dn = NULL;
BVarray refs;
BerVarray refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
......@@ -64,7 +64,7 @@ bdb_compare(
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
free( matched_dn );
goto done;
......@@ -72,7 +72,7 @@ bdb_compare(
if (!manageDSAit && is_entry_referral( e ) ) {
/* entry is a referral, don't allow add */
BVarray refs = get_entry_referrals( be,
BerVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
......@@ -81,7 +81,7 @@ bdb_compare(
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
goto done;
}
......
......@@ -88,7 +88,7 @@ retry: /* transaction retry */
if ( e == NULL ) {
char *matched_dn = NULL;
BVarray refs;
BerVarray refs;
Debug( LDAP_DEBUG_ARGS,
"<=- bdb_delete: no such object %s\n",
......@@ -110,7 +110,7 @@ retry: /* transaction retry */
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
free( matched_dn );
rc = -1;
......@@ -196,7 +196,7 @@ retry: /* transaction retry */
if ( !manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
BVarray refs = get_entry_referrals( be,
BerVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE,
......@@ -206,7 +206,7 @@ retry: /* transaction retry */
send_ldap_result( conn, op, LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
rc = 1;
goto done;
......
......@@ -32,7 +32,7 @@ bdb_extended(
struct berval **rspdata,
LDAPControl *** rspctrls,
const char** text,
BVarray *refs
BerVarray *refs
)
{
int i;
......
......@@ -343,7 +343,7 @@ equality_candidates(
break;
}
bvarray_free( keys );
ber_bvarray_free( keys );
Debug( LDAP_DEBUG_TRACE,
"<= bdb_equality_candidates id=%ld, first=%ld, last=%ld\n",
......@@ -450,7 +450,7 @@ approx_candidates(
break;
}
bvarray_free( keys );
ber_bvarray_free( keys );
Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates %ld, first=%ld, last=%ld\n",
(long) ids[0],
......@@ -553,7 +553,7 @@ substring_candidates(
break;
}
bvarray_free( keys );
ber_bvarray_free( keys );
Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates %ld, first=%ld, last=%ld\n",
(long) ids[0],
......
......@@ -160,7 +160,7 @@ static int indexer(
DB_TXN *txn,
char *dbname,
struct berval *atname,
BVarray vals,
BerVarray vals,
ID id,
int op,
slap_mask_t mask )
......@@ -209,11 +209,11 @@ static int indexer(
for( i=0; keys[i].bv_val != NULL; i++ ) {
rc = bdb_key_change( be, db, txn, &keys[i], id, op );
if( rc ) {
bvarray_free( keys );
ber_bvarray_free( keys );
goto done;
}
}
bvarray_free( keys );
ber_bvarray_free( keys );
}
rc = LDAP_SUCCESS;
}
......@@ -230,11 +230,11 @@ static int indexer(
for( i=0; keys[i].bv_val != NULL; i++ ) {
rc = bdb_key_change( be, db, txn, &keys[i], id, op );
if( rc ) {
bvarray_free( keys );
ber_bvarray_free( keys );
goto done;
}
}
bvarray_free( keys );
ber_bvarray_free( keys );
}
rc = LDAP_SUCCESS;
......@@ -252,11 +252,11 @@ static int indexer(
for( i=0; keys[i].bv_val != NULL; i++ ) {
bdb_key_change( be, db, txn, &keys[i], id, op );
if( rc ) {
bvarray_free( keys );
ber_bvarray_free( keys );
goto done;
}
}
bvarray_free( keys );
ber_bvarray_free( keys );
}
rc = LDAP_SUCCESS;
......@@ -271,7 +271,7 @@ static int index_at_values(
DB_TXN *txn,
AttributeType *type,
struct berval *lang,
BVarray vals,
BerVarray vals,
ID id,
int op,
char ** dbnamep,
......@@ -352,7 +352,7 @@ int bdb_index_values(
Backend *be,
DB_TXN *txn,
AttributeDescription *desc,
BVarray vals,
BerVarray vals,
ID id,
int op )
{
......
......@@ -257,7 +257,7 @@ retry: /* transaction retry */
/* acquire and lock entry */
if ( e == NULL ) {
char* matched_dn = NULL;
BVarray refs;
BerVarray refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
......@@ -275,7 +275,7 @@ retry: /* transaction retry */
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
free( matched_dn );
return rc;
......@@ -284,7 +284,7 @@ retry: /* transaction retry */
if ( !manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
BVarray refs = get_entry_referrals( be,
BerVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE,
......@@ -294,7 +294,7 @@ retry: /* transaction retry */
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
goto done;
}
......
......@@ -119,7 +119,7 @@ retry: /* transaction retry */
if ( e == NULL ) {
char* matched_dn = NULL;
BVarray refs;
BerVarray refs;
if( matched != NULL ) {
matched_dn = strdup( matched->e_dn );
......@@ -137,7 +137,7 @@ retry: /* transaction retry */
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
free( matched_dn );
goto done;
......@@ -146,7 +146,7 @@ retry: /* transaction retry */
if (!manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
BVarray refs = get_entry_referrals( be,
BerVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n",
......@@ -155,7 +155,7 @@ retry: /* transaction retry */
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
goto done;
}
......@@ -486,7 +486,7 @@ retry: /* transaction retry */
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ 2 * sizeof( struct berval ) );
mod_tmp->sml_desc = desc;
mod_tmp->sml_bvalues = ( BVarray )( mod_tmp + 1 );
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_op = SLAP_MOD_SOFTADD;
......@@ -536,7 +536,7 @@ retry: /* transaction retry */
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ 2 * sizeof ( struct berval ) );
mod_tmp->sml_desc = desc;
mod_tmp->sml_bvalues = ( BVarray )(mod_tmp+1);
mod_tmp->sml_bvalues = ( BerVarray )(mod_tmp+1);
mod_tmp->sml_bvalues[ 0 ] = old_rdn[0][ d_cnt ]->la_value;
mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
mod_tmp->sml_op = LDAP_MOD_DELETE;
......
......@@ -24,7 +24,7 @@ bdb_exop_passwd(
struct berval **rspdata,
LDAPControl *** rspctrls,
const char **text,
BVarray *refs )
BerVarray *refs )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
int rc;
......
......@@ -225,7 +225,7 @@ bdb_index_values LDAP_P((
Backend *be,
DB_TXN *txn,
AttributeDescription *desc,
BVarray vals,
BerVarray vals,
ID id,
int op ));
......
......@@ -54,7 +54,7 @@ bdb_referrals(
if ( e == NULL ) {
char *matched_dn = NULL;
BVarray refs = NULL;
BerVarray refs = NULL;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
......@@ -80,7 +80,7 @@ bdb_referrals(
/* send referrals */
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
bvarray_free( refs );
ber_bvarray_free( refs );
} else if ( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc, matched_dn,
matched_dn ? "bad referral object" : NULL,
......@@ -93,8 +93,8 @@ bdb_referrals(
if ( is_entry_referral( e ) ) {
/* entry is a referral */
BVarray refs = get_entry_referrals( be, conn, op, e );
BVarray rrefs = referral_rewrite(
BerVarray refs = get_entry_referrals( be, conn, op, e );
BerVarray rrefs = referral_rewrite(
refs, &e->e_name, dn, LDAP_SCOPE_DEFAULT );
Debug( LDAP_DEBUG_TRACE,
......@@ -104,13 +104,13 @@ bdb_referrals(
if( rrefs != NULL ) {
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, rrefs, NULL );
bvarray_free( rrefs );