1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * The contents of this file are subject to the Netscape Public License
4 * Version 1.0 (the "NPL"); you may not use this file except in
5 * compliance with the NPL. You may obtain a copy of the NPL at
6 * http://www.mozilla.org/NPL/
8 * Software distributed under the NPL is distributed on an "AS IS" basis,
9 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
10 * for the specific language governing rights and limitations under the
13 * The Initial Developer of this code under the NPL is Netscape
14 * Communications Corporation. Portions created by Netscape are
15 * Copyright (C) 1998 Netscape Communications Corporation. All Rights
32 # define FD_SETSIZE 256 /* number of connections we support */
34 # define WIN32_LEAN_AND_MEAN
37 #elif defined(macintosh)
38 #include "ldap-macos.h"
43 # include <sys/time.h>
44 # include <sys/types.h>
45 # include <sys/socket.h>
46 # include <netinet/in.h>
48 #if !defined(hpux) && !defined(SUNOS4) && !defined(LINUX1_2) && !defined(LINUX2_0)
49 # include <sys/select.h>
50 #endif /* !defined(hpux) and others */
53 #if defined(BSDI) || defined(LINUX1_2) || defined(SNI) || defined(IRIX)
54 #include <arpa/inet.h>
69 #include <sys/filio.h> /* to get FIONBIO for ioctl() call */
70 #else /* NEED_FILIO */
71 #include <sys/ioctl.h> /* to get FIONBIO for ioctl() call */
72 #endif /* NEED_FILIO */
73 #endif /* LDAP_ASYNC_IO */
77 #endif /* USE_SYSCONF */
79 #if !defined(_WINDOWS) && !defined(macintosh) && !defined(LINUX2_0)
80 #define NSLDAPI_HAVE_POLL 1
83 /* SSL version, or 0 if not built with SSL */
85 # define SSL_VERSION 3
87 # define SSL_VERSION 0
90 #define LDAP_URL_URLCOLON "URL:"
91 #define LDAP_URL_URLCOLON_LEN 4
93 #define LDAP_LDAP_REF_STR LDAP_URL_PREFIX
94 #define LDAP_LDAP_REF_STR_LEN LDAP_URL_PREFIX_LEN
95 #define LDAP_LDAPS_REF_STR LDAPS_URL_PREFIX
96 #define LDAP_LDAPS_REF_STR_LEN LDAPS_URL_PREFIX_LEN
98 /* default limit on nesting of referrals */
99 #define LDAP_DEFAULT_REFHOPLIMIT 5
101 #define LDAP_DX_REF_STR "dx://"
102 #define LDAP_DX_REF_STR_LEN 5
103 #endif /* LDAP_DNS */
105 typedef enum { LDAP_CACHE_LOCK, LDAP_MEMCACHE_LOCK, LDAP_MSGID_LOCK,
106 LDAP_REQ_LOCK, LDAP_RESP_LOCK, LDAP_ABANDON_LOCK, LDAP_CTRL_LOCK,
107 LDAP_OPTION_LOCK, LDAP_ERR_LOCK, LDAP_CONN_LOCK, LDAP_SELECT_LOCK,
108 LDAP_RESULT_LOCK, LDAP_PEND_LOCK, LDAP_MAX_LOCK } LDAPLock;
111 * This structure represents both ldap messages and ldap responses.
112 * These are really the same, except in the case of search responses,
113 * where a response has multiple messages.
117 int lm_msgid; /* the message id */
118 int lm_msgtype; /* the message type */
119 BerElement *lm_ber; /* the ber encoded message contents */
120 struct ldapmsg *lm_chain; /* for search - next msg in the resp */
121 struct ldapmsg *lm_next; /* next response */
122 int lm_fromcache; /* memcache: origin of message */
126 * structure for tracking LDAP server host, ports, DNs, etc.
128 typedef struct ldap_server {
130 char *lsrv_dn; /* if NULL, use default */
132 unsigned long lsrv_options; /* boolean options */
133 #define LDAP_SRV_OPT_SECURE 0x01
134 struct ldap_server *lsrv_next;
138 * structure for representing an LDAP server connection
140 typedef struct ldap_conn {
142 BerElement *lconn_ber; /* non-NULL if in midst of msg. */
143 int lconn_version; /* LDAP protocol version */
145 unsigned long lconn_lastused; /* time */
147 #define LDAP_CONNST_NEEDSOCKET 1
148 #define LDAP_CONNST_CONNECTING 2
149 #define LDAP_CONNST_CONNECTED 3
150 #define LDAP_CONNST_DEAD 4
151 LDAPServer *lconn_server;
152 char *lconn_binddn; /* DN of last successful bind */
153 int lconn_bound; /* has a bind been done? */
154 char *lconn_krbinstance;
155 struct ldap_conn *lconn_next;
160 * structure used to track outstanding requests
162 typedef struct ldapreq {
163 int lr_msgid; /* the message id */
164 int lr_status; /* status of request */
165 #define LDAP_REQST_INPROGRESS 1
166 #define LDAP_REQST_CHASINGREFS 2
167 #define LDAP_REQST_NOTCONNECTED 3
168 #define LDAP_REQST_WRITING 4
169 #define LDAP_REQST_CONNDEAD 5 /* associated conn. has failed */
170 int lr_outrefcnt; /* count of outstanding referrals */
171 int lr_origid; /* original request's message id */
172 int lr_parentcnt; /* count of parent requests */
173 int lr_res_msgtype; /* result message type */
174 int lr_res_errno; /* result LDAP errno */
175 char *lr_res_error; /* result error string */
176 char *lr_res_matched;/* result matched DN string */
177 BerElement *lr_ber; /* ber encoded request contents */
178 LDAPConn *lr_conn; /* connection used to send request */
179 char *lr_binddn; /* request is a bind for this DN */
180 struct ldapreq *lr_parent; /* request that spawned this referral */
181 struct ldapreq *lr_refnext; /* next referral spawned */
182 struct ldapreq *lr_prev; /* previous request */
183 struct ldapreq *lr_next; /* next request */
186 typedef struct ldappend {
187 void *lp_sema; /* semaphore to post */
188 int lp_msgid; /* message id */
189 LDAPMessage *lp_result; /* result storage */
190 struct ldappend *lp_prev; /* previous pending */
191 struct ldappend *lp_next; /* next pending */
195 * structure representing an ldap connection
198 struct sockbuf *ld_sbp; /* pointer to socket desc. & buffer */
200 int ld_version; /* LDAP protocol version */
207 struct ldap_filt_desc *ld_filtd; /* from getfilter for ufn searches */
208 char *ld_ufnprefix; /* for incomplete ufn's */
215 /* do not mess with these */
216 LDAPRequest *ld_requests; /* list of outstanding requests */
217 LDAPMessage *ld_responses; /* list of outstanding responses */
218 int *ld_abandoned; /* array of abandoned requests */
219 char *ld_cldapdn; /* DN used in connectionless search */
221 /* it is OK to change these next four values directly */
222 int ld_cldaptries; /* connectionless search retry count */
223 int ld_cldaptimeout;/* time between retries */
224 int ld_refhoplimit; /* limit on referral nesting */
225 unsigned long ld_options; /* boolean options */
226 #define LDAP_BITOPT_REFERRALS 0x80000000
227 #define LDAP_BITOPT_SSL 0x40000000
228 #define LDAP_BITOPT_DNS 0x20000000
229 #define LDAP_BITOPT_RESTART 0x10000000
230 #define LDAP_BITOPT_RECONNECT 0x08000000
231 #define LDAP_BITOPT_ASYNC 0x04000000
233 /* do not mess with the rest though */
234 char *ld_defhost; /* full name of default server */
235 int ld_defport; /* port of default server */
236 BERTranslateProc ld_lber_encode_translate_proc;
237 BERTranslateProc ld_lber_decode_translate_proc;
238 LDAPConn *ld_defconn; /* default connection */
239 LDAPConn *ld_conns; /* list of all server connections */
240 void *ld_selectinfo; /* platform specifics for select */
241 int ld_selectreadcnt; /* count of read sockets */
242 int ld_selectwritecnt; /* count of write sockets */
243 LDAP_REBINDPROC_CALLBACK *ld_rebind_fn;
246 /* function pointers, etc. for io */
247 struct ldap_io_fns ld_io;
248 #define ld_read_fn ld_io.liof_read
249 #define ld_write_fn ld_io.liof_write
250 #define ld_select_fn ld_io.liof_select
251 #define ld_socket_fn ld_io.liof_socket
252 #define ld_ioctl_fn ld_io.liof_ioctl
253 #define ld_connect_fn ld_io.liof_connect
254 #define ld_close_fn ld_io.liof_close
255 #define ld_ssl_enable_fn ld_io.liof_ssl_enable
257 /* function pointers, etc. for DNS */
258 struct ldap_dns_fns ld_dnsfn;
259 #define ld_dns_extradata ld_dnsfn.lddnsfn_extradata
260 #define ld_dns_bufsize ld_dnsfn.lddnsfn_bufsize
261 #define ld_dns_gethostbyname_fn ld_dnsfn.lddnsfn_gethostbyname
262 #define ld_dns_gethostbyaddr_fn ld_dnsfn.lddnsfn_gethostbyaddr
264 /* function pointers, etc. for threading */
265 struct ldap_thread_fns ld_thread;
266 #define ld_mutex_alloc_fn ld_thread.ltf_mutex_alloc
267 #define ld_mutex_free_fn ld_thread.ltf_mutex_free
268 #define ld_mutex_lock_fn ld_thread.ltf_mutex_lock
269 #define ld_mutex_unlock_fn ld_thread.ltf_mutex_unlock
270 #define ld_get_errno_fn ld_thread.ltf_get_errno
271 #define ld_set_errno_fn ld_thread.ltf_set_errno
272 #define ld_get_lderrno_fn ld_thread.ltf_get_lderrno
273 #define ld_set_lderrno_fn ld_thread.ltf_set_lderrno
274 #define ld_lderrno_arg ld_thread.ltf_lderrno_arg
277 /* function pointers, etc. for caching */
279 int ld_cache_strategy;
280 struct ldap_cache_fns ld_cache;
281 #define ld_cache_config ld_cache.lcf_config
282 #define ld_cache_bind ld_cache.lcf_bind
283 #define ld_cache_unbind ld_cache.lcf_unbind
284 #define ld_cache_search ld_cache.lcf_search
285 #define ld_cache_compare ld_cache.lcf_compare
286 #define ld_cache_add ld_cache.lcf_add
287 #define ld_cache_delete ld_cache.lcf_delete
289 #define ld_cache_rename ld_cache.lcf_rename
291 #define ld_cache_modify ld_cache.lcf_modify
292 #define ld_cache_modrdn ld_cache.lcf_modrdn
293 #define ld_cache_abandon ld_cache.lcf_abandon
294 #define ld_cache_result ld_cache.lcf_result
295 #define ld_cache_flush ld_cache.lcf_flush
296 #define ld_cache_arg ld_cache.lcf_arg
298 /* ldapv3 controls */
299 LDAPControl **ld_servercontrols;
300 LDAPControl **ld_clientcontrols;
302 /* Preferred language */
303 char *ld_preferred_language;
306 LDAPMemCache *ld_memcache;
308 /* Pending results */
309 LDAPPend *ld_pend; /* list of pending results */
311 /* extra thread function pointers */
312 struct ldap_extra_thread_fns ld_thread2;
313 #define ld_mutex_trylock_fn ld_thread2.ltf_mutex_trylock
314 #define ld_sema_alloc_fn ld_thread2.ltf_sema_alloc
315 #define ld_sema_free_fn ld_thread2.ltf_sema_free
316 #define ld_sema_wait_fn ld_thread2.ltf_sema_wait
317 #define ld_sema_post_fn ld_thread2.ltf_sema_post
320 /* allocate/free mutex */
321 #define LDAP_MUTEX_ALLOC( ld ) \
322 (((ld)->ld_mutex_alloc_fn != NULL) ? (ld)->ld_mutex_alloc_fn() : NULL)
324 /* allocate/free mutex */
325 #define LDAP_MUTEX_FREE( ld, m ) \
326 if ( (ld)->ld_mutex_free_fn != NULL && m != NULL ) { \
327 (ld)->ld_mutex_free_fn( m ); \
330 /* enter/exit critical sections */
331 #define LDAP_MUTEX_TRYLOCK( ld, i ) \
332 ( (ld)->ld_mutex_trylock_fn == NULL ) ? 0 : \
333 (ld)->ld_mutex_trylock_fn( (ld)->ld_mutex[i] )
334 #define LDAP_MUTEX_LOCK( ld, i ) \
335 if ( (ld)->ld_mutex_lock_fn != NULL ) { \
336 (ld)->ld_mutex_lock_fn( (ld)->ld_mutex[i] ); \
338 #define LDAP_MUTEX_UNLOCK( ld, i ) \
339 if ( (ld)->ld_mutex_unlock_fn != NULL ) { \
340 (ld)->ld_mutex_unlock_fn( (ld)->ld_mutex[i] ); \
343 /* Backword compatibility locks */
344 #define LDAP_MUTEX_BC_LOCK( ld, i ) \
345 if( (ld)->ld_mutex_trylock_fn == NULL ) { \
346 if ( (ld)->ld_mutex_lock_fn != NULL ) { \
347 (ld)->ld_mutex_lock_fn( (ld)->ld_mutex[i] ); \
350 #define LDAP_MUTEX_BC_UNLOCK( ld, i ) \
351 if( (ld)->ld_mutex_trylock_fn == NULL ) { \
352 if ( (ld)->ld_mutex_unlock_fn != NULL ) { \
353 (ld)->ld_mutex_unlock_fn( (ld)->ld_mutex[i] ); \
357 /* allocate/free semaphore */
358 #define LDAP_SEMA_ALLOC( ld ) \
359 (((ld)->ld_sema_alloc_fn != NULL) ? (ld)->ld_sema_alloc_fn() : NULL)
360 #define LDAP_SEMA_FREE( ld, m ) \
361 if ( (ld)->ld_sema_free_fn != NULL && m != NULL ) { \
362 (ld)->ld_sema_free_fn( m ); \
365 /* wait/post binary semaphore */
366 #define LDAP_SEMA_WAIT( ld, lp ) \
367 if ( (ld)->ld_sema_wait_fn != NULL ) { \
368 (ld)->ld_sema_wait_fn( lp->lp_sema ); \
370 #define LDAP_SEMA_POST( ld, lp ) \
371 if ( (ld)->ld_sema_post_fn != NULL ) { \
372 (ld)->ld_sema_post_fn( lp->lp_sema ); \
374 #define POST( ld, y, z ) \
375 if( (ld)->ld_mutex_trylock_fn != NULL ) { \
376 nsldapi_post_result( ld, y, z ); \
381 #define LDAP_SET_ERRNO( ld, e ) \
382 if ( (ld)->ld_set_errno_fn != NULL ) { \
383 (ld)->ld_set_errno_fn( e ); \
387 #define LDAP_GET_ERRNO( ld ) \
388 (((ld)->ld_get_errno_fn != NULL) ? \
389 (ld)->ld_get_errno_fn() : errno)
390 #else /* macintosh */
391 #define LDAP_SET_ERRNO( ld, e ) \
392 if ( (ld)->ld_set_errno_fn != NULL ) { \
393 (ld)->ld_set_errno_fn( e ); \
395 #define LDAP_GET_ERRNO( ld ) \
396 (((ld)->ld_get_errno_fn != NULL) ? \
397 (ld)->ld_get_errno_fn() : 0)
401 /* get/set ldap-specific errno */
402 #define LDAP_SET_LDERRNO( ld, e, m, s ) ldap_set_lderrno( ld, e, m, s )
403 #define LDAP_GET_LDERRNO( ld, m, s ) ldap_get_lderrno( ld, m, s )
406 * your standard "mimimum of two values" macro
408 #define NSLDAPI_MIN(a, b) (((a) < (b)) ? (a) : (b))
411 * handy macro to check whether LDAP struct is set up for CLDAP or not
413 #define LDAP_IS_CLDAP( ld ) ( ld->ld_sbp->sb_naddr > 0 )
416 * handy macro to check errno "e" for an "in progress" sort of error
418 #if defined(macintosh) || defined(_WINDOWS)
419 #define NSLDAPI_ERRNO_IO_INPROGRESS( e ) ((e) == EWOULDBLOCK || (e) == EAGAIN)
422 #define NSLDAPI_ERRNO_IO_INPROGRESS( e ) ((e) == EWOULDBLOCK || (e) == EINPROGRESS || (e) == EAGAIN)
424 #define NSLDAPI_ERRNO_IO_INPROGRESS( e ) ((e) == EWOULDBLOCK || (e) == EINPROGRESS)
426 #endif /* macintosh || _WINDOWS*/
429 * macro to return the LDAP protocol version we are using
431 #define NSLDAPI_LDAP_VERSION( ld ) ( (ld)->ld_defconn == NULL ? \
433 (ld)->ld_defconn->lconn_version )
436 * Structures used for handling client filter lists.
438 #define LDAP_FILT_MAXSIZ 1024
440 struct ldap_filt_list {
444 struct ldap_filt_info *lfl_ilist;
445 struct ldap_filt_list *lfl_next;
448 struct ldap_filt_desc {
449 LDAPFiltList *lfd_filtlist;
450 LDAPFiltInfo *lfd_curfip;
451 LDAPFiltInfo lfd_retfi;
452 char lfd_filter[ LDAP_FILT_MAXSIZ ];
454 char *lfd_curvalcopy;
455 char **lfd_curvalwords;
456 char *lfd_filtprefix;
457 char *lfd_filtsuffix;
461 * "internal" globals used to track defaults and memory allocation callbacks:
462 * (the actual definitions are in open.c)
464 extern struct ldap nsldapi_ld_defaults;
465 extern struct ldap_memalloc_fns nsldapi_memalloc_fns;
466 extern int nsldapi_initialized;
470 * Memory allocation done in liblber should all go through one of the
471 * following macros. This is so we can plug-in alternative memory
472 * allocators, etc. as the need arises.
474 #define NSLDAPI_MALLOC( size ) nsldapi_malloc( size )
475 #define NSLDAPI_CALLOC( nelem, elsize ) nsldapi_calloc( nelem, elsize )
476 #define NSLDAPI_REALLOC( ptr, size ) nsldapi_realloc( ptr, size )
477 #define NSLDAPI_FREE( ptr ) nsldapi_free( ptr )
481 * macros used to check validity of data structures and parameters
483 #define NSLDAPI_VALID_LDAP_POINTER( ld ) \
486 #define NSLDAPI_VALID_LDAPMESSAGE_POINTER( lm ) \
489 #define NSLDAPI_VALID_LDAPMESSAGE_ENTRY_POINTER( lm ) \
490 ( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_SEARCH_ENTRY )
492 #define NSLDAPI_VALID_LDAPMESSAGE_REFERENCE_POINTER( lm ) \
493 ( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_SEARCH_REFERENCE )
495 #define NSLDAPI_VALID_LDAPMESSAGE_BINDRESULT_POINTER( lm ) \
496 ( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_BIND )
498 #define NSLDAPI_VALID_LDAPMESSAGE_EXRESULT_POINTER( lm ) \
499 ( (lm) != NULL && (lm)->lm_msgtype == LDAP_RES_EXTENDED )
501 #define NSLDAPI_VALID_LDAPMOD_ARRAY( mods ) \
504 #define NSLDAPI_VALID_NONEMPTY_LDAPMOD_ARRAY( mods ) \
505 ( (mods) != NULL && (mods)[0] != NULL )
507 #define NSLDAPI_IS_SEARCH_ENTRY( code ) \
508 ((code) == LDAP_RES_SEARCH_ENTRY)
510 #define NSLDAPI_IS_SEARCH_RESULT( code ) \
511 ((code) == LDAP_RES_SEARCH_RESULT)
513 #define NSLDAPI_SEARCH_RELATED_RESULT( code ) \
514 (NSLDAPI_IS_SEARCH_RESULT( code ) || NSLDAPI_IS_SEARCH_ENTRY( code ))
519 char *nsldapi_get_binddn( LDAP *ld );
524 void nsldapi_add_result_to_cache( LDAP *ld, LDAPMessage *result );
529 int nsldapi_next_line_tokens( char **bufp, long *blenp, char ***toksp );
530 void nsldapi_free_strarray( char **sap );
535 int nsldapi_parse_result( LDAP *ld, int msgtype, BerElement *rber,
536 int *errcodep, char **matchednp, char **errmsgp, char ***referralsp,
537 LDAPControl ***serverctrlsp );
542 void nsldapi_initialize_defaults( void );
543 int nsldapi_open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host,
544 int defport, char **krbinstancep, int async, int secure );
545 int nsldapi_open_ldap_defconn( LDAP *ld );
546 void *nsldapi_malloc( size_t size );
547 void *nsldapi_calloc( size_t nelem, size_t elsize );
548 void *nsldapi_realloc( void *ptr, size_t size );
549 void nsldapi_free( void *ptr );
550 char *nsldapi_strdup( const char *s );
555 int nsldapi_connect_to_host( LDAP *ld, Sockbuf *sb, char *host,
556 unsigned long address, int port, int async, int secure );
557 void nsldapi_close_connection( LDAP *ld, Sockbuf *sb );
559 int nsldapi_do_ldap_select( LDAP *ld, struct timeval *timeout );
560 void *nsldapi_new_select_info( void );
561 void nsldapi_free_select_info( void *vsip );
562 void nsldapi_mark_select_write( LDAP *ld, Sockbuf *sb );
563 void nsldapi_mark_select_read( LDAP *ld, Sockbuf *sb );
564 void nsldapi_mark_select_clear( LDAP *ld, Sockbuf *sb );
565 int nsldapi_is_read_ready( LDAP *ld, Sockbuf *sb );
566 int nsldapi_is_write_ready( LDAP *ld, Sockbuf *sb );
571 int nsldapi_parse_reference( LDAP *ld, BerElement *rber, char ***referralsp,
572 LDAPControl ***serverctrlsp );
578 int ldap_msgdelete( LDAP *ld, int msgid );
579 int nsldapi_result_nolock( LDAP *ld, int msgid, int all, int unlock_permitted,
580 struct timeval *timeout, LDAPMessage **result );
581 int nsldapi_wait_result( LDAP *ld, int msgid, int all, struct timeval *timeout,
582 LDAPMessage **result );
583 int nsldapi_post_result( LDAP *ld, int msgid, LDAPMessage *result );
588 int nsldapi_send_initial_request( LDAP *ld, int msgid, unsigned long msgtype,
589 char *dn, BerElement *ber );
590 int nsldapi_alloc_ber_with_options( LDAP *ld, BerElement **berp );
591 void nsldapi_set_ber_options( LDAP *ld, BerElement *ber );
592 int nsldapi_ber_flush( LDAP *ld, Sockbuf *sb, BerElement *ber, int freeit,
594 int nsldapi_send_server_request( LDAP *ld, BerElement *ber, int msgid,
595 LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc,
596 char *bindreqdn, int bind );
597 LDAPConn *nsldapi_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
598 int connect, int bind );
599 LDAPRequest *nsldapi_find_request_by_msgid( LDAP *ld, int msgid );
600 void nsldapi_free_request( LDAP *ld, LDAPRequest *lr, int free_conn );
601 void nsldapi_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
602 void nsldapi_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
603 void nsldapi_dump_requests_and_responses( LDAP *ld );
604 int nsldapi_chase_v2_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp,
605 int *totalcountp, int *chasingcountp );
606 int nsldapi_chase_v3_refs( LDAP *ld, LDAPRequest *lr, char **refs,
607 int is_reference, int *totalcountp, int *chasingcountp );
608 int nsldapi_append_referral( LDAP *ld, char **referralsp, char *s );
609 void nsldapi_connection_lost_nolock( LDAP *ld, Sockbuf *sb );
614 int ldap_build_search_req( LDAP *ld, char *base, int scope,
615 char *filter, char **attrs, int attrsonly, LDAPControl **serverctrls,
616 LDAPControl **clientctrls, struct timeval *timeoutp, int sizelimit,
617 int msgid, BerElement **berp );
622 int ldap_ld_free( LDAP *ld, int close );
623 int nsldapi_send_unbind( LDAP *ld, Sockbuf *sb );
629 char **nsldapi_getdxbyname( char *domain );
631 #endif /* LDAP_DNS */
636 void nsldapi_hex_unescape( char *s );
641 LDAPMessage *ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e );
642 void ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e );
648 char *nsldapi_compat_ctime_r( const time_t *clock, char *buf, int buflen );
649 struct hostent *nsldapi_compat_gethostbyname_r( const char *name,
650 struct hostent *result, char *buffer, int buflen, int *h_errnop );
656 int nsldapi_put_controls( LDAP *ld, LDAPControl **ctrls, int closeseq,
658 int nsldapi_get_controls( BerElement *ber, LDAPControl ***controlsp );
659 int nsldapi_dup_controls( LDAP *ld, LDAPControl ***ldctrls,
660 LDAPControl **newctrls );
661 int nsldapi_build_control( char *oid, BerElement *ber, int freeber,
662 char iscritical, LDAPControl **ctrlp );
668 int nsldapi_url_parse( char *url, LDAPURLDesc **ludpp, int dn_required );
674 * If we ever want to expose character set translation functionality to
675 * users of libldap, all of these prototypes will need to be moved to ldap.h
677 #ifdef STR_TRANSLATION
678 void ldap_set_string_translators( LDAP *ld,
679 BERTranslateProc encode_proc, BERTranslateProc decode_proc );
680 int ldap_translate_from_t61( LDAP *ld, char **bufp,
681 unsigned long *lenp, int free_input );
682 int ldap_translate_to_t61( LDAP *ld, char **bufp,
683 unsigned long *lenp, int free_input );
684 void ldap_enable_translation( LDAP *ld, LDAPMessage *entry,
686 #ifdef LDAP_CHARSET_8859
687 int ldap_t61_to_8859( char **bufp, unsigned long *buflenp,
689 int ldap_8859_to_t61( char **bufp, unsigned long *buflenp,
691 #endif /* LDAP_CHARSET_8859 */
692 #endif /* STR_TRANSLATION */
697 int ldap_memcache_createkey( LDAP *ld, const char *base, int scope,
698 const char *filter, char **attrs, int attrsonly,
699 LDAPControl **serverctrls, LDAPControl **clientctrls,
700 unsigned long *keyp );
701 int ldap_memcache_result( LDAP *ld, int msgid, unsigned long key );
702 int ldap_memcache_new( LDAP *ld, int msgid, unsigned long key,
703 const char *basedn );
704 int ldap_memcache_append( LDAP *ld, int msgid, int bLast, LDAPMessage *result );
705 int ldap_memcache_abandon( LDAP *ld, int msgid );
707 #endif /* _LDAPINT_H */