2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * Copyright (c) 1990 Regents of the University of Michigan.
18 #include <ac/socket.h>
19 #include <ac/string.h>
26 ldap_first_entry( LDAP *ld, LDAPMessage *chain )
28 if( ld == NULL || chain == NULLMSG ) {
32 return chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY
34 : ldap_next_entry( ld, chain );
39 ldap_next_entry( LDAP *ld, LDAPMessage *entry )
41 if ( ld == NULL || entry == NULLMSG ) {
46 entry = entry->lm_chain;
48 entry = entry->lm_chain )
50 if( entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
60 ldap_count_entries( LDAP *ld, LDAPMessage *chain )
68 for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
69 if( chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
78 ldap_get_entry_controls(
81 LDAPControl ***serverctrls)
86 if ( ld == NULL || serverctrls == NULL ||
87 entry == NULL || entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY )
89 return LDAP_PARAM_ERROR;
92 /* make a local copy of the BerElement */
93 SAFEMEMCPY(&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_get_ber_controls( &be, serverctrls );
103 if( rc != LDAP_SUCCESS ) {
106 if( ld->ld_matched != NULL )
107 free( ld->ld_matched );
109 ld->ld_matched = NULL;
111 if( ld->ld_error != NULL )
112 free( ld->ld_error );