*** empty log message ***
[m17n/m17n-lib.git] / src / m17n-core.c
1 /* m17n-core.c -- body of the CORE API.
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 /***en
24     @addtogroup m17nIntro
25     @brief Introduction to the m17n library.
26
27     <em>API LEVELS</em>
28
29     The API of the m17n library is divided into these four.
30
31     <ol>
32     <li> CORE API
33
34     It provides basic modules to handle M-texts.  They do not require
35     the m17n database.  To use this API, an application program must
36     include <m17n-core.h> and be linked by -lm17n-core.
37
38     <li> SHELL API
39
40     It provides modules that utilize the m17n database (code
41     conversion, character property, etc).  They load various kinds of
42     data from the database on demand.  To use this API, an application
43     program must include <m17n.h> and be linked by -lm17n (some system
44     requires -lm17n-core in addition).  With that, CORE API is also available.
45
46     <li> GUI API
47
48     It provides GUI modules such as drawing and inputting M-texts on a
49     graphic device.  The API itself is independent on a graphic device
50     but most of functions require an argument MFrame which is created
51     for a specific type of graphic device.  Currently, X Window
52     System, gdImagePtr of GD library, and null device are supported as
53     a graphic device.  To use this API, an application program must
54     include <m17n-gui.h>, and be linked by -lm17n-gui (some system
55     requires -lm17n-core -lm17n in addition).  With that, CORE and
56     SHELL APIs are also available.
57
58     <li> MISC API
59
60     It provides miscellaneous functions to support error handling and
61     debugging.  This API cannot be used by itself, but with one or more
62     APIs listed above.  To use the API, an application program must
63     include <m17n-misc.h> in addition to one of <m17n-core.h>,
64     <m17n.h>, and <m17n-gui.h>.
65
66     </ol>
67
68     See also the section @ref m17n-config "m17n-config(1)".
69
70     <em>ENVIRONMENT VARIABLE</em>
71
72     The m17n library pays attention to these environment variables.
73
74     <ul>
75     <li> @c M17NDIR
76
77     Name of a directory that contains data of the m17n database.  See
78     @ref m17nDatabase for more details.
79
80     <li> @c MDEBUG_XXXX
81
82     Environment variables whose name start by "MDEBUG_" controls
83     printing of debug information.  See @ref m17nDebug for more
84     details.
85
86     </ul>
87
88     <em>API NAMING CONVENTION</em>
89
90     The library exports functions, variables, macros, and types.  All
91     of them start by the letter 'm' or 'M' followed by an object name
92     (e.g. "symbol" and "plist", but "mtext" object is given the name
93     "text" to avoid double 'm' at the head) or a module name
94     (e.g. draw, input).
95     
96     <ul>
97
98     <li> functions -- mobject () or mobject_xxx ()
99
100     They start with 'm' followed by lower case object name.  For
101     example, msymbol (), mtext_ref_char (), mdraw_text ().
102
103     <li> non-symbol variables -- mobject, or mobject_xxx
104     
105     The naming convention is the same as functions (e.g. mface_large).
106
107     <li> symbol variables -- Mname
108
109     Variables of type MSymbol start with 'M' followed by their names
110     (e.g. Mlanguage (name is "language"), Miso_2022 (name is
111     "iso-2022").
112
113     <li> macros -- MOBJECT_XXX
114
115     They start by 'M' followed by upper case object names.
116
117     <li> types -- MObject or MObjectXxx
118
119     They start by 'M' followed by capitalized object names (e.g.
120     MConverter, MInputDriver).
121
122     </ul>
123
124   */
125
126 /***ja
127     @addtogroup m17nIntro
128     @brief m17n ¥é¥¤¥Ö¥é¥ê ¥¤¥ó¥È¥í¥À¥¯¥·¥ç¥ó.
129
130     @em API¤Î¥ì¥Ù¥ë
131
132     m17n ¥é¥¤¥Ö¥é¥ê¤Î API ¤Ï°Ê²¼¤Î£´¼ï¤ËʬÎव¤ì¤Æ¤¤¤ë¡£
133
134     <ol>
135     <li> ¥³¥¢ API
136
137     M-text ¤ò°·¤¦¤¿¤á¤Î´ðËÜŪ¤Ê¥â¥¸¥å¡¼¥ë¤òÄ󶡤¹¤ë¡£¤³¤ÎʬÎà¤Î API ¤Ï
138     m17n ¥Ç¡¼¥¿¥Ù¡¼¥¹¤òɬÍפȤ·¤Ê¤¤¡£ÍøÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢¥¢¥×¥ê¥±¡¼¥·¥ç
139     ¥ó¥×¥í¥°¥é¥à¤Ï<m17n-core.h> ¤ò include ¤·¡¢ -lm17n-core ¤Ç¥ê¥ó¥¯¤µ
140     ¤ì¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
141
142     <li> ¥·¥§¥ë API
143
144     m17n ¥Ç¡¼¥¿¥Ù¡¼¥¹¤òÍøÍѤ¹¤ë¥â¥¸¥å¡¼¥ë¡Ê¥³¡¼¥ÉÊÑ´¹¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£
145     Åù¡Ë¤òÄ󶡤¹¤ë¡£¥â¥¸¥å¡¼¥ë¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤éɬÍפ˱þ¤¸¤Æ¿Íͤʥǡ¼
146     ¥¿¤ò¥í¡¼¥É¤¹¤ë¡£ÍøÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤Ï
147     <m17n.h> ¤ò include ¤·¡¢ -lm17n ¤Ç¥ê¥ó¥¯¤µ¤ì¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡Ê¥·¥¹
148     ¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï -lm17n-core ¤âɬÍסˡ£¤³¤¦¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¥³¥¢ API
149     ¤â»ÈÍѤǤ­¤ë¡£
150
151     <li> GUI API
152
153     M-texts ¤ò¥°¥é¥Õ¥£¥Ã¥¯¥Ç¥Ð¥¤¥¹¾å¤Çɽ¼¨¤·¤¿¤êÆþÎϤ·¤¿¤ê¤¹¤ë¤È¤¤¤Ã¤¿¡¢
154     ¥°¥é¥Õ¥£¥Ã¥¯¥æ¡¼¥¶¥¤¥ó¥¿¥Õ¥§¡¼¥¹¥â¥¸¥å¡¼¥ë¤òÄ󶡤¹¤ë¡£API ¼«ÂΤϥ¦¥£
155     ¥ó¥É¥¦¥·¥¹¥Æ¥à¤È¤ÏÆÈΩ¤Ç¤¢¤ë¤¬¡¢Â¿¤¯¤Î´Ø¿ô¤ÏÆÃÄê¤Î¥°¥é¥Õ¥£¥Ã¥¯¥Ç¥Ð
156     ¥¤¥¹¾å¤ËºîÀ®¤µ¤ì¤¿ MFrame ¤ò°ú¿ô¤Ë¼è¤ë¡£¸½»þÅÀ¤Ç¤Ï¡¢X ¥¦¥£¥ó¥É¥¦¥·
157     ¥¹¥Æ¥à¡¢GD ¥é¥¤¥Ö¥é¥ê¤Î gdImagePtr¡¢¥Ì¥ë¥Ç¥Ð¥¤¥¹¤¬¥°¥é¥Õ¥£¥Ã¥¯¥Ç¥Ð
158     ¥¤¥¹¤È¤·¤Æ¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¡£ÍøÍѤ¹¤ë¤¿¤á¤Ë¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í
159     ¥°¥é¥à¤Ï <m17n-gui.h> ¤ò include ¤·¡¢-lm17n-gui ¤Ç¥ê¥ó¥¯¤µ¤ì¤Ê¤¯¤Æ
160     ¤Ï¤Ê¤é¤Ê¤¤¡Ê¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï -lm17n-core -lm17n ¤âɬÍסˡ£¤³¤¦¤¹
161     ¤ë¤³¤È¤Ë¤è¤Ã¤Æ¥³¥¢ API ¤È¥·¥§¥ë API ¤â»ÈÍѤǤ­¤ë¡£
162
163     <li> ¤½¤Î¾¤Î API
164
165     ¥¨¥é¡¼½èÍý¡¢¥Ç¥Ð¥Ã¥°ÍѤΤ½¤Î¾¤Î´Ø¿ô¤òÄ󶡤¹¤ë¡£¤³¤Î API ¤Ï¤½¤ì¤À
166     ¤±¤Ç¤Ï»ÈÍѤǤ­¤º¡¢¾åµ­¤Î¾¤Î¤â¤Î¤È¶¦¤Ë»È¤¦¡£ÍøÍѤ¹¤ë¤¿¤á¤Ë¤Ï
167     <m17n-core.h>, <m17n.h>, <m17n-gui.h> ¤Î¤¤¤º¤ì¤«¤Ë²Ã¤¨¤Æ¡¢ 
168     <m17n-misc.h> ¤ò include ¤·¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
169
170     </ol>
171
172     @ref m17n-config "m17n-config(1)" Àá¤â»²¾È¡£
173
174     @em ´Ä¶­ÊÑ¿ô
175
176     m17n ¥é¥¤¥Ö¥é¥ê¤Ï¼¡¤Î´Ä¶­ÊÑ¿ô¤ò¹Íθ¤¹¤ë¡£
177
178     <ul>
179     <li> @c M17NDIR
180
181     m17n ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥Ç¡¼¥¿¤ò´Þ¤à¥Ç¥£¥ì¥¯¥È¥ê¤Î̾Á°¡£¾ÜºÙ¤Ï@ref
182     m17nDatabase »²¾È¡£
183
184     <li> @c MDEBUG_XXXX
185
186     "MDEBUG_" ¤Ç»Ï¤Þ¤ë̾Á°¤ò»ý¤Ä´Ä¶­ÊÑ¿ô¤Ï¥Ç¥Ð¥Ã¥°¾ðÊó¤òÀ©¸æ¤¹¤ë¡£¾ÜºÙ
187     ¤Ï@ref m17nDebug »²¾È¡£
188
189     </ul>
190
191     @em API @em ¤Î̿̾µ¬Â§ ¥³¥Þ¥ó¥É
192
193     ¥é¥¤¥Ö¥é¥ê¤Ï¡¢´Ø¿ô¡¢ÊÑ¿ô¡¢¥Þ¥¯¥í¡¢·¿¤ò export ¤¹¤ë¡£¤½¤ì¤é¤Ï'm' ¤Þ
194     ¤¿¤Ï 'M' ¤Î¤¢¤È¤Ë¥ª¥Ö¥¸¥§¥¯¥È̾("symbol" ¤ä "plist" ¤Ê¤É¡£¤¿¤À¤· 
195     "mtext" ¥ª¥Ö¥¸¥§¥¯¥È¤Ï¤Ï¤¸¤á¤Î 'm' ¤Î½ÅÊ£¤òÈò¤±¤ë¤¿¤á "text" ¤òÍÑ
196     ¤¤¤ë¡£) ¤Þ¤¿¤Ï¥â¥¸¥å¡¼¥ë̾(draw, input ¤Ê¤É) ¤ò³¤±¤¿¤â¤Î¤Ç¤¢¤ë¡£
197     
198     <ul>
199
200     <li> ´Ø¿ô -- mobject () ¤Þ¤¿¤Ï mobject_xxx ()
201
202     'm' ¤Î¤¢¤È¤Ë¾®Ê¸»ú¤Ç¥ª¥Ö¥¸¥§¥¯¥È̾¤¬Â³¤¯¡£¤¿¤È¤¨¤Ð¡¢msymbol (),
203      mtext_ref_char (), mdraw_text () ¤Ê¤É¡£
204
205     <li> ¥·¥ó¥Ü¥ë¤Ç¤Ê¤¤ÊÑ¿ô -- mobject,  ¤Þ¤¿¤Ï mobject_xxx
206     
207     ´Ø¿ô¤ÈƱ¤¸Ì¿Ì¾µ¬Â§¤Ë½¾¤¦¡£(¤¿¤È¤¨¤Ð  mface_large)
208
209     <li> ¥·¥ó¥Ü¥ëÊÑ¿ô -- Mname
210
211     MSymbol ·¿ÊÑ¿ô¤Ï¡¢'M' ¤Î¸å¤Ë̾Á°¤¬Â³¤¯¡£¤¿¤È¤¨¤Ð Mlanguage (̾Á°¤Ï 
212     "language"), Miso_2022 (̾Á°¤Ï"iso-2022")¤Ê¤É¡£
213
214     <li> ¥Þ¥¯¥í -- MOBJECT_XXX
215
216     'M' ¤Î¸å¤ËÂçʸ»ú¤Ç¥ª¥Ö¥¸¥§¥¯¥È̾¤¬Â³¤¯¡£
217
218     <li> ¥¿¥¤¥× -- MObject ¤Þ¤¿¤Ï MObjectXxx
219
220     'M' ¤Î¸å¤ËÂçʸ»ú¤Ç»Ï¤á¤Æ¥ª¥Ö¥¸¥§¥¯¥È̾¤ò¤¬Â³¤¯¡£ (¤¿¤È¤¨¤Ð
221     MConverter, MInputDriver)
222
223     </ul>
224     
225     */
226 /*=*/
227 /*** @{ */
228 #ifdef FOR_DOXYGEN
229 /***en
230     The #M17NLIB_MAJOR_VERSION macro gives the major version number
231     of the m17n library.  */
232
233 /***ja
234     ¥Þ¥¯¥í #M17NLIB_MAJOR_VERSION ¤Ï m17n ¥é¥¤¥Ö¥é¥ê¤Î¥á¥¸¥ã¡¼¥Ð¡¼¥¸¥ç
235     ¥óÈÖ¹æ¤òÍ¿¤¨¤ë¡£  */
236
237 #define M17NLIB_MAJOR_VERSION
238
239 /*=*/
240
241 /***en
242     The #M17NLIB_MINOR_VERSION macro gives the minor version number
243     of the m17n library.  */
244
245 /***ja
246     ¥Þ¥¯¥í #M17NLIB_MINOR_VERSION ¤Ï m17n ¥é¥¤¥Ö¥é¥ê¤Î¥Þ¥¤¥Ê¡¼¥Ð¡¼¥¸¥ç
247     ¥óÈÖ¹æ¤òÍ¿¤¨¤ë¡£  */
248
249 #define M17NLIB_MINOR_VERSION
250
251 /*=*/
252
253 /***en
254     The #M17NLIB_PATCH_LEVEL macro gives the patch level number
255     of the m17n library.  */
256
257 /***ja
258     ¥Þ¥¯¥í #M17NLIB_PATCH_LEVEL ¤Ï m17n ¥é¥¤¥Ö¥é¥ê¤Î¥Ñ¥Ã¥Á¥ì¥Ù¥ëÈÖ¹æ¤ò
259     Í¿¤¨¤ë¡£  */
260
261 #define M17NLIB_PATCH_LEVEL
262
263 /*=*/
264
265 /***en
266     The #M17NLIB_VERSION_NAME macro gives the version name of the
267     m17n library as a string.  */
268
269 /***ja
270     ¥Þ¥¯¥í #M17NLIB_VERSION_NAME ¤Ï m17n ¥é¥¤¥Ö¥é¥ê¤Î¥Ð¡¼¥¸¥ç¥ó̾¤ò
271     Ê¸»úÎó¤È¤·¤ÆÍ¿¤¨¤ë¡£  */
272
273 #define M17NLIB_VERSION_NAME
274
275 /*=*/
276
277 /***en
278     @brief Initialize the m17n library.
279
280     The macro M17N_INIT () initializes the m17n library.  This macro
281     must be called before any m17n functions are used.
282
283     If the initialization was successful, the external variable
284     #merror_code is set to 0.  Otherwise it is set to -1.  */
285
286 /***ja
287     @brief m17n ¥é¥¤¥Ö¥é¥ê¤ò½é´ü²½¤¹¤ë.
288
289     ¥Þ¥¯¥í M17N_INIT () ¤Ï m17n ¥é¥¤¥Ö¥é¥ê¤ò½é´ü²½¤¹¤ë¡£m17n ¤Î´Ø¿ô¤ò
290     ÍøÍѤ¹¤ëÁ°¤Ë¡¢¤³¤Î¥Þ¥¯¥í¤ò¤Þ¤º¸Æ¤Ð¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
291     
292     ³°ÉôÊÑ¿ô #merror_code ¤Ï¡¢½é´ü²½¤¬À®¸ù¤¹¤ì¤Ð 0 ¤Ë¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð 
293     -1 ¤ËÀßÄꤵ¤ì¤ë¡£  */
294
295 #define M17N_INIT()
296
297 /*=*/
298
299 /***en
300     @brief Finalize the m17n library.
301
302     The macro M17N_FINI () finalizes the m17n library.  It frees all the
303     memory area used by the m17n library.  Once this macro is
304     called, no m17n functions should be used until the
305     macro M17N_INIT () is called again.  */
306 /***ja
307     @brief m17n ¥é¥¤¥Ö¥é¥ê¤ò½ªÎ»¤¹¤ë. 
308
309     ¥Þ¥¯¥í M17N_FINI () ¤Ï m17n ¥é¥¤¥Ö¥é¥ê¤ò½ªÎ»¤¹¤ë¡£m17n ¥é¥¤¥Ö¥é¥ê
310     ¤¬»È¤Ã¤¿Á´¤Æ¤Î¥á¥â¥êÎΰè¤Ï²òÊü¤µ¤ì¤ë¡£°ìÅÙ¤³¤Î¥Þ¥¯¥í¤¬¸Æ¤Ð¤ì¤¿¤é¡¢
311     ¥Þ¥¯¥í M17N_INIT () ¤¬ºÆÅٸƤФì¤ë¤Þ¤Ç m17n ´Ø¿ô¤Ï»È¤¦¤Ù¤­¤Ç¤Ê¤¤¡£
312  */
313
314 #define M17N_FINI()
315 #endif /* FOR_DOXYGEN */
316 /*=*/
317 /*** @} */ 
318 /*=*/
319
320 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
321 /*** @addtogroup m17nInternal
322      @{ */
323
324 #include <config.h>
325 #include <stdio.h>
326 #include <stdlib.h>
327 #include <sys/time.h>
328 #include <sys/resource.h>
329 #include <unistd.h>
330
331 #include "m17n-core.h"
332 #include "m17n-misc.h"
333 #include "internal.h"
334
335 static int core_initialized;
336
337 static void
338 default_error_handler (enum MErrorCode err)
339 {
340   exit (err);
341 }
342
343 static struct timeval time_stack[16];
344 static int time_stack_index;
345
346 static int report_header_printed;
347
348 \f
349 /* Internal API */
350
351 void
352 mdebug__report_object (char *name, M17NObjectArray *array)
353 {
354   if (! (mdebug__flag & MDEBUG_FINI))
355     return;
356   if (! report_header_printed)
357     {
358       fprintf (stderr, "%16s %7s %7s %7s\n",
359                "object", "created", "freed", "alive");
360       fprintf (stderr, "%16s %7s %7s %7s\n",
361                "------", "-------", "-----", "-----");
362       report_header_printed = 1;
363     }
364   fprintf (stderr, "%16s %7d %7d %7d\n", name,
365            array->used, array->used - array->count, array->count);
366   if (array->used > 0)
367     {
368       free (array->objects);
369       array->count = array->used = 0;
370     }
371 }
372
373
374 void *(*mdatabase__finder) (MSymbol tag1, MSymbol tag2,
375                            MSymbol tag3, MSymbol tag4);
376 void *(*mdatabase__loader) (void *);
377
378 int mdebug__flag;
379
380 void
381 mdebug__push_time ()
382 {
383   struct timezone tz;
384
385   gettimeofday (time_stack + time_stack_index++, &tz);
386 }
387
388 void
389 mdebug__pop_time ()
390 {
391   time_stack_index--;
392 }
393
394 void
395 mdebug__print_time ()
396 {
397   struct timeval tv;
398   struct timezone tz;
399   long diff;
400
401   gettimeofday (&tv, &tz);
402   diff = ((tv.tv_sec - time_stack[time_stack_index - 1].tv_sec) * 1000000
403           + (tv.tv_usec - time_stack[time_stack_index - 1].tv_usec));
404   fprintf (stderr, "%8ld ms.", diff);
405   time_stack[time_stack_index - 1] = tv;
406 }
407
408 #define SET_DEBUG_FLAG(env_name, mask)          \
409   do {                                          \
410     char *env_value = getenv (env_name);        \
411                                                 \
412     if (env_value && env_value[0] == '1')       \
413       mdebug__flag |= (mask);                   \
414   } while (0)
415
416
417 void
418 mdebug__register_object (M17NObjectArray *array, void *object)
419 {
420   if (array->used == 0)
421     MLIST_INIT1 (array, objects, 256);
422   array->count++;
423   MLIST_APPEND1 (array, objects, object, MERROR_OBJECT);
424 }
425
426 void
427 mdebug__unregister_object (M17NObjectArray *array, void *object)
428 {
429   array->count--;
430   if (array->count >= 0)
431     {
432       int i = 0;
433
434       while (i < array->used && array->objects[i] != object) i++;
435       if (i < array->used)
436         array->objects[i] = NULL;
437       else
438         mdebug_hook ();
439     }
440   else                                                                  \
441     mdebug_hook ();
442 }
443
444 \f
445 /* External API */
446
447 /* The following two are actually not exposed to a user but concealed
448    by the macro M17N_INIT (). */
449
450 void
451 m17n_init_core (void)
452 {
453   int mdebug_mask = MDEBUG_INIT;
454
455   if (core_initialized++)
456     return;
457
458   merror_code = MERROR_NONE;
459   m17n_memory_full_handler = default_error_handler;
460
461   mdebug__flag = 0;
462   SET_DEBUG_FLAG ("MDEBUG_INIT", MDEBUG_INIT);
463   SET_DEBUG_FLAG ("MDEBUG_FINI", MDEBUG_FINI);
464   SET_DEBUG_FLAG ("MDEBUG_CHARSET", MDEBUG_CHARSET);
465   SET_DEBUG_FLAG ("MDEBUG_CODING", MDEBUG_CODING);
466   SET_DEBUG_FLAG ("MDEBUG_DATABASE", MDEBUG_DATABASE);
467   SET_DEBUG_FLAG ("MDEBUG_FONT", MDEBUG_FONT); 
468   SET_DEBUG_FLAG ("MDEBUG_FONT_FLT", MDEBUG_FONT_FLT);
469   SET_DEBUG_FLAG ("MDEBUG_FONT_OTF", MDEBUG_FONT_OTF);
470   SET_DEBUG_FLAG ("MDEBUG_INPUT", MDEBUG_INPUT);
471
472   MDEBUG_PUSH_TIME ();
473   MDEBUG_PUSH_TIME ();
474   if (msymbol__init () < 0)
475     goto err;
476   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize symbol module."));
477   if  (mplist__init () < 0)
478     goto err;
479   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize plist module."));
480   if (mtext__init () < 0)
481     goto err;
482   if (mtext__prop_init () < 0)
483     goto err;
484   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize mtext module."));
485   if  (mchartable__init () < 0)
486     goto err;
487   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize chartable module."));
488
489   mdatabase__finder = NULL;
490   mdatabase__loader = NULL;
491
492  err:
493   MDEBUG_POP_TIME ();
494   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize the core modules."));
495   MDEBUG_POP_TIME ();
496 }
497
498 void
499 m17n_fini_core (void)
500 {
501   int mdebug_mask = MDEBUG_FINI;
502
503   if (core_initialized > 1)
504     core_initialized--;
505   else
506     {
507       core_initialized = 0;
508       MDEBUG_PUSH_TIME ();
509       MDEBUG_PUSH_TIME ();
510       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize chartable module."));
511       mchartable__fini ();
512       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize textprop module."));
513       mtext__prop_fini ();
514       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize mtext module."));
515       mtext__fini ();
516       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize symbol module."));
517       msymbol__fini ();
518       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize plist module."));
519       mplist__fini ();
520       MDEBUG_POP_TIME ();
521       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the core modules."));
522       MDEBUG_POP_TIME ();
523     }
524   report_header_printed = 0;
525 }
526
527 /*** @} */
528 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
529 /*=*/
530
531 /***en
532     @addtogroup m17nObject
533     @brief Managed objects are objects managed by the reference count.
534
535     There are some types of m17n objects that are managed by their
536     reference count.  Those objects are called @e managed @e objects.
537     When created, the reference count of a managed object is
538     initialized to one.  The m17n_object_ref () function increments
539     the reference count of a managed object by one, and the
540     m17n_object_unref () function decrements by one.  A managed
541     object is automatically freed when its reference count becomes
542     zero.
543
544     A property whose key is a managing key can have only a managed
545     object as its value.  Such functions as msymbol_put () and
546     mplist_put () pay special attention to such a property.
547
548     In addition to the predefined managed object types, users can
549     define their own managed object types.  See the documentation of
550     the m17n_object () for more details.  */
551 /***ja
552     @addtogroup m17nObject
553     @brief ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤È¤Ï»²¾È¿ô¤Ë¤è¤Ã¤Æ´ÉÍý¤µ¤ì¤Æ¤¤¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ë.
554
555     m17n ¥ª¥Ö¥¸¥§¥¯¥È¤Î¤¢¤ë·¿¤Î¤â¤Î¤Ï¡¢»²¾È¿ô¤Ë¤è¤Ã¤Æ´ÉÍý¤µ¤ì¤Æ¤¤¤ë¡£
556     ¤½¤ì¤é¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ï @e ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È ¤È¸Æ¤Ð¤ì¤ë¡£À¸À®¤µ¤ì
557     ¤¿»þÅÀ¤Ç¤Î»²¾È¿ô¤Ï 0 ¤Ë½é´ü²½¤µ¤ì¤Æ¤¤¤ë¡£´Ø¿ô m17n_object_ref () 
558     ¤Ï´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¿ô¤ò 1 Áý¤ä¤·¡¢´Ø¿ôm17n_object_unref () 
559     ¤Ï 1 ¸º¤é¤¹¡£»²¾È¿ô¤¬ 0 ¤Ë¤Ê¤Ã¤¿´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ï¼«Æ°Åª¤Ë²òÊü¤µ
560     ¤ì¤ë¡£
561
562     ¥­¡¼¤¬´ÉÍý¥­¡¼¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤Ï¡¢ÃͤȤ·¤Æ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤À¤±¤ò
563     ¼è¤ë¡£´Ø¿ô msymbol_put () ¤ä mplist_put () ¤Ê¤É¤Ï¤½¤ì¤é¤Î¥×¥í¥Ñ¥Æ¥£
564     ¤òÆÃÊÌ°·¤¤¤¹¤ë¡£
565
566     ÄêµÁºÑ¤ß´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¥¿¥¤¥×¤Î¾¤Ë¡¢¥æ¡¼¥¶¤ÏɬÍפʴÉÍý²¼¥ª¥Ö¥¸¥§
567     ¥¯¥È¥¿¥¤¥×¤ò¼«Ê¬¤ÇÄêµÁ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£¾ÜºÙ¤Ïm17n_object () ¤ÎÀâ
568     ÌÀ¤ò»²¾È¡£  */
569
570 /*** @{  */
571 /*=*/
572 /***en
573     @brief Allocate a managed object.
574
575     The m17n_object () function allocates a new managed object of
576     $SIZE bytes and sets its reference count to 1.  $FREER is the
577     function that is used to free the object when the reference count
578     becomes 0.  If $FREER is NULL, the object is freed by the free ()
579     function.
580
581     The heading bytes of the allocated object is occupied by
582     #M17NObjectHead.  That area is reserved for the m17n library and
583     application programs should never touch it.
584
585     @return
586     This function returns a newly allocated object.
587
588     @errors
589     This function never fails.  */
590
591 /***ja
592     @brief ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤ò³ä¤êÅö¤Æ¤ë.
593
594     ´Ø¿ô m17n_object () ¤Ï$SIZE ¥Ð¥¤¥È¤Î¿·¤·¤¤´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤ò³ä¤ê
595     Åö¤Æ¡¢¤½¤Î»²¾È¿ô¤ò 1 ¤È¤¹¤ë¡£ $FREER ¤Ï»²¾È¿ô¤¬ 0 ¤Ë¤Ê¤Ã¤¿ºÝ¤Ë¤½¤Î
596     ¥ª¥Ö¥¸¥§¥¯¥È¤ò²òÊü¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë´Ø¿ô¤Ç¤¢¤ë¡£$FREER ¤¬ NULL¤Ê
597     ¤é¤Ð¡¢¥ª¥Ö¥¸¥§¥¯¥È¤Ï´Ø¿ô free () ¤Ë¤è¤Ã¤Æ²òÊü¤µ¤ì¤ë¡£
598
599     ³ä¤êÅö¤Æ¤é¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥ÈËÁƬ¤Î¥Ð¥¤¥È¤Ï¡¢#M17NObjectHead ¤¬Àê¤á¤ë¡£ 
600     ¤³¤ÎÎΰè¤Ï m17n ¥é¥¤¥Ö¥é¥ê¤¬»ÈÍѤ¹¤ë¤Î¤Ç¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é
601     ¥à¤Ï¿¨¤ì¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
602
603     @return
604     ¤³¤Î´Ø¿ô¤Ï¿·¤·¤¯³ä¤êÅö¤Æ¤é¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤¹¡£
605
606     @errors
607     ¤³¤Î´Ø¿ô¤Ï¼ºÇÔ¤·¤Ê¤¤¡£    */
608
609 #if EXAMPLE_CODE
610 typedef struct
611 {
612   M17NObjectHead head;
613   int mem1;
614   char *mem2;
615 } MYStruct;
616
617 void
618 my_freer (void *obj)
619 {
620   free (((MYStruct *) obj)->mem2);
621   free (obj);
622 }
623
624 void
625 my_func (MText *mt, MSymbol key, int num, char *str)
626 {
627   MYStruct *st = m17n_object (sizeof (MYStruct), my_freer);
628
629   st->mem1 = num;
630   st->mem2 = strdup (str);
631   /* KEY must be a managing key.   */
632   mtext_put_prop (mt, 0, mtext_len (mt), key, st);
633   /* This sets the reference count of ST back to 1.  */
634   m17n_object_unref (st);
635 }
636 #endif
637
638 void *
639 m17n_object (int size, void (*freer) (void *))
640 {
641   M17NObject *obj = malloc (size);
642
643   obj->ref_count = 1;
644   obj->u.freer = freer;
645   return obj;
646 }
647
648 /*=*/
649
650 /***en
651     @brief Increment the reference count of a managed object.
652
653     The m17n_object_ref () function increments the reference count of
654     the managed object pointed to by $OBJECT.
655
656     @return
657     This function returns the resulting reference count if it fits in
658     a 16-bit unsigned integer (i.e. less than 0x10000).  Otherwise, it
659     return -1.
660
661     @errors
662     This function never fails.  */
663 /***ja
664     @brief ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¿ô¤ò 1 Áý¤ä¤¹.
665
666     ´Ø¿ô m17n_object_ref () ¤Ï $OBJECT ¤Ç»Ø¤µ¤ì¤ë´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Î
667     »²¾È¿ô¤ò 1 Áý¤ä¤¹¡£
668
669     @return 
670     ¤³¤Î´Ø¿ô¤Ï¡¢Áý¤ä¤·¤¿»²¾È¿ô¤¬ 16 ¥Ó¥Ã¥È¤ÎÉä¹æ̵¤·À°¿ôÃÍ(¤¹¤Ê¤ï¤Á 
671     0x10000 Ì¤Ëþ)¤Ë¤ª¤µ¤Þ¤ì¤Ð¡¢¤½¤ì¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð -1 ¤òÊÖ¤¹¡£
672
673     @errors
674     ¤³¤Î´Ø¿ô¤Ï¼ºÇÔ¤·¤Ê¤¤¡£    */
675
676 int
677 m17n_object_ref (void *object)
678 {
679   M17NObject *obj = (M17NObject *) object;
680   M17NObjectRecord *record;
681   unsigned *count;
682
683   if (! obj->ref_count_extended)
684     {
685       if (++obj->ref_count)
686         return (int) obj->ref_count;
687       MSTRUCT_MALLOC (record, MERROR_OBJECT);
688       record->freer = obj->u.freer;
689       MLIST_INIT1 (record, counts, 1);
690       MLIST_APPEND1 (record, counts, 0, MERROR_OBJECT);
691       obj->u.record = record;
692       obj->ref_count_extended = 1;
693     }
694   else
695     record = obj->u.record;
696
697   count = record->counts;
698   while (*count == 0xFFFFFFFF)
699     *(count++) = 0;
700   (*count)++;
701   if (*count == 0xFFFFFFFF)
702     MLIST_APPEND1 (record, counts, 0, MERROR_OBJECT);
703   return -1;
704 }
705
706 /*=*/
707
708 /***en
709     @brief Decrement the reference count of a managed object.
710
711     The m17n_object_unref () function decrements the reference count
712     of the managed object pointed to by $OBJECT.  When the reference
713     count becomes zero, the object is freed by its freer function.
714
715     @return
716     This function returns the resulting reference count if it fits in
717     a 16-bit unsigned integer (i.e. less than 0x10000).  Otherwise, it
718     returns -1.  Thus, the return value zero means that $OBJECT is
719     freed.
720
721     @errors
722     This function never fails.  */
723 /***ja
724     @brief ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¿ô¤ò 1 ¸º¤é¤¹.
725
726     ´Ø¿ô m17n_object_unref () ¤Ï $OBJECT ¤Ç»Ø¤µ¤ì¤ë´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È
727     ¤Î»²¾È¿ô¤ò 1 ¸º¤é¤¹¡£»²¾È¿ô¤¬ 0 ¤Ë¤Ê¤ì¤Ð¡¢¥ª¥Ö¥¸¥§¥¯¥È¤Ï²òÊü´Ø¿ô¤Ë
728     ¤è¤Ã¤Æ²òÊü¤µ¤ì¤ë¡£
729
730     @return 
731     ¤³¤Î´Ø¿ô¤Ï¡¢¸º¤é¤·¤¿»²¾È¿ô¤¬ 16 ¥Ó¥Ã¥È¤ÎÉä¹æ̵¤·À°¿ôÃÍ(¤¹¤Ê¤ï¤Á 
732     0x10000 Ì¤Ëþ)¤Ë¤ª¤µ¤Þ¤ì¤Ð¡¢¤½¤ì¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð -1 ¤òÊÖ¤¹¡£
733     ¤Ä¤Þ¤ê¡¢0 ¤¬Ê֤äÆÍ褿¾ì¹ç¤Ï$OBJECT ¤Ï²òÊü¤µ¤ì¤Æ¤¤¤ë¡£
734
735     @errors
736     ¤³¤Î´Ø¿ô¤Ï¼ºÇÔ¤·¤Ê¤¤¡£    */
737 int
738 m17n_object_unref (void *object)
739 {
740   M17NObject *obj = (M17NObject *) object;
741   M17NObjectRecord *record;
742   unsigned *count;
743
744   if (! obj->ref_count_extended)
745     {
746       if (! --obj->ref_count)
747         {
748           if (obj->u.freer)
749             (obj->u.freer) (object);
750           else
751             free (object);
752           return 0;
753         }
754       return (int) obj->ref_count;
755     }
756
757   record = obj->u.record;
758   count = record->counts;
759   while (! *count)
760     *(count++) = 0xFFFFFFFF;
761   (*count)--;
762   if (! record->counts[0])
763     {
764       obj->ref_count_extended = 0;
765       obj->ref_count--;
766       obj->u.freer = record->freer;
767       MLIST_FREE1 (record, counts);
768       free (record);
769     }
770   return -1;
771 }
772
773 /*=*/
774
775 /*** @} */
776
777 /***en
778     @addtogroup m17nError Error handling
779     @brief Error handling of the m17n library.
780
781     There are two types of errors that may happen in a function of
782     the m17n library.
783
784     The first type is argument errors.  When a library function is
785     called with invalid arguments, it returns a value that indicates
786     error and at the same time sets the external variable #merror_code
787     to a non-zero integer.
788
789     The second type is memory allocation errors.  When the required
790     amount of memory is not available on the system, m17n library
791     functions call a function pointed to by the external variable @c
792     m17n_memory_full_handler.  The default value of the variable is a
793     pointer to the default_error_handle () function, which just calls
794     <tt> exit ()</tt>.  */
795
796 /***ja
797     @addtogroup m17nError ¥¨¥é¡¼½èÍý
798     @brief m17n ¥é¥¤¥Ö¥é¥ê¤Î¥¨¥é¡¼½èÍý.
799
800     m17n ¥é¥¤¥Ö¥é¥ê¤Î´Ø¿ô¤Ç¤Ï¡¢£²¤Ä¤Î¼ïÎà¤Î¥¨¥é¡¼¤¬µ¯¤³¤êÆÀ¤ë¡£
801
802     °ì¤Ä¤Ï°ú¿ô¤Î¥¨¥é¡¼¤Ç¤¢¤ë¡£¥é¥¤¥Ö¥é¥ê¤Î´Ø¿ô¤¬ÂÅÅö¤Ç¤Ê¤¤°ú¿ô¤È¤È¤â¤Ë
803     ¸Æ¤Ð¤ì¤¿¾ì¹ç¡¢¤½¤Î´Ø¿ô¤Ï¥¨¥é¡¼¤ò°ÕÌ£¤¹¤ëÃͤòÊÖ¤·¡¢Æ±»þ¤Ë³°ÉôÊÑ¿ô 
804     #merror_code ¤Ë¥¼¥í¤Ç¤Ê¤¤À°¿ô¤ò¥»¥Ã¥È¤¹¤ë¡£
805
806     ¤â¤¦°ì¤Ä¤Î¼ïÎà¤Ï¥á¥â¥ê³äÅö¤Æ¥¨¥é¡¼¤Ç¤¢¤ë¡£¥·¥¹¥Æ¥à¤¬É¬ÍפÊÎ̤Υá¥â
807     ¥ê¤ò³äÅö¤Æ¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¾ì¹ç¡¢¥é¥¤¥Ö¥é¥ê´Ø¿ô¤Ï³°ÉôÊÑ¿ô @c
808     m17n_memory_full_handler ¤¬»Ø¤¹´Ø¿ô¤ò¸Æ¤Ö¡£¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢´Ø¿ô 
809     default_error_handle () ¤ò»Ø¤·¤Æ¤ª¤ê¡¢¤³¤Î´Ø¿ô¤Ïñ¤Ë <tt>exit
810     ()</tt> ¤ò¸Æ¤Ö¡£
811 */
812
813 /*** @{ */
814
815 /*=*/
816
817 /***en 
818     @brief External variable to hold error code of the m17n library.
819
820     The external variable #merror_code holds an error code of the
821     m17n library.  When a library function is called with an invalid
822     argument, it sets this variable to one of @c enum #MErrorCode.
823
824     This variable initially has the value 0.  */
825
826 /***ja 
827     @brief m17n ¥é¥¤¥Ö¥é¥ê¤Î¥¨¥é¡¼¥³¡¼¥É¤òÊÝ»ý¤¹¤ë³°ÉôÊÑ¿ô.
828
829     ³°ÉôÊÑ¿ô #merror_code ¤Ï¡¢m17n ¥é¥¤¥Ö¥é¥ê¤Î¥¨¥é¡¼¥³¡¼¥É¤òÊÝ»ý¤¹¤ë¡£
830     ¥é¥¤¥Ö¥é¥ê´Ø¿ô¤¬ÂÅÅö¤Ç¤Ê¤¤°ú¿ô¤È¤È¤â¤Ë¸Æ¤Ð¤ì¤¿ºÝ¤Ë¤Ï¡¢¤³¤ÎÊÑ¿ô¤ò 
831     @c enum #MErrorCode ¤Î°ì¤Ä¤Ë¥»¥Ã¥È¤¹¤ë¡£
832
833     ¤³¤ÎÊÑ¿ô¤Î½é´üÃͤϠ0 ¤Ç¤¢¤ë¡£  */
834
835 enum MErrorCode merror_code;
836
837 /*=*/
838
839 /***en 
840     @brief Memory allocation error handler.
841
842     The external variable #m17n_memory_full_handler holds a pointer
843     to the function to call when a library function failed to allocate
844     memory.  $ERR is one of @c enum #MErrorCode indicating in which
845     function the error occurred.
846
847     This variable initially points a function that simply calls the
848     <tt>exit </tt>() function with $ERR as an argument.
849
850     An application program that needs a different error handling can
851     change this variable to point a proper function.  */
852
853 /***ja 
854     @brief ¥á¥â¥ê³äÅö¤Æ¥¨¥é¡¼¥Ï¥ó¥É¥é.
855
856     ÊÑ¿ô #m17n_memory_full_handler ¤Ï¡¢¥é¥¤¥Ö¥é¥ê´Ø¿ô¤¬¥á¥â¥ê³äÅö¤Æ
857     ¤Ë¼ºÇÔ¤·¤¿ºÝ¤Ë¸Æ¤Ö¤Ù¤­´Ø¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£$ERR ¤Ï @c enum
858     #MErrorCode ¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ê¡¢¤É¤Î¥é¥¤¥Ö¥é¥ê´Ø¿ô¤Ç¥¨¥é¡¼¤¬µ¯¤Ã¤¿
859     ¤«¤ò¼¨¤¹¡£
860
861     @anchor test
862
863     ½é´üÀßÄê¤Ç¤Ï¡¢¤³¤ÎÊÑ¿ô¤Ïñ¤Ë <tt>exit ()</tt> ¤ò $ERR ¤ò°ú¿ô¤È¤·¤Æ
864     ¸Æ¤Ö´Ø¿ô¤ò»Ø¤·¤Æ¤¤¤ë¡£
865
866     ¤³¤ì¤È¤Ï°Û¤Ê¤ë¥¨¥é¡¼½èÍý¤òɬÍפȤ¹¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¤³¤ÎÊÑ¿ô¤ò
867     Å¬Åö¤Ê´Ø¿ô¤ËÀßÄꤹ¤ë¤³¤È¤Ç¡¢ÌÜŪ¤òãÀ®¤Ç¤­¤ë¡£  */
868
869 void (*m17n_memory_full_handler) (enum MErrorCode err);
870
871 /*** @} */
872
873 /*=*/
874
875 /***en
876     @addtogroup m17nDebug
877     @brief Support for m17n library users to debug their programs.
878
879     The m17n library provides the following facilities to support the
880     library users to debug their programs.
881
882     <ul>
883
884     <li> Environment variables to control printing of various
885     information.
886
887     <ul>
888
889     <li> MDEBUG_INIT -- If set to 1, print information about the
890     library initialization on the call of M17N_INIT ().
891
892     <li> MDEBUG_FINI -- If set to 1, print counts of objects that are
893     not yet freed on the call of M17N_FINI ().
894
895     <li> MDEBUG_CHARSET -- If set to 1, print information about
896     charsets being loaded from the m17n database.
897
898     <li> MDEBUG_CODING -- If set to 1, print information about coding
899     systems being loaded from the m17n database.
900
901     <li> MDEBUG_DATABASE -- If set to 1, print information about
902     data being loaded from the m17n database.
903
904     <li> MDEBUG_FONT -- If set to 1, print information about fonts
905     being selected and opened.
906
907     <li> MDEBUG_FONT_FLT -- If set to 1, print information about which
908     command of Font Layout Table are being executed.
909
910     <li> MDEBUG_FONT_OTF -- If set to 1, print information about which
911     feature of OpenType Layout Table are being executed.
912
913     <li> MDEBUG_INPUT -- If set to 1, print information about how an
914     input method is running.
915
916     <li> MDEBUG_ALL -- Setting this variable to 1 is equivalent to
917     setting all the above variables to 1.
918
919     </ul>
920
921     <li> Functions to print various objects in a human readable way.
922     See the documentation of mdebug_dump_XXXX () functions.
923
924     <li> The hook function called on an error.  See the documentation
925     of mdebug_hook ().
926
927     </ul>
928 */
929 /***ja
930     @addtogroup m17nDebug
931     @brief m17n ¥é¥¤¥Ö¥é¥ê¥æ¡¼¥¶¤Î¤¿¤á¤Î¥×¥í¥°¥é¥à¥Ç¥Ð¥Ã¥°¥µ¥Ý¡¼¥È.
932
933     m17n ¥é¥¤¥Ö¥é¥ê¤Ï¡¢¤½¤Î¥æ¡¼¥¶¤¬¼«Ê¬¤Î¥×¥í¥°¥é¥à¤ò¥Ç¥Ð¥Ã¥°¤¹¤ë¤¿¤á
934     ¤Ë¡¢°Ê²¼¤Îµ¡Ç½¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¡£
935
936     <ul>
937
938     <li> ¤µ¤Þ¤¶¤Þ¤Ê¾ðÊó¤Î¥×¥ê¥ó¥È¤òÀ©¸æ¤¹¤ë´Ä¶­ÊÑ¿ô¡£
939
940     <ul>
941
942     <li> MDEBUG_INIT -- 1 ¤Ê¤é¤Ð¡¢M17N_INIT () ¤¬¸Æ¤Ð¤ì¤¿»þÅÀ¤Ç¡¢¥é¥¤
943     ¥Ö¥é¥ê¤Î½é´ü²½¤Ë´Ø¤¹¤ë¾ðÊó¤ò¥×¥ê¥ó¥È¤¹¤ë¡£
944
945     <li> MDEBUG_FINI -- 1 ¤Ê¤é¤Ð¡¢M17N_FINI () ¤¬¸Æ¤Ð¤ì¤¿»þÅÀ¤Ç¡¢¤Þ¤À
946     ²òÊü¤µ¤ì¤Æ¤¤¤Ê¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¿ô¤ò¥×¥ê¥ó¥È¤¹¤ë¡£
947
948     <li> MDEBUG_CHARSET -- 1 ¤Ê¤é¤Ð¡¢m17n ¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤é¥í¡¼¥É¤µ¤ì¤¿
949     Ê¸»ú¥»¥Ã¥È¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤ò¥×¥ê¥ó¥È¤¹¤ë¡£
950
951     <li> MDEBUG_CODING --  1 ¤Ê¤é¤Ð¡¢m17n ¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤é¥í¡¼¥É¤µ¤ì¤¿
952     ¥³¡¼¥É·Ï¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤ò¥×¥ê¥ó¥È¤¹¤ë¡£
953
954     <li> MDEBUG_DATABASE -- 1 ¤Ê¤é¤Ð¡¢m17n ¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤é¥í¡¼¥É¤µ¤ì
955     ¤¿¥Ç¡¼¥¿¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤ò¥×¥ê¥ó¥È¤¹¤ë¡£
956
957     <li> MDEBUG_FONT -- 1 ¤Ê¤é¤Ð¡¢ÁªÂò¤µ¤ì¤Æ¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥©¥ó¥È¤Ë¤Ä
958     ¤¤¤Æ¤Î¾ðÊó¤ò¥×¥ê¥ó¥È¤¹¤ë¡£
959
960     <li> MDEBUG_FONT_FLT -- 1 ¤Ê¤é¤Ð¡¢Font Layout Table ¤Î¤É¤Î¥³¥Þ¥ó¥É
961     ¤¬¼Â¹ÔÃ椫¤Ë¤Ä¤¤¤Æ¤Î¤ò¥×¥ê¥ó¥È¤¹¤ë¡£
962
963     <li> MDEBUG_FONT_OTF -- 1 ¤Ê¤é¤Ð¡¢OpenType Layout Table ¤Î¤É¤Î°À­
964     ¤¬¼Â¹ÔÃ椫¤Ë¤Ä¤¤¤Æ¤Î¤ò¥×¥ê¥ó¥È¤¹¤ë¡£
965
966     <li> MDEBUG_INPUT -- 1 ¤Ê¤é¤Ð¡¢¼Â¹ÔÃæ¤ÎÆþÎϥ᥽¥Ã¥É¤Î¾õÂÖ¤ËÉÕ¤¤¤Æ
967     ¤Î¾ðÊó¤ò¥×¥ê¥ó¥È¤¹¤ë¡£
968
969     <li> MDEBUG_ALL -- 1 ¤Ê¤é¤Ð¡¢¾åµ­¤¹¤Ù¤Æ¤ÎÊÑ¿ô¤ò 1 ¤Ë¤·¤¿¤Î¤ÈƱ¤¸¸ú
970     ²Ì¤ò»ý¤Ä¡£
971
972     </ul>
973
974     <li> ¼ï¡¹¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ò¿Í´Ö¤Ë²ÄÆɤʷÁ¤Ç¥×¥ê¥ó¥È¤¹¤ë´Ø¿ô¡£¾ÜºÙ¤Ï
975     ´Ø¿ô mdebug_dump_XXXX () ¤ÎÀâÌÀ»²¾È¡£
976
977     <li> ¥¨¥é¡¼È¯À¸»þ¤Ë¸Æ¤Ð¤ì¤ë¥Õ¥Ã¥¯´Ø¿ô¡£mdebug_hook () ¤ÎÀâÌÀ»²¾È¡£
978
979     </ul>
980 */
981
982 /*=*/
983 /*** @{ */
984 /*=*/
985
986 /***en
987     @brief Hook function called on an error.
988
989     The mdebug_hook () function is called when an error happens.  It
990     returns -1 without doing anything.  It is useful to set a break
991     point on this function in a debugger.  */ 
992 /***ja
993     @brief ¥¨¥é¡¼¤ÎºÝ¤Ë¸Æ¤Ð¤ì¤ë¥Õ¥Ã¥¯´Ø¿ô.
994
995     ´Ø¿ô mdebug_hook () ¤Ï¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿ºÝ¤Ë¸Æ¤Ð¤ì¡¢²¿¤â¤»¤º¤Ë-1 ¤ò
996     ÊÖ¤¹¡£¥Ç¥Ð¥Ã¥¬Æâ¤Ç¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¤òÀßÄꤹ¤ë¤¿¤á¤ËÍѤ¤¤ë¤³¤È¤¬¤Ç¤­
997     ¤ë¡£
998     */ 
999
1000 int
1001 mdebug_hook ()
1002 {
1003   return -1;
1004 }
1005
1006 /*=*/
1007
1008 /*** @} */ 
1009
1010 /*
1011   Local Variables:
1012   coding: euc-japan
1013   End:
1014 */