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