2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1992-1997
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 Adding for Japanese language by <fujita@ainix.isac.co.jp> 1994.9.5
22 and extend coding system to EUC/SJIS/JIS/HEX at 1994.10.11
23 and add all jis codes sequence at 1995.8.16
24 Notes: Hexadecimal code by <ohki@gssm.otuka.tsukuba.ac.jp>
25 and add upper/lower case conversion 1997.8.21
32 /* FOR SHIFT JIS CODE */
33 #define is_shift_jis(c) \
34 ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f) \
35 || (0xe0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xef))
36 #define is_shift_jis2(c) \
37 (0x40 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfc \
38 && ((unsigned char) (c)) != 0x7f)
39 #define is_kana(c) ((0xa0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xdf))
42 #define is_sj_upper2(c) \
43 ((0x60 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x79))
44 #define is_sj_lower2(c) \
45 ((0x81 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x9A))
46 #define sjis_alph 0x82
47 #define is_sj_alph(c) (sjis_alph == (unsigned char) (c))
48 #define is_sj_upper(c1, c2) (is_sj_alph (c1) && is_sj_upper2 (c2))
49 #define is_sj_lower(c1, c2) (is_sj_alph (c1) && is_sj_lower2 (c2))
50 #define sj_toupper2(c) \
51 (is_sj_lower2 (c) ? ((int) ((unsigned char) (c) - 0x81 + 0x60)) : \
52 ((int) (unsigned char) (c)))
53 #define sj_tolower2(c) \
54 (is_sj_upper2 (c) ? ((int) ((unsigned char) (c) - 0x60 + 0x81)) : \
55 ((int) (unsigned char) (c)))
59 #define euc_kana (0x8e)
60 #define is_euc_kana(c) (((unsigned char) (c)) == euc_kana)
61 #define is_euc(c) (0xa0 < ((unsigned char) (c)) && ((unsigned char) (c)) < 0xff)
64 /* default jis third shift code, use for output */
71 /* in: \E$B or \E$@ */
72 /* out: \E(J or \E(B or \E(H */
73 #define jis_esc (0x1b)
80 #define is_esc(c) (((unsigned char) (c)) == jis_esc)
81 #define is_so1(c) (((unsigned char) (c)) == jis_so1)
82 #define is_so2(c) (((unsigned char) (c)) == jis_so2 || ((unsigned char) (c)) == '@')
83 #define is_si1(c) (((unsigned char) (c)) == jis_si1)
84 #define is_si2(c) (((unsigned char) (c)) == jis_si2 || ((unsigned char) (c)) == 'B' \
85 || ((unsigned char) (c)) == 'H')
86 #define is_so(c) (((unsigned char) (c)) == jis_so)
87 #define is_si(c) (((unsigned char) (c)) == jis_si)
88 #define junet_kana1 ('(')
89 #define junet_kana2 ('I')
90 #define is_juk1(c) (((unsigned char) (c)) == junet_kana1)
91 #define is_juk2(c) (((unsigned char) (c)) == junet_kana2)
100 ( ((int) '0' <= ((int) (x)) && ((int) (x)) <= (int)'9')? \
101 (((int) (x))-(int)'0'): \
102 ((int) 'a'<= ((int) (x)) && ((int) (x))<= (int) 'f')? \
103 (((int) (x)) - (int)'a'+10): \
104 (((int) (x)) - (int)'A'+10) )
106 ( (((int) (x)) >= 10)? (((int) (x))-10 + (int) 'a'): (((int) (x)) + (int) '0') )
108 #else /* not _KANJI_C_ */
110 extern char* (*_dos_to_unix) (const char *str, BOOL overwrite);
111 extern char* (*_unix_to_dos) (const char *str, BOOL overwrite);
113 #define unix_to_dos (*_unix_to_dos)
114 #define dos_to_unix (*_dos_to_unix)
116 extern char *sj_strtok (char *s1, const char *s2);
117 extern char *sj_strchr (const char *s, int c);
118 extern char *sj_strrchr (const char *s, int c);
119 extern char *sj_strstr (const char *s1, const char *s2);
121 #define strchr sj_strchr
122 #define strrchr sj_strrchr
123 #define strstr sj_strstr
124 #define strtok sj_strtok
126 #endif /* _KANJI_C_ */
128 #define UNKNOWN_CODE (-1)
129 #define SJIS_CODE (0)
131 #define JIS7_CODE (2)
132 #define JIS8_CODE (3)
133 #define JUNET_CODE (4)
136 #define DOSV_CODE SJIS_CODE
138 int interpret_coding_system (char *str, int def);
142 #define unix_to_dos(x,y) unix2dos_format(x,y)
143 #define dos_to_unix(x,y) dos2unix_format(x,y)
145 #endif /* not KANJI */
147 #endif /* _KANJI_H_ */