Include <sys/types.h> and fix compilation on an old PPC/Debian system
[elinks/images.git] / src / main / module.c
blob4988bbd0b64b87d33df20c0c964d9785e1cd91bd
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/timer.h"
18 #include "config/urlhist.h"
19 #include "cookies/cookies.h"
20 #include "dialogs/exmode.h"
21 #include "document/css/css.h"
22 #include "document/document.h"
23 #include "ecmascript/ecmascript.h"
24 #include "formhist/formhist.h"
25 #include "globhist/globhist.h"
26 #include "mime/mime.h"
27 #include "network/ssl/ssl.h"
28 #include "protocol/protocol.h"
29 #include "scripting/scripting.h"
30 #include "viewer/text/search.h"
31 #include "viewer/timer.h"
34 struct module *main_modules[] = {
35 &document_module,
36 NULL /* XXX: Keep this */
39 /* This is also used for version string composing so keep NULL terminated */
40 struct module *builtin_modules[] = {
41 &periodic_saving_module,
42 &timer_module,
43 #ifdef CONFIG_CSS
44 &css_module,
45 #endif
46 &protocol_module,
47 #ifdef CONFIG_SSL
48 &ssl_module,
49 #endif
50 &mime_module,
51 #ifdef CONFIG_LEDS
52 &leds_module,
53 #endif
54 #ifdef CONFIG_BOOKMARKS
55 &bookmarks_module,
56 #endif
57 #ifdef CONFIG_COOKIES
58 &cookies_module,
59 #endif
60 #ifdef CONFIG_ECMASCRIPT
61 &ecmascript_module,
62 #endif
63 #ifdef CONFIG_FORMHIST
64 &forms_history_module,
65 #endif
66 #ifdef CONFIG_GLOBHIST
67 &global_history_module,
68 #endif
69 #ifdef CONFIG_SCRIPTING
70 &scripting_module,
71 #endif
72 #ifdef CONFIG_EXMODE
73 &exmode_module,
74 #endif
75 &goto_url_history_module,
76 &search_history_module,
77 NULL
80 /* Interface for handling single modules. */
82 void
83 register_module_options(struct module *module)
85 struct module *submodule;
86 int i;
88 if (module->options) register_options(module->options, config_options);
90 foreach_module (submodule, module->submodules, i) {
91 register_module_options(submodule);
95 void
96 unregister_module_options(struct module *module)
98 struct module *submodule;
99 int i;
101 /* First knock out the submodules if any. */
102 foreachback_module (submodule, module->submodules, i)
103 unregister_module_options(submodule);
105 if (module->options) unregister_options(module->options, config_options);
108 void
109 init_module(struct module *module)
111 struct module *submodule;
112 int i;
114 if (module->init) module->init(module);
115 if (module->hooks) register_event_hooks(module->hooks);
117 foreach_module (submodule, module->submodules, i) {
118 init_module(submodule);
122 void
123 done_module(struct module *module)
125 struct module *submodule;
126 int i;
128 /* First knock out the submodules if any. */
129 foreachback_module (submodule, module->submodules, i)
130 done_module(submodule);
132 if (module->hooks) unregister_event_hooks(module->hooks);
133 if (module->done) module->done(module);
136 /* Interface for handling builtin modules. */
138 void
139 register_modules_options(struct module *modules[])
141 struct module *module;
142 int i;
144 foreach_module (module, modules, i) {
145 register_module_options(module);
149 void
150 unregister_modules_options(struct module *modules[])
152 struct module *module;
153 int i;
155 /* Cleanups backward to initialization. */
156 foreachback_module (module, modules, i)
157 unregister_module_options(module);
160 /* TODO: We probably need to have two builtin module tables one for critical
161 * modules that should always be used and one for optional (the ones controlled
162 * by init_b in main.c */
164 void
165 init_modules(struct module *modules[])
167 struct module *module;
168 int i;
170 foreach_module (module, modules, i) {
171 init_module(module);
175 void
176 done_modules(struct module *modules[])
178 struct module *module;
179 int i;
181 /* Cleanups backward to initialization. */
182 foreachback_module (module, modules, i)
183 done_module(module);