Mercurial > hg
annotate mcabber/mcabber/modules.c @ 2036:f8958ab545ac
Make message delivery receipts more backward-compatible
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 15 Oct 2012 19:53:02 +0200 |
parents | 78616d66a7f2 |
children | f5402d705f67 |
rev | line source |
---|---|
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
1 /* |
1828
8f7d7c05f275
Small coding style update
Mikael Berthe <mikael@lilotux.net>
parents:
1822
diff
changeset
|
2 * modules.c -- Modules handling |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
3 * |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
4 * Copyright (C) 2010 Myhailo Danylenko <isbear@ukrpost.net> |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
5 * |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or (at |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
9 * your option) any later version. |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
10 * |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, but |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
12 * WITHOUT ANY WARRANTY; without even the implied warranty of |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
14 * General Public License for more details. |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
15 * |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
19 * USA |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
20 */ |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
21 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
22 #include <glib.h> |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
23 #include <gmodule.h> |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
24 #include <string.h> |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
25 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
26 #include "settings.h" |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
27 #include "config.h" |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
28 #include "modules.h" |
1773
553e7aa88c9f
Set the message flag for /module info output
Mikael Berthe <mikael@lilotux.net>
parents:
1771
diff
changeset
|
29 #include "screen.h" |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
30 #include "utils.h" |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
31 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
32 // Registry of loaded modules |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
33 GSList *loaded_modules = NULL; |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
34 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
35 const gchar *mcabber_branch = MCABBER_BRANCH; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
36 const guint mcabber_api_version = MCABBER_API_VERSION; |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
37 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
38 static gint module_list_comparator(gconstpointer arg1, gconstpointer arg2) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
39 { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
40 const loaded_module_t *module = arg1; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
41 const char *name = arg2; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
42 return g_strcmp0(module->name, name); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
43 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
44 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
45 // module_load(modulename, manual, force) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
46 // Tries to load specified module and any modules, that this module |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
47 // depends on. Returns NULL on success or constant error string in a |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
48 // case of error. Error message not necessarily indicates error. |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
49 const gchar *module_load(const gchar *arg, gboolean manual, gboolean force) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
50 { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
51 GModule *mod; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
52 module_info_t *info; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
53 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
54 if (!arg || !*arg) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
55 return "Missing module name"; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
56 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
57 { // Check if module is already loaded |
1736
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
58 GSList *lmod = g_slist_find_custom(loaded_modules, arg, |
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
59 module_list_comparator); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
60 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
61 if (lmod) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
62 loaded_module_t *module = lmod->data; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
63 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
64 if (manual) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
65 if (!module->locked) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
66 module->locked = TRUE; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
67 module->refcount += 1; |
1736
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
68 return force ? NULL : "Module is already automatically loaded, " |
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
69 "marked as manually loaded"; |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
70 } else |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
71 return force ? NULL : "Module is already loaded"; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
72 } else { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
73 module->refcount += 1; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
74 return NULL; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
75 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
76 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
77 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
78 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
79 { // Load module |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
80 gchar *mdir = expand_filename(settings_opt_get("modules_dir")); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
81 gchar *path = g_module_build_path(mdir ? mdir : PKGLIB_DIR, arg); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
82 g_free(mdir); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
83 mod = g_module_open(path, G_MODULE_BIND_LAZY); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
84 g_free(path); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
85 if (!mod) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
86 return g_module_error(); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
87 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
88 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
89 { // Obtain module information structures list |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
90 gchar *varname = g_strdup_printf("info_%s", arg); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
91 gpointer var = NULL; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
92 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
93 // convert to a valid symbol name |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
94 g_strcanon(varname, "abcdefghijklmnopqrstuvwxyz0123456789", '_'); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
95 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
96 if (!g_module_symbol(mod, varname, &var)) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
97 if (!force) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
98 g_free(varname); |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
99 if(!g_module_close(mod)) |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
100 scr_LogPrint(LPRINT_LOGNORM, "Error closing module: %s.", |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
101 g_module_error()); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
102 return "Module provides no information structure"; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
103 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
104 |
1736
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
105 scr_LogPrint(LPRINT_LOGNORM, "Forced to ignore error: " |
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
106 "Module provides no information structure."); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
107 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
108 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
109 g_free(varname); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
110 info = var; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
111 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
112 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
113 // Find appropriate info struct |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
114 if (info) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
115 while (info) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
116 if (!info->branch || !*(info->branch)) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
117 scr_LogPrint(LPRINT_DEBUG, "No branch name, " |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
118 "skipping info chunk."); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
119 } else if (strcmp(info->branch, mcabber_branch)) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
120 scr_LogPrint(LPRINT_DEBUG, "Unhandled branch %s, " |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
121 "skipping info chunk.", info->branch); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
122 } else if (info->api > mcabber_api_version || |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
123 info->api < MCABBER_API_MIN) { // XXX force? |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
124 if(!g_module_close(mod)) |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
125 scr_LogPrint(LPRINT_LOGNORM, "Error closing module: %s.", |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
126 g_module_error()); |
1771
ffd0f245de40
Minor cosmetic change (api->API)
Mikael Berthe <mikael@lilotux.net>
parents:
1770
diff
changeset
|
127 return "Incompatible mcabber API version"; |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
128 } else |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
129 break; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
130 info = info->next; |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
131 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
132 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
133 if (!info) { // XXX force? |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
134 if(!g_module_close(mod)) |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
135 scr_LogPrint(LPRINT_LOGNORM, "Error closing module: %s.", |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
136 g_module_error()); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
137 return "No supported mcabber branch description found"; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
138 } |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
139 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
140 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
141 // Load dependencies |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
142 if (info && info->requires) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
143 const gchar **dep; |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
144 GSList *deps = NULL; |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
145 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
146 for (dep = info->requires; *dep; ++dep) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
147 const gchar *err = module_load(*dep, FALSE, FALSE); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
148 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
149 if (err) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
150 GSList *mel; |
1736
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
151 scr_LogPrint(LPRINT_LOGNORM, "Error loading dependency module %s: %s.", |
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
152 *dep, err); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
153 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
154 // Unload already loaded dependencies |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
155 for (mel = deps; mel; mel = mel->next) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
156 gchar *ldmname = mel->data; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
157 err = module_unload(ldmname, FALSE, FALSE); |
1736
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
158 scr_LogPrint(LPRINT_LOGNORM, |
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
159 "Error unloading dependency module %s: %s.", |
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
160 ldmname, err); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
161 g_free(ldmname); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
162 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
163 g_slist_free(deps); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
164 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
165 // Unload module |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
166 if (!g_module_close(mod)) |
1736
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
167 scr_LogPrint(LPRINT_LOGNORM, "Error unloading module %s: %s.", |
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
168 arg, g_module_error()); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
169 return "Dependency problems"; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
170 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
171 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
172 deps = g_slist_append(deps, (gpointer) *dep); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
173 } |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
174 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
175 g_slist_free(deps); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
176 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
177 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
178 { // Register module |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
179 loaded_module_t *module = g_new(loaded_module_t, 1); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
180 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
181 module->refcount = 1; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
182 module->locked = manual; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
183 module->name = g_strdup(arg); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
184 module->module = mod; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
185 module->info = info; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
186 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
187 loaded_modules = g_slist_prepend(loaded_modules, module); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
188 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
189 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
190 // Run initialization routine |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
191 if (info && info->init) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
192 info->init(); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
193 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
194 // XXX Run hk_loaded_module hook (and move this line there) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
195 scr_LogPrint(LPRINT_LOGNORM, "Loaded module %s.", arg); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
196 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
197 return NULL; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
198 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
199 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
200 // module_unload(modulename, manual, force) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
201 // Unload specified module and any automatically loaded modules |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
202 // that are no more required. |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
203 const gchar *module_unload(const gchar *arg, gboolean manual, gboolean force) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
204 { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
205 GSList *lmod; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
206 loaded_module_t *module; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
207 module_info_t *info; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
208 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
209 if (!arg || !*arg) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
210 return "Missing module name"; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
211 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
212 lmod = g_slist_find_custom(loaded_modules, arg, module_list_comparator); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
213 if (!lmod) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
214 return "Module not found"; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
215 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
216 module = lmod->data; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
217 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
218 // Check if user can unload this module |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
219 if (manual) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
220 if (!module->locked) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
221 if (force) |
1736
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
222 scr_LogPrint(LPRINT_LOGNORM, "Forced to ignore error: " |
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
223 "Manually unloading automatically loaded module."); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
224 else |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
225 return "Module is not loaded manually"; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
226 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
227 module->locked = FALSE; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
228 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
229 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
230 // Check refcount |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
231 module->refcount -= 1; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
232 if (module->refcount > 0) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
233 if (force) |
1736
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
234 scr_LogPrint(LPRINT_LOGNORM, "Forced to ignore error: " |
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
235 "Refcount is not zero (%u).", module->refcount); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
236 else |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
237 return manual ? "Module is required by some other modules" : NULL; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
238 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
239 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
240 info = module->info; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
241 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
242 // Run uninitialization routine |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
243 if (info && info->uninit) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
244 info->uninit(); |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
245 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
246 // Unload dependencies |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
247 if (info && info->requires) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
248 const gchar **dep; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
249 for (dep = info->requires; *dep; ++dep) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
250 const gchar *err = module_unload(*dep, FALSE, FALSE); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
251 if (err) // XXX |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
252 scr_LogPrint(LPRINT_LOGNORM, |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
253 "Error unloading automatically loaded module %s: %s.", |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
254 *dep, err); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
255 } |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
256 } |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
257 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
258 // XXX Prevent uninitialization routine and dep unloading to be performed again |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
259 module->info = NULL; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
260 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
261 // Unload module |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
262 if (!g_module_close(module->module)) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
263 return g_module_error(); // XXX destroy structure? |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
264 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
265 // Destroy structure |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
266 loaded_modules = g_slist_delete_link(loaded_modules, lmod); |
1763
5b497046df40
Fix output of message on module unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1755
diff
changeset
|
267 // Output this here, as arg may point to module->name |
5b497046df40
Fix output of message on module unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1755
diff
changeset
|
268 scr_LogPrint(LPRINT_LOGNORM, "Unloaded module %s.", module->name); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
269 g_free(module->name); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
270 g_free(module); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
271 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
272 return NULL; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
273 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
274 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
275 // module_list_print(void) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
276 // Prints into status buffer and log list of the currently loaded |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
277 // modules. |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
278 void module_list_print(void) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
279 { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
280 GSList *mel; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
281 gsize maxlen = 0; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
282 gchar *format; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
283 GString *message; |
1820
0628dcecaddf
Set the message flag with module list (when there are several modules)
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
284 guint module_count = 0; |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
285 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
286 if (!loaded_modules) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
287 scr_LogPrint(LPRINT_LOGNORM, "No modules loaded."); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
288 return; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
289 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
290 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
291 // Count maximum module name length |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
292 for (mel = loaded_modules; mel; mel = mel -> next) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
293 loaded_module_t *module = mel->data; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
294 gsize len = strlen(module->name); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
295 if (len > maxlen) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
296 maxlen = len; |
1820
0628dcecaddf
Set the message flag with module list (when there are several modules)
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
297 module_count++; |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
298 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
299 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
300 // Create format string |
1774 | 301 format = g_strdup_printf("%%-%us %%2u (%%c)", (unsigned)maxlen); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
302 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
303 // Fill the message to be printed |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
304 message = g_string_new("Loaded modules:\n"); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
305 for (mel = loaded_modules; mel; mel = mel -> next) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
306 loaded_module_t *module = mel->data; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
307 |
1736
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
308 g_string_append_printf(message, format, module->name, module->refcount, |
15e1f3957786
Misc. small style changes
Mikael Berthe <mikael@lilotux.net>
parents:
1735
diff
changeset
|
309 module->locked ? 'M' : 'A'); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
310 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
311 if (module->info) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
312 module_info_t *info = module->info; |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
313 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
314 // Module version |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
315 if (info->version) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
316 g_string_append(message, " version: "); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
317 g_string_append(message, info->version); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
318 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
319 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
320 // Module dependencies |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
321 if (info->requires && *(info->requires)) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
322 const gchar **dep; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
323 g_string_append(message, " depends: "); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
324 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
325 for (dep = info->requires; *dep; ++dep) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
326 g_string_append(message, *dep); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
327 g_string_append(message, ", "); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
328 } |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
329 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
330 // Chop extra ", " |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
331 g_string_truncate(message, message->len - 2); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
332 } |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
333 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
334 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
335 g_string_append_c(message, '\n'); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
336 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
337 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
338 // Chop extra "\n" |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
339 g_string_truncate(message, message->len - 1); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
340 |
1820
0628dcecaddf
Set the message flag with module list (when there are several modules)
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
341 scr_LogPrint(LPRINT_NORMAL, "%s", message->str); |
0628dcecaddf
Set the message flag with module list (when there are several modules)
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
342 |
1822
f44c375dabf1
Slight change for changeset 0628dcecaddf
Mikael Berthe <mikael@lilotux.net>
parents:
1820
diff
changeset
|
343 if (module_count + 1 > scr_getlogwinheight()) { |
1820
0628dcecaddf
Set the message flag with module list (when there are several modules)
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
344 scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
0628dcecaddf
Set the message flag with module list (when there are several modules)
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
345 scr_setattentionflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE, |
0628dcecaddf
Set the message flag with module list (when there are several modules)
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
346 ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
0628dcecaddf
Set the message flag with module list (when there are several modules)
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
347 } |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
348 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
349 g_string_free(message, TRUE); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
350 g_free(format); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
351 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
352 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
353 // module_info_print(name) |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
354 // Prints info about specific module |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
355 void module_info_print(const gchar *name) |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
356 { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
357 GSList *lmod; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
358 loaded_module_t *module; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
359 module_info_t *info; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
360 |
1755
84487d78d0ea
Add a warning when using /module info with no module name
Mikael Berthe <mikael@lilotux.net>
parents:
1749
diff
changeset
|
361 if (!name || !name[0]) { |
84487d78d0ea
Add a warning when using /module info with no module name
Mikael Berthe <mikael@lilotux.net>
parents:
1749
diff
changeset
|
362 scr_LogPrint(LPRINT_NORMAL, "Please specify a module name."); |
84487d78d0ea
Add a warning when using /module info with no module name
Mikael Berthe <mikael@lilotux.net>
parents:
1749
diff
changeset
|
363 return; |
84487d78d0ea
Add a warning when using /module info with no module name
Mikael Berthe <mikael@lilotux.net>
parents:
1749
diff
changeset
|
364 } |
84487d78d0ea
Add a warning when using /module info with no module name
Mikael Berthe <mikael@lilotux.net>
parents:
1749
diff
changeset
|
365 |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
366 lmod = g_slist_find_custom(loaded_modules, name, module_list_comparator); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
367 if (!lmod) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
368 scr_LogPrint(LPRINT_NORMAL, "Module %s not found.", name); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
369 return; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
370 } |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
371 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
372 module = lmod->data; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
373 info = module->info; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
374 |
1831
78616d66a7f2
Make module info output slightly more readable
Mikael Berthe <mikael@lilotux.net>
parents:
1828
diff
changeset
|
375 scr_LogPrint(LPRINT_NORMAL, "Module %s", module->name); |
78616d66a7f2
Make module info output slightly more readable
Mikael Berthe <mikael@lilotux.net>
parents:
1828
diff
changeset
|
376 scr_LogPrint(LPRINT_NORMAL, " Location: %s", g_module_name(module->module)); |
78616d66a7f2
Make module info output slightly more readable
Mikael Berthe <mikael@lilotux.net>
parents:
1828
diff
changeset
|
377 scr_LogPrint(LPRINT_NORMAL, " Loaded: %s", |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
378 module->locked ? "Manually" : "Automatically"); |
1831
78616d66a7f2
Make module info output slightly more readable
Mikael Berthe <mikael@lilotux.net>
parents:
1828
diff
changeset
|
379 scr_LogPrint(LPRINT_NORMAL, " Reference count: %u", module->refcount); |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
380 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
381 if (info) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
382 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
383 if (info->version) |
1831
78616d66a7f2
Make module info output slightly more readable
Mikael Berthe <mikael@lilotux.net>
parents:
1828
diff
changeset
|
384 scr_LogPrint(LPRINT_NORMAL, " Version: %s", info->version); |
78616d66a7f2
Make module info output slightly more readable
Mikael Berthe <mikael@lilotux.net>
parents:
1828
diff
changeset
|
385 scr_LogPrint(LPRINT_NORMAL, " API: %s:%u", info->branch, info->api); |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
386 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
387 if (info->requires && *(info->requires)) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
388 GString *message = g_string_new("Depends on: "); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
389 const gchar **dep; |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
390 for (dep = info->requires; *dep; ++dep) { |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
391 g_string_append(message, *dep); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
392 g_string_append(message, ", "); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
393 } |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
394 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
395 // Chop last ", " |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
396 g_string_truncate(message, message->len - 2); |
1831
78616d66a7f2
Make module info output slightly more readable
Mikael Berthe <mikael@lilotux.net>
parents:
1828
diff
changeset
|
397 scr_LogPrint(LPRINT_NORMAL, " %s", message->str); |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
398 g_string_free(message, TRUE); |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
399 } |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
400 |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
401 if (info->description) |
1831
78616d66a7f2
Make module info output slightly more readable
Mikael Berthe <mikael@lilotux.net>
parents:
1828
diff
changeset
|
402 scr_LogPrint(LPRINT_NORMAL, " Description: %s", info->description); |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
403 } |
1773
553e7aa88c9f
Set the message flag for /module info output
Mikael Berthe <mikael@lilotux.net>
parents:
1771
diff
changeset
|
404 scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
1815
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
405 scr_setattentionflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE, |
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
406 ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
407 } |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1736
diff
changeset
|
408 |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
409 // modules_init() |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
410 // Initializes module system. |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
411 void modules_init(void) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
412 { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
413 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
414 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
415 // modules_deinit() |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
416 // Unloads all the modules. |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
417 void modules_deinit(void) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
418 { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
419 GSList *mel; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
420 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
421 // We need only manually loaded modules |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
422 for (mel = loaded_modules; mel; mel = mel->next) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
423 loaded_module_t *module = mel->data; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
424 if (module->locked) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
425 break; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
426 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
427 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
428 while (mel) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
429 loaded_module_t *module = mel->data; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
430 const gchar *err; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
431 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
432 // Find next manually loaded module to treat |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
433 for (mel = mel->next; mel; mel = mel->next) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
434 loaded_module_t *module = mel->data; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
435 if (module->locked) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
436 break; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
437 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
438 |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
439 // Unload module |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
440 scr_LogPrint(LPRINT_LOGNORM, "Unloading module %s.", module->name); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
441 err = module_unload(module->name, TRUE, FALSE); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
442 if (err) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
443 scr_LogPrint(LPRINT_LOGNORM, "* Module unloading failed: %s.", err); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
444 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
445 } |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
446 |
1811 | 447 /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2: For Vim users... */ |