summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-10-03 02:12:14 +0000
committerJeremy Allison <jra@samba.org>2000-10-03 02:12:14 +0000
commit3ad2ee22bb4ecee24d069bb7efadff18c25044d1 (patch)
tree833839953637fd990b712717df13efffa5b6ae10 /source3
parent2679fa315da579fbdc7dd35d3ee1cb364b85a1d9 (diff)
downloadsamba-3ad2ee22bb4ecee24d069bb7efadff18c25044d1.tar.gz
samba-3ad2ee22bb4ecee24d069bb7efadff18c25044d1.tar.bz2
samba-3ad2ee22bb4ecee24d069bb7efadff18c25044d1.zip
utf-8 and EUC3 patch from Hiroshi Miura Samba User Group Japan staff.
mkdir high bits patch from Robert Dahlem" <Robert.Dahlem@gmx.net>. jeremy. (This used to be commit b40191d27180ab1e59935086073c4d312552f717)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/kanji.h570
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/include/vfs.h6
-rw-r--r--source3/lib/doscalls.c2
-rw-r--r--source3/lib/kanji.c473
-rw-r--r--source3/lib/util_unistr.c14
-rw-r--r--source3/param/loadparm.c1
-rw-r--r--source3/smbd/open.c3
-rw-r--r--source3/smbd/reply.c3
-rw-r--r--source3/smbd/trans2.c3
-rw-r--r--source3/smbd/vfs.c24
11 files changed, 1080 insertions, 22 deletions
diff --git a/source3/include/kanji.h b/source3/include/kanji.h
index 1dd8f108c6..f5e198c2ee 100644
--- a/source3/include/kanji.h
+++ b/source3/include/kanji.h
@@ -30,7 +30,7 @@
/* FOR SHIFT JIS CODE */
#define is_shift_jis(c) \
((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f) \
- || (0xe0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xef))
+ || (0xe0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfc))
#define is_shift_jis2(c) \
(0x40 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfc \
&& ((unsigned char) (c)) != 0x7f)
@@ -52,12 +52,33 @@
(is_sj_upper2 (c) ? ((int) ((unsigned char) (c) - 0x60 + 0x81)) : \
((int) (unsigned char) (c)))
+#define is_sj_ru_upper2(c) \
+ ((0x40 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x60))
+#define is_sj_ru_lower2(c) \
+ (((0x70 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x7e)) || \
+ ((0x80 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x91)))
+#define sjis_russian 0x84
+#define is_sj_russian(c) (sjis_russian == (unsigned char) (c))
+#define is_sj_ru_upper(c1, c2) (is_sj_russian (c1) && is_sj_ru_upper2 (c2))
+#define is_sj_ru_lower(c1, c2) (is_sj_russian (c1) && is_sj_ru_lower2 (c2))
+#define sj_ru_toupper2(c) \
+ (is_sj_ru_lower2 (c) ? ((int) ((unsigned char) (c) + \
+ (((unsigned char)(c) >= 0x4f) ? (0x70 - 0x40) : (0x80 - 0x4f)))) : \
+ ((int) (unsigned char) (c)))
+#define sj_ru_tolower2(c) \
+ (is_sj_ru_upper2 (c) ? ((int) ((unsigned char) (c) - \
+ (((unsigned char)(c) >= 0x80) ? (0x70 - 0x40) : (0x80 - 0x4f)))) : \
+ ((int) (unsigned char) (c)))
+
#ifdef _KANJI_C_
/* FOR EUC CODE */
#define euc_kana (0x8e)
#define is_euc_kana(c) (((unsigned char) (c)) == euc_kana)
#define is_euc(c) (0xa0 < ((unsigned char) (c)) && ((unsigned char) (c)) < 0xff)
+#define euc_sup (0x8f)
+#define is_euc_sup(c) (((unsigned char ) (c)) == euc_sup)
+
/* FOR JIS CODE */
/* default jis third shift code, use for output */
#ifndef JIS_KSO
@@ -167,5 +188,552 @@ extern int (*_skip_multibyte_char)(char c);
#define HEX_CODE (5)
#define CAP_CODE (6)
#define DOSV_CODE SJIS_CODE
+#define EUC3_CODE (7)
+#define UTF8_CODE (8)
+
+#ifdef _KANJI_C_
+
+/* For conversion */
+
+#define EXTSJISC(c) (0xf0 <= ((unsigned char)(c)) \
+ && ((unsigned char)(c) <= 0xfc))
+#define GETAHI (0x81)
+#define GETALO (0xac)
+
+typedef struct _sjis_regur_t {
+ int start;
+ int end;
+ int rstart;
+} sjis_regur_t;
+
+/* When Converting to EUC and JIS, there is no room for
+ * these SJIS codes whose hi byte is larger than 0xf0.
+ *
+ * So we must drop or convert it to harmless code.
+ * This is not standard way, so it is ad hoc but practical.
+ * It is also thought of backward and future compatibility.
+ *
+ * Miura.
+ */
+
+static sjis_regur_t sjisconv[] = {
+{0xfa40, 0xfa49, 0xeeef},
+{0xfa4a, 0xfa53, 0x8754},
+{0xfa54, 0xfa54, 0x81ca},
+{0xfa55, 0xfa57, 0xeefa},
+{0xfa58, 0xfa58, 0x878a},
+{0xfa59, 0xfa59, 0x8782},
+{0xfa5a, 0xfa5a, 0x8784},
+{0xfa5b, 0xfa5b, 0x81e6},
+{0xfa5c, 0xfa7e, 0xed40},
+{0xfa80, 0xfa9b, 0xed63},
+{0xfa9c, 0xfafc, 0xed80},
+{0xfb40, 0xfb5b, 0xede1},
+{0xfb5c, 0xfb7e, 0xee40},
+{0xfb80, 0xfb9b, 0xee63},
+{0xfb9c, 0xfbfc, 0xee80},
+{0xfc40, 0xfc4b, 0xeee1}
+};
+#define SJISCONVTBLSIZ (sizeof(sjisconv) / sizeof(sjis_regur_t))
+
+static sjis_regur_t sjisrev[] = {
+{0x81ca, 0x81ca, 0xfa54},
+{0x81e6, 0x81e6, 0xfa5b},
+{0x8754, 0x875d, 0xfa4a},
+{0x8782, 0x8782, 0xfa59},
+{0x8784, 0x8784, 0xfa5a},
+{0x878a, 0x878a, 0xfa58},
+{0xed40, 0xed62, 0xfa5c},
+{0xed63, 0xed7e, 0xfa80},
+{0xed80, 0xede0, 0xfa9c},
+{0xede1, 0xedfc, 0xfb40},
+{0xee40, 0xee62, 0xfb5c},
+{0xee63, 0xee7e, 0xfb80},
+{0xee80, 0xeee0, 0xfb9c},
+{0xeee1, 0xeeec, 0xfc40},
+{0xeeef, 0xeef8, 0xfa40},
+{0xeefa, 0xeefc, 0xfa55}
+};
+#define SJISREVTBLSIZ (sizeof(sjisrev) / sizeof(sjis_regur_t))
+/* EUC3BYTE DEFINITIONS */
+
+typedef struct _sjis_euc_map_t {
+ int sjis;
+ int euc;
+} sjis_euc_map_t;
+
+static sjis_euc_map_t euc3conv2[] = {
+{0x8754 , 0xf3fd},
+{0x8755 , 0xf3fe},
+{0x8756 , 0xf4a1},
+{0x8757 , 0xf4a2},
+{0x8758 , 0xf4a3},
+{0x8759 , 0xf4a4},
+{0x875a , 0xf4a5},
+{0x875b , 0xf4a6},
+{0x875c , 0xf4a7},
+{0x875d , 0xf4a8},
+{0x8782 , 0xf4ac},
+{0x8784 , 0xf4ad},
+{0x878a , 0xf4ab}
+};
+#define EUC3CONV2TBLSIZ (sizeof(euc3conv2) / sizeof(sjis_euc_map_t))
+
+
+/* IBM Kanji to EUC 3byte */
+static int euc3conv[] = {
+/* 0xfa40 */
+0xf3f3, 0xf3f4, 0xf3f5, 0xf3f6, 0xf3f7, 0xf3f8, 0xf3f9, 0xf3fa, 0xf3fb, 0xf3fc, 0xf3fd, 0xf3fe, 0xf4a1, 0xf4a2, 0xf4a3, 0xf4a4,
+/* 0xfa50 */
+0xf4a5, 0xf4a6, 0xf4a7, 0xf4a8, 0, 0xa2c3, 0xf4a9, 0xf4aa, 0xf4ab, 0xf4ac, 0xf4ad, 0, 0xd4e3, 0xdcdf, 0xe4e9, 0xe3f8,
+/* 0xfa60 */
+0xd9a1, 0xb1bb, 0xf4ae, 0xc2ad, 0xc3fc, 0xe4d0, 0xc2bf, 0xbcf4, 0xb0a9, 0xb0c8, 0xf4af, 0xb0d2, 0xb0d4, 0xb0e3, 0xb0ee, 0xb1a7,
+/* 0xfa70 */
+0xb1a3, 0xb1ac, 0xb1a9, 0xb1be, 0xb1df, 0xb1d8, 0xb1c8, 0xb1d7, 0xb1e3, 0xb1f4, 0xb1e1, 0xb2a3, 0xf4b0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4, 0xfa6c},
+{0xb0e3, 0xfa6d},
+{0xb0ee, 0xfa6e},
+{0xb1a3, 0xfa70},
+{0xb1a7, 0xfa6f},
+{0xb1a9, 0xfa72},
+{0xb1ac, 0xfa71},
+{0xb1bb, 0xfa61},
+{0xb1be, 0xfa73},
+{0xb1c8, 0xfa76},
+{0xb1d7, 0xfa77},
+{0xb1d8, 0xfa75},
+{0xb1df, 0xfa74},
+{0xb1e1, 0xfa7a},
+{0xb1e3, 0xfa78},
+{0xb1f4, 0xfa79},
+{0xb2a3, 0xfa7b},
+{0xb2bb, 0xfa7d},
+{0xb2e6, 0xfa7e},
+{0xb2ed, 0xfa80},
+{0xb2f5, 0xfa81},
+{0xb2fc, 0xfa82},
+{0xb3b5, 0xfa84},
+{0xb3d8, 0xfa85},
+{0xb3db, 0xfa86},
+{0xb3dd, 0xfb77},
+{0xb3e5, 0xfa87},
+{0xb3ee, 0xfa88},
+{0xb3fb, 0xfa89},
+{0xb4c0, 0xfa8c},
+{0xb4c7, 0xfa8d},
+{0xb4d0, 0xfa8e},
+{0xb4de, 0xfa8f},
+{0xb5aa, 0xfa91},
+{0xb5af, 0xfa93},
+{0xb5c4, 0xfa94},
+{0xb5e8, 0xfa95},
+{0xb7c2, 0xfa97},
+{0xb7e4, 0xfa98},
+{0xb7e7, 0xfa9a},
+{0xb7e8, 0xfa99},
+{0xb8ce, 0xfa9e},
+{0xb8e1, 0xfa9f},
+{0xb8f5, 0xfaa0},
+{0xb8f7, 0xfaa1},
+{0xb8f8, 0xfaa2},
+{0xb8fc, 0xfaa3},
+{0xb9af, 0xfaa4},
+{0xb9b7, 0xfaa5},
+{0xbabe, 0xfaa6},
+{0xbadb, 0xfaa7},
+{0xbae1, 0xfaa9},
+{0xbaeb, 0xfaab},
+{0xbbb3, 0xfaac},
+{0xbbb8, 0xfaad},
+{0xbbca, 0xfaaf},
+{0xbbd0, 0xfab2},
+{0xbbde, 0xfab3},
+{0xbbf4, 0xfab4},
+{0xbbf5, 0xfab5},
+{0xbbf9, 0xfab6},
+{0xbce4, 0xfab7},
+{0xbced, 0xfab8},
+{0xbcf4, 0xfa67},
+{0xbcfe, 0xfab9},
+{0xbdc2, 0xfabb},
+{0xbde7, 0xfabc},
+{0xbdf0, 0xfabe},
+{0xbeac, 0xfac0},
+{0xbeb0, 0xfabf},
+{0xbeb3, 0xfac2},
+{0xbebd, 0xfac3},
+{0xbec9, 0xfac5},
+{0xbecd, 0xfac4},
+{0xbee4, 0xfac6},
+{0xbfa8, 0xfac7},
+{0xbfc9, 0xfac8},
+{0xc0c4, 0xfac9},
+{0xc0e4, 0xfaca},
+{0xc0f4, 0xfacb},
+{0xc1a6, 0xfacc},
+{0xc1f5, 0xface},
+{0xc1f8, 0xfad1},
+{0xc1fc, 0xfacf},
+{0xc2a1, 0xfad3},
+{0xc2a5, 0xfad4},
+{0xc2ab, 0xfad2},
+{0xc2ad, 0xfa63},
+{0xc2b8, 0xfad6},
+{0xc2ba, 0xfad7},
+{0xc2bf, 0xfa66},
+{0xc2c4, 0xfad9},
+{0xc2d2, 0xfada},
+{0xc2d7, 0xfadb},
+{0xc2db, 0xfadc},
+{0xc2de, 0xfadd},
+{0xc2ed, 0xfade},
+{0xc2f0, 0xfadf},
+{0xc3a1, 0xfae1},
+{0xc3b5, 0xfae2},
+{0xc3b9, 0xfae4},
+{0xc3c9, 0xfae3},
+{0xc3d8, 0xfae6},
+{0xc3fc, 0xfa64},
+{0xc3fe, 0xfae7},
+{0xc4cc, 0xfae9},
+{0xc4d9, 0xfaeb},
+{0xc4ea, 0xfaec},
+{0xc4fd, 0xfaed},
+{0xc5a7, 0xfaef},
+{0xc5b5, 0xfaf0},
+{0xc5b6, 0xfaf1},
+{0xc5d5, 0xfaf3},
+{0xc6b8, 0xfaf4},
+{0xc6d7, 0xfaf5},
+{0xc6e0, 0xfaf6},
+{0xc6e3, 0xfaf8},
+{0xc6ea, 0xfaf7},
+{0xc7a1, 0xfaf9},
+{0xc7ab, 0xfafa},
+{0xc7c3, 0xfafc},
+{0xc7c7, 0xfafb},
+{0xc7cb, 0xfb40},
+{0xc7cf, 0xfb41},
+{0xc7d9, 0xfb42},
+{0xc7e6, 0xfb45},
+{0xc7eb, 0xfb48},
+{0xc7ee, 0xfb46},
+{0xc7f0, 0xfb49},
+{0xc7fc, 0xfb47},
+{0xc8b1, 0xfb4a},
+{0xc8e5, 0xfb4b},
+{0xc8f8, 0xfb4c},
+{0xc9a6, 0xfb4d},
+{0xc9ab, 0xfb4e},
+{0xc9ad, 0xfb4f},
+{0xc9ca, 0xfb51},
+{0xc9d3, 0xfb52},
+{0xc9e3, 0xfb54},
+{0xc9e9, 0xfb53},
+{0xc9f4, 0xfb56},
+{0xc9f5, 0xfb57},
+{0xc9fc, 0xfb55},
+{0xcab3, 0xfb59},
+{0xcabd, 0xfb5a},
+{0xcaef, 0xfb5b},
+{0xcaf1, 0xfb5c},
+{0xcbae, 0xfb5d},
+{0xcbca, 0xfb5f},
+{0xcbe6, 0xfb60},
+{0xcbea, 0xfb61},
+{0xcbee, 0xfb64},
+{0xcbf0, 0xfb62},
+{0xcbf4, 0xfb63},
+{0xcbf9, 0xfb66},
+{0xcca5, 0xfb65},
+{0xccab, 0xfb67},
+{0xccad, 0xfb69},
+{0xccae, 0xfb68},
+{0xccb2, 0xfb6a},
+{0xccc2, 0xfb6b},
+{0xccd0, 0xfb6c},
+{0xccd9, 0xfb6d},
+{0xcdaa, 0xfaa8},
+{0xcdbb, 0xfb6f},
+{0xceba, 0xfb73},
+{0xcebb, 0xfb71},
+{0xcec3, 0xfb74},
+{0xcef2, 0xfb76},
+{0xcfd5, 0xfb78},
+{0xcfe2, 0xfb79},
+{0xcfe9, 0xfb7a},
+{0xcfed, 0xfb7b},
+{0xd0e5, 0xfb81},
+{0xd0e9, 0xfb83},
+{0xd1e8, 0xfb84},
+{0xd1ec, 0xfb87},
+{0xd2bb, 0xfb88},
+{0xd3e1, 0xfb8a},
+{0xd3e8, 0xfb8b},
+{0xd4a7, 0xf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, 0xfa58},
+{0xf4ac, 0xfa59},
+{0xf4ad, 0xfa5a},
+{0xf4ae, 0xfa62},
+{0xf4af, 0xfa6a},
+{0xf4b0, 0xfa7c},
+{0xf4b1, 0xfa83},
+{0xf4b2, 0xfa8a},
+{0xf4b3, 0xfa8b},
+{0xf4b4, 0xfa90},
+{0xf4b5, 0xfa92},
+{0xf4b6, 0xfa96},
+{0xf4b7, 0xfa9b},
+{0xf4b8, 0xfa9c},
+{0xf4b9, 0xfa9d},
+{0xf4ba, 0xfaaa},
+{0xf4bb, 0xfaae},
+{0xf4bc, 0xfab0},
+{0xf4bd, 0xfab1},
+{0xf4be, 0xfaba},
+{0xf4bf, 0xfabd},
+{0xf4c0, 0xfac1},
+{0xf4c1, 0xfacd},
+{0xf4c2, 0xfad0},
+{0xf4c3, 0xfad5},
+{0xf4c4, 0xfad8},
+{0xf4c5, 0xfae0},
+{0xf4c6, 0xfae5},
+{0xf4c7, 0xfae8},
+{0xf4c8, 0xfaea},
+{0xf4c9, 0xfaee},
+{0xf4ca, 0xfaf2},
+{0xf4cb, 0xfb43},
+{0xf4cc, 0xfb44},
+{0xf4cd, 0xfb50},
+{0xf4ce, 0xfb58},
+{0xf4cf, 0xfb5e},
+{0xf4d0, 0xfb6e},
+{0xf4d1, 0xfb70},
+{0xf4d2, 0xfb72},
+{0xf4d3, 0xfb75},
+{0xf4d4, 0xfb7c},
+{0xf4d5, 0xfb7d},
+{0xf4d6, 0xfb7e},
+{0xf4d7, 0xfb80},
+{0xf4d8, 0xfb82},
+{0xf4d9, 0xfb85},
+{0xf4da, 0xfb86},
+{0xf4db, 0xfb89},
+{0xf4dc, 0xfb8d},
+{0xf4dd, 0xfb8e},
+{0xf4de, 0xfb92},
+{0xf4df, 0xfb94},
+{0xf4e0, 0xfb9d},
+{0xf4e1, 0xfb9e},
+{0xf4e2, 0xfb9f},
+{0xf4e3, 0xfba0},
+{0xf4e4, 0xfba1},
+{0xf4e5, 0xfba9},
+{0xf4e6, 0xfbac},
+{0xf4e7, 0xfbae},
+{0xf4e8, 0xfbb0},
+{0xf4e9, 0xfbb1},
+{0xf4ea, 0xfbb3},
+{0xf4eb, 0xfbb4},
+{0xf4ec, 0xfbb6},
+{0xf4ed, 0xfbb7},
+{0xf4ee, 0xfbb8},
+{0xf4ef, 0xfbd3},
+{0xf4f0, 0xfbda},
+{0xf4f1, 0xfbe8},
+{0xf4f2, 0xfbe9},
+{0xf4f3, 0xfbea},
+{0xf4f4, 0xfbee},
+{0xf4f5, 0xfbf0},
+{0xf4f6, 0xfbf2},
+{0xf4f7, 0xfbf6},
+{0xf4f8, 0xfbf7},
+{0xf4f9, 0xfbf9},
+{0xf4fa, 0xfbfa},
+{0xf4fb, 0xfbfc},
+{0xf4fc, 0xfc42},
+{0xf4fd, 0xfc49},
+{0xf4fe, 0xfc4b},
+};
+
+#define EUC3REVTBLSIZ (sizeof(euc3rev) / sizeof(sjis_euc_revmap_t))
+
+#endif /* _KANJI_C_ */
#endif /* _KANJI_H_ */
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f06a0a790f..1a54aae928 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -616,6 +616,8 @@ void all_string_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *
void split_at_last_component_w(smb_ucs2_t *path, smb_ucs2_t *front, smb_ucs2_t sep, smb_ucs2_t *back);
smb_ucs2_t *octal_string_w(int i);
smb_ucs2_t *string_truncate_w(smb_ucs2_t *s, size_t length);
+smb_ucs2_t doscp2ucs2(int w);
+int ucs2doscp(smb_ucs2_t w);
/*The following definitions come from lib/wins_srv.c */
@@ -3868,6 +3870,7 @@ int vfs_init_default(connection_struct *conn);
BOOL vfs_init_custom(connection_struct *conn);
int vfs_stat(connection_struct *conn, char *fname, SMB_STRUCT_STAT *st);
BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st);
+int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode);
int vfs_unlink(connection_struct *conn, char *fname);
int vfs_chmod(connection_struct *conn, char *fname,mode_t mode);
int vfs_chown(connection_struct *conn, char *fname, uid_t uid, gid_t gid);
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index e657354d94..840377627b 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -191,8 +191,10 @@ struct vfs_ops {
int (*ftruncate)(int fd, SMB_OFF_T offset);
BOOL (*lock)(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
#if 0
- size_t (*get_nt_acl)(files_struct *fsp, SEC_DESC **ppdesc);
- BOOL (*set_nt_acl)(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd);
+ size_t (*fget_nt_acl)(int fd, SEC_DESC **ppdesc);
+ size_t (*get_nt_acl)(char *name, SEC_DESC **ppdesc);
+ BOOL (*fset_nt_acl)(int fd, uint32 security_info_sent, SEC_DESC *psd);
+ BOOL (*set_nt_acl)(char *name, uint32 security_info_sent, SEC_DESC *psd);
#endif
};
diff --git a/source3/lib/doscalls.c b/source3/lib/doscalls.c
index 50c446faeb..8d0071dde6 100644
--- a/source3/lib/doscalls.c
+++ b/source3/lib/doscalls.c
@@ -112,6 +112,7 @@ int dos_lstat(char *fname,SMB_STRUCT_STAT *sbuf)
return(sys_lstat(dos_to_unix(fname,False),sbuf));
}
+#if 0 /* VFS */
/*******************************************************************
Mkdir() that calls dos_to_unix.
Cope with UNIXes that don't allow high order mode bits on mkdir.
@@ -128,6 +129,7 @@ int dos_mkdir(char *dname,mode_t mode)
else
return ret;
}
+#endif
/*******************************************************************
Rmdir() - call dos_to_unix.
diff --git a/source3/lib/kanji.c b/source3/lib/kanji.c
index 43b22c19cc..fe65f98b58 100644
--- a/source3/lib/kanji.c
+++ b/source3/lib/kanji.c
@@ -22,6 +22,8 @@
and extend coding system to EUC/SJIS/JIS/HEX at 1994.10.11
and add all jis codes sequence type at 1995.8.16
Notes: Hexadecimal code by <ohki@gssm.otuka.tsukuba.ac.jp>
+ Adding features about Machine dependent codes and User Defined Codes
+ by Hiroshi MIURA <miura@samba.gr.jp> 2000.3.19
*/
#define _KANJI_C_
@@ -387,15 +389,63 @@ static char cvtbuf[2*sizeof(pstring)];
static int euc2sjis (int hi, int lo)
{
- if (hi & 1)
- return ((hi / 2 + (hi < 0xdf ? 0x31 : 0x71)) << 8) |
- (lo - (lo >= 0xe0 ? 0x60 : 0x61));
- else
- return ((hi / 2 + (hi < 0xdf ? 0x30 : 0x70)) << 8) | (lo - 2);
+ int w;
+ int maxidx = SJISREVTBLSIZ;
+ int minidx = 0;
+ int i = 2;
+
+ if (hi & 1) {
+ hi = hi / 2 + (hi < 0xdf ? 0x31 : 0x71);
+ w = (hi << 8) | (lo - (lo >= 0xe0 ? 0x60 : 0x61));
+ } else {
+ hi = hi / 2 + (hi < 0xdf ? 0x30 : 0x70);
+ w = (hi << 8) | (lo - 2);
+ }
+ if ( (0x87 < hi ) && (hi < 0xed ) ) {
+ return w;
+ }
+ while ( maxidx >= minidx ) {
+ if ( sjisrev[i].start > w ) {
+ maxidx = i-1;
+ } else if ( w > sjisrev[i].end ) {
+ minidx = i+1;
+ } else {
+ w -= sjisrev[i].start;
+ w += sjisrev[i].rstart;
+ break;
+ }
+ i = (int)( minidx + (maxidx - minidx) % 2 );
+ }
+ return w;
}
static int sjis2euc (int hi, int lo)
{
+ int minidx = 0;
+ int maxidx = SJISCONVTBLSIZ;
+ int i = ( 0 + SJISCONVTBLSIZ ) % 2;
+ int w = (int)((hi << 8) | lo);
+
+ if ( (sjisconv[0].start < w) && (w < sjisconv[SJISCONVTBLSIZ].end) ) {
+ while (maxidx >= minidx) {
+ if ( sjisconv[i].start > w ) {
+ maxidx = i-1;
+ } else if (w > sjisconv[i].end) {
+ minidx = i+1;
+ } else {
+ w -= sjisconv[i].start;
+ w += sjisconv[i].rstart;
+ break;
+ }
+ i = (int)( minidx + (maxidx-minidx)%2 );
+ }
+ hi = (int) ((w >> 8) & 0xff);
+ lo = (int) (w & 0xff);
+ }
+ if (hi >= 0xf0) {
+ hi = GETAHI;
+ lo = GETALO;
+ }
if (lo >= 0x9f)
return ((hi * 2 - (hi >= 0xe0 ? 0xe0 : 0x60)) << 8) | (lo + 2);
else
@@ -418,7 +468,7 @@ static char *sj_to_euc(char *from, BOOL overwrite)
if (is_shift_jis (*from)) {
int code = sjis2euc ((int) from[0] & 0xff, (int) from[1] & 0xff);
*out++ = (code >> 8) & 0xff;
- *out++ = code;
+ *out++ = code & 0xff;
from += 2;
} else if (is_kana (*from)) {
*out++ = (char)euc_kana;
@@ -451,7 +501,7 @@ static char *euc_to_sj(char *from, BOOL overwrite)
if (is_euc (*from)) {
int code = euc2sjis ((int) from[0] & 0xff, (int) from[1] & 0xff);
*out++ = (code >> 8) & 0xff;
- *out++ = code;
+ *out++ = code & 0xff;
from += 2;
} else if (is_euc_kana (*from)) {
*out++ = from[1];
@@ -461,8 +511,260 @@ static char *euc_to_sj(char *from, BOOL overwrite)
}
}
*out = 0;
+
if (overwrite) {
- pstrcpy(save, (char *) cvtbuf);
+ pstrcpy(save, (char *) cvtbuf);
+ return save;
+ } else {
+ return cvtbuf;
+ }
+}
+
+/*******************************************************************
+ EUC3 <-> SJIS
+********************************************************************/
+static int sjis3euc (int hi, int lo, int *len)
+{
+ int i,w;
+ int minidx;
+ int maxidx;
+
+ w = (int)((hi << 8) | lo);
+
+ /* no sjis */
+ if ( ( 0x40 >= lo ) && (lo >= 0xfc) && (lo == 0x7f )) {
+ w = (GETAHI << 8) | GETALO;
+
+ /* IBM Extended Kanji */
+ } else if (( w == 0xfa54 )||( w == 0x81ca )) {
+ *len = 2;
+ return (0xa2cc);
+
+ } else if (( w == 0xfa5b )||( w == 0x81e6)) {
+ *len = 2;
+ return (0xa2e8);
+
+ } else if (( 0xfa <= hi ) && ( hi <= 0xfc ) ) {
+ i = w - 0xfa40 - ( hi - 0xfa )*( 0xfb40 - 0xfafc) - ((lo < 0x7f)? 0 : 1 );
+ if ( i <= EUC3CONVTBLSIZ ){
+ *len = 3;
+ return euc3conv[i];
+ }
+
+/* NEC selected IBM Extend Kanji */
+ /* there are 3 code that is not good for conv */
+ } else if (( 0x8754 <= w ) && ( w <= 0x878a)) {
+ minidx = 0;
+ maxidx = EUC3CONV2TBLSIZ;
+ i = minidx + (maxidx - minidx) % 2;
+ while ( maxidx >= minidx ) {
+ if ( euc3conv2[i].sjis > w ) {
+ maxidx = i-1;
+ } else if ( w > euc3conv2[i].sjis ) {
+ minidx = i+1;
+ } else {
+ *len = 3;
+ return (euc3conv2[i].euc);
+ }
+ i = (int)( minidx + (maxidx - minidx) % 2 );
+ }
+ /* else normal EUC */
+
+ } else if (( w == 0xeef9 ) || ( w == 0x81ca )) {
+ *len = 2;
+ return (0xa2cc);
+
+ } else if (( 0xed <= hi ) && ( hi <= 0xef )) {
+ minidx = 0;
+ maxidx = SJISREVTBLSIZ;
+ i = 10;
+ while ( maxidx >= minidx ) {
+ if ( sjisrev[i].start > w ) {
+ maxidx = i-1;
+ } else if ( w > sjisrev[i].end ) {
+ minidx = i+1;
+ } else {
+ w -= sjisrev[i].start;
+ w += sjisrev[i].rstart;
+ break;
+ }
+ i = (int)( minidx + (maxidx - minidx) % 2 );
+ }
+ if ( w >= 0xfa40 ) {
+ i = w - 0xfa40 - ( hi - 0xfa )*( 0xfb40 - 0xfafc) - ((lo < 0x7f)? 0 : 1 );
+ if ( i <= EUC3CONVTBLSIZ ){
+ *len = 3;
+ return euc3conv[i];
+ } else {
+ w = (GETAHI << 8) | GETALO;
+ }
+ }
+ /* else normal EUC */
+
+/* UDC half low*/
+/* this area maps to the G2 UDC area: 0xf5a1 -- 0xfefe */
+ } else if ((0xf0 <= hi) && (hi <= 0xf4)) {
+ *len = 2;
+ if (lo >= 0x9f) {
+ return (((hi * 2 - 0xea) << 8) | (lo + 2));
+ } else {
+ return (((hi * 2 - 0xeb) << 8) | (lo + (lo >=0x7f ? 0x60: 0x61 )));
+ }
+
+/* UDC half high*/
+/* this area maps to the G3 UDC area: 0xf8f5a1 -- 0xf8fefe */
+ } else if ((0xf5 <= hi) && (hi <= 0xf9)) {
+ *len = 3;
+ if (lo >= 0x9f) {
+ return (((hi*2 - 0xf4) << 8) | (lo + 2));
+ } else {
+ return (((hi*2 - 0xf5) << 8) | (lo + (lo >= 0x7f ? 0x60: 0x61 )));
+ }
+ /* ....checked all special case */
+ }
+
+ /* These Normal 2 byte EUC */
+ *len = 2;
+ hi = (int) ((w >> 8) & 0xff);
+ lo = (int) (w & 0xff);
+
+ if (hi >= 0xf0) { /* Check range */
+ hi = GETAHI;
+ lo = GETALO;
+ }
+
+ if (lo >= 0x9f)
+ return ((hi * 2 - (hi >= 0xe0 ? 0xe0 : 0x60)) << 8) | (lo + 2);
+ else
+ return ((hi * 2 - (hi >= 0xe0 ? 0xe1 : 0x61)) << 8) |
+ (lo + (lo >= 0x7f ? 0x60 : 0x61));
+}
+
+static int euc3sjis (int hi, int lo, BOOL is_3byte)
+{
+ int w;
+
+ w = (int)((hi << 8) | lo);
+ if (is_3byte) {
+ if (( 0xf5 <= hi) && ( hi <= 0xfe)) {
+ /* UDC half high*/
+ /* this area maps to the G3 UDC area */
+ /* 0xf8f5a1 -- 0xf8fefe --> 0xf540 -- 0xf9fc */
+ if (hi & 1) {
+ return (((hi / 2 + 0x7b) << 8) | (lo - (lo >= 0xe0 ? 0x60 : 0x61)));
+ } else {
+ return (((hi / 2 + 0x7a) << 8) | (lo - 2));
+ }
+ } else {
+ /* Using map table */
+ int minidx = 0;
+ int maxidx = EUC3REVTBLSIZ;
+ int i = minidx + (maxidx - minidx) % 2;
+
+ while ( maxidx >= minidx ) {
+ if (euc3rev[i].euc > w) {
+ maxidx = i-1;
+ } else if (euc3rev[i].euc < w) {
+ minidx = i+1;
+ } else {
+ return (euc3rev[i].sjis);
+ }
+ i = (int)( minidx + ( maxidx - minidx ) % 2);
+ }
+ return ((GETAHI << 8 ) | GETALO);
+ }
+ } else { /* is_2byte */
+ if ((0xf5 <= hi) && (hi <= 0xfe)) {
+ /* UDC half low*/
+ /* this area maps to the G2 UDC area */
+ /* 0xf5a1 -- 0xfefe --> 0xf040 -- 0xf4fc */
+ if (hi & 1) {
+ return (((hi / 2 + 0x76) << 8) | (lo - (lo >= 0xe0 ? 0x60 : 0x61)));
+ } else {
+ return (((hi / 2 + 0x75) << 8) | (lo - 2));
+ }
+ } else { /* Normal EUC */
+ if (hi & 1) {
+ hi = hi / 2 + (hi < 0xdf ? 0x31 : 0x71);
+ return ((hi << 8) | (lo - (lo >= 0xe0 ? 0x60 : 0x61)));
+ } else {
+ hi = hi / 2 + (hi < 0xdf ? 0x30 : 0x70);
+ return ((hi << 8) | (lo - 2));
+ }
+ }
+ }
+ return ((GETAHI << 8) | GETALO);
+}
+
+/*******************************************************************
+ Convert FROM contain SHIFT JIS codes to EUC codes (with SS2)
+ return converted buffer
+********************************************************************/
+
+static char *sj_to_euc3(char *from, BOOL overwrite)
+{
+ char *out;
+ char *save;
+ int len;
+
+ save = (char *) from;
+ for (out = cvtbuf; *from && (out - cvtbuf < sizeof(cvtbuf)-4);) {
+ if (is_shift_jis (*from)) {
+ int code = sjis3euc ((int) from[0] & 0xff, (int) from[1] & 0xff, &len);
+ if (len == 3) {
+ *out++ = (char)euc_sup;
+ }
+ *out++ = (code >> 8) & 0xff;
+ *out++ = code & 0xff;
+ from += 2;
+ } else if (is_kana (*from)) {
+ *out++ = (char)euc_kana;
+ *out++ = *from++;
+ } else {
+ *out++ = *from++;
+ }
+ }
+ *out = 0;
+ if (overwrite) {
+ pstrcpy((char *) save, (char *) cvtbuf);
+ return (char *) save;
+ } else {
+ return cvtbuf;
+ }
+}
+
+/*******************************************************************
+ Convert FROM contain EUC codes (with Sup-Kanji) to SHIFT JIS codes
+ return converted buffer
+********************************************************************/
+static char *euc3_to_sj(char *from, BOOL overwrite)
+{
+ char *out;
+ char *save;
+
+ save = (char *) from;
+ for (out = cvtbuf; *from && (out - cvtbuf < sizeof(cvtbuf)-3); ) {
+ if (is_euc_sup (*from)) {
+ int code = euc3sjis((int) from[1] & 0xff, (int) from[2] & 0xff, True);
+ *out++ = (code >> 8) & 0xff;
+ *out++ = code & 0xff;
+ from += 3;
+ } else if (is_euc (*from)) {
+ int code = euc3sjis ((int) from[0] & 0xff, (int) from[1] & 0xff,False);
+ *out++ = (code >> 8) & 0xff;
+ *out++ = code & 0xff;
+ from += 2;
+ } else if (is_euc_kana (*from)) {
+ *out++ = from[1];
+ from += 2;
+ } else {
+ *out++ = *from++;
+ }
+ }
+ *out = 0;
+
+ if (overwrite) {
+ pstrcpy(save, (char *) cvtbuf);
return save;
} else {
return cvtbuf;
@@ -475,6 +777,31 @@ static char *euc_to_sj(char *from, BOOL overwrite)
static int sjis2jis(int hi, int lo)
{
+ int minidx = 0;
+ int maxidx = SJISCONVTBLSIZ;
+ int i = (0 + SJISCONVTBLSIZ) % 2;
+ int w = (int)((hi << 8) | lo);
+
+ if ((sjisconv[0].start < w) && (w < sjisconv[SJISCONVTBLSIZ].end)) {
+ while (maxidx >= minidx) {
+ if (sjisconv[i].start > w) {
+ maxidx = i-1;
+ } else if (w > sjisconv[i].end) {
+ minidx = i+1;
+ } else {
+ w -= sjisconv[i].start;
+ w += sjisconv[i].rstart;
+ break;
+ }
+ i = (int)( minidx + (maxidx-minidx) %2 );
+ }
+ hi = (int) ((w >> 8) & 0xff);
+ lo = (int) (w & 0xff);
+ }
+ if (hi >= 0xf0) {
+ hi = GETAHI;
+ lo = GETALO;
+ }
if (lo >= 0x9f)
return ((hi * 2 - (hi >= 0xe0 ? 0x160 : 0xe0)) << 8) | (lo - 0x7e);
else
@@ -484,11 +811,35 @@ static int sjis2jis(int hi, int lo)
static int jis2sjis(int hi, int lo)
{
- if (hi & 1)
- return ((hi / 2 + (hi < 0x5f ? 0x71 : 0xb1)) << 8) |
- (lo + (lo >= 0x60 ? 0x20 : 0x1f));
- else
- return ((hi / 2 + (hi < 0x5f ? 0x70 : 0xb0)) << 8) | (lo + 0x7e);
+ int w;
+ int minidx = 0;
+ int maxidx = SJISREVTBLSIZ;
+ int i = 2;
+
+ if (hi & 1) {
+ hi = hi / 2 + (hi < 0x5f ? 0x71 : 0xb1);
+ w = (hi << 8) | (lo + (lo >= 0x60 ? 0x20 : 0x1f));
+ } else {
+ hi = hi / 2 + (hi < 0x5f ? 0x70 : 0xb0);
+ w = (hi << 8) | (lo + 0x7e);
+ }
+
+ if (( 0x87 < hi ) && ( hi < 0xed )) {
+ return w;
+ }
+ while (maxidx >= minidx) {
+ if (sjisrev[i].start > w) {
+ maxidx = i-1;
+ } else if (w > sjisrev[i].end) {
+ minidx = i+1;
+ } else {
+ w -= sjisrev[i].start;
+ w += sjisrev[i].rstart;
+ break;
+ }
+ i = (int)( minidx + (maxidx-minidx) %2 );
+ }
+ return w;
}
/*******************************************************************
@@ -999,6 +1350,90 @@ static char *sj_to_sj(char *from, BOOL overwrite)
}
}
+/*******************************************************************
+ cp to utf8
+********************************************************************/
+static char *cp_to_utf8(char *from, BOOL overwrite)
+{
+ unsigned char *dst;
+ unsigned char *src;
+ smb_ucs2_t val;
+ int w;
+ size_t len;
+
+ src = (unsigned char *)from;
+ dst = (unsigned char *)cvtbuf;
+ while (*src && (((char *)dst - cvtbuf) < sizeof(cvtbuf)-4)) {
+ len = _skip_multibyte_char(*src);
+ if ( len == 2 ) {
+ w = (int)(*src++ & 0xff);
+ w = (int)((w << 8)|(*src++ & 0xff));
+ } else {
+ w = (int)(*src++ & 0xff);
+ }
+ val = doscp2ucs2(w);
+
+ if ( val <= 0x7f ) {
+ *dst++ = (char)(val & 0xff);
+ } else if ( val <= 0x7ff ){
+ *dst++ = (char)( 0xc0 | ((val >> 6) & 0xff));
+ *dst++ = (char)( 0x80 | ( val & 0x3f ));
+ } else {
+ *dst++ = (char)( 0xe0 | ((val >> 12) & 0x0f));
+ *dst++ = (char)( 0x80 | ((val >> 6) & 0x3f));
+ *dst++ = (char)( 0x80 | (val & 0x3f));
+ }
+
+ }
+ *dst++='\0';
+ if (overwrite) {
+ pstrcpy ((char *) from, (char *) cvtbuf);
+ return (char *) from;
+ } else {
+ return cvtbuf;
+ }
+}
+
+/*******************************************************************
+ utf8 to cp
+********************************************************************/
+static char *utf8_to_cp(char *from, BOOL overwrite)
+{
+ unsigned char *src;
+ unsigned char *dst;
+ smb_ucs2_t val;
+ int w;
+
+ src = (unsigned char *)from;
+ dst = (unsigned char *)cvtbuf;
+
+ while (*src && ((char *)dst - cvtbuf < sizeof(cvtbuf)-4)) {
+ val = (*src++ & 0xff);
+ if (val < 0x80) {
+ *dst++ = (char)(val & 0x7f);
+ } else if ((0xc0 <= val) && (val <= 0xdf)
+ && (0x80 <= *src) && (*src <= 0xbf)) {
+ w = ucs2doscp( ((val & 31) << 6) | ((*src++) & 63 ));
+ *dst++ = (char)((w >> 8) & 0xff);
+ *dst++ = (char)(w & 0xff);
+ } else {
+ val = (val & 0x0f) << 12;
+ val |= ((*src++ & 0x3f) << 6);
+ val |= (*src++ & 0x3f);
+ w = ucs2doscp(val);
+ *dst++ = (char)((w >> 8) & 0xff);
+ *dst++ = (char)(w & 0xff);
+ }
+ }
+ *dst++='\0';
+ if (overwrite) {
+ pstrcpy ((char *) from, (char *) cvtbuf);
+ return (char *) from;
+ } else {
+ return cvtbuf;
+ }
+}
+
/************************************************************************
conversion:
_dos_to_unix _unix_to_dos
@@ -1046,6 +1481,14 @@ static void setup_string_function(int codes)
_dos_to_unix = sj_to_cap;
_unix_to_dos = cap_to_sj;
break;
+ case UTF8_CODE:
+ _dos_to_unix = cp_to_utf8;
+ _unix_to_dos = utf8_to_cp;
+ break;
+ case EUC3_CODE:
+ _dos_to_unix = sj_to_euc3;
+ _unix_to_dos = euc3_to_sj;
+ break;
}
}
@@ -1142,6 +1585,10 @@ void interpret_coding_system(char *str)
codes = JUNET_CODE;
jis_kso = '@';
jis_ksi = 'H';
+ } else if (strequal (str, "utf8")) {
+ codes = UTF8_CODE;
+ } else if (strequal (str, "euc3")) {
+ codes = EUC3_CODE;
}
setup_string_function (codes);
}
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index b786d0c98b..93f5490ffc 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -1977,3 +1977,17 @@ smb_ucs2_t *string_truncate_w(smb_ucs2_t *s, size_t length)
return s;
}
+
+/******************************************************************
+ functions for UTF8 support (using in kanji.c)
+ ******************************************************************/
+smb_ucs2_t doscp2ucs2(int w)
+{
+ return ((smb_ucs2_t)doscp_to_ucs2[w]);
+}
+
+int ucs2doscp(smb_ucs2_t w)
+{
+ return ((int)ucs2_to_doscp[w]);
+}
+
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 64e5908b19..525c1931cc 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -2243,6 +2243,7 @@ static BOOL handle_client_code_page(char *pszParmValue, char **ptr)
if (saved_character_set != NULL)
interpret_character_set(saved_character_set,
lp_client_code_page());
+ codepage_initialise(lp_client_code_page());
return (True);
}
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index e9d2f01e10..4964e15e01 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -897,8 +897,7 @@ files_struct *open_directory(connection_struct *conn,
return NULL;
}
- if(conn->vfs_ops.mkdir(dos_to_unix(fname, False),
- unix_mode(conn,aDIR, fname)) < 0) {
+ if(vfs_mkdir(conn,fname, unix_mode(conn,aDIR, fname)) < 0) {
DEBUG(0,("open_directory: unable to create %s. Error was %s\n",
fname, strerror(errno) ));
file_free(fsp);
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 96a43b48c8..b98ae441ac 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3099,8 +3099,7 @@ int mkdir_internal(connection_struct *conn, char *inbuf, char *outbuf, pstring d
unix_convert(directory,conn,0,&bad_path,NULL);
if (check_name(directory, conn))
- ret = conn->vfs_ops.mkdir(dos_to_unix(directory,False),
- unix_mode(conn,aDIR,directory));
+ ret = vfs_mkdir(conn,directory,unix_mode(conn,aDIR,directory));
if (ret < 0)
{
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 900a87e32b..9d1aa5dcfe 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2014,8 +2014,7 @@ static int call_trans2mkdir(connection_struct *conn,
unix_convert(directory,conn,0,&bad_path,NULL);
if (check_name(directory,conn))
- ret = conn->vfs_ops.mkdir(dos_to_unix(directory,False),
- unix_mode(conn,aDIR,directory));
+ ret = vfs_mkdir(conn,directory,unix_mode(conn,aDIR,directory));
if(ret < 0)
{
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 631d4bedbe..097f51d217 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -267,6 +267,30 @@ BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *
}
/*******************************************************************
+ vfs mkdir wrapper that calls dos_to_unix.
+********************************************************************/
+
+int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode)
+{
+ int ret;
+ pstring name;
+ SMB_STRUCT_STAT sbuf;
+
+ pstrcpy(name,dos_to_unix(fname,False)); /* paranoia copy */
+ if(!(ret=conn->vfs_ops.mkdir(name,mode))) {
+ /*
+ * Check if high bits should have been set,
+ * then (if bits are missing): add them.
+ * Consider bits automagically set by UNIX, i.e. SGID bit from parent dir.
+ */
+ if(mode & ~(S_IRWXU|S_IRWXG|S_IRWXO) &&
+ !vfs_stat(conn,name,&sbuf) && (mode & ~sbuf.st_mode))
+ vfs_chmod(conn,name,sbuf.st_mode | (mode & ~sbuf.st_mode));
+ }
+ return ret;
+}
+
+/*******************************************************************
vfs Unlink wrapper that calls dos_to_unix.
********************************************************************/