/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef _LDAPINT_H
#define _LDAPINT_H
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#ifdef hpux
#include <strings.h>
#endif /* hpux */
#ifdef _WINDOWS
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#include "ldap-macos.h"
#include <os2sock.h>
#else /* _WINDOWS */
# include <netdb.h>
#endif /* !defined(hpux) and others */
#endif /* _WINDOWS */
#if defined(IRIX)
#include <bstring.h>
#endif /* IRIX */
#define NSLBERI_LBER_INT_FRIEND
#ifdef macintosh
#include "lber-int.h"
#elif defined(_SOLARIS_SDK)
#include "../ber/lber-int.h"
#else /* _SOLARIS_SDK */
#include "../liblber/lber-int.h"
#endif /* macintosh */
#include "ldap.h"
#include "ldaprot.h"
#include "ldaplog.h"
#include "portable.h"
#include "regex.h"
#ifdef LDAP_ASYNC_IO
#ifdef NEED_FILIO
#else /* NEED_FILIO */
#endif /* _WINDOWS && macintosh */
#endif /* NEED_FILIO */
#endif /* LDAP_ASYNC_IO */
#ifdef USE_SYSCONF
# include <unistd.h>
#endif /* USE_SYSCONF */
#ifdef _SOLARIS_SDK
#include <libintl.h>
#endif
#ifdef LDAP_SASLIO_HOOKS
#endif
#endif
/* SSL version, or 0 if not built with SSL */
#if defined(NET_SSL)
#else
# define SSL_VERSION 0
#endif
/* default limit on nesting of referrals */
#ifdef LDAP_DNS
#endif /* LDAP_DNS */
typedef enum {
#ifdef LDAP_SASLIO_HOOKS
#endif
} LDAPLock;
/*
* This structure represents both ldap messages and ldap responses.
* These are really the same, except in the case of search responses,
* where a response has multiple messages.
*/
struct ldapmsg {
};
/*
* structure for tracking LDAP server host, ports, DNs, etc.
*/
typedef struct ldap_server {
char *lsrv_host;
int lsrv_port;
} LDAPServer;
/*
* structure for representing an LDAP server connection
*/
typedef struct ldap_conn {
int lconn_refcnt;
int lconn_status;
char *lconn_krbinstance;
} LDAPConn;
/*
* structure used to track outstanding requests
*/
typedef struct ldapreq {
} LDAPRequest;
typedef struct ldappend {
} LDAPPend;
/*
* forward declaration for I/O status structure (defined in os-ip.c)
*/
/*
* old extended IO structure (before writev callback was added)
*/
struct ldap_x_ext_io_fns_rev0 {
int lextiof_size;
void *lextiof_session_arg;
};
/*
* structure representing an ldap connection
*/
struct ldap {
char *ld_host;
char ld_lberoptions;
int ld_deref;
int ld_timelimit;
int ld_sizelimit;
int ld_errno;
char *ld_error;
char *ld_matched;
int ld_msgid;
/* do not mess with these */
/* it is OK to change these next four values directly */
/* do not mess with the rest though */
void *ld_rebind_arg;
/* function pointers, etc. for extended I/O */
/* allocated pointer for older I/O functions */
/* function pointers, etc. for DNS */
/* function pointers, etc. for threading */
void **ld_mutex;
/* function pointers, etc. for caching */
int ld_cache_on;
int ld_cache_strategy;
#if 0
#endif
/* ldapv3 controls */
/* Preferred language */
char *ld_preferred_language;
/* MemCache */
/* Pending results */
/* extra thread function pointers */
/* With the 4.0 version of the LDAP SDK */
/* the extra thread functions except for */
/* the ld_threadid_fn has been disabled */
/* Look at the release notes for the full */
/* explanation */
/* extra data for mutex handling in referrals */
/* connect timeout value (milliseconds) */
int ld_connect_timeout;
#ifdef LDAP_SASLIO_HOOKS
/* SASL default option settings */
char *ld_def_sasl_mech;
char *ld_def_sasl_realm;
char *ld_def_sasl_authcid;
char *ld_def_sasl_authzid;
/* SASL Security properties */
/* prldap shadow io functions */
#endif
};
(ld)->ld_mutex_free_fn( m ); \
}
/*
* The locks assume that the locks are thread safe. XXXmcs: which means???
*
* Note that we test for both ld_mutex_lock_fn != NULL AND ld_mutex != NULL.
* This is necessary because there is a window in ldap_init() between the
* time we set the ld_mutex_lock_fn pointer and the time we allocate the
* mutexes in which external code COULD be called which COULD make a call to
* something like ldap_get_option(), which uses LDAP_MUTEX_LOCK(). The
* libprldap code does this in its newhandle callback (prldap_newhandle).
*/
} else { \
} \
} else { \
} \
}
} \
} \
} else { \
} \
}
/* Backward compatibility locks */
/* the ld_mutex_trylock_fn is always set to NULL */ \
/* in setoption.c as the extra thread functions were */ \
/* turned off in the 4.0 SDK. This check will */ \
/* always be true */ \
LDAP_MUTEX_LOCK( ld, i ) ; \
}
/* the ld_mutex_trylock_fn is always set to NULL */ \
/* in setoption.c as the extra thread functions were */ \
/* turned off in the 4.0 SDK. This check will */ \
/* always be true */ \
LDAP_MUTEX_UNLOCK( ld, i ) ; \
}
(ld)->ld_sema_free_fn( m ); \
}
}
}
/* the ld_mutex_trylock_fn is always set to NULL */ \
/* in setoption.c as the extra thread functions were */ \
/* turned off in the 4.0 SDK. This check will */ \
/* always be false */ \
nsldapi_post_result( ld, y, z ); \
}
#ifndef macintosh
(ld)->ld_set_errno_fn( e ); \
} else { \
errno = e; \
}
#else /* macintosh */
(ld)->ld_set_errno_fn( e ); \
}
(ld)->ld_get_errno_fn() : 0)
#endif
/*
* your standard "mimimum of two values" macro
*/
#define NSLDAPI_MIN(a, b) (((a) < (b)) ? (a) : (b))
/*
* handy macro to check whether LDAP struct is set up for CLDAP or not
*/
/*
* handy macro to check errno "e" for an "in progress" sort of error
*/
#else
#ifdef EAGAIN
#define NSLDAPI_ERRNO_IO_INPROGRESS( e ) ((e) == EWOULDBLOCK || (e) == EINPROGRESS || (e) == EAGAIN)
#else /* EAGAIN */
#endif /* EAGAIN */
#endif /* macintosh || _WINDOWS*/
/*
* macro to return the LDAP protocol version we are using
*/
(ld)->ld_version : \
/*
* Structures used for handling client filter lists.
*/
struct ldap_filt_list {
char *lfl_tag;
char *lfl_pattern;
char *lfl_delims;
};
struct ldap_filt_desc {
char *lfd_curval;
char *lfd_curvalcopy;
char **lfd_curvalwords;
char *lfd_filtprefix;
char *lfd_filtsuffix;
};
/*
* "internal" globals used to track defaults and memory allocation callbacks:
* (the actual definitions are in open.c)
*/
extern struct ldap nsldapi_ld_defaults;
extern struct ldap_memalloc_fns nsldapi_memalloc_fns;
extern int nsldapi_initialized;
/*
* Memory allocation done in liblber should all go through one of the
* following macros. This is so we can plug-in alternative memory
* allocators, etc. as the need arises.
*/
/*
* macros used to check validity of data structures and parameters
*/
((code) == LDAP_RES_SEARCH_ENTRY)
((code) == LDAP_RES_SEARCH_RESULT)
/*
* in bind.c
*/
/*
* in cache.c
*/
/*
* in dsparse.c
*/
void ldap_free_strarray( char **sap );
/*
* in error.c
*/
LDAPControl ***serverctrlsp );
/*
* in open.c
*/
void nsldapi_initialize_defaults( void );
char *nsldapi_strdup( const char *s ); /* if s is NULL, returns NULL */
/*
* in os-ip.c
*/
/*
* if referral.c
*/
LDAPControl ***serverctrlsp );
/*
* in result.c
*/
LDAPMessage **result );
/*
* in request.c
*/
int async );
int *totalcountp, int *chasingcountp );
/*
* in search.c
*/
/*
* in unbind.c
*/
LDAPControl **clientctrls );
#ifdef LDAP_DNS
/*
* in getdxbyname.c
*/
char **nsldapi_getdxbyname( char *domain );
#endif /* LDAP_DNS */
/*
* in unescape.c
*/
void nsldapi_hex_unescape( char *s );
/*
* in reslist.c
*/
/*
* in compat.c
*/
#ifdef hpux
#endif /* hpux */
/*
* in control.c
*/
BerElement *ber );
LDAPControl **newctrls );
/*
* in url.c
*/
int dn_required );
/*
*/
void ber_err_print( char *data );
#ifdef _SOLARIS_SDK
/*
* in ../prldap/ldappr-dns.c
*/
/*
* in ../prldap/ldappr-threads.c
*/
void prldap_nspr_init(void);
#endif
/*
* in ../prldap/ldappr-public.c
*/
int
int
int
#ifndef _SOLARIS_SDK
/*
* in charset.c
*
* If we ever want to expose character set translation functionality to
* users of libldap, all of these prototypes will need to be moved to ldap.h
*
* These are moved to ldap.h in the Solaris version of the library
*
*/
#ifdef STR_TRANSLATION
unsigned long *lenp, int free_input );
unsigned long *lenp, int free_input );
int enable );
#ifdef LDAP_CHARSET_8859
int free_input );
int free_input );
#endif /* LDAP_CHARSET_8859 */
#endif /* STR_TRANSLATION */
#endif /* _SOLARIS_SDK */
/*
* in memcache.h
*/
unsigned long *keyp );
const char *basedn );
#endif /* _LDAPINT_H */