diff options
author | Jeremy Allison <jra@samba.org> | 1997-09-11 20:17:32 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1997-09-11 20:17:32 +0000 |
commit | 30416c0b8a0f54f6cc1179c2e00860eaf5f58401 (patch) | |
tree | 09137fd9f782aaf0df42e59aff10953ed95bed32 /source3/lib | |
parent | 77df5c87c69ea7f929df211c41da522248d73cfc (diff) | |
download | samba-30416c0b8a0f54f6cc1179c2e00860eaf5f58401.tar.gz samba-30416c0b8a0f54f6cc1179c2e00860eaf5f58401.tar.bz2 samba-30416c0b8a0f54f6cc1179c2e00860eaf5f58401.zip |
charcnv.c client.c clitar.c kanji.c kanji.h loadparm.c
mangle.c smb.h util.c:
Big merge to allow KANJI support to be in the main
binary without explicitly compiling with it.
locking.c: Fix for smbstatus not being able to read files.
namepacket.c: Removed unneccesary debug statement.
trans2.c: Added Luke's proposed fix (ifdefed out until further testing).
nmblookup.c: Fixed bug where query fails and status is done on bogus IP.
Jeremy (jallison@whistle.com)
(This used to be commit 9196255022ae8c51b527412747b324819bea2c13)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/charcnv.c | 38 | ||||
-rw-r--r-- | source3/lib/kanji.c | 5 | ||||
-rw-r--r-- | source3/lib/util.c | 432 |
3 files changed, 273 insertions, 202 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 6be455c47b..a7dff4224b 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -107,13 +107,18 @@ char *unix2dos_format(char *str,BOOL overwrite) char *dp; if (!mapsinited) initmaps(); - if (overwrite) { - for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p]; - return str; - } else { - for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p]; - *dp = 0; - return cvtbuf; + + if(lp_client_code_page() == KANJI_CODEPAGE) + return (*_unix_to_dos)(str, overwrite); + else { + if (overwrite) { + for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p]; + return str; + } else { + for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p]; + *dp = 0; + return cvtbuf; + } } } @@ -126,13 +131,18 @@ char *dos2unix_format(char *str, BOOL overwrite) char *dp; if (!mapsinited) initmaps(); - if (overwrite) { - for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p]; - return str; - } else { - for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p]; - *dp = 0; - return cvtbuf; + + if(lp_client_code_page() == KANJI_CODEPAGE) + return (*_dos_to_unix)(str, overwrite); + else { + if (overwrite) { + for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p]; + return str; + } else { + for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p]; + *dp = 0; + return cvtbuf; + } } } diff --git a/source3/lib/kanji.c b/source3/lib/kanji.c index 479763fd40..f5888e4877 100644 --- a/source3/lib/kanji.c +++ b/source3/lib/kanji.c @@ -23,7 +23,6 @@ and add all jis codes sequence type at 1995.8.16 Notes: Hexadecimal code by <ohki@gssm.otuka.tsukuba.ac.jp> */ -#ifdef KANJI #define _KANJI_C_ #include "includes.h" @@ -888,7 +887,3 @@ int interpret_coding_system(char *str, int def) } return setup_string_function (codes); } -#else - int kanji_dummy_procedure(void) -{return 0;} -#endif /* KANJI */ diff --git a/source3/lib/util.c b/source3/lib/util.c index 7f922def7e..ce0b8bc768 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -813,53 +813,59 @@ int StrCaseCmp(const char *s, const char *t) /* We *must* use toupper rather than tolower here due to the asynchronous upper to lower mapping. */ -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - int diff; - for (;;) +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) { - if (!*s || !*t) - return toupper (*s) - toupper (*t); - else if (is_sj_alph (*s) && is_sj_alph (*t)) - { - diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1)); - if (diff) - return diff; - s += 2; - t += 2; - } - else if (is_shift_jis (*s) && is_shift_jis (*t)) - { - diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t); - if (diff) - return diff; - diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1)); - if (diff) - return diff; - s += 2; - t += 2; - } - else if (is_shift_jis (*s)) - return 1; - else if (is_shift_jis (*t)) - return -1; - else - { - diff = toupper (*s) - toupper (*t); - if (diff) - return diff; - s++; - t++; - } + /* Win95 treats full width ascii characters as case sensitive. */ + int diff; + for (;;) + { + if (!*s || !*t) + return toupper (*s) - toupper (*t); + else if (is_sj_alph (*s) && is_sj_alph (*t)) + { + diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1)); + if (diff) + return diff; + s += 2; + t += 2; + } + else if (is_shift_jis (*s) && is_shift_jis (*t)) + { + diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t); + if (diff) + return diff; + diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1)); + if (diff) + return diff; + s += 2; + t += 2; + } + else if (is_shift_jis (*s)) + return 1; + else if (is_shift_jis (*t)) + return -1; + else + { + diff = toupper (*s) - toupper (*t); + if (diff) + return diff; + s++; + t++; + } + } } -#else /* KANJI */ - while (*s && *t && toupper(*s) == toupper(*t)) + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { - s++; t++; - } + while (*s && *t && toupper(*s) == toupper(*t)) + { + s++; + t++; + } - return(toupper(*s) - toupper(*t)); -#endif /* KANJI */ + return(toupper(*s) - toupper(*t)); + } } /******************************************************************* @@ -871,61 +877,69 @@ int StrnCaseCmp(const char *s, const char *t, int n) /* We *must* use toupper rather than tolower here due to the asynchronous upper to lower mapping. */ -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - int diff; - for (;n > 0;) +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) { - if (!*s || !*t) - return toupper (*s) - toupper (*t); - else if (is_sj_alph (*s) && is_sj_alph (*t)) - { - diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1)); - if (diff) - return diff; - s += 2; - t += 2; - n -= 2; - } - else if (is_shift_jis (*s) && is_shift_jis (*t)) - { - diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t); - if (diff) - return diff; - diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1)); - if (diff) - return diff; - s += 2; - t += 2; - n -= 2; - } - else if (is_shift_jis (*s)) - return 1; - else if (is_shift_jis (*t)) - return -1; - else - { - diff = toupper (*s) - toupper (*t); - if (diff) - return diff; - s++; - t++; - n--; - } + /* Win95 treats full width ascii characters as case sensitive. */ + int diff; + for (;n > 0;) + { + if (!*s || !*t) + return toupper (*s) - toupper (*t); + else if (is_sj_alph (*s) && is_sj_alph (*t)) + { + diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1)); + if (diff) + return diff; + s += 2; + t += 2; + n -= 2; + } + else if (is_shift_jis (*s) && is_shift_jis (*t)) + { + diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t); + if (diff) + return diff; + diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1)); + if (diff) + return diff; + s += 2; + t += 2; + n -= 2; + } + else if (is_shift_jis (*s)) + return 1; + else if (is_shift_jis (*t)) + return -1; + else + { + diff = toupper (*s) - toupper (*t); + if (diff) + return diff; + s++; + t++; + n--; + } + } + return 0; } - return 0; -#else /* KANJI */ - while (n-- && *s && *t && toupper(*s) == toupper(*t)) + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { - s++; t++; - } + while (n-- && *s && *t && toupper(*s) == toupper(*t)) + { + s++; + t++; + } - /* not run out of chars - strings are different lengths */ - if (n) return(toupper(*s) - toupper(*t)); + /* not run out of chars - strings are different lengths */ + if (n) + return(toupper(*s) - toupper(*t)); - /* identical up to where we run out of chars, and strings are same length */ - return(0); -#endif /* KANJI */ + /* identical up to where we run out of chars, + and strings are same length */ + return(0); + } } /******************************************************************* @@ -968,27 +982,36 @@ BOOL strcsequal(char *s1,char *s2) void strlower(char *s) { while (*s) + { +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + /* Win95 treats full width ascii characters as case sensitive. */ + if (is_shift_jis (*s)) + { + if (is_sj_upper (s[0], s[1])) + s[1] = sj_tolower2 (s[1]); + s += 2; + } + else if (is_kana (*s)) + { + s++; + } + else + { + if (isupper(*s)) + *s = tolower(*s); + s++; + } + } + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - if (is_shift_jis (*s)) { - if (is_sj_upper (s[0], s[1])) { - s[1] = sj_tolower2 (s[1]); - } - s += 2; - } else if (is_kana (*s)) { - s++; - } else { - if (isupper(*s)) - *s = tolower(*s); - s++; - } -#else /* KANJI */ if (isupper(*s)) - *s = tolower(*s); + *s = tolower(*s); s++; -#endif /* KANJI */ } + } } /******************************************************************* @@ -997,27 +1020,36 @@ void strlower(char *s) void strupper(char *s) { while (*s) + { +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + /* Win95 treats full width ascii characters as case sensitive. */ + if (is_shift_jis (*s)) + { + if (is_sj_lower (s[0], s[1])) + s[1] = sj_toupper2 (s[1]); + s += 2; + } + else if (is_kana (*s)) + { + s++; + } + else + { + if (islower(*s)) + *s = toupper(*s); + s++; + } + } + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - if (is_shift_jis (*s)) { - if (is_sj_lower (s[0], s[1])) { - s[1] = sj_toupper2 (s[1]); - } - s += 2; - } else if (is_kana (*s)) { - s++; - } else { - if (islower(*s)) - *s = toupper(*s); - s++; - } -#else /* KANJI */ if (islower(*s)) - *s = toupper(*s); + *s = toupper(*s); s++; -#endif /* KANJI */ } + } } /******************************************************************* @@ -1049,24 +1081,30 @@ BOOL strisnormal(char *s) void string_replace(char *s,char oldc,char newc) { while (*s) + { +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + /* Win95 treats full width ascii characters as case sensitive. */ + if (is_shift_jis (*s)) + s += 2; + else if (is_kana (*s)) + s++; + else + { + if (oldc == *s) + *s = newc; + s++; + } + } + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - if (is_shift_jis (*s)) { - s += 2; - } else if (is_kana (*s)) { - s++; - } else { - if (oldc == *s) - *s = newc; - s++; - } -#else /* KANJI */ if (oldc == *s) - *s = newc; + *s = newc; s++; -#endif /* KANJI */ } + } } /**************************************************************************** @@ -1688,22 +1726,30 @@ does a string have any uppercase chars in it? BOOL strhasupper(char *s) { while (*s) + { +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + /* Win95 treats full width ascii characters as case sensitive. */ + if (is_shift_jis (*s)) + s += 2; + else if (is_kana (*s)) + s++; + else + { + if (isupper(*s)) + return(True); + s++; + } + } + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - if (is_shift_jis (*s)) { - s += 2; - } else if (is_kana (*s)) { - s++; - } else { - if (isupper(*s)) return(True); - s++; - } -#else /* KANJI */ - if (isupper(*s)) return(True); + if (isupper(*s)) + return(True); s++; -#endif /* KANJI */ } + } return(False); } @@ -1713,24 +1759,38 @@ does a string have any lowercase chars in it? BOOL strhaslower(char *s) { while (*s) + { +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) { -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - if (is_shift_jis (*s)) { - if (is_sj_upper (s[0], s[1])) return(True); - if (is_sj_lower (s[0], s[1])) return (True); - s += 2; - } else if (is_kana (*s)) { - s++; - } else { - if (islower(*s)) return(True); - s++; - } -#else /* KANJI */ - if (islower(*s)) return(True); + /* Win95 treats full width ascii characters as case sensitive. */ + if (is_shift_jis (*s)) + { + if (is_sj_upper (s[0], s[1])) + return(True); + if (is_sj_lower (s[0], s[1])) + return (True); + s += 2; + } + else if (is_kana (*s)) + { + s++; + } + else + { + if (islower(*s)) + return(True); + s++; + } + } + else +#endif /* KANJI_WIN95_COMPATIBILITY */ + { + if (islower(*s)) + return(True); s++; -#endif /* KANJI */ } + } return(False); } @@ -1740,27 +1800,33 @@ find the number of chars in a string int count_chars(char *s,char c) { int count=0; -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - while (*s) + +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + /* Win95 treats full width ascii characters as case sensitive. */ + while (*s) { - if (is_shift_jis (*s)) - s += 2; - else - { - if (*s == c) - count++; - s++; + if (is_shift_jis (*s)) + s += 2; + else + { + if (*s == c) + count++; + s++; + } } } -#else /* KANJI */ - while (*s) + else +#endif /* KANJI_WIN95_COMPATIBILITY */ + { + while (*s) { if (*s == c) - count++; + count++; s++; } -#endif /* KANJI */ + } return(count); } |