]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/result.c
Add lber_log_print support to libldap.
[openldap] / libraries / libldap / result.c
index 182a13ccd7d4b19c9048861ad79fe7d8dbf40143..ef3a86fad3b4ba7b29d235650c5ecb08f3b2809a 100644 (file)
@@ -1,4 +1,8 @@
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
@@ -7,10 +11,6 @@
 
 #include "portable.h"
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -27,16 +27,16 @@ static int ldap_abandoned LDAP_P(( LDAP *ld, int msgid ));
 static int ldap_mark_abandoned LDAP_P(( LDAP *ld, int msgid ));
 static int wait4msg LDAP_P(( LDAP *ld, int msgid, int all, struct timeval *timeout,
        LDAPMessage **result ));
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
 static int read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc,
        LDAPMessage **result ));
 static unsigned long build_result_ber LDAP_P(( LDAP *ld, BerElement *ber, LDAPRequest *lr ));
 static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ));
-#else /* LDAP_REFERRALS */
+#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
 static int read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb,
        LDAPMessage **result ));
-#endif /* LDAP_REFERRALS */
-#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_REFERRALS )
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
+#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS )
 static int ldap_select1 LDAP_P(( LDAP *ld, struct timeval *timeout ));
 #endif
 
@@ -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;
 
@@ -139,9 +140,9 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
        struct timeval  tv, *tvp;
        time_t          start_time = 0;
        time_t          tmp_time;
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
        LDAPConn        *lc, *nextlc;
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
 
 #ifdef LDAP_DEBUG
        if ( timeout == NULL ) {
@@ -149,7 +150,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                    0, 0, 0 );
        } else {
                Debug( LDAP_DEBUG_TRACE, "wait4msg (timeout %ld sec, %ld usec)\n",
-                   timeout->tv_sec, timeout->tv_usec, 0 );
+                      (long) timeout->tv_sec, (long) timeout->tv_usec, 0 );
        }
 #endif /* LDAP_DEBUG */
 
@@ -163,7 +164,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                    
        rc = -2;
        while ( rc == -2 ) {
-#ifndef LDAP_REFERRALS
+#ifndef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
                /* hack attack */
                if ( ld->ld_sb.sb_ber.ber_ptr >= ld->ld_sb.sb_ber.ber_end ) {
                        rc = ldap_select1( ld, tvp );
@@ -183,7 +184,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                } else {
                        rc = read1msg( ld, msgid, all, &ld->ld_sb, result );
                }
-#else /* !LDAP_REFERRALS */
+#else /* !LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
 #ifdef LDAP_DEBUG
                if ( ldap_debug & LDAP_DEBUG_TRACE ) {
                        ldap_dump_connection( ld, ld->ld_conns, 1 );
@@ -238,7 +239,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                                }
                        }
                }
-#endif /* !LDAP_REFERRALS */
+#endif /* !LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
 
                if ( rc == -2 && tvp != NULL ) {
                        tmp_time = time( NULL );
@@ -249,7 +250,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                        }
 
                        Debug( LDAP_DEBUG_TRACE, "wait4msg:  %ld secs to go\n",
-                               tv.tv_sec, 0, 0 );
+                              (long) tv.tv_sec, 0, 0 );
                        start_time = tmp_time;
                }
        }
@@ -260,9 +261,9 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
 
 static int
 read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
     LDAPConn *lc,
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
     LDAPMessage **result )
 {
        BerElement      ber;
@@ -270,12 +271,12 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
        long            id;
        unsigned long   tag, len;
        int             foundit = 0;
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
        LDAPRequest     *lr;
        BerElement      tmpber;
        int             rc, refer_cnt, hadref, simple_request;
        unsigned long   lderr;
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
 
        Debug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 );
 
@@ -302,7 +303,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
                return( -2 );   /* continue looking */
        }
 
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
        if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) {
                Debug( LDAP_DEBUG_ANY,
                    "no request for response with msgid %ld (tossing)\n",
@@ -314,7 +315,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
            ( tag == LDAP_RES_SEARCH_ENTRY ) ? "entry" : "result", id,
            lr->lr_origid );
        id = lr->lr_origid;
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
 
        /* the message type */
        if ( (tag = ber_peek_tag( &ber, &len )) == LBER_ERROR ) {
@@ -322,7 +323,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
                return( -1 );
        }
 
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
        refer_cnt = 0;
        hadref = simple_request = 0;
        rc = -2;        /* default is to keep looking (no response found) */
@@ -424,7 +425,7 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
                return( rc );
        }
 
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
        /* make a new ldap message */
        if ( (new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
            == NULL ) {
@@ -516,7 +517,7 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
 }
 
 
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
 static unsigned long
 build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr )
 {
@@ -581,11 +582,11 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )
            parentr->lr_res_error : "", parentr->lr_res_matched ?
            parentr->lr_res_matched : "" );
 }
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
 
 
 
-#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_REFERRALS )
+#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS )
 
 static int
 ldap_select1( LDAP *ld, struct timeval *timeout )
@@ -614,7 +615,7 @@ ldap_select1( LDAP *ld, struct timeval *timeout )
        return( select( tblsize, &readfds, 0, 0, timeout ) );
 }
 
-#endif /* !LDAP_REFERRALS */
+#endif /* !LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
 
 
 int