}
if ( result->lm_msgtype != LDAP_RES_SEARCH_ENTRY &&
+ result->lm_msgtype != LDAP_RES_SEARCH_REFERENCE &&
result->lm_msgtype != LDAP_RES_SEARCH_RESULT &&
result->lm_msgtype != LDAP_RES_COMPARE ) {
/*
LDAPMessage *
ldap_first_entry( LDAP *ld, LDAPMessage *chain )
{
- return( chain == NULLMSG || chain->lm_msgtype == LDAP_RES_SEARCH_RESULT
- ? NULLMSG : chain );
+ if( ld == NULL || chain == NULLMSG ) {
+ return NULLMSG;
+ }
+
+ return chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY
+ ? chain
+ : ldap_next_entry( ld, chain );
}
/* ARGSUSED */
-LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry )
+LDAPMessage *
+ldap_next_entry( LDAP *ld, LDAPMessage *entry )
{
- if ( entry == NULLMSG || entry->lm_chain == NULLMSG
- || entry->lm_chain->lm_msgtype == LDAP_RES_SEARCH_RESULT )
- return( NULLMSG );
+ if ( ld == NULL || entry == NULLMSG ) {
+ return NULLMSG;
+ }
- return( entry->lm_chain );
+ for (
+ entry = entry->lm_chain;
+ entry != NULLMSG;
+ entry = entry->lm_chain )
+ {
+ if( entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
+ return( entry );
+ }
+ }
+
+ return( NULLMSG );
}
/* ARGSUSED */
{
int i;
- for ( i = 0; chain != NULL && chain->lm_msgtype
- != LDAP_RES_SEARCH_RESULT; chain = chain->lm_chain )
- i++;
+ if ( ld == NULL ) {
+ return -1;
+ }
+
+ for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
+ if( chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
+ i++;
+ }
+ }
return( i );
}