root/src/vfs/smbfs/helpers/include/kanji.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 /*
   2    Unix SMB/Netbios implementation.
   3    Version 1.9.
   4    Kanji Extensions
   5  */
   6 #ifndef _KANJI_H_
   7 #define _KANJI_H_
   8 
   9 /* FOR SHIFT JIS CODE */
  10 #define is_shift_jis(c) \
  11     ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f) \
  12      || (0xe0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xef))
  13 #define is_shift_jis2(c) \
  14     (0x40 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfc \
  15     && ((unsigned char) (c)) != 0x7f)
  16 #define is_kana(c) ((0xa0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xdf))
  17 
  18 /* case conversion */
  19 #define is_sj_upper2(c) \
  20   ((0x60 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x79))
  21 #define is_sj_lower2(c) \
  22   ((0x81 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x9A))
  23 #define sjis_alph 0x82
  24 #define is_sj_alph(c) (sjis_alph == (unsigned char) (c))
  25 #define is_sj_upper(c1, c2) (is_sj_alph (c1) && is_sj_upper2 (c2))
  26 #define is_sj_lower(c1, c2) (is_sj_alph (c1) && is_sj_lower2 (c2))
  27 #define sj_toupper2(c) \
  28     (is_sj_lower2 (c) ? ((int) ((unsigned char) (c) - 0x81 + 0x60)) : \
  29      ((int) (unsigned char) (c)))
  30 #define sj_tolower2(c) \
  31     (is_sj_upper2 (c) ? ((int) ((unsigned char) (c) - 0x60 + 0x81)) : \
  32      ((int) (unsigned char) (c)))
  33 
  34 #ifdef _KANJI_C_
  35 /* FOR EUC CODE */
  36 #define euc_kana (0x8e)
  37 #define is_euc_kana(c) (((unsigned char) (c)) == euc_kana)
  38 #define is_euc(c)  (0xa0 < ((unsigned char) (c)) && ((unsigned char) (c)) < 0xff)
  39 
  40 /* FOR JIS CODE */
  41 /* default jis third shift code, use for output */
  42 #ifndef JIS_KSO
  43 #define JIS_KSO 'B'
  44 #endif
  45 #ifndef JIS_KSI
  46 #define JIS_KSI 'J'
  47 #endif
  48 /* in: \E$B or \E$@ */
  49 /* out: \E(J or \E(B or \E(H */
  50 #define jis_esc (0x1b)
  51 #define jis_so (0x0e)
  52 #define jis_so1 ('$')
  53 #define jis_so2 ('B')
  54 #define jis_si (0x0f)
  55 #define jis_si1 ('(')
  56 #define jis_si2 ('J')
  57 #define is_esc(c) (((unsigned char) (c)) == jis_esc)
  58 #define is_so1(c) (((unsigned char) (c)) == jis_so1)
  59 #define is_so2(c) (((unsigned char) (c)) == jis_so2 || ((unsigned char) (c)) == '@')
  60 #define is_si1(c) (((unsigned char) (c)) == jis_si1)
  61 #define is_si2(c) (((unsigned char) (c)) == jis_si2 || ((unsigned char) (c)) == 'B' \
  62     || ((unsigned char) (c)) == 'H')
  63 #define is_so(c) (((unsigned char) (c)) == jis_so)
  64 #define is_si(c) (((unsigned char) (c)) == jis_si)
  65 #define junet_kana1 ('(')
  66 #define junet_kana2 ('I')
  67 #define is_juk1(c) (((unsigned char) (c)) == junet_kana1)
  68 #define is_juk2(c) (((unsigned char) (c)) == junet_kana2)
  69 
  70 #define _KJ_ROMAN (0)
  71 #define _KJ_KANJI (1)
  72 #define _KJ_KANA (2)
  73 
  74 /* FOR HEX */
  75 #define HEXTAG ':'
  76 #define hex2bin(x)                                                    \
  77     ( ((int) '0' <= ((int) (x)) && ((int) (x)) <= (int)'9')?          \
  78         (((int) (x))-(int)'0'):                                       \
  79       ((int) 'a'<= ((int) (x)) && ((int) (x))<= (int) 'f')?           \
  80         (((int) (x)) - (int)'a'+10):                                  \
  81       (((int) (x)) - (int)'A'+10) )
  82 #define bin2hex(x)                                                    \
  83     ( (((int) (x)) >= 10)? (((int) (x))-10 + (int) 'a'): (((int) (x)) + (int) '0') )
  84 
  85 /* For Hangul (Korean - code page 949). */
  86 #define is_hangul(c) ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfd))
  87 
  88 /* For traditional Chinese (known as Big5 encoding - code page 950). */
  89 #define is_big5_c1(c) ((0xa1 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xf9))
  90 
  91 /* For simplified Chinese (code page - 936). */
  92 #define is_simpch_c1(c) ((0xa1 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xf7))
  93 
  94 #else /* not _KANJI_C_ */
  95 
  96 /*
  97  * The following is needed for AIX systems that have
  98  * their own #defines for strchr, strrchr, strstr
  99  * and strtok.
 100  */
 101 
 102 #ifdef strchr
 103 #undef strchr
 104 #endif /* strchr */
 105 
 106 #ifdef strrchr
 107 #undef strrchr
 108 #endif /* strrchr */
 109 
 110 #ifdef strstr
 111 #undef strstr
 112 #endif /* strstr */
 113 
 114 #ifdef strtok
 115 #undef strtok
 116 #endif /* strtok */
 117 
 118 /* Ensure we use our definitions in all other files than kanji.c. */
 119 
 120 /* Function pointers we will replace. */
 121 extern char *(*multibyte_strchr) (const char *s, int c);
 122 extern char *(*multibyte_strrchr) (const char *s, int c);
 123 extern char *(*multibyte_strstr) (const char *s1, const char *s2);
 124 extern char *(*multibyte_strtok) (char *s1, const char *s2);
 125 extern char *(*_dos_to_unix) (char *str, BOOL overwrite);
 126 extern char *(*_unix_to_dos) (char *str, BOOL overwrite);
 127 extern BOOL (*is_multibyte_char) (char c);
 128 extern int (*_skip_multibyte_char) (char c);
 129 
 130 #define strchr(s1, c) ((*multibyte_strchr)((s1), (c)))
 131 #define strrchr(s1, c) ((*multibyte_strrchr)((s1), (c)))
 132 #define strstr(s1, s2) ((*multibyte_strstr)((s1), (s2)))
 133 #define strtok(s1, s2) ((*multibyte_strtok)((s1), (s2)))
 134 #define dos_to_unix(x,y) ((*_dos_to_unix)((x), (y)))
 135 #define unix_to_dos(x,y) ((*_unix_to_dos)((x), (y)))
 136 #define skip_multibyte_char(c) ((*_skip_multibyte_char)((c)))
 137 
 138 #endif /* _KANJI_C_ */
 139 
 140 #define UNKNOWN_CODE (-1)
 141 #define SJIS_CODE (0)
 142 #define EUC_CODE (1)
 143 #define JIS7_CODE (2)
 144 #define JIS8_CODE (3)
 145 #define JUNET_CODE (4)
 146 #define HEX_CODE (5)
 147 #define CAP_CODE (6)
 148 #define DOSV_CODE SJIS_CODE
 149 
 150 #endif /* _KANJI_H_ */

/* [previous][next][first][last][top][bottom][index][help]  */