Use pkg-config (if available) for Xft.
[m17n/m17n-lib.git] / src / m17n.c
1 /* m17n.c -- body of the SHELL 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 #include <config.h>
24 #include <stdio.h>
25
26 #include "m17n.h"
27 #include "m17n-misc.h"
28 #include "internal.h"
29 #include "charset.h"
30 #include "coding.h"
31
32 static int shell_initialized;
33
34 \f
35 /* Internal API */
36
37 \f
38 /* External API */
39
40 void
41 m17n_init (void)
42 {
43   int mdebug_mask = MDEBUG_INIT;
44
45   if (shell_initialized++)
46     return;
47   m17n_init_core ();
48   if (merror_code != MERROR_NONE)
49     return;
50   MDEBUG_PUSH_TIME ();
51   MDEBUG_PUSH_TIME ();
52   if (mcharset__init () < 0)
53     goto err;
54   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize charset module."));
55   if (mcoding__init () < 0)
56     goto err;
57   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize conv module."));
58   if (mdatabase__init () < 0)
59     goto err;
60   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize database module."));
61   if (mcharset__load_from_database () < 0)
62     goto err;
63   MDEBUG_PRINT_TIME ("INIT", (stderr, " to load charset definitions."));
64   if (mcoding__load_from_database () < 0)
65     goto err;
66   MDEBUG_PRINT_TIME ("INIT", (stderr, " to load coding definitions."));
67   if (mchar__init () < 0)
68     goto err;
69   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize character module."));
70   if (mlang__init () < 0)
71     goto err;
72   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize language module"));
73   if (mlocale__init () < 0)
74     goto err;
75   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize locale module."));
76   if (minput__init () < 0)
77     goto err;
78   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize input module."));
79
80  err:
81   MDEBUG_POP_TIME ();
82   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize the shell modules."));
83   MDEBUG_POP_TIME ();
84 }
85
86 void
87 m17n_fini (void)
88 {
89   int mdebug_mask = MDEBUG_FINI;
90
91   if (shell_initialized > 1)
92     shell_initialized--;
93   else
94     {
95       shell_initialized = 0;
96       MDEBUG_PUSH_TIME ();
97       MDEBUG_PUSH_TIME ();
98       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize input module."));
99       minput__fini ();
100       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize locale module."));
101       mlocale__fini ();
102       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize language module."));
103       mlang__fini ();
104       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize character module."));
105       mchar__fini ();
106       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize database module."));
107       mdatabase__fini ();
108       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize coding module."));
109       mcoding__fini ();
110       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize charset module."));
111       mcharset__fini ();
112       MDEBUG_POP_TIME ();
113       MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the shell modules."));
114       MDEBUG_POP_TIME ();
115     }
116   m17n_fini_core ();
117 }
118
119 /*
120   Local Variables:
121   coding: euc-japan
122   End:
123 */