3 * Copyright 1998-2002 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 return chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY
34 : ldap_next_entry( ld, chain );
38 ldap_next_entry( LDAP *ld, LDAPMessage *entry )
41 assert( LDAP_VALID( ld ) );
42 assert( entry != NULL );
45 entry = entry->lm_chain;
47 entry = entry->lm_chain )
49 if( entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
58 ldap_count_entries( LDAP *ld, LDAPMessage *chain )
63 assert( LDAP_VALID( ld ) );
65 for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
66 if( chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
75 ldap_get_entry_controls(
78 LDAPControl ***sctrls )
84 assert( LDAP_VALID( ld ) );
85 assert( entry != NULL );
86 assert( sctrls != NULL );
88 if ( entry->lm_msgtype != LDAP_RES_SEARCH_ENTRY ) {
89 return LDAP_PARAM_ERROR;
92 /* make a local copy of the BerElement */
93 AC_MEMCPY(&be, entry->lm_ber, sizeof(be));
95 if ( ber_scanf( &be, "{xx" /*}*/ ) == LBER_ERROR ) {
96 rc = LDAP_DECODING_ERROR;
97 goto cleanup_and_return;
100 rc = ldap_int_get_controls( &be, sctrls );
103 if( rc != LDAP_SUCCESS ) {
106 if( ld->ld_matched != NULL ) {
107 LDAP_FREE( ld->ld_matched );
108 ld->ld_matched = NULL;
111 if( ld->ld_error != NULL ) {
112 LDAP_FREE( ld->ld_error );