mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-04-18 15:20:35 +08:00
use new paged results control client API (ITS#4314)
This commit is contained in:
parent
564dca34bf
commit
5640f6313a
@ -1406,24 +1406,23 @@ print_postread( LDAP *ld, LDAPControl *ctrl )
|
||||
static int
|
||||
print_paged_results( LDAP *ld, LDAPControl *ctrl )
|
||||
{
|
||||
BerElement *ber;
|
||||
ber_int_t estimate;
|
||||
|
||||
ber = ber_init( &ctrl->ldctl_value );
|
||||
unsigned long estimate;
|
||||
|
||||
/* note: pr_cookie is being malloced; it's freed
|
||||
* the next time the control is sent, but the last
|
||||
* time it's not; we don't care too much, because
|
||||
* the last time an empty value is returned... */
|
||||
if ( ber_scanf( ber, "{io}", &estimate, &pr_cookie ) == LBER_ERROR ) {
|
||||
if ( ldap_parse_pageresponse_control( ld, ctrl, &estimate, &pr_cookie ) != LDAP_SUCCESS ) {
|
||||
/* error? */
|
||||
return 1;
|
||||
|
||||
} else {
|
||||
/* FIXME: check buffer overflow */
|
||||
char buf[ BUFSIZ ], *ptr = buf;
|
||||
|
||||
if ( estimate > 0 ) {
|
||||
ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
|
||||
"estimate=%d", estimate );
|
||||
"estimate=%lu", estimate );
|
||||
}
|
||||
|
||||
if ( pr_cookie.bv_len > 0 ) {
|
||||
@ -1455,10 +1454,6 @@ print_paged_results( LDAP *ld, LDAPControl *ctrl )
|
||||
"pagedresults", buf, ptr - buf );
|
||||
}
|
||||
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 1 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -627,7 +627,7 @@ main( int argc, char **argv )
|
||||
FILE *fp = NULL;
|
||||
int rc, i, first;
|
||||
LDAP *ld = NULL;
|
||||
BerElement *seber = NULL, *vrber = NULL, *prber = NULL;
|
||||
BerElement *seber = NULL, *vrber = NULL;
|
||||
|
||||
BerElement *syncber = NULL;
|
||||
struct berval *syncbvalp = NULL;
|
||||
@ -851,14 +851,10 @@ getNextPage:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (( prber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
|
||||
if ( ldap_create_page_control_value( ld, pageSize, &pr_cookie, &c[i].ldctl_value ) ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ber_printf( prber, "{iO}", pageSize, &pr_cookie );
|
||||
if ( ber_flatten2( prber, &c[i].ldctl_value, 0 ) == -1 ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if ( pr_cookie.bv_val != NULL ) {
|
||||
ber_memfree( pr_cookie.bv_val );
|
||||
pr_cookie.bv_val = NULL;
|
||||
@ -878,7 +874,6 @@ getNextPage:
|
||||
|
||||
ber_free( seber, 1 );
|
||||
ber_free( vrber, 1 );
|
||||
ber_free( prber, 1 );
|
||||
}
|
||||
|
||||
if ( verbose ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user