00001
00009 #ifndef __LDAP_URL_HEADER_H__
00010 #define __LDAP_URL_HEADER_H__
00011
00012 #include "PKIFdll.h"
00013 #include "PKIFEnums.h"
00014
00015 #ifdef _WIN32
00016 #include "winldap.h"
00017 #include "winber.h"
00018 #else
00019 #include "ldap.h"
00020 #endif //_WIN32
00021
00022 namespace PKIFLDAP {
00023
00024
00025
00026
00027 const char ldap_utf8_lentab[] = {
00028 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00029 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00030 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00031 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00032 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00033 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00034 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
00035 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0 };
00036
00037 #define c const char
00038 c ldap_utf8_mintab[] = {
00039 (c)0x20, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80,
00040 (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80,
00041 (c)0x30, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80,
00042 (c)0x38, (c)0x80, (c)0x80, (c)0x80, (c)0x3c, (c)0x80, (c)0x00, (c)0x00 };
00043 #undef c
00044
00045 #define LDAP_UCS4_INVALID (0x80000000U)
00046
00047 #define LDAP_UTF8_ISASCII(p) ( !(*(const unsigned char *)(p) & 0x80 ) )
00048 #define LDAP_UTF8_INCR(p) ((p) = LDAP_UTF8_NEXT(p))
00049 #define LDAP_UTF8_NEXT(p) ( LDAP_UTF8_ISASCII(p) \
00050 ? (char *)(p)+1 : ldap_utf8_next((p)) )
00051
00052 #define LDAP_UTF8_CHARLEN(p) ( LDAP_UTF8_ISASCII(p) \
00053 ? 1 : ldap_utf8_lentab[*(const unsigned char *)(p) ^ 0x80] )
00054
00055
00056
00057
00058
00059 #define LDAP_UTF8_CHARLEN2(p, l) ( ( ( l = LDAP_UTF8_CHARLEN( p )) < 3 || \
00060 ( ldap_utf8_mintab[*(const unsigned char *)(p) & 0x1f] & (p)[1] ) ) ? \
00061 l : 0 )
00062
00063 #define LBER_INT_T int
00064 typedef LBER_INT_T ber_int_t;
00065 typedef ber_int_t ldap_ucs4_t;
00066
00067 #define LBER_LEN_T long
00068 typedef unsigned LBER_LEN_T ber_len_t;
00069
00070
00071
00072 #define LBER_MALLOC malloc
00073 #define LBER_CALLOC calloc
00074 #define LBER_REALLOC realloc
00075 #define LBER_FREE free
00076 #define LBER_VFREE ber_memvfree
00077 #define LBER_STRDUP strdup
00078 #define LBER_STRNDUP ber_strndup__
00079
00080
00081
00082
00083 #define LDAP_MALLOC(s) (LBER_MALLOC((s)))
00084 #define LDAP_CALLOC(n,s) (LBER_CALLOC((n),(s)))
00085 #define LDAP_REALLOC(p,s) (LBER_REALLOC((p),(s)))
00086 #define LDAP_FREE(p) (LBER_FREE((p)))
00087 #define LDAP_VFREE(v) (LBER_VFREE((void **)(v)))
00088 #define LDAP_STRDUP(s) (LBER_STRDUP((s)))
00089 #define LDAP_STRNDUP(s,l) (LBER_STRNDUP((s),(l)))
00090
00091
00092
00093 #define LDAP_PORT 389
00094 #define LDAPS_PORT 636
00095
00096 #if !defined(LDAP_SCOPE_DEFAULT)
00097 #define LDAP_SCOPE_DEFAULT ((PKIFLDAP::ber_int_t) -1)
00098 #endif
00099
00100
00101
00102
00103
00104
00105
00106 struct lber_options {
00107 short lbo_valid;
00108 unsigned short lbo_options;
00109 int lbo_debug;
00110 long lbo_meminuse;
00111 };
00112
00113 #define BER_MEM_VALID(p)
00114
00115
00116
00117 #define LBER_UNINITIALIZED 0x0
00118 #define LBER_INITIALIZED 0x1
00119 #define LBER_VALID_BERELEMENT 0x2
00120 #define LBER_VALID_SOCKBUF 0x3
00121
00122
00123
00124
00125
00126 #ifdef _WIN32
00127 typedef struct ldap_url_desc {
00128 struct ldap_url_desc *lud_next;
00129 char *lud_scheme;
00130 char *lud_host;
00131 int lud_port;
00132 char *lud_dn;
00133 char **lud_attrs;
00134 int lud_scope;
00135 char *lud_filter;
00136 char **lud_exts;
00137 int lud_crit_exts;
00138 } LDAPURLDesc;
00139 #else
00140 typedef ::LDAPURLDesc LDAPURLDesc;
00141 #endif
00142
00143 #define LDAP_URL_SUCCESS 0x00
00144 #define LDAP_URL_ERR_MEM 0x01
00145 #define LDAP_URL_ERR_PARAM 0x02
00146
00147 #define LDAP_URL_ERR_BADSCHEME 0x03
00148 #define LDAP_URL_ERR_BADENCLOSURE 0x04
00149 #define LDAP_URL_ERR_BADURL 0x05
00150 #define LDAP_URL_ERR_BADHOST 0x06
00151 #define LDAP_URL_ERR_BADATTRS 0x07
00152 #define LDAP_URL_ERR_BADSCOPE 0x08
00153 #define LDAP_URL_ERR_BADFILTER 0x09
00154 #define LDAP_URL_ERR_BADEXTS 0x0a
00155
00156
00157
00158 #define LDAP_URL_PREFIX "ldap://"
00159 #define LDAP_URL_PREFIX_LEN (sizeof(LDAP_URL_PREFIX)-1)
00160 #define LDAPS_URL_PREFIX "ldaps://"
00161 #define LDAPS_URL_PREFIX_LEN (sizeof(LDAPS_URL_PREFIX)-1)
00162 #define LDAPI_URL_PREFIX "ldapi://"
00163 #define LDAPI_URL_PREFIX_LEN (sizeof(LDAPI_URL_PREFIX)-1)
00164 #ifdef LDAP_CONNECTIONLESS
00165 #define LDAPC_URL_PREFIX "cldap://"
00166 #define LDAPC_URL_PREFIX_LEN (sizeof(LDAPC_URL_PREFIX)-1)
00167 #endif
00168 #define LDAP_URL_URLCOLON "URL:"
00169 #define LDAP_URL_URLCOLON_LEN (sizeof(LDAP_URL_URLCOLON)-1)
00170
00171 #define LDAP_URL_URLEQUALTO "URL="
00172 #define LDAP_URL_URLEQUALTO_LEN (sizeof(LDAP_URL_URLEQUALTO)-1)
00173
00174
00175 #define LDAP_REF_STR "Referral:\n"
00176 #define LDAP_REF_STR_LEN (sizeof(LDAP_REF_STR)-1)
00177 #define LDAP_LDAP_REF_STR LDAP_URL_PREFIX
00178 #define LDAP_LDAP_REF_STR_LEN LDAP_URL_PREFIX_LEN
00179
00180
00181
00182
00183
00184
00185 int ldap_url_parse( const char *url_in, LDAPURLDesc **ludpp );
00186 int ldap_url_parse_ext( const char *url_in, LDAPURLDesc **ludpp );
00187 const char* skip_url_prefix(const char *url,int *enclosedp,const char **scheme );
00188 void ldap_free_urldesc( LDAPURLDesc *ludp );
00189 void ber_memvfree( void **vec );
00190 void ldap_pvt_hex_unescape( char *s );
00191 char **ldap_str2charray( const char *str_in, const char *brkstr );
00192 char * (ldap_utf8_strchr)( const char *str, const char *chr );
00193 char *(ldap_utf8_strtok)(char *str, const char *sep, char **last);
00194 ber_len_t (ldap_utf8_strspn)( const char *str, const char *set );
00195 ber_len_t (ldap_utf8_strcspn)( const char *str, const char *set );
00196 ldap_ucs4_t ldap_x_utf8_to_ucs4( const char * p );
00197 char* ldap_utf8_next( const char * p );
00198
00199
00200 #define ERR_LDAP_CONNECTION 1001
00201 #define ERR_LDAP_QUERY 1002
00202
00203 };
00204
00205 extern struct PKIFLDAP::lber_options ber_int_options;
00206
00207 #endif