Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
getoption.c File Reference
#include "ldap-int.h"

Go to the source code of this file.

Defines

#define LDAP_GET_BITOPT(ld, bit)   ((ld)->ld_options & bit ) != 0 ? 1 : 0
#define NSLDAPI_EXTENSIONS_COUNT   (sizeof(nsldapi_extensions)/sizeof(LDAPAPIFeatureInfo))

Functions

static int nsldapi_get_api_info (LDAPAPIInfo *aip)
static int nsldapi_get_feature_info (LDAPAPIFeatureInfo *fip)
int LDAP_CALL ldap_get_option (LDAP *ld, int option, void *optdata)

Variables

static LDAPAPIFeatureInfo nsldapi_extensions []

Define Documentation

#define LDAP_GET_BITOPT (   ld,
  bit 
)    ((ld)->ld_options & bit ) != 0 ? 1 : 0

Definition at line 39 of file getoption.c.

Definition at line 310 of file getoption.c.


Function Documentation

int LDAP_CALL ldap_get_option ( LDAP *  ld,
int  option,
void optdata 
)

Definition at line 48 of file getoption.c.

{
       int           rc = 0;

       if ( !nsldapi_initialized ) {
              nsldapi_initialize_defaults();
       }

    /*
     * optdata MUST be a valid pointer...
     */
    if (NULL == optdata)
    {
        return(LDAP_PARAM_ERROR);
    }
       /*
        * process global options (not associated with an LDAP session handle)
        */
       if ( option == LDAP_OPT_MEMALLOC_FN_PTRS ) {
              /* struct copy */
              *((struct ldap_memalloc_fns *)optdata) = nsldapi_memalloc_fns;
              return( 0 );
       }

       if ( option == LDAP_OPT_API_INFO ) {
              rc = nsldapi_get_api_info( (LDAPAPIInfo *)optdata );
              if ( rc != LDAP_SUCCESS ) {
                     if ( ld != NULL ) {
                            LDAP_SET_LDERRNO( ld, rc, NULL, NULL );
                     }
                     return( -1 );
              }
              return( 0 );
       }
    /* 
     * LDAP_OPT_DEBUG_LEVEL is global 
     */
    if (LDAP_OPT_DEBUG_LEVEL == option) 
    {
#ifdef LDAP_DEBUG      
        *((int *) optdata) = ldap_debug;
#endif /* LDAP_DEBUG */
        return ( 0 );
    }

       /*
        * if ld is NULL, arrange to return options from our default settings
        */
       if ( ld == NULL ) {
              ld = &nsldapi_ld_defaults;
       }

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


       if (ld != &nsldapi_ld_defaults)
              LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK );
       switch( option ) {
#ifdef LDAP_DNS
       case LDAP_OPT_DNS:
              *((int *) optdata) = LDAP_GET_BITOPT( ld, LDAP_BITOPT_DNS );
              break;
#endif

       case LDAP_OPT_REFERRALS:
              *((int *) optdata) =
                  LDAP_GET_BITOPT( ld, LDAP_BITOPT_REFERRALS );
              break;

       case LDAP_OPT_SSL:
              *((int *) optdata) = LDAP_GET_BITOPT( ld, LDAP_BITOPT_SSL );
              break;

       case LDAP_OPT_RESTART:
              *((int *) optdata) = LDAP_GET_BITOPT( ld, LDAP_BITOPT_RESTART );
              break;

       case LDAP_OPT_RECONNECT:
              *((int *) optdata) =
                  LDAP_GET_BITOPT( ld, LDAP_BITOPT_RECONNECT );
              break;

#ifdef LDAP_ASYNC_IO
       case LDAP_OPT_ASYNC_CONNECT:
              *((int *) optdata) =
                  LDAP_GET_BITOPT( ld, LDAP_BITOPT_ASYNC );
              break;
#endif /* LDAP_ASYNC_IO */

       /* stuff in the sockbuf */
       case LDAP_OPT_DESC:
              if ( ber_sockbuf_get_option( ld->ld_sbp,
                  LBER_SOCKBUF_OPT_DESC, optdata ) != 0 ) {
                     LDAP_SET_LDERRNO( ld, LDAP_LOCAL_ERROR, NULL, NULL );
                     rc = -1;
              }
              break;

       /* fields in the LDAP structure */
       case LDAP_OPT_DEREF:
              *((int *) optdata) = ld->ld_deref;
              break;
       case LDAP_OPT_SIZELIMIT:
              *((int *) optdata) = ld->ld_sizelimit;
                break;  
       case LDAP_OPT_TIMELIMIT:
              *((int *) optdata) = ld->ld_timelimit;
                break;
       case LDAP_OPT_REFERRAL_HOP_LIMIT:
               *((int *) optdata) = ld->ld_refhoplimit;
              break;
       case LDAP_OPT_PROTOCOL_VERSION:
               *((int *) optdata) = ld->ld_version;
              break;
       case LDAP_OPT_SERVER_CONTROLS:
              /* fall through */
       case LDAP_OPT_CLIENT_CONTROLS:
              *((LDAPControl ***)optdata) = NULL;
              /* nsldapi_dup_controls returns -1 and sets lderrno on error */
              rc = nsldapi_dup_controls( ld, (LDAPControl ***)optdata,
                  ( option == LDAP_OPT_SERVER_CONTROLS ) ?
                  ld->ld_servercontrols : ld->ld_clientcontrols );
              break;

       /* rebind proc */
       case LDAP_OPT_REBIND_FN:
              *((LDAP_REBINDPROC_CALLBACK **) optdata) = ld->ld_rebind_fn;
              break;
       case LDAP_OPT_REBIND_ARG:
              *((void **) optdata) = ld->ld_rebind_arg;
              break;

       /* i/o function pointers */
       case LDAP_OPT_IO_FN_PTRS:
              if ( ld->ld_io_fns_ptr == NULL ) {
                     memset( optdata, 0, sizeof( struct ldap_io_fns ));
              } else {
                     /* struct copy */
                     *((struct ldap_io_fns *)optdata) = *(ld->ld_io_fns_ptr);
              }
              break;

       /* extended i/o function pointers */
       case LDAP_X_OPT_EXTIO_FN_PTRS:
         if ( ((struct ldap_x_ext_io_fns *) optdata)->lextiof_size == LDAP_X_EXTIO_FNS_SIZE_REV0) {
           ((struct ldap_x_ext_io_fns_rev0 *) optdata)->lextiof_close = ld->ld_extclose_fn;
           ((struct ldap_x_ext_io_fns_rev0 *) optdata)->lextiof_connect = ld->ld_extconnect_fn;
           ((struct ldap_x_ext_io_fns_rev0 *) optdata)->lextiof_read = ld->ld_extread_fn;
           ((struct ldap_x_ext_io_fns_rev0 *) optdata)->lextiof_write = ld->ld_extwrite_fn;
           ((struct ldap_x_ext_io_fns_rev0 *) optdata)->lextiof_poll = ld->ld_extpoll_fn;
           ((struct ldap_x_ext_io_fns_rev0 *) optdata)->lextiof_newhandle = ld->ld_extnewhandle_fn;
           ((struct ldap_x_ext_io_fns_rev0 *) optdata)->lextiof_disposehandle = ld->ld_extdisposehandle_fn;
           ((struct ldap_x_ext_io_fns_rev0 *) optdata)->lextiof_session_arg = ld->ld_ext_session_arg;
         } else if ( ((struct ldap_x_ext_io_fns *) optdata)->lextiof_size ==
                    LDAP_X_EXTIO_FNS_SIZE ) {
           /* struct copy */
           *((struct ldap_x_ext_io_fns *) optdata) = ld->ld_ext_io_fns;
         } else {       
           LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL );
           rc = -1;
         }
         break;

       /* thread function pointers */
       case LDAP_OPT_THREAD_FN_PTRS:
              /* struct copy */
              *((struct ldap_thread_fns *) optdata) = ld->ld_thread;
              break;

       /* DNS function pointers */
       case LDAP_OPT_DNS_FN_PTRS:
              /* struct copy */
              *((struct ldap_dns_fns *) optdata) = ld->ld_dnsfn;
              break;

       /* cache function pointers */
       case LDAP_OPT_CACHE_FN_PTRS:
              /* struct copy */
              *((struct ldap_cache_fns *) optdata) = ld->ld_cache;
              break;
       case LDAP_OPT_CACHE_STRATEGY:
              *((int *) optdata) = ld->ld_cache_strategy;
              break;
       case LDAP_OPT_CACHE_ENABLE:
              *((int *) optdata) = ld->ld_cache_on;
              break;

       case LDAP_OPT_ERROR_NUMBER:
              *((int *) optdata) = LDAP_GET_LDERRNO( ld, NULL, NULL );
              break;

       case LDAP_OPT_ERROR_STRING:
              (void)LDAP_GET_LDERRNO( ld, NULL, (char **)optdata );
              *((char **) optdata) = nsldapi_strdup( *((char **) optdata ));
              break;

       case LDAP_OPT_MATCHED_DN:
              (void)LDAP_GET_LDERRNO( ld, (char **)optdata, NULL );
              *((char **) optdata) = nsldapi_strdup( *((char **) optdata ));
              break;

       case LDAP_OPT_PREFERRED_LANGUAGE:
              if ( NULL != ld->ld_preferred_language ) {
                     *((char **) optdata) =
                         nsldapi_strdup(ld->ld_preferred_language);
              } else {
                     *((char **) optdata) = NULL;
              }
              break;

       case LDAP_OPT_API_FEATURE_INFO:
              rc = nsldapi_get_feature_info( (LDAPAPIFeatureInfo *)optdata );
              if ( rc != LDAP_SUCCESS ) {
                     LDAP_SET_LDERRNO( ld, rc, NULL, NULL );
                     rc = -1;
              }
              break;

       case LDAP_OPT_HOST_NAME:
              *((char **) optdata) = nsldapi_strdup( ld->ld_defhost );
              break;

        case LDAP_X_OPT_CONNECT_TIMEOUT:
                *((int *) optdata) = ld->ld_connect_timeout;
                break;

       default:
              LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL );
              rc = -1;
       }
       if (ld != &nsldapi_ld_defaults)
              LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK  );
       return( rc );
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int nsldapi_get_api_info ( LDAPAPIInfo aip) [static]

