Polish translation was updated.
[elinks.git] / src / main / module.c
blob3d0ebb865a3bf63ff1c7e15e5e690da0ad9afdc6
1 /* General module system functionality */
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
7 #include "elinks.h"
9 #include "config/options.h"
10 #include "main/module.h"
13 /* Dynamic area: */
15 #include "bfu/dialog.h"
16 #include "bookmarks/bookmarks.h"
17 #include "config/kbdbind.h"
18 #include "config/timer.h"
19 #include "config/urlhist.h"
20 #include "cookies/cookies.h"
21 #include "dialogs/exmode.h"
22 #include "document/css/css.h"
23 #include "document/document.h"
24 #include "ecmascript/ecmascript.h"
25 #include "formhist/formhist.h"
26 #include "globhist/globhist.h"
27 #include "mime/mime.h"
28 #include "network/ssl/ssl.h"
29 #include "protocol/protocol.h"
30 #include "scripting/scripting.h"
31 #include "terminal/terminal.h"
32 #include "viewer/viewer.h"
35 struct module *main_modules[] = {
36 &document_module,
37 &kbdbind_module,
38 &terminal_module,
39 NULL /* XXX: Keep this */
42 /* This is also used for version string composing so keep NULL terminated */
43 struct module *builtin_modules[] = {
44 &periodic_saving_module,
45 &viewer_module,
46 #ifdef CONFIG_CSS
47 &css_module,
48 #endif
49 &protocol_module,
50 #ifdef CONFIG_SSL
51 &ssl_module,
52 #endif
53 &mime_module,
54 #ifdef CONFIG_LEDS
55 &leds_module,
56 #endif
57 #ifdef CONFIG_BOOKMARKS
58 &bookmarks_module,
59 #endif
60 #ifdef CONFIG_COOKIES
61 &cookies_module,
62 #endif
63 #ifdef CONFIG_ECMASCRIPT
64 &ecmascript_module,
65 #endif
66 #ifdef CONFIG_FORMHIST
67 &forms_history_module,
68 #endif
69 #ifdef CONFIG_GLOBHIST
70 &global_history_module,
71 #endif
72 #ifdef CONFIG_SCRIPTING
73 &scripting_module,
74 #endif
75 #ifdef CONFIG_EXMODE
76 &exmode_module,
77 #endif
78 &goto_url_history_module,
79 NULL
82 /* Interface for handling single modules. */
84 void
85 register_module_options(struct module *module)
87 struct module *submodule;
88 int i;
90 if (module->options) register_options(module->options, config_options);
92 foreach_module (submodule, module->submodules, i) {
93 register_module_options(submodule);
97 void
98 unregister_module_options(struct module *module)
100 struct module *submodule;
101 int i;
103 /* First knock out the submodules if any. */
104 foreachback_module (submodule, module->submodules, i)
105 unregister_module_options(submodule);
107 if (module->options) unregister_options(module->options, config_options);
110 void
111 init_module(struct module *module)
113 struct module *submodule;
114 int i;
116 if (module->init) module->init(module);
117 if (module->hooks) register_event_hooks(module->hooks);
119 foreach_module (submodule, module->submodules, i) {
120 init_module(submodule);
124 void
125 done_module(struct module *module)
127 struct module *submodule;
128 int i;
130 /* First knock out the submodules if any. */
131 foreachback_module (submodule, module->submodules, i)
132 done_module(submodule);
134 if (module->hooks) unregister_event_hooks(module->hooks);
135 if (module->done) module->done(module);
138 /* Interface for handling builtin modules. */
140 void
141 register_modules_options(struct module *modules[])
143 struct module *module;
144 int i;
146 foreach_module (module, modules, i) {
147 register_module_options(module);
151 void
152 unregister_modules_options(struct module *modules[])
154 struct module *module;
155 int i;
157 /* Cleanups backward to initialization. */
158 foreachback_module (module, modules, i)
159 unregister_module_options(module);
162 /* TODO: We probably need to have two builtin module tables one for critical
163 * modules that should always be used and one for optional (the ones controlled
164 * by init_b in main.c */
166 void
167 init_modules(struct module *modules[])
169 struct module *module;
170 int i;
172 foreach_module (module, modules, i) {
173 init_module(module);
177 void
178 done_modules(struct module *modules[])
180 struct module *module;
181 int i;
183 /* Cleanups backward to initialization. */
184 foreachback_module (module, modules, i)
185 done_module(module);