Main Page   Modules   Data Structures   Globals   Appendix  

m17n.h

Go to the documentation of this file.
00001 /* m17n.h -- header file for the SHELL API of the m17n library.
00002    Copyright (C) 2003, 2004
00003      National Institute of Advanced Industrial Science and Technology (AIST)
00004      Registration Number H15PRO112
00005 
00006    This file is part of the m17n library.
00007 
00008    The m17n library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public License
00010    as published by the Free Software Foundation; either version 2.1 of
00011    the License, or (at your option) any later version.
00012 
00013    The m17n library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Lesser General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public
00019    License along with the m17n library; if not, write to the Free
00020    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00021    02111-1307, USA.  */
00022 
00023 #ifndef _M17N_H_
00024 #define _M17N_H_
00025 
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <time.h>
00029 
00030 #ifndef _M17N_CORE_H_
00031 #include <m17n-core.h>
00032 #endif
00033 
00034 #ifdef __cplusplus
00035 extern "C"
00036 {
00037 #endif
00038 
00039 extern void m17n_init (void);
00040 #undef M17N_INIT
00041 #define M17N_INIT() m17n_init ()
00042 
00043 extern void m17n_fini (void);
00044 #undef M17N_FINI
00045 #define M17N_FINI() m17n_fini ()
00046 
00047 /***en @defgroup m17nShell SHELL API */
00048 /***ja @defgroup m17nShell SHELL API */
00049 /*=*/
00050 
00051 /*
00052  *  (11) Functions related to the m17n database
00053  */
00054 
00055 /*** @ingroup m17nShell */
00056 /***en @defgroup m17nDatabase Database */
00057 /***ja @defgroup m17nDatabase 言語情報データベース */
00058 /*=*/
00059 /* Directory of an application specific databases.  */
00060 extern char *mdatabase_dir;
00061 
00062 /***
00063     @ingroup m17nDatabase  */ 
00064 /***en
00065     @brief Type of database.
00066 
00067     The type #MDatabase is for a database object.  Its internal
00068     structure is concealed from application programs.  */
00069 /***ja データベースの型宣言 */
00070 typedef struct MDatabase MDatabase;
00071 
00072 /*=*/
00073 
00074 /* Look for a data.  */
00075 extern MDatabase *mdatabase_find (MSymbol tag1, MSymbol tag2,
00076                                   MSymbol tag3, MSymbol tag4);
00077 
00078 extern MPlist *mdatabase_list (MSymbol tag0, MSymbol tag1,
00079                                MSymbol tag2, MSymbol tag3);
00080 
00081 /* Load a data.  */
00082 void *mdatabase_load (MDatabase *mdb);
00083 
00084 /* Get tags of a data.  */
00085 extern MSymbol *mdatabase_tag (MDatabase *mdb);
00086 
00087 /* Define a data.  */
00088 extern MDatabase *mdatabase_define (MSymbol tag1, MSymbol tag2,
00089                                     MSymbol tag3, MSymbol tag4,
00090                                     void *(*loader) (MSymbol *, void *),
00091                                     void *extra_info);
00092 
00093 /*=*/
00094 /* (S2) Charset staffs */
00095 
00096 /*** @ingroup m17nShell */
00097 /***en @defgroup m17nCharset Charset */
00098 /***ja @defgroup m17nCharset 文字セット */
00099 /*=*/
00100 #define MCHAR_INVALID_CODE 0xFFFFFFFF
00101 
00102 /* Predefined charsets */ 
00103 extern MSymbol Mcharset_ascii;
00104 extern MSymbol Mcharset_iso_8859_1;
00105 extern MSymbol Mcharset_unicode;
00106 extern MSymbol Mcharset_m17n;
00107 extern MSymbol Mcharset_binary;
00108 
00109 /* Predefined keys for mchar_define_charset ().  */ 
00110 extern MSymbol Mmethod;
00111 extern MSymbol Mdimension;
00112 extern MSymbol Mmin_range;
00113 extern MSymbol Mmax_range;
00114 extern MSymbol Mmin_code;
00115 extern MSymbol Mmax_code;
00116 extern MSymbol Mascii_compatible;
00117 extern MSymbol Mfinal_byte;
00118 extern MSymbol Mrevision;
00119 extern MSymbol Mmin_char;
00120 extern MSymbol Mmapfile;
00121 extern MSymbol Mparents;
00122 extern MSymbol Msubset_offset;
00123 extern MSymbol Mdefine_coding;
00124 extern MSymbol Maliases;
00125 
00126 /* Methods of a charset.  */
00127 extern MSymbol Moffset;
00128 extern MSymbol Mmap;
00129 extern MSymbol Munify;
00130 extern MSymbol Msubset;
00131 extern MSymbol Msuperset;
00132 
00133 /* etc. */
00134 extern MSymbol Mcharset;
00135 
00136 extern MSymbol mchar_define_charset (char *name, MPlist *plist);
00137 
00138 extern MSymbol mchar_resolve_charset (MSymbol symbol);
00139 
00140 extern int mchar_list_charset (MSymbol **symbols);
00141 
00142 extern int mchar_decode (MSymbol charset_name, unsigned code);
00143 
00144 extern unsigned mchar_encode (MSymbol charset_name, int c);
00145 
00146 extern int mchar_map_charset (MSymbol charset_name,
00147                               void (*func) (int from, int to, void *arg),
00148                               void *func_arg);
00149 
00150 /*=*/
00151 
00152 /* (S3) code conversion */
00153 
00154 /*** @ingroup m17nShell */
00155 /***en @defgroup m17nConv Code Conversion */
00156 /***ja @defgroup m17nConv コード変換 */
00157 /*=*/
00158 
00159 /* Predefined coding systems */
00160 extern MSymbol Mcoding_us_ascii;
00161 extern MSymbol Mcoding_iso_8859_1;
00162 extern MSymbol Mcoding_utf_8;
00163 extern MSymbol Mcoding_utf_8_full;
00164 extern MSymbol Mcoding_utf_16;
00165 extern MSymbol Mcoding_utf_16be;
00166 extern MSymbol Mcoding_utf_16le;
00167 extern MSymbol Mcoding_utf_32;
00168 extern MSymbol Mcoding_utf_32be;
00169 extern MSymbol Mcoding_utf_32le;
00170 extern MSymbol Mcoding_sjis;
00171 
00172 /* Parameter keys for mconv_define_coding ().  */
00173 extern MSymbol Mtype;
00174 extern MSymbol Mcharsets;
00175 extern MSymbol Mflags;
00176 extern MSymbol Mdesignation;
00177 extern MSymbol Minvocation;
00178 extern MSymbol Mcode_unit;
00179 extern MSymbol Mbom;
00180 extern MSymbol Mlittle_endian;
00181 
00182 /* Symbols representing coding system type.  */
00183 extern MSymbol Mutf;
00184 extern MSymbol Miso_2022;
00185 
00186 /* Symbols appearing in the value of Mfrag parameter.  */
00187 extern MSymbol Mreset_at_eol;
00188 extern MSymbol Mreset_at_cntl;
00189 extern MSymbol Meight_bit;
00190 extern MSymbol Mlong_form;
00191 extern MSymbol Mdesignation_g0;
00192 extern MSymbol Mdesignation_g1;
00193 extern MSymbol Mdesignation_ctext;
00194 extern MSymbol Mdesignation_ctext_ext;
00195 extern MSymbol Mlocking_shift;
00196 extern MSymbol Msingle_shift;
00197 extern MSymbol Msingle_shift_7;
00198 extern MSymbol Meuc_tw_shift;
00199 extern MSymbol Miso_6429;
00200 extern MSymbol Mrevision_number;
00201 extern MSymbol Mfull_support;
00202 
00203 /* etc */
00204 extern MSymbol Mcoding;
00205 extern MSymbol Mmaybe;
00206 
00207 /*** @ingroup m17nConv */
00208 /***en
00209     @brief Codes that represent the result of code conversion.
00210 
00211     One of these values is set in @c MConverter->result.   */
00212 
00213 /***ja
00214     @brief コード変換の結果を示すコード
00215 
00216     これらの値のうち一つが @c MConverter->result に設定される。  */
00217 
00218 enum MConversionResult
00219   {
00220     /***en Code conversion is successful. */
00221     /***ja コード変換は成功。 */
00222     MCONVERSION_RESULT_SUCCESS,
00223 
00224     /***en On decoding, the source contains an invalid byte. */
00225     /***ja デコードの際、ソースに不正なバイトが含まれる。 */
00226     MCONVERSION_RESULT_INVALID_BYTE,
00227 
00228     /***en On encoding, the source contains a character that cannot be
00229         encoded by the specified coding system. */
00230 
00231     /***ja エンコードの際、ソースに指定のコード系で
00232         エンコードできない文字が含まれる。 */
00233     MCONVERSION_RESULT_INVALID_CHAR,
00234 
00235     /***en On decoding, the source ends with an incomplete byte sequence. */
00236     /***ja デコードの際、ソースが不完全なバイト列で終わる。*/
00237     MCONVERSION_RESULT_INSUFFICIENT_SRC,
00238 
00239     /***en On encoding, the destination is too short to store the result. */
00240     /***ja エンコードの際、結果を格納する領域が短かすぎる。 */
00241     MCONVERSION_RESULT_INSUFFICIENT_DST,
00242 
00243     /***en An I/O error occurred in the conversion.  */
00244     /***ja コード変換中に I/O エラーが起こった。  */
00245     MCONVERSION_RESULT_IO_ERROR
00246   };
00247 /*=*/
00248 
00249 /*** @ingroup m17nConv */
00250 /***en
00251     @brief Structure to be used in code conversion.
00252 
00253     The first three members are to control the conversion.  */
00254 
00255 /***ja
00256     @brief コード変換に用いられる構造体 
00257 
00258     @latexonly \IPAlabel{MConverter} @endlatexonly  
00259 */
00260 
00261 typedef struct
00262 {
00263   /***en
00264       Set the value to nonzero if the conversion should be lenient.
00265       By default, the conversion is strict (i.e. not lenient).
00266 
00267       If the conversion is strict, the converter stops at the first
00268       invalid byte (on decoding) or at the first character not
00269       supported by the coding system (on encoding).  If this happens,
00270       @c MConverter->result is set to @c
00271       MCONVERSION_RESULT_INVALID_BYTE or @c
00272       MCONVERSION_RESULT_INVALID_CHAR accordingly.
00273 
00274       If the conversion is lenient, on decoding, an invalid byte is
00275       kept per se, and on encoding, an invalid character is replaced
00276       with "<U+XXXX>" (if the character is a Unicode character) or
00277       with "<M+XXXXXX>" (otherwise).  */
00278 
00279   /***ja
00280       厳密な変換が必要でない場合にこのフラグビットをたてる。デフォ
00281       ルトでは、変換は厳密である。
00282 
00283       変換が厳密とは、デコードの際には最初の不正なバイトでコンバータ
00284       が止まること、エンコードの際には変換されるコード系でサポートさ
00285       れない最初の文字でコンバータが止まることを指す。これらの場合、
00286       @c MConverter->result はそれぞれ@c
00287       MCONVERSION_RESULT_INVALID_BYTE か@c
00288       MCONVERSION_RESULT_INVALID_CHAR となる。
00289 
00290       変換が厳密でない場合には、デコードの際の不正なバイトはそのバイ
00291       トのまま残る。またエンコードの際には、不正な文字はコード系ごと
00292       に定められたデフォルトの文字と置き換えられる。  */
00293 
00294   int lenient;
00295 
00296   /***en
00297       Set the value to nonzero before decoding or encoding the last
00298       block of the byte sequence or the character sequence
00299       respectively.  The value influences the conversion as below.
00300 
00301       On decoding, in the case that the last few bytes are too short
00302       to form a valid byte sequence:
00303 
00304         If the value is nonzero, the conversion terminates by error
00305         (MCONVERSION_RESULT_INVALID_BYTE) at the first byte of the
00306         sequence.
00307 
00308         If the value is zero, the conversion terminates successfully.
00309         Those bytes are stored in the converter as carryover and are
00310         prepended to the byte sequence of the further conversion.
00311 
00312       On encoding, in the case that the coding system is context
00313       dependent:
00314 
00315         If the value is nonzero, the conversion may produce a byte
00316         sequence at the end to reset the context to the initial state
00317         even if the source characters are zero.
00318 
00319         If the value is zero, the conversion never produce such a byte
00320         sequence at the end.  */
00321 
00322     /***ja
00323         文字コード列の終端部分をエンコードする際には、このフラグを立て
00324         る。この場合出力コードポイント列のコンテクストを元に戻すための
00325         数バイトが付加的に生成されることがある。
00326 
00327         このフラグはデフォルトでは立っておらず、コンバータは続けて他の
00328         文字をエンコードするものと仮定している。
00329 
00330         このフラグはデコードには関係しない。  */
00331 
00332   int last_block;
00333 
00334   /***en
00335       If the value is nonzero, it specifies at most how many
00336       characters to convert.  */
00337 
00338   unsigned at_most;
00339 
00340   /***en
00341       The following three members are to report the result of the
00342       conversion.  */
00343 
00344   /***en
00345       Number of characters most recently decoded or encoded. */
00346 
00347   /***ja
00348       最後にデコード/エンコードされた文字数 */
00349 
00350   int nchars;
00351 
00352   /***en
00353       Number of bytes recently decoded or encoded. */
00354 
00355   /***ja
00356       最後にデコード/エンコードされたバイト数 */
00357 
00358   int nbytes;
00359 
00360   /***en
00361       Result code of the conversion. */
00362 
00363   /***ja
00364       コード変換の結果を示すコード */
00365 
00366   enum MConversionResult result;
00367 
00368   /***en
00369       Various information about the status of code conversion.  The
00370       contents depend on the type of coding system.  It is assured
00371       that @c status is aligned so that any type of casting is safe
00372       and at least 256 bytes of memory space can be used.  */
00373 
00374   /***ja
00375       コード変換の状況に関する情報。内容はコード系のタイプによって異な
00376       る。@c status はどのような型へのキャストに対しても安全なようにメ
00377       モリアラインされており、また最低256バイトのメモリ領域が使えるよ
00378       うになっている。  */
00379 
00380   union {
00381     void *ptr;
00382     double dbl;
00383     char c[256];
00384   } status;
00385 
00386   /***en
00387       This member is for internally use only.  An application program
00388       should never touch it.  */
00389   void *internal_info;
00390 } MConverter;
00391 /*=*/
00392 
00393 /*** @ingroup m17nConv */
00394 /***en @brief Types of coding system  */
00395 /***ja @brief コード系のタイプ  */
00396 
00397 enum MCodingType
00398   {
00399     /***en
00400         A coding system of this type supports charsets directly.
00401         The dimension of each charset defines the length of bytes to
00402         represent a single character of the charset, and a byte
00403         sequence directly represents the code-point of a character.
00404 
00405         The m17n library provides the default decoding and encoding
00406         routines of this type.  */
00407 
00408     /***ja
00409         このタイプのコード系は文字セットを直接サポートする。各文字セッ
00410         トの次元とは、その文字セットで一文字を表現するために必要なバイ
00411         ト数であり、バイト列は文字のコードポイントを直接表わす。
00412 
00413         m17n ライブラリはこのタイプ用のデフォルトのエンコード/デコー
00414         ドルーティンを提供する。  */
00415 
00416     MCODING_TYPE_CHARSET,
00417 
00418     /***en
00419         A coding system of this type supports byte sequences of a
00420         UTF (UTF-8, UTF-16, UTF-32) like structure.
00421 
00422         The m17n library provides the default decoding and encoding
00423         routines of this type.  */
00424 
00425     /***ja
00426         このタイプのコード系は、UTF 系 (UTF-8, UTF-16, UTF-32) のバイ
00427         ト列をサポートする。
00428 
00429         m17n ライブラリはこのタイプ用のデフォルトのエンコード/デコー
00430         ドルーティンを提供する。  */
00431 
00432     MCODING_TYPE_UTF,
00433 
00434     /***en
00435         A coding system of this type supports byte sequences of an
00436         ISO-2022 like structure.  The details of each structure are
00437         specified by @c MCodingInfoISO2022 .
00438 
00439         The m17n library provides decoding and encoding routines of
00440         this type.  */
00441 
00442     /***ja
00443         このタイプのコード系は、ISO-2022 系のバイト列をサポートする。
00444         これらのコード系の構造の詳細は @c MCodingInfoISO2022 で指定さ
00445         れる。
00446 
00447         m17n ライブラリはこのタイプ用のデフォルトのエンコード/デコー
00448         ドルーティンを提供する。  */
00449 
00450     MCODING_TYPE_ISO_2022,
00451 
00452     /***en
00453         A coding system of this type is for byte sequences of
00454         miscellaneous structures.
00455 
00456         The m17n library does not provide decoding and encoding
00457         routines of this type.  They must be provided by the
00458         application program.  */
00459 
00460     /***ja
00461         このタイプのコード系は、その他の構造のバイト列のためのものであ
00462         る。
00463 
00464         m17n ライブラリはこのタイプ用のエンコード/デコードルーティン
00465         を提供しないので、アプリケーションプログラム側でそれらを準備す
00466         る必要がある。  */
00467 
00468     MCODING_TYPE_MISC
00469   };
00470 /*=*/
00471 
00472 /*** @ingroup m17nConv */
00473 /***en @brief Bit-masks to specify the detail of coding system whose type is
00474     MCODING_TYPE_ISO_2022.  */
00475 
00476 /***ja @brief MCODING_TYPE_ISO_2022 タイプのコード系の詳細を表わすビットマス
00477     ク  */
00478 
00479 enum MCodingFlagISO2022
00480   {
00481     /***en
00482         On encoding, reset the invocation and designation status to
00483         initial at end of line.  */
00484     /***ja エンコードの際、行末で呼び出し (invocation) と指示
00485         (designation) の状態を初期値に戻す。   */
00486     MCODING_ISO_RESET_AT_EOL =          0x1,
00487 
00488     /***en
00489         On encoding, reset the invocation and designation status to
00490         initial before any control codes.  */
00491     /***ja
00492         エンコードの際、すべての制御文字の前で、呼び出し
00493         (invocation) と指示 (designation) の状態を初期値に戻す。        */
00494     MCODING_ISO_RESET_AT_CNTL =         0x2,
00495 
00496     /***en
00497         Use the right graphic plane.  */
00498     /***ja
00499         図形文字集合の右側を使う。  */
00500     MCODING_ISO_EIGHT_BIT =             0x4,
00501 
00502     /***en
00503         Use the non-standard 4 bytes format for designation sequence
00504         for charsets JISX0208.1978, GB2312, and JISX0208.1983.  */
00505     /***ja
00506         JISX0208.1978, GB2312, JISX0208.1983 の文字集合に対する指示シー
00507         クエンスとして、非標準の4バイト形式を用いる。 */
00508 
00509     MCODING_ISO_LONG_FORM =             0x8,
00510 
00511     /***en
00512         On encoding, unless explicitly specified, designate charsets
00513         to G0.  */
00514     /***ja
00515         エンコードの際、特に指定されない限り、文字集合を G0 に
00516         指示する。*/
00517     MCODING_ISO_DESIGNATION_G0 =                0x10,
00518 
00519     /***en
00520         On encoding, unless explicitly specified, designate charsets
00521         except for ASCII to G1.  */
00522     /***ja
00523         エンコードの際、特に指定されない限り、ASCII 以外の文字集合を G1 
00524         に指示する。*/
00525     MCODING_ISO_DESIGNATION_G1 =                0x20,
00526 
00527     /***en
00528         On encoding, unless explicitly specified, designate 94-chars
00529         charsets to G0, 96-chars charsets to G1.  */
00530     /***ja
00531         エンコードの際、特に指定されない限り、94文字集合を G0 
00532         に、96文字集合を G1 に指示する。*/
00533     MCODING_ISO_DESIGNATION_CTEXT =     0x40,
00534 
00535     /***en
00536         On encoding, encode such charsets not conforming to ISO-2022
00537         by ESC % / ..., and encode non-supported Unicode characters by
00538         ESC % G ... ESC % @@ .  On decoding, handle those escape
00539         sequences.  */
00540     /***ja
00541         エンコードの際、ISO-2022 に合致しない文字集合を ESC % / ... でエ
00542         ンコードする。サポートされていない Unicode 文字は ESC % G ...
00543         ESC % @@ でエンコードする。
00544         デコードの際、これらのエスケープ・シーケンスを解釈する。  */
00545     MCODING_ISO_DESIGNATION_CTEXT_EXT = 0x80,
00546 
00547     /***en
00548         Use locking shift.  */
00549     /***ja
00550         ロッキングシフトを使う。  */
00551     MCODING_ISO_LOCKING_SHIFT = 0x100,
00552 
00553     /***en
00554         Use single shift (SS2 (0x8E or ESC N), SS3 (0x8F or ESC O)).  */
00555     /***ja
00556         シングルシフト (SS2 or ESC N) を使う。  */
00557     MCODING_ISO_SINGLE_SHIFT =  0x200,
00558 
00559     /***en
00560         Use 7-bit single shift 2 (SS2 (0x19)).  */
00561     /***ja
00562         シングルシフト (0x19) を使う。  */
00563     MCODING_ISO_SINGLE_SHIFT_7 =        0x400,
00564 
00565     /***en
00566         Use EUC-TW like special shifting.  */
00567     /***ja
00568         EUC-TW 風の特別なシフトを使う。  */
00569     MCODING_ISO_EUC_TW_SHIFT =  0x800,
00570 
00571     /***en
00572         Use ISO-6429 escape sequences to indicate direction.
00573         Not yet implemented.  */
00574     /***ja
00575         ISO-6429 のエスケープシークエンスで方向を指示する。  */
00576     MCODING_ISO_ISO6429 =               0x1000,
00577 
00578     /***en
00579         On encoding, if a charset has revision number, produce escape
00580         sequences to specify the number.  */
00581     /***ja
00582         エンコードの際、文字セットに revision number があればそ
00583         れを表わすエスケープシークエンスを生成する。        */
00584     MCODING_ISO_REVISION_NUMBER =       0x2000,
00585 
00586     /***en
00587         Support all ISO-2022 charsets.  */
00588     /***ja
00589         ISO-2022 の全文字集合をサポートする  */
00590     MCODING_ISO_FULL_SUPPORT =          0x3000,
00591 
00592     MCODING_ISO_FLAG_MAX
00593   };
00594 /*=*/
00595 
00596 /*** @ingroup m17nConv */
00597 /***en
00598     @brief Structure for a coding system of type MCODING_TYPE_ISO_2022.
00599 
00600     Structure for extra information about a coding system of type
00601     MCODING_TYPE_ISO_2022.  */
00602 
00603 /***ja
00604     @brief MCODING_TYPE_ISO_2022 タイプのコード系で必要
00605     な付加情報用構造体
00606 
00607     @latexonly \IPAlabel{MCodingInfoISO2022} @endlatexonly  */
00608 
00609 typedef struct
00610 {
00611   /***en
00612       Table of numbers of an ISO2022 code extension element invoked
00613       to each graphic plane (Graphic Left and Graphic Right).  -1
00614       means no code extension element is invoked to that plane.  */
00615 
00616   /***ja
00617       各図形文字領域 (Graphic Left と Graphic Right) に呼び出されてい
00618       る、ISO2022 符合拡張要素の番号のテーブル。-1 はその領域にどの符
00619       合拡張要素も呼び出されていないことを示す。   */
00620 
00621   int initial_invocation[2];
00622 
00623   /***en
00624       Table of code extension elements.  The Nth element corresponds
00625       to the Nth charset in $CHARSET_NAMES, which is an argument given
00626       to the mconv_define_coding () function.
00627 
00628       If an element value is 0..3, it specifies a graphic register
00629       number to designate the corresponds charset.  In addition, the
00630       charset is initially designated to that graphic register.
00631 
00632       If the value is -4..-1, it specifies a graphic register number
00633       0..3 respectively to designate the corresponds charset.
00634       Initially, the charset is not designated to any graphic
00635       register.  */
00636 
00637   /***ja
00638 
00639   符合拡張要素のテーブル。N番目の要素は、$CHARSET_NAMES の N 番目
00640   の文字セットに対応する。$CHARSET_NAMES は関数 
00641   mconv_define_coding () の引数として使われる。
00642 
00643   値が 0..3 だったら、対応する文字セットを G0..G3 のそれぞれに指示
00644   することを意味する。さらに、初期状態ですでに G0..G3 に指示されて
00645   いる。
00646 
00647   値が -4..-1 だったら、対応する文字セットを G0..G3 のそれぞれに指
00648   示するが、初期状態ではどこにも指示されていないことを意味する。 */
00649 
00650   char designations[32];
00651 
00652   /***en
00653       Bitwise OR of @c enum @c MCodingFlagISO2022 .  */
00654 
00655   /***ja
00656       @c enum @c MCodingFlagISO2022 のビット単位での論理 OR  */
00657 
00658   unsigned flags;
00659 
00660 } MCodingInfoISO2022;
00661 /*=*/
00662 
00663 /*** @ingroup m17nConv */
00664 /***en
00665     @brief Structure for extra information about a coding system of
00666     type #MCODING_TYPE_UTF.  */
00667 
00668 /***ja
00669     @brief MCODING_TYPE_UTF タイプのコード系で必要な付加情報用の構造体
00670 
00671     @latexonly \IPApage{MCodingInfoUTF} @endlatexonly
00672 
00673     @latexonly \IPAlabel{MCodingInfoUTF} @endlatexonly  */
00674 
00675 typedef struct
00676 {
00677   /***en
00678       Specify bits of a code unit.  The value must be 8, 16, or 32.  */
00679   int code_unit_bits;
00680 
00681   /***en
00682       Specify how to handle the heading BOM (byte order mark).  The
00683       value must be 0, 1, or 2.  The meanings are as follows:
00684 
00685       0: On decoding, check the first two byte.  If they are BOM,
00686       decide endian by them. If not, decide endian by the member @c
00687       endian.  On encoding, produce byte sequence according to
00688       @c endian with heading BOM.
00689 
00690       1: On decoding, do not handle the first two bytes as BOM, and
00691       decide endian by @c endian.  On encoding, produce byte sequence
00692       according to @c endian without BOM.
00693 
00694       2: On decoding, handle the first two bytes as BOM and decide
00695       ending by them.  On encoding, produce byte sequence according to
00696       @c endian with heading BOM.
00697 
00698       If <code_unit_bits> is 8, the value has no meaning.  */
00699 
00700   /***ja
00701       先頭の BOM (バイトオーダーマーク) の取り扱いを指定する。値は 0,
00702       1, 2 のいずれかであり、それぞれの意味は以下のようになる。
00703 
00704       0: デコードの際に最初の2バイトを調べる。もしそれが BOM であれば、
00705       エンディアンをそれで判定する。もし最初の2バイトが BOM でなければ、
00706       メンバ @c endian に従ってエンディアンを決定する。エンコードの際
00707       には @c endian に従ったバイト列を BOM 付で生成する。
00708 
00709       1: デコードの際、最初の2バイトを BOM として扱わない。エン
00710       ディアンは @c endian で判定する。エンコードの際には、BOM 
00711       を出力せず、@c endian に応じたバイト列を生成する。
00712 
00713       2: デコードの際に最初の2バイトを BOMとして扱い、それに従っ
00714       てエンディアンを判定する。エンコードの際には @c endian に
00715       応じたバイト列を BOM 付きで生成する。  */
00716   int bom;
00717 
00718   /***en
00719       Specify the endian type.  The value must be 0 or 1.  0 means
00720       little endian, and 1 means big endian.
00721 
00722       If <code_unit_bits> is 8, the value has no meaning.  */
00723   /***ja
00724       エンディアンのタイプを指定する。値は 0 か 1 であり、0 ならばリト
00725       ルエンディアン、1 ならばビッグエンディアンである。*/
00726   int endian;
00727 } MCodingInfoUTF;
00728 /*=*/
00729 
00730 extern MSymbol mconv_define_coding (char *name, MPlist *plist,
00731                                     int (*resetter) (MConverter *),
00732                                     int (*decoder) (unsigned char *, int,
00733                                                     MText *, MConverter *),
00734                                     int (*encoder) (MText *, int, int,
00735                                                     unsigned char *, int,
00736                                                     MConverter *),
00737                                     void *extra_info);
00738 
00739 extern MSymbol mconv_resolve_coding (MSymbol symbol);
00740 
00741 extern int mconv_list_codings (MSymbol **symbols);
00742 
00743 extern MConverter *mconv_buffer_converter (MSymbol coding, unsigned char *buf,
00744                                            int n);
00745 
00746 extern MConverter *mconv_stream_converter (MSymbol coding, FILE *fp);
00747 
00748 extern int mconv_reset_converter (MConverter *converter);
00749 
00750 extern void mconv_free_converter (MConverter *converter);
00751 
00752 extern MConverter *mconv_rebind_buffer (MConverter *converter,
00753                                         unsigned char *buf, int n);
00754 
00755 extern MConverter *mconv_rebind_stream (MConverter *converter, FILE *fp);
00756 
00757 extern MText *mconv_decode (MConverter *converter, MText *mt);
00758 
00759 MText *mconv_decode_buffer (MSymbol name, unsigned char *buf, int n);
00760 
00761 MText *mconv_decode_stream (MSymbol name, FILE *fp);   
00762 
00763 extern int mconv_encode (MConverter *converter, MText *mt);
00764 
00765 extern int mconv_encode_range (MConverter *converter, MText *mt,
00766                                int from, int to);
00767 
00768 extern int mconv_encode_buffer (MSymbol name, MText *mt,
00769                                 unsigned char *buf, int n);
00770 
00771 extern int mconv_encode_stream (MSymbol name, MText *mt, FILE *fp);
00772 
00773 extern int mconv_getc (MConverter *converter);
00774 
00775 extern int mconv_ungetc (MConverter *converter, int c);
00776 
00777 extern int mconv_putc (MConverter *converter, int c);
00778 
00779 extern MText *mconv_gets (MConverter *converter, MText *mt);
00780 
00781 /* (S4) Locale related functions corresponding to libc functions */
00782 
00783 /*** @ingroup m17nShell */
00784 /***en @defgroup m17nLocale Locale */
00785 /***ja @defgroup m17nLocale ロケール */
00786 /*=*/
00787 
00788 /***en
00789     @brief @c struct @c MLocale
00790 
00791     The structure @c MLocale is used to hold information about name,
00792     language, territory, modifier, codeset, and the corresponding
00793     coding system of locales.
00794 
00795     The contents of this structure are implementation dependent.  Its
00796     internal structure is concealed from application programs.  */
00797 
00798 /***ja
00799     @brief @c MLocale 構造体
00800 
00801     @c MLocale 構造体は、ロケールの名前、言語、地域、モディファイア、
00802     コードセット、および対応するコード系に関する情報を保持するために用
00803     いられる。
00804 
00805     この構造体の内容は実装に依存する。 内部構造はアプリケーションプロ
00806     グラムからは見えない。  */
00807 
00808 /***
00809     @seealso
00810     mlocale_get_prop () */
00811 
00812 typedef struct MLocale MLocale;
00813 
00814 /*=*/
00815 
00816 extern MSymbol Mlanguage;
00817 extern MSymbol Mterritory;
00818 extern MSymbol Mmodifier;
00819 extern MSymbol Mcodeset;
00820 
00821 extern MLocale *mlocale_set (int category, const char *locale);
00822 
00823 extern MSymbol mlocale_get_prop (MLocale *locale, MSymbol key);
00824 
00825 extern int mtext_ftime (MText *mt, const char *format, const struct tm *tm,
00826                         MLocale *locale);
00827 
00828 extern MText *mtext_getenv (const char *name);
00829 
00830 extern int mtext_putenv (MText *mt);
00831 
00832 extern int mtext_coll (MText *mt1, MText *mt2);
00833 
00834 /*
00835  *  (9) Miscellaneous functions of libc level (not yet implemented)
00836  */
00837 
00838 /*
00839 extern int mtext_width (MText *mt, int n);
00840 extern MText *mtext_tolower (MText *mt);
00841 extern MText *mtext_toupper (MText *mt);
00842 */
00843 
00844 /*
00845  *  (10) Input method
00846  */
00847 
00848 /*** @ingroup m17nShell */
00849 /***en @defgroup m17nInputMethod Input Method (basic) */
00850 /***ja @defgroup m17nInputMethod 入力メソッド (基本) */
00851 /*=*/
00852 
00853 /* Struct forward declaration.  */
00854 typedef struct MInputMethod MInputMethod;
00855 typedef struct MInputContext MInputContext;
00856 
00857 /*** @ingroup m17nInputMethod */
00858 
00859 /***en
00860     @brief Type of input method callback functions.
00861 
00862     This is the type of callback functions called from input method
00863     drivers.  #IC is a pointer to an input context, #COMMAND is a name
00864     of callback for which the function is called.   */
00865 
00866 typedef void (*MInputCallbackFunc) (MInputContext *ic, MSymbol command);
00867 /*=*/
00868 
00869 /***en
00870     @brief Structure of input method driver.
00871 
00872     The type @c MInputDriver is the structure of an input driver that
00873     contains several functions to handle an input method.  */
00874 
00875 /***ja
00876     @brief 入力ドライバ
00877 
00878     @c MInputDriver 型は、入力メソッドを取り扱う関数を含む入力ドライバ
00879     の構造体である。  */
00880 
00881 typedef struct MInputDriver
00882 {
00883   /***en
00884       @brief Open an input method.
00885 
00886       This function opens the input method $IC.  It is called from the
00887       function minput_open_im () after all member of $IM but <info>
00888       set.  If opening $IM succeeds, it returns 0.  Otherwise, it
00889       returns -1.  The function can setup $IM->info to keep various
00890       information that is referred by the other driver functions.  */
00891 
00892   /***ja
00893       @brief 入力メソッドをオープンする
00894 
00895       この関数は、入力メソッド$IMをオープンする。$IM の<info>以外の全
00896       メンバーがセットされた後で、関数 minput_open_im () から呼ばれる。
00897       $IM をオープンできれば 0 を、できなければ -1を返す。この関数は 
00898       $IM->info を設定して、他のドライバ関数から参照される情報を保持す
00899       ることができる。
00900       */
00901 
00902   int (*open_im) (MInputMethod *im);
00903 
00904   /***en
00905       @brief Close an input method.
00906 
00907       This function closes the input method $IM.  It is called from
00908       the function minput_close_im ().  It frees all memory allocated
00909       for $IM->info (if any) after finishing all the tasks of closing
00910       the input method.  But, the other members of $IM should not be
00911       touched.  */
00912 
00913   /***ja
00914       @brief 入力メソッドをクローズする
00915 
00916       この関数は関数 minput_close_im () から呼ばれ、入力メソッドをクロー
00917       ズする。。入力メソッドのクローズがすべて終了した時点で、
00918       $IM->info に割り当てられているメモリを(あれば)開放する。ただし、
00919       $IM の他のメンバに影響を与えてはならない。       */
00920 
00921   void (*close_im) (MInputMethod *im);
00922 
00923   /***en
00924       @brief Create an input context.
00925 
00926       This function creates the input context $IC.  It is called from
00927       the function minput_create_ic () after all members of $IC but
00928       <info> are set.  If creating $IC succeeds, it returns 0.
00929       Otherwise, it returns -1.  The function can setup $IC->info to
00930       keep various information that is referred by the other driver
00931       functions.  */
00932 
00933   /***ja
00934       @brief 入力コンテクストを生成する
00935 
00936       入力コンテクスト $IC を生成する関数。この関数は、$IC の <info> 
00937       以外の全メンバーがセットされた後で、関数 minput_create_ic () か
00938       ら呼ばれる。$IC を生成できれば 0 を、できなければ -1 を返す。こ
00939       の関数は $IC->info を設定して、他のドライバ関数から参照される情
00940       報を保持することができる。  */
00941 
00942 
00943   int (*create_ic) (MInputContext *ic);
00944 
00945   /***en
00946       @brief Destroy an input context.
00947 
00948       This function is called from the function minput_destroy_ic ()
00949       and destroys the input context $IC.  It frees all memory
00950       allocated for $IC->info (if any) after finishing all the tasks
00951       of destroying the input method.  But, the other members of $IC
00952       should not be touched.  */
00953 
00954   /***ja
00955       @brief 入力コンテクストを破壊する
00956 
00957       関数 minput_destroy_ic () から呼ばれ、入力コンテクスト $IC を破
00958       壊する。入力コンテクストの破壊がすべて終了した時点で、$IC->info 
00959       に割り当てられているメモリを(あれば)開放する。ただし、$IC の他の
00960       メンバに影響を与えてはならない。       */
00961 
00962   void (*destroy_ic) (MInputContext *ic);
00963 
00964   /***en
00965       @brief Filter an input key.
00966 
00967       This function is called from the function minput_filter () and
00968       filters an input key.  $KEY and $ARG are the same as what given
00969       to minput_filter ().
00970 
00971       The task of the function is to handle $KEY, update the internal
00972       state of $IC.  If $KEY is absorbed by the input method and no
00973       text is produced, it returns 1.  Otherwise, it returns 0.
00974 
00975       It may update $IC->status, $IC->preedit, $IC->cursor_pos,
00976       $IC->ncandidates, $IC->candidates, and $IC->produced if that is
00977       necessary for the member <callback>.
00978 
00979       The meaning of $ARG depends on the input driver.  See the
00980       documentation of @c minput_default_driver and @c
00981       minput_gui_driver for instance.  */
00982 
00983   /***ja
00984       @brief 入力イベントあるいは入力キーをフィルタする
00985 
00986       関数 minput_filter () から呼ばれ、入力キーをフィルタする。引数 
00987       $KEY, $ARG は関数 minput_filter () のものと同じ。
00988 
00989       この関数は $KEY を処理し、$IC の内部状態をアップデートする。 
00990       $KEY が入力メソッドに吸収されてテキストが生成されなかった場合に
00991       は、 1 を返す。そうでなければ 0 を返す。
00992 
00993       メンバ <callback> に必要であれば、$IC->status, $IC->preedit,
00994       $IC->cursor_pos, $IC->ncandidates, $IC->candidates,
00995       $IC->produced をアップデートすることができる。
00996 
00997       $ARG の意味は入力ドライバに依存する。例は @c
00998       minput_default_driver または @c minput_gui_driver のドキュメント
00999       を参照のこと。 */
01000 
01001   int (*filter) (MInputContext *ic, MSymbol key, void *arg);
01002 
01003   /***en
01004       @brief  Lookup a produced text in an input context
01005 
01006       It is called from the function minput_lookup () and looks up a
01007       produced text in the input context $IC.  This function
01008       concatenate a text produced by the input key $KEY (if any) to
01009       M-text $MT.  If $KEY was correctly handled by the input method
01010       of $IC, it returns 0.  Otherwise, it returns 1.
01011 
01012       The meaning of $ARG depends on the input driver.  See the
01013       documentation of @c minput_default_driver and @c
01014       minput_gui_driver for instance.  */
01015 
01016   /***ja
01017       @brief 入力コンテクストで生成されるテキストの獲得
01018 
01019       関数 minput_lookup () から呼ばれ、入力コンテクスト $IC で生成さ
01020       れるテキストを検索する。入力キー $KEY によって生成されるテキスト
01021       があれば、$IC->produced に設定する。 $KEY が入力メソッド $IC に
01022       よって正しく処理されれば 0 を返す。そうでなければ 1 を返す。
01023 
01024       $ARG の意味は入力ドライバに依存する。例は @c
01025       minput_default_driver または @c minput_gui_driver のドキュメント
01026       を参照のこと。 */
01027 
01028   int (*lookup) (MInputContext *ic, MSymbol key, void *arg, MText *mt);
01029 
01030   /***en
01031       @brief List of callback functions.
01032 
01033       List of callback functions.  Keys are one of
01034       #Minput_preedit_start, #Minput_preedit_draw,
01035       #Minput_preedit_done, #Minput_status_start, #Minput_status_draw,
01036       #Minput_status_done, #Minput_candidates_start,
01037       #Minput_candidates_draw, #Minput_candidates_done,
01038       #Minput_set_spot, and #Minput_toggle.  Values are functions of
01039       type #MInputCallbackFunc.  */
01040   MPlist *callback_list;
01041 
01042 } MInputDriver;
01043 /*=*/
01044 
01045 extern MInputDriver minput_default_driver;
01046 
01047 extern MSymbol Minput_driver;
01048 
01049 extern MInputDriver *minput_driver;
01050 
01052 extern MSymbol Minput_preedit_start;
01053 extern MSymbol Minput_preedit_draw;
01054 extern MSymbol Minput_preedit_done;
01055 extern MSymbol Minput_status_start;
01056 extern MSymbol Minput_status_draw;
01057 extern MSymbol Minput_status_done;
01058 extern MSymbol Minput_candidates_start;
01059 extern MSymbol Minput_candidates_draw;
01060 extern MSymbol Minput_candidates_done;
01061 extern MSymbol Minput_set_spot;
01062 extern MSymbol Minput_toggle;
01063 
01064 /***en
01065     @brief Structure of input method.
01066 
01067     The type @c MInputMethod is the structure of input method
01068     objects.  */
01069 /***ja
01070     @brief 入力メソッド用構造体
01071 
01072     @c MInputMethod 型は、入力メソッドオブジェクト用の構造体である。  */
01073 
01074 struct MInputMethod
01075 {
01076   /***en Which language this input method is for.  The value is @c
01077       Mnil if the input method is foreign.  */
01078   /***ja どの言語用の入力メソッドか。入力メソッドが外部のものである場
01079       合には値として @c を持つ。  */
01080   MSymbol language;
01081 
01082   /***en Name of the input method.  If the input method is foreign, it
01083       must has a property of key @c Minput_driver and the value must be a
01084       pointer to a proper input driver.  */
01085   /***ja 入力メソッドの名前。外部メソッドである場合には、@c
01086       Minput_driver をキーとするプロパティを持ち、その値は適切な入力ド
01087       ライバへのポインタでなくてはならない。*/
01088   MSymbol name;
01089 
01090   /***en Input driver of the input method.  */
01091   /***ja その入力メソッド用の入力ドライバ  */
01092   MInputDriver driver;
01093 
01094   /***en The argument given to minput_open_im (). */
01095   /***ja minput_open_im () に与えられる引数  */
01096   void *arg;
01097 
01098   /***en Pointer to extra information that <driver>.open_im ()
01099       setups. */
01100   /***ja <driver>.open_im () が設定する追加情報へのポインタ */
01101   void *info;
01102 };
01103 
01104 /*=*/
01105 
01106 /***en
01107     @brief Structure of input context.
01108 
01109     The type @c MInputContext is the structure of input context
01110     objects.  */
01111 
01112 /***ja
01113     @brief 入力コンテクスト用構造体
01114 
01115     @c MInputContext 型は、入力コンテクストオブジェクト用の構造体であ
01116     る。  */
01117 
01118 struct MInputContext
01119 {
01120   /***en Backward pointer to the input method.  It is set up be the
01121       function minput_create_ic ().  */
01122   /***ja 入力メソッドへの逆ポインタ。関数 minput_create_ic () によって
01123       設定される。  */ 
01124   MInputMethod *im;
01125 
01126   /***en M-text produced by the input method.  It is set up by the
01127       function minput_lookup () .  */
01128   /***ja 入力メソッドによって生成される M-text。関数 minput_lookup () 
01129       によって設定される。  */
01130   MText *produced;
01131 
01132   /***en Argument given to the function minput_create_im (). */
01133   /***ja 関数 minput_create_ic () に渡される引数 */
01134   void *arg;
01135 
01136   /***en Flag telling whether the input context is currently active or
01137       inactive.  The value is set to 1 (active) when the input context
01138       is created.  It can be toggled by the function minput_toggle
01139       ().  */
01140   /***ja 入力コンテクストがアクティブかどうかを示すフラグ。入力コンテ
01141       クストが生成された時点では値は 1 (アクティブ)であり、関数 
01142       minput_toggle () によってトグルできる。  */
01143   int active;
01144 
01145 
01146   /***en Spot location and size of the input context.  */
01147   /***ja 入力コンテクストのスポットの位置と大きさ  */
01148   struct {
01149     /***en X and Y coordinate of the spot.  */
01150     /***ja スポットの X, Y 座標  */
01151     int x, y;
01152     /***en Ascent and descent pixels of the line of the spot.  */
01153     /***ja スポットのアセントとディセントのピクセル数  */
01154     int ascent, descent;
01155 
01156     /***en Font size for preedit text in 1/10 point.  */
01157     int fontsize;
01158 
01159     /***en M-text at the spot, or NULL.  */
01160     MText *mt;
01161     /***en Character position in <mt> at the spot.  */
01162     int pos;
01163   } spot;
01164 
01165   /***en The usage of the following members depends on the input
01166       driver.  The descriptions below are for the input driver of an
01167       internal input method.  They are set by the function
01168       <im>->driver.filter ().  */
01169   /***ja 以下のメンバの使用法は入力ドライバによって異なる。以下の説明
01170       は、内部入力メソッド用の入力ドライバに対するものである。 */
01171 
01172   /***en Pointer to extra information that <im>->driver.create_ic ()
01173       setups.  It is used to record the internal state of the input
01174       context.  */
01175   /***ja <im>->driver.create_ic () が設定する追加情報へのポインタ。入
01176       力コンテクストの内部状態を記録するために用いられる。 */
01177   void *info;
01178 
01179   /***en M-text describing the current status of the input
01180       context.  */
01181   /***ja 入力コンテクストの現在の状況を表す M-text  */
01182   MText *status;
01183 
01184   /***en The function <im>->driver.filter () sets the value to 1 when
01185       it changes <status>.  */
01186   int status_changed;
01187 
01188   /***en M-text containing the current preedit text.  The function
01189       <im>->driver.filter () sets the value.  */
01190   /***ja 現在の preedit テキストを含む M-text */
01191   MText *preedit;
01192 
01193   /***en The function <im>->driver.filter () sets the value to 1 when
01194       it changes <preedit>.  */
01195   int preedit_changed;
01196 
01197   /***en Cursor position of <preedit>.  */
01198   /***ja <preedit>のカーソル位置  */
01199   int cursor_pos;
01200 
01201   int cursor_pos_changed;
01202 
01203   /***en Array of the current candidate texts.  */
01204   /***ja 現在のテキスト候補のグループのリスト  */
01205   MPlist *candidate_list;
01206   int candidate_index;
01207   int candidate_from, candidate_to;
01208   int candidate_show;
01209 
01210   /***en The function <im>->driver.filter () sets the value to 1 when
01211       it changes one of the above members.  */
01212   int candidates_changed;
01213 
01214   MPlist *plist;
01215 };
01216 
01217 /*=*/
01218 
01219 extern MInputMethod *minput_open_im (MSymbol language, MSymbol name,
01220                                      void *arg);
01221 
01222 /*=*/
01223 
01224 extern void minput_close_im (MInputMethod *im);
01225 
01226 extern MInputContext *minput_create_ic (MInputMethod *im, void *arg);
01227 
01228 extern void minput_destroy_ic (MInputContext *ic);
01229 
01230 extern int minput_filter (MInputContext *ic, MSymbol key, void *arg);
01231 
01232 extern int minput_lookup (MInputContext *ic, MSymbol key, void *arg,
01233                           MText *mt);
01234 
01235 extern void minput_set_spot (MInputContext *ic, int x, int y,
01236                              int ascent, int descent, int fontsize,
01237                              MText *mt, int pos);
01238 
01239 extern void minput_toggle (MInputContext *ic);
01240 
01241 extern MSymbol minput_char_to_key (int c);
01242 
01243 /*=*/
01244 
01245 extern MInputMethod *mdebug_dump_im (MInputMethod *im, int indent);
01246 
01247 #ifdef __cplusplus
01248 }
01249 #endif
01250 
01251 #endif /* _M17N_H_ */
01252 
01253 /*
01254   Local Variables:
01255   coding: euc-japan
01256   End:
01257 */

Top of this page

Main Page   Modules   Data Structures   Globals   Appendix  

mulemark mule-aist@m17n.org