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