Diff for /libraries/libldap/result.c between versions 1.36.2.2 and 1.36.2.6

version 1.36.2.2, 2000/06/13 17:57:20 version 1.36.2.6, 2000/08/18 02:32:54
Line 1 Line 1
 /* $OpenLDAP: pkg/ldap/libraries/libldap/result.c,v 1.45 2000/06/01 18:59:22 kurt Exp $ */  /* $OpenLDAP$ */
 /*  /*
  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.   * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file   * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
Line 67  static void merge_error_info LDAP_P(( LD Line 67  static void merge_error_info LDAP_P(( LD
   
 /*  /*
  * ldap_result - wait for an ldap result response to a message from the   * ldap_result - wait for an ldap result response to a message from the
  * ldap server.  If msgid is -1, any message will be accepted, otherwise   * ldap server.  If msgid is LDAP_RES_ANY (-1), any message will be
  * ldap_result will wait for a response with msgid.  If all is 0 the   * accepted.  If msgid is LDAP_RES_UNSOLICITED (0), any unsolicited
  * first message with id msgid will be accepted, otherwise, ldap_result   * message is accepted.  Otherwise ldap_result will wait for a response
  * will wait for all responses with id msgid and then return a pointer to   * with msgid.  If all is LDAP_MSG_ONE (0) the first message with id
  * the entire list of messages.  This is only useful for search responses,   * msgid will be accepted, otherwise, ldap_result will wait for all
  * which can be of two message types (zero or more entries, followed by an   * responses with id msgid and then return a pointer to the entire list
    * of messages.  This is only useful for search responses, which can be
    * of two message types (zero or more entries, followed by an
  * ldap result).  The type of the first message received is returned.   * ldap result).  The type of the first message received is returned.
  * When waiting, any messages that have been abandoned are discarded.   * When waiting, any messages that have been abandoned are discarded.
  *   *
Line 135  ldap_result( Line 137  ldap_result(
                         if ( all == LDAP_MSG_ONE                          if ( all == LDAP_MSG_ONE
                             || (lm->lm_msgtype != LDAP_RES_SEARCH_RESULT                              || (lm->lm_msgtype != LDAP_RES_SEARCH_RESULT
                             && lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE      /* LDAPv3 */                              && lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE      /* LDAPv3 */
                             && lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY) )                              && lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY
                                   && lm->lm_msgtype != LDAP_RES_EXTENDED_PARTIAL) )
                                 break;                                  break;
   
                         for ( tmp = lm; tmp != NULL; tmp = tmp->lm_chain ) {                          for ( tmp = lm; tmp != NULL; tmp = tmp->lm_chain ) {
Line 382  try_read1msg( Line 385  try_read1msg(
         }          }
   
         Debug( LDAP_DEBUG_TRACE, "ldap_read: message type %s msgid %ld, original id %ld\n",          Debug( LDAP_DEBUG_TRACE, "ldap_read: message type %s msgid %ld, original id %ld\n",
             ( tag == LDAP_RES_SEARCH_ENTRY ) ? "entry" :               ldap_int_msgtype2str( tag ),
                 ( tag == LDAP_RES_SEARCH_REFERENCE ) ? "reference" : "result",  
                 (long) lr->lr_msgid, (long) lr->lr_origid );                  (long) lr->lr_msgid, (long) lr->lr_origid );
   
         id = lr->lr_origid;          id = lr->lr_origid;
Line 464  try_read1msg( Line 466  try_read1msg(
                                                 }                                                  }
                                         }                                          }
                                 }                                  }
   
                                   if( lr->lr_res_matched != NULL ) {
                                           LDAP_FREE( lr->lr_res_matched );
                                           lr->lr_res_matched = NULL;
                                   }
                                   if( lr->lr_res_error != NULL ) {
                                           LDAP_FREE( lr->lr_res_error );
                                           lr->lr_res_error = NULL;
                                   }
                         }                          }
                 }                  }
         }          }
Line 644  lr->lr_res_matched ? lr->lr_res_matched Line 655  lr->lr_res_matched ? lr->lr_res_matched
         /* part of a search response - add to end of list of entries */          /* part of a search response - add to end of list of entries */
         for ( tmp = l; (tmp->lm_chain != NULL) &&          for ( tmp = l; (tmp->lm_chain != NULL) &&
                 ((tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY) ||                  ((tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY) ||
                  (tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE));                   (tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) ||
                            (tmp->lm_chain->lm_msgtype == LDAP_RES_EXTENDED_PARTIAL ));
             tmp = tmp->lm_chain )              tmp = tmp->lm_chain )
                 ;       /* NULL */                  ;       /* NULL */
         tmp->lm_chain = new;          tmp->lm_chain = new;
Line 784  ldap_msgid( LDAPMessage *lm ) Line 796  ldap_msgid( LDAPMessage *lm )
 }  }
   
   
   char * ldap_int_msgtype2str( ber_tag_t tag )
   {
           switch( tag ) {
           case LDAP_RES_ADD: return "add";
           case LDAP_RES_BIND: return "bind";
           case LDAP_RES_COMPARE: return "compare";
           case LDAP_RES_DELETE: return "delete";
           case LDAP_RES_EXTENDED: return "extended-result";
           case LDAP_RES_EXTENDED_PARTIAL: return "extended-partial";
           case LDAP_RES_MODIFY: return "modify";
           case LDAP_RES_RENAME: return "rename";
           case LDAP_RES_SEARCH_ENTRY: return "search-entry";
           case LDAP_RES_SEARCH_REFERENCE: return "search-reference";
           case LDAP_RES_SEARCH_RESULT: return "search-result";
           }
           return "unknown";
   }
   
 int  int
 ldap_msgfree( LDAPMessage *lm )  ldap_msgfree( LDAPMessage *lm )
 {  {
Line 880  ldap_mark_abandoned( LDAP *ld, ber_int_t Line 910  ldap_mark_abandoned( LDAP *ld, ber_int_t
   
         return( 0 );          return( 0 );
 }  }
   
   
 #ifdef LDAP_CONNECTIONLESS  
 int  
 cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber )  
 {  
         int     rc;  
         ber_tag_t       tag;  
         ber_len_t       len;  
         ber_socket_t    sd;  
   
         ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, &sd );  
         if ( sd != AC_SOCKET_INVALID ) {  
                 /* restored from ldap_select1() in result.c version 1.24 */  
                 fd_set  readfds;  
                 if ( ldap_int_tblsize == 0 )  
                         ldap_int_ip_init();  
                 FD_ZERO( &readfds );  
                 FD_SET( sd, &readfds );  
                 rc = select( ldap_int_tblsize, &readfds, 0, 0, timeout );  
   
                 if ( rc == -1 || rc == 0 ) {  
                         ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :  
                             LDAP_TIMEOUT);  
                         return( rc );  
                 }  
         }  
   
         /* get the next message */  
         if ( (tag = ber_get_next( ld->ld_sb, &len, ber ))  
             != LDAP_TAG_MESSAGE ) {  
                 ld->ld_errno = (tag == LBER_DEFAULT ? LDAP_SERVER_DOWN :  
                     LDAP_LOCAL_ERROR);  
                 return( -1 );  
         }  
   
         return( 0 );  
 }  
 #endif /* LDAP_CONNECTIONLESS */  

Removed from v.1.36.2.2  
changed lines
  Added in v.1.36.2.6


______________
© Copyright 1998-2020, OpenLDAP Foundation, info@OpenLDAP.org