home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ldapsdk.zip / include / ldap_pvt.h < prev    next >
C/C++ Source or Header  |  2001-07-22  |  8KB  |  253 lines

  1. /* $OpenLDAP: pkg/ldap/include/ldap_pvt.h,v 1.7.4.13 2001/07/21 19:01:38 kurt Exp $ */
  2. /*
  3.  * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA
  4.  * All rights reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted only as authorized by the OpenLDAP
  8.  * Public License.  A copy of this license is available at
  9.  * http://www.OpenLDAP.org/license.html or in file LICENSE in the
  10.  * top-level directory of the distribution.
  11.  */
  12. /*
  13.  * ldap-pvt.h - Header for ldap_pvt_ functions. These are meant to be used
  14.  *         by the OpenLDAP distribution only.
  15.  */
  16.  
  17. #ifndef _LDAP_PVT_H
  18. #define _LDAP_PVT_H 1
  19.  
  20. #include <ldap_cdefs.h>
  21. #include <lber.h>                /* get ber_slen_t */
  22.  
  23. LDAP_BEGIN_DECL
  24.  
  25. #define LDAP_PROTO_TCP 1 /* ldap://  */
  26. #define LDAP_PROTO_UDP 2 /* reserved */
  27. #define LDAP_PROTO_IPC 3 /* ldapi:// */
  28.  
  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.  
  36. struct ldap_url_desc; /* avoid pulling in <ldap.h> */
  37.  
  38. LDAP_F( int )
  39. ldap_url_parse_ext LDAP_P((
  40.     LDAP_CONST char *url,
  41.     struct ldap_url_desc **ludpp ));
  42.  
  43. LDAP_F ( int )
  44. ldap_pvt_domain2dn LDAP_P((
  45.     LDAP_CONST char *domain,
  46.     char **dn ));
  47.  
  48. struct hostent;    /* avoid pulling in <netdb.h> */
  49.  
  50. LDAP_F( char * )
  51. ldap_pvt_ctime LDAP_P((
  52.     const time_t *tp,
  53.     char *buf ));
  54.  
  55. LDAP_F( char *) ldap_pvt_get_fqdn LDAP_P(( char * ));
  56.  
  57. LDAP_F( int )
  58. ldap_pvt_gethostbyname_a LDAP_P((
  59.     const char *name, 
  60.     struct hostent *resbuf,
  61.     char **buf,
  62.     struct hostent **result,
  63.     int *herrno_ptr ));
  64.  
  65. LDAP_F( int )
  66. ldap_pvt_gethostbyaddr_a LDAP_P((
  67.     const char *addr,
  68.     int len,
  69.     int type,
  70.     struct hostent *resbuf,
  71.     char **buf,
  72.     struct hostent **result,
  73.     int *herrno_ptr ));
  74.  
  75.  
  76. /* charray.c */
  77.  
  78. LDAP_F( int )
  79. ldap_charray_add LDAP_P((
  80.     char    ***a,
  81.     char    *s ));
  82.  
  83. LDAP_F( int )
  84. ldap_charray_merge LDAP_P((
  85.     char    ***a,
  86.     char    **s ));
  87.  
  88. LDAP_F( void )
  89. ldap_charray_free LDAP_P(( char **a ));
  90.  
  91. LDAP_F( int )
  92. ldap_charray_inlist LDAP_P((
  93.     char    **a,
  94.     char    *s ));
  95.  
  96. LDAP_F( char ** )
  97. ldap_charray_dup LDAP_P(( char **a ));
  98.  
  99. LDAP_F( char ** )
  100. ldap_str2charray LDAP_P((
  101.     const char *str,
  102.     const char *brkstr ));
  103.  
  104. LDAP_F( char * )
  105. ldap_charray2str LDAP_P((
  106.     char **array, const char* sep ));
  107.  
  108. /* url.c */
  109. LDAP_F (void) ldap_pvt_hex_unescape LDAP_P(( char *s ));
  110. LDAP_F (int) ldap_pvt_unhex( int c );
  111.  
  112. /* these macros assume 'x' is an ASCII x */
  113. #define LDAP_DNSEPARATOR(c)    ((c) == ',' || (c) == ';')
  114. #define LDAP_SEPARATOR(c)    ((c) == ',' || (c) == ';' || (c) == '+')
  115. #define LDAP_SPACE(c)        ((c) == ' ' || (c) == '\t' || (c) == '\n')
  116.  
  117. #define LDAP_LOWER(c)        ( (c) >= 'a' && (c) <= 'z' )
  118. #define LDAP_UPPER(c)        ( (c) >= 'A' && (c) <= 'Z' )
  119. #define LDAP_ALPHA(c)        ( LDAP_LOWER(c) || LDAP_UPPER(c) )
  120. #define LDAP_DIGIT(c)        ( (c) >= '0' && (c) <= '9' )
  121. #define LDAP_ALNUM(c)        ( LDAP_ALPHA(c) || LDAP_DIGIT(c) )
  122.  
  123. #define LDAP_LEADKEYCHAR(c)    ( LDAP_ALPHA(c) )
  124. #define LDAP_KEYCHAR(c)        ( LDAP_ALNUM(c) || (c) == '-' )
  125. #define LDAP_LEADOIDCHAR(c)    ( LDAP_DIGIT(c) )
  126. #define LDAP_OIDCHAR(c)        ( LDAP_DIGIT(c) || (c) == '.' )
  127.  
  128. #define LDAP_LEADATTRCHAR(c)    ( LDAP_LEADKEYCHAR(c) || LDAP_LEADOIDCHAR(c) )
  129. #define LDAP_ATTRCHAR(c)        ( LDAP_KEYCHAR(c) || LDAP_OIDCHAR(c) )
  130.  
  131. #define LDAP_NEEDSESCAPE(c)    ((c) == '\\' || (c) == '"')
  132.  
  133. #ifdef HAVE_CYRUS_SASL
  134. /* cyrus.c */
  135. struct sasl_security_properties; /* avoid pulling in <sasl.h> */
  136. LDAP_F (int) ldap_pvt_sasl_secprops LDAP_P((
  137.     const char *in,
  138.     struct sasl_security_properties *secprops ));
  139.  
  140. LDAP_F (void *) ldap_pvt_sasl_mutex_new LDAP_P((void));
  141. LDAP_F (int) ldap_pvt_sasl_mutex_lock LDAP_P((void *mutex));
  142. LDAP_F (int) ldap_pvt_sasl_mutex_unlock LDAP_P((void *mutex));
  143. LDAP_F (void) ldap_pvt_sasl_mutex_dispose LDAP_P((void *mutex));
  144.  
  145. struct sockbuf; /* avoid pulling in <lber.h> */
  146. LDAP_F (int) ldap_pvt_sasl_install LDAP_P(( struct sockbuf *, void * ));
  147. #endif /* HAVE_CYRUS_SASL */
  148.  
  149. #define LDAP_PVT_SASL_LOCAL_SSF    71    /* SSF for Unix Domain Sockets */
  150.  
  151. struct ldap;
  152.  
  153. LDAP_F (int) ldap_open_internal_connection LDAP_P((
  154.     struct ldap **ldp, ber_socket_t *fdp ));
  155.  
  156. /* search.c */
  157. LDAP_F( char * )
  158. ldap_pvt_find_wildcard LDAP_P((    const char *s ));
  159.  
  160. LDAP_F( ber_slen_t )
  161. ldap_pvt_filter_value_unescape LDAP_P(( char *filter ));
  162.  
  163. /* string.c */
  164. LDAP_F( char * )
  165. ldap_pvt_str2upper LDAP_P(( char *str ));
  166.  
  167. LDAP_F( char * )
  168. ldap_pvt_str2lower LDAP_P(( char *str ));
  169.  
  170. /* tls.c */
  171. LDAP_F (int) ldap_pvt_tls_init LDAP_P(( void ));
  172. LDAP_F (int) ldap_pvt_tls_connect LDAP_P(( struct ldap *ld,
  173.     Sockbuf *sb, void *ctx_arg ));
  174. LDAP_F (int) ldap_pvt_tls_accept LDAP_P(( Sockbuf *sb, void *ctx_arg ));
  175. LDAP_F (void *) ldap_pvt_tls_sb_handle LDAP_P(( Sockbuf *sb ));
  176. LDAP_F (void *) ldap_pvt_tls_get_handle LDAP_P(( struct ldap *ld ));
  177. LDAP_F (char *) ldap_pvt_tls_get_peer LDAP_P(( void *handle ));
  178. LDAP_F (int) ldap_pvt_tls_get_strength LDAP_P(( void *handle ));
  179. LDAP_F (int) ldap_pvt_tls_inplace LDAP_P(( Sockbuf *sb ));
  180. LDAP_F (int) ldap_pvt_tls_start LDAP_P(( struct ldap *ld,
  181.     Sockbuf *sb, void *ctx_arg ));
  182. LDAP_F (int) ldap_pvt_tls_get_option LDAP_P(( struct ldap *ld,
  183.     int option, void *arg ));
  184. LDAP_F (int) ldap_pvt_tls_set_option LDAP_P(( struct ldap *ld,
  185.     int option, void *arg ));
  186.  
  187. /*  
  188.  * UTF-8 (in utf-8.c)
  189.  */
  190.  
  191. typedef ber_int_t ldap_ucs4_t;
  192. typedef short ldap_ucs2_t;
  193. typedef ldap_ucs2_t ldap_unicode_t;
  194.  
  195. /* returns the number of bytes in the UTF-8 string */
  196. LDAP_F (ber_len_t) ldap_utf8_bytes( const char * );
  197. /* returns the number of UTF-8 characters in the string */
  198. LDAP_F (ber_len_t) ldap_utf8_chars( const char * );
  199. /* returns the length (in bytes) of the UTF-8 character */
  200. LDAP_F (int) ldap_utf8_offset( const char * );
  201. /* returns the length (in bytes) indicated by the UTF-8 character */
  202. LDAP_F (int) ldap_utf8_charlen( const char * );
  203. /* copies a UTF-8 character and returning number of bytes copied */
  204. LDAP_F (int) ldap_utf8_copy( char *, const char *);
  205.  
  206. /* returns pointer of next UTF-8 character in string */
  207. LDAP_F (char*) ldap_utf8_next( const char * );
  208. /* returns pointer of previous UTF-8 character in string */
  209. LDAP_F (char*) ldap_utf8_prev( const char * );
  210.  
  211. /* primitive ctype routines -- not aware of non-ascii characters */
  212. LDAP_F (int) ldap_utf8_isascii( const char * );
  213. LDAP_F (int) ldap_utf8_isalpha( const char * );
  214. LDAP_F (int) ldap_utf8_isalnum( const char * );
  215. LDAP_F (int) ldap_utf8_isdigit( const char * );
  216. LDAP_F (int) ldap_utf8_isxdigit( const char * );
  217. LDAP_F (int) ldap_utf8_isspace( const char * );
  218.  
  219. /* span characters not in set, return bytes spanned */
  220. LDAP_F (ber_len_t) ldap_utf8_strcspn( const char* str, const char *set);
  221. /* span characters in set, return bytes spanned */
  222. LDAP_F (ber_len_t) ldap_utf8_strspn( const char* str, const char *set);
  223. /* return first occurance of character in string */
  224. LDAP_F (char *) ldap_utf8_strchr( const char* str, const char *chr);
  225. /* return first character of set in string */
  226. LDAP_F (char *) ldap_utf8_strpbrk( const char* str, const char *set);
  227. /* reentrant tokenizer */
  228. LDAP_F (char*) ldap_utf8_strtok( char* sp, const char* sep, char **last);
  229.  
  230. /* Optimizations */
  231. #define LDAP_UTF8_ISASCII(p) ( * (const unsigned char *) (p) < 0x80 )
  232. #define LDAP_UTF8_CHARLEN(p) ( LDAP_UTF8_ISASCII(p) \
  233.     ? 1 : ldap_utf8_charlen((p)) )
  234. #define LDAP_UTF8_OFFSET(p) ( LDAP_UTF8_ISASCII(p) \
  235.     ? 1 : ldap_utf8_offset((p)) )
  236.  
  237. #define LDAP_UTF8_COPY(d,s) (    LDAP_UTF8_ISASCII(s) \
  238.     ? (*(d) = *(s), 1) : ldap_utf8_copy((d),(s)) )
  239.  
  240. #define LDAP_UTF8_NEXT(p) (    LDAP_UTF8_ISASCII(p) \
  241.     ? (char *)(p)+1 : ldap_utf8_next((p)) )
  242.  
  243. #define LDAP_UTF8_INCR(p) ((p) = LDAP_UTF8_NEXT(p))
  244.  
  245. /* For symmetry */
  246. #define LDAP_UTF8_PREV(p) (ldap_utf8_prev((p)))
  247. #define LDAP_UTF8_DECR(p) ((p)=LDAP_UTF8_PREV((p)))
  248.  
  249. LDAP_END_DECL
  250.  
  251. #endif
  252.  
  253.