]> git.sur5r.net Git - openldap/commitdiff
use new paged results control client API (ITS#4314)
authorPierangelo Masarati <ando@openldap.org>
Sun, 8 Jan 2006 22:49:24 +0000 (22:49 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sun, 8 Jan 2006 22:49:24 +0000 (22:49 +0000)
clients/tools/common.c
clients/tools/ldapsearch.c

index 42186ff69965dda2dbc29363267047f4c70fef12..317340229db32b7dd41aa0756049006ab3b635b3 100644 (file)
@@ -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;
 }
 
index a229b56391a6311c115b230b48b94ea57584f8eb..409138a340950563e514575348c23c118c2acfda 100644 (file)
@@ -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 ) {