1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
7*7c478bd9Sstevel@tonic-gate 
8*7c478bd9Sstevel@tonic-gate /*
9*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the Netscape Public
10*7c478bd9Sstevel@tonic-gate  * License Version 1.1 (the "License"); you may not use this file
11*7c478bd9Sstevel@tonic-gate  * except in compliance with the License. You may obtain a copy of
12*7c478bd9Sstevel@tonic-gate  * the License at http://www.mozilla.org/NPL/
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * Software distributed under the License is distributed on an "AS
15*7c478bd9Sstevel@tonic-gate  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16*7c478bd9Sstevel@tonic-gate  * implied. See the License for the specific language governing
17*7c478bd9Sstevel@tonic-gate  * rights and limitations under the License.
18*7c478bd9Sstevel@tonic-gate  *
19*7c478bd9Sstevel@tonic-gate  * The Original Code is Mozilla Communicator client code, released
20*7c478bd9Sstevel@tonic-gate  * March 31, 1998.
21*7c478bd9Sstevel@tonic-gate  *
22*7c478bd9Sstevel@tonic-gate  * The Initial Developer of the Original Code is Netscape
23*7c478bd9Sstevel@tonic-gate  * Communications Corporation. Portions created by Netscape are
24*7c478bd9Sstevel@tonic-gate  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
25*7c478bd9Sstevel@tonic-gate  * Rights Reserved.
26*7c478bd9Sstevel@tonic-gate  *
27*7c478bd9Sstevel@tonic-gate  * Contributor(s):
28*7c478bd9Sstevel@tonic-gate  */
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #ifndef LDAP_PR_H
31*7c478bd9Sstevel@tonic-gate #define LDAP_PR_H
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #include "nspr.h"
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate /*
36*7c478bd9Sstevel@tonic-gate  * ldappr.h - prototypes for functions that tie libldap into NSPR (Netscape
37*7c478bd9Sstevel@tonic-gate  *	Portable Runtime).
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
41*7c478bd9Sstevel@tonic-gate extern "C" {
42*7c478bd9Sstevel@tonic-gate #endif
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate /*
45*7c478bd9Sstevel@tonic-gate  * Function: prldap_init().
46*7c478bd9Sstevel@tonic-gate  *
47*7c478bd9Sstevel@tonic-gate  * Create a new LDAP session handle, but with NSPR I/O, threading, and DNS
48*7c478bd9Sstevel@tonic-gate  * functions installed.
49*7c478bd9Sstevel@tonic-gate  *
50*7c478bd9Sstevel@tonic-gate  * Pass a non-zero value for the 'shared' parameter if you plan to use
51*7c478bd9Sstevel@tonic-gate  * this LDAP * handle from more than one thread.
52*7c478bd9Sstevel@tonic-gate  *
53*7c478bd9Sstevel@tonic-gate  * Returns an LDAP session handle (or NULL if an error occurs).
54*7c478bd9Sstevel@tonic-gate  */
55*7c478bd9Sstevel@tonic-gate LDAP * LDAP_CALL prldap_init( const char *defhost, int defport, int shared );
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate /*
59*7c478bd9Sstevel@tonic-gate  * Function: prldap_install_routines().
60*7c478bd9Sstevel@tonic-gate  *
61*7c478bd9Sstevel@tonic-gate  * Install NSPR I/O, threading, and DNS functions so they will be used by
62*7c478bd9Sstevel@tonic-gate  * 'ld'.
63*7c478bd9Sstevel@tonic-gate  *
64*7c478bd9Sstevel@tonic-gate  * If 'ld' is NULL, the functions are installed as the default functions
65*7c478bd9Sstevel@tonic-gate  * for all new LDAP * handles).
66*7c478bd9Sstevel@tonic-gate  *
67*7c478bd9Sstevel@tonic-gate  * Pass a non-zero value for the 'shared' parameter if you plan to use
68*7c478bd9Sstevel@tonic-gate  * this LDAP * handle from more than one thread.
69*7c478bd9Sstevel@tonic-gate  *
70*7c478bd9Sstevel@tonic-gate  * Returns an LDAP API error code (LDAP_SUCCESS if all goes well).
71*7c478bd9Sstevel@tonic-gate  */
72*7c478bd9Sstevel@tonic-gate int LDAP_CALL prldap_install_routines( LDAP *ld, int shared );
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate #ifndef _SOLARIS_SDK    /* Not used, left in to stay in sync with iplanet */
76*7c478bd9Sstevel@tonic-gate /*
77*7c478bd9Sstevel@tonic-gate  * Function: prldap_set_session_option().
78*7c478bd9Sstevel@tonic-gate  *
79*7c478bd9Sstevel@tonic-gate  * Given an LDAP session handle or a session argument such is passed to
80*7c478bd9Sstevel@tonic-gate  * CONNECT, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks, set
81*7c478bd9Sstevel@tonic-gate  * an option that affects the prldap layer.
82*7c478bd9Sstevel@tonic-gate  *
83*7c478bd9Sstevel@tonic-gate  * If 'ld' and 'session" are both NULL, the option is set as the default
84*7c478bd9Sstevel@tonic-gate  * for all new prldap sessions.
85*7c478bd9Sstevel@tonic-gate  *
86*7c478bd9Sstevel@tonic-gate  * Returns an LDAP API error code (LDAP_SUCCESS if all goes well).
87*7c478bd9Sstevel@tonic-gate  */
88*7c478bd9Sstevel@tonic-gate int LDAP_CALL prldap_set_session_option( LDAP *ld, void *sessionarg,
89*7c478bd9Sstevel@tonic-gate 	int option, ... );
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate /*
93*7c478bd9Sstevel@tonic-gate  * Function: prldap_get_session_option().
94*7c478bd9Sstevel@tonic-gate  *
95*7c478bd9Sstevel@tonic-gate  * Given an LDAP session handle or a session argument such is passed to
96*7c478bd9Sstevel@tonic-gate  * CONNECT, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks, retrieve
97*7c478bd9Sstevel@tonic-gate  * the setting for an option that affects the prldap layer.
98*7c478bd9Sstevel@tonic-gate  *
99*7c478bd9Sstevel@tonic-gate  * If 'ld' and 'session" are both NULL, the default option value for all new
100*7c478bd9Sstevel@tonic-gate  * new prldap sessions is retrieved.
101*7c478bd9Sstevel@tonic-gate  *
102*7c478bd9Sstevel@tonic-gate  * Returns an LDAP API error code (LDAP_SUCCESS if all goes well).
103*7c478bd9Sstevel@tonic-gate  */
104*7c478bd9Sstevel@tonic-gate int LDAP_CALL prldap_get_session_option( LDAP *ld, void *sessionarg,
105*7c478bd9Sstevel@tonic-gate 	int option, ... );
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate /*
110*7c478bd9Sstevel@tonic-gate  * Available options.
111*7c478bd9Sstevel@tonic-gate  */
112*7c478bd9Sstevel@tonic-gate /*
113*7c478bd9Sstevel@tonic-gate  * PRLDAP_OPT_IO_MAX_TIMEOUT: set the maximum time in milliseconds to
114*7c478bd9Sstevel@tonic-gate  * block waiting for a network I/O operation to complete.
115*7c478bd9Sstevel@tonic-gate  *
116*7c478bd9Sstevel@tonic-gate  * Data type: int.
117*7c478bd9Sstevel@tonic-gate  *
118*7c478bd9Sstevel@tonic-gate  * These two special values from ldap-extension.h can also be used;
119*7c478bd9Sstevel@tonic-gate  *
120*7c478bd9Sstevel@tonic-gate  *    LDAP_X_IO_TIMEOUT_NO_TIMEOUT
121*7c478bd9Sstevel@tonic-gate  *    LDAP_X_IO_TIMEOUT_NO_WAIT
122*7c478bd9Sstevel@tonic-gate  */
123*7c478bd9Sstevel@tonic-gate #define PRLDAP_OPT_IO_MAX_TIMEOUT		1
124*7c478bd9Sstevel@tonic-gate #endif	/* !_SOLARIS_SDK */
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate /**
128*7c478bd9Sstevel@tonic-gate  ** Note: the types and functions below are only useful for developers
129*7c478bd9Sstevel@tonic-gate  ** who need to layer one or more custom extended I/O functions on top of
130*7c478bd9Sstevel@tonic-gate  ** the standard NSPR I/O functions installed by a call to prldap_init()
131*7c478bd9Sstevel@tonic-gate  ** or prldap_install_routines().  Layering can be accomplished after
132*7c478bd9Sstevel@tonic-gate  ** prldap_init() or prldap_install_routines() has completed successfully
133*7c478bd9Sstevel@tonic-gate  ** by:
134*7c478bd9Sstevel@tonic-gate  **
135*7c478bd9Sstevel@tonic-gate  **   1) Calling ldap_get_option( ..., LDAP_X_OPT_EXTIO_FN_PTRS, ... ).
136*7c478bd9Sstevel@tonic-gate  **
137*7c478bd9Sstevel@tonic-gate  **   2) Saving the function pointer of one or more of the standard functions.
138*7c478bd9Sstevel@tonic-gate  **
139*7c478bd9Sstevel@tonic-gate  **   3) Replacing one or more standard functions in the ldap_x_ext_io_fns
140*7c478bd9Sstevel@tonic-gate  **      struct	with new functions that optionally do some preliminary work,
141*7c478bd9Sstevel@tonic-gate  **      call the standard function (via the function pointer saved in step 2),
142*7c478bd9Sstevel@tonic-gate  **      and optionally do some followup work.
143*7c478bd9Sstevel@tonic-gate  */
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate /*
146*7c478bd9Sstevel@tonic-gate  * Data structure for session information.
147*7c478bd9Sstevel@tonic-gate  * seinfo_size should be set to PRLDAP_SESSIONINFO_SIZE before use.
148*7c478bd9Sstevel@tonic-gate  */
149*7c478bd9Sstevel@tonic-gate struct prldap_session_private;
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate typedef struct prldap_session_info {
152*7c478bd9Sstevel@tonic-gate 	int				seinfo_size;
153*7c478bd9Sstevel@tonic-gate 	struct prldap_session_private	*seinfo_appdata;
154*7c478bd9Sstevel@tonic-gate } PRLDAPSessionInfo;
155*7c478bd9Sstevel@tonic-gate #define PRLDAP_SESSIONINFO_SIZE	sizeof( PRLDAPSessionInfo )
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate /*
159*7c478bd9Sstevel@tonic-gate  * Function: prldap_set_session_info().
160*7c478bd9Sstevel@tonic-gate  *
161*7c478bd9Sstevel@tonic-gate  * Given an LDAP session handle or a session argument such is passed to
162*7c478bd9Sstevel@tonic-gate  * CONNECT, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks,
163*7c478bd9Sstevel@tonic-gate  * set some application-specific data.  If ld is NULL, arg is used.  If
164*7c478bd9Sstevel@tonic-gate  * both ld and arg are NULL, LDAP_PARAM_ERROR is returned.
165*7c478bd9Sstevel@tonic-gate  *
166*7c478bd9Sstevel@tonic-gate  * Returns an LDAP API error code (LDAP_SUCCESS if all goes well).
167*7c478bd9Sstevel@tonic-gate  */
168*7c478bd9Sstevel@tonic-gate int LDAP_CALL prldap_set_session_info( LDAP *ld, void *sessionarg,
169*7c478bd9Sstevel@tonic-gate 	PRLDAPSessionInfo *seip );
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate /*
173*7c478bd9Sstevel@tonic-gate  * Function: prldap_get_session_info().
174*7c478bd9Sstevel@tonic-gate  *
175*7c478bd9Sstevel@tonic-gate  * Given an LDAP session handle or a session argument such is passed to
176*7c478bd9Sstevel@tonic-gate  * CONNECT, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks,
177*7c478bd9Sstevel@tonic-gate  * retrieve some application-specific data.  If ld is NULL, arg is used.  If
178*7c478bd9Sstevel@tonic-gate  * both ld and arg are NULL, LDAP_PARAM_ERROR is returned.
179*7c478bd9Sstevel@tonic-gate  *
180*7c478bd9Sstevel@tonic-gate  * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
181*7c478bd9Sstevel@tonic-gate  * which case the fields in the structure that seip points to are filled in).
182*7c478bd9Sstevel@tonic-gate  */
183*7c478bd9Sstevel@tonic-gate int LDAP_CALL prldap_get_session_info( LDAP *ld, void *sessionarg,
184*7c478bd9Sstevel@tonic-gate 	PRLDAPSessionInfo *seip );
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate 
187*7c478bd9Sstevel@tonic-gate /*
188*7c478bd9Sstevel@tonic-gate  * Data structure for socket specific information.
189*7c478bd9Sstevel@tonic-gate  * Note: soinfo_size should be set to PRLDAP_SOCKETINFO_SIZE before use.
190*7c478bd9Sstevel@tonic-gate  */
191*7c478bd9Sstevel@tonic-gate struct prldap_socket_private;
192*7c478bd9Sstevel@tonic-gate typedef struct prldap_socket_info {
193*7c478bd9Sstevel@tonic-gate 	int				soinfo_size;
194*7c478bd9Sstevel@tonic-gate 	PRFileDesc			*soinfo_prfd;
195*7c478bd9Sstevel@tonic-gate 	struct prldap_socket_private	*soinfo_appdata;
196*7c478bd9Sstevel@tonic-gate } PRLDAPSocketInfo;
197*7c478bd9Sstevel@tonic-gate #define PRLDAP_SOCKETINFO_SIZE	sizeof( PRLDAPSocketInfo )
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate 
200*7c478bd9Sstevel@tonic-gate /*
201*7c478bd9Sstevel@tonic-gate  * Function: prldap_set_socket_info().
202*7c478bd9Sstevel@tonic-gate  *
203*7c478bd9Sstevel@tonic-gate  * Given an integer fd and a socket argument such as those passed to the
204*7c478bd9Sstevel@tonic-gate  * extended I/O callback functions, set socket specific information.
205*7c478bd9Sstevel@tonic-gate  *
206*7c478bd9Sstevel@tonic-gate  * Returns an LDAP API error code (LDAP_SUCCESS if all goes well).
207*7c478bd9Sstevel@tonic-gate  *
208*7c478bd9Sstevel@tonic-gate  * Note: it is only safe to change soinfo_prfd from within the SOCKET
209*7c478bd9Sstevel@tonic-gate  * extended I/O callback function.
210*7c478bd9Sstevel@tonic-gate  */
211*7c478bd9Sstevel@tonic-gate int LDAP_CALL prldap_set_socket_info( int fd, void *socketarg,
212*7c478bd9Sstevel@tonic-gate 					PRLDAPSocketInfo *soip );
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate /*
215*7c478bd9Sstevel@tonic-gate  * Function: prldap_get_socket_info().
216*7c478bd9Sstevel@tonic-gate  *
217*7c478bd9Sstevel@tonic-gate  * Given an integer fd and a socket argument such as those passed to the
218*7c478bd9Sstevel@tonic-gate  * extended I/O callback functions, retrieve socket specific information.
219*7c478bd9Sstevel@tonic-gate  *
220*7c478bd9Sstevel@tonic-gate  * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
221*7c478bd9Sstevel@tonic-gate  * which case the fields in the structure that soip points to are filled in).
222*7c478bd9Sstevel@tonic-gate  */
223*7c478bd9Sstevel@tonic-gate int LDAP_CALL prldap_get_socket_info( int fd, void *socketarg,
224*7c478bd9Sstevel@tonic-gate 					PRLDAPSocketInfo *soip );
225*7c478bd9Sstevel@tonic-gate 
226*7c478bd9Sstevel@tonic-gate /*
227*7c478bd9Sstevel@tonic-gate  * Function: prldap_get_default_socket_info().
228*7c478bd9Sstevel@tonic-gate  *
229*7c478bd9Sstevel@tonic-gate  * Given an LDAP session handle, retrieve socket specific information.
230*7c478bd9Sstevel@tonic-gate  * If ld is NULL, LDAP_PARAM_ERROR is returned.
231*7c478bd9Sstevel@tonic-gate  *
232*7c478bd9Sstevel@tonic-gate  * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
233*7c478bd9Sstevel@tonic-gate  * which case the fields in the structure that soip points to are filled in).
234*7c478bd9Sstevel@tonic-gate  */
235*7c478bd9Sstevel@tonic-gate int LDAP_CALL prldap_get_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip );
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate /*
238*7c478bd9Sstevel@tonic-gate  * Function: prldap_set_default_socket_info().
239*7c478bd9Sstevel@tonic-gate  *
240*7c478bd9Sstevel@tonic-gate  * Given an LDAP session handle, set socket specific information.
241*7c478bd9Sstevel@tonic-gate  * If ld is NULL, LDAP_PARAM_ERROR is returned.
242*7c478bd9Sstevel@tonic-gate  *
243*7c478bd9Sstevel@tonic-gate  * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
244*7c478bd9Sstevel@tonic-gate  * which case the fields in the structure that soip points to are filled in).
245*7c478bd9Sstevel@tonic-gate  */
246*7c478bd9Sstevel@tonic-gate int LDAP_CALL prldap_set_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip );
247*7c478bd9Sstevel@tonic-gate 
248*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
249*7c478bd9Sstevel@tonic-gate }
250*7c478bd9Sstevel@tonic-gate #endif
251*7c478bd9Sstevel@tonic-gate #endif /* !defined(LDAP_PR_H) */
252