From: Kurt Zeilenga Date: Fri, 15 Sep 2000 05:56:37 +0000 (+0000) Subject: consistently use ber_pvt_ber_*() routines X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1977 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b611ec4b87aa0858ba99fd114d99cff5054c52a3;p=openldap consistently use ber_pvt_ber_*() routines --- diff --git a/libraries/liblber/bprint.c b/libraries/liblber/bprint.c index 97f575b904..e88f072a78 100644 --- a/libraries/liblber/bprint.c +++ b/libraries/liblber/bprint.c @@ -208,28 +208,26 @@ ber_dump( int inout ) { char buf[132]; + ber_len_t len; assert( ber != NULL ); assert( BER_VALID( ber ) ); - sprintf( buf, "ber_dump: buf 0x%lx, ptr 0x%lx, end 0x%lx\n", + if ( inout == 1 ) { + len = ber_pvt_ber_remaining(ber); + } else { + len = ber_pvt_ber_write(ber); + } + + sprintf( buf, "ber_dump: buf=0x%08lx ptr=0x%08lx end=0x%08lx len=%ld\n", (long) ber->ber_buf, (long) ber->ber_ptr, - (long) ber->ber_end ); + (long) ber->ber_end, + (long) len ); (*ber_pvt_log_print)( buf ); - if ( inout == 1 ) { - sprintf( buf, " current len %ld, contents:\n", - (long) (ber->ber_end - ber->ber_ptr) ); - ber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr ); - - } else { - sprintf( buf, " current len %ld, contents:\n", - (long) (ber->ber_ptr - ber->ber_buf) ); - - ber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf ); - } + ber_bprint( ber->ber_ptr, len ); } int diff --git a/libraries/liblber/lber-int.h b/libraries/liblber/lber-int.h index 7234e33db2..00a8f06a6c 100644 --- a/libraries/liblber/lber-int.h +++ b/libraries/liblber/lber-int.h @@ -61,8 +61,9 @@ struct berelement { }; #define BER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT) -#define ber_pvt_ber_bytes(ber) ((ber)->ber_ptr - (ber)->ber_buf) #define ber_pvt_ber_remaining(ber) ((ber)->ber_end - (ber)->ber_ptr) +#define ber_pvt_ber_total(ber) ((ber)->ber_end - (ber)->ber_buf) +#define ber_pvt_ber_write(ber) ((ber)->ber_ptr - (ber)->ber_buf) struct sockbuf { struct lber_options sb_opts; diff --git a/libraries/liblber/options.c b/libraries/liblber/options.c index 3689f0df58..13a484335e 100644 --- a/libraries/liblber/options.c +++ b/libraries/liblber/options.c @@ -71,15 +71,15 @@ ber_get_option( return LBER_OPT_SUCCESS; case LBER_OPT_BER_REMAINING_BYTES: - *((ber_len_t *) outvalue) = ber->ber_end - ber->ber_ptr; + *((ber_len_t *) outvalue) = ber_pvt_ber_remaining(ber); return LBER_OPT_SUCCESS; case LBER_OPT_BER_TOTAL_BYTES: - *((ber_len_t *) outvalue) = ber->ber_end - ber->ber_buf; + *((ber_len_t *) outvalue) = ber_pvt_ber_total(ber); return LBER_OPT_SUCCESS; case LBER_OPT_BER_BYTES_TO_WRITE: - *((ber_len_t *) outvalue) = ber->ber_ptr - ber->ber_buf; + *((ber_len_t *) outvalue) = ber_pvt_ber_write(ber); return LBER_OPT_SUCCESS; default: diff --git a/libraries/libldap/controls.c b/libraries/libldap/controls.c index 6a814b80fe..c48e83cb89 100644 --- a/libraries/libldap/controls.c +++ b/libraries/libldap/controls.c @@ -125,14 +125,13 @@ int ldap_int_get_controls( } *ctrls = NULL; - len = ber_pvt_ber_remaining(ber); + len = ber_pvt_ber_remaining( ber ); if( len == 0) { /* no controls */ return LDAP_SUCCESS; } - if(( tag = ber_peek_tag( ber, &len )) != LDAP_TAG_CONTROLS ) { if( tag == LBER_ERROR ) { /* decoding error */ diff --git a/libraries/libldap/getattr.c b/libraries/libldap/getattr.c index 9b4f2fe06c..272dbce04f 100644 --- a/libraries/libldap/getattr.c +++ b/libraries/libldap/getattr.c @@ -89,9 +89,6 @@ ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber ) { ber_tag_t rc; char *attr; -#if 0 - ber_len_t len; -#endif Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 ); @@ -101,14 +98,9 @@ ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber ) assert( ber != NULL ); #if 0 - rc = ber_get_option( ber, LBER_OPT_REMAINING_BYTES, &len ); - if( rc != LDAP_OPT_SUCCESS ) { - ld->ld_errno = LDAP_LOCAL_ERROR; + if ( ber_pvt_ber_remaining( ber ) == 0 ) { return NULL; } - - /* we're done */ - if( len == 0 ) return NULL; #endif /* skip sequence, snarf attribute type, skip values */