1 /* # skkinput (Simple Kana-Kanji Input) 2 * kanji.h 3 * This file is part of skkinput. 4 * Copyright (C) 1997 5 * Takashi SAKAMOTO (sakamoto@yajima.kuis.kyoto-u.ac.jp) 6 * 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, or (at your option) 10 * any later version. 11 * 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. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with skkinput; see the file COPYING. If not, write to 19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 20 */ 21 #if !defined(kanji_h) 22 #define kanji_h 23 24 struct myChar { 25 signed char charset ; 26 unsigned short chara ; 27 } ; 28 29 struct MessageBuffer { 30 unsigned char internal [TEXTBUFSIZE] ; 31 unsigned char* buffer ; 32 int usage, bufsize ; 33 } ; 34 35 struct KanjiBuffer { 36 struct myChar internal [TEXTBUFSIZE] ; 37 struct myChar* buffer ; 38 int usage, bufsize ; 39 } ; 40 41 #define ERR (-1) 42 #define NOERR (0) 43 44 enum { 45 CHARSET_NOTHING = -1, 46 CHARSET_ISO8859_1 = 0, 47 CHARSET_ISO8859_2, 48 CHARSET_ISO8859_3, 49 CHARSET_ISO8859_4, 50 CHARSET_ISO8859_5, 51 CHARSET_ISO8859_6, 52 CHARSET_ISO8859_7, 53 CHARSET_ISO8859_8, 54 CHARSET_ISO8859_9, 55 CHARSET_JISX0201_1976, 56 CHARSET_JISX0208_1978, 57 CHARSET_JISX0208_1983, 58 CHARSET_JISX0212_1990, 59 CHARSET_GB2312_1980, 60 CHARSET_KSC5601_1987, 61 MAX_CHARSET, 62 } ; 63 64 enum { 65 ISO2022JP_CHARSET_NOTDEFINE = -1, 66 ISO2022JP_CHARSET_ASCII = 0, 67 ISO2022JP_CHARSET_ISO8859_1, 68 ISO2022JP_CHARSET_ISO8859_2, 69 ISO2022JP_CHARSET_ISO8859_3, 70 ISO2022JP_CHARSET_ISO8859_4, 71 ISO2022JP_CHARSET_ISO8859_5, 72 ISO2022JP_CHARSET_ISO8859_6, 73 ISO2022JP_CHARSET_ISO8859_7, 74 ISO2022JP_CHARSET_ISO8859_8, 75 ISO2022JP_CHARSET_ISO8859_9, 76 ISO2022JP_CHARSET_JISX0201_ROMAN, 77 ISO2022JP_CHARSET_JISX0201_KATAKANA, 78 ISO2022JP_CHARSET_JISX0208_1978, 79 ISO2022JP_CHARSET_JISX0208_1983, 80 ISO2022JP_CHARSET_JISX0212_1990, 81 ISO2022JP_CHARSET_GB2312_1980, 82 ISO2022JP_CHARSET_KSC5601_1987, 83 } ; 84 85 /* ISO8859 �κ�Ⱦ�̤��Ѥ�����ˤϡ�CHARSET_ISO8859_1 �˽���뤳�Ȥ� 86 * ���롣����ȡ�ʸ�������ɤ���Ӥ��ưפˤʤ�Ȧ��*/ 87 #define CHARSET_ASCII (CHARSET_ISO8859_1) 88 89 /* ������ʸ������ο���*/ 90 #define NUMBER_OF_CHARSET (MAX_CHARSET) 91 92 enum { 93 KANJI_CODE_UNKNOWN = -2, /* ���������ɤ����������Τ�ʤ���*/ 94 KANJI_CODE_EUC_SJIS_UNKNOWN = -1, /* EUC �� SJIS �����̤Ǥ��ʤ���*/ 95 KANJI_CODE_JIS = 0, /* JIS ���ȻפäƤ��롣*/ 96 KANJI_CODE_SJIS, /* SJIS ���ȻפäƤ��롣*/ 97 KANJI_CODE_EUC, /* EUC ���ȻפäƤ��롣*/ 98 } ; 99 /* 100 * (���)��SJIS �ȸƤ֤ʡ�MS���������ɤȸƤ١פȤ������ˤϤ��ߤޤ��� 101 * �ɡ������ǤϺ��ߤ��Ƥޤ���m(_ _)m 102 */ 103 104 /* 105 * 106 */ 107 #define IS_ASCII_CHARA( wchara ) \ 108 ( ( ( !( (wchara).chara & 0x80 ) ) && \ 109 ( (wchara).charset >= CHARSET_ISO8859_1 && \ 110 (wchara).charset <= CHARSET_JISX0201_1976 ) )? True : False ) 111 112 #define IS_ASCII_EQUAL( wchara, nchara ) \ 113 ( ( ( (wchara).chara == (unsigned char)(nchara) ) && \ 114 ( (wchara).charset >= CHARSET_ISO8859_1 && \ 115 (wchara).charset <= CHARSET_JISX0201_1976 ) )? True : False ) 116 117 #define IS_END_OF_STRING(wchara) \ 118 ( ( ( (wchara).chara == '\0' ) && \ 119 ( (wchara).charset == CHARSET_ASCII ) )? \ 120 True : False ) 121 122 #define MYCHAR_IS_ALPHABETIC(wchara) \ 123 ( ( ( ( (wchara).charset >= CHARSET_ISO8859_1 && \ 124 (wchara).charset <= CHARSET_JISX0201_1976 ) ) && \ 125 ( ( (wchara).chara >= 'a' && (wchara).chara <= 'z' ) || \ 126 ( (wchara).chara >= 'A' && (wchara).chara <= 'Z' ) || \ 127 ( (wchara).chara >= '0' && (wchara).chara <= '9' ) ) )? True : False ) 128 129 #define MYCHAR_IS_LOWERCASE(wchara) \ 130 ( ( ( ( (wchara).charset >= CHARSET_ISO8859_1 && \ 131 (wchara).charset <= CHARSET_JISX0201_1976 ) ) && \ 132 ( ( (wchara).chara >= 'a' && (wchara).chara <= 'z' ) ) )? True : False ) 133 134 #define MYCHAR_IS_UPPERCASE(wchara) \ 135 ( ( ( ( (wchara).charset >= CHARSET_ISO8859_1 || \ 136 (wchara).charset <= CHARSET_JISX0201_1976 ) ) && \ 137 ( ( (wchara).chara >= 'A' && (wchara).chara <= 'Z' ) ) )? True : False ) 138 139 #define MYCHAR_SET_END_OF_STRING(wchara) \ 140 do { (wchara).charset = CHARSET_ASCII ; (wchara).chara = '\0' ; } while(0) 141 142 #define MYCHAR_SET_CHARA(wchara,nchara) \ 143 do { (wchara).charset = CHARSET_ASCII ; (wchara).chara = nchara ; } while(0) 144 145 #define MYCHAR_SET_JISX0208_1983(wchara,jchara) \ 146 do { (wchara).charset = CHARSET_JISX0208_1983 ; (wchara).chara = jchara ; } while(0) 147 148 /* 149 * �ץ�ȥ���������� 150 */ 151 void init_kanjibuffer 152 ( struct KanjiBuffer *buf ) ; 153 void add_kanjibuffer 154 ( struct KanjiBuffer *buf, struct myChar chara ) ; 155 void add_kanjiStringToKanjiBuffer 156 ( struct KanjiBuffer *buf, struct myChar *string, int length ) ; 157 void close_kanjibuffer 158 ( struct KanjiBuffer *buf ) ; 159 160 int extendedUnixCode_stringToMycharset 161 ( unsigned char *string, struct myChar **wstring ) ; 162 163 int myCharStrlen( struct myChar *string ) ; 164 int myCharStrncmp 165 ( struct myChar *string1, struct myChar *string2, int count ) ; 166 int myCharStrcmp 167 ( struct myChar *string1, struct myChar *string2 ) ; 168 int myCharStrcpy 169 ( struct myChar *string1, struct myChar *string2 ) ; 170 int myCharKatakanaStrcpy 171 ( struct myChar *string1, struct myChar *string2 ) ; 172 int myCharStrncpy 173 ( struct myChar *string1, struct myChar *string2, int length ) ; 174 int myCharCharStrcpy 175 ( struct myChar *string1, unsigned char *string2 ) ; 176 int myCharCharStrncpy 177 ( struct myChar *string1, unsigned char *string2, int number ) ; 178 int myCharHiraganaStrncpy 179 ( struct myChar *string1, struct myChar *string2, int length ) ; 180 int myCharHiraKataStrnncpy 181 ( struct myChar *string1, int length1, struct myChar *string2, int length2 ) ; 182 int myCharCharStrncmp 183 ( struct myChar *string1, unsigned char *string2, int length ) ; 184 int myCharCharStrcmp 185 ( struct myChar *string1, unsigned char *string2 ) ; 186 int myCharStrcat 187 ( struct myChar *string1, struct myChar *string2 ) ; 188 int myCharStrncat 189 ( struct myChar *string1, struct myChar *string2, int length ) ; 190 int myCharHiraganaStrncat 191 ( struct myChar *string1, struct myChar *string2, int length ) ; 192 int myCharHiraKataStrnncat 193 ( struct myChar *string1, int length1, struct myChar *string2, int length2 ) ; 194 int myCharCharStrncat 195 ( struct myChar *string1, unsigned char *string2, int length ) ; 196 int myCharCharStrcat 197 ( struct myChar *string1, unsigned char *string2 ) ; 198 int myCharItoa( struct myChar *string, int value ) ; 199 int myCharFputEUCc( struct myChar chara, FILE *fp ) ; 200 void myCharFputstring( FILE *fp, struct myChar *string ) ; 201 202 void init_messagebuffer( struct MessageBuffer *buf ) ; 203 void add_messagebuffer( struct MessageBuffer *buf, int chara ) ; 204 void close_messagebuffer( struct MessageBuffer *buf ) ; 205 206 struct myChar *mychar_readOneLine( FILE *fp, int coding_system ) ; 207 int check_kanjiCode( unsigned char *text, int length ) ; 208 209 int myCharAtoi( struct myChar *string ) ; 210 unsigned char *myCharStringToAsciiString( struct myChar *string ) ; 211 void myCharFputstrning( FILE *fp, struct myChar *string, int len ) ; 212 #endif 213