]> git.sur5r.net Git - openldap/commitdiff
getentry.c: LDAP_RES_SEARCH_REFERENCE changes after fixing loop initializer.
authorKurt Zeilenga <kurt@openldap.org>
Thu, 24 Dec 1998 06:00:53 +0000 (06:00 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 24 Dec 1998 06:00:53 +0000 (06:00 +0000)
references.c: fix same bug here.  need to implement parsing.
Still need to implement chasing in cldap.c/result.c

libraries/libldap/cache.c
libraries/libldap/cldap.c
libraries/libldap/getentry.c
libraries/libldap/references.c
libraries/libldap/result.c

index de09a7ae7884fa105e094c3e2ef89c62f3adf7bf..33b9bdf5bd23cdae4b8e3fdc892c9edf95f4743b 100644 (file)
@@ -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 ) {
                /*
index 36e2a03447c898c2a1d1372f07725f5b194f032d..adc2f9de3ba201fb65218f0daf456c18927d5dce 100644 (file)
@@ -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 );
index 01d8f2c1250791f1d84c10ebdebec0d5a8a2ef93..069b2dcbe97f2df759e56623dc3ed5ebb36e806b 100644 (file)
@@ -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 );
 }
index 569e209518a961306ef1cb375f3f3f1a96b06e72..3c317e1937ff649e01a3f10d5186bf0b40984856 100644 (file)
@@ -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 );
                }
index a552c3f5435e40c6a1a4c8c9c46a722f1fe84e62..dead0523f87855dfde9df611597e8fa4281c3db3 100644 (file)
@@ -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;