xref: /titanic_41/usr/src/lib/libldap5/include/ldap/solaris-int.h (revision ba2e4443695ee6a6f420a35cd4fc3d3346d22932)
1 /*
2  * Copyright 2001-2003 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 #ifndef _SOLARISINT_H
9 #define _SOLARISINT_H
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <stdio.h>
16 #include <ctype.h>
17 #include <stdarg.h>
18 #include <stdlib.h>
19 
20 #include "ldap.h"
21 
22 /*
23  * These were moved from lber.h. This should have been ifdef'd with
24  * _SOLARIS_SDK but since we do not want to expose these in lber.h its
25  * not possible to ifndef it there.
26  */
27 
28 /* BerElement set/get options */
29 #define LBER_OPT_REMAINING_BYTES	0x01
30 #define LBER_OPT_TOTAL_BYTES		0x02
31 #define LBER_OPT_USE_DER		0x04
32 #define LBER_OPT_TRANSLATE_STRINGS	0x08
33 #define LBER_OPT_BYTES_TO_WRITE		0x10
34 #define LBER_OPT_MEMALLOC_FN_PTRS	0x20
35 #define LBER_OPT_DEBUG_LEVEL		0x40
36 /*
37  * LBER_USE_DER is defined for compatibility with the C LDAP API RFC.
38  * In our implementation, we recognize it (instead of the numerically
39  * identical LBER_OPT_REMAINING_BYTES) in calls to ber_alloc_t() and
40  * ber_init_w_nullchar() only.  Callers of ber_set_option() or
41  * ber_get_option() must use LBER_OPT_USE_DER instead.  Sorry!
42  */
43 #define LBER_USE_DER			0x01
44 
45 /* Sockbuf set/get options */
46 #define LBER_SOCKBUF_OPT_TO_FILE		0x001
47 #define LBER_SOCKBUF_OPT_TO_FILE_ONLY		0x002
48 #define LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE	0x004
49 #define LBER_SOCKBUF_OPT_NO_READ_AHEAD		0x008
50 #define LBER_SOCKBUF_OPT_DESC			0x010
51 #define LBER_SOCKBUF_OPT_COPYDESC		0x020
52 #define LBER_SOCKBUF_OPT_READ_FN		0x040
53 #define LBER_SOCKBUF_OPT_WRITE_FN		0x080
54 #define LBER_SOCKBUF_OPT_EXT_IO_FNS		0x100
55 
56 #ifndef _SOLARIS_SDK
57 /*
58  * The following is not used by solaris. Just kept to stay in sync with
59  * iplanet and also a place holder (0x200)
60  */
61 #define LBER_SOCKBUF_OPT_VALID_TAG              0x200
62 #endif	/* !_SOLARIS_SDK */
63 
64 /*
65  * Socket buffer structure associated to the LDAP connection
66  */
67 #define LDAP_X_OPT_SOCKBUF	(LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F02)
68 	/* 0x4000 + 0x0F02 = 0x4F02 = 20226 - API extension */
69 
70 
71 #define LBER_OPT_ON	((void *) 1)
72 #define LBER_OPT_OFF	((void *) 0)
73 
74 /* Used in various functions */
75 #define LBER_FUNC_VALUE		-1
76 
77 struct lextiof_socket_private;          /* Defined by the extended I/O */
78                                         /* callback functions */
79 struct lextiof_session_private;         /* Defined by the extended I/O */
80                                         /* callback functions */
81 
82 /* This is modeled after the PRIOVec that is passed to the NSPR
83    writev function! The void* is a char* in that struct */
84 typedef struct ldap_x_iovec {
85         char    *ldapiov_base;
86         int     ldapiov_len;
87 } ldap_x_iovec;
88 
89 /*
90  * libldap read and write I/O function callbacks.  The rest of the I/O callback
91  * types are defined in ldap.h
92  */
93 typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_READ_CALLBACK)( LBER_SOCKET s,
94 	void *buf, int bufsize );
95 typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_WRITE_CALLBACK)( LBER_SOCKET s,
96 	const void *buf, int len );
97 typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_READ_CALLBACK)( int s,
98 	void *buf, int bufsize, struct lextiof_socket_private *arg );
99 typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_WRITE_CALLBACK)( int s,
100 	const void *buf, int len, struct lextiof_socket_private *arg );
101 typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_WRITEV_CALLBACK)(int s,
102         const ldap_x_iovec iov[], int iovcnt, struct lextiof_socket_private *socketarg);
103 
104 
105 /*
106  * Structure for use with LBER_SOCKBUF_OPT_EXT_IO_FNS:
107  */
108 struct lber_x_ext_io_fns {
109 	    /* lbextiofn_size should always be set to LBER_X_EXTIO_FNS_SIZE */
110 	int				lbextiofn_size;
111 	LDAP_X_EXTIOF_READ_CALLBACK	*lbextiofn_read;
112 	LDAP_X_EXTIOF_WRITE_CALLBACK	*lbextiofn_write;
113 	struct lextiof_socket_private	*lbextiofn_socket_arg;
114         LDAP_X_EXTIOF_WRITEV_CALLBACK   *lbextiofn_writev;
115 };
116 #define LBER_X_EXTIO_FNS_SIZE sizeof(struct lber_x_ext_io_fns)
117 
118 /*
119  * liblber memory allocation callback functions.  These are global to all
120  *  Sockbufs and BerElements.  Install your own functions by using a call
121  *  like this: ber_set_option( NULL, LBER_OPT_MEMALLOC_FN_PTRS, &memalloc_fns );
122  */
123 typedef void * (LDAP_C LDAP_CALLBACK LDAP_MALLOC_CALLBACK)( size_t size );
124 typedef void * (LDAP_C LDAP_CALLBACK LDAP_CALLOC_CALLBACK)( size_t nelem,
125 	size_t elsize );
126 typedef void * (LDAP_C LDAP_CALLBACK LDAP_REALLOC_CALLBACK)( void *ptr,
127 	size_t size );
128 typedef void (LDAP_C LDAP_CALLBACK LDAP_FREE_CALLBACK)( void *ptr );
129 
130 struct lber_memalloc_fns {
131 	LDAP_MALLOC_CALLBACK	*lbermem_malloc;
132 	LDAP_CALLOC_CALLBACK	*lbermem_calloc;
133 	LDAP_REALLOC_CALLBACK	*lbermem_realloc;
134 	LDAP_FREE_CALLBACK	*lbermem_free;
135 };
136 
137 /*
138  * Functions marked as Project Private in PSARC case and moved
139  * from lber.h
140  */
141 typedef struct sockbuf Sockbuf;
142 
143 LDAP_API(void) LDAP_CALL ber_special_free(void* buf, BerElement *ber);
144 LDAP_API(void*) LDAP_CALL ber_special_alloc(size_t size, BerElement **ppBer);
145 LDAP_API(ber_uint_t) LDAP_CALL ber_get_next_buffer( void *buffer,
146 	size_t buffer_size, ber_len_t *len, BerElement *ber,
147 	ber_uint_t *Bytes_Scanned );
148 LDAP_API(ber_uint_t) LDAP_CALL ber_get_next_buffer_ext( void *buffer,
149 	size_t buffer_size, ber_len_t *len, BerElement *ber,
150 	ber_len_t *Bytes_Scanned, Sockbuf *sb );
151 LDAP_API(void) LDAP_CALL ber_init_w_nullchar( BerElement *ber, int options );
152 LDAP_API(int) LDAP_CALL ber_set_option( BerElement *ber, int option,
153 	void *value );
154 LDAP_API(int) LDAP_CALL ber_get_option( BerElement *ber, int option,
155 	void *value );
156 LDAP_API(Sockbuf*) LDAP_CALL ber_sockbuf_alloc( void );
157 LDAP_API(void) LDAP_CALL ber_sockbuf_free( Sockbuf* p );
158 LDAP_API(int) LDAP_CALL ber_sockbuf_set_option( Sockbuf *sb, int option,
159 	void *value );
160 LDAP_API(int) LDAP_CALL ber_sockbuf_get_option( Sockbuf *sb, int option,
161 	void *value );
162 LDAP_API(int) LDAP_CALL ber_flush( Sockbuf *sb, BerElement *ber, int freeit );
163 LDAP_API(ber_tag_t) LDAP_CALL ber_get_next( Sockbuf *sb, ber_len_t *len,
164 	BerElement *ber );
165 
166 /*
167  * The following was moved from ldap.h
168  */
169 
170 /*
171  * These extended I/O function callbacks echo the BSD socket API but accept
172  * an extra pointer parameter at the end of their argument list that can
173  * be used by client applications for their own needs.  For some of the calls,
174  * the pointer is a session argument of type struct lextiof_session_private *
175  * that is associated with the LDAP session handle (LDAP *).  For others, the
176  * pointer is a socket specific struct lextiof_socket_private * argument that
177  * is associated with a particular socket (a TCP connection).
178  *
179  * The lextiof_session_private and lextiof_socket_private structures are not
180  * defined by the LDAP C API; users of this extended I/O interface should
181  * define these themselves.
182  *
183  * The combination of the integer socket number (i.e., lpoll_fd, which is
184  * the value returned by the CONNECT callback) and the application specific
185  * socket argument (i.e., lpoll_socketarg, which is the value set in *sockargpp
186  * by the CONNECT callback) must be unique.
187  *
188  * The types for the extended READ and WRITE callbacks are actually in lber.h.
189  *
190  * The CONNECT callback gets passed both the session argument (sessionarg)
191  * and a pointer to a socket argument (socketargp) so it has the
192  * opportunity to set the socket-specific argument.  The CONNECT callback
193  * also takes a timeout parameter whose value can be set by calling
194  * ldap_set_option( ld, LDAP_X_OPT_..., &val ).  The units used for the
195  * timeout parameter are milliseconds.
196  *
197  * A POLL interface is provided instead of a select() one.  The timeout is
198  * in milliseconds.
199 
200  * A NEWHANDLE callback function is also provided.  It is called right
201  * after the LDAP session handle is created, e.g., during ldap_init().
202  * If the NEWHANDLE callback returns anything other than LDAP_SUCCESS,
203  * the session handle allocation fails.
204  *
205  * A DISPOSEHANDLE callback function is also provided.  It is called right
206  * before the LDAP session handle and its contents are destroyed, e.g.,
207  * during ldap_unbind().
208  */
209 
210 /* LDAP poll()-like descriptor:
211  */
212 typedef struct ldap_x_pollfd {	   /* used by LDAP_X_EXTIOF_POLL_CALLBACK */
213     int		lpoll_fd;	   /* integer file descriptor / socket */
214     struct lextiof_socket_private
215 		*lpoll_socketarg;
216 				   /* pointer socket and for use by */
217 				   /* application */
218     short	lpoll_events;      /* requested event */
219     short	lpoll_revents;     /* returned event */
220 } LDAP_X_PollFD;
221 
222 /* Event flags for lpoll_events and lpoll_revents:
223  */
224 #define LDAP_X_POLLIN    0x01  /* regular data ready for reading */
225 #define LDAP_X_POLLPRI   0x02  /* high priority data available */
226 #define LDAP_X_POLLOUT   0x04  /* ready for writing */
227 #define LDAP_X_POLLERR   0x08  /* error occurred -- only in lpoll_revents */
228 #define LDAP_X_POLLHUP   0x10  /* connection closed -- only in lpoll_revents */
229 #define LDAP_X_POLLNVAL  0x20  /* invalid lpoll_fd -- only in lpoll_revents */
230 
231 /* Options passed to LDAP_X_EXTIOF_CONNECT_CALLBACK to modify socket behavior:
232  */
233 #define LDAP_X_EXTIOF_OPT_NONBLOCKING	0x01  /* turn on non-blocking mode */
234 #define LDAP_X_EXTIOF_OPT_SECURE	0x02  /* turn on 'secure' mode */
235 
236 /* extended I/O callback function prototypes:
237  */
238 typedef int	(LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CONNECT_CALLBACK )(
239 	    const char *hostlist, int port, /* host byte order */
240 	    int timeout /* milliseconds */,
241 	    unsigned long options, /* bitmapped options */
242 	    struct lextiof_session_private *sessionarg,
243 	    struct lextiof_socket_private **socketargp
244 #ifdef _SOLARIS_SDK
245 		, void **datapriv );
246 #else
247 		);
248 #endif
249 typedef int	(LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CLOSE_CALLBACK )(
250 	    int s, struct lextiof_socket_private *socketarg );
251 typedef int	(LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_POLL_CALLBACK)(
252 	    LDAP_X_PollFD fds[], int nfds, int timeout /* milliseconds */,
253 	    struct lextiof_session_private *sessionarg );
254 typedef int	(LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_NEWHANDLE_CALLBACK)(
255 	    LDAP *ld, struct lextiof_session_private *sessionarg );
256 typedef void	(LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK)(
257 	    LDAP *ld, struct lextiof_session_private *sessionarg );
258 
259 
260 /* Structure to hold extended I/O function pointers:
261  */
262 struct ldap_x_ext_io_fns {
263 	/* lextiof_size should always be set to LDAP_X_EXTIO_FNS_SIZE */
264 	int					lextiof_size;
265 	LDAP_X_EXTIOF_CONNECT_CALLBACK		*lextiof_connect;
266 	LDAP_X_EXTIOF_CLOSE_CALLBACK		*lextiof_close;
267 	LDAP_X_EXTIOF_READ_CALLBACK		*lextiof_read;
268 	LDAP_X_EXTIOF_WRITE_CALLBACK		*lextiof_write;
269 	LDAP_X_EXTIOF_POLL_CALLBACK		*lextiof_poll;
270 	LDAP_X_EXTIOF_NEWHANDLE_CALLBACK	*lextiof_newhandle;
271 	LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK	*lextiof_disposehandle;
272 	void					*lextiof_session_arg;
273 	LDAP_X_EXTIOF_WRITEV_CALLBACK           *lextiof_writev;
274 };
275 #define LDAP_X_EXTIO_FNS_SIZE	sizeof(struct ldap_x_ext_io_fns)
276 
277 
278 /*
279  * Utility functions for parsing space-separated host lists (useful for
280  * implementing an extended I/O CONNECT callback function).
281  */
282 struct ldap_x_hostlist_status;
283 LDAP_API(int) LDAP_CALL ldap_x_hostlist_first( const char *hostlist,
284 	int defport, char **hostp, int *portp /* host byte order */,
285 	struct ldap_x_hostlist_status **statusp );
286 LDAP_API(int) LDAP_CALL ldap_x_hostlist_next( char **hostp,
287 	int *portp /* host byte order */, struct ldap_x_hostlist_status *status );
288 LDAP_API(void) LDAP_CALL ldap_x_hostlist_statusfree(
289 	struct ldap_x_hostlist_status *status );
290 
291 
292 /*
293  * I/O callback functions (note that types for the read and write callbacks
294  * are actually in lber.h):
295  */
296 typedef int	(LDAP_C LDAP_CALLBACK LDAP_IOF_SELECT_CALLBACK)( int nfds,
297 	fd_set *readfds, fd_set *writefds, fd_set *errorfds,
298 	struct timeval *timeout );
299 typedef LBER_SOCKET (LDAP_C LDAP_CALLBACK LDAP_IOF_SOCKET_CALLBACK)(
300 	int domain, int type, int protocol );
301 typedef int	(LDAP_C LDAP_CALLBACK LDAP_IOF_IOCTL_CALLBACK)( LBER_SOCKET s,
302 	int option, ... );
303 typedef int	(LDAP_C LDAP_CALLBACK LDAP_IOF_CONNECT_CALLBACK )(
304 	LBER_SOCKET s, struct sockaddr *name, int namelen );
305 typedef int	(LDAP_C LDAP_CALLBACK LDAP_IOF_CLOSE_CALLBACK )(
306 	LBER_SOCKET s );
307 typedef int	(LDAP_C LDAP_CALLBACK LDAP_IOF_SSL_ENABLE_CALLBACK )(
308 	LBER_SOCKET s );
309 
310 
311 /*
312  * Structure to hold I/O function pointers:
313  */
314 struct ldap_io_fns {
315 	LDAP_IOF_READ_CALLBACK *liof_read;
316 	LDAP_IOF_WRITE_CALLBACK *liof_write;
317 	LDAP_IOF_SELECT_CALLBACK *liof_select;
318 	LDAP_IOF_SOCKET_CALLBACK *liof_socket;
319 	LDAP_IOF_IOCTL_CALLBACK *liof_ioctl;
320 	LDAP_IOF_CONNECT_CALLBACK *liof_connect;
321 	LDAP_IOF_CLOSE_CALLBACK *liof_close;
322 	LDAP_IOF_SSL_ENABLE_CALLBACK *liof_ssl_enable;
323 };
324 
325 /********* the functions in the following section are experimental ***********/
326 
327 #define	LDAP_OPT_PREFERRED_LANGUAGE	0x14	/* 20 - API extension */
328 
329 /*
330  * SSL option (an API extension):
331  */
332 #define	LDAP_OPT_SSL			0x0A	/* 10 - API extension */
333 
334 /*
335  * Referral hop limit (an API extension):
336  */
337 #define	LDAP_OPT_REFERRAL_HOP_LIMIT	0x10	/* 16 - API extension */
338 
339 /*
340  * DNS resolver callbacks (an API extension --LDAP_API_FEATURE_X_DNS_FUNCTIONS).
341  * Note that gethostbyaddr() is not currently used.
342  */
343 #define	LDAP_OPT_DNS_FN_PTRS		0x60	/* 96 - API extension */
344 
345 typedef struct LDAPHostEnt {
346     char	*ldaphe_name;		/* official name of host */
347     char	**ldaphe_aliases;	/* alias list */
348     int		ldaphe_addrtype;	/* host address type */
349     int		ldaphe_length;		/* length of address */
350     char	**ldaphe_addr_list;	/* list of addresses from name server */
351 } LDAPHostEnt;
352 
353 typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYNAME)(
354 	const char *name, LDAPHostEnt *result, char *buffer,
355 	int buflen, int *statusp, void *extradata);
356 typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYADDR)(
357 	const char *addr, int length, int type, LDAPHostEnt *result,
358 	char *buffer, int buflen, int *statusp, void *extradata);
359 typedef int (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETPEERNAME)(
360 	LDAP *ld, struct sockaddr *netaddr, char *buffer, int buflen);
361 
362 struct ldap_dns_fns {
363 	void				*lddnsfn_extradata;
364 	int				lddnsfn_bufsize;
365 	LDAP_DNSFN_GETHOSTBYNAME	*lddnsfn_gethostbyname;
366 	LDAP_DNSFN_GETHOSTBYADDR	*lddnsfn_gethostbyaddr;
367 	LDAP_DNSFN_GETPEERNAME		*lddnsfn_getpeername;
368 };
369 
370 /*
371  * Generalized cache callback interface:
372  */
373 #define	LDAP_OPT_CACHE_FN_PTRS		0x0D	/* 13 - API extension */
374 #define	LDAP_OPT_CACHE_STRATEGY		0x0E	/* 14 - API extension */
375 #define	LDAP_OPT_CACHE_ENABLE		0x0F	/* 15 - API extension */
376 
377 /* cache strategies */
378 #define	LDAP_CACHE_CHECK		0
379 #define	LDAP_CACHE_POPULATE		1
380 #define	LDAP_CACHE_LOCALDB		2
381 
382 typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_BIND_CALLBACK)(LDAP *ld, int msgid,
383 	ber_tag_t tag, const char *dn, const struct berval *creds,
384 	int method);
385 typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_UNBIND_CALLBACK)(LDAP *ld,
386 	int unused0, unsigned long unused1);
387 typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_SEARCH_CALLBACK)(LDAP *ld,
388 	int msgid, ber_tag_t tag, const char *base, int scope,
389 	const char LDAP_CALLBACK *filter, char **attrs, int attrsonly);
390 typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_COMPARE_CALLBACK)(LDAP *ld,
391 	int msgid, ber_tag_t tag, const char *dn, const char *attr,
392 	const struct berval *value);
393 typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_ADD_CALLBACK)(LDAP *ld,
394 	int msgid, ber_tag_t tag, const char *dn, LDAPMod **attrs);
395 typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_DELETE_CALLBACK)(LDAP *ld,
396 	int msgid, ber_tag_t tag, const char *dn);
397 typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_MODIFY_CALLBACK)(LDAP *ld,
398 	int msgid, ber_tag_t tag, const char *dn, LDAPMod **mods);
399 typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_MODRDN_CALLBACK)(LDAP *ld,
400 	int msgid, ber_tag_t tag, const char *dn, const char *newrdn,
401 	int deleteoldrdn);
402 typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_RESULT_CALLBACK)(LDAP *ld,
403 	int msgid, int all, struct timeval *timeout, LDAPMessage **result);
404 typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_FLUSH_CALLBACK)(LDAP *ld,
405 	const char *dn, const char *filter);
406 
407 struct ldap_cache_fns {
408 	void    *lcf_private;
409 	LDAP_CF_BIND_CALLBACK *lcf_bind;
410 	LDAP_CF_UNBIND_CALLBACK *lcf_unbind;
411 	LDAP_CF_SEARCH_CALLBACK *lcf_search;
412 	LDAP_CF_COMPARE_CALLBACK *lcf_compare;
413 	LDAP_CF_ADD_CALLBACK *lcf_add;
414 	LDAP_CF_DELETE_CALLBACK *lcf_delete;
415 	LDAP_CF_MODIFY_CALLBACK *lcf_modify;
416 	LDAP_CF_MODRDN_CALLBACK *lcf_modrdn;
417 	LDAP_CF_RESULT_CALLBACK *lcf_result;
418 	LDAP_CF_FLUSH_CALLBACK *lcf_flush;
419 };
420 
421 int LDAP_CALL ldap_cache_flush(LDAP *ld, const char *dn,
422 	const char *filter);
423 
424 /*
425  * Memory allocation callback functions (an API extension --
426  * LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS).  These are global and can
427  * not be set on a per-LDAP session handle basis.  Install your own
428  * functions by making a call like this:
429  *    ldap_set_option( NULL, LDAP_OPT_MEMALLOC_FN_PTRS, &memalloc_fns );
430  *
431  * look in lber.h for the function typedefs themselves.
432  */
433 #define LDAP_OPT_MEMALLOC_FN_PTRS	0x61	/* 97 - API extension */
434 
435 struct ldap_memalloc_fns {
436 	LDAP_MALLOC_CALLBACK	*ldapmem_malloc;
437 	LDAP_CALLOC_CALLBACK	*ldapmem_calloc;
438 	LDAP_REALLOC_CALLBACK	*ldapmem_realloc;
439 	LDAP_FREE_CALLBACK	*ldapmem_free;
440 };
441 
442 
443 /*
444  * Memory allocation functions (an API extension)
445  */
446 void *ldap_x_malloc( size_t size );
447 void *ldap_x_calloc( size_t nelem, size_t elsize );
448 void *ldap_x_realloc( void *ptr, size_t size );
449 void ldap_x_free( void *ptr );
450 
451 /*
452  * Extra thread callback functions (an API extension --
453  * LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS)
454  */
455 #define LDAP_OPT_EXTRA_THREAD_FN_PTRS  0x65	/* 101 - API extension */
456 
457 typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_TRYLOCK_CALLBACK)( void *m );
458 typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_ALLOC_CALLBACK)( void );
459 typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_FREE_CALLBACK)( void *s );
460 typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_WAIT_CALLBACK)( void *s );
461 typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_POST_CALLBACK)( void *s );
462 typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_THREADID_CALLBACK)(void);
463 
464 struct ldap_extra_thread_fns {
465         LDAP_TF_MUTEX_TRYLOCK_CALLBACK *ltf_mutex_trylock;
466         LDAP_TF_SEMA_ALLOC_CALLBACK *ltf_sema_alloc;
467         LDAP_TF_SEMA_FREE_CALLBACK *ltf_sema_free;
468         LDAP_TF_SEMA_WAIT_CALLBACK *ltf_sema_wait;
469         LDAP_TF_SEMA_POST_CALLBACK *ltf_sema_post;
470 	LDAP_TF_THREADID_CALLBACK *ltf_threadid_fn;
471 };
472 
473 
474 /*
475  * Debugging level (an API extension)
476  */
477 #define LDAP_OPT_DEBUG_LEVEL		0x6E	/* 110 - API extension */
478 /* On UNIX, there's only one copy of ldap_debug */
479 /* On NT, each dll keeps its own module_ldap_debug, which */
480 /* points to the process' ldap_debug and needs initializing after load */
481 #ifdef _WIN32
482 extern int		*module_ldap_debug;
483 typedef void (*set_debug_level_fn_t)(int*);
484 #endif
485 
486 /************************ end of experimental section ************************/
487 
488 
489 LDAP_API(int) LDAP_CALL ldap_keysort_entries( LDAP *ld, LDAPMessage **chain,
490 	void *arg, LDAP_KEYGEN_CALLBACK *gen, LDAP_KEYCMP_CALLBACK *cmp,
491 	LDAP_KEYFREE_CALLBACK *fre );
492 
493 /*
494  * utility routines
495  */
496 LDAP_API(int) LDAP_CALL ldap_charray_add( char ***a, char *s );
497 LDAP_API(int) LDAP_CALL ldap_charray_merge( char ***a, char **s );
498 LDAP_API(void) LDAP_CALL ldap_charray_free( char **array );
499 LDAP_API(int) LDAP_CALL ldap_charray_inlist( char **a, char *s );
500 LDAP_API(char **) LDAP_CALL ldap_charray_dup( char **a );
501 LDAP_API(char **) LDAP_CALL ldap_str2charray( char *str, char *brkstr );
502 LDAP_API(int) LDAP_CALL ldap_charray_position( char **a, char *s );
503 
504 /*
505  * UTF-8 routines (should these move into libnls?)
506  */
507 /* number of bytes in character */
508 LDAP_API(int) LDAP_CALL ldap_utf8len( const char* );
509 /* find next character */
510 LDAP_API(char*) LDAP_CALL ldap_utf8next( char* );
511 /* find previous character */
512 LDAP_API(char*) LDAP_CALL ldap_utf8prev( char* );
513 /* copy one character */
514 LDAP_API(int) LDAP_CALL ldap_utf8copy( char* dst, const char* src );
515 /* total number of characters */
516 LDAP_API(size_t) LDAP_CALL ldap_utf8characters( const char* );
517 /* get one UCS-4 character, and move *src to the next character */
518 LDAP_API(unsigned long) LDAP_CALL ldap_utf8getcc( const char** src );
519 /* UTF-8 aware strtok_r() */
520 LDAP_API(char*) LDAP_CALL ldap_utf8strtok_r( char* src, const char* brk, char** next);
521 
522 /* like isalnum(*s) in the C locale */
523 LDAP_API(int) LDAP_CALL ldap_utf8isalnum( char* s );
524 /* like isalpha(*s) in the C locale */
525 LDAP_API(int) LDAP_CALL ldap_utf8isalpha( char* s );
526 /* like isdigit(*s) in the C locale */
527 LDAP_API(int) LDAP_CALL ldap_utf8isdigit( char* s );
528 /* like isxdigit(*s) in the C locale */
529 LDAP_API(int) LDAP_CALL ldap_utf8isxdigit(char* s );
530 /* like isspace(*s) in the C locale */
531 LDAP_API(int) LDAP_CALL ldap_utf8isspace( char* s );
532 
533 #define LDAP_UTF8LEN(s)  ((0x80 & *(unsigned char*)(s)) ?   ldap_utf8len (s) : 1)
534 #define LDAP_UTF8NEXT(s) ((0x80 & *(unsigned char*)(s)) ?   ldap_utf8next(s) : (s)+1)
535 #define LDAP_UTF8INC(s)  ((0x80 & *(unsigned char*)(s)) ? s=ldap_utf8next(s) : ++s)
536 
537 #define LDAP_UTF8PREV(s)   ldap_utf8prev(s)
538 #define LDAP_UTF8DEC(s) (s=ldap_utf8prev(s))
539 
540 #define LDAP_UTF8COPY(d,s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8copy(d,s) : ((*(d) = *(s)), 1))
541 #define LDAP_UTF8GETCC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc (&s) : *s++)
542 #define LDAP_UTF8GETC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc ((const char**)&s) : *s++)
543 
544 #ifdef __cplusplus
545 }
546 #endif
547 #endif /* _SOLARISINT_H */
548 
549