d3d8/tests: Test the presentation parameters after creating an additional swap chain.
[wine.git] / libs / ldap / include / ldap_pvt.h
blob779da39586b54e5cab0100358b457edba0fc492f
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2022 The OpenLDAP Foundation.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
9 * Public License.
11 * A copy of this license is available in file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
16 /* ldap-pvt.h - Header for ldap_pvt_ functions.
17 * These are meant to be internal to OpenLDAP Software.
20 #ifndef _LDAP_PVT_H
21 #define _LDAP_PVT_H 1
23 #include <openldap.h> /* get public interfaces */
24 #include <lber.h> /* get ber_slen_t */
25 #include <lber_pvt.h> /* get Sockbuf_Buf */
27 LDAP_BEGIN_DECL
29 LDAP_F ( int )
30 ldap_pvt_url_scheme2proto LDAP_P((
31 const char * ));
32 LDAP_F ( int )
33 ldap_pvt_url_scheme2tls LDAP_P((
34 const char * ));
35 LDAP_F ( int )
36 ldap_pvt_url_scheme2proxied LDAP_P((
37 const char * ));
39 LDAP_F ( int )
40 ldap_pvt_url_scheme_port LDAP_P((
41 const char *, int ));
43 struct ldap_url_desc; /* avoid pulling in <ldap.h> */
45 #define LDAP_PVT_URL_PARSE_NONE (0x00U)
46 #define LDAP_PVT_URL_PARSE_NOEMPTY_HOST (0x01U)
47 #define LDAP_PVT_URL_PARSE_DEF_PORT (0x02U)
48 #define LDAP_PVT_URL_PARSE_NOEMPTY_DN (0x04U)
49 #define LDAP_PVT_URL_PARSE_NODEF_SCOPE (0x08U)
50 #define LDAP_PVT_URL_PARSE_HISTORIC (LDAP_PVT_URL_PARSE_NODEF_SCOPE | \
51 LDAP_PVT_URL_PARSE_NOEMPTY_HOST | \
52 LDAP_PVT_URL_PARSE_DEF_PORT)
54 LDAP_F( int )
55 ldap_url_parse_ext LDAP_P((
56 LDAP_CONST char *url,
57 struct ldap_url_desc **ludpp,
58 unsigned flags ));
60 LDAP_F (int) ldap_url_parselist LDAP_P(( /* deprecated, use ldap_url_parselist_ext() */
61 struct ldap_url_desc **ludlist,
62 const char *url ));
64 LDAP_F (int) ldap_url_parselist_ext LDAP_P((
65 struct ldap_url_desc **ludlist,
66 const char *url,
67 const char *sep,
68 unsigned flags ));
70 LDAP_F (char *) ldap_url_list2urls LDAP_P((
71 struct ldap_url_desc *ludlist ));
73 LDAP_F (void) ldap_free_urllist LDAP_P((
74 struct ldap_url_desc *ludlist ));
76 LDAP_F (int) ldap_pvt_scope2bv LDAP_P ((
77 int scope, struct berval *bv ));
79 LDAP_F (LDAP_CONST char *) ldap_pvt_scope2str LDAP_P ((
80 int scope ));
82 LDAP_F (int) ldap_pvt_bv2scope LDAP_P ((
83 struct berval *bv ));
85 LDAP_F (int) ldap_pvt_str2scope LDAP_P ((
86 LDAP_CONST char * ));
88 LDAP_F( char * )
89 ldap_pvt_ctime LDAP_P((
90 const time_t *tp,
91 char *buf ));
93 # if defined( HAVE_GMTIME_R )
94 # define USE_GMTIME_R
95 # define ldap_pvt_gmtime(timep, result) gmtime_r((timep), (result))
96 # else
97 LDAP_F( struct tm * )
98 ldap_pvt_gmtime LDAP_P((
99 LDAP_CONST time_t *timep,
100 struct tm *result ));
101 #endif
103 # if defined( HAVE_LOCALTIME_R )
104 # define USE_LOCALTIME_R
105 # define ldap_pvt_localtime(timep, result) localtime_r((timep), (result))
106 # else
107 LDAP_F( struct tm * )
108 ldap_pvt_localtime LDAP_P((
109 LDAP_CONST time_t *timep,
110 struct tm *result ));
111 # endif
113 #if defined( USE_GMTIME_R ) && defined( USE_LOCALTIME_R )
114 # define ldap_pvt_gmtime_lock() (0)
115 # define ldap_pvt_gmtime_unlock() (0)
116 #else
117 LDAP_F( int )
118 ldap_pvt_gmtime_lock LDAP_P(( void ));
120 LDAP_F( int )
121 ldap_pvt_gmtime_unlock LDAP_P(( void ));
122 #endif /* USE_GMTIME_R && USE_LOCALTIME_R */
124 /* Get current time as a structured time */
125 struct lutil_tm;
126 LDAP_F( void )
127 ldap_pvt_gettime LDAP_P(( struct lutil_tm * ));
129 #ifdef _WIN32
130 #define gettimeofday(tv,tz) ldap_pvt_gettimeofday(tv,tz)
131 struct timeval;
132 LDAP_F( int )
133 ldap_pvt_gettimeofday LDAP_P(( struct timeval *tv, void *unused ));
134 #ifndef CLOCK_REALTIME
135 #define CLOCK_REALTIME 0
136 #endif
137 #define clock_gettime(clkid,tv) ldap_pvt_clock_gettime(clkid,tv)
138 struct timespec;
139 LDAP_F( int )
140 ldap_pvt_clock_gettime LDAP_P(( int clkid, struct timespec *tv ));
141 #endif
143 /* use this macro to allocate buffer for ldap_pvt_csnstr */
144 #define LDAP_PVT_CSNSTR_BUFSIZE 64
145 LDAP_F( size_t )
146 ldap_pvt_csnstr( char *buf, size_t len, unsigned int replica, unsigned int mod );
148 LDAP_F( char *) ldap_pvt_get_fqdn LDAP_P(( char * ));
150 struct hostent; /* avoid pulling in <netdb.h> */
152 LDAP_F( int )
153 ldap_pvt_gethostbyname_a LDAP_P((
154 const char *name,
155 struct hostent *resbuf,
156 char **buf,
157 struct hostent **result,
158 int *herrno_ptr ));
160 LDAP_F( int )
161 ldap_pvt_gethostbyaddr_a LDAP_P((
162 const char *addr,
163 int len,
164 int type,
165 struct hostent *resbuf,
166 char **buf,
167 struct hostent **result,
168 int *herrno_ptr ));
170 struct sockaddr;
172 LDAP_F( int )
173 ldap_pvt_get_hname LDAP_P((
174 const struct sockaddr * sa,
175 int salen,
176 char *name,
177 int namelen,
178 char **herr ));
180 #ifdef LDAP_PF_LOCAL
181 #define LDAP_IPADDRLEN (MAXPATHLEN + sizeof("PATH="))
182 #elif defined(LDAP_PF_INET6)
183 #define LDAP_IPADDRLEN sizeof("IP=[ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]:65535")
184 #else
185 #define LDAP_IPADDRLEN sizeof("IP=255.255.255.255:65336")
186 #endif
188 union Sockaddr;
190 LDAP_F (void)
191 ldap_pvt_sockaddrstr LDAP_P((
192 union Sockaddr *sa,
193 struct berval * ));
196 /* charray.c */
198 LDAP_F( int )
199 ldap_charray_add LDAP_P((
200 char ***a,
201 const char *s ));
203 LDAP_F( int )
204 ldap_charray_merge LDAP_P((
205 char ***a,
206 char **s ));
208 LDAP_F( void )
209 ldap_charray_free LDAP_P(( char **a ));
211 LDAP_F( int )
212 ldap_charray_inlist LDAP_P((
213 char **a,
214 const char *s ));
216 LDAP_F( char ** )
217 ldap_charray_dup LDAP_P(( char **a ));
219 LDAP_F( char ** )
220 ldap_str2charray LDAP_P((
221 const char *str,
222 const char *brkstr ));
224 LDAP_F( char * )
225 ldap_charray2str LDAP_P((
226 char **array, const char* sep ));
228 /* getdn.c */
230 #ifdef LDAP_AVA_NULL /* in ldap.h */
231 LDAP_F( void ) ldap_rdnfree_x LDAP_P(( LDAPRDN rdn, void *ctx ));
232 LDAP_F( void ) ldap_dnfree_x LDAP_P(( LDAPDN dn, void *ctx ));
234 LDAP_F( int ) ldap_bv2dn_x LDAP_P((
235 struct berval *bv, LDAPDN *dn, unsigned flags, void *ctx ));
236 LDAP_F( int ) ldap_dn2bv_x LDAP_P((
237 LDAPDN dn, struct berval *bv, unsigned flags, void *ctx ));
238 LDAP_F( int ) ldap_bv2rdn_x LDAP_P((
239 struct berval *, LDAPRDN *, char **, unsigned flags, void *ctx ));
240 LDAP_F( int ) ldap_rdn2bv_x LDAP_P((
241 LDAPRDN rdn, struct berval *bv, unsigned flags, void *ctx ));
242 #endif /* LDAP_AVA_NULL */
244 /* url.c */
245 LDAP_F (void) ldap_pvt_hex_unescape LDAP_P(( char *s ));
248 * these macros assume 'x' is an ASCII x
249 * and assume the "C" locale
251 #define LDAP_ASCII(c) (!((c) & 0x80))
252 #define LDAP_SPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
253 #define LDAP_DIGIT(c) ((c) >= '0' && (c) <= '9')
254 #define LDAP_LOWER(c) ((c) >= 'a' && (c) <= 'z')
255 #define LDAP_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
256 #define LDAP_ALPHA(c) (LDAP_LOWER(c) || LDAP_UPPER(c))
257 #define LDAP_ALNUM(c) (LDAP_ALPHA(c) || LDAP_DIGIT(c))
259 #define LDAP_LDH(c) (LDAP_ALNUM(c) || (c) == '-')
261 #define LDAP_HEXLOWER(c) ((c) >= 'a' && (c) <= 'f')
262 #define LDAP_HEXUPPER(c) ((c) >= 'A' && (c) <= 'F')
263 #define LDAP_HEX(c) (LDAP_DIGIT(c) || \
264 LDAP_HEXLOWER(c) || LDAP_HEXUPPER(c))
266 /* controls.c */
267 struct ldapcontrol;
268 LDAP_F (int)
269 ldap_pvt_put_control LDAP_P((
270 const struct ldapcontrol *c,
271 BerElement *ber ));
272 LDAP_F (int) ldap_pvt_get_controls LDAP_P((
273 BerElement *be,
274 struct ldapcontrol ***ctrlsp));
276 #ifdef HAVE_CYRUS_SASL
277 /* cyrus.c */
278 struct sasl_security_properties; /* avoid pulling in <sasl.h> */
279 LDAP_F (int) ldap_pvt_sasl_secprops LDAP_P((
280 const char *in,
281 struct sasl_security_properties *secprops ));
282 LDAP_F (void) ldap_pvt_sasl_secprops_unparse LDAP_P((
283 struct sasl_security_properties *secprops,
284 struct berval *out ));
286 LDAP_F (void *) ldap_pvt_sasl_mutex_new LDAP_P((void));
287 LDAP_F (int) ldap_pvt_sasl_mutex_lock LDAP_P((void *mutex));
288 LDAP_F (int) ldap_pvt_sasl_mutex_unlock LDAP_P((void *mutex));
289 LDAP_F (void) ldap_pvt_sasl_mutex_dispose LDAP_P((void *mutex));
291 LDAP_F (int) ldap_pvt_sasl_cbinding_parse LDAP_P(( const char *arg ));
292 LDAP_F (void *) ldap_pvt_sasl_cbinding LDAP_P(( void *ssl, int type,
293 int is_server ));
294 #endif /* HAVE_CYRUS_SASL */
296 struct sockbuf; /* avoid pulling in <lber.h> */
297 LDAP_F (int) ldap_pvt_sasl_install LDAP_P(( struct sockbuf *, void * ));
298 LDAP_F (void) ldap_pvt_sasl_remove LDAP_P(( struct sockbuf * ));
301 * SASL encryption support for LBER Sockbufs
304 struct sb_sasl_generic_data;
306 struct sb_sasl_generic_ops {
307 void (*init)(struct sb_sasl_generic_data *p,
308 ber_len_t *min_send,
309 ber_len_t *max_send,
310 ber_len_t *max_recv);
311 ber_int_t (*encode)(struct sb_sasl_generic_data *p,
312 unsigned char *buf,
313 ber_len_t len,
314 Sockbuf_Buf *dst);
315 ber_int_t (*decode)(struct sb_sasl_generic_data *p,
316 const Sockbuf_Buf *src,
317 Sockbuf_Buf *dst);
318 void (*reset_buf)(struct sb_sasl_generic_data *p,
319 Sockbuf_Buf *buf);
320 void (*fini)(struct sb_sasl_generic_data *p);
323 struct sb_sasl_generic_install {
324 const struct sb_sasl_generic_ops *ops;
325 void *ops_private;
328 struct sb_sasl_generic_data {
329 const struct sb_sasl_generic_ops *ops;
330 void *ops_private;
331 Sockbuf_IO_Desc *sbiod;
332 ber_len_t min_send;
333 ber_len_t max_send;
334 ber_len_t max_recv;
335 Sockbuf_Buf sec_buf_in;
336 Sockbuf_Buf buf_in;
337 Sockbuf_Buf buf_out;
338 unsigned int flags;
339 #define LDAP_PVT_SASL_PARTIAL_WRITE 1
342 #ifndef LDAP_PVT_SASL_LOCAL_SSF
343 #define LDAP_PVT_SASL_LOCAL_SSF 71 /* SSF for Unix Domain Sockets */
344 #endif /* ! LDAP_PVT_SASL_LOCAL_SSF */
346 struct ldap;
347 struct ldapmsg;
348 struct ldifrecord;
350 /* abandon */
351 LDAP_F ( int ) ldap_pvt_discard LDAP_P((
352 struct ldap *ld, ber_int_t msgid ));
354 /* init.c */
355 LDAP_F( int )
356 ldap_pvt_conf_option LDAP_P((
357 char *cmd, char *opt, int userconf ));
359 /* ldifutil.c */
360 LDAP_F( int )
361 ldap_parse_ldif_record_x LDAP_P((
362 struct berval *rbuf,
363 unsigned long linenum,
364 struct ldifrecord *lr,
365 const char *errstr,
366 unsigned int flags,
367 void *ctx ));
369 /* messages.c */
370 LDAP_F( BerElement * )
371 ldap_get_message_ber LDAP_P((
372 struct ldapmsg * ));
374 /* open */
375 LDAP_F (int) ldap_open_internal_connection LDAP_P((
376 struct ldap **ldp, ber_socket_t *fdp ));
378 /* sasl.c */
379 LDAP_F (int) ldap_pvt_sasl_generic_install LDAP_P(( Sockbuf *sb,
380 struct sb_sasl_generic_install *install_arg ));
381 LDAP_F (void) ldap_pvt_sasl_generic_remove LDAP_P(( Sockbuf *sb ));
383 /* search.c */
384 LDAP_F( int ) ldap_pvt_put_filter LDAP_P((
385 BerElement *ber,
386 const char *str ));
388 LDAP_F( char * )
389 ldap_pvt_find_wildcard LDAP_P(( const char *s ));
391 LDAP_F( ber_slen_t )
392 ldap_pvt_filter_value_unescape LDAP_P(( char *filter ));
394 LDAP_F( ber_len_t )
395 ldap_bv2escaped_filter_value_len LDAP_P(( struct berval *in ));
397 LDAP_F( int )
398 ldap_bv2escaped_filter_value_x LDAP_P(( struct berval *in, struct berval *out,
399 int inplace, void *ctx ));
401 LDAP_F (int) ldap_pvt_search LDAP_P((
402 struct ldap *ld,
403 LDAP_CONST char *base,
404 int scope,
405 LDAP_CONST char *filter,
406 char **attrs,
407 int attrsonly,
408 struct ldapcontrol **sctrls,
409 struct ldapcontrol **cctrls,
410 struct timeval *timeout,
411 int sizelimit,
412 int deref,
413 int *msgidp ));
415 LDAP_F(int) ldap_pvt_search_s LDAP_P((
416 struct ldap *ld,
417 LDAP_CONST char *base,
418 int scope,
419 LDAP_CONST char *filter,
420 char **attrs,
421 int attrsonly,
422 struct ldapcontrol **sctrls,
423 struct ldapcontrol **cctrls,
424 struct timeval *timeout,
425 int sizelimit,
426 int deref,
427 struct ldapmsg **res ));
429 /* string.c */
430 LDAP_F( char * )
431 ldap_pvt_str2upper LDAP_P(( char *str ));
433 LDAP_F( char * )
434 ldap_pvt_str2lower LDAP_P(( char *str ));
436 LDAP_F( struct berval * )
437 ldap_pvt_str2upperbv LDAP_P(( char *str, struct berval *bv ));
439 LDAP_F( struct berval * )
440 ldap_pvt_str2lowerbv LDAP_P(( char *str, struct berval *bv ));
442 /* tls.c */
443 LDAP_F (int) ldap_pvt_tls_config LDAP_P(( struct ldap *ld,
444 int option, const char *arg ));
445 LDAP_F (int) ldap_pvt_tls_get_option LDAP_P(( struct ldap *ld,
446 int option, void *arg ));
447 LDAP_F (int) ldap_pvt_tls_set_option LDAP_P(( struct ldap *ld,
448 int option, void *arg ));
450 LDAP_F (void) ldap_pvt_tls_destroy LDAP_P(( void ));
451 LDAP_F (int) ldap_pvt_tls_init LDAP_P(( int do_threads ));
452 LDAP_F (int) ldap_pvt_tls_init_def_ctx LDAP_P(( int is_server ));
453 LDAP_F (int) ldap_pvt_tls_accept LDAP_P(( Sockbuf *sb, void *ctx_arg ));
454 LDAP_F (int) ldap_pvt_tls_connect LDAP_P(( struct ldap *ld, Sockbuf *sb, const char *host ));
455 LDAP_F (int) ldap_pvt_tls_inplace LDAP_P(( Sockbuf *sb ));
456 LDAP_F (void *) ldap_pvt_tls_sb_ctx LDAP_P(( Sockbuf *sb ));
457 LDAP_F (void) ldap_pvt_tls_ctx_free LDAP_P(( void * ));
459 typedef int LDAPDN_rewrite_dummy LDAP_P (( void *dn, unsigned flags ));
461 typedef int (LDAP_TLS_CONNECT_CB) LDAP_P (( struct ldap *ld, void *ssl,
462 void *ctx, void *arg ));
464 LDAP_F (int) ldap_pvt_tls_get_my_dn LDAP_P(( void *ctx, struct berval *dn,
465 LDAPDN_rewrite_dummy *func, unsigned flags ));
466 LDAP_F (int) ldap_pvt_tls_get_peer_dn LDAP_P(( void *ctx, struct berval *dn,
467 LDAPDN_rewrite_dummy *func, unsigned flags ));
468 LDAP_F (int) ldap_pvt_tls_get_strength LDAP_P(( void *ctx ));
469 LDAP_F (int) ldap_pvt_tls_get_unique LDAP_P(( void *ctx, struct berval *buf, int is_server ));
470 LDAP_F (int) ldap_pvt_tls_get_endpoint LDAP_P(( void *ctx, struct berval *buf, int is_server ));
471 LDAP_F (const char *) ldap_pvt_tls_get_version LDAP_P(( void *ctx ));
472 LDAP_F (const char *) ldap_pvt_tls_get_cipher LDAP_P(( void *ctx ));
474 LDAP_END_DECL
477 * Multiple precision stuff
479 * May use OpenSSL's BIGNUM if built with TLS,
480 * or GNU's multiple precision library. But if
481 * long long is available, that's big enough
482 * and much more efficient.
484 * If none is available, unsigned long data is used.
487 LDAP_BEGIN_DECL
489 #ifdef USE_MP_BIGNUM
491 * Use OpenSSL's BIGNUM
493 #include <openssl/crypto.h>
494 #include <openssl/bn.h>
496 typedef BIGNUM* ldap_pvt_mp_t;
497 #define LDAP_PVT_MP_INIT (NULL)
499 #define ldap_pvt_mp_init(mp) \
500 do { (mp) = BN_new(); } while (0)
502 /* FIXME: we rely on mpr being initialized */
503 #define ldap_pvt_mp_init_set(mpr,mpv) \
504 do { ldap_pvt_mp_init((mpr)); BN_add((mpr), (mpr), (mpv)); } while (0)
506 #define ldap_pvt_mp_add(mpr,mpv) \
507 BN_add((mpr), (mpr), (mpv))
509 #define ldap_pvt_mp_add_ulong(mp,v) \
510 BN_add_word((mp), (v))
512 #define ldap_pvt_mp_clear(mp) \
513 do { BN_free((mp)); (mp) = 0; } while (0)
515 #elif defined(USE_MP_GMP)
517 * Use GNU's multiple precision library
519 #include <gmp.h>
521 typedef mpz_t ldap_pvt_mp_t;
522 #define LDAP_PVT_MP_INIT { 0 }
524 #define ldap_pvt_mp_init(mp) \
525 mpz_init((mp))
527 #define ldap_pvt_mp_init_set(mpr,mpv) \
528 mpz_init_set((mpr), (mpv))
530 #define ldap_pvt_mp_add(mpr,mpv) \
531 mpz_add((mpr), (mpr), (mpv))
533 #define ldap_pvt_mp_add_ulong(mp,v) \
534 mpz_add_ui((mp), (mp), (v))
536 #define ldap_pvt_mp_clear(mp) \
537 mpz_clear((mp))
539 #else
541 * Use unsigned long long
544 #ifdef USE_MP_LONG_LONG
545 typedef unsigned long long ldap_pvt_mp_t;
546 #define LDAP_PVT_MP_INIT (0LL)
547 #elif defined(USE_MP_LONG)
548 typedef unsigned long ldap_pvt_mp_t;
549 #define LDAP_PVT_MP_INIT (0L)
550 #elif defined(HAVE_LONG_LONG)
551 typedef unsigned long long ldap_pvt_mp_t;
552 #define LDAP_PVT_MP_INIT (0LL)
553 #else
554 typedef unsigned long ldap_pvt_mp_t;
555 #define LDAP_PVT_MP_INIT (0L)
556 #endif
558 #define ldap_pvt_mp_init(mp) \
559 do { (mp) = 0; } while (0)
561 #define ldap_pvt_mp_init_set(mpr,mpv) \
562 do { (mpr) = (mpv); } while (0)
564 #define ldap_pvt_mp_add(mpr,mpv) \
565 do { (mpr) += (mpv); } while (0)
567 #define ldap_pvt_mp_add_ulong(mp,v) \
568 do { (mp) += (v); } while (0)
570 #define ldap_pvt_mp_clear(mp) \
571 do { (mp) = 0; } while (0)
573 #endif /* MP */
575 #include "ldap_pvt_uc.h"
577 LDAP_END_DECL
579 LDAP_BEGIN_DECL
581 #include <limits.h> /* get CHAR_BIT */
583 /* Buffer space for sign, decimal digits and \0. Note: log10(2) < 146/485. */
584 #define LDAP_PVT_INTTYPE_CHARS(type) (((sizeof(type)*CHAR_BIT-1)*146)/485 + 3)
586 LDAP_END_DECL
588 #endif /* _LDAP_PVT_H */