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 | b7fb6c6b38784d25c9c85e9b27b08e30111dbd0c (patch) | |
tree | ff98efd1c5b4f92782b9687791a321037e2f9e6d /source3/smbd | |
parent | f0e121d100ef207b683fbb8d3079403e22929d0a (diff) | |
download | samba-b7fb6c6b38784d25c9c85e9b27b08e30111dbd0c.tar.gz samba-b7fb6c6b38784d25c9c85e9b27b08e30111dbd0c.tar.bz2 samba-b7fb6c6b38784d25c9c85e9b27b08e30111dbd0c.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.
(This used to be commit 299016338cfb47f0c585875ef9b468121fcee97d)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/mangle.c | 136 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 5 |
2 files changed, 53 insertions, 88 deletions
diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c index 7b6a563511..d0d5ada247 100644 --- a/source3/smbd/mangle.c +++ b/source3/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 */ diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 35272ae3d9..3cd6c138c8 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -908,11 +908,14 @@ resume_key = %d resume name = %s continue=%d level = %d\n", start_pos = TellDir(dirptr); for(current_pos = start_pos; current_pos >= 0; current_pos--) { + DEBUG(7,("call_trans2findnext: seeking to pos %d\n", current_pos)); + SeekDir(dirptr, current_pos); dname = ReadDirName(dirptr); if(dname && strcsequal( resume_name, dname)) { SeekDir(dirptr, current_pos+1); + DEBUG(7,("call_trans2findnext: got match at pos %d\n", current_pos+1 )); break; } } @@ -923,12 +926,14 @@ resume_key = %d resume name = %s continue=%d level = %d\n", if(current_pos < 0) { + DEBUG(7,("call_trans2findnext: notfound: seeking to pos %d\n", start_pos)); SeekDir(dirptr, start_pos); for(current_pos = start_pos; (dname = ReadDirName(dirptr)) != NULL; SeekDir(dirptr,++current_pos)) { if(strcsequal( resume_name, dname)) { SeekDir(dirptr, current_pos+1); + DEBUG(7,("call_trans2findnext: got match at pos %d\n", current_pos+1 )); break; } } /* end for */ |