diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index ae7f0c6402a503283c78884c356f54a337eb8f97..a9b995d0f194f1d975cbe91cdfd61a31c20419f4 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -1388,24 +1388,26 @@ print_entry( ber_free( ber, 0 ); } } -#else /* This is the proposed new way of doing things. */ +#else +/* This is the proposed new way of doing things. + * It is more * efficient, but the API is non-standard. + */ static void print_entry( LDAP *ld, LDAPMessage *entry, int attrsonly) { - char *ufn; + char *ufn = NULL; char tmpfname[ 256 ]; char url[ 256 ]; int i, rc; BerElement *ber = NULL; - struct berval *bvals, bv; + struct berval bv, *bvals, **bvp = &bvals; LDAPControl **ctrls = NULL; FILE *tmpfp; rc = ldap_get_dn_ber( ld, entry, &ber, &bv ); - ufn = NULL; if ( ldif < 2 ) { ufn = ldap_dn2ufn( bv.bv_val ); @@ -1435,17 +1437,17 @@ print_entry( if( ufn != NULL ) ldap_memfree( ufn ); - for ( rc = ldap_get_attribute_ber( ld, entry, ber, &bv ); rc == LDAP_SUCCESS; - rc = ldap_get_attribute_ber( ld, entry, ber, &bv ) ) + if ( attrsonly ) bvp = NULL; + + for ( rc = ldap_get_attribute_ber( ld, entry, ber, &bv, bvp ); rc == LDAP_SUCCESS; + rc = ldap_get_attribute_ber( ld, entry, ber, &bv, bvp ) ) { if (bv.bv_val == NULL) break; if ( attrsonly ) { write_ldif( LDIF_PUT_NOVALUE, bv.bv_val, NULL, 0 ); - /* skip values */ - ber_scanf( ber, "x}" ); - } else if (( rc = ldap_get_values_ber( ld, entry, ber, &bvals )) == LDAP_SUCCESS ) { + } else { for ( i = 0; bvals[i].bv_val != NULL; i++ ) { if ( vals2tmp > 1 || ( vals2tmp && ldif_is_not_printable( bvals[i].bv_val, bvals[i].bv_len ) )) diff --git a/include/ldap.h b/include/ldap.h index 1ee7b43fde37a770d940ad601328b9b05b002f4f..5f7f8ab4074e865680e97716a3ab2959d56f435b 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -1306,11 +1306,8 @@ ldap_get_dn_ber LDAP_P(( LDAP_F( int ) ldap_get_attribute_ber LDAP_P(( - LDAP *ld, LDAPMessage *e, BerElement *ber, struct berval *attr )); - -LDAP_F( int ) -ldap_get_values_ber LDAP_P(( - LDAP *ld, LDAPMessage *e, BerElement *ber, struct berval **bv )); + LDAP *ld, LDAPMessage *e, BerElement *ber, struct berval *attr, + struct berval **vals )); /* * in getattr.c diff --git a/libraries/libldap/getattr.c b/libraries/libldap/getattr.c index db690d13b1c7facc64539cbbecc188a04c3951a9..90b969aeb5dd2a34ebf2d766de67ec9f64a6a378 100644 --- a/libraries/libldap/getattr.c +++ b/libraries/libldap/getattr.c @@ -121,10 +121,11 @@ ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber ) return attr; } +/* Fetch attribute type and optionally fetch values */ /* ARGSUSED */ int ldap_get_attribute_ber( LDAP *ld, LDAPMessage *entry, BerElement *ber, - BerValue *attr ) + BerValue *attr, BerVarray *vals ) { ber_tag_t tag; int rc = LDAP_SUCCESS; @@ -146,7 +147,7 @@ ldap_get_attribute_ber( LDAP *ld, LDAPMessage *entry, BerElement *ber, if ( ber_pvt_ber_remaining( ber ) ) { /* skip sequence, snarf attribute type */ - tag = ber_scanf( ber, "{m", attr ); + tag = ber_scanf( ber, vals ? "{mW}" : "{mx}", attr, vals ); if( tag == LBER_ERROR ) { rc = ld->ld_errno = LDAP_DECODING_ERROR; } diff --git a/libraries/libldap/getvalues.c b/libraries/libldap/getvalues.c index ee2962b7c34f725797605e021ea1e11e1d5b4304..34ee28da563a40a9706cf1aca713aaea49f2dd3d 100644 --- a/libraries/libldap/getvalues.c +++ b/libraries/libldap/getvalues.c @@ -144,30 +144,6 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) return( vals ); } -int -ldap_get_values_ber( LDAP *ld, LDAPMessage *entry, BerElement *ber, BerVarray *bv ) -{ - int rc = LDAP_SUCCESS; - - assert( ld != NULL ); - assert( LDAP_VALID( ld ) ); - assert( entry != NULL ); - assert( ber != NULL ); - assert( bv != NULL ); - -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ENTRY, "ldap_get_values_ber\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "ldap_get_values_ber\n", 0, 0, 0 ); -#endif - - /* get the array of vals */ - if ( ber_scanf( ber, "W}" /* }}} */, bv ) == LBER_ERROR ) { - rc = ld->ld_errno = LDAP_DECODING_ERROR; - } - - return( rc ); -} int ldap_count_values( char **vals ) {