diff options
author | Jeremy Allison <jra@samba.org> | 1998-03-03 20:19:14 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-03-03 20:19:14 +0000 |
commit | 299016338cfb47f0c585875ef9b468121fcee97d (patch) | |
tree | 9d50463080527f1e1d7487c9552609633511ff2c /source/smbd/mangle.c | |
parent | 4adb00e41abbbaf6eaa014e6a599cb2c8b77d7da (diff) | |
download | samba-299016338cfb47f0c585875ef9b468121fcee97d.tar.gz samba-299016338cfb47f0c585875ef9b468121fcee97d.tar.xz samba-299016338cfb47f0c585875ef9b468121fcee97d.zip |
Change the multibyte character set support so that
Kanji support is one case of multibyte character
support, rather than being a specific case in
single byte character support.
This allows us to add Big5 Chinese support (code page 950)
and Korean Hangul support (code page 949) at very little
cost. Also allows us to easily add future multibyte
code pages.
Makefile: Added codepages 949, 950 as we now support more multibyte
codepages.
asyncdns.c: Fixed problem with child being re-spawned when parent killed.
charcnv.c
charset.c
client.c
clitar.c
kanji.c
kanji.h
smb.h
util.c
loadparm.c: Generic multibyte codepage support (adding Big5 Chinese
and Korean Hangul).
nmbd.c: Fixed problem with child being re-spawned when parent killed.
mangle.c: Modified str_checksum so that first 15 characters have more
effect on outcome. This helps with short name mangling as
most 'long' names are still shorter than 15 chars (bug was
foobar_mng and foobar_sum would hash to the same value, with
the modified code they hash differently.
Jeremy.
Diffstat (limited to 'source/smbd/mangle.c')
-rw-r--r-- | source/smbd/mangle.c | 136 |
1 files changed, 48 insertions, 88 deletions
diff --git a/source/smbd/mangle.c b/source/smbd/mangle.c index 7b6a5635110..d0d5ada2479 100644 --- a/source/smbd/mangle.c +++ b/source/smbd/mangle.c @@ -42,7 +42,7 @@ int str_checksum(char *s) while( *s ) { c = *s; - res ^= (c << (i % 15)) ^ (c >> (15-(i%15))); + res ^= (c << (15-(i%15))) ^ (c >> (i % 15)); s++; i++; } return(res); @@ -130,38 +130,25 @@ BOOL is_8_3(char *fname, BOOL check_case) dot_pos = strchr(fname,'.'); - { + { char *p = fname; + int skip; - if(lp_client_code_page() == KANJI_CODEPAGE) - { - dot_pos = 0; - while (*p) - { - if (is_shift_jis (*p)) - p += 2; - else if (is_kana (*p)) - p ++; - else - { - if (*p == '.' && !dot_pos) - dot_pos = (char *) p; - if (!isdoschar(*p)) - return(False); - p++; - } - } - } - else + dot_pos = 0; + while (*p) + { + if((skip = skip_multibyte_char( *p )) != 0) + p += skip; + else { - while (*p) - { + if (*p == '.' && !dot_pos) + dot_pos = (char *) p; if (!isdoschar(*p)) return(False); p++; - } } } + } /* no dot and less than 9 means OK */ if (!dot_pos) @@ -542,6 +529,7 @@ void mangle_name_83(char *s) char base[9]; int baselen = 0; int extlen = 0; + int skip; extension[0]=0; base[0]=0; @@ -572,40 +560,29 @@ void mangle_name_83(char *s) *p++ = 0; while (*p && extlen < 3) { - if(lp_client_code_page() == KANJI_CODEPAGE) + skip = skip_multibyte_char(*p); + if (skip == 2) { - if (is_shift_jis (*p)) + if (extlen < 2) { - if (extlen < 2) - { - extension[extlen++] = p[0]; - extension[extlen++] = p[1]; - } - else - { - extension[extlen++] = base36 (((unsigned char) *p) % 36); - } - p += 2; + extension[extlen++] = p[0]; + extension[extlen++] = p[1]; } - else + else { - if( is_kana (*p) ) - { - extension[extlen++] = p[0]; - p++; - } - else - { - if (isdoschar (*p) && *p != '.') - extension[extlen++] = p[0]; - p++; - } + extension[extlen++] = base36 (((unsigned char) *p) % 36); } + p += 2; } - else + else if( skip == 1 ) { - if (isdoschar(*p) && *p != '.') - extension[extlen++] = *p; + extension[extlen++] = p[0]; + p++; + } + else + { + if (isdoschar (*p) && *p != '.') + extension[extlen++] = p[0]; p++; } } @@ -617,9 +594,8 @@ void mangle_name_83(char *s) while (*p && baselen < 5) { - if(lp_client_code_page() == KANJI_CODEPAGE) - { - if (is_shift_jis (*p)) + skip = skip_multibyte_char(*p); + if (skip == 2) { if (baselen < 4) { @@ -632,27 +608,17 @@ void mangle_name_83(char *s) } p += 2; } - else + else if( skip == 1) { - if( is_kana (*p) ) - { + base[baselen++] = p[0]; + p++; + } + else + { + if (isdoschar (*p) && *p != '.') base[baselen++] = p[0]; - p++; - } - else - { - if (isdoschar (*p) && *p != '.') - base[baselen++] = p[0]; - p++; - } + p++; } - } - else - { - if (isdoschar(*p) && *p != '.') - base[baselen++] = *p; - p++; - } } base[baselen] = 0; @@ -679,6 +645,7 @@ static BOOL illegal_name(char *name) static unsigned char illegal[256]; static BOOL initialised=False; unsigned char *s; + int skip; if( !initialised ) { @@ -690,26 +657,19 @@ static BOOL illegal_name(char *name) illegal[*s] = True; } - if(lp_client_code_page() == KANJI_CODEPAGE) + for (s = (unsigned char *)name; *s;) { - for (s = (unsigned char *)name; *s;) + skip = skip_multibyte_char( *s ); + if (skip != 0) + s += skip; + else { - if (is_shift_jis (*s)) - s += 2; + if (illegal[*s]) + return(True); else - { - if (illegal[*s]) - return(True); - else - s++; - } + s++; } } - else - { - for (s = (unsigned char *)name;*s;s++) - if (illegal[*s]) return(True); - } return(False); } /* illegal_name */ |