*** empty log message ***
[m17n/m17n-lib.git] / src / m17n-core.h
1 /* m17n-core.h -- header file for the CORE API of the m17n library.
2    Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
3      National Institute of Advanced Industrial Science and Technology (AIST)
4      Registration Number H15PRO112
5
6    This file is part of the m17n library.
7
8    The m17n library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public License
10    as published by the Free Software Foundation; either version 2.1 of
11    the License, or (at your option) any later version.
12
13    The m17n library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Lesser General Public License for more details.
17
18    You should have received a copy of the GNU Lesser General Public
19    License along with the m17n library; if not, write to the Free
20    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    02111-1307, USA.  */
22
23 #ifndef _M17N_CORE_H_
24 #define _M17N_CORE_H_
25
26 #ifdef __cplusplus
27 #define M17N_BEGIN_HEADER extern "C" {
28 #define M17N_END_HEADER }
29 #else
30 #define M17N_BEGIN_HEADER       /* do nothing */
31 #define M17N_END_HEADER         /* do nothing */
32 #endif
33
34 M17N_BEGIN_HEADER
35
36 /*
37  * Header file for m17n library.
38  */
39
40 /* (C1) Introduction */
41
42 /***en @defgroup m17nIntro Introduction  */
43 /***ja @defgroup m17nIntro ¤Ï¤¸¤á¤Ë  */
44 /*=*/
45
46 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
47
48 #define M17NLIB_MAJOR_VERSION 1
49 #define M17NLIB_MINOR_VERSION 5
50 #define M17NLIB_PATCH_LEVEL 4
51 #define M17NLIB_VERSION_NAME "1.5.4"
52
53 extern void m17n_init_core (void);
54 #define M17N_INIT() m17n_init_core ()
55 extern void m17n_fini_core (void);
56 #define M17N_FINI() m17n_fini_core ()
57
58 extern int merror_code;
59
60 #endif
61
62 /*=*/
63
64 /*** @ingroup m17nIntro */
65 /***en
66     @brief Enumeration for the status of the m17n library.
67
68     The enum #M17NStatus is used as a return value of the function
69     m17n_status ().  */
70
71 /***ja
72     @brief  m17n ¥é¥¤¥Ö¥é¥ê¤Î¾õÂÖ¤ò¼¨¤¹Îóµó·¿.
73
74     Îóµó·¿ #M17NStatus ¤Ï´Ø¿ô m17n_status () ¤ÎÌá¤êÃͤȤ·¤ÆÍѤ¤¤é¤ì¤ë¡£ */
75
76 enum M17NStatus
77   {
78     /***en No modules is initialized, and all modules are finalized.  */
79     M17N_NOT_INITIALIZED, 
80     /***en Only the modules in CORE API are initialized.  */
81     M17N_CORE_INITIALIZED,
82     /***en Only the modules in CORE and SHELL APIs are initialized.  */
83     M17N_SHELL_INITIALIZED, 
84     /***en All modules are initialized.  */
85     M17N_GUI_INITIALIZED
86   };
87
88 /*=*/
89
90 extern enum M17NStatus m17n_status (void);
91
92 /***en @defgroup m17nCore CORE API
93     @brief API provided by libm17n-core.so */
94 /***ja @defgroup m17nCore ¥³¥¢ API
95     @brief libm17n-core.so ¤¬Ä󶡤¹¤ë API */
96 /*=*/
97 /*** @ingroup m17nCore */
98 /***en @defgroup m17nObject Managed Object
99     @brief Objects managed by the reference count */
100 /***ja @defgroup m17nObject ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È
101     @brief »²¾È²ó¿ô¤Ç´ÉÍý¤µ¤ì¤ë¥ª¥Ö¥¸¥§¥¯¥È */
102 /*=*/
103
104 /*** @ingroup m17nObject  */
105 /***en
106     @brief The first member of a managed object.
107
108     When an application program defines a new structure for managed
109     objects, its first member must be of the type @c struct
110     #M17NObjectHead.  Its contents are used by the m17n library, and
111     application programs should never touch them.  */
112 /***ja
113     @brief ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤ÎºÇ½é¤Î¥á¥ó¥Ð.
114
115     ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤¬¿·¤·¤¤¹½Â¤ÂΤò´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤È¤·¤ÆÄêµÁ¤¹¤ëºÝ¤Ë¤Ï¡¢ºÇ½é¤Î¥á¥ó¥Ð¤Ï 
116     @c #M17NObjectHead ¹½Â¤Âη¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
117     @c #M17NObjectHead ¤ÎÆâÍƤϠm17n 
118     ¥é¥¤¥Ö¥é¥ê¤¬»ÈÍѤ¹¤ë¤Î¤Ç¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤Ï¿¨¤ì¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£    */
119
120 typedef struct
121 {
122   void *filler[2];
123 } M17NObjectHead;
124
125 /*=*/
126
127 /* Return a newly allocated managed object.  */
128 extern void *m17n_object (int size, void (*freer) (void *));
129
130 /* Increment the reference count of managed object OBJECT.  */
131 extern int m17n_object_ref (void *object);
132
133 /* Decrement the reference count of managed object OBJECT.  */
134 extern int m17n_object_unref (void *object);
135
136 /*** @ingroup m17nCore */
137 /***en
138     @brief Generic function type.
139
140     #M17NFunc is a generic function type for setting a function
141     pointer as a value of #MSymbol property or #MPlist.  */
142
143 /***ja
144     @brief ÈÆ´Ø¿ô·¿.
145
146     #M17NFunc ¤ÏÈÆ´Ø¿ô·¿¤Ç¤¢¤ê¡¢´Ø¿ô¥Ý¥¤¥ó¥¿¤ò #MSymbol ¥×¥í¥Ñ¥Æ¥£¤ä
147     #MPlist ¤ÎÃͤȤ·¤ÆÀßÄꤹ¤ëºÝÍѤ¤¤ë¡£  */
148
149
150 /***
151     @seealso
152     msymbol_put_func (), msymbol_get_func (),
153     mplist_put_func (), mplist_get_func ().  */
154
155 typedef void (*M17NFunc) (void);
156
157 /*=*/
158
159 /*** @ingroup m17nCore */
160 /***en
161     @brief Wrapper for a generic function type.
162
163     The macro M17N_FUNC () casts a function to the type #M17NFunc.  */
164
165 /***ja
166     @brief ÈÆ´Ø¿ô·¿¤Ø¤Î¥é¥Ã¥Ñ.
167
168     ¥Þ¥¯¥í M17N_FUNC () ¤Ï´Ø¿ô¤ò #M17NFunc ·¿¤Ø¥­¥ã¥¹¥È¤¹¤ë¡£  */
169
170
171 #define M17N_FUNC(func) ((M17NFunc) (func))
172
173 /*=*/
174
175 /* (C2) Symbol handling */
176
177 /*** @ingroup m17nCore */
178 /***en @defgroup m17nSymbol Symbol  */
179 /***ja @defgroup m17nSymbol ¥·¥ó¥Ü¥ë */
180 /*=*/
181
182 /***
183     @ingroup m17nSymbol */
184 /***en
185     @brief Type of symbols.
186
187     The type #MSymbol is for a @e symbol object.  Its internal
188     structure is concealed from application programs.  */
189
190 /***ja
191     @brief ¥·¥ó¥Ü¥ë¤Î·¿Àë¸À.
192
193     #MSymbol ¤Ï @e ¥·¥ó¥Ü¥ë (symbol) ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
194     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
195
196 typedef struct MSymbolStruct *MSymbol;
197
198 /*=*/
199
200 /* Predefined symbols. */ 
201 extern MSymbol Mnil;
202 extern MSymbol Mt;
203 extern MSymbol Mstring;
204 extern MSymbol Msymbol;
205 extern MSymbol Mtext;
206 extern MSymbol Mcharset;
207
208 /* Return a symbol of name NAME.  */
209 extern MSymbol msymbol (const char *name);
210
211 /* Return a managing key of name NAME.  */
212 extern MSymbol msymbol_as_managing_key (const char *name);
213
214 /* Check if SYMBOL is a managing key.  */
215 extern int msymbol_is_managing_key (MSymbol symbol);
216
217 /* Return a symbol of name NAME if it already exists.  */
218 extern MSymbol msymbol_exist (const char *name);
219
220 /* Return the name of SYMBOL.  */
221 extern char *msymbol_name (MSymbol symbol);
222
223 /* Give SYMBOL KEY property with value VALUE.  */
224 extern int msymbol_put (MSymbol symbol, MSymbol key, void *val);
225
226 /*** Return KEY property value of SYMBOL.  */
227 extern void *msymbol_get (MSymbol symbol, MSymbol key);
228
229 extern int msymbol_put_func (MSymbol symbol, MSymbol key, M17NFunc func);
230
231 extern M17NFunc msymbol_get_func (MSymbol symbol, MSymbol key);
232
233 /* 
234  *  (2-1) Property List
235  */
236 /*=*/
237 /*** @ingroup m17nCore */
238 /***en @defgroup m17nPlist Property List */
239 /***ja @defgroup m17nPlist ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È */
240 /*=*/
241
242 /***
243     @ingroup m17nPlist */ 
244 /***en
245     @brief Type of property list objects.
246
247     The type #MPlist is for a @e property @e list object.  Its internal
248     structure is concealed from application programs.  */
249
250 /***ja
251     @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿Àë¸À.
252
253     #MPlist ¤Ï @e ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È (Property list) ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
254     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
255
256 typedef struct MPlist MPlist;
257
258 /*=*/
259
260 extern MSymbol Mplist, Minteger;
261
262 extern MPlist *mplist ();
263
264 extern MPlist *mplist_copy (MPlist *plist);
265
266 extern MPlist *mplist_add (MPlist *plist, MSymbol key, void *val);
267
268 extern MPlist *mplist_push (MPlist *plist, MSymbol key, void *val);
269
270 extern void *mplist_pop (MPlist *plist);
271
272 extern MPlist *mplist_put (MPlist *plist, MSymbol key, void *val);
273
274 extern void *mplist_get (MPlist *plist, MSymbol key);
275
276 extern MPlist *mplist_put_func (MPlist *plist, MSymbol key, M17NFunc func);
277
278 extern M17NFunc mplist_get_func (MPlist *plist, MSymbol key);
279
280 extern MPlist *mplist_find_by_key (MPlist *plist, MSymbol key);
281
282 extern MPlist *mplist_find_by_value (MPlist *plist, void *val);
283
284 extern MPlist *mplist_next (MPlist *plist);
285
286 extern MPlist *mplist_set (MPlist *plist, MSymbol key, void *val);
287
288 extern int mplist_length (MPlist *plist);
289
290 extern MSymbol mplist_key (MPlist *plist);
291
292 extern void *mplist_value (MPlist *plist);
293
294 /* (S1) Characters */
295
296 /*=*/
297 /*** @ingroup m17nCore */
298 /***en @defgroup m17nCharacter Character */
299 /***ja @defgroup m17nCharacter Ê¸»ú */
300 /*=*/
301
302 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
303 #define MCHAR_MAX 0x3FFFFF
304 /*#define MCHAR_MAX 0x7FFFFFFF*/
305 #endif
306
307 extern MSymbol Mscript;
308 extern MSymbol Mname;
309 extern MSymbol Mcategory;
310 extern MSymbol Mcombining_class;
311 extern MSymbol Mbidi_category;
312 extern MSymbol Msimple_case_folding;
313 extern MSymbol Mcomplicated_case_folding;
314 extern MSymbol Mcased, Msoft_dotted, Mcase_mapping;
315 extern MSymbol Mblock;
316
317 extern MSymbol mchar_define_property (const char *name, MSymbol type);
318
319 extern void *mchar_get_prop (int c, MSymbol key);
320
321 extern int mchar_put_prop (int c, MSymbol key, void *val);
322
323 /* (C3) Handling chartable */
324
325 /*** @ingroup m17nCore */
326 /***en @defgroup m17nChartable Chartable */
327 /***ja @defgroup m17nChartable Ê¸»ú¥Æ¡¼¥Ö¥ë */
328 /*=*/
329 extern MSymbol Mchar_table;
330
331 /***
332     @ingroup m17nChartable */
333 /***en
334     @brief Type of chartables.
335
336     The type #MCharTable is for a @e chartable objects.  Its
337     internal structure is concealed from application programs.  */
338
339 /***ja
340     @brief Ê¸»ú¥Æ¡¼¥Ö¥ë¤Î·¿Àë¸À.
341
342     #MCharTable ¤Ï @e Ê¸»ú¥Æ¡¼¥Ö¥ë (chartable) ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
343     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
344
345 typedef struct MCharTable MCharTable;
346 /*=*/
347
348 extern MCharTable *mchartable (MSymbol key, void *default_value);
349
350 extern int mchartable_min_char (MCharTable *table);
351
352 extern int mchartable_max_char (MCharTable *table);
353
354 extern void *mchartable_lookup (MCharTable *table, int c);
355
356 extern int mchartable_set (MCharTable *table, int c, void *val);
357
358 extern int mchartable_set_range (MCharTable *table, int from, int to,
359                                  void *val);
360
361 extern int mchartable_map (MCharTable *table, void *ignore,
362                            void (*func) (int, int, void *, void *), 
363                            void *func_arg);
364
365 extern void mchartable_range (MCharTable *table, int *from, int *to);
366
367 extern MCharTable *mchar_get_prop_table (MSymbol key, MSymbol *type);
368
369 /*
370  *  (5) Handling M-text.
371  *      "M" of M-text stands for:
372  *      o Multilingual
373  *      o Metamorphic
374  *      o More than string
375  */
376
377 /*** @ingroup m17nCore */
378 /***en @defgroup m17nMtext M-text */
379 /***ja @defgroup m17nMtext M-text */
380 /*=*/
381
382 /*
383  * (5-1) M-text basics
384  */
385 /*=*/
386 /*** @ingroup m17nMtext */
387 /***en
388     @brief Type of @e M-texts.
389
390     The type #MText is for an @e M-text object.  Its internal
391     structure is concealed from application programs.  */
392
393 /***ja
394     @brief @e MText ¤Î·¿Àë¸À.
395
396     #Mtext ¤Ï @e M-text ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
397     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£ 
398
399     @latexonly \IPAlabel{MText} @endlatexonly
400     @latexonly \IPAlabel{MText->MPlist} @endlatexonly  */
401
402 typedef struct MText MText;
403
404 /*=*/
405
406 /*** @ingroup m17nMtext */
407 /***en
408     @brief Enumeration for specifying the format of an M-text.
409
410     The enum #MTextFormat is used as an argument of the
411     mtext_from_data () function to specify the format of data from
412     which an M-text is created.  */
413
414 /***ja
415     @brief M-text ¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤ò»ØÄꤹ¤ëÎóµó·¿.
416
417     Îóµó·¿ #MTextFormat ¤Ï´Ø¿ô
418     mtext_from_data () ¤Î°ú¿ô¤È¤·¤ÆÍѤ¤¤é¤ì¡¢
419     M-text ¤òÀ¸À®¤¹¤ë¸µ¤È¤Ê¤ë¥Ç¡¼¥¿¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤ò»ØÄꤹ¤ë¡£  */
420
421 enum MTextFormat
422   {
423     MTEXT_FORMAT_US_ASCII,
424     MTEXT_FORMAT_UTF_8,
425     MTEXT_FORMAT_UTF_16LE,
426     MTEXT_FORMAT_UTF_16BE,
427     MTEXT_FORMAT_UTF_32LE,
428     MTEXT_FORMAT_UTF_32BE,
429     MTEXT_FORMAT_MAX
430   };
431 /*=*/
432
433 extern MText *mtext ();
434
435 extern void *mtext_data (MText *mt, enum MTextFormat *fmt, int *nunits,
436                          int *pos_idx, int *unit_idx);
437
438 /*=*/
439
440 /***en @name Variables: Default Endian of UTF-16 and UTF-32 */
441 /***ja @name ÊÑ¿ô: UTF-16 ¤È UTF-32 ¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥¨¥ó¥Ç¥£¥¢¥ó */
442 /*** @{ */
443 /*=*/
444
445 /*** @ingroup m17nMtext */
446 /***en
447     @brief Variable of value MTEXT_FORMAT_UTF_16LE or MTEXT_FORMAT_UTF_16BE.
448
449     The global variable #MTEXT_FORMAT_UTF_16 is initialized to
450     #MTEXT_FORMAT_UTF_16LE on a "Little Endian" system (storing words
451     with the least significant byte first), and to
452     #MTEXT_FORMAT_UTF_16BE on a "Big Endian" system (storing words
453     with the most significant byte first).  */
454
455 /***ja
456     @brief Ãͤ¬ MTEXT_FORMAT_UTF_16LE ¤« MTEXT_FORMAT_UTF_16BE ¤Ç¤¢¤ëÊÑ¿ô
457
458     Âç°èÊÑ¿ô #MTEXT_FORMAT_UTF_16 ¤Ï¥ê¥È¥ë¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
459     ¡Ê¥ï¡¼¥É¤ò LSB (Least Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
460     #MTEXT_FORMAT_UTF_16LE ¤Ë½é´ü²½¤µ¤ì¡¢¥Ó¥Ã¥°¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
461     ¡Ê¥ï¡¼¥É¤ò MSB (Most Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
462     #MTEXT_FORMAT_UTF_16BE ¤Ë½é´ü²½¤µ¤ì¤ë¡£  */
463
464 /***
465     @seealso
466     mtext_from_data ()  */
467
468 extern const enum MTextFormat MTEXT_FORMAT_UTF_16;
469 /*=*/
470
471 /*** @ingroup m17nMtext */
472 /***en
473     @brief Variable of value MTEXT_FORMAT_UTF_32LE or MTEXT_FORMAT_UTF_32BE.
474
475     The global variable #MTEXT_FORMAT_UTF_32 is initialized to
476     #MTEXT_FORMAT_UTF_32LE on a "Little Endian" system (storing words
477     with the least significant byte first), and to
478     #MTEXT_FORMAT_UTF_32BE on a "Big Endian" system (storing
479     words with the most significant byte first).  */
480
481 /***ja
482     @brief Ãͤ¬ MTEXT_FORMAT_UTF_32LE ¤« MTEXT_FORMAT_UTF_32BE ¤Ç¤¢¤ëÊÑ¿ô
483
484     Âç°èÊÑ¿ô #MTEXT_FORMAT_UTF_32 ¤Ï¥ê¥È¥ë¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
485     ¡Ê¥ï¡¼¥É¤ò LSB (Least Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
486     #MTEXT_FORMAT_UTF_32LE ¤Ë½é´ü²½¤µ¤ì¡¢¥Ó¥Ã¥°¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
487     ¡Ê¥ï¡¼¥É¤ò MSB (Most Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
488     #MTEXT_FORMAT_UTF_32BE ¤Ë½é´ü²½¤µ¤ì¤ë¡£  */
489
490 /***
491     @seealso
492     mtext_from_data ()  */
493
494 extern const int MTEXT_FORMAT_UTF_32;
495
496 /*=*/
497 /*** @} */
498 /*=*/
499
500 extern MText *mtext_from_data (const void *data, int nitems,
501                                enum MTextFormat format);
502
503 /*=*/
504 /*** @} */
505
506 extern MSymbol Mlanguage;
507
508 /*
509  *  (5-2) Functions to manipulate M-texts.  They correspond to string
510  *   manipulating functions in libc.
511  *   In the following functions, mtext_XXX() corresponds to strXXX().
512  */
513
514 extern int mtext_len (MText *mt);
515
516 extern int mtext_ref_char (MText *mt, int pos);
517
518 extern int mtext_set_char (MText *mt, int pos, int c);
519
520 extern MText *mtext_copy (MText *mt1, int pos, MText *mt2, int from, int to);
521
522 extern int mtext_compare (MText *mt1, int from1, int to1,
523                           MText *mt2, int from2, int to2);
524
525 extern int mtext_case_compare (MText *mt1, int from1, int to1,
526                                MText *mt2, int from2, int to2);
527
528 extern int mtext_character (MText *mt, int from, int to, int c);
529
530 extern int mtext_del (MText *mt, int from, int to);
531
532 extern int mtext_ins (MText *mt1, int pos, MText *mt2);
533
534 extern int mtext_insert (MText *mt1, int pos, MText *mt2, int from, int to);
535
536 extern int mtext_ins_char (MText *mt, int pos, int c, int n);
537
538 extern int mtext_replace (MText *mt1, int from1, int to1,
539                           MText *mt2, int from2, int to2);
540
541 extern MText *mtext_cat_char (MText *mt, int c);
542
543 extern MText *mtext_duplicate (MText *mt, int from, int to);
544
545 extern MText *mtext_dup (MText *mt);
546
547 extern MText *mtext_cat (MText *mt1, MText *mt2);
548
549 extern MText *mtext_ncat (MText *mt1, MText *mt2, int n);
550
551 extern MText *mtext_cpy (MText *mt1, MText *mt2);
552
553 extern MText *mtext_ncpy (MText *mt1, MText *mt2, int n);
554
555 extern int mtext_chr (MText *mt, int c);
556
557 extern int mtext_rchr (MText *mt, int c);
558
559 extern int mtext_cmp (MText *mt1, MText *mt2);
560
561 extern int mtext_ncmp (MText *mt1, MText *mt2, int n);
562
563 extern int mtext_spn (MText *mt1, MText *mt2);
564
565 extern int mtext_cspn (MText *mt1, MText *mt2);
566
567 extern int mtext_pbrk (MText *mt1, MText *mt2);
568
569 extern int mtext_text (MText *mt1, int pos, MText *mt2);
570
571 extern int mtext_search (MText *mt1, int from, int to, MText *mt2);
572
573 extern MText *mtext_tok (MText *mt, MText *delim, int *pos);
574
575 extern int mtext_casecmp (MText *mt1, MText *mt2);
576
577 extern int mtext_ncasecmp (MText *mt1, MText *mt2, int n);
578
579 extern int mtext_lowercase (MText *mt);
580
581 extern int mtext_titlecase (MText *mt);
582
583 extern int mtext_uppercase (MText *mt);
584
585 /***en
586     @brief Enumeration for specifying a set of line breaking option.
587
588     The enum #MTextLineBreakOption is to control the line breaking
589     algorithm of the function mtext_line_break () by specifying
590     logical-or of the members in the arg @e option.  */
591
592 enum MTextLineBreakOption
593   {
594     /***en Specify the legacy support for space character as base for
595        combining marks.  See the section 8.3 of UAX#14. */
596     MTEXT_LBO_SP_CM = 1,
597     /***en Specify to use space characters for line breaking Korean
598         text.  */
599     MTEXT_LBO_KOREAN_SP = 2,
600     /***en Specify to treat characters of ambiguous line-breaking
601         class as of ideographic line-breaking class.  */
602     MTEXT_LBO_AI_AS_ID = 4,
603     MTEXT_LBO_MAX
604   };
605
606 extern int mtext_line_break (MText *mt, int pos, int option, int *after);
607
608 /*** @ingroup m17nPlist */
609 extern MPlist *mplist_deserialize (MText *mt);
610
611 /*
612  * (5-3) Text properties
613  */
614 /*=*/
615 /*** @ingroup m17nCore */
616 /***en @defgroup m17nTextProperty Text Property */
617 /***ja @defgroup m17nTextProperty ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£ */
618 /*=*/
619 /*** @ingroup m17nTextProperty */
620 /***en
621     @brief Flag bits to control text property.
622
623     The mtext_property () function accepts logical OR of these flag
624     bits as an argument.  They control the behaviour of the created
625     text property as described in the documentation of each flag
626     bit.  */
627
628 /***ja
629     @brief ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤òÀ©¸æ¤¹¤ë¥Õ¥é¥°¥Ó¥Ã¥È.
630
631     ´Ø¿ô mtext_property () ¤Ï°Ê²¼¤Î¥Õ¥é¥°¥Ó¥Ã¥È¤ÎÏÀÍý
632     OR ¤ò°ú¿ô¤È¤·¤Æ¤È¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
633     ¥Õ¥é¥°¥Ó¥Ã¥È¤ÏÀ¸À®¤µ¤ì¤¿¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î¿¶Éñ¤¤¤òÀ©¸æ¤¹¤ë¡£
634     ¾ÜºÙ¤Ï³Æ¥Õ¥é¥°¥Ó¥Ã¥È¤ÎÀâÌÀ¤ò»²¾È¡£*/
635
636 enum MTextPropertyControl
637   {
638     /***en If this flag bit is on, an M-text inserted at the start
639         position or at the middle of the text property inherits the
640         text property.  */
641     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î»Ï¤Þ¤ëÅÀ¤¢¤ë¤¤¤ÏÃæ´Ö¤ËÁÞÆþ¤µ¤ì¤¿
642         M-text ¤Ï¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ò·Ñ¾µ¤¹¤ë¡£
643         */
644     MTEXTPROP_FRONT_STICKY = 0x01,
645
646     /***en If this flag bit is on, an M-text inserted at the end
647         position or at the middle of the text property inherits the
648         text property.  */
649     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î½ª¤ï¤ëÅÀ¤¢¤ë¤¤¤ÏÃæ´Ö¤ËÁÞÆþ¤µ¤ì¤¿
650         M-text ¤Ï¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ò·Ñ¾µ¤¹¤ë¡£
651         */
652     MTEXTPROP_REAR_STICKY = 0x02,
653
654     /***en If this flag bit is on, the text property is removed if a
655         text in its region is modified.  */
656     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ÎÈÏ°ÏÆâ¤Î¥Æ¥­¥¹¥È¤¬Êѹ¹¤µ¤ì¤¿¾ì¹ç¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¼è¤ê½ü¤«¤ì¤ë¡£  */
657     MTEXTPROP_VOLATILE_WEAK = 0x04,
658
659     /***en If this flag bit is on, the text property is removed if a
660         text or the other text property in its region is modified.  */
661     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ÎÈÏ°ÏÆâ¤Î¥Æ¥­¥¹¥È¤¢¤ë¤¤¤ÏÊ̤Υƥ­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤¬Êѹ¹¤µ¤ì¤¿¾ì¹ç¤³¤Î¥Æ¥­
662         ¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¼è¤ê½ü¤«¤ì¤ë¡£*/
663     MTEXTPROP_VOLATILE_STRONG = 0x08,
664
665     /***en If this flag bit is on, the text property is not
666         automatically merged with the others.  */
667     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¾¤Î¥×¥í¥Ñ¥Æ¥£¤È¼«Æ°Åª¤Ë¤Ï¥Þ¡¼¥¸¤µ¤ì¤Ê¤¤¡£ */
668     MTEXTPROP_NO_MERGE = 0x10,
669
670     MTEXTPROP_CONTROL_MAX = 0x1F
671   };
672
673 /*=*/
674 extern MSymbol Mtext_prop_serializer;
675 extern MSymbol Mtext_prop_deserializer;
676
677
678 /*** @ingroup m17nTextProperty */
679 /***en
680     @brief Type of serializer functions.
681
682     This is the type of serializer functions.  If the key of a symbol
683     property is #Mtext_prop_serializer, the value must be of this
684     type.
685
686     @seealso
687     mtext_serialize (), #Mtext_prop_serializer
688 */
689 /***ja
690     @brief ¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿Àë¸À.
691
692     ¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿¤Ç¤¢¤ë¡£ ¤¢¤ë¥·¥ó¥Ü¥ë¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤¬ @c
693     #Mtext_prop_serializer ¤Ç¤¢¤ë¤È¤­¡¢ ÃͤϤ³¤Î·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
694
695     @seealso
696     mtext_serialize (), #Mtext_prop_serializer
697 */
698
699 typedef MPlist *(*MTextPropSerializeFunc) (void *val);
700
701 /*** @ingroup m17nTextProperty */
702 /***en
703     @brief Type of deserializer functions.
704
705     This is the type of deserializer functions.  If the key of a
706     symbol property is #Mtext_prop_deserializer, the value must be of
707     this type.
708
709     @seealso
710     mtext_deserialize (), #Mtext_prop_deserializer
711 */
712 /***ja
713     @brief ¥Ç¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿Àë¸À.
714
715     ¥Ç¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿¤Ç¤¢¤ë¡£ ¤¢¤ë¥·¥ó¥Ü¥ë¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤¬ @c
716     #Msymbol_prop_deserializer ¤Ç¤¢¤ë¤È¤­¡¢ ÃͤϤ³¤Î·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
717
718     @seealso
719     Mtext_prop_deserialize (), Mtext_prop_deserializer
720 */
721 typedef void *(*MTextPropDeserializeFunc) (MPlist *plist);
722
723 extern void *mtext_get_prop (MText *mt, int pos, MSymbol key);
724
725 extern int mtext_get_prop_values (MText *mt, int pos, MSymbol key,
726                                   void **values, int num);
727
728 extern int mtext_get_prop_keys (MText *mt, int pos, MSymbol **keys);
729
730 extern int mtext_put_prop (MText *mt, int from, int to,
731                            MSymbol key, void *val);
732
733 extern int mtext_put_prop_values (MText *mt, int from, int to,
734                                   MSymbol key, void **values, int num);
735
736 extern int mtext_push_prop (MText *mt, int from, int to,
737                             MSymbol key, void *val);
738
739 extern int mtext_pop_prop (MText *mt, int from, int to,
740                            MSymbol key);
741
742 extern int mtext_prop_range (MText *mt, MSymbol key, int pos,
743                              int *from, int *to, int deeper);
744
745 /*=*/
746 /***
747     @ingroup m17nTextProperty */
748 /***en
749     @brief Type of text properties.
750
751     The type #MTextProperty is for a @e text @e property objects.  Its
752     internal structure is concealed from application programs.  */
753 /***ja
754     @brief @c ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î·¿Àë¸À.
755
756     #MTextProperty ¤Ï @e ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£ ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
757     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
758
759 typedef struct MTextProperty MTextProperty;
760
761 /*=*/
762
763 extern MTextProperty *mtext_property (MSymbol key, void *val,
764                                       int control_bits);
765
766 extern MText *mtext_property_mtext (MTextProperty *prop);
767
768 extern MSymbol mtext_property_key (MTextProperty *prop);
769
770 extern void *mtext_property_value (MTextProperty *prop);
771
772 extern int mtext_property_start (MTextProperty *prop);
773
774 extern int mtext_property_end (MTextProperty *prop);
775
776 extern MTextProperty *mtext_get_property (MText *mt, int pos, MSymbol key);
777
778 extern int mtext_get_properties (MText *mt, int pos, MSymbol key,
779                                  MTextProperty **props, int num);
780
781 extern int mtext_attach_property (MText *mt, int from, int to,
782                                   MTextProperty *prop);
783
784 extern int mtext_detach_property (MTextProperty *prop);
785
786 extern int mtext_push_property (MText *mt, int from, int to,
787                                 MTextProperty *prop);
788
789 extern MText *mtext_serialize (MText *mt, int from, int to,
790                                MPlist *property_list);
791
792 extern MText *mtext_deserialize (MText *mt);
793
794 /*** @ingroup m17nCore */
795 /***en @defgroup m17nDatabase Database */
796 /***ja @defgroup m17nDatabase ¥Ç¡¼¥¿¥Ù¡¼¥¹ */
797 /*=*/
798
799 /* Directory of an application specific databases.  */
800 extern char *mdatabase_dir;
801 /*=*/
802 /***
803     @ingroup m17nDatabase  */ 
804 /***en
805     @brief Type of database.
806
807     The type #MDatabase is for a database object.  Its internal
808     structure is concealed from an application program.  */
809 /***ja 
810     @brief ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î·¿Àë¸À.
811
812     #MDatabase ·¿¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¥ª¥Ö¥¸¥§¥¯¥ÈÍѤι½Â¤ÂΤǤ¢¤ë¡£
813     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£
814     */
815
816 typedef struct MDatabase MDatabase;
817
818 /*=*/
819
820 /* Look for a data.  */
821 extern MDatabase *mdatabase_find (MSymbol tag1, MSymbol tag2,
822                                   MSymbol tag3, MSymbol tag4);
823
824 extern MPlist *mdatabase_list (MSymbol tag0, MSymbol tag1,
825                                MSymbol tag2, MSymbol tag3);
826
827 /* Load a data.  */
828 void *mdatabase_load (MDatabase *mdb);
829
830 /* Get tags of a data.  */
831 extern MSymbol *mdatabase_tag (MDatabase *mdb);
832
833 /* Define a data.  */
834 extern MDatabase *mdatabase_define (MSymbol tag1, MSymbol tag2,
835                                     MSymbol tag3, MSymbol tag4,
836                                     void *(*loader) (MSymbol *, void *),
837                                     void *extra_info);
838
839 M17N_END_HEADER
840
841 #endif /* _M17N_CORE_H_ */
842
843 /*
844   Local Variables:
845   coding: euc-japan
846   End:
847 */