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 ) {
"pagedresults", buf, ptr - buf );
}
- if ( ber != NULL ) {
- ber_free( ber, 1 );
- }
-
return 0;
}
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;
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;
ber_free( seber, 1 );
ber_free( vrber, 1 );
- ber_free( prber, 1 );
}
if ( verbose ) {