X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fldap_pvt_uc.h;h=a9b2515757c7012bbad8650da24d8d19f80ddd1f;hb=0f4a5f74453365236874d4223e1a177de0a2970d;hp=6778628fa6c3a8c680ebbf9e57a46a5c8c33c7a7;hpb=9e8f3053cb56875bdd5a8dce0a74976a70a8080a;p=openldap diff --git a/include/ldap_pvt_uc.h b/include/ldap_pvt_uc.h index 6778628fa6..a9b2515757 100644 --- a/include/ldap_pvt_uc.h +++ b/include/ldap_pvt_uc.h @@ -1,14 +1,18 @@ /* $OpenLDAP$ */ -/* - * Copyright 1998-2002 The OpenLDAP Foundation, Redwood City, California, USA +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2005 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP - * Public License. A copy of this license is available at - * http://www.OpenLDAP.org/license.html or in file LICENSE in the - * top-level directory of the distribution. + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . */ + /* * ldap_pvt_uc.h - Header for Unicode functions. * These are meant to be used by the OpenLDAP distribution only. @@ -20,11 +24,8 @@ #include /* get ber_slen_t */ -#ifdef _MSC_VER +#include #include "../libraries/liblunicode/ucdata/ucdata.h" -#else -#include "../libraries/liblunicode/ucdata.h" -#endif LDAP_BEGIN_DECL @@ -39,6 +40,11 @@ typedef unsigned long ldap_unicode_t; #define ldap_utf8_to_unicode( p ) ldap_utf8_to_ucs4((p)) #define ldap_unicode_to_utf8( c, buf ) ldap_ucs4_to_ucs4((c),(buf)) +/* Convert a string with csize octets per character to UTF-8 */ +LDAP_F( int ) ldap_ucs_to_utf8s LDAP_P(( + struct berval *ucs, int csize, struct berval *utf8s )); + + /* returns the number of bytes in the UTF-8 string */ LDAP_F (ber_len_t) ldap_utf8_bytes( const char * ); /* returns the number of UTF-8 characters in the string */ @@ -84,16 +90,16 @@ LDAP_F (char*) ldap_utf8_strtok( char* sp, const char* sep, char **last); LDAP_V (const char) ldap_utf8_lentab[128]; LDAP_V (const char) ldap_utf8_mintab[32]; -#define LDAP_UTF8_ISASCII(p) ( !(*(unsigned char *)(p) & 0x80 ) ) +#define LDAP_UTF8_ISASCII(p) ( !(*(const unsigned char *)(p) & 0x80 ) ) #define LDAP_UTF8_CHARLEN(p) ( LDAP_UTF8_ISASCII(p) \ - ? 1 : ldap_utf8_lentab[*(unsigned char *)(p) ^ 0x80] ) + ? 1 : ldap_utf8_lentab[*(const unsigned char *)(p) ^ 0x80] ) /* This is like CHARLEN but additionally validates to make sure * the char used the shortest possible encoding. * 'l' is used to temporarily hold the result of CHARLEN. */ #define LDAP_UTF8_CHARLEN2(p, l) ( ( ( l = LDAP_UTF8_CHARLEN( p )) < 3 || \ - ( ldap_utf8_mintab[*(unsigned char *)(p) & 0x1f] & (p)[1] ) ) ? \ + ( ldap_utf8_mintab[*(const unsigned char *)(p) & 0x1f] & (p)[1] ) ) ? \ l : 0 ) #define LDAP_UTF8_OFFSET(p) ( LDAP_UTF8_ISASCII(p) \ @@ -137,27 +143,23 @@ LDAP_LUNICODE_F(void) ucstr2upper( ldap_unicode_t *, ber_len_t ); -#define LDAP_UTF8_CASEFOLD 0x1U #define LDAP_UTF8_NOCASEFOLD 0x0U - -LDAP_LUNICODE_F(char *) UTF8normalize( - struct berval *, - unsigned ); +#define LDAP_UTF8_CASEFOLD 0x1U +#define LDAP_UTF8_ARG1NFC 0x2U +#define LDAP_UTF8_ARG2NFC 0x4U +#define LDAP_UTF8_APPROX 0x8U LDAP_LUNICODE_F(struct berval *) UTF8bvnormalize( struct berval *, struct berval *, - unsigned ); - -LDAP_LUNICODE_F(int) UTF8normcmp( - const char *, - const char *, - unsigned ); + unsigned, + void *memctx ); LDAP_LUNICODE_F(int) UTF8bvnormcmp( struct berval *, struct berval *, - unsigned ); + unsigned, + void *memctx ); LDAP_END_DECL