From: Kurt Zeilenga Date: Thu, 24 Dec 1998 06:00:53 +0000 (+0000) Subject: getentry.c: LDAP_RES_SEARCH_REFERENCE changes after fixing loop initializer. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~872 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=138d76ecf458ca1d1fd6ca0e24183d86a8b71e92;p=openldap getentry.c: LDAP_RES_SEARCH_REFERENCE changes after fixing loop initializer. references.c: fix same bug here. need to implement parsing. Still need to implement chasing in cldap.c/result.c --- diff --git a/libraries/libldap/cache.c b/libraries/libldap/cache.c index de09a7ae78..33b9bdf5bd 100644 --- a/libraries/libldap/cache.c +++ b/libraries/libldap/cache.c @@ -271,6 +271,7 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) } 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 ) { /* diff --git a/libraries/libldap/cldap.c b/libraries/libldap/cldap.c index 36e2a03447..adc2f9de3b 100644 --- a/libraries/libldap/cldap.c +++ b/libraries/libldap/cldap.c @@ -472,6 +472,9 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, ber_bvfree( bv ); bv = NULL; +#ifdef notyet + } else if ( tag == LDAP_RES_SEARCH_REFERENCE ) { +#endif } else { Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %lu\n", tag, 0, 0 ); diff --git a/libraries/libldap/getentry.c b/libraries/libldap/getentry.c index 01d8f2c125..069b2dcbe9 100644 --- a/libraries/libldap/getentry.c +++ b/libraries/libldap/getentry.c @@ -25,18 +25,34 @@ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of 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 */ @@ -45,9 +61,15 @@ ldap_count_entries( LDAP *ld, LDAPMessage *chain ) { 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 ); } diff --git a/libraries/libldap/references.c b/libraries/libldap/references.c index 569e209518..3c317e1937 100644 --- a/libraries/libldap/references.c +++ b/libraries/libldap/references.c @@ -35,7 +35,11 @@ ldap_next_reference( LDAP *ld, LDAPMessage *ref ) return NULLMSG; } - for ( ; ref != NULLMSG; ref = ref->lm_chain ) { + for ( + ref = ref->lm_chain; + ref != NULLMSG; + ref = ref->lm_chain ) + { if( ref->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) { return( ref ); } diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index a552c3f543..dead0523f8 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -94,6 +94,7 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout, if ( all == 0 || (lm->lm_msgtype != LDAP_RES_SEARCH_RESULT + && lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE /* LDAPv3 */ && lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY) ) break;