Back to index

lightning-sunbird  0.9+nobinonly
Functions
referral.c File Reference
#include "ldap-int.h"

Go to the source code of this file.

Functions

LDAPMessage *LDAP_CALL ldap_first_reference (LDAP *ld, LDAPMessage *res)
LDAPMessage *LDAP_CALL ldap_next_reference (LDAP *ld, LDAPMessage *ref)
int LDAP_CALL ldap_count_references (LDAP *ld, LDAPMessage *res)
int LDAP_CALL ldap_parse_reference (LDAP *ld, LDAPMessage *ref, char ***referralsp, LDAPControl ***serverctrlsp, int freeit)
int nsldapi_parse_reference (LDAP *ld, BerElement *rber, char ***referralsp, LDAPControl ***serverctrlsp)

Function Documentation

int LDAP_CALL ldap_count_references ( LDAP *  ld,
LDAPMessage *  res 
)

Definition at line 80 of file referral.c.

{
       int    i;

       if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
              return( -1 );
       }

       for ( i = 0; res != NULL; res = res->lm_chain ) {
              if ( res->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
                     ++i;
              }
       }

       return( i );
}
LDAPMessage* LDAP_CALL ldap_first_reference ( LDAP *  ld,
LDAPMessage *  res 
)

Definition at line 46 of file referral.c.

{
       if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || res == NULLMSG ) {
              return( NULLMSG );
       }

       if ( res->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
              return( res );
       }

       return( ldap_next_reference( ld, res ));
}

Here is the call graph for this function:

LDAPMessage* LDAP_CALL ldap_next_reference ( LDAP *  ld,
LDAPMessage *  ref 
)

Definition at line 62 of file referral.c.

{
       if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || ref == NULLMSG ) {
              return( NULLMSG );          /* punt */
       }

       for ( ref = ref->lm_chain; ref != NULLMSG; ref = ref->lm_chain ) {
              if ( ref->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
                     return( ref );
              }
       }

       return( NULLMSG );
}

Here is the caller graph for this function:

int LDAP_CALL ldap_parse_reference ( LDAP *  ld,
LDAPMessage *  ref,
char ***  referralsp,
LDAPControl ***  serverctrlsp,
int  freeit 
)

Definition at line 103 of file referral.c.

{
       int           err;

       if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ||
           !NSLDAPI_VALID_LDAPMESSAGE_REFERENCE_POINTER( ref )) {
              return( LDAP_PARAM_ERROR );
       }

       err = nsldapi_parse_reference( ld, ref->lm_ber, referralsp,
              serverctrlsp );

       LDAP_SET_LDERRNO( ld, err, NULL, NULL );

       if ( freeit ) {
              ldap_msgfree( ref );
       }

       return( err );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsldapi_parse_reference ( LDAP *  ld,
BerElement *  rber,
char ***  referralsp,
LDAPControl ***  serverctrlsp 
)

Definition at line 131 of file referral.c.

{
       int           err;
       BerElement    ber;
       char          **refs;

       /*
        * Parse a searchResultReference message.  These are used in LDAPv3
        * and beyond and look like this:
        *
        *     SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LDAPURL
        *
        * all wrapped up in an LDAPMessage sequence which looks like this:
        *
        *     LDAPMessage ::= SEQUENCE {
        *            messageID     MessageID,
        *            SearchResultReference
        *            controls      [0] Controls OPTIONAL
        *     }
        *
        * ldap_result() pulls out the message id, so by the time a result
        * message gets here we are conveniently sitting at the start of the
        * SearchResultReference itself.
        */
       err = LDAP_SUCCESS;  /* optimistic */
       ber = *rber;         /* struct copy */

       if ( ber_scanf( &ber, "{v", &refs ) == LBER_ERROR ) {
           err = LDAP_DECODING_ERROR;
       } else if ( serverctrlsp != NULL ) {
           /* pull out controls (if requested and any are present) */
           if ( ber_scanf( &ber, "}" ) == LBER_ERROR ) {
              err = LDAP_DECODING_ERROR;
           } else {
              err = nsldapi_get_controls( &ber, serverctrlsp );
           }
       }

       if ( referralsp == NULL ) {
           ldap_value_free( refs );
       } else {
           *referralsp = refs;
       }

       return( err );
}

Here is the call graph for this function:

Here is the caller graph for this function: