2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
15 #include <ac/socket.h>
16 #include <ac/string.h>
23 ldap_first_reference( LDAP *ld, LDAPMessage *chain )
25 if ( ld == NULL || chain == NULLMSG ) {
29 return chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE
31 : ldap_next_reference( ld, chain );
36 ldap_next_reference( LDAP *ld, LDAPMessage *ref )
38 if ( ld == NULL || ref == NULLMSG ) {
47 if( ref->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
57 ldap_count_references( LDAP *ld, LDAPMessage *chain )
65 for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
66 if( chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
79 LDAPControl ***serverctrls,
86 if( ld == NULL || ref == NULL ||
87 ref->lm_msgtype != LDAP_RES_SEARCH_REFERENCE )
89 return LDAP_PARAM_ERROR;
92 /* make a private copy of BerElement */
93 SAFEMEMCPY(&be, ref->lm_ber, sizeof(be));
95 if ( ber_scanf( &be, "{v" /*}*/, &refs ) == LBER_ERROR ) {
96 rc = LDAP_DECODING_ERROR;
100 if ( serverctrls == NULL ) {
102 goto free_and_return;
105 if ( ber_scanf( &be, /*{*/ "}" ) == LBER_ERROR ) {
106 rc = LDAP_DECODING_ERROR;
107 goto free_and_return;
110 rc = ldap_int_get_controls( &be, serverctrls );
114 if( referralsp != NULL ) {
115 /* provide references regradless of return code */
119 ldap_value_free( refs );
126 if( rc != LDAP_SUCCESS ) {
129 if( ld->ld_matched != NULL )
130 free( ld->ld_matched );
132 ld->ld_matched = NULL;
134 if( ld->ld_error != NULL )
135 free( ld->ld_error );