17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright 2001-2003 Sun Microsystems, Inc.  All rights reserved.
37c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate  */
57c478bd9Sstevel@tonic-gate 
67c478bd9Sstevel@tonic-gate #ifndef _SOLARISINT_H
77c478bd9Sstevel@tonic-gate #define _SOLARISINT_H
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate #ifdef __cplusplus
107c478bd9Sstevel@tonic-gate extern "C" {
117c478bd9Sstevel@tonic-gate #endif
127c478bd9Sstevel@tonic-gate 
137c478bd9Sstevel@tonic-gate #include <stdio.h>
147c478bd9Sstevel@tonic-gate #include <ctype.h>
157c478bd9Sstevel@tonic-gate #include <stdarg.h>
167c478bd9Sstevel@tonic-gate #include <stdlib.h>
177c478bd9Sstevel@tonic-gate 
187c478bd9Sstevel@tonic-gate #include "ldap.h"
197c478bd9Sstevel@tonic-gate 
207c478bd9Sstevel@tonic-gate /*
217c478bd9Sstevel@tonic-gate  * These were moved from lber.h. This should have been ifdef'd with
227c478bd9Sstevel@tonic-gate  * _SOLARIS_SDK but since we do not want to expose these in lber.h its
237c478bd9Sstevel@tonic-gate  * not possible to ifndef it there.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /* BerElement set/get options */
277c478bd9Sstevel@tonic-gate #define LBER_OPT_REMAINING_BYTES	0x01
287c478bd9Sstevel@tonic-gate #define LBER_OPT_TOTAL_BYTES		0x02
297c478bd9Sstevel@tonic-gate #define LBER_OPT_USE_DER		0x04
307c478bd9Sstevel@tonic-gate #define LBER_OPT_TRANSLATE_STRINGS	0x08
317c478bd9Sstevel@tonic-gate #define LBER_OPT_BYTES_TO_WRITE		0x10
327c478bd9Sstevel@tonic-gate #define LBER_OPT_MEMALLOC_FN_PTRS	0x20
337c478bd9Sstevel@tonic-gate #define LBER_OPT_DEBUG_LEVEL		0x40
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * LBER_USE_DER is defined for compatibility with the C LDAP API RFC.
367c478bd9Sstevel@tonic-gate  * In our implementation, we recognize it (instead of the numerically
37*1da57d55SToomas Soome  * identical LBER_OPT_REMAINING_BYTES) in calls to ber_alloc_t() and
387c478bd9Sstevel@tonic-gate  * ber_init_w_nullchar() only.  Callers of ber_set_option() or
397c478bd9Sstevel@tonic-gate  * ber_get_option() must use LBER_OPT_USE_DER instead.  Sorry!
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate #define LBER_USE_DER			0x01
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /* Sockbuf set/get options */
447c478bd9Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_TO_FILE		0x001
457c478bd9Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_TO_FILE_ONLY		0x002
467c478bd9Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE	0x004
477c478bd9Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_NO_READ_AHEAD		0x008
487c478bd9Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_DESC			0x010
497c478bd9Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_COPYDESC		0x020
507c478bd9Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_READ_FN		0x040
517c478bd9Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_WRITE_FN		0x080
527c478bd9Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_EXT_IO_FNS		0x100
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate #ifndef _SOLARIS_SDK
557c478bd9Sstevel@tonic-gate /*
567c478bd9Sstevel@tonic-gate  * The following is not used by solaris. Just kept to stay in sync with
577c478bd9Sstevel@tonic-gate  * iplanet and also a place holder (0x200)
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_VALID_TAG              0x200
607c478bd9Sstevel@tonic-gate #endif	/* !_SOLARIS_SDK */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * Socket buffer structure associated to the LDAP connection
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate #define LDAP_X_OPT_SOCKBUF	(LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F02)
667c478bd9Sstevel@tonic-gate 	/* 0x4000 + 0x0F02 = 0x4F02 = 20226 - API extension */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #define LBER_OPT_ON	((void *) 1)
707c478bd9Sstevel@tonic-gate #define LBER_OPT_OFF	((void *) 0)
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /* Used in various functions */
737c478bd9Sstevel@tonic-gate #define LBER_FUNC_VALUE		-1
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate struct lextiof_socket_private;          /* Defined by the extended I/O */
767c478bd9Sstevel@tonic-gate                                         /* callback functions */
777c478bd9Sstevel@tonic-gate struct lextiof_session_private;         /* Defined by the extended I/O */
787c478bd9Sstevel@tonic-gate                                         /* callback functions */
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /* This is modeled after the PRIOVec that is passed to the NSPR
817c478bd9Sstevel@tonic-gate    writev function! The void* is a char* in that struct */
827c478bd9Sstevel@tonic-gate typedef struct ldap_x_iovec {
837c478bd9Sstevel@tonic-gate         char    *ldapiov_base;
847c478bd9Sstevel@tonic-gate         int     ldapiov_len;
857c478bd9Sstevel@tonic-gate } ldap_x_iovec;
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /*
887c478bd9Sstevel@tonic-gate  * libldap read and write I/O function callbacks.  The rest of the I/O callback
897c478bd9Sstevel@tonic-gate  * types are defined in ldap.h
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_READ_CALLBACK)( LBER_SOCKET s,
927c478bd9Sstevel@tonic-gate 	void *buf, int bufsize );
937c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_WRITE_CALLBACK)( LBER_SOCKET s,
947c478bd9Sstevel@tonic-gate 	const void *buf, int len );
957c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_READ_CALLBACK)( int s,
967c478bd9Sstevel@tonic-gate 	void *buf, int bufsize, struct lextiof_socket_private *arg );
977c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_WRITE_CALLBACK)( int s,
987c478bd9Sstevel@tonic-gate 	const void *buf, int len, struct lextiof_socket_private *arg );
997c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_WRITEV_CALLBACK)(int s,
1007c478bd9Sstevel@tonic-gate         const ldap_x_iovec iov[], int iovcnt, struct lextiof_socket_private *socketarg);
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate /*
1047c478bd9Sstevel@tonic-gate  * Structure for use with LBER_SOCKBUF_OPT_EXT_IO_FNS:
1057c478bd9Sstevel@tonic-gate  */
1067c478bd9Sstevel@tonic-gate struct lber_x_ext_io_fns {
1077c478bd9Sstevel@tonic-gate 	    /* lbextiofn_size should always be set to LBER_X_EXTIO_FNS_SIZE */
1087c478bd9Sstevel@tonic-gate 	int				lbextiofn_size;
1097c478bd9Sstevel@tonic-gate 	LDAP_X_EXTIOF_READ_CALLBACK	*lbextiofn_read;
1107c478bd9Sstevel@tonic-gate 	LDAP_X_EXTIOF_WRITE_CALLBACK	*lbextiofn_write;
1117c478bd9Sstevel@tonic-gate 	struct lextiof_socket_private	*lbextiofn_socket_arg;
1127c478bd9Sstevel@tonic-gate         LDAP_X_EXTIOF_WRITEV_CALLBACK   *lbextiofn_writev;
1137c478bd9Sstevel@tonic-gate };
1147c478bd9Sstevel@tonic-gate #define LBER_X_EXTIO_FNS_SIZE sizeof(struct lber_x_ext_io_fns)
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate /*
1177c478bd9Sstevel@tonic-gate  * liblber memory allocation callback functions.  These are global to all
1187c478bd9Sstevel@tonic-gate  *  Sockbufs and BerElements.  Install your own functions by using a call
1197c478bd9Sstevel@tonic-gate  *  like this: ber_set_option( NULL, LBER_OPT_MEMALLOC_FN_PTRS, &memalloc_fns );
1207c478bd9Sstevel@tonic-gate  */
1217c478bd9Sstevel@tonic-gate typedef void * (LDAP_C LDAP_CALLBACK LDAP_MALLOC_CALLBACK)( size_t size );
1227c478bd9Sstevel@tonic-gate typedef void * (LDAP_C LDAP_CALLBACK LDAP_CALLOC_CALLBACK)( size_t nelem,
1237c478bd9Sstevel@tonic-gate 	size_t elsize );
1247c478bd9Sstevel@tonic-gate typedef void * (LDAP_C LDAP_CALLBACK LDAP_REALLOC_CALLBACK)( void *ptr,
1257c478bd9Sstevel@tonic-gate 	size_t size );
1267c478bd9Sstevel@tonic-gate typedef void (LDAP_C LDAP_CALLBACK LDAP_FREE_CALLBACK)( void *ptr );
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate struct lber_memalloc_fns {
1297c478bd9Sstevel@tonic-gate 	LDAP_MALLOC_CALLBACK	*lbermem_malloc;
1307c478bd9Sstevel@tonic-gate 	LDAP_CALLOC_CALLBACK	*lbermem_calloc;
1317c478bd9Sstevel@tonic-gate 	LDAP_REALLOC_CALLBACK	*lbermem_realloc;
1327c478bd9Sstevel@tonic-gate 	LDAP_FREE_CALLBACK	*lbermem_free;
1337c478bd9Sstevel@tonic-gate };
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate  * Functions marked as Project Private in PSARC case and moved
1377c478bd9Sstevel@tonic-gate  * from lber.h
1387c478bd9Sstevel@tonic-gate  */
1397c478bd9Sstevel@tonic-gate typedef struct sockbuf Sockbuf;
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ber_special_free(void* buf, BerElement *ber);
1427c478bd9Sstevel@tonic-gate LDAP_API(void*) LDAP_CALL ber_special_alloc(size_t size, BerElement **ppBer);
1437c478bd9Sstevel@tonic-gate LDAP_API(ber_uint_t) LDAP_CALL ber_get_next_buffer( void *buffer,
1447c478bd9Sstevel@tonic-gate 	size_t buffer_size, ber_len_t *len, BerElement *ber,
1457c478bd9Sstevel@tonic-gate 	ber_uint_t *Bytes_Scanned );
1467c478bd9Sstevel@tonic-gate LDAP_API(ber_uint_t) LDAP_CALL ber_get_next_buffer_ext( void *buffer,
1477c478bd9Sstevel@tonic-gate 	size_t buffer_size, ber_len_t *len, BerElement *ber,
1487c478bd9Sstevel@tonic-gate 	ber_len_t *Bytes_Scanned, Sockbuf *sb );
1497c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ber_init_w_nullchar( BerElement *ber, int options );
150*1da57d55SToomas Soome LDAP_API(int) LDAP_CALL ber_set_option( BerElement *ber, int option,
1517c478bd9Sstevel@tonic-gate 	void *value );
152*1da57d55SToomas Soome LDAP_API(int) LDAP_CALL ber_get_option( BerElement *ber, int option,
1537c478bd9Sstevel@tonic-gate 	void *value );
1547c478bd9Sstevel@tonic-gate LDAP_API(Sockbuf*) LDAP_CALL ber_sockbuf_alloc( void );
1557c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ber_sockbuf_free( Sockbuf* p );
156*1da57d55SToomas Soome LDAP_API(int) LDAP_CALL ber_sockbuf_set_option( Sockbuf *sb, int option,
1577c478bd9Sstevel@tonic-gate 	void *value );
158*1da57d55SToomas Soome LDAP_API(int) LDAP_CALL ber_sockbuf_get_option( Sockbuf *sb, int option,
1597c478bd9Sstevel@tonic-gate 	void *value );
1607c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ber_flush( Sockbuf *sb, BerElement *ber, int freeit );
1617c478bd9Sstevel@tonic-gate LDAP_API(ber_tag_t) LDAP_CALL ber_get_next( Sockbuf *sb, ber_len_t *len,
1627c478bd9Sstevel@tonic-gate 	BerElement *ber );
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate /*
1657c478bd9Sstevel@tonic-gate  * The following was moved from ldap.h
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate /*
1697c478bd9Sstevel@tonic-gate  * These extended I/O function callbacks echo the BSD socket API but accept
1707c478bd9Sstevel@tonic-gate  * an extra pointer parameter at the end of their argument list that can
1717c478bd9Sstevel@tonic-gate  * be used by client applications for their own needs.  For some of the calls,
1727c478bd9Sstevel@tonic-gate  * the pointer is a session argument of type struct lextiof_session_private *
1737c478bd9Sstevel@tonic-gate  * that is associated with the LDAP session handle (LDAP *).  For others, the
1747c478bd9Sstevel@tonic-gate  * pointer is a socket specific struct lextiof_socket_private * argument that
1757c478bd9Sstevel@tonic-gate  * is associated with a particular socket (a TCP connection).
1767c478bd9Sstevel@tonic-gate  *
1777c478bd9Sstevel@tonic-gate  * The lextiof_session_private and lextiof_socket_private structures are not
1787c478bd9Sstevel@tonic-gate  * defined by the LDAP C API; users of this extended I/O interface should
1797c478bd9Sstevel@tonic-gate  * define these themselves.
1807c478bd9Sstevel@tonic-gate  *
1817c478bd9Sstevel@tonic-gate  * The combination of the integer socket number (i.e., lpoll_fd, which is
1827c478bd9Sstevel@tonic-gate  * the value returned by the CONNECT callback) and the application specific
1837c478bd9Sstevel@tonic-gate  * socket argument (i.e., lpoll_socketarg, which is the value set in *sockargpp
1847c478bd9Sstevel@tonic-gate  * by the CONNECT callback) must be unique.
1857c478bd9Sstevel@tonic-gate  *
1867c478bd9Sstevel@tonic-gate  * The types for the extended READ and WRITE callbacks are actually in lber.h.
1877c478bd9Sstevel@tonic-gate  *
1887c478bd9Sstevel@tonic-gate  * The CONNECT callback gets passed both the session argument (sessionarg)
1897c478bd9Sstevel@tonic-gate  * and a pointer to a socket argument (socketargp) so it has the
1907c478bd9Sstevel@tonic-gate  * opportunity to set the socket-specific argument.  The CONNECT callback
1917c478bd9Sstevel@tonic-gate  * also takes a timeout parameter whose value can be set by calling
1927c478bd9Sstevel@tonic-gate  * ldap_set_option( ld, LDAP_X_OPT_..., &val ).  The units used for the
1937c478bd9Sstevel@tonic-gate  * timeout parameter are milliseconds.
1947c478bd9Sstevel@tonic-gate  *
1957c478bd9Sstevel@tonic-gate  * A POLL interface is provided instead of a select() one.  The timeout is
1967c478bd9Sstevel@tonic-gate  * in milliseconds.
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate  * A NEWHANDLE callback function is also provided.  It is called right
1997c478bd9Sstevel@tonic-gate  * after the LDAP session handle is created, e.g., during ldap_init().
2007c478bd9Sstevel@tonic-gate  * If the NEWHANDLE callback returns anything other than LDAP_SUCCESS,
2017c478bd9Sstevel@tonic-gate  * the session handle allocation fails.
2027c478bd9Sstevel@tonic-gate  *
2037c478bd9Sstevel@tonic-gate  * A DISPOSEHANDLE callback function is also provided.  It is called right
2047c478bd9Sstevel@tonic-gate  * before the LDAP session handle and its contents are destroyed, e.g.,
2057c478bd9Sstevel@tonic-gate  * during ldap_unbind().
2067c478bd9Sstevel@tonic-gate  */
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate /* LDAP poll()-like descriptor:
2097c478bd9Sstevel@tonic-gate  */
2107c478bd9Sstevel@tonic-gate typedef struct ldap_x_pollfd {	   /* used by LDAP_X_EXTIOF_POLL_CALLBACK */
2117c478bd9Sstevel@tonic-gate     int		lpoll_fd;	   /* integer file descriptor / socket */
2127c478bd9Sstevel@tonic-gate     struct lextiof_socket_private
2137c478bd9Sstevel@tonic-gate 		*lpoll_socketarg;
2147c478bd9Sstevel@tonic-gate 				   /* pointer socket and for use by */
2157c478bd9Sstevel@tonic-gate 				   /* application */
2167c478bd9Sstevel@tonic-gate     short	lpoll_events;      /* requested event */
2177c478bd9Sstevel@tonic-gate     short	lpoll_revents;     /* returned event */
2187c478bd9Sstevel@tonic-gate } LDAP_X_PollFD;
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate /* Event flags for lpoll_events and lpoll_revents:
2217c478bd9Sstevel@tonic-gate  */
2227c478bd9Sstevel@tonic-gate #define LDAP_X_POLLIN    0x01  /* regular data ready for reading */
2237c478bd9Sstevel@tonic-gate #define LDAP_X_POLLPRI   0x02  /* high priority data available */
2247c478bd9Sstevel@tonic-gate #define LDAP_X_POLLOUT   0x04  /* ready for writing */
2257c478bd9Sstevel@tonic-gate #define LDAP_X_POLLERR   0x08  /* error occurred -- only in lpoll_revents */
2267c478bd9Sstevel@tonic-gate #define LDAP_X_POLLHUP   0x10  /* connection closed -- only in lpoll_revents */
2277c478bd9Sstevel@tonic-gate #define LDAP_X_POLLNVAL  0x20  /* invalid lpoll_fd -- only in lpoll_revents */
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate /* Options passed to LDAP_X_EXTIOF_CONNECT_CALLBACK to modify socket behavior:
2307c478bd9Sstevel@tonic-gate  */
2317c478bd9Sstevel@tonic-gate #define LDAP_X_EXTIOF_OPT_NONBLOCKING	0x01  /* turn on non-blocking mode */
2327c478bd9Sstevel@tonic-gate #define LDAP_X_EXTIOF_OPT_SECURE	0x02  /* turn on 'secure' mode */
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate /* extended I/O callback function prototypes:
2357c478bd9Sstevel@tonic-gate  */
2367c478bd9Sstevel@tonic-gate typedef int	(LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CONNECT_CALLBACK )(
2377c478bd9Sstevel@tonic-gate 	    const char *hostlist, int port, /* host byte order */
2387c478bd9Sstevel@tonic-gate 	    int timeout /* milliseconds */,
2397c478bd9Sstevel@tonic-gate 	    unsigned long options, /* bitmapped options */
2407c478bd9Sstevel@tonic-gate 	    struct lextiof_session_private *sessionarg,
2417c478bd9Sstevel@tonic-gate 	    struct lextiof_socket_private **socketargp
2427c478bd9Sstevel@tonic-gate #ifdef _SOLARIS_SDK
2437c478bd9Sstevel@tonic-gate 		, void **datapriv );
2447c478bd9Sstevel@tonic-gate #else
2457c478bd9Sstevel@tonic-gate 		);
2467c478bd9Sstevel@tonic-gate #endif
2477c478bd9Sstevel@tonic-gate typedef int	(LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CLOSE_CALLBACK )(
2487c478bd9Sstevel@tonic-gate 	    int s, struct lextiof_socket_private *socketarg );
2497c478bd9Sstevel@tonic-gate typedef int	(LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_POLL_CALLBACK)(
2507c478bd9Sstevel@tonic-gate 	    LDAP_X_PollFD fds[], int nfds, int timeout /* milliseconds */,
2517c478bd9Sstevel@tonic-gate 	    struct lextiof_session_private *sessionarg );
2527c478bd9Sstevel@tonic-gate typedef int	(LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_NEWHANDLE_CALLBACK)(
2537c478bd9Sstevel@tonic-gate 	    LDAP *ld, struct lextiof_session_private *sessionarg );
2547c478bd9Sstevel@tonic-gate typedef void	(LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK)(
2557c478bd9Sstevel@tonic-gate 	    LDAP *ld, struct lextiof_session_private *sessionarg );
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate /* Structure to hold extended I/O function pointers:
2597c478bd9Sstevel@tonic-gate  */
2607c478bd9Sstevel@tonic-gate struct ldap_x_ext_io_fns {
2617c478bd9Sstevel@tonic-gate 	/* lextiof_size should always be set to LDAP_X_EXTIO_FNS_SIZE */
2627c478bd9Sstevel@tonic-gate 	int					lextiof_size;
2637c478bd9Sstevel@tonic-gate 	LDAP_X_EXTIOF_CONNECT_CALLBACK		*lextiof_connect;
2647c478bd9Sstevel@tonic-gate 	LDAP_X_EXTIOF_CLOSE_CALLBACK		*lextiof_close;
2657c478bd9Sstevel@tonic-gate 	LDAP_X_EXTIOF_READ_CALLBACK		*lextiof_read;
2667c478bd9Sstevel@tonic-gate 	LDAP_X_EXTIOF_WRITE_CALLBACK		*lextiof_write;
2677c478bd9Sstevel@tonic-gate 	LDAP_X_EXTIOF_POLL_CALLBACK		*lextiof_poll;
2687c478bd9Sstevel@tonic-gate 	LDAP_X_EXTIOF_NEWHANDLE_CALLBACK	*lextiof_newhandle;
2697c478bd9Sstevel@tonic-gate 	LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK	*lextiof_disposehandle;
2707c478bd9Sstevel@tonic-gate 	void					*lextiof_session_arg;
2717c478bd9Sstevel@tonic-gate 	LDAP_X_EXTIOF_WRITEV_CALLBACK           *lextiof_writev;
2727c478bd9Sstevel@tonic-gate };
2737c478bd9Sstevel@tonic-gate #define LDAP_X_EXTIO_FNS_SIZE	sizeof(struct ldap_x_ext_io_fns)
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate /*
2777c478bd9Sstevel@tonic-gate  * Utility functions for parsing space-separated host lists (useful for
2787c478bd9Sstevel@tonic-gate  * implementing an extended I/O CONNECT callback function).
2797c478bd9Sstevel@tonic-gate  */
2807c478bd9Sstevel@tonic-gate struct ldap_x_hostlist_status;
2817c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_x_hostlist_first( const char *hostlist,
2827c478bd9Sstevel@tonic-gate 	int defport, char **hostp, int *portp /* host byte order */,
2837c478bd9Sstevel@tonic-gate 	struct ldap_x_hostlist_status **statusp );
2847c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_x_hostlist_next( char **hostp,
2857c478bd9Sstevel@tonic-gate 	int *portp /* host byte order */, struct ldap_x_hostlist_status *status );
2867c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_x_hostlist_statusfree(
2877c478bd9Sstevel@tonic-gate 	struct ldap_x_hostlist_status *status );
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /*
2917c478bd9Sstevel@tonic-gate  * I/O callback functions (note that types for the read and write callbacks
2927c478bd9Sstevel@tonic-gate  * are actually in lber.h):
2937c478bd9Sstevel@tonic-gate  */
2947c478bd9Sstevel@tonic-gate typedef int	(LDAP_C LDAP_CALLBACK LDAP_IOF_SELECT_CALLBACK)( int nfds,
2957c478bd9Sstevel@tonic-gate 	fd_set *readfds, fd_set *writefds, fd_set *errorfds,
2967c478bd9Sstevel@tonic-gate 	struct timeval *timeout );
2977c478bd9Sstevel@tonic-gate typedef LBER_SOCKET (LDAP_C LDAP_CALLBACK LDAP_IOF_SOCKET_CALLBACK)(
2987c478bd9Sstevel@tonic-gate 	int domain, int type, int protocol );
299*1da57d55SToomas Soome typedef int	(LDAP_C LDAP_CALLBACK LDAP_IOF_IOCTL_CALLBACK)( LBER_SOCKET s,
3007c478bd9Sstevel@tonic-gate 	int option, ... );
3017c478bd9Sstevel@tonic-gate typedef int	(LDAP_C LDAP_CALLBACK LDAP_IOF_CONNECT_CALLBACK )(
3027c478bd9Sstevel@tonic-gate 	LBER_SOCKET s, struct sockaddr *name, int namelen );
3037c478bd9Sstevel@tonic-gate typedef int	(LDAP_C LDAP_CALLBACK LDAP_IOF_CLOSE_CALLBACK )(
3047c478bd9Sstevel@tonic-gate 	LBER_SOCKET s );
3057c478bd9Sstevel@tonic-gate typedef int	(LDAP_C LDAP_CALLBACK LDAP_IOF_SSL_ENABLE_CALLBACK )(
3067c478bd9Sstevel@tonic-gate 	LBER_SOCKET s );
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate /*
3107c478bd9Sstevel@tonic-gate  * Structure to hold I/O function pointers:
3117c478bd9Sstevel@tonic-gate  */
3127c478bd9Sstevel@tonic-gate struct ldap_io_fns {
3137c478bd9Sstevel@tonic-gate 	LDAP_IOF_READ_CALLBACK *liof_read;
3147c478bd9Sstevel@tonic-gate 	LDAP_IOF_WRITE_CALLBACK *liof_write;
3157c478bd9Sstevel@tonic-gate 	LDAP_IOF_SELECT_CALLBACK *liof_select;
3167c478bd9Sstevel@tonic-gate 	LDAP_IOF_SOCKET_CALLBACK *liof_socket;
3177c478bd9Sstevel@tonic-gate 	LDAP_IOF_IOCTL_CALLBACK *liof_ioctl;
3187c478bd9Sstevel@tonic-gate 	LDAP_IOF_CONNECT_CALLBACK *liof_connect;
3197c478bd9Sstevel@tonic-gate 	LDAP_IOF_CLOSE_CALLBACK *liof_close;
3207c478bd9Sstevel@tonic-gate 	LDAP_IOF_SSL_ENABLE_CALLBACK *liof_ssl_enable;
3217c478bd9Sstevel@tonic-gate };
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate /********* the functions in the following section are experimental ***********/
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate #define	LDAP_OPT_PREFERRED_LANGUAGE	0x14	/* 20 - API extension */
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate /*
3287c478bd9Sstevel@tonic-gate  * SSL option (an API extension):
3297c478bd9Sstevel@tonic-gate  */
3307c478bd9Sstevel@tonic-gate #define	LDAP_OPT_SSL			0x0A	/* 10 - API extension */
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate /*
3337c478bd9Sstevel@tonic-gate  * Referral hop limit (an API extension):
3347c478bd9Sstevel@tonic-gate  */
3357c478bd9Sstevel@tonic-gate #define	LDAP_OPT_REFERRAL_HOP_LIMIT	0x10	/* 16 - API extension */
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate /*
3387c478bd9Sstevel@tonic-gate  * DNS resolver callbacks (an API extension --LDAP_API_FEATURE_X_DNS_FUNCTIONS).
3397c478bd9Sstevel@tonic-gate  * Note that gethostbyaddr() is not currently used.
3407c478bd9Sstevel@tonic-gate  */
3417c478bd9Sstevel@tonic-gate #define	LDAP_OPT_DNS_FN_PTRS		0x60	/* 96 - API extension */
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate typedef struct LDAPHostEnt {
3447c478bd9Sstevel@tonic-gate     char	*ldaphe_name;		/* official name of host */
3457c478bd9Sstevel@tonic-gate     char	**ldaphe_aliases;	/* alias list */
3467c478bd9Sstevel@tonic-gate     int		ldaphe_addrtype;	/* host address type */
3477c478bd9Sstevel@tonic-gate     int		ldaphe_length;		/* length of address */
3487c478bd9Sstevel@tonic-gate     char	**ldaphe_addr_list;	/* list of addresses from name server */
3497c478bd9Sstevel@tonic-gate } LDAPHostEnt;
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYNAME)(
3527c478bd9Sstevel@tonic-gate 	const char *name, LDAPHostEnt *result, char *buffer,
3537c478bd9Sstevel@tonic-gate 	int buflen, int *statusp, void *extradata);
3547c478bd9Sstevel@tonic-gate typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYADDR)(
3557c478bd9Sstevel@tonic-gate 	const char *addr, int length, int type, LDAPHostEnt *result,
3567c478bd9Sstevel@tonic-gate 	char *buffer, int buflen, int *statusp, void *extradata);
3577c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETPEERNAME)(
3587c478bd9Sstevel@tonic-gate 	LDAP *ld, struct sockaddr *netaddr, char *buffer, int buflen);
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate struct ldap_dns_fns {
3617c478bd9Sstevel@tonic-gate 	void				*lddnsfn_extradata;
3627c478bd9Sstevel@tonic-gate 	int				lddnsfn_bufsize;
3637c478bd9Sstevel@tonic-gate 	LDAP_DNSFN_GETHOSTBYNAME	*lddnsfn_gethostbyname;
3647c478bd9Sstevel@tonic-gate 	LDAP_DNSFN_GETHOSTBYADDR	*lddnsfn_gethostbyaddr;
3657c478bd9Sstevel@tonic-gate 	LDAP_DNSFN_GETPEERNAME		*lddnsfn_getpeername;
3667c478bd9Sstevel@tonic-gate };
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate /*
3697c478bd9Sstevel@tonic-gate  * Generalized cache callback interface:
3707c478bd9Sstevel@tonic-gate  */
3717c478bd9Sstevel@tonic-gate #define	LDAP_OPT_CACHE_FN_PTRS		0x0D	/* 13 - API extension */
3727c478bd9Sstevel@tonic-gate #define	LDAP_OPT_CACHE_STRATEGY		0x0E	/* 14 - API extension */
3737c478bd9Sstevel@tonic-gate #define	LDAP_OPT_CACHE_ENABLE		0x0F	/* 15 - API extension */
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate /* cache strategies */
3767c478bd9Sstevel@tonic-gate #define	LDAP_CACHE_CHECK		0
3777c478bd9Sstevel@tonic-gate #define	LDAP_CACHE_POPULATE		1
3787c478bd9Sstevel@tonic-gate #define	LDAP_CACHE_LOCALDB		2
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_BIND_CALLBACK)(LDAP *ld, int msgid,
3817c478bd9Sstevel@tonic-gate 	ber_tag_t tag, const char *dn, const struct berval *creds,
3827c478bd9Sstevel@tonic-gate 	int method);
3837c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_UNBIND_CALLBACK)(LDAP *ld,
3847c478bd9Sstevel@tonic-gate 	int unused0, unsigned long unused1);
3857c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_SEARCH_CALLBACK)(LDAP *ld,
3867c478bd9Sstevel@tonic-gate 	int msgid, ber_tag_t tag, const char *base, int scope,
3877c478bd9Sstevel@tonic-gate 	const char LDAP_CALLBACK *filter, char **attrs, int attrsonly);
3887c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_COMPARE_CALLBACK)(LDAP *ld,
3897c478bd9Sstevel@tonic-gate 	int msgid, ber_tag_t tag, const char *dn, const char *attr,
3907c478bd9Sstevel@tonic-gate 	const struct berval *value);
3917c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_ADD_CALLBACK)(LDAP *ld,
3927c478bd9Sstevel@tonic-gate 	int msgid, ber_tag_t tag, const char *dn, LDAPMod **attrs);
3937c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_DELETE_CALLBACK)(LDAP *ld,
3947c478bd9Sstevel@tonic-gate 	int msgid, ber_tag_t tag, const char *dn);
3957c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_MODIFY_CALLBACK)(LDAP *ld,
3967c478bd9Sstevel@tonic-gate 	int msgid, ber_tag_t tag, const char *dn, LDAPMod **mods);
3977c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_MODRDN_CALLBACK)(LDAP *ld,
3987c478bd9Sstevel@tonic-gate 	int msgid, ber_tag_t tag, const char *dn, const char *newrdn,
3997c478bd9Sstevel@tonic-gate 	int deleteoldrdn);
4007c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_RESULT_CALLBACK)(LDAP *ld,
4017c478bd9Sstevel@tonic-gate 	int msgid, int all, struct timeval *timeout, LDAPMessage **result);
4027c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_FLUSH_CALLBACK)(LDAP *ld,
4037c478bd9Sstevel@tonic-gate 	const char *dn, const char *filter);
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate struct ldap_cache_fns {
4067c478bd9Sstevel@tonic-gate 	void    *lcf_private;
4077c478bd9Sstevel@tonic-gate 	LDAP_CF_BIND_CALLBACK *lcf_bind;
4087c478bd9Sstevel@tonic-gate 	LDAP_CF_UNBIND_CALLBACK *lcf_unbind;
4097c478bd9Sstevel@tonic-gate 	LDAP_CF_SEARCH_CALLBACK *lcf_search;
4107c478bd9Sstevel@tonic-gate 	LDAP_CF_COMPARE_CALLBACK *lcf_compare;
4117c478bd9Sstevel@tonic-gate 	LDAP_CF_ADD_CALLBACK *lcf_add;
4127c478bd9Sstevel@tonic-gate 	LDAP_CF_DELETE_CALLBACK *lcf_delete;
4137c478bd9Sstevel@tonic-gate 	LDAP_CF_MODIFY_CALLBACK *lcf_modify;
4147c478bd9Sstevel@tonic-gate 	LDAP_CF_MODRDN_CALLBACK *lcf_modrdn;
4157c478bd9Sstevel@tonic-gate 	LDAP_CF_RESULT_CALLBACK *lcf_result;
4167c478bd9Sstevel@tonic-gate 	LDAP_CF_FLUSH_CALLBACK *lcf_flush;
4177c478bd9Sstevel@tonic-gate };
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_cache_flush(LDAP *ld, const char *dn,
4207c478bd9Sstevel@tonic-gate 	const char *filter);
4217c478bd9Sstevel@tonic-gate 
4227c478bd9Sstevel@tonic-gate /*
4237c478bd9Sstevel@tonic-gate  * Memory allocation callback functions (an API extension --
4247c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS).  These are global and can
4257c478bd9Sstevel@tonic-gate  * not be set on a per-LDAP session handle basis.  Install your own
4267c478bd9Sstevel@tonic-gate  * functions by making a call like this:
4277c478bd9Sstevel@tonic-gate  *    ldap_set_option( NULL, LDAP_OPT_MEMALLOC_FN_PTRS, &memalloc_fns );
4287c478bd9Sstevel@tonic-gate  *
4297c478bd9Sstevel@tonic-gate  * look in lber.h for the function typedefs themselves.
4307c478bd9Sstevel@tonic-gate  */
4317c478bd9Sstevel@tonic-gate #define LDAP_OPT_MEMALLOC_FN_PTRS	0x61	/* 97 - API extension */
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate struct ldap_memalloc_fns {
4347c478bd9Sstevel@tonic-gate 	LDAP_MALLOC_CALLBACK	*ldapmem_malloc;
4357c478bd9Sstevel@tonic-gate 	LDAP_CALLOC_CALLBACK	*ldapmem_calloc;
4367c478bd9Sstevel@tonic-gate 	LDAP_REALLOC_CALLBACK	*ldapmem_realloc;
4377c478bd9Sstevel@tonic-gate 	LDAP_FREE_CALLBACK	*ldapmem_free;
4387c478bd9Sstevel@tonic-gate };
4397c478bd9Sstevel@tonic-gate 
4407c478bd9Sstevel@tonic-gate 
4417c478bd9Sstevel@tonic-gate /*
4427c478bd9Sstevel@tonic-gate  * Memory allocation functions (an API extension)
4437c478bd9Sstevel@tonic-gate  */
4447c478bd9Sstevel@tonic-gate void *ldap_x_malloc( size_t size );
4457c478bd9Sstevel@tonic-gate void *ldap_x_calloc( size_t nelem, size_t elsize );
4467c478bd9Sstevel@tonic-gate void *ldap_x_realloc( void *ptr, size_t size );
4477c478bd9Sstevel@tonic-gate void ldap_x_free( void *ptr );
4487c478bd9Sstevel@tonic-gate 
4497c478bd9Sstevel@tonic-gate /*
4507c478bd9Sstevel@tonic-gate  * Extra thread callback functions (an API extension --
4517c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS)
4527c478bd9Sstevel@tonic-gate  */
4537c478bd9Sstevel@tonic-gate #define LDAP_OPT_EXTRA_THREAD_FN_PTRS  0x65	/* 101 - API extension */
4547c478bd9Sstevel@tonic-gate 
4557c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_TRYLOCK_CALLBACK)( void *m );
4567c478bd9Sstevel@tonic-gate typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_ALLOC_CALLBACK)( void );
4577c478bd9Sstevel@tonic-gate typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_FREE_CALLBACK)( void *s );
4587c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_WAIT_CALLBACK)( void *s );
4597c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_POST_CALLBACK)( void *s );
4607c478bd9Sstevel@tonic-gate typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_THREADID_CALLBACK)(void);
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate struct ldap_extra_thread_fns {
4637c478bd9Sstevel@tonic-gate         LDAP_TF_MUTEX_TRYLOCK_CALLBACK *ltf_mutex_trylock;
4647c478bd9Sstevel@tonic-gate         LDAP_TF_SEMA_ALLOC_CALLBACK *ltf_sema_alloc;
4657c478bd9Sstevel@tonic-gate         LDAP_TF_SEMA_FREE_CALLBACK *ltf_sema_free;
4667c478bd9Sstevel@tonic-gate         LDAP_TF_SEMA_WAIT_CALLBACK *ltf_sema_wait;
4677c478bd9Sstevel@tonic-gate         LDAP_TF_SEMA_POST_CALLBACK *ltf_sema_post;
4687c478bd9Sstevel@tonic-gate 	LDAP_TF_THREADID_CALLBACK *ltf_threadid_fn;
4697c478bd9Sstevel@tonic-gate };
4707c478bd9Sstevel@tonic-gate 
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate /*
4737c478bd9Sstevel@tonic-gate  * Debugging level (an API extension)
4747c478bd9Sstevel@tonic-gate  */
4757c478bd9Sstevel@tonic-gate #define LDAP_OPT_DEBUG_LEVEL		0x6E	/* 110 - API extension */
4767c478bd9Sstevel@tonic-gate /* On UNIX, there's only one copy of ldap_debug */
4777c478bd9Sstevel@tonic-gate /* On NT, each dll keeps its own module_ldap_debug, which */
4787c478bd9Sstevel@tonic-gate /* points to the process' ldap_debug and needs initializing after load */
4797c478bd9Sstevel@tonic-gate #ifdef _WIN32
4807c478bd9Sstevel@tonic-gate extern int		*module_ldap_debug;
4817c478bd9Sstevel@tonic-gate typedef void (*set_debug_level_fn_t)(int*);
4827c478bd9Sstevel@tonic-gate #endif
4837c478bd9Sstevel@tonic-gate 
4847c478bd9Sstevel@tonic-gate /************************ end of experimental section ************************/
4857c478bd9Sstevel@tonic-gate 
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_keysort_entries( LDAP *ld, LDAPMessage **chain,
4887c478bd9Sstevel@tonic-gate 	void *arg, LDAP_KEYGEN_CALLBACK *gen, LDAP_KEYCMP_CALLBACK *cmp,
4897c478bd9Sstevel@tonic-gate 	LDAP_KEYFREE_CALLBACK *fre );
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate /*
4927c478bd9Sstevel@tonic-gate  * utility routines
4937c478bd9Sstevel@tonic-gate  */
4947c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_charray_add( char ***a, char *s );
4957c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_charray_merge( char ***a, char **s );
4967c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_charray_free( char **array );
4977c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_charray_inlist( char **a, char *s );
4987c478bd9Sstevel@tonic-gate LDAP_API(char **) LDAP_CALL ldap_charray_dup( char **a );
4997c478bd9Sstevel@tonic-gate LDAP_API(char **) LDAP_CALL ldap_str2charray( char *str, char *brkstr );
5007c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_charray_position( char **a, char *s );
5017c478bd9Sstevel@tonic-gate 
5027c478bd9Sstevel@tonic-gate /*
5037c478bd9Sstevel@tonic-gate  * UTF-8 routines (should these move into libnls?)
5047c478bd9Sstevel@tonic-gate  */
5057c478bd9Sstevel@tonic-gate /* number of bytes in character */
5067c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8len( const char* );
5077c478bd9Sstevel@tonic-gate /* find next character */
5087c478bd9Sstevel@tonic-gate LDAP_API(char*) LDAP_CALL ldap_utf8next( char* );
5097c478bd9Sstevel@tonic-gate /* find previous character */
5107c478bd9Sstevel@tonic-gate LDAP_API(char*) LDAP_CALL ldap_utf8prev( char* );
5117c478bd9Sstevel@tonic-gate /* copy one character */
5127c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8copy( char* dst, const char* src );
5137c478bd9Sstevel@tonic-gate /* total number of characters */
5147c478bd9Sstevel@tonic-gate LDAP_API(size_t) LDAP_CALL ldap_utf8characters( const char* );
5157c478bd9Sstevel@tonic-gate /* get one UCS-4 character, and move *src to the next character */
5167c478bd9Sstevel@tonic-gate LDAP_API(unsigned long) LDAP_CALL ldap_utf8getcc( const char** src );
5177c478bd9Sstevel@tonic-gate /* UTF-8 aware strtok_r() */
5187c478bd9Sstevel@tonic-gate LDAP_API(char*) LDAP_CALL ldap_utf8strtok_r( char* src, const char* brk, char** next);
5197c478bd9Sstevel@tonic-gate 
5207c478bd9Sstevel@tonic-gate /* like isalnum(*s) in the C locale */
5217c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8isalnum( char* s );
5227c478bd9Sstevel@tonic-gate /* like isalpha(*s) in the C locale */
5237c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8isalpha( char* s );
5247c478bd9Sstevel@tonic-gate /* like isdigit(*s) in the C locale */
5257c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8isdigit( char* s );
5267c478bd9Sstevel@tonic-gate /* like isxdigit(*s) in the C locale */
5277c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8isxdigit(char* s );
5287c478bd9Sstevel@tonic-gate /* like isspace(*s) in the C locale */
5297c478bd9Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8isspace( char* s );
5307c478bd9Sstevel@tonic-gate 
5317c478bd9Sstevel@tonic-gate #define LDAP_UTF8LEN(s)  ((0x80 & *(unsigned char*)(s)) ?   ldap_utf8len (s) : 1)
5327c478bd9Sstevel@tonic-gate #define LDAP_UTF8NEXT(s) ((0x80 & *(unsigned char*)(s)) ?   ldap_utf8next(s) : (s)+1)
5337c478bd9Sstevel@tonic-gate #define LDAP_UTF8INC(s)  ((0x80 & *(unsigned char*)(s)) ? s=ldap_utf8next(s) : ++s)
5347c478bd9Sstevel@tonic-gate 
5357c478bd9Sstevel@tonic-gate #define LDAP_UTF8PREV(s)   ldap_utf8prev(s)
5367c478bd9Sstevel@tonic-gate #define LDAP_UTF8DEC(s) (s=ldap_utf8prev(s))
5377c478bd9Sstevel@tonic-gate 
5387c478bd9Sstevel@tonic-gate #define LDAP_UTF8COPY(d,s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8copy(d,s) : ((*(d) = *(s)), 1))
5397c478bd9Sstevel@tonic-gate #define LDAP_UTF8GETCC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc (&s) : *s++)
5407c478bd9Sstevel@tonic-gate #define LDAP_UTF8GETC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc ((const char**)&s) : *s++)
5417c478bd9Sstevel@tonic-gate 
5427c478bd9Sstevel@tonic-gate #ifdef __cplusplus
5437c478bd9Sstevel@tonic-gate }
5447c478bd9Sstevel@tonic-gate #endif
5457c478bd9Sstevel@tonic-gate #endif /* _SOLARISINT_H */
5467c478bd9Sstevel@tonic-gate 
547