Handle the case of _M17N_FLT_H_ being defined.
[m17n/m17n-lib.git] / src / m17n.h
1 /* m17n.h -- header file for the SHELL API of the m17n library.
2    Copyright (C) 2003, 2004
3      National Institute of Advanced Industrial Science and Technology (AIST)
4      Registration Number H15PRO112
5
6    This file is part of the m17n library.
7
8    The m17n library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public License
10    as published by the Free Software Foundation; either version 2.1 of
11    the License, or (at your option) any later version.
12
13    The m17n library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Lesser General Public License for more details.
17
18    You should have received a copy of the GNU Lesser General Public
19    License along with the m17n library; if not, write to the Free
20    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    02111-1307, USA.  */
22
23 #ifndef _M17N_H_
24 #define _M17N_H_
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <time.h>
29
30 #ifndef _M17N_CORE_H_
31 #include <m17n-core.h>
32 #endif
33
34 M17N_BEGIN_HEADER
35
36 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
37 extern void m17n_init (void);
38 #undef M17N_INIT
39 #ifdef _M17N_FLT_H_
40 #define M17N_INIT()     \
41   do {                  \
42     m17n_init ();       \
43     m17n_init_flt ();   \
44   } while (0)
45 #else  /* not _M17N_FLT_H_ */
46 #define M17N_INIT() m17n_init ()
47 #endif  /* not _M17N_FLT_H_ */
48
49 extern void m17n_fini (void);
50 #undef M17N_FINI
51 #ifdef _M17N_FLT_H_
52 #define M17N_FINI()     \
53   do {                  \
54     m17n_fini_flt ();   \
55     m17n_fini ();       \
56   } while (0)
57 #else  /* not _M17N_FLT_H_ */
58 #define M17N_FINI() m17n_fini ()
59 #endif  /* not _M17N_FLT_H_ */
60
61 #endif
62
63 /***en @defgroup m17nShell SHELL API */
64 /***ja @defgroup m17nShell ¥·¥§¥ë API */
65 /*=*/
66
67 /*
68  *  (11) Functions related to the m17n database
69  */
70 /*=*/
71
72 /*=*/
73 /* (S2) Charset staffs */
74 /*=*/
75
76 /*** @ingroup m17nShell */
77 /***en @defgroup m17nCharset Charset */
78 /***ja @defgroup m17nCharset Ê¸»ú¥»¥Ã¥È */
79 /*=*/
80
81 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
82 #define MCHAR_INVALID_CODE 0xFFFFFFFF
83 #endif
84
85 /* Predefined charsets */ 
86 extern MSymbol Mcharset_ascii;
87 extern MSymbol Mcharset_iso_8859_1;
88 extern MSymbol Mcharset_unicode;
89 extern MSymbol Mcharset_m17n;
90 extern MSymbol Mcharset_binary;
91
92 /* Predefined keys for mchar_define_charset ().  */ 
93 extern MSymbol Mmethod;
94 extern MSymbol Mdimension;
95 extern MSymbol Mmin_range;
96 extern MSymbol Mmax_range;
97 extern MSymbol Mmin_code;
98 extern MSymbol Mmax_code;
99 extern MSymbol Mascii_compatible;
100 extern MSymbol Mfinal_byte;
101 extern MSymbol Mrevision;
102 extern MSymbol Mmin_char;
103 extern MSymbol Mmapfile;
104 extern MSymbol Mparents;
105 extern MSymbol Msubset_offset;
106 extern MSymbol Mdefine_coding;
107 extern MSymbol Maliases;
108
109 /* Methods of a charset.  */
110 extern MSymbol Moffset;
111 extern MSymbol Mmap;
112 extern MSymbol Munify;
113 extern MSymbol Msubset;
114 extern MSymbol Msuperset;
115
116 /* etc. */
117 extern MSymbol mchar_define_charset (const char *name, MPlist *plist);
118
119 extern MSymbol mchar_resolve_charset (MSymbol symbol);
120
121 extern int mchar_list_charset (MSymbol **symbols);
122
123 extern int mchar_decode (MSymbol charset_name, unsigned code);
124
125 extern unsigned mchar_encode (MSymbol charset_name, int c);
126
127 extern int mchar_map_charset (MSymbol charset_name,
128                               void (*func) (int from, int to, void *arg),
129                               void *func_arg);
130
131 /*=*/
132
133 /* (S3) code conversion */
134 /*=*/
135 /*** @ingroup m17nShell */
136 /***en @defgroup m17nConv Code Conversion */
137 /***ja @defgroup m17nConv ¥³¡¼¥ÉÊÑ´¹ */
138 /*=*/
139
140 /* Predefined coding systems */
141 extern MSymbol Mcoding_us_ascii;
142 extern MSymbol Mcoding_iso_8859_1;
143 extern MSymbol Mcoding_utf_8;
144 extern MSymbol Mcoding_utf_8_full;
145 extern MSymbol Mcoding_utf_16;
146 extern MSymbol Mcoding_utf_16be;
147 extern MSymbol Mcoding_utf_16le;
148 extern MSymbol Mcoding_utf_32;
149 extern MSymbol Mcoding_utf_32be;
150 extern MSymbol Mcoding_utf_32le;
151 extern MSymbol Mcoding_sjis;
152
153 /* Parameter keys for mconv_define_coding ().  */
154 extern MSymbol Mtype;
155 extern MSymbol Mcharsets;
156 extern MSymbol Mflags;
157 extern MSymbol Mdesignation;
158 extern MSymbol Minvocation;
159 extern MSymbol Mcode_unit;
160 extern MSymbol Mbom;
161 extern MSymbol Mlittle_endian;
162
163 /* Symbols representing coding system type.  */
164 extern MSymbol Mutf;
165 extern MSymbol Miso_2022;
166
167 /* Symbols appearing in the value of Mfrag parameter.  */
168 extern MSymbol Mreset_at_eol;
169 extern MSymbol Mreset_at_cntl;
170 extern MSymbol Meight_bit;
171 extern MSymbol Mlong_form;
172 extern MSymbol Mdesignation_g0;
173 extern MSymbol Mdesignation_g1;
174 extern MSymbol Mdesignation_ctext;
175 extern MSymbol Mdesignation_ctext_ext;
176 extern MSymbol Mlocking_shift;
177 extern MSymbol Msingle_shift;
178 extern MSymbol Msingle_shift_7;
179 extern MSymbol Meuc_tw_shift;
180 extern MSymbol Miso_6429;
181 extern MSymbol Mrevision_number;
182 extern MSymbol Mfull_support;
183
184 /* etc */
185 extern MSymbol Mcoding;
186 extern MSymbol Mmaybe;
187
188 /*** @ingroup m17nConv */
189 /***en
190     @brief Codes that represent the result of code conversion.
191
192     One of these values is set in @c MConverter-\>result.   */
193
194 /***ja
195     @brief ¥³¡¼¥ÉÊÑ´¹¤Î·ë²Ì¤ò¼¨¤¹¥³¡¼¥É.
196
197     ¤³¤ì¤é¤ÎÃͤΤ¦¤Á°ì¤Ä¤¬ @c MConverter-\>result ¤ËÀßÄꤵ¤ì¤ë¡£  */
198
199 enum MConversionResult
200   {
201     /***en Code conversion is successful. */
202     /***ja ¥³¡¼¥ÉÊÑ´¹¤ÏÀ®¸ù. */
203     MCONVERSION_RESULT_SUCCESS,
204
205     /***en On decoding, the source contains an invalid byte. */
206     /***ja ¥Ç¥³¡¼¥É»þ¡¢¥½¡¼¥¹¤ËÉÔÀµ¤Ê¥Ð¥¤¥È¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë. */
207     MCONVERSION_RESULT_INVALID_BYTE,
208
209     /***en On encoding, the source contains a character that cannot be
210         encoded by the specified coding system. */
211     /***ja ¥¨¥ó¥³¡¼¥É»þ¡¢»ØÄê¤Î¥³¡¼¥É·Ï¤Ç¥¨¥ó¥³¡¼¥É¤Ç¤­¤Ê¤¤Ê¸»ú¤¬¥½¡¼¥¹¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë. */
212     MCONVERSION_RESULT_INVALID_CHAR,
213
214     /***en On decoding, the source ends with an incomplete byte sequence. */
215     /***ja ¥Ç¥³¡¼¥É»þ¡¢ÉÔ´°Á´¤Ê¥Ð¥¤¥ÈÎó¤Ç¥½¡¼¥¹¤¬½ª¤ï¤Ã¤Æ¤¤¤ë¡£*/
216     MCONVERSION_RESULT_INSUFFICIENT_SRC,
217
218     /***en On encoding, the destination is too short to store the result. */
219     /***ja ¥¨¥ó¥³¡¼¥É»þ¡¢·ë²Ì¤ò³ÊǼ¤¹¤ëÎΰ褬û¤«¤¹¤®¤ë¡£ */
220     MCONVERSION_RESULT_INSUFFICIENT_DST,
221
222     /***en An I/O error occurred in the conversion.  */
223     /***ja ¥³¡¼¥ÉÊÑ´¹Ãæ¤Ë I/O ¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£  */
224     MCONVERSION_RESULT_IO_ERROR
225   };
226 /*=*/
227
228 /*** @ingroup m17nConv */
229 /***en
230     @brief Structure to be used in code conversion.
231
232     Structure to be used in code conversion.  The first three members
233     are to control the conversion.  */
234
235 /***ja
236     @brief ¥³¡¼¥ÉÊÑ´¹¤ËÍѤ¤¤é¤ì¤ë¹½Â¤ÂÎ.
237
238     ¥³¡¼¥ÉÊÑ´¹¤ËÍѤ¤¤é¤ì¤ë¹½Â¤ÂΡ£ºÇ½é¤Î£³¤Ä¤Î¥á¥ó¥Ð¤ÏÊÑ´¹¤òÀ©¸æ¤¹¤ë¡£
239
240     @latexonly \IPAlabel{MConverter} @endlatexonly  
241 */
242
243 typedef struct
244 {
245   /***en
246       Set the value to nonzero if the conversion should be lenient.
247       By default, the conversion is strict (i.e. not lenient).
248
249       If the conversion is strict, the converter stops at the first
250       invalid byte (on decoding) or at the first character not
251       supported by the coding system (on encoding).  If this happens,
252       @c MConverter-\>result is set to @c
253       MCONVERSION_RESULT_INVALID_BYTE or @c
254       MCONVERSION_RESULT_INVALID_CHAR accordingly.
255
256       If the conversion is lenient, on decoding, an invalid byte is
257       kept per se, and on encoding, an invalid character is replaced
258       with "<U+XXXX>" (if the character is a Unicode character) or
259       with "<M+XXXXXX>" (otherwise).  */
260
261   /***ja 
262       ¸·Ì©¤ÊÊÑ´¹¤¬É¬ÍפǤʤ¤¾ì¹ç¤ËÃͤò 0 °Ê³°¤Ë¤¹¤ë¡£
263       ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢ÊÑ´¹¤Ï¸·Ì©¤Ç¤¢¤ë¡£
264
265       ÊÑ´¹¤¬¸·Ì©¤È¤Ï¡¢¥Ç¥³¡¼¥É¤ÎºÝ¤Ë¤ÏºÇ½é¤ÎÉÔÀµ¤Ê¥Ð¥¤¥È¤Ç¥³¥ó¥Ð¡¼¥¿¤¬»ß¤Þ¤ë¤³¤È¡¢
266       ¥¨¥ó¥³¡¼¥É¤ÎºÝ¤Ë¤ÏÊÑ´¹¤µ¤ì¤ë¥³¡¼¥É·Ï¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Ê¤¤ºÇ½é¤Îʸ»ú¤Ç¥³¥ó¥Ð¡¼¥¿¤¬»ß¤Þ¤ë¤³¤È¤ò»Ø¤¹¡£
267       ¤³¤ì¤é¤Î¾ì¹ç¡¢@c MConverter-\>result ¤Ï¤½¤ì¤¾¤ì @c
268       MCONVERSION_RESULT_INVALID_BYTE ¤«@c
269       MCONVERSION_RESULT_INVALID_CHAR ¤È¤Ê¤ë¡£
270
271       ÊÑ´¹¤¬¸·Ì©¤Ç¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢¥Ç¥³¡¼¥É¤ÎºÝ¤ÎÉÔÀµ¤Ê¥Ð¥¤¥È¤Ï¤½¤Î¥Ð¥¤¥È¤Î¤Þ¤Þ»Ä¤ë¡£
272       ¤Þ¤¿¥¨¥ó¥³¡¼¥É¤ÎºÝ¤Ë¤Ï¡¢ÉÔÀµ¤Êʸ»ú¤¬ Unicode Ê¸»ú¤Î¾ì¹ç¤Ë¤Ï "<U+XXXX>"
273       ¤Ë¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ë¤Ï "<M+XXXXXX>" ¤ËÃÖ¤­´¹¤¨¤é¤ì¤ë¡£  */
274
275   int lenient;
276
277   /***en
278       Set the value to nonzero before decoding or encoding the last
279       block of the byte sequence or the character sequence
280       respectively.  The value influences the conversion as below.
281
282       On decoding, in the case that the last few bytes are too short
283       to form a valid byte sequence:
284
285         If the value is nonzero, the conversion terminates by error
286         (MCONVERSION_RESULT_INVALID_BYTE) at the first byte of the
287         sequence.
288
289         If the value is zero, the conversion terminates successfully.
290         Those bytes are stored in the converter as carryover and are
291         prepended to the byte sequence of the further conversion.
292
293       On encoding, in the case that the coding system is context
294       dependent:
295
296         If the value is nonzero, the conversion may produce a byte
297         sequence at the end to reset the context to the initial state
298         even if the source characters are zero.
299
300         If the value is zero, the conversion never produce such a byte
301         sequence at the end.  */
302
303 /***ja 
304
305      ¥Ð¥¤¥ÈÎó¤Î½ªÃ¼¤Î¥Ö¥í¥Ã¥¯¤ò¥Ç¥³¡¼¥É¤¹¤ëºÝ¡¢¤Þ¤¿¤Ïʸ»úÎó¤Î½ªÃ¼¤Î¥Ö¥í¥Ã¥¯¤ò¥¨¥ó¥³¡¼¥É¤¹¤ëºÝ¤Ï¡¢Ãͤò
306      0 °Ê³°¤Ë¤¹¤ë¡£¤³¤ÎÃͤϰʲ¼¤Î¤è¤¦¤ËÊÑ´¹¤Ë±Æ¶Á¤¹¤ë¡£
307
308      ¥Ç¥³¡¼¥Ç¥£¥ó¥°¤ÎºÝ¤ËºÇ¸å¤Î¿ô¥Ð¥¤¥È¤¬Àµ¤·¤¤¥Ð¥¤¥È¥·¡¼¥¯¥¨¥ó¥¹¤ò·ÁÀ®¤¹¤ë¤Ë¤Ïû¤¹¤®¤ë¾ì¹ç¡§
309
310        Ãͤ¬ 0 ¤Ç¤Ê¤±¤ì¤Ð¡¢ÊÑ´¹¤Ï¤½¤Î¥·¡¼¥¯¥¨¥ó¥¹¤ÎºÇ½é¤Î¥Ð¥¤¥È¤Ë¤ª¤¤¤Æ¡¢¥¨¥é¡¼
311        (MCONVERSION_RESULT_INVALID_BYTE) ¤Ç½ª¤ë¡£
312
313        Ãͤ¬ 0 ¤Ê¤é¤Ð¡¢ÊÑ´¹¤ÏÀ®¸ù¤·¤Æ½ª¤ë¡£
314        ÌäÂê¤Î¿ô¥Ð¥¤¥È¤Ï¥­¥ã¥ê¡¼¥ª¡¼¥Ð¤È¤·¤Æ¥³¥ó¥Ð¡¼¥¿¤ËÊÝ»ý¤µ¤ì¡¢ÊÑ´¹¤Î³¤­¤ò¹Ô¤¦ºÝ¤ËÊÑ´¹¤¹¤ë¥Ð¥¤¥ÈÎó¤ÎÁ°¤ËÉÕ¤±¤é¤ì¤ë¡£
315
316      ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ÎºÝ¤Ë¥³¡¼¥É·Ï¤¬Ê¸Ì®°Í¸¤Î¾ì¹ç¡¢
317
318        Ãͤ¬ 0 ¤Ç¤Ê¤±¤ì¤Ð¡¢¥³¥ó¥Æ¥­¥¹¥È¤òºÇ½é¤ËÌ᤹¤¿¤á¤Î¥Ð¥¤¥ÈÎ󤬥½¡¼¥¹¤Îʸ»ú¤È¤«¤«¤ï¤ê¤Ê¤¯ÊÑ´¹¤Î·ë²ÌÀ¸À®¤µ¤ì¤ë¤³¤È¤¬¤¢¤ë¡£
319
320        Ãͤ¬ 0 ¤Ê¤é¤Ð¡¢¤½¤Î¤è¤¦¤Ê¥Ð¥¤¥ÈÎó¤ÏÀ¸À®¤µ¤ì¤Ê¤¤¡£
321
322          */
323
324   int last_block;
325
326   /***en
327       If the value is nonzero, it specifies at most how many
328       characters to convert.  */
329   /***ja
330       0 ¤Ç¤Ê¤±¤ì¤Ð¡¢ÊÑ´¹¤µ¤ì¤ëºÇÂç¤Îʸ»ú¿ô¤ò»ØÄꤹ¤ë¡£
331       */
332
333   unsigned at_most;
334
335   /***en
336       The following three members are to report the result of the
337       conversion.  */
338   /***ja
339       °Ê²¼¤Î£³¤Ä¤Î¥á¥ó¥Ð¤ÏÊÑ´¹¤Î·ë²Ì¤òɽ¤¹¤¿¤á¤Î¤â¤Î¤Ç¤¢¤ë¡£  */
340
341   /***en
342       Number of characters most recently decoded or encoded. */
343   /***ja
344       ºÇ¶á¤Ë¥Ç¥³¡¼¥É/¥¨¥ó¥³¡¼¥É¤µ¤ì¤¿Ê¸»ú¿ô¡£ */
345
346   int nchars;
347
348   /***en
349       Number of bytes recently decoded or encoded. */
350
351   /***ja
352       ºÇ¶á¤Ë¥Ç¥³¡¼¥É/¥¨¥ó¥³¡¼¥É¤µ¤ì¤¿¥Ð¥¤¥È¿ô¡£ */
353
354   int nbytes;
355
356   /***en
357       Result code of the conversion. */
358
359   /***ja
360       ¥³¡¼¥ÉÊÑ´¹¤Î·ë²Ì¤ò¼¨¤¹¥³¡¼¥É¡£ */
361
362   enum MConversionResult result;
363
364   /***en
365       Various information about the status of code conversion.  The
366       contents depend on the type of coding system.  It is assured
367       that @c status is aligned so that any type of casting is safe
368       and at least 256 bytes of memory space can be used.  */
369
370   /***ja
371       ¥³¡¼¥ÉÊÑ´¹¤Î¾õ¶·¤Ë´Ø¤¹¤ë¼ï¡¹¤Î¾ðÊó¡£ÆâÍƤϥ³¡¼¥É·Ï¤Î¥¿¥¤¥×¤Ë¤è¤Ã¤Æ°Û¤Ê¤ë¡£
372       @c status ¤Ï¤É¤Î¤è¤¦¤Ê·¿¤Ø¤Î¥­¥ã¥¹¥È¤ËÂФ·¤Æ¤â°ÂÁ´¤Ê¤è¤¦¤Ë¥á¥â¥ê¥¢¥é¥¤¥ó¤µ¤ì¤Æ¤ª¤ê¡¢¤Þ¤¿ºÇÄã256¥Ð¥¤¥È¤Î¥á¥â¥êÎΰ褬»È¤¨¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£  */
373
374   union {
375     void *ptr;
376     double dbl;
377     char c[256];
378   } status;
379
380   /***en
381       This member is for internally use only.  An application program
382       should never touch it.  */
383   /***ja ¤³¤Î¥á¥ó¥Ð¤ÏÆâÉôŪ¤Ë»ÈÍѤµ¤ì¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤Ï¿¨¤ì¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ */
384   void *internal_info;
385 } MConverter;
386 /*=*/
387
388 /*** @ingroup m17nConv */
389 /***en 
390     @brief Types of coding system.  */
391 /***ja 
392     @brief ¥³¡¼¥É·Ï¤Î¥¿¥¤¥×.  */
393
394 enum MCodingType
395   {
396     /***en
397         A coding system of this type supports charsets directly.
398         The dimension of each charset defines the length of bytes to
399         represent a single character of the charset, and a byte
400         sequence directly represents the code-point of a character.
401
402         The m17n library provides the default decoding and encoding
403         routines of this type.  */
404
405     /***ja
406         ¤³¤Î¥¿¥¤¥×¤Î¥³¡¼¥É·Ï¤Ïʸ»ú¥»¥Ã¥È¤òľÀÜ¥µ¥Ý¡¼¥È¤¹¤ë¡£
407         ³Æʸ»ú¥»¥Ã¥È¤Î¼¡¸µ¤È¤Ï¡¢¤½¤Îʸ»ú¥»¥Ã¥È¤Ç°ìʸ»ú¤òɽ¸½¤¹¤ë¤¿¤á¤ËɬÍפʥХ¤¥È¿ô¤Ç¤¢¤ê¡¢¥Ð¥¤¥ÈÎó¤Ïʸ»ú¤Î¥³¡¼¥É¥Ý¥¤¥ó¥È¤òľÀÜɽ¤¹¡£
408
409         m17n ¥é¥¤¥Ö¥é¥ê¤Ï¤³¤Î¥¿¥¤¥×ÍѤΥǥե©¥ë¥È¤Î¥¨¥ó¥³¡¼¥É¡¿¥Ç¥³¡¼¥É¥ë¡¼¥Æ¥£¥ó¤òÄ󶡤¹¤ë¡£  */
410
411     MCODING_TYPE_CHARSET,
412
413     /***en
414         A coding system of this type supports byte sequences of a
415         UTF (UTF-8, UTF-16, UTF-32) like structure.
416
417         The m17n library provides the default decoding and encoding
418         routines of this type.  */
419
420     /***ja
421         ¤³¤Î¥¿¥¤¥×¤Î¥³¡¼¥É·Ï¤Ï¡¢UTF ·Ï (UTF-8, UTF-16, UTF-32) ¤Î¥Ð¥¤¥ÈÎó¤ò¥µ¥Ý¡¼¥È¤¹¤ë¡£
422
423         m17n ¥é¥¤¥Ö¥é¥ê¤Ï¤³¤Î¥¿¥¤¥×ÍѤΥǥե©¥ë¥È¤Î¥¨¥ó¥³¡¼¥É¡¿¥Ç¥³¡¼¥É¥ë¡¼¥Æ¥£¥ó¤òÄ󶡤¹¤ë¡£  */
424
425     MCODING_TYPE_UTF,
426
427     /***en
428         A coding system of this type supports byte sequences of an
429         ISO-2022 like structure.  The details of each structure are
430         specified by @c MCodingInfoISO2022 .
431
432         The m17n library provides decoding and encoding routines of
433         this type.  */
434
435     /***ja 
436         ¤³¤Î¥¿¥¤¥×¤Î¥³¡¼¥É·Ï¤Ï¡¢ISO-2022 ·Ï¤Î¥Ð¥¤¥ÈÎó¤ò¥µ¥Ý¡¼¥È¤¹¤ë¡£
437         ³Æ¥³¡¼¥É·Ï¤Î¹½Â¤¤Î¾ÜºÙ¤Ï @c MCodingInfoISO2022 ¤Ç»ØÄꤵ¤ì¤ë¡£
438
439         m17n ¥é¥¤¥Ö¥é¥ê¤Ï¤³¤Î¥¿¥¤¥×ÍѤΥǥե©¥ë¥È¤Î¥¨¥ó¥³¡¼¥É¡¿¥Ç¥³¡¼¥É¥ë¡¼¥Æ¥£¥ó¤òÄ󶡤¹¤ë¡£  */
440
441     MCODING_TYPE_ISO_2022,
442
443     /***en
444         A coding system of this type is for byte sequences of
445         miscellaneous structures.
446
447         The m17n library does not provide decoding and encoding
448         routines of this type.  They must be provided by the
449         application program.  */
450
451     /***ja
452         ¤³¤Î¥¿¥¤¥×¤Î¥³¡¼¥É·Ï¤Ï¡¢¤½¤Î¾¤Î¹½Â¤¤Î¥Ð¥¤¥ÈÎó¤Î¤¿¤á¤Î¤â¤Î¤Ç¤¢¤ë¡£
453
454         m17n ¥é¥¤¥Ö¥é¥ê¤Ï¤³¤Î¥¿¥¤¥×ÍѤΥ¨¥ó¥³¡¼¥É¡¿¥Ç¥³¡¼¥É¥ë¡¼¥Æ¥£¥ó¤òÄ󶡤·¤Ê¤¤¤Î¤Ç¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¦¤Ç½àÈ÷¤¹¤ëɬÍפ¬¤¢¤ë¡£  */
455
456     MCODING_TYPE_MISC
457   };
458 /*=*/
459
460 /*** @ingroup m17nConv */
461 /***en 
462     @brief  Bit-masks to specify the detail of coding system whose type is MCODING_TYPE_ISO_2022.  */
463 /***ja 
464     @brief MCODING_TYPE_ISO_2022 ¥¿¥¤¥×¤Î¥³¡¼¥É·Ï¤Î¾ÜºÙ¤òɽ¤ï¤¹¥Ó¥Ã¥È¥Þ¥¹¥¯.  */
465
466 enum MCodingFlagISO2022
467   {
468     /***en
469         On encoding, reset the invocation and designation status to
470         initial at end of line.  */
471     /***ja ¥¨¥ó¥³¡¼¥É¤ÎºÝ¡¢¹ÔËö¤Ç¸Æ¤Ó½Ð¤· (invocation) ¤È»Ø¼¨
472         (designation) ¤Î¾õÂÖ¤ò½é´üÃͤËÌ᤹¡£   */
473     MCODING_ISO_RESET_AT_EOL =          0x1,
474
475     /***en
476         On encoding, reset the invocation and designation status to
477         initial before any control codes.  */
478     /***ja
479         ¥¨¥ó¥³¡¼¥É¤ÎºÝ¡¢¤¹¤Ù¤Æ¤ÎÀ©¸æʸ»ú¤ÎÁ°¤Ç¡¢¸Æ¤Ó½Ð¤·
480         (invocation) ¤È»Ø¼¨ (designation) ¤Î¾õÂÖ¤ò½é´üÃͤËÌ᤹¡£        */
481     MCODING_ISO_RESET_AT_CNTL =         0x2,
482
483     /***en
484         Use the right graphic plane.  */
485     /***ja
486         ¿Þ·Áʸ»ú½¸¹ç¤Î±¦Â¦¤ò»È¤¦¡£  */
487     MCODING_ISO_EIGHT_BIT =             0x4,
488
489     /***en
490         Use the non-standard 4 bytes format for designation sequence
491         for charsets JISX0208-1978, GB2312, and JISX0208-1983.  */
492     /***ja
493         JISX0208-1978, GB2312, JISX0208-1983 
494         ¤Îʸ»ú½¸¹ç¤ËÂФ¹¤ë»Ø¼¨¥·¡¼¥¯¥¨¥ó¥¹¤È¤·¤Æ¡¢Èóɸ½à¤Î4¥Ð¥¤¥È·Á¼°¤òÍѤ¤¤ë¡£ */
495
496     MCODING_ISO_LONG_FORM =             0x8,
497
498     /***en
499         On encoding, unless explicitly specified, designate charsets
500         to G0.  */
501     /***ja 
502         ¥¨¥ó¥³¡¼¥É¤ÎºÝ¡¢Æä˻ØÄꤵ¤ì¤Ê¤¤¸Â¤ê¡¢Ê¸»ú½¸¹ç¤ò G0 
503         ¤Ë»Ø¼¨¤¹¤ë¡£*/
504     MCODING_ISO_DESIGNATION_G0 =                0x10,
505
506     /***en
507         On encoding, unless explicitly specified, designate charsets
508         except for ASCII to G1.  */
509     /***ja
510         ¥¨¥ó¥³¡¼¥É¤ÎºÝ¡¢Æä˻ØÄꤵ¤ì¤Ê¤¤¸Â¤ê¡¢ASCII °Ê³°¤Îʸ»ú½¸¹ç¤ò 
511         G1 ¤Ë»Ø¼¨¤¹¤ë¡£*/
512     MCODING_ISO_DESIGNATION_G1 =                0x20,
513
514     /***en
515         On encoding, unless explicitly specified, designate 94-chars
516         charsets to G0, 96-chars charsets to G1.  */
517     /***ja
518         ¥¨¥ó¥³¡¼¥É¤ÎºÝ¡¢Æä˻ØÄꤵ¤ì¤Ê¤¤¸Â¤ê¡¢94ʸ»ú½¸¹ç¤ò G0 
519         ¤Ë¡¢96ʸ»ú½¸¹ç¤ò G1 ¤Ë»Ø¼¨¤¹¤ë¡£*/
520     MCODING_ISO_DESIGNATION_CTEXT =     0x40,
521
522     /***en
523         On encoding, encode such charsets not conforming to ISO-2022
524         by ESC % / ..., and encode non-supported Unicode characters by
525         ESC % G ... ESC % @@ .  On decoding, handle those escape
526         sequences.  */
527     /***ja
528         ¥¨¥ó¥³¡¼¥É¤ÎºÝ¡¢ISO-2022 ¤Ë¹çÃפ·¤Ê¤¤Ê¸»ú½¸¹ç¤ò ESC % / ... 
529         ¤Ç¥¨¥ó¥³¡¼¥É¤¹¤ë¡£¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤ Unicode Ê¸»ú¤Ï ESC % G ...
530         ESC % @@ ¤Ç¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
531         ¥Ç¥³¡¼¥É¤ÎºÝ¡¢¤³¤ì¤é¤Î¥¨¥¹¥±¡¼¥×¡¦¥·¡¼¥±¥ó¥¹¤ò²ò¼á¤¹¤ë¡£  */
532     MCODING_ISO_DESIGNATION_CTEXT_EXT = 0x80,
533
534     /***en
535         Use locking shift.  */
536     /***ja
537         ¥í¥Ã¥­¥ó¥°¥·¥Õ¥È¤ò»È¤¦¡£  */
538     MCODING_ISO_LOCKING_SHIFT = 0x100,
539
540     /***en
541         Use single shift (SS2 (0x8E or ESC N), SS3 (0x8F or ESC O)).  */
542     /***ja
543         ¥·¥ó¥°¥ë¥·¥Õ¥È (SS2 (0x8E or ESC N), SS3 (0x8F or ESC O)) ¤ò»È¤¦¡£  */
544     MCODING_ISO_SINGLE_SHIFT =  0x200,
545
546     /***en
547         Use 7-bit single shift 2 (SS2 (0x19)).  */
548     /***ja
549         7¥Ó¥Ã¥È¥·¥ó¥°¥ë¥·¥Õ¥È 2 (SS2 (0x19)) ¤ò»È¤¦¡£  */
550     MCODING_ISO_SINGLE_SHIFT_7 =        0x400,
551
552     /***en
553         Use EUC-TW like special shifting.  */
554     /***ja
555         EUC-TW É÷¤ÎÆÃÊ̤ʥ·¥Õ¥È¤ò»È¤¦¡£  */
556     MCODING_ISO_EUC_TW_SHIFT =  0x800,
557
558     /***en
559         Use ISO-6429 escape sequences to indicate direction.
560         Not yet implemented.  */
561     /***ja
562         ISO-6429 ¤Î¥¨¥¹¥±¡¼¥×¥·¡¼¥¯¥¨¥ó¥¹¤ÇÊý¸þ¤ò»Ø¼¨¤¹¤ë¡£Ì¤¼ÂÁõ¡£ */
563     MCODING_ISO_ISO6429 =               0x1000,
564
565     /***en
566         On encoding, if a charset has revision number, produce escape
567         sequences to specify the number.  */
568     /***ja
569         ¥¨¥ó¥³¡¼¥É¤ÎºÝ¡¢Ê¸»ú¥»¥Ã¥È¤Ë revision number 
570         ¤¬¤¢¤ì¤Ð¤½¤ì¤òɽ¤ï¤¹¥¨¥¹¥±¡¼¥×¥·¡¼¥¯¥¨¥ó¥¹¤òÀ¸À®¤¹¤ë¡£        */
571     MCODING_ISO_REVISION_NUMBER =       0x2000,
572
573     /***en
574         Support all ISO-2022 charsets.  */
575     /***ja
576         ISO-2022 ¤ÎÁ´Ê¸»ú½¸¹ç¤ò¥µ¥Ý¡¼¥È¤¹¤ë¡£  */
577     MCODING_ISO_FULL_SUPPORT =          0x3000,
578
579     MCODING_ISO_FLAG_MAX
580   };
581 /*=*/
582
583 /*** @ingroup m17nConv */
584 /***en
585     @brief Structure for a coding system of type #MCODING_TYPE_ISO_2022.
586
587     Structure for extra information about a coding system of type
588     MCODING_TYPE_ISO_2022.  */
589
590 /***ja 
591     @brief #MCODING_TYPE_ISO_2022 ¥¿¥¤¥×¤Î¥³¡¼¥É·Ï¤ÇɬÍפÊÉղþðÊóÍѹ½Â¤ÂÎ.
592
593     MCODING_TYPE_ISO_2022 ¥¿¥¤¥×¤Î¥³¡¼¥É·Ï¤ÇɬÍפÊÉղþðÊóÍѤòÊÝ»ý¤¹¤ë¤¿¤á¤Î¹½Â¤ÂΡ£
594
595     @latexonly \IPAlabel{MCodingInfoISO2022} @endlatexonly  */
596
597 typedef struct
598 {
599   /***en
600       Table of numbers of an ISO2022 code extension element invoked
601       to each graphic plane (Graphic Left and Graphic Right).  -1
602       means no code extension element is invoked to that plane.  */
603
604   /***ja
605       ³Æ¿Þ·Áʸ»úÎΰè (Graphic Left ¤È Graphic Right) ¤Ë¸Æ¤Ó½Ð¤µ¤ì¤Æ¤¤¤ë¡¢
606       ISO2022 Éä¹ç³ÈÄ¥Í×ÁǤÎÈÖ¹æ¤Î¥Æ¡¼¥Ö¥ë¡£-1 
607       ¤Ï¤½¤ÎÎΰè¤Ë¤É¤ÎÉä¹ç³ÈÄ¥Í×ÁǤâ¸Æ¤Ó½Ð¤µ¤ì¤Æ¤¤¤Ê¤¤¤³¤È¤ò¼¨¤¹¡£   */
608
609   int initial_invocation[2];
610
611   /***en
612       Table of code extension elements.  The Nth element corresponds
613       to the Nth charset in $CHARSET_NAMES, which is an argument given
614       to the mconv_define_coding () function.
615
616       If an element value is 0..3, it specifies a graphic register
617       number to designate the corresponds charset.  In addition, the
618       charset is initially designated to that graphic register.
619
620       If the value is -4..-1, it specifies a graphic register number
621       0..3 respectively to designate the corresponds charset.
622       Initially, the charset is not designated to any graphic
623       register.  */
624
625   /***ja
626       Éä¹ç³ÈÄ¥Í×ÁǤΥơ¼¥Ö¥ë¡£NÈÖÌܤÎÍ×ÁǤϡ¢$CHARSET_NAMES ¤Î N 
627       ÈÖÌܤÎʸ»ú¥»¥Ã¥È¤ËÂбþ¤¹¤ë¡£$CHARSET_NAMES ¤Ï´Ø¿ô 
628       mconv_define_coding () ¤Î°ú¿ô¤È¤Ê¤ë¡£
629
630       Ãͤ¬ 0..3 ¤À¤Ã¤¿¤é¡¢Âбþ¤¹¤ëʸ»ú¥»¥Ã¥È¤ò G0..G3 
631       ¤Î¤½¤ì¤¾¤ì¤Ë»Ø¼¨¤¹¤ë¤³¤È¡¢¤Þ¤¿½é´ü¾õÂ֤Ǥ¹¤Ç¤Ë G0..G3
632       ¤Ë»Ø¼¨¤µ¤ì¤Æ¤¤¤ë¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
633
634       Ãͤ¬ -4..-1 ¤À¤Ã¤¿¤é¡¢Âбþ¤¹¤ëʸ»ú¥»¥Ã¥È¤ò G0..G3 
635       ¤Î¤½¤ì¤¾¤ì¤Ë»Ø¼¨¤¹¤ë¤³¤È¡¢¤·¤«¤·½é´ü¾õÂ֤ǤϤɤ³¤Ë¤â»Ø¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
636         */
637
638   char designations[32];
639
640   /***en
641       Bitwise OR of @c enum @c MCodingFlagISO2022 .  */
642
643   /***ja
644       @c enum @c MCodingFlagISO2022 ¤Î¥Ó¥Ã¥Èñ°Ì¤Ç¤ÎÏÀÍý OR  */
645
646   unsigned flags;
647
648 } MCodingInfoISO2022;
649 /*=*/
650
651 /*** @ingroup m17nConv */
652 /***en
653     @brief Structure for extra information about a coding system of type #MCODING_TYPE_UTF.
654     */
655
656 /***ja
657     @brief #MCODING_TYPE_UTF ¥¿¥¤¥×¤Î¥³¡¼¥É·Ï¤ÇɬÍפÊÉղþðÊóÍѤι½Â¤ÂÎ.
658
659     @latexonly \IPApage{MCodingInfoUTF} @endlatexonly
660
661     @latexonly \IPAlabel{MCodingInfoUTF} @endlatexonly  */
662
663 typedef struct
664 {
665   /***en
666       Specify bits of a code unit.  The value must be 8, 16, or 32.  */
667   /***ja
668       ¥³¡¼¥ÉĹ¡Ê¥Ó¥Ã¥È¿ô¡Ë¤Î»ØÄê¡£ÃͤϠ8, 16, 32 ¤Î¤¤¤º¤ì¤«¡£  */
669   int code_unit_bits;
670
671   /***en
672       Specify how to handle the heading BOM (byte order mark).  The
673       value must be 0, 1, or 2.  The meanings are as follows:
674
675       0: On decoding, check the first two byte.  If they are BOM,
676       decide endian by them. If not, decide endian by the member @c
677       endian.  On encoding, produce byte sequence according to
678       @c endian with heading BOM.
679
680       1: On decoding, do not handle the first two bytes as BOM, and
681       decide endian by @c endian.  On encoding, produce byte sequence
682       according to @c endian without BOM.
683
684       2: On decoding, handle the first two bytes as BOM and decide
685       ending by them.  On encoding, produce byte sequence according to
686       @c endian with heading BOM.
687
688       If <code_unit_bits> is 8, the value has no meaning.  */
689
690   /***ja
691       ÀèƬ¤Î BOM (¥Ð¥¤¥È¥ª¡¼¥À¡¼¥Þ¡¼¥¯) ¤Î¼è¤ê°·¤¤¤ò»ØÄꤹ¤ë¡£ÃͤϠ0,
692       1, 2 ¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ê¡¢¤½¤ì¤¾¤ì¤Î°ÕÌ£¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ë¡£
693
694       0: ¥Ç¥³¡¼¥É¤ÎºÝ¤ËºÇ½é¤Î 2 ¥Ð¥¤¥È¤òÄ´¤Ù¤ë¡£¤â¤·¤½¤ì¤¬ BOM 
695       ¤Ç¤¢¤ì¤Ð¡¢¥¨¥ó¥Ç¥£¥¢¥ó¤ò¤½¤ì¤ÇȽÄꤹ¤ë¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢¥á¥ó¥Ð @c
696       endian ¤Ë½¾¤Ã¤Æ¥¨¥ó¥Ç¥£¥¢¥ó¤ò·èÄꤹ¤ë¡£¥¨¥ó¥³¡¼¥É¤ÎºÝ¤Ë¤Ï @c
697       endian ¤Ë½¾¤Ã¤¿¥Ð¥¤¥ÈÎó¤òÀèƬ¤Ë BOM ÉÕ¤ÇÀ¸À®¤¹¤ë¡£
698
699       1: ¥Ç¥³¡¼¥É¤ÎºÝ¡¢ºÇ½é¤Î 2 ¥Ð¥¤¥È¤ò BOM ¤È¤·¤Æ°·¤ï¤º¡¢¥¨¥ó¥Ç¥£¥¢¥ó¤Ï
700       @c endian ¤ÇȽÄꤹ¤ë¡£¥¨¥ó¥³¡¼¥É¤ÎºÝ¤Ë¤Ï¡¢BOM ¤ò½ÐÎϤ»¤º¡¢
701       @c endian ¤Ë±þ¤¸¤¿¥Ð¥¤¥ÈÎó¤òÀ¸À®¤¹¤ë¡£
702
703       2: ¥Ç¥³¡¼¥É¤ÎºÝ¤ËºÇ½é¤Î2¥Ð¥¤¥È¤ò BOM¤È¤·¤Æ°·¤¤¡¢¤½¤ì¤Ë½¾¤Ã¤Æ¥¨¥ó¥Ç¥£¥¢¥ó¤òȽÄꤹ¤ë¡£
704       ¥¨¥ó¥³¡¼¥É¤ÎºÝ¤Ë¤Ï @c endian ¤Ë±þ¤¸¤¿¥Ð¥¤¥ÈÎó¤òÀèƬ¤Ë BOM ÉÕ¤­¤ÇÀ¸À®¤¹¤ë¡£  */
705   int bom;
706
707   /***en
708       Specify the endian type.  The value must be 0 or 1.  0 means
709       little endian, and 1 means big endian.
710
711       If <code_unit_bits> is 8, the value has no meaning.  */
712   /***ja
713       ¥¨¥ó¥Ç¥£¥¢¥ó¤Î¥¿¥¤¥×¤ò»ØÄꤹ¤ë¡£ÃͤϠ0 ¤« 1 ¤Ç¤¢¤ê¡¢0 
714       ¤Ê¤é¤Ð¥ê¥È¥ë¥¨¥ó¥Ç¥£¥¢¥ó¡¢1 ¤Ê¤é¤Ð¥Ó¥Ã¥°¥¨¥ó¥Ç¥£¥¢¥ó¤Ç¤¢¤ë¡£
715
716       <code_unit_bits> ¤¬ 8 ¤Î¾ì¹ç¤Ë¤Ï¡¢¤³¤ÎÃͤϰÕÌ£¤ò»ý¤¿¤Ê¤¤¡£
717   */
718   int endian;
719 } MCodingInfoUTF;
720 /*=*/
721
722 extern MSymbol mconv_define_coding (const char *name, MPlist *plist,
723                                     int (*resetter) (MConverter *),
724                                     int (*decoder) (const unsigned char *, int,
725                                                     MText *, MConverter *),
726                                     int (*encoder) (MText *, int, int,
727                                                     unsigned char *, int,
728                                                     MConverter *),
729                                     void *extra_info);
730
731 extern MSymbol mconv_resolve_coding (MSymbol symbol);
732
733 extern int mconv_list_codings (MSymbol **symbols);
734
735 extern MConverter *mconv_buffer_converter (MSymbol coding,
736                                            const unsigned char *buf,
737                                            int n);
738
739 extern MConverter *mconv_stream_converter (MSymbol coding, FILE *fp);
740
741 extern int mconv_reset_converter (MConverter *converter);
742
743 extern void mconv_free_converter (MConverter *converter);
744
745 extern MConverter *mconv_rebind_buffer (MConverter *converter,
746                                         const unsigned char *buf, int n);
747
748 extern MConverter *mconv_rebind_stream (MConverter *converter, FILE *fp);
749
750 extern MText *mconv_decode (MConverter *converter, MText *mt);
751
752 MText *mconv_decode_buffer (MSymbol name, const unsigned char *buf, int n);
753
754 MText *mconv_decode_stream (MSymbol name, FILE *fp);   
755
756 extern int mconv_encode (MConverter *converter, MText *mt);
757
758 extern int mconv_encode_range (MConverter *converter, MText *mt,
759                                int from, int to);
760
761 extern int mconv_encode_buffer (MSymbol name, MText *mt,
762                                 unsigned char *buf, int n);
763
764 extern int mconv_encode_stream (MSymbol name, MText *mt, FILE *fp);
765
766 extern int mconv_getc (MConverter *converter);
767
768 extern int mconv_ungetc (MConverter *converter, int c);
769
770 extern int mconv_putc (MConverter *converter, int c);
771
772 extern MText *mconv_gets (MConverter *converter, MText *mt);
773
774 /* (S4) Locale related functions corresponding to libc functions */
775 /*=*/
776 /*** @ingroup m17nShell */
777 /***en @defgroup m17nLocale Locale */
778 /***ja @defgroup m17nLocale ¥í¥±¡¼¥ë */
779 /*=*/
780
781 /*** @ingroup m17nLocale */
782 /***en
783     @brief @c struct @c MLocale.
784
785     The structure @c MLocale is used to hold information about name,
786     language, territory, modifier, codeset, and the corresponding
787     coding system of locales.
788
789     The contents of this structure are implementation dependent.  Its
790     internal structure is concealed from application programs.  */
791
792 /***ja
793     @brief @c MLocale ¹½Â¤ÂÎ.
794
795     @c MLocale ¹½Â¤ÂΤϡ¢¥í¥±¡¼¥ë¤Î̾Á°¡¢¸À¸ì¡¢ÃÏ°è¡¢¥â¥Ç¥£¥Õ¥¡¥¤¥¢¡¢¥³¡¼¥É¥»¥Ã¥È¡¢¤ª¤è¤ÓÂбþ¤¹¤ë¥³¡¼¥É·Ï¤Ë´Ø¤¹¤ë¾ðÊó¤òÊÝ»ý¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£
796
797     ¤³¤Î¹½Â¤ÂΤÎÆâÍƤϼÂÁõ¤Ë°Í¸¤¹¤ë¡£ 
798     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
799
800 /***
801     @seealso
802     mlocale_get_prop () */
803
804 typedef struct MLocale MLocale;
805
806 /*=*/
807
808 extern MSymbol Miso639_1, Miso639_2;
809 extern MSymbol Mterritory;
810 extern MSymbol Mmodifier;
811 extern MSymbol Mcodeset;
812
813 extern MPlist *mlanguage_list (void);
814
815 extern MSymbol mlanguage_code (MSymbol language, int len);
816
817 extern MPlist *mlanguage_name_list (MSymbol language, MSymbol target,
818                                     MSymbol script, MSymbol territory);
819
820 extern MText *mlanguage_text (MSymbol language);
821
822 extern MPlist *mscript_list (void);
823
824 extern MPlist *mscript_language_list (MSymbol script);
825
826 extern MSymbol mlanguage_name (MSymbol language);
827
828 extern MLocale *mlocale_set (int category, const char *locale);
829
830 extern MSymbol mlocale_get_prop (MLocale *locale, MSymbol key);
831
832 extern int mtext_ftime (MText *mt, const char *format, const struct tm *tm,
833                         MLocale *locale);
834
835 extern MText *mtext_getenv (const char *name);
836
837 extern int mtext_putenv (MText *mt);
838
839 extern int mtext_coll (MText *mt1, MText *mt2);
840
841 /*
842  *  (9) Miscellaneous functions of libc level (not yet implemented)
843  */
844
845 /*
846 extern int mtext_width (MText *mt, int n);
847 extern MText *mtext_tolower (MText *mt);
848 extern MText *mtext_toupper (MText *mt);
849 */
850
851 /*
852  *  (10) Input method
853  */
854 /*=*/
855 /*** @ingroup m17nShell */
856 /***en @defgroup m17nInputMethod Input Method (basic) */
857 /***ja @defgroup m17nInputMethod ÆþÎϥ᥽¥Ã¥É (´ðËÜÉôʬ) */
858 /*=*/
859
860 /*** @addtogroup m17nInputMethod 
861      @{ */
862
863 /* Struct forward declaration.  */
864 typedef struct MInputMethod MInputMethod;
865 typedef struct MInputContext MInputContext;
866
867 /***en
868     @brief Type of input method callback functions.
869
870     This is the type of callback functions called from input method
871     drivers.  #IC is a pointer to an input context, #COMMAND is a name
872     of callback for which the function is called.   */
873 /***ja
874     @brief ÆþÎϥ᥽¥Ã¥É¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤Î·¿Àë¸À.
875
876     ÆþÎϥ᥽¥Ã¥É¤«¤é¸Æ¤Ð¤ì¤ë¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤Î·¿¤Ç¤¢¤ë¡£#IC 
877     ¤ÏÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¡¢#COMMAND ¤Ï´Ø¿ô¤¬¸Æ¤Ð¤ì¤ë¥³¡¼¥ë¥Ð¥Ã¥¯¤Î̾Á°¤Ç¤¢¤ë¡£  */
878
879 typedef void (*MInputCallbackFunc) (MInputContext *ic, MSymbol command);
880 /*=*/
881
882 /***en
883     @brief Structure of input method driver.
884
885     The type @c MInputDriver is the structure of an input method driver that
886     contains several functions to handle an input method.  */
887
888 /***ja
889     @brief ÆþÎϥɥ饤¥ÐÍѹ½Â¤ÂÎ.
890
891     @c MInputDriver ¤Ï¡¢ÆþÎϥ᥽¥Ã¥É¤ò¼è¤ê°·¤¦´Ø¿ô¤ò´Þ¤àÆþÎϥ᥽¥Ã¥É¥É¥é¥¤¥Ð¤Î¹½Â¤ÂΤη¿¤Ç¤¢¤ë¡£  */
892
893 typedef struct MInputDriver
894 {
895   /***en
896       @brief Open an input method.
897
898       This function opens the input method $IM.  It is called from the
899       function minput_open_im () after all member of $IM but <info>
900       set.  If opening $IM succeeds, it returns 0.  Otherwise, it
901       returns -1.  The function can setup $IM->info to keep various
902       information that is referred by the other driver functions.  */
903
904   /***ja
905       @brief ÆþÎϥ᥽¥Ã¥É¤ò¥ª¡¼¥×¥ó¤¹¤ë.
906
907       ¤³¤Î´Ø¿ô¤Ï¡¢ÆþÎϥ᥽¥Ã¥É $IM ¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£$IM ¤Î <info> 
908       °Ê³°¤ÎÁ´¥á¥ó¥Ð¡¼¤¬¥»¥Ã¥È¤µ¤ì¤¿¸å¤Ç¡¢´Ø¿ô minput_open_im () 
909       ¤«¤é¸Æ¤Ð¤ì¤ë¡£$IM ¤ò¥ª¡¼¥×¥ó¤Ç¤­¤ì¤Ð 0 ¤ò¡¢¤Ç¤­¤Ê¤±¤ì¤Ð -1¤òÊÖ¤¹¡£
910       ¤³¤Î´Ø¿ô¤Ï $IM->info 
911       ¤òÀßÄꤷ¤Æ¡¢Â¾¤Î¥É¥é¥¤¥Ð´Ø¿ô¤«¤é»²¾È¤µ¤ì¤ë¾ðÊó¤òÊÝ»ý¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
912       */
913
914   int (*open_im) (MInputMethod *im);
915
916   /***en
917       @brief Close an input method.
918
919       This function closes the input method $IM.  It is called from
920       the function minput_close_im ().  It frees all memory allocated
921       for $IM->info (if any) after finishing all the tasks of closing
922       the input method.  But, the other members of $IM should not be
923       touched.  */
924
925   /***ja
926       @brief ÆþÎϥ᥽¥Ã¥É¤ò¥¯¥í¡¼¥º¤¹¤ë.
927
928       ¤³¤Î´Ø¿ô¤Ï¡¢ÆþÎϥ᥽¥Ã¥É $IM ¤ò¥¯¥í¡¼¥º¤¹¤ë¡£´Ø¿ô 
929       minput_close_im () ¤«¤é¸Æ¤Ð¤ì¤ë¡£
930       ÆþÎϥ᥽¥Ã¥É¤Î¥¯¥í¡¼¥º¤¬¤¹¤Ù¤Æ½ªÎ»¤·¤¿»þÅÀ¤Ç¡¢¤³¤Î´Ø¿ô¤Ï$IM->info 
931       ¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¥á¥â¥ê¤ò(¤¢¤ì¤Ð)¤¹¤Ù¤Æ³«Êü¤¹¤ë¡£
932       ¤¿¤À¤·¡¢$IM ¤Î¾¤Î¥á¥ó¥Ð¤Ë±Æ¶Á¤òÍ¿¤¨¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
933         */
934
935   void (*close_im) (MInputMethod *im);
936
937   /***en
938       @brief Create an input context.
939
940       This function creates the input context $IC.  It is called from
941       the function minput_create_ic () after all members of $IC but
942       <info> are set.  If creating $IC succeeds, it returns 0.
943       Otherwise, it returns -1.  The function can setup $IC->info to
944       keep various information that is referred by the other driver
945       functions.  */
946
947   /***ja
948       @brief ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¤òÀ¸À®¤¹¤ë.
949
950       ¤³¤Î´Ø¿ô¤ÏÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È $IC ¤òÀ¸À®¤¹¤ë¡£
951       $IC ¤Î <info> °Ê³°¤ÎÁ´¥á¥ó¥Ð¡¼¤¬¥»¥Ã¥È¤µ¤ì¤¿¸å¤Ç¡¢´Ø¿ô
952       minput_create_ic () ¤«¤é¸Æ¤Ð¤ì¤ë¡£
953       $IC ¤òÀ¸À®¤Ç¤­¤ì¤Ð 0 ¤ò¡¢¤Ç¤­¤Ê¤±¤ì¤Ð -1 ¤òÊÖ¤¹¡£
954       ¤³¤Î´Ø¿ô¤Ï $IC->info ¤òÀßÄꤷ¤Æ¡¢Â¾¤Î¥É¥é¥¤¥Ð´Ø¿ô¤«¤é»²¾È¤µ¤ì¤ë¾ðÊó¤òÊÝ»ý¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£  */
955
956
957   int (*create_ic) (MInputContext *ic);
958
959   /***en
960       @brief Destroy an input context.
961
962       This function is called from the function minput_destroy_ic ()
963       and destroys the input context $IC.  It frees all memory
964       allocated for $IC->info (if any) after finishing all the tasks
965       of destroying the input method.  But, the other members of $IC
966       should not be touched.  */
967
968   /***ja
969       @brief ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¤òÇ˲õ¤¹¤ë.
970
971       ´Ø¿ô minput_destroy_ic () ¤«¤é¸Æ¤Ð¤ì¡¢ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È $IC 
972       ¤òÇ˲õ¤¹¤ë¡£ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¤ÎÇ˲õ¤¬¤¹¤Ù¤Æ½ªÎ»¤·¤¿»þÅÀ¤Ç¡¢$IC->info 
973       ¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¥á¥â¥ê¤ò(¤¢¤ì¤Ð)¤¹¤Ù¤Æ³«Êü¤¹¤ë¡£¤¿¤À¤·¡¢$IC 
974       ¤Î¾¤Î¥á¥ó¥Ð¤Ë±Æ¶Á¤òÍ¿¤¨¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£  */
975
976   void (*destroy_ic) (MInputContext *ic);
977
978   /***en
979       @brief Filter an input key.
980
981       This function is called from the function minput_filter () and
982       filters an input key.  $KEY and $ARG are the same as what given
983       to minput_filter ().
984
985       The task of the function is to handle $KEY, update the internal
986       state of $IC.  If $KEY is absorbed by the input method and no
987       text is produced, it returns 1.  Otherwise, it returns 0.
988
989       It may update $IC->status, $IC->preedit, $IC->cursor_pos,
990       $IC->ncandidates, $IC->candidates, and $IC->produced if that is
991       necessary for the member <callback>.
992
993       The meaning of $ARG depends on the input method river.  See the
994       documentation of @c minput_default_driver and @c
995       minput_gui_driver for instance.  */
996
997   /***ja
998       @brief ÆþÎÏ¥­¡¼¤ò¥Õ¥£¥ë¥¿¤¹¤ë.
999
1000       ´Ø¿ô minput_filter () ¤«¤é¸Æ¤Ð¤ì¡¢ÆþÎÏ¥­¡¼¤ò¥Õ¥£¥ë¥¿¤¹¤ë¡£°ú¿ô 
1001       $KEY, $ARG ¤Ï´Ø¿ô minput_filter () ¤Î¤â¤Î¤ÈƱ¤¸¡£
1002
1003       ¤³¤Î´Ø¿ô¤Ï $KEY ¤ò½èÍý¤·¡¢$IC ¤ÎÆâÉô¾õÂÖ¤ò¹¹¿·¤¹¤ë¡£ $KEY 
1004       ¤¬ÆþÎϥ᥽¥Ã¥É¤ËµÛ¼ý¤µ¤ì¤Æ¥Æ¥­¥¹¥È¤¬À¸À®¤µ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢ 
1005       1 ¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð 0 ¤òÊÖ¤¹¡£
1006
1007       ¥á¥ó¥Ð <callback> ¤ËɬÍפǤ¢¤ì¤Ð¡¢$IC->status, $IC->preedit,
1008       $IC->cursor_pos, $IC->ncandidates, $IC->candidates,
1009       $IC->produced ¤ò¹¹¿·¤Ç¤­¤ë¡£
1010
1011       $ARG ¤Î°ÕÌ£¤ÏÆþÎϥ᥽¥Ã¥É¥É¥é¥¤¥Ð¤Ë°Í¸¤¹¤ë¡£Îã¤Ï @c
1012       minput_default_driver ¤Þ¤¿¤Ï @c minput_gui_driver 
1013       ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£ */
1014
1015   int (*filter) (MInputContext *ic, MSymbol key, void *arg);
1016
1017   /***en
1018       @brief  Lookup a produced text in an input context.
1019
1020       It is called from the function minput_lookup () and looks up a
1021       produced text in the input context $IC.  This function
1022       concatenate a text produced by the input key $KEY (if any) to
1023       M-text $MT.  If $KEY was correctly handled by the input method
1024       of $IC, it returns 0.  Otherwise, it returns 1.
1025
1026       The meaning of $ARG depends on the input method driver.  See the
1027       documentation of @c minput_default_driver and @c
1028       minput_gui_driver for instance.  */
1029
1030   /***ja
1031       @brief ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¤ÇÀ¸À®¤µ¤ì¤ë¥Æ¥­¥¹¥È¤Î³ÍÆÀ.
1032
1033       ´Ø¿ô minput_lookup () ¤«¤é¸Æ¤Ð¤ì¡¢ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È $IC 
1034       ¤ÇÀ¸À®¤µ¤ì¤ë¥Æ¥­¥¹¥È¤ò¸¡º÷¤¹¤ë¡£ÆþÎÏ¥­¡¼ $KEY 
1035       ¤Ë¤è¤Ã¤ÆÀ¸À®¤µ¤ì¤ë¥Æ¥­¥¹¥È¤¬¤¢¤ì¤Ð¡¢M-text $MT ¤ËÄɲ乤롣 $KEY
1036       ¤¬ÆþÎϥ᥽¥Ã¥É $IC ¤Ë¤è¤Ã¤ÆÀµ¤·¤¯½èÍý¤µ¤ì¤ì¤Ð 0 ¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð 1 ¤òÊÖ¤¹¡£
1037
1038       $ARG ¤Î°ÕÌ£¤ÏÆþÎϥ᥽¥Ã¥É¥É¥é¥¤¥Ð¤Ë°Í¸¤¹¤ë¡£Îã¤Ï @c
1039       minput_default_driver ¤Þ¤¿¤Ï @c minput_gui_driver ¤ÎÀâÌÀ¤ò»²¾È¤Î
1040       ¤³¤È¡£ */
1041
1042   int (*lookup) (MInputContext *ic, MSymbol key, void *arg, MText *mt);
1043
1044   /***en
1045       @brief List of callback functions.
1046
1047       List of callback functions.  Keys are one of
1048       #Minput_preedit_start, #Minput_preedit_draw,
1049       #Minput_preedit_done, #Minput_status_start, #Minput_status_draw,
1050       #Minput_status_done, #Minput_candidates_start,
1051       #Minput_candidates_draw, #Minput_candidates_done,
1052       #Minput_set_spot, #Minput_toggle, #Minput_reset,
1053       #Minput_get_surrounding_text, #Minput_delete_surrounding_text.
1054       Values are functions of type #MInputCallbackFunc.  */
1055   /***ja
1056       @brief ¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤Î¥ê¥¹¥È.
1057
1058       ¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤Î¥ê¥¹¥È¡£¥­¡¼¤Ï¼¡¤Î¤¤¤º¤ì¤«¡£
1059       #Minput_preedit_start, #Minput_preedit_draw,
1060       #Minput_preedit_done, #Minput_status_start, #Minput_status_draw,
1061       #Minput_status_done, #Minput_candidates_start,
1062       #Minput_candidates_draw, #Minput_candidates_done,
1063       #Minput_set_spot, #Minput_toggle, #Minput_reset,
1064       #Minput_get_surrounding_text, #Minput_delete_surrounding_text¡£
1065       ÃͤÏ#MInputCallbackFunc ·¿¤Î´Ø¿ô¡£  */
1066   MPlist *callback_list;
1067
1068 } MInputDriver;
1069 /*=*/
1070
1071 extern MInputDriver minput_default_driver;
1072
1073 extern MSymbol Minput_driver;
1074
1075 extern MInputDriver *minput_driver;
1076
1077 /** Symbols for callback commands.  */
1078 extern MSymbol Minput_preedit_start;
1079 extern MSymbol Minput_preedit_draw;
1080 extern MSymbol Minput_preedit_done;
1081 extern MSymbol Minput_status_start;
1082 extern MSymbol Minput_status_draw;
1083 extern MSymbol Minput_status_done;
1084 extern MSymbol Minput_candidates_start;
1085 extern MSymbol Minput_candidates_draw;
1086 extern MSymbol Minput_candidates_done;
1087 extern MSymbol Minput_set_spot;
1088 extern MSymbol Minput_toggle;
1089 extern MSymbol Minput_reset;
1090 extern MSymbol Minput_get_surrounding_text;
1091 extern MSymbol Minput_delete_surrounding_text;
1092
1093 /** Symbols for special input key event.  */
1094 extern MSymbol Minput_focus_move;
1095 extern MSymbol Minput_focus_in;
1096 extern MSymbol Minput_focus_out;
1097
1098 /** Symbols describing input method command/variable.  */
1099 extern MSymbol Minherited;
1100 extern MSymbol Mcustomized;
1101 extern MSymbol Mconfigured;
1102
1103 /***en
1104     @brief Structure of input method.
1105
1106     The type @c MInputMethod is the structure of input method
1107     objects.  */
1108 /***ja
1109     @brief ÆþÎϥ᥽¥Ã¥É¤Î¹½Â¤ÂÎ.
1110
1111     @c MInputMethod ¤Ï¡¢ÆþÎϥ᥽¥Ã¥É¥ª¥Ö¥¸¥§¥¯¥ÈÍѤι½Â¤ÂΤη¿¤Ç¤¢¤ë¡£  */
1112
1113 struct MInputMethod
1114 {
1115   /***en Which language this input method is for.  The value is @c
1116       Mnil if the input method is foreign.  */
1117   /***ja ¤É¤Î¸À¸ìÍѤÎÆþÎϥ᥽¥Ã¥É¤«¡£
1118       ÆþÎϥ᥽¥Ã¥É¤¬³°Éô¤Î¤â¤Î¤Ç¤¢¤ë¾ì¹ç¤ÎÃͤϠ@c Mnil ¡£  */
1119   MSymbol language;
1120
1121   /***en Name of the input method.  If the input method is foreign, it
1122       must has a property of key @c Minput_driver and the value must be a
1123       pointer to a proper input method driver.  */
1124   /***ja ÆþÎϥ᥽¥Ã¥É¤Î̾Á°¡£³°Éô¥á¥½¥Ã¥É¤Ç¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢@c
1125       Minput_driver ¤ò¥­¡¼¤È¤¹¤ë¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Á¡¢¤½¤ÎÃͤÏŬÀÚ¤ÊÆþÎϥ᥽¥Ã¥É¥É¥é¥¤¥Ð¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£*/
1126   MSymbol name;
1127
1128   /***en Input method driver of the input method.  */
1129   /***ja ¤½¤ÎÆþÎϥ᥽¥Ã¥ÉÍѤÎÆþÎϥ᥽¥Ã¥É¥É¥é¥¤¥Ð¡£  */
1130   MInputDriver driver;
1131
1132   /***en The argument given to minput_open_im (). */
1133   /***ja minput_open_im () ¤ËÅϤµ¤ì¤ë°ú¿ô¡£  */
1134   void *arg;
1135
1136   /***en Pointer to extra information that <driver>.open_im ()
1137       setups. */
1138   /***ja <driver>.open_im () ¤¬ÀßÄꤹ¤ëÄɲþðÊó¤Ø¤Î¥Ý¥¤¥ó¥¿¡£ */
1139   void *info;
1140 };
1141
1142 /*=*/
1143
1144 /***en
1145     @brief Bit-masks to specify how candidates of input method is changed.  */
1146
1147 /***ja
1148     @brief ÆþÎϥ᥽¥Ã¥É¤ÎÆþÎϸõÊ䤬¤É¤¦Êѹ¹¤µ¤ì¤¿¤«¤ò¼¨¤¹¥Ó¥Ã¥È¥Þ¥¹¥¯.  */
1149
1150 enum MInputCandidatesChanged
1151   {
1152     MINPUT_CANDIDATES_LIST_CHANGED = 1,
1153     MINPUT_CANDIDATES_INDEX_CHANGED = 2,
1154     MINPUT_CANDIDATES_SHOW_CHANGED = 4,
1155     MINPUT_CANDIDATES_CHANGED_MAX
1156   };
1157
1158
1159 /*=*/
1160
1161 /***en
1162     @brief Structure of input context.
1163
1164     The type @c MInputContext is the structure of input context
1165     objects.  */
1166
1167 /***ja
1168     @brief ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥ÈÍѹ½Â¤ÂÎ.
1169
1170     @c MInputContext ¤Ï¡¢ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¥ª¥Ö¥¸¥§¥¯¥ÈÍѤι½Â¤ÂΤη¿¤Ç¤¢¤ë¡£  */
1171
1172 struct MInputContext
1173 {
1174   /***en Backward pointer to the input method.  It is set up be the
1175       function minput_create_ic ().  */
1176   /***ja ÆþÎϥ᥽¥Ã¥É¤Ø¤ÎµÕ¥Ý¥¤¥ó¥¿¡£´Ø¿ô minput_create_ic () 
1177       ¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤ë¡£  */ 
1178   MInputMethod *im;
1179
1180   /***en M-text produced by the input method.  It is set up by the
1181       function minput_lookup () .  */
1182   /***ja ÆþÎϥ᥽¥Ã¥É¤Ë¤è¤Ã¤ÆÀ¸À®¤µ¤ì¤ë M-text¡£´Ø¿ô minput_lookup () 
1183       ¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤ë¡£  */
1184   MText *produced;
1185
1186   /***en Argument given to the function minput_create_im (). */
1187   /***ja ´Ø¿ô minput_create_ic () ¤ËÅϤµ¤ì¤ë°ú¿ô¡£ */
1188   void *arg;
1189
1190   /***en Flag telling whether the input context is currently active or
1191       inactive.  The value is set to 1 (active) when the input context
1192       is created.  It is toggled by the function minput_toggle ().  */
1193   /***ja ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¤¬¥¢¥¯¥Æ¥£¥Ö¤«¤É¤¦¤«¤ò¼¨¤¹¥Õ¥é¥°¡£
1194       ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¤¬À¸À®¤µ¤ì¤¿»þÅÀ¤Ç¤ÏÃͤϠ1 ¡Ê¥¢¥¯¥Æ¥£¥Ö¡Ë¤Ç¤¢¤ê¡¢´Ø¿ô 
1195       minput_toggle () ¤Ë¤è¤Ã¤Æ¥È¥°¥ë¤µ¤ì¤ë¡£  */
1196   int active;
1197
1198   /***en Spot location and size of the input context.  */
1199   /***ja ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¤Î¥¹¥Ý¥Ã¥È¤Î°ÌÃÖ¤ÈÂ礭¤µ.  */
1200   struct {
1201     /***en X and Y coordinate of the spot.  */
1202     /***ja ¥¹¥Ý¥Ã¥È¤Î X, Y ºÂɸ.  */
1203     int x, y;
1204
1205     /***en Ascent and descent pixels of the line of the spot.  */
1206     /***ja ¥¹¥Ý¥Ã¥È¤Î¥¢¥»¥ó¥È¤È¥Ç¥£¥»¥ó¥È¤Î¥Ô¥¯¥»¥ë¿ô.  */
1207     int ascent, descent;
1208
1209     /***en Font size for preedit text in 1/10 point.  */
1210     /***ja preedit ¥Æ¥­¥¹¥ÈÍѤΥե©¥ó¥È¥µ¥¤¥º (1/10 ¥Ý¥¤¥ó¥Èñ°Ì).  */
1211     int fontsize;
1212
1213     /***en M-text at the spot, or NULL.  */
1214     /***ja ¥¹¥Ý¥Ã¥È¾å¤Î M-text¡¢¤Þ¤¿¤Ï NULL.  */
1215     MText *mt;
1216
1217     /***en Character position in <mt> at the spot.  */
1218     /***ja <mt> ¤Ë¤ª¤±¤ë¥¹¥Ý¥Ã¥È¤Îʸ»ú°ÌÃÖ.  */
1219     int pos;
1220   } spot;
1221
1222   /***en The usage of the following members depends on the input
1223       method driver.  The descriptions below are for the driver of an
1224       internal input method.  They are set by the function
1225       <im>->driver.filter ().  */
1226   /***ja °Ê²¼¤Î¥á¥ó¥Ð¤Î»ÈÍÑË¡¤ÏÆþÎϥ᥽¥Ã¥É¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ°Û¤Ê¤ë¡£
1227       °Ê²¼¤ÎÀâÌÀ¤Ï¡¢ÆâÉôÆþÎϥ᥽¥Ã¥ÉÍѤÎÆþÎϥɥ饤¥Ð¤ËÂФ¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
1228       ¤³¤ì¤é¤Ï´Ø¿ô <im>->driver.filter () ¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤ë¡£  */
1229
1230   /***en Pointer to extra information that <im>->driver.create_ic ()
1231       setups.  It is used to record the internal state of the input
1232       context.  */
1233   /***ja <im>->driver.create_ic () ¤¬ÀßÄꤹ¤ëÄɲþðÊó¤Ø¤Î¥Ý¥¤¥ó¥¿¡£
1234       ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¤ÎÆâÉô¾õÂÖ¤òµ­Ï¿¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£ */
1235   void *info;
1236
1237   /***en M-text describing the current status of the input
1238       context.  */
1239   /***ja ÆþÎÏ¥³¥ó¥Æ¥¯¥¹¥È¤Î¸½ºß¤Î¾õÂÖ¤òɽ¤¹ M-text  */
1240   MText *status;
1241
1242   /***en The function <im>->driver.filter () sets the value to 1 when
1243       it changes <status>.  */
1244   /***ja ´Ø¿ô <im>->driver.filter () ¤Ï¡¢<status> ¤òÊѤ¨¤¿ºÝ¤Ë¤³¤ÎÃͤò 1 
1245       ¤ËÀßÄꤹ¤ë¡£  */
1246   int status_changed;
1247
1248   /***en M-text containing the current preedit text.  The function
1249       <im>->driver.filter () sets the value.  */
1250   /***ja ¸½ºß¤Î preedit ¥Æ¥­¥¹¥È¤ò´Þ¤à M-text¡£´Ø¿ô 
1251       <im>->driver.filter () ¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤ë¡£  */ 
1252   MText *preedit;
1253
1254   /***en The function <im>->driver.filter () sets the value to 1 when
1255       it changes <preedit>.  */
1256   /***ja ´Ø¿ô <im>->driver.filter () ¤Ï¡¢<preedit> ¤òÊѤ¨¤¿ºÝ¤Ë¤³¤ÎÃͤò 
1257       1 ¤ËÀßÄꤹ¤ë¡£  */
1258   int preedit_changed;
1259
1260   /***en Cursor position of <preedit>.  */
1261   /***ja <preedit>¤Î¥«¡¼¥½¥ë°ÌÃÖ  */
1262   int cursor_pos;
1263
1264   /***en The function <im>->driver.filter () sets the value to 1 when
1265       it changes <cursor_pos>.  */
1266   /***ja ´Ø¿ô <im>->driver.filter () ¤Ï¡¢<cursor_pos> ¤òÊѤ¨¤¿ºÝ¤Ë¤³¤ÎÃͤò 
1267       1 ¤ËÀßÄꤹ¤ë¡£  */
1268   int cursor_pos_changed;
1269
1270   /***en Plist of the current candidate groups.  Each element is an
1271       M-text or a plist.  If an element is an M-text (i.e. the key is Mtext),
1272       candidates in that group are characters in the M-text.  If it is
1273       a plist (i.e. the key is Mplist), each element is an M-text, and
1274       candidates in that group are those M-texts.  */
1275   /***ja ¸½ºß¤Î¸õÊ䥰¥ë¡¼¥×¤Î Plist ¡£³ÆÍ×ÁǤϠM-text ¤« plist ¤Ç¤¢¤ë¡£
1276       Í×ÁǤ¬ M-text ¤Î¾ì¹ç¡Ê¥­¡¼¤¬ Mtext ¤Ç¤¢¤ë¾ì¹ç¡Ë¤Ë¤Ï¡¢¤½¤Î¥°¥ë¡¼¥×¤Î¸õÊä¤Ï¤½¤Î 
1277       M-text Ãæ¤Î³Æʸ»ú¤Ç¤¢¤ë¡£ Í×ÁǤ¬ plist ¤Î¾ì¹ç¡Ê¥­¡¼¤¬ Mplist
1278       ¤Ç¤¢¤ë¾ì¹ç¡Ë¤Ë¤Ï¡¢¤½¤Î¥ê¥¹¥È¤Î³ÆÍ×ÁǤϠM-text ¤Ç¤¢¤ê¡¢¤½¤ì¤é¤¬¤½¤Î¥°¥ë¡¼¥×¤Î¸õÊä¤È¤Ê¤ë¡£  */
1279   MPlist *candidate_list;
1280
1281   /***en Index number of the currently selected candidate in all the
1282       candidates. The index of the first candidate is 0.  If the
1283       number is 8, and the first candidate group contains 7
1284       candidates, the currently selected candidate is the second element of the
1285       second candidate group.  */
1286   /***ja ¸½ºßÁªÂò¤µ¤ì¤Æ¤¤¤ë¸õÊ䤬Á´¸õÊäÃæ¤Ç²¿ÈÖÌܤ«¤ò¤ò¼¨¤¹¥¤¥ó¥Ç¥Ã¥¯¥¹¡£
1287       ºÇ½é¤Î¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ï 0¡£ºÇ½é¤Î¸õÊ䥰¥ë¡¼¥×¤Ë¼·¤Ä¤Î¸õÊ䤬´Þ¤Þ¤ì¤Æ¤ª¤ê¡¢¤³¤ÎÃͤ¬
1288       8 ¤Ê¤é¤Ð¡¢¸½ºß¤Î¸õÊä¤ÏÆóÈÖÌܤθõÊ䥰¥ë¡¼¥×¤ÎÆóÈÖÌܤÎÍ×ÁǤȤ¤¤¦¤³¤È¤Ë¤Ê¤ë¡£
1289       */
1290   int candidate_index;
1291
1292   /***en Start and the end positions of the preedit text where
1293        <candidate_list> corresponds to.  */
1294   /***ja preedit ¥Æ¥­¥¹¥ÈÃæ¤Ç¡¢<candidate_list>¤ËÂбþ¤¹¤ëºÇ½é¤ÈºÇ¸å¤Î°ÌÃÖ¡£
1295        */
1296   int candidate_from, candidate_to;
1297
1298   /***en Flag telling whether the current candidate group must be
1299       shown or not.  The function <im>->driver.filter () sets the
1300       value to 1 when an input method required to show candidates, and
1301       sets the value to 0 otherwise.  */
1302   /***ja ¸½ºß¤Î¸õÊ䥰¥ë¡¼¥×¤òɽ¼¨¤¹¤ë¤«¤É¤¦¤«¤ò¼¨¤¹¥Õ¥é¥°¡£
1303       ´Ø¿ô <im>->driver.filter () ¤Ï¡¢ÆþÎϥ᥽¥Ã¥É¤¬¸õÊä¤Îɽ¼¨¤òÍ׵ᤷ¤¿»þ¤³¤ÎÃͤò
1304       1 ¤Ë¡¢¤½¤ì°Ê³°¤Î»þ 0 ¤ËÀßÄꤹ¤ë¡£  */
1305   int candidate_show;
1306
1307   /***en The function <im>->driver.filter () sets the value to bitwise
1308       OR of @c enum @c MInputCandidatesChanged when it changed any of
1309       the above members (<candidate_XXX>), and sets the value to 0
1310       otherwise.  */
1311   /***ja ´Ø¿ô <im>->driver.filter () ¤Ï¡¢¾åµ­¤Î¥á¥ó¥Ð <candidate_XXX>
1312       ¤Î£±¤Ä¤Ç¤âÊѹ¹¤·¤¿ºÝ¤Ë¤Ï¡¢¤³¤ÎÃͤò @c enum @c
1313       MInputCandidatesChanged ¤Î¥Ó¥Ã¥Èñ°Ì¤Ç¤ÎÏÀÍý OR ¤ËÀßÄꤹ¤ë¡£¤½¤¦
1314       ¤Ç¤Ê¤±¤ì¤Ð 0 ¤ËÀßÄꤹ¤ë¡£ */
1315   int candidates_changed;
1316
1317   /***en Plist that can be freely used by <im>->driver functions.
1318       The driver of internal input method uses it to exchange extra
1319       arguments and result for callback functions.  The function
1320       <im>->driver.create_ic () sets this to an empty plist, and the
1321       function <im>->driver.destroy_ic () frees it by using
1322       m17n_object_unref ().  */
1323   /***ja <im>->driver ¤Î´Ø¿ô·²¤Ë¤è¤Ã¤Æ¼«Í³¤Ë»ÈÍѤǤ­¤ë plist¡£
1324       ÆâÉôÆþÎϥ᥽¥Ã¥ÉÍѥɥ饤¥Ð¤Ï¤³¤ì¤ò¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤È¤Î°ú¿ô¤äÊÖÃÍ
1325       ¤Î¼õÅϤ·¤Ë»ÈÍѤ¹¤ë¡£´Ø¿ô <im>->driver.create_ic () ¤Ï¤³¤Î plist
1326       ¤ò¶õ¤ËÀßÄꤹ¤ë¡£´Ø¿ô<im>->driver.destroy_ic () ¤Ï
1327       m17n_object_unref () ¤òÍѤ¤¤Æ¤³¤Î plist ¤ò²òÊü¤¹¤ë¡£  */
1328   MPlist *plist;
1329 };
1330
1331 /*=*/
1332
1333 extern MInputMethod *minput_open_im (MSymbol language, MSymbol name,
1334                                      void *arg);
1335
1336 /*=*/
1337
1338 extern void minput_close_im (MInputMethod *im);
1339
1340 extern MInputContext *minput_create_ic (MInputMethod *im, void *arg);
1341
1342 extern void minput_destroy_ic (MInputContext *ic);
1343
1344 extern int minput_filter (MInputContext *ic, MSymbol key, void *arg);
1345
1346 extern int minput_lookup (MInputContext *ic, MSymbol key, void *arg,
1347                           MText *mt);
1348 extern void minput_set_spot (MInputContext *ic, int x, int y, int ascent,
1349                              int descent, int fontsize, MText *mt, int pos);
1350 extern void minput_toggle (MInputContext *ic);
1351
1352 extern void minput_reset_ic (MInputContext *ic);
1353
1354 extern MText *minput_get_description (MSymbol language, MSymbol name);
1355
1356 extern MPlist *minput_get_title_icon (MSymbol language, MSymbol name);
1357
1358 extern MPlist *minput_get_command (MSymbol language, MSymbol name,
1359                                    MSymbol command);
1360 extern int minput_config_command (MSymbol language, MSymbol name,
1361                                   MSymbol command, MPlist *keyseq);
1362 extern MPlist *minput_get_variable (MSymbol language, MSymbol name,
1363                                     MSymbol variable);
1364 extern int minput_config_variable (MSymbol language, MSymbol name,
1365                                    MSymbol variable, MPlist *value);
1366 extern char *minput_config_file (void);
1367
1368 extern int minput_save_config (void);
1369
1370 extern int minput_callback (MInputContext *ic, MSymbol command);
1371
1372 /* obsolete functions */
1373 extern MPlist *minput_get_commands (MSymbol language, MSymbol name);
1374
1375 extern int minput_assign_command_keys (MSymbol language, MSymbol name,
1376                                        MSymbol command, MPlist *keys);
1377 extern MPlist *minput_get_variables (MSymbol language, MSymbol name);
1378
1379 extern int minput_set_variable (MSymbol language, MSymbol name,
1380                                 MSymbol variable, void *value);
1381 /*=*/
1382 /***     @} */
1383
1384 extern MInputMethod *mdebug_dump_im (MInputMethod *im, int indent);
1385
1386
1387 M17N_END_HEADER
1388
1389 #endif /* _M17N_H_ */
1390
1391 /*
1392   Local Variables:
1393   coding: euc-japan
1394   End:
1395 */