(parse_otf_command): Fix previous change.
[m17n/m17n-lib.git] / src / m17n.c
1 /* m17n.c -- body of the SHELL API.
2    Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
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 #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 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
33
34 \f
35 /* Internal API */
36
37 \f
38 /* External API */
39
40 void
41 m17n_init (void)
42 {
43   int mdebug_flag = MDEBUG_INIT;
44
45   merror_code = MERROR_NONE;
46   if (m17n__shell_initialized++)
47     return;
48   m17n_init_core ();
49   if (merror_code != MERROR_NONE)
50     {
51       m17n__shell_initialized--;
52       return;
53     }
54   MDEBUG_PUSH_TIME ();
55   MDEBUG_PUSH_TIME ();
56   if (mcharset__init () < 0)
57     goto err;
58   MDEBUG_PRINT_TIME ("INIT",
59                      (mdebug__output, " to initialize charset module."));
60   if (mcoding__init () < 0)
61     goto err;
62   MDEBUG_PRINT_TIME ("INIT", (mdebug__output, " to initialize conv module."));
63   if (mcharset__load_from_database () < 0)
64     goto err;
65   MDEBUG_PRINT_TIME ("INIT", (mdebug__output, " to load charset definitions."));
66   if (mcoding__load_from_database () < 0)
67     goto err;
68   MDEBUG_PRINT_TIME ("INIT", (mdebug__output, " to load coding definitions."));
69   if (mlang__init () < 0)
70     goto err;
71   MDEBUG_PRINT_TIME ("INIT",
72                      (mdebug__output, " to initialize language module"));
73   if (mlocale__init () < 0)
74     goto err;
75   MDEBUG_PRINT_TIME ("INIT", (mdebug__output, " to initialize locale module."));
76   if (minput__init () < 0)
77     goto err;
78   MDEBUG_PRINT_TIME ("INIT", (mdebug__output, " to initialize input module."));
79
80  err:
81   MDEBUG_POP_TIME ();
82   MDEBUG_PRINT_TIME ("INIT",
83                      (mdebug__output, " to initialize the shell modules."));
84   MDEBUG_POP_TIME ();
85 }
86
87 void
88 m17n_fini (void)
89 {
90   int mdebug_flag = MDEBUG_FINI;
91
92   if (m17n__shell_initialized == 0
93       || --m17n__shell_initialized > 0)
94     return;
95
96   MDEBUG_PUSH_TIME ();
97   MDEBUG_PUSH_TIME ();
98   minput__fini ();
99   MDEBUG_PRINT_TIME ("FINI", (mdebug__output, " to finalize input module."));
100   mlocale__fini ();
101   MDEBUG_PRINT_TIME ("FINI", (mdebug__output, " to finalize locale module."));
102   mlang__fini ();
103   MDEBUG_PRINT_TIME ("FINI", (mdebug__output, " to finalize language module."));
104   mchar__fini ();
105   MDEBUG_PRINT_TIME ("FINI",
106                      (mdebug__output, " to finalize character module."));
107   mdatabase__fini ();
108   MDEBUG_PRINT_TIME ("FINI",
109                      (mdebug__output, " to finalize database module."));
110   mcoding__fini ();
111   MDEBUG_PRINT_TIME ("FINI",
112                      (mdebug__output, " to finalize coding module."));
113   mcharset__fini ();
114   MDEBUG_PRINT_TIME ("FINI",
115                      (mdebug__output, " to finalize charset module."));
116   MDEBUG_POP_TIME ();
117   MDEBUG_PRINT_TIME ("FINI",
118                      (mdebug__output, " to finalize the shell modules."));
119   MDEBUG_POP_TIME ();
120   m17n_fini_core ();
121 }
122
123 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
124
125 /*
126   Local Variables:
127   coding: euc-japan
128   End:
129 */