* (all): Changed JID storage format, added support for stringprep

* src/stringprep/: Added support for Unicode normalization form KC

* src/stringprep/: Added support for case convertion to multiple
characters

* src/cyrsasl_digest.erl: Temporary removed "auth-int" QOP

SVN Revision: 144
This commit is contained in:
Alexey Shchepin
2003-10-07 20:31:44 +00:00
parent e1de741cfc
commit 61875f80b3
26 changed files with 1328 additions and 1200 deletions
+122 -7
View File
@@ -32,8 +32,38 @@ static void stringprep_erl_stop(ErlDrvData handle)
driver_free((char*)handle);
}
/*
* "canonical_ordering" and "compose" functions are based on nfkc.c from Gnome
* library
*/
static int combine(int ch1, int ch2)
void canonical_ordering(int *str, int len)
{
int i, j, t;
int last, next;
last = GetUniCharCClass(str[0]);
for (i = 0; i < len - 1; i++)
{
next = GetUniCharCClass(str[i + 1]);
if (next != 0 && last > next)
{
for(j = i; j > 0; j--)
{
if (GetUniCharCClass(str[j]) <= next)
break;
t = str[j + 1];
str[j + 1] = str[j];
str[j] = t;
}
next = last;
}
last = next;
}
}
static int compose(int ch1, int ch2)
{
int info1, info2;
@@ -90,6 +120,29 @@ static int combine(int ch1, int ch2)
pos += 3; \
}
#define ADD_UCHAR32(str, pos, len, ch) \
if(pos >= len) { \
len = 2*len + 1; \
str = driver_realloc(str, len * sizeof(int)); \
} \
str[pos] = ch; \
pos++;
#define ADD_DECOMP(ruc) \
info = GetUniCharDecompInfo(ruc); \
if(info >= 0) { \
decomp_len = GetDecompLen(info); \
decomp_shift = GetDecompShift(info); \
for(j = 0; j < decomp_len; j++) { \
ADD_UCHAR32(str32, str32pos, str32len, \
decompList[decomp_shift + j]); \
} \
} else { \
ADD_UCHAR32(str32, str32pos, str32len, ruc); \
}
static int stringprep_erl_control(ErlDrvData drv_data,
unsigned int command,
@@ -105,12 +158,22 @@ static int stringprep_erl_control(ErlDrvData drv_data,
int prohibit, tolower;
char *rstring;
int *mc;
int *str32;
int str32len, str32pos = 0;
int decomp_len, decomp_shift;
int comp_pos;
int cclass1, cclass2;
int ch1, ch2;
size = len + 1;
rstring = driver_alloc(size);
rstring[0] = 0;
str32len = len + 1;
str32 = driver_alloc(str32len * sizeof(int));
switch (command)
{
case 0:
@@ -134,7 +197,7 @@ static int stringprep_erl_control(ErlDrvData drv_data,
break;
}
for(i=0; i < len; i++)
for(i = 0; i < len; i++)
{
c = buf[i];
if(c < 0x80) {
@@ -164,12 +227,14 @@ static int stringprep_erl_control(ErlDrvData drv_data,
if(bad) {
*rbuf = rstring;
driver_free(str32);
return 1;
}
info = GetUniCharInfo(uc);
if(info & prohibit) {
*rbuf = rstring;
driver_free(str32);
return 1;
}
@@ -180,6 +245,19 @@ static int stringprep_erl_control(ErlDrvData drv_data,
if(!(info & MCMask))
{
ruc = uc + GetDelta(info);
ADD_DECOMP(ruc);
//info = GetUniCharDecompInfo(ruc);
//if(info >= 0) {
// decomp_len = GetDecompLen(info);
// decomp_shift = GetDecompShift(info);
// for(j = 0; j < decomp_len; j++) {
// ADD_UCHAR32(str32, str32pos, str32len,
// decompList[decomp_shift + j]);
// }
//} else {
// ADD_UCHAR32(str32, str32pos, str32len, ruc);
//}
//info = GetUniCharDecompInfo(ruc);
//if(info >= 0) {
@@ -190,26 +268,63 @@ static int stringprep_erl_control(ErlDrvData drv_data,
// printf("\r\n");
//}
ADD_UCHAR(ruc);
//ADD_UCHAR(ruc);
} else {
mc = GetMC(info);
for(j = 1; j <= mc[0]; j++) {
ruc = mc[j];
//printf("Char %x cclass %d\r\n", ruc, GetUniCharCClass(ruc));
ADD_UCHAR(ruc);
ADD_DECOMP(ruc);
}
}
} else {
ruc = uc;
ADD_UCHAR(ruc);
ADD_DECOMP(ruc);
}
}
}
//printf("Combine: %x\r\n", combine(0x438, 0x301));
if (str32pos == 0) {
rstring[0] = 1;
*rbuf = rstring;
driver_free(str32);
return 1;
}
canonical_ordering(str32, str32pos);
comp_pos = 0;
ch1 = str32[0];
cclass1 = GetUniCharCClass(ch1);
for(i = 1; i < str32pos; i++)
{
ch2 = str32[i];
cclass2 = GetUniCharCClass(ch2);
//printf("Compose: %x + %x = %x\r\n", ch1, ch2, compose(ch1, ch2));
if(cclass1 == 0 && cclass1 < cclass2 && (ruc = compose(ch1, ch2))) {
ch1 = ruc;
} else {
str32[comp_pos] = ch1;
comp_pos++;
ch1 = ch2;
}
}
str32[comp_pos] = ch1;
str32pos = comp_pos+1;
for(i = 0; i < str32pos; i++)
{
ruc = str32[i];
ADD_UCHAR(ruc);
}
//printf("Compose: %x\r\n", compose(0x438, 0x301));
//printf("Pos: %d\r\n", pos);
rstring[0] = 1;
*rbuf = rstring;
driver_free(str32);
return pos;
}
+813 -821
View File
File diff suppressed because it is too large Load Diff
+6 -69
View File
@@ -283,6 +283,12 @@ proc uni::buildTables {} {
if {[info exists decomp_map($i)]} {
set decomp $decomp_map($i)
#puts -$decomp
while {[info exists decomp_map([set ch1 [lindex $decomp 0]])]} {
set decomp [concat $decomp_map($ch1) [lreplace $decomp 0 0]]
#puts +$decomp
}
if {[info exists decomp_used($decomp)]} {
lappend decomp_info $decomp_used($decomp)
} else {
@@ -442,75 +448,6 @@ static unsigned char cclassGroupMap\[\] = {"
puts $f $line
puts $f "};
/*
* Each group represents a unique set of character attributes. The attributes
* are encoded into a 32-bit value as follows:
*
* Bits 0-4 Character category: see the constants listed below.
*
* Bits 5-7 Case delta type: 000 = identity
* 010 = add delta for lower
* 011 = add delta for lower, add 1 for title
* 100 = sutract delta for title/upper
* 101 = sub delta for upper, sub 1 for title
* 110 = sub delta for upper, add delta for lower
*
* Bits 8-21 Reserved for future use.
*
* Bits 22-31 Case delta: delta for case conversions. This should be the
* highest field so we can easily sign extend.
*/
static int cclass_groups\[\] = {"
set line " "
set last [expr {[llength $groups] - 1}]
for {set i 0} {$i <= $last} {incr i} {
foreach {type toupper tolower totitle} [split [lindex $groups $i] ,] {}
# Compute the case conversion type and delta
if {$totitle != ""} {
if {$totitle == $toupper} {
# subtract delta for title or upper
set case 4
set delta $toupper
} elseif {$toupper != ""} {
# subtract delta for upper, subtract 1 for title
set case 5
set delta $toupper
} else {
# add delta for lower, add 1 for title
set case 3
set delta $tolower
}
} elseif {$toupper != ""} {
# subtract delta for upper, add delta for lower
set case 6
set delta $toupper
} elseif {$tolower != ""} {
# add delta for lower
set case 2
set delta $tolower
} else {
# noop
set case 0
set delta 0
}
set val [expr {($delta << 22) | ($case << 5) | $type}]
append line [format "%d" $val]
if {$i != $last} {
append line ", "
}
if {[string length $line] > 65} {
puts $f $line
set line " "
}
}
puts $f $line
puts $f "};
#define GetUniCharCClass(ch) (cclassGroupMap\[(cclassPageMap\[(((int)(ch)) & 0xffff) >> CCLASS_OFFSET_BITS\] << CCLASS_OFFSET_BITS) | ((ch) & ((1 << CCLASS_OFFSET_BITS)-1))\])