3 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1990 Regents of the University of Michigan.
16 #include <ac/stdlib.h>
18 #include <ac/socket.h>
19 #include <ac/string.h>
26 ldap_first_entry( LDAP *ld, LDAPMessage *chain )
29 assert( LDAP_VALID( ld ) );
30 assert( chain != NULL );
32 if( ld == NULL || chain == NULL ) {
36 return chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY
38 : ldap_next_entry( ld, chain );
42 ldap_next_entry( LDAP *ld, LDAPMessage *entry )
45 assert( LDAP_VALID( ld ) );
46 assert( entry != NULL );
48 if ( ld == NULL || entry == NULL ) {
53 entry = entry->lm_chain;
55 entry = entry->lm_chain )
57 if( entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
66 ldap_count_entries( LDAP *ld, LDAPMessage *chain )
71 assert( LDAP_VALID( ld ) );
77 for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
78 if( chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
87 ldap_get_entry_controls(
90 LDAPControl ***sctrls )
96 assert( LDAP_VALID( ld ) );
97 assert( entry != NULL );
98 assert( sctrls != NULL );
100 if ( ld == NULL || sctrls == NULL ||
101 entry == NULL || entry->lm_msgtype != LDAP_RES_SEARCH_ENTRY )
103 return LDAP_PARAM_ERROR;
106 /* make a local copy of the BerElement */
107 AC_MEMCPY(&be, entry->lm_ber, sizeof(be));
109 if ( ber_scanf( &be, "{xx" /*}*/ ) == LBER_ERROR ) {
110 rc = LDAP_DECODING_ERROR;
111 goto cleanup_and_return;
114 rc = ldap_int_get_controls( &be, sctrls );
117 if( rc != LDAP_SUCCESS ) {
120 if( ld->ld_matched != NULL ) {
121 LDAP_FREE( ld->ld_matched );
122 ld->ld_matched = NULL;
125 if( ld->ld_error != NULL ) {
126 LDAP_FREE( ld->ld_error );