3 * Copyright 1998,1999 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 */
25 ldap_pvt_domain2dn LDAP_P((
26 LDAP_CONST char *domain,
29 struct hostent; /* avoid pulling in <netdb.h> */
32 ldap_pvt_ctime LDAP_P((
37 ldap_pvt_gethostbyname_a LDAP_P((
39 struct hostent *resbuf,
41 struct hostent **result,
45 ldap_pvt_gethostbyaddr_a LDAP_P((
49 struct hostent *resbuf,
51 struct hostent **result,
58 ldap_charray_add LDAP_P((
63 ldap_charray_merge LDAP_P((
68 ldap_charray_free LDAP_P(( char **a ));
71 ldap_charray_inlist LDAP_P((
76 ldap_charray_dup LDAP_P(( char **a ));
79 ldap_str2charray LDAP_P((
84 LIBLDAP_F (void) ldap_pvt_hex_unescape LDAP_P(( char *s ));
85 LIBLDAP_F (int) ldap_pvt_unhex( int c );
87 /* these macros assume 'x' is an ASCII x */
88 #define LDAP_DNSEPARATOR(c) ((c) == ',' || (c) == ';')
89 #define LDAP_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '+')
90 #define LDAP_SPACE(c) ((c) == ' ' || (c) == '\n')
92 #define LDAP_LOWER(c) ( (c) >= 'a' && (c) <= 'z' )
93 #define LDAP_UPPER(c) ( (c) >= 'A' && (c) <= 'Z' )
94 #define LDAP_ALPHA(c) ( LDAP_LOWER(c) || LDAP_UPPER(c) )
95 #define LDAP_DIGIT(c) ( (c) >= '0' && (c) <= '9' )
96 #define LDAP_ALNUM(c) ( LDAP_ALPHA(c) || LDAP_DIGIT(c) )
98 #define LDAP_LEADKEYCHAR(c) ( LDAP_ALPHA(c) )
99 #define LDAP_KEYCHAR(c) ( LDAP_ALNUM(c) || (c) == '-' )
100 #define LDAP_LEADOIDCHAR(c) ( LDAP_DIGIT(c) )
101 #define LDAP_OIDCHAR(c) ( LDAP_DIGIT(c) || (c) == '.' )
103 #define LDAP_LEADATTRCHAR(c) ( LDAP_LEADKEYCHAR(c) || LDAP_LEADOIDCHAR(c) )
104 #define LDAP_ATTRCHAR(c) ( LDAP_KEYCHAR((c)) || (c) == '.' )
106 #define LDAP_NEEDSESCAPE(c) ((c) == '\\' || (c) == '"')
108 #ifdef HAVE_CYRUS_SASL
114 LIBLDAP_F (int) ldap_pvt_sasl_init LDAP_P(( void )); /* clientside init */
115 LIBLDAP_F (int) ldap_pvt_sasl_install LDAP_P(( Sockbuf *, void * ));
116 LIBLDAP_F (int) ldap_pvt_sasl_err2ldap LDAP_P(( int ));
117 LIBLDAP_F (int) ldap_pvt_sasl_bind LDAP_P(( LDAP *, LDAP_CONST char *, LDAP_CONST char *, LDAP_CONST sasl_callback_t *, LDAPControl **, LDAPControl ** ));
118 #endif /* HAVE_CYRUS_SASL */
122 ldap_pvt_find_wildcard LDAP_P(( char *s ));
124 LIBLDAP_F( ber_slen_t )
125 ldap_pvt_filter_value_unescape LDAP_P(( char *filter ));
129 ldap_pvt_str2upper LDAP_P(( char *str ));
132 ldap_pvt_str2lower LDAP_P(( char *str ));
137 LIBLDAP_F (int) ldap_pvt_tls_init LDAP_P(( void ));
138 LIBLDAP_F (int) ldap_pvt_tls_config LDAP_P(( struct ldapoptions *lo, int option, const char *arg ));
139 LIBLDAP_F (int) ldap_pvt_tls_connect LDAP_P(( Sockbuf *sb, void *ctx_arg ));
140 LIBLDAP_F (int) ldap_pvt_tls_accept LDAP_P(( Sockbuf *sb, void *ctx_arg ));
141 LIBLDAP_F (int) ldap_pvt_tls_get_option LDAP_P(( struct ldapoptions *lo, int option, void *arg ));
142 LIBLDAP_F (int) ldap_pvt_tls_set_option LDAP_P(( struct ldapoptions *lo, int option, void *arg ));
143 LIBLDAP_F (int) ldap_pvt_tls_inplace LDAP_P(( Sockbuf *sb ));
144 LIBLDAP_F (int) ldap_pvt_tls_start LDAP_P(( Sockbuf *sb, void *ctx_arg ));
150 /* returns the number of bytes in the UTF-8 string
151 (counting the NULL) */
152 LIBLDAP_F (ber_len_t) ldap_utf8_bytes( const char * );
153 /* returns the number of UTF-8 characters in the string */
154 LIBLDAP_F (ber_len_t) ldap_utf8_chars( const char * );
155 /* returns the length (in bytes) of a UTF-8 string */
156 LIBLDAP_F (int) ldap_utf8_charlen( const char * );
157 /* copies a UTF-8 character and returning number of bytes copied */
158 LIBLDAP_F (int) ldap_utf8_copy( char *, const char *);
160 /* returns pointer of next UTF-8 character in string */
161 LIBLDAP_F (char*) ldap_utf8_next( const char * );
162 /* returns pointer of previous UTF-8 character in string */
163 LIBLDAP_F (char*) ldap_utf8_prev( const char * );
165 /* primitive ctype routines -- not aware of non-ascii characters */
166 LIBLDAP_F (int) ldap_utf8_isascii( const char * );
167 LIBLDAP_F (int) ldap_utf8_isalpha( const char * );
168 LIBLDAP_F (int) ldap_utf8_isalnum( const char * );
169 LIBLDAP_F (int) ldap_utf8_isdigit( const char * );
170 LIBLDAP_F (int) ldap_utf8_isxdigit( const char * );
171 LIBLDAP_F (int) ldap_utf8_isspace( const char * );
173 /* span characters not in set, return bytes spanned */
174 LIBLDAP_F (ber_len_t) ldap_utf8_strcspn( const char* str, const char *set);
175 /* span characters in set, return bytes spanned */
176 LIBLDAP_F (ber_len_t) ldap_utf8_strspn( const char* str, const char *set);
177 /* return first character of set in string */
178 LIBLDAP_F (char *) ldap_utf8_strpbrk( const char* str, const char *set);
179 /* reentrant tokenizer */
180 LIBLDAP_F (char*) ldap_utf8_strtok( char* sp, const char* sep, char **last);
183 #define LDAP_UTF8_CHARLEN(p) (*(unsigned char *)(p) < 0x100 \
184 ? 1 : ldap_utf8_charlen((p)))
186 #define LDAP_UTF8_COPY(p) (*(unsigned char *)(s) < 0x100 \
187 ? (*(d) = *(s), 1) : ldap_utf8_cpy((d),(s)))
189 #define LDAP_UTF8_NEXT(p) (*(unsigned char *)(p) < 0x100 \
190 ? &(p)[1] : ldap_utf8_next((p)))
192 #define LDAP_UTF8_INCR(p) (*(unsigned char *)(p) < 0x100 \
193 ? ++(p) : (p)=ldap_utf8_next((p)))
196 #define LDAP_UTF8_PREV(p) (ldap_utf8_prev((p)))
197 #define LDAP_UTF8_DECR(p) ((p)=ldap_utf8_prev((p)))