1 /* AbiWord
2 * Copyright (C) 2001 Dom Lachowicz <dominicl@seas.upenn.edu>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #include "ie_imp_WML.h"
21 #include "ie_exp_WML.h"
22 #include "xap_Module.h"
23
24 #ifdef ABI_PLUGIN_BUILTIN
25 #define abi_plugin_register abipgn_wml_register
26 #define abi_plugin_unregister abipgn_wml_unregister
27 #define abi_plugin_supports_version abipgn_wml_supports_version
28 // dll exports break static linking
29 #define ABI_BUILTIN_FAR_CALL extern "C"
30 #else
31 #define ABI_BUILTIN_FAR_CALL ABI_FAR_CALL
32 ABI_PLUGIN_DECLARE("WML")
33 #endif
34
35 #define PLUGIN_NAME "AbiWML::WML"
36
37 // we use a reference-counted sniffer
38 static IE_Imp_WML_Sniffer * m_impSniffer = 0;
39 static IE_Exp_WML_Sniffer * m_expSniffer = 0;
40
41 ABI_BUILTIN_FAR_CALL
abi_plugin_register(XAP_ModuleInfo * mi)42 int abi_plugin_register (XAP_ModuleInfo * mi)
43 {
44
45 if (!m_impSniffer)
46 {
47 m_impSniffer = new IE_Imp_WML_Sniffer (PLUGIN_NAME);
48 }
49
50 if (!m_expSniffer)
51 {
52 m_expSniffer = new IE_Exp_WML_Sniffer (PLUGIN_NAME);
53 }
54
55 mi->name = "WML Importer";
56 mi->desc = "Import/Export WML Documents";
57 mi->version = ABI_VERSION_STRING;
58 mi->author = "Abi the Ant";
59 mi->usage = "No Usage";
60
61 IE_Imp::registerImporter (m_impSniffer);
62 IE_Exp::registerExporter (m_expSniffer);
63 return 1;
64 }
65
66 ABI_BUILTIN_FAR_CALL
abi_plugin_unregister(XAP_ModuleInfo * mi)67 int abi_plugin_unregister (XAP_ModuleInfo * mi)
68 {
69 mi->name = 0;
70 mi->desc = 0;
71 mi->version = 0;
72 mi->author = 0;
73 mi->usage = 0;
74
75 UT_ASSERT (m_impSniffer);
76 UT_ASSERT (m_expSniffer);
77
78 IE_Imp::unregisterImporter (m_impSniffer);
79 delete m_impSniffer;
80 m_impSniffer = 0;
81
82 IE_Exp::unregisterExporter (m_expSniffer);
83 delete m_expSniffer;
84 m_expSniffer = 0;
85
86 return 1;
87 }
88
89 ABI_BUILTIN_FAR_CALL
abi_plugin_supports_version(UT_uint32,UT_uint32,UT_uint32)90 int abi_plugin_supports_version (UT_uint32 /*major*/, UT_uint32 /*minor*/,
91 UT_uint32 /*release*/)
92 {
93 return 1;
94 }
95