version 1.7.2.3.2.1, 2001/05/29 16:41:11
|
version 1.8, 1998/10/26 00:18:44
|
Line 1
|
Line 1
|
/* |
/* |
* 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. |
* Copyright (c) 1990 Regents of the University of Michigan. |
* All rights reserved. |
* All rights reserved. |
* |
* |
Line 11
|
Line 7
|
|
|
#include "portable.h" |
#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 <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
|
Line 20
|
Line 20
|
#include <ac/time.h> |
#include <ac/time.h> |
#include <ac/unistd.h> |
#include <ac/unistd.h> |
|
|
#include "lber.h" |
|
#include "ldap.h" |
|
#include "ldap-int.h" |
#include "ldap-int.h" |
|
|
|
|
Line 32 static int wait4msg LDAP_P(( LDAP *ld, i
|
Line 30 static int wait4msg LDAP_P(( LDAP *ld, i
|
#ifdef LDAP_REFERRALS |
#ifdef LDAP_REFERRALS |
static int read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc, |
static int read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc, |
LDAPMessage **result )); |
LDAPMessage **result )); |
static unsigned long build_result_ber LDAP_P(( LDAP *ld, BerElement *ber, LDAPRequest *lr )); |
static int build_result_ber LDAP_P(( LDAP *ld, BerElement *ber, LDAPRequest *lr )); |
static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )); |
static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )); |
#else /* LDAP_REFERRALS */ |
#else /* LDAP_REFERRALS */ |
static int read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, |
static int read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, |
Line 151 wait4msg( LDAP *ld, int msgid, int all,
|
Line 149 wait4msg( LDAP *ld, int msgid, int all,
|
0, 0, 0 ); |
0, 0, 0 ); |
} else { |
} else { |
Debug( LDAP_DEBUG_TRACE, "wait4msg (timeout %ld sec, %ld usec)\n", |
Debug( LDAP_DEBUG_TRACE, "wait4msg (timeout %ld sec, %ld usec)\n", |
(long) timeout->tv_sec, (long) timeout->tv_usec, 0 ); |
timeout->tv_sec, timeout->tv_usec, 0 ); |
} |
} |
#endif /* LDAP_DEBUG */ |
#endif /* LDAP_DEBUG */ |
|
|
Line 246 wait4msg( LDAP *ld, int msgid, int all,
|
Line 244 wait4msg( LDAP *ld, int msgid, int all,
|
} |
} |
|
|
Debug( LDAP_DEBUG_TRACE, "wait4msg: %ld secs to go\n", |
Debug( LDAP_DEBUG_TRACE, "wait4msg: %ld secs to go\n", |
(long) tv.tv_sec, 0, 0 ); |
tv.tv_sec, 0, 0 ); |
start_time = tmp_time; |
start_time = tmp_time; |
} |
} |
} |
} |
Line 280 read1msg( LDAP *ld, int msgid, int all,
|
Line 278 read1msg( LDAP *ld, int msgid, int all,
|
ldap_set_ber_options( ld, &ber ); |
ldap_set_ber_options( ld, &ber ); |
|
|
/* get the next message */ |
/* get the next message */ |
if ( (tag = ber_get_next( sb, &len, &ber )) != LDAP_TAG_MESSAGE ) { |
if ( (tag = ber_get_next( sb, &len, &ber )) |
ld->ld_errno = (tag == LBER_DEFAULT) |
!= LDAP_TAG_MESSAGE ) { |
? LDAP_SERVER_DOWN |
ld->ld_errno = (tag == LBER_DEFAULT ? LDAP_SERVER_DOWN : |
: LDAP_LOCAL_ERROR; |
LDAP_LOCAL_ERROR); |
free( ber.ber_buf ); |
|
return( -1 ); |
return( -1 ); |
} |
} |
|
|
/* message id */ |
/* message id */ |
if ( ber_get_int( &ber, &id ) == LBER_ERROR ) { |
if ( ber_get_int( &ber, &id ) == LBER_ERROR ) { |
ld->ld_errno = LDAP_DECODING_ERROR; |
ld->ld_errno = LDAP_DECODING_ERROR; |
free( ber.ber_buf ); |
|
return( -1 ); |
return( -1 ); |
} |
} |
|
|
/* if it's been abandoned, toss it */ |
/* if it's been abandoned, toss it */ |
if ( ldap_abandoned( ld, (int)id ) ) { |
if ( ldap_abandoned( ld, (int)id ) ) { |
free( ber.ber_buf ); |
free( ber.ber_buf ); /* gack! */ |
return( -2 ); /* continue looking */ |
return( -2 ); /* continue looking */ |
} |
} |
|
|
Line 306 read1msg( LDAP *ld, int msgid, int all,
|
Line 302 read1msg( LDAP *ld, int msgid, int all,
|
Debug( LDAP_DEBUG_ANY, |
Debug( LDAP_DEBUG_ANY, |
"no request for response with msgid %ld (tossing)\n", |
"no request for response with msgid %ld (tossing)\n", |
id, 0, 0 ); |
id, 0, 0 ); |
free( ber.ber_buf ); |
free( ber.ber_buf ); /* gack! */ |
return( -2 ); /* continue looking */ |
return( -2 ); /* continue looking */ |
} |
} |
Debug( LDAP_DEBUG_TRACE, "got %s msgid %ld, original id %d\n", |
Debug( LDAP_DEBUG_TRACE, "got %s msgid %ld, original id %d\n", |
Line 318 read1msg( LDAP *ld, int msgid, int all,
|
Line 314 read1msg( LDAP *ld, int msgid, int all,
|
/* the message type */ |
/* the message type */ |
if ( (tag = ber_peek_tag( &ber, &len )) == LBER_ERROR ) { |
if ( (tag = ber_peek_tag( &ber, &len )) == LBER_ERROR ) { |
ld->ld_errno = LDAP_DECODING_ERROR; |
ld->ld_errno = LDAP_DECODING_ERROR; |
free( ber.ber_buf ); |
|
return( -1 ); |
return( -1 ); |
} |
} |
|
|
Line 375 Debug( LDAP_DEBUG_TRACE,
|
Line 370 Debug( LDAP_DEBUG_TRACE,
|
simple_request = ( hadref ? 0 : 1 ); |
simple_request = ( hadref ? 0 : 1 ); |
} else { |
} else { |
/* request with referrals or child request */ |
/* request with referrals or child request */ |
free( ber.ber_buf ); |
free( ber.ber_buf ); /* gack! */ |
ber.ber_buf = NULL; |
ber.ber_buf = NULL; |
} |
} |
|
|
Line 419 lr->lr_res_matched ? lr->lr_res_matched
|
Line 414 lr->lr_res_matched ? lr->lr_res_matched
|
} |
} |
|
|
if ( ber.ber_buf == NULL ) { |
if ( ber.ber_buf == NULL ) { |
return rc; |
return( rc ); |
} |
} |
|
|
#endif /* LDAP_REFERRALS */ |
#endif /* LDAP_REFERRALS */ |
Line 427 lr->lr_res_matched ? lr->lr_res_matched
|
Line 422 lr->lr_res_matched ? lr->lr_res_matched
|
if ( (new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) )) |
if ( (new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) )) |
== NULL ) { |
== NULL ) { |
ld->ld_errno = LDAP_NO_MEMORY; |
ld->ld_errno = LDAP_NO_MEMORY; |
free( ber.ber_buf ); |
|
return( -1 ); |
return( -1 ); |
} |
} |
new->lm_msgid = (int)id; |
new->lm_msgid = (int)id; |
Line 516 lr->lr_res_matched ? lr->lr_res_matched
|
Line 510 lr->lr_res_matched ? lr->lr_res_matched
|
|
|
|
|
#ifdef LDAP_REFERRALS |
#ifdef LDAP_REFERRALS |
static unsigned long |
static int |
build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr ) |
build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr ) |
{ |
{ |
unsigned long len; |
unsigned long len; |
Line 527 build_result_ber( LDAP *ld, BerElement *
|
Line 521 build_result_ber( LDAP *ld, BerElement *
|
if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid, |
if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid, |
(long)lr->lr_res_msgtype, lr->lr_res_errno, |
(long)lr->lr_res_msgtype, lr->lr_res_errno, |
lr->lr_res_matched ? lr->lr_res_matched : "", |
lr->lr_res_matched ? lr->lr_res_matched : "", |
lr->lr_res_error ? lr->lr_res_error : "" ) == -1 ) { |
lr->lr_res_error ? lr->lr_res_error : "" ) == LBER_ERROR ) { |
return( LBER_ERROR ); |
return( LBER_ERROR ); |
} |
} |
|
|