Definition at line 318 of file getoption.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static int nsldapi_get_feature_info ( LDAPAPIFeatureInfo fip) [static]

Definition at line 372 of file getoption.c.

{
       int    i;

       if ( fip == NULL || fip->ldapaif_name == NULL ) {
              return( LDAP_PARAM_ERROR );
       }

       if ( fip->ldapaif_info_version != LDAP_FEATURE_INFO_VERSION ) {
              fip->ldapaif_info_version = LDAP_FEATURE_INFO_VERSION;
              return( LDAP_PARAM_ERROR );
       }

       for ( i = 0; i < NSLDAPI_EXTENSIONS_COUNT; ++i ) {
              if ( strcmp( fip->ldapaif_name,
                  nsldapi_extensions[i].ldapaif_name ) == 0 ) {
                     fip->ldapaif_version =
                         nsldapi_extensions[i].ldapaif_version;
                     break;
              }
       }

       return(( i < NSLDAPI_EXTENSIONS_COUNT ) ? LDAP_SUCCESS
           : LDAP_PARAM_ERROR );
}

Here is the caller graph for this function:


Variable Documentation

Initial value:
 {
    { 0, "SERVER_SIDE_SORT",              LDAP_API_FEATURE_SERVER_SIDE_SORT },
    { 0, "VIRTUAL_LIST_VIEW",             LDAP_API_FEATURE_VIRTUAL_LIST_VIEW },
    { 0, "PERSISTENT_SEARCH",             LDAP_API_FEATURE_PERSISTENT_SEARCH },
    { 0, "PROXY_AUTHORIZATION",           LDAP_API_FEATURE_PROXY_AUTHORIZATION },
    { 0, "X_LDERRNO",                     LDAP_API_FEATURE_X_LDERRNO },
    { 0, "X_MEMCACHE",                    LDAP_API_FEATURE_X_MEMCACHE },
    { 0, "X_IO_FUNCTIONS",         LDAP_API_FEATURE_X_IO_FUNCTIONS },
    { 0, "X_EXTIO_FUNCTIONS",             LDAP_API_FEATURE_X_EXTIO_FUNCTIONS },
    { 0, "X_DNS_FUNCTIONS",        LDAP_API_FEATURE_X_DNS_FUNCTIONS },
    { 0, "X_MEMALLOC_FUNCTIONS",   LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS },
    { 0, "X_THREAD_FUNCTIONS",            LDAP_API_FEATURE_X_THREAD_FUNCTIONS },
    { 0, "X_EXTHREAD_FUNCTIONS",   LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS },
    { 0, "X_GETLANGVALUES",        LDAP_API_FEATURE_X_GETLANGVALUES },
    { 0, "X_CLIENT_SIDE_SORT",            LDAP_API_FEATURE_X_CLIENT_SIDE_SORT },
    { 0, "X_URL_FUNCTIONS",        LDAP_API_FEATURE_X_URL_FUNCTIONS },
    { 0, "X_FILTER_FUNCTIONS",            LDAP_API_FEATURE_X_FILTER_FUNCTIONS },
}

Definition at line 291 of file getoption.c.