3 * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA
6 * Redistribution and use in source and binary forms are permitted only
7 * as authorized by the OpenLDAP Public License. A copy of this
8 * license is available at http://www.OpenLDAP.org/license.html or
9 * in file LICENSE in the top-level directory of the distribution.
12 * ldap-pvt.h - Header for ldap_pvt_ functions. These are meant to be used
13 * by the OpenLDAP distribution only.
19 #include <ldap_cdefs.h>
20 #include <lber.h> /* get ber_slen_t */
24 #define LDAP_PROTO_TCP 1 /* ldap:// */
25 #define LDAP_PROTO_UDP 2 /* reserved */
26 #define LDAP_PROTO_IPC 3 /* ldapi:// */
29 ldap_pvt_url_scheme2proto LDAP_P((
32 ldap_pvt_url_scheme2tls LDAP_P((
35 struct ldap_url_desc; /* avoid pulling in <ldap.h> */
38 ldap_url_parse_ext LDAP_P((
40 struct ldap_url_desc **ludpp ));
43 ldap_pvt_domain2dn LDAP_P((
44 LDAP_CONST char *domain,
47 struct hostent; /* avoid pulling in <netdb.h> */
50 ldap_pvt_ctime LDAP_P((
54 LDAP_F( char *) ldap_pvt_get_fqdn LDAP_P(( char * ));
57 ldap_pvt_gethostbyname_a LDAP_P((
59 struct hostent *resbuf,
61 struct hostent **result,
65 ldap_pvt_gethostbyaddr_a LDAP_P((
69 struct hostent *resbuf,
71 struct hostent **result,
78 ldap_charray_add LDAP_P((
83 ldap_charray_merge LDAP_P((
88 ldap_charray_free LDAP_P(( char **a ));
91 ldap_charray_inlist LDAP_P((
96 ldap_charray_dup LDAP_P(( char **a ));
99 ldap_str2charray LDAP_P((
101 const char *brkstr ));
104 ldap_charray2str LDAP_P((
105 char **array, const char* sep ));
108 LDAP_F (void) ldap_pvt_hex_unescape LDAP_P(( char *s ));
109 LDAP_F (int) ldap_pvt_unhex( int c );
111 /* these macros assume 'x' is an ASCII x */
112 #define LDAP_DNSEPARATOR(c) ((c) == ',' || (c) == ';')
113 #define LDAP_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '+')
114 #define LDAP_SPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
116 #define LDAP_LOWER(c) ( (c) >= 'a' && (c) <= 'z' )
117 #define LDAP_UPPER(c) ( (c) >= 'A' && (c) <= 'Z' )
118 #define LDAP_ALPHA(c) ( LDAP_LOWER(c) || LDAP_UPPER(c) )
119 #define LDAP_DIGIT(c) ( (c) >= '0' && (c) <= '9' )
120 #define LDAP_ALNUM(c) ( LDAP_ALPHA(c) || LDAP_DIGIT(c) )
122 #define LDAP_LEADKEYCHAR(c) ( LDAP_ALPHA(c) )
123 #define LDAP_KEYCHAR(c) ( LDAP_ALNUM(c) || (c) == '-' )
124 #define LDAP_LEADOIDCHAR(c) ( LDAP_DIGIT(c) )
125 #define LDAP_OIDCHAR(c) ( LDAP_DIGIT(c) || (c) == '.' )
127 #define LDAP_LEADATTRCHAR(c) ( LDAP_LEADKEYCHAR(c) || LDAP_LEADOIDCHAR(c) )
128 #define LDAP_ATTRCHAR(c) ( LDAP_KEYCHAR(c) || LDAP_OIDCHAR(c) )
130 #define LDAP_NEEDSESCAPE(c) ((c) == '\\' || (c) == '"')
132 #ifdef HAVE_CYRUS_SASL
134 struct sasl_security_properties; /* avoid pulling in <sasl.h> */
135 LDAP_F (int) ldap_pvt_sasl_secprops LDAP_P((
137 struct sasl_security_properties *secprops ));
139 LDAP_F (void *) ldap_pvt_sasl_mutex_new LDAP_P((void));
140 LDAP_F (int) ldap_pvt_sasl_mutex_lock LDAP_P((void *mutex));
141 LDAP_F (int) ldap_pvt_sasl_mutex_unlock LDAP_P((void *mutex));
142 LDAP_F (void) ldap_pvt_sasl_mutex_dispose LDAP_P((void *mutex));
144 struct sockbuf; /* avoid pulling in <lber.h> */
145 LDAP_F (int) ldap_pvt_sasl_install LDAP_P(( struct sockbuf *, void * ));
146 #endif /* HAVE_CYRUS_SASL */
148 #define LDAP_PVT_SASL_LOCAL_SSF 71 /* SSF for Unix Domain Sockets */
152 ldap_pvt_find_wildcard LDAP_P(( const char *s ));
155 ldap_pvt_filter_value_unescape LDAP_P(( char *filter ));
159 ldap_pvt_str2upper LDAP_P(( char *str ));
162 ldap_pvt_str2lower LDAP_P(( char *str ));
168 LDAP_F (int) ldap_pvt_tls_init LDAP_P(( void ));
169 LDAP_F (int) ldap_pvt_tls_connect LDAP_P(( struct ldap *ld, Sockbuf *sb, void *ctx_arg ));
170 LDAP_F (int) ldap_pvt_tls_accept LDAP_P(( Sockbuf *sb, void *ctx_arg ));
171 LDAP_F (void *) ldap_pvt_tls_sb_handle LDAP_P(( Sockbuf *sb ));
172 LDAP_F (void *) ldap_pvt_tls_get_handle LDAP_P(( struct ldap *ld ));
173 LDAP_F (const char *) ldap_pvt_tls_get_peer LDAP_P(( void *handle ));
174 LDAP_F (int) ldap_pvt_tls_get_strength LDAP_P(( void *handle ));
175 LDAP_F (int) ldap_pvt_tls_inplace LDAP_P(( Sockbuf *sb ));
176 LDAP_F (int) ldap_pvt_tls_start LDAP_P(( struct ldap *ld, Sockbuf *sb, void *ctx_arg ));
178 LDAP_F (int) ldap_pvt_tls_get_option LDAP_P(( struct ldapoptions *lo, int option, void *arg ));
179 LDAP_F (int) ldap_pvt_tls_set_option LDAP_P(( struct ldapoptions *lo, int option, void *arg ));
185 typedef ber_int_t ldap_ucs4_t;
186 typedef short ldap_ucs2_t;
187 typedef ldap_ucs2_t ldap_unicode_t;
189 /* returns the number of bytes in the UTF-8 string */
190 LDAP_F (ber_len_t) ldap_utf8_bytes( const char * );
191 /* returns the number of UTF-8 characters in the string */
192 LDAP_F (ber_len_t) ldap_utf8_chars( const char * );
193 /* returns the length (in bytes) of the UTF-8 character */
194 LDAP_F (int) ldap_utf8_offset( const char * );
195 /* returns the length (in bytes) indicated by the UTF-8 character */
196 LDAP_F (int) ldap_utf8_charlen( const char * );
197 /* copies a UTF-8 character and returning number of bytes copied */
198 LDAP_F (int) ldap_utf8_copy( char *, const char *);
200 /* returns pointer of next UTF-8 character in string */
201 LDAP_F (char*) ldap_utf8_next( const char * );
202 /* returns pointer of previous UTF-8 character in string */
203 LDAP_F (char*) ldap_utf8_prev( const char * );
205 /* primitive ctype routines -- not aware of non-ascii characters */
206 LDAP_F (int) ldap_utf8_isascii( const char * );
207 LDAP_F (int) ldap_utf8_isalpha( const char * );
208 LDAP_F (int) ldap_utf8_isalnum( const char * );
209 LDAP_F (int) ldap_utf8_isdigit( const char * );
210 LDAP_F (int) ldap_utf8_isxdigit( const char * );
211 LDAP_F (int) ldap_utf8_isspace( const char * );
213 /* span characters not in set, return bytes spanned */
214 LDAP_F (ber_len_t) ldap_utf8_strcspn( const char* str, const char *set);
215 /* span characters in set, return bytes spanned */
216 LDAP_F (ber_len_t) ldap_utf8_strspn( const char* str, const char *set);
217 /* return first occurance of character in string */
218 LDAP_F (char *) ldap_utf8_strchr( const char* str, const char *chr);
219 /* return first character of set in string */
220 LDAP_F (char *) ldap_utf8_strpbrk( const char* str, const char *set);
221 /* reentrant tokenizer */
222 LDAP_F (char*) ldap_utf8_strtok( char* sp, const char* sep, char **last);
225 #define LDAP_UTF8_ISASCII(p) ( * (const unsigned char *) (p) < 0x80 )
226 #define LDAP_UTF8_CHARLEN(p) ( LDAP_UTF8_ISASCII(p) \
227 ? 1 : ldap_utf8_charlen((p)) )
228 #define LDAP_UTF8_OFFSET(p) ( LDAP_UTF8_ISASCII(p) \
229 ? 1 : ldap_utf8_offset((p)) )
231 #define LDAP_UTF8_COPY(d,s) ( LDAP_UTF8_ISASCII(s) \
232 ? (*(d) = *(s), 1) : ldap_utf8_copy((d),(s)) )
234 #define LDAP_UTF8_NEXT(p) ( LDAP_UTF8_ISASCII(p) \
235 ? (char *)(p)+1 : ldap_utf8_next((p)) )
237 #define LDAP_UTF8_INCR(p) ((p) = LDAP_UTF8_NEXT(p))
240 #define LDAP_UTF8_PREV(p) (ldap_utf8_prev((p)))
241 #define LDAP_UTF8_DECR(p) ((p)=LDAP_UTF8_PREV((p)))