author | Myhailo Danylenko <isbear@ukrpost.net> |
Mon, 23 Feb 2009 17:05:43 +0200 | |
changeset 2 | a88a395e6868 |
parent 1 | 7d87d323c889 |
child 3 | a5f864d4207f |
permissions | -rw-r--r-- |
0 | 1 |
|
2 |
#include <glib.h> |
|
3 |
#include <gmodule.h> |
|
4 |
#include <lua.h> |
|
5 |
#include <lauxlib.h> |
|
6 |
#include <lualib.h> |
|
1 | 7 |
#include <stdio.h> |
8 |
#include <stdlib.h> // getenv |
|
2
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
9 |
#include <string.h> // strcmp |
0 | 10 |
|
1 | 11 |
#include "util.h" |
12 |
#include "logprint.h" // scr_LogPrint |
|
13 |
#include "screen.h" // scr_Beep, scr_WriteIncomingMessage |
|
14 |
#include "hbuf.h" // HBB_PREFIX_INFO |
|
15 |
#include "commands.h" // process_command, cmd_add, cmd_del |
|
16 |
#include "xmpp.h" // xmpp_getstatus, xmpp_getstatusmsg, lconnection, xmpp_add_feature, xmpp_del_feature |
|
17 |
#include "roster.h" // imstatus2char, foreach_buddy, buddy_*, current_buddy, BUDDATA, ROSTER_TYPE_* |
|
18 |
#include "utils.h" // from_utf8, jidtodisp |
|
19 |
#include "hooks.h" // hk_add_handler, hk_del_handler |
|
20 |
#include "settings.h" // settings_set, settings_del, settings_get |
|
0 | 21 |
|
22 |
||
1 | 23 |
// global lua state object, necessary for uninitialization function |
24 |
static lua_State *lua = NULL; |
|
0 | 25 |
|
1 | 26 |
// caller sould g_free result |
0 | 27 |
char *mcabber_config_filename (const char *file) |
28 |
{ |
|
1 | 29 |
const char *home = getenv ("HOME"); |
30 |
if (!home) |
|
31 |
return NULL; |
|
32 |
return g_strconcat (home, "/.mcabber/", file ? file : "", NULL); |
|
0 | 33 |
} |
34 |
||
35 |
/// print |
|
1 | 36 |
/// Prints its arguments to log with default priority. |
37 |
/// A: string/number, ... |
|
0 | 38 |
static int lua_global_print (lua_State *L) |
39 |
{ |
|
1 | 40 |
lua_concat (L, lua_gettop (L)); |
41 |
scr_LogPrint (LPRINT_LOGNORM, lua_tostring (L, -1)); |
|
42 |
return 0; |
|
0 | 43 |
} |
44 |
||
45 |
/// dopath |
|
46 |
/// Loads lua file from default location. |
|
47 |
/// A: string (filename, without ".lua") |
|
48 |
static int lua_global_dopath (lua_State *L) |
|
49 |
{ |
|
1 | 50 |
const char *name = luaL_checkstring (L, 1); |
51 |
size_t size = lua_objlen (L, 1); |
|
52 |
char *path; |
|
53 |
if (!strncmp (name + size - 4, ".lua", 4)) |
|
54 |
path = mcabber_config_filename (name); |
|
55 |
else { |
|
56 |
char *fname = g_strconcat (name, ".lua", NULL); |
|
57 |
path = mcabber_config_filename (fname); |
|
58 |
g_free (fname); |
|
59 |
} |
|
60 |
||
61 |
if (luaL_loadfile (L, path)) |
|
62 |
scr_LogPrint (LPRINT_LOGNORM, "lua: Unable to compile file %s: %s", path, lua_tostring (L, -1)); |
|
63 |
else if (lua_pcall (lua, 0, LUA_MULTRET, 0)) |
|
64 |
scr_LogPrint(LPRINT_LOGNORM, "lua: Runtime error in file %s: %s", path, lua_tostring (L, -1)); |
|
65 |
||
66 |
g_free (path); |
|
67 |
return 0; |
|
0 | 68 |
} |
69 |
||
70 |
/// main.config_file |
|
71 |
/// Adds mcabber default config location path to config file name. |
|
1 | 72 |
/// Note: deprecated, use dopath. |
0 | 73 |
/// A: string (filename) |
74 |
/// R: string (full path) |
|
75 |
static int lua_main_config_file (lua_State *L) |
|
76 |
{ |
|
1 | 77 |
char *home = mcabber_config_filename (luaL_checkstring (L, 1)); |
78 |
if (!home) { |
|
79 |
lua_pushstring (L, "Cannot find home dir!"); |
|
80 |
lua_error (L); |
|
81 |
} |
|
82 |
lua_pushstring (L, home); |
|
83 |
g_free (home); |
|
84 |
return 1; |
|
0 | 85 |
} |
86 |
||
87 |
/// log print type |
|
1 | 88 |
/// G: |
0 | 89 |
static const string2enum_t lua_lprint[] = { |
1 | 90 |
{ "normal", LPRINT_NORMAL }, |
91 |
{ "log", LPRINT_LOG }, |
|
92 |
{ "debug", LPRINT_DEBUG }, |
|
93 |
{ "notutf0", LPRINT_NOTUTF8 }, |
|
94 |
{ NULL, 0 }, |
|
0 | 95 |
}; |
96 |
||
1 | 97 |
/// roster type |
98 |
/// G: |
|
0 | 99 |
static const string2enum_t lua_roster_type[] = { |
1 | 100 |
{ "user", ROSTER_TYPE_USER }, |
101 |
{ "group", ROSTER_TYPE_GROUP }, |
|
102 |
{ "agent", ROSTER_TYPE_AGENT }, |
|
103 |
{ "room", ROSTER_TYPE_ROOM }, |
|
104 |
{ "special", ROSTER_TYPE_SPECIAL }, |
|
105 |
{ NULL, 0 }, |
|
0 | 106 |
}; |
107 |
||
108 |
/// main.log |
|
109 |
/// Prints message to log. |
|
110 |
/// A: log print type, message, message... |
|
111 |
static int lua_main_log (lua_State *L) |
|
112 |
{ |
|
1 | 113 |
int type = luaL_checkenum_multi (L, 1, lua_lprint); |
114 |
lua_concat (L, lua_gettop (L) - 1); |
|
115 |
scr_LogPrint (type, lua_tostring (L, -1)); |
|
116 |
return 0; |
|
0 | 117 |
} |
118 |
||
119 |
/// main.option |
|
120 |
/// Sets or gets value of mcabber option. |
|
121 |
/// You can specify nil as a value to delete option. |
|
122 |
/// XXX: Should we do types here? |
|
123 |
/// A: string (option name), string (value, optional) |
|
124 |
/// R: string (value, optional) |
|
125 |
static int lua_main_option (lua_State *L) |
|
126 |
{ |
|
1 | 127 |
const char *name = luaL_checkstring (L, 1); |
128 |
if (lua_gettop (L) > 1) { // Set |
|
129 |
if (lua_type (L, 2) == LUA_TNIL) // Unset |
|
130 |
settings_del (SETTINGS_TYPE_OPTION, name); |
|
131 |
else { // Set |
|
132 |
const char *value = luaL_checkstring (L, 2); |
|
133 |
settings_set (SETTINGS_TYPE_OPTION, name, value); |
|
134 |
} |
|
135 |
return 0; |
|
136 |
} else { // Get |
|
137 |
const char *value = settings_get (SETTINGS_TYPE_OPTION, name); |
|
138 |
if (value) |
|
139 |
lua_pushstring (L, value); |
|
140 |
else |
|
141 |
lua_pushnil (L); |
|
142 |
return 1; |
|
143 |
} |
|
0 | 144 |
} |
145 |
||
146 |
/// main.connection |
|
147 |
/// Returns lightuserdata of mcabber's loudmouth connection. |
|
148 |
/// This can be very useful with lua-loudmouth, and not much otherwise. |
|
149 |
/// R: lightuserdata |
|
150 |
static int lua_main_connection (lua_State *L) |
|
151 |
{ |
|
1 | 152 |
lua_pushlightuserdata (L, lconnection); |
153 |
return 1; |
|
0 | 154 |
} |
155 |
||
156 |
/// main.print_info |
|
157 |
/// Prints a system message to buddy's window. |
|
158 |
/// A: string (jid), string (message) |
|
159 |
static int lua_main_print_info (lua_State *L) |
|
160 |
{ |
|
1 | 161 |
char *to = jidtodisp (luaL_checkstring (L, 1)); |
162 |
scr_WriteIncomingMessage (to, luaL_checkstring (L, 2), 0, HBB_PREFIX_INFO, 0); |
|
163 |
g_free (to); |
|
164 |
return 0; |
|
0 | 165 |
} |
166 |
||
167 |
/// main.beep |
|
168 |
/// Beeps with system speaker. |
|
169 |
static int lua_main_beep (lua_State *L) |
|
170 |
{ |
|
1 | 171 |
scr_Beep (); |
172 |
return 0; |
|
0 | 173 |
} |
174 |
||
175 |
/// main.run |
|
176 |
/// Runs specified mcabber command. |
|
177 |
/// A: string |
|
178 |
static int lua_main_run (lua_State *L) |
|
179 |
{ |
|
1 | 180 |
process_command (luaL_checkstring (L, 1), TRUE); |
181 |
return 0; |
|
0 | 182 |
} |
183 |
||
184 |
/// main.status |
|
185 |
/// Returns your current status. |
|
1 | 186 |
/// R: string (status letter), string (status message) |
0 | 187 |
static int lua_main_status (lua_State *L) |
188 |
{ |
|
1 | 189 |
char *sm = from_utf8 (xmpp_getstatusmsg ()); |
190 |
lua_pushlstring (L, &imstatus2char[xmpp_getstatus ()], 1); |
|
191 |
lua_pushstring (L, sm); |
|
192 |
g_free (sm); |
|
193 |
return 2; |
|
0 | 194 |
} |
195 |
||
1 | 196 |
// expects table on top |
0 | 197 |
static void lua_rosterlist_callback (gpointer buddy, lua_State *L) |
198 |
{ |
|
1 | 199 |
lua_pushnumber (L, lua_objlen (L, -1) + 1); |
200 |
lua_pushstring (L, buddy_getjid (buddy)); |
|
201 |
lua_settable (L, -3); |
|
0 | 202 |
} |
203 |
||
204 |
/// main.roster |
|
205 |
/// Returns array of jids of buddies in roster. |
|
206 |
/// R: table |
|
207 |
static int lua_main_roster (lua_State *L) |
|
208 |
{ |
|
1 | 209 |
lua_newtable (L); |
210 |
foreach_buddy (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM, (void (*) (gpointer buddy, void *data))lua_rosterlist_callback, L); |
|
211 |
return 1; |
|
0 | 212 |
} |
213 |
||
214 |
/// main.current_buddy |
|
215 |
/// Returns jid of current selected buddy. |
|
216 |
/// R: string |
|
217 |
static int lua_main_current_buddy (lua_State *L) |
|
218 |
{ |
|
1 | 219 |
lua_pushstring (L, buddy_getjid (BUDDATA (current_buddy))); |
220 |
return 1; |
|
0 | 221 |
} |
222 |
||
223 |
typedef struct { |
|
1 | 224 |
lua_State *L; |
225 |
gpointer buddy; |
|
0 | 226 |
} lua_state_and_buddy_t; // :) |
227 |
||
228 |
// expects table on top! |
|
229 |
static void lua_buddy_resources_callback (gpointer resource, lua_state_and_buddy_t *d) |
|
230 |
{ |
|
1 | 231 |
lua_pushstring (d->L, resource); |
232 |
lua_createtable (d->L, 0, 3); |
|
233 |
lua_pushstring (d->L, "priority"); |
|
234 |
lua_pushnumber (d->L, buddy_getresourceprio (d->buddy, resource)); |
|
235 |
lua_settable (d->L, -3); |
|
236 |
lua_pushstring (d->L, "status"); |
|
237 |
lua_pushlstring (d->L, &imstatus2char[buddy_getstatus (d->buddy, resource)], 1); |
|
238 |
lua_settable (d->L, -3); |
|
239 |
lua_pushstring (d->L, "message"); |
|
240 |
lua_pushstring (d->L, buddy_getstatusmsg (d->buddy, resource)); |
|
241 |
lua_settable (d->L, -3); |
|
242 |
lua_settable (d->L, -3); |
|
0 | 243 |
} |
244 |
||
245 |
/// main.buddy_info |
|
246 |
/// Returns a hash table with information on specified buddy. |
|
247 |
/// Table contains fields type, name, onserver and resources. |
|
248 |
/// Resources is also a hash table, that contains tables with information, |
|
249 |
/// specific for each resource. In each resource table there are fields |
|
250 |
/// priority, status and message. |
|
251 |
/// A: string (jid) |
|
252 |
/// R: table |
|
253 |
static int lua_main_buddy_info (lua_State *L) |
|
254 |
{ |
|
1 | 255 |
char *jid = jidtodisp (luaL_checkstring (L, 1)); |
256 |
GSList *buddy = roster_find (jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
|
257 |
lua_state_and_buddy_t snb; |
|
258 |
g_free (jid); |
|
259 |
||
260 |
if (!buddy) { |
|
261 |
lua_pushnil (L); |
|
262 |
return 1; |
|
263 |
} |
|
0 | 264 |
|
1 | 265 |
lua_createtable (L, 0, 3); |
266 |
lua_pushstring (L, "type"); |
|
267 |
luaL_pushenum (L, buddy_gettype (BUDDATA (buddy)), lua_roster_type); |
|
268 |
lua_settable (L, -3); |
|
269 |
lua_pushstring (L, "name"); |
|
270 |
lua_pushstring (L, buddy_getname (BUDDATA (buddy))); |
|
271 |
lua_settable (L, -3); |
|
272 |
lua_pushstring (L, "onserver"); |
|
273 |
lua_pushboolean (L, buddy_getonserverflag (BUDDATA (buddy))); |
|
274 |
lua_settable (L, -3); |
|
275 |
lua_pushstring (L, "resources"); |
|
276 |
lua_createtable (L, 0, 0); |
|
277 |
snb.L = L; |
|
278 |
snb.buddy = BUDDATA (buddy); |
|
279 |
g_slist_foreach (buddy_getresources (BUDDATA (buddy)), (GFunc) lua_buddy_resources_callback, &snb); |
|
280 |
lua_settable (L, -3); |
|
281 |
||
282 |
return 1; |
|
0 | 283 |
} |
284 |
||
2
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
285 |
// XMPP DISCO FEATURES |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
286 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
287 |
GSList *lua_added_features = NULL; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
288 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
289 |
/// main.add_feature |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
290 |
/// Adds xmlns to disco#info features list. |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
291 |
/// A: string (xmlns) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
292 |
static int lua_main_add_feature (lua_State *L) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
293 |
{ |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
294 |
const char *xmlns = luaL_checkstring (L, 1); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
295 |
xmpp_add_feature (xmlns); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
296 |
lua_added_features = g_slist_prepend (lua_added_features, g_strdup (xmlns)); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
297 |
return 0; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
298 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
299 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
300 |
/// main.del_feature |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
301 |
/// Removes xmlns from disco#info features list. |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
302 |
/// A: stirng (xmlns) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
303 |
static int lua_main_del_feature (lua_State *L) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
304 |
{ |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
305 |
const char *xmlns = luaL_checkstring (L, 1); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
306 |
GSList *el = g_slist_find_custom (lua_added_features, xmlns, (GCompareFunc) strcmp); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
307 |
xmpp_del_feature (xmlns); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
308 |
if (el) { |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
309 |
g_free (el->data); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
310 |
lua_added_features = g_slist_delete_link (lua_added_features, el); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
311 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
312 |
return 0; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
313 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
314 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
315 |
// MCABBER COMMANDS |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
316 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
317 |
typedef struct { |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
318 |
int reference; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
319 |
lua_State *L; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
320 |
} lua_command_callback_t; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
321 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
322 |
static GSList *lua_added_commands = NULL; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
323 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
324 |
/// command function |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
325 |
/// Function to handle newly registered command. |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
326 |
/// A: string (arguments) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
327 |
void lua_main_command_handler (char *args, lua_command_callback_t *cb) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
328 |
{ |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
329 |
lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
330 |
lua_pushstring (cb->L, args); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
331 |
if (lua_pcall (cb->L, 1, 0, 0)) { |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
332 |
scr_LogPrint (LPRINT_LOGNORM, "lua: Command execution error: %s", lua_tostring (cb->L, -1)); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
333 |
lua_pop (cb->L, 1); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
334 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
335 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
336 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
337 |
/// main.add_command |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
338 |
/// Associates mcabber command name with lua function. |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
339 |
/// A: string (command name), command function |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
340 |
static int lua_main_add_command (lua_State *L) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
341 |
{ |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
342 |
const char *name = luaL_checkstring (L, 1); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
343 |
lua_command_callback_t *cb; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
344 |
luaL_argcheck (L, lua_isfunction (L, 2), 2, "function expected"); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
345 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
346 |
cb = luaL_malloc (L, sizeof (lua_command_callback_t)); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
347 |
cb->reference = luaL_ref (L, LUA_REGISTRYINDEX); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
348 |
cb->L = L; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
349 |
cmd_add (name, "", 0, 0, (void (*) (char *p)) lua_main_command_handler, cb); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
350 |
lua_added_commands = g_slist_prepend (lua_added_commands, g_strdup (name)); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
351 |
return 0; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
352 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
353 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
354 |
/// main.del_command |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
355 |
/// Removes command from a list of commands. |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
356 |
/// A: string (command name) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
357 |
static int lua_main_del_command (lua_State *L) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
358 |
{ |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
359 |
const char *name = luaL_checkstring (L, 1); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
360 |
GSList *el = g_slist_find_custom (lua_added_commands, name, (GCompareFunc) strcmp); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
361 |
lua_command_callback_t *cb = cmd_del (name); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
362 |
if (cb) { |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
363 |
luaL_unref (cb->L, LUA_REGISTRYINDEX, cb->reference); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
364 |
luaL_free (cb->L, cb); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
365 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
366 |
if (el) { |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
367 |
g_free (el->data); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
368 |
lua_added_commands = g_slist_delete_link (lua_added_commands, el); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
369 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
370 |
return 0; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
371 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
372 |
|
0 | 373 |
// TIMER |
374 |
||
375 |
#define LUA_TIMER_PRIORITY ( G_PRIORITY_HIGH_IDLE ) |
|
376 |
||
377 |
typedef struct { |
|
1 | 378 |
int reference; |
379 |
lua_State *L; |
|
0 | 380 |
} lua_timer_callback_t; |
381 |
||
382 |
static void lua_timer_callback_destroy (lua_timer_callback_t *cb) |
|
383 |
{ |
|
1 | 384 |
luaL_unref (cb->L, LUA_REGISTRYINDEX, cb->reference); |
385 |
luaL_free (cb->L, cb); |
|
0 | 386 |
} |
387 |
||
388 |
/// timer function |
|
389 |
/// Function, that will be called periodically until it returns false. |
|
390 |
/// R: boolean |
|
391 |
static gboolean lua_timer_callback (lua_timer_callback_t *cb) |
|
392 |
{ |
|
1 | 393 |
int ret; |
394 |
lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); |
|
395 |
if (lua_pcall (cb->L, 0, 1, 0)) { |
|
396 |
scr_LogPrint (LPRINT_LOGNORM, "lua: Timer callback execution error: %s", lua_tostring (cb->L, -1)); |
|
397 |
lua_pop (cb->L, 1); |
|
398 |
return FALSE; |
|
399 |
} |
|
400 |
ret = lua_toboolean (cb->L, -1); |
|
401 |
lua_pop (cb->L, 1); |
|
402 |
return ret; |
|
0 | 403 |
} |
404 |
||
405 |
/// main.timer |
|
406 |
/// Creates new timer function, that will be called periodically. |
|
407 |
/// A: integer (interval, seconds), timer function |
|
408 |
static int lua_main_timer (lua_State *L) |
|
409 |
{ |
|
1 | 410 |
int interval = luaL_checkint (L, 1); |
411 |
lua_timer_callback_t *cb; |
|
412 |
luaL_argcheck (L, lua_isfunction (L, 2), 2, "function expected"); |
|
0 | 413 |
|
1 | 414 |
cb = luaL_malloc (L, sizeof (lua_timer_callback_t)); |
415 |
cb->reference = luaL_ref (L, LUA_REGISTRYINDEX); |
|
416 |
cb->L = L; |
|
0 | 417 |
|
1 | 418 |
g_timeout_add_seconds_full (LUA_TIMER_PRIORITY, interval, (GSourceFunc) lua_timer_callback, cb, (GDestroyNotify) lua_timer_callback_destroy); |
419 |
return 0; |
|
0 | 420 |
} |
421 |
||
422 |
// BACKGROUND PIPE READING |
|
423 |
||
424 |
#define LUA_BGREAD_BUFFER ( 4096 ) |
|
425 |
||
426 |
typedef struct { |
|
1 | 427 |
lua_State *L; |
428 |
FILE *fd; |
|
429 |
int reference; |
|
0 | 430 |
} lua_bgread_callback_t; |
431 |
||
432 |
static gchar lua_bgread_buffer[LUA_BGREAD_BUFFER]; |
|
433 |
||
434 |
static void lua_bgread_callback_destroy (lua_bgread_callback_t *cb) |
|
435 |
{ |
|
1 | 436 |
luaL_unref (cb->L, LUA_REGISTRYINDEX, cb->reference); |
437 |
pclose (cb->fd); |
|
438 |
luaL_free (cb->L, cb); |
|
0 | 439 |
} |
440 |
||
441 |
/// background reading function |
|
442 |
/// Function, that processes output from pipe in asynchroneous way. |
|
443 |
/// A: string (data) or nil (eof) |
|
444 |
/// R: boolean (false if reading should be terminated) |
|
445 |
static gboolean |
|
1 | 446 |
lua_bgread_callback (GIOChannel *source, GIOCondition condition, lua_bgread_callback_t *cb) |
0 | 447 |
{ |
1 | 448 |
int ret = TRUE; |
0 | 449 |
|
1 | 450 |
if (condition | G_IO_IN) { // data |
451 |
while (TRUE) { |
|
452 |
gsize read = 0; |
|
453 |
g_io_channel_read_chars (source, lua_bgread_buffer, LUA_BGREAD_BUFFER, &read, NULL); |
|
454 |
if (!read) // exausted |
|
455 |
break; |
|
0 | 456 |
|
1 | 457 |
lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); |
458 |
lua_pushlstring (cb->L, lua_bgread_buffer, read); |
|
459 |
if (lua_pcall (cb->L, 1, 1, 0)) { |
|
460 |
scr_LogPrint (LPRINT_LOGNORM, "lua: Bgread callback execution error: %s", lua_tostring (cb->L, -1)); |
|
461 |
lua_pop (cb->L, 1); |
|
462 |
return FALSE; |
|
463 |
} |
|
464 |
ret = lua_toboolean (cb->L, -1); |
|
465 |
lua_pop (cb->L, 1); |
|
466 |
if (!ret) // enough |
|
467 |
return FALSE; |
|
468 |
} |
|
469 |
} |
|
0 | 470 |
|
1 | 471 |
if (condition & ~G_IO_IN) { // err or hup |
472 |
lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); |
|
473 |
lua_pushnil (cb->L); |
|
474 |
if (lua_pcall (cb->L, 1, 1, 0)) { |
|
475 |
scr_LogPrint (LPRINT_LOGNORM, "lua: Bgread callback execution error: %s", lua_tostring (cb->L, -1)); |
|
476 |
lua_pop (cb->L, 1); |
|
477 |
return FALSE; |
|
478 |
} |
|
479 |
ret = lua_toboolean (cb->L, -1); |
|
480 |
lua_pop (cb->L, 1); |
|
481 |
} |
|
0 | 482 |
|
1 | 483 |
return ret; |
0 | 484 |
} |
485 |
||
486 |
/// main.bgread |
|
1 | 487 |
/// Runs specified command and passes its output to a given function. |
0 | 488 |
/// A: string (command), background reading function |
489 |
static int lua_main_bgread (lua_State *L) |
|
490 |
{ |
|
1 | 491 |
const char *command = luaL_checkstring (L, 1); |
492 |
lua_bgread_callback_t *cb; |
|
493 |
FILE *fd; |
|
494 |
GIOChannel *channel; |
|
495 |
const char *charset = NULL; |
|
496 |
luaL_argcheck (L, lua_isfunction (L, 2), 2, "function expected"); |
|
0 | 497 |
|
1 | 498 |
fd = popen (command, "r"); |
499 |
if (!fd) { |
|
500 |
lua_pushstring (L, "Error opening pipe"); |
|
501 |
lua_error (L); |
|
502 |
} |
|
0 | 503 |
|
1 | 504 |
channel = g_io_channel_unix_new (fileno (fd)); |
505 |
// We, most likely, need this, |
|
506 |
// But we cannot use this, |
|
507 |
// It will block. |
|
508 |
//if (!g_get_charset (&charset)) |
|
509 |
g_io_channel_set_encoding (channel, charset, NULL); |
|
510 |
g_io_channel_set_buffered (channel, FALSE); |
|
511 |
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); |
|
512 |
g_io_channel_set_close_on_unref (channel, TRUE); |
|
0 | 513 |
|
1 | 514 |
cb = luaL_malloc (L, sizeof (lua_bgread_callback_t)); |
515 |
cb->reference = luaL_ref (L, LUA_REGISTRYINDEX); |
|
516 |
cb->L = L; |
|
517 |
cb->fd = fd; |
|
0 | 518 |
|
1 | 519 |
g_io_add_watch_full (channel, G_PRIORITY_HIGH_IDLE, G_IO_IN|G_IO_HUP|G_IO_ERR, (GIOFunc) lua_bgread_callback, cb, (GDestroyNotify) lua_bgread_callback_destroy); |
520 |
return 0; |
|
0 | 521 |
} |
522 |
||
523 |
// MAIN INITIALIZATION CODE |
|
524 |
||
1 | 525 |
#define LUA_HOOK_NAME ( "hook_handler" ) |
0 | 526 |
|
527 |
static void lua_hook (hk_arg_t *args, lua_State *L) |
|
528 |
{ |
|
1 | 529 |
hk_arg_t *arg = args; |
530 |
lua_getglobal (lua, LUA_HOOK_NAME); |
|
531 |
if (!lua_isfunction (lua, -1)) { |
|
532 |
lua_pop (lua, 1); |
|
533 |
return; |
|
534 |
} |
|
535 |
lua_newtable (L); |
|
536 |
while (arg->name != NULL) { |
|
537 |
lua_pushstring (L, arg->name); |
|
538 |
lua_pushstring (L, arg->value); |
|
539 |
lua_settable (L, -3); |
|
540 |
arg++; |
|
541 |
} |
|
542 |
if (lua_pcall (lua, 1, 0, 0)) { |
|
543 |
scr_LogPrint (LPRINT_NORMAL, "lua: Error in hook_handler: %s", lua_tostring (lua, -1)); |
|
544 |
lua_pop (lua, 1); |
|
545 |
} |
|
546 |
} |
|
547 |
||
548 |
static void *lua_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { |
|
549 |
if (nsize == 0) { |
|
550 |
g_free (ptr); |
|
551 |
return NULL; |
|
552 |
} else |
|
553 |
return g_realloc (ptr, nsize); |
|
0 | 554 |
} |
555 |
||
556 |
static const luaL_Reg lua_reg_main[] = { |
|
1 | 557 |
{ "config_file", lua_main_config_file }, |
558 |
{ "connection", lua_main_connection }, |
|
559 |
{ "log", lua_main_log }, |
|
560 |
{ "option", lua_main_option }, |
|
561 |
{ "add_feature", lua_main_add_feature }, |
|
562 |
{ "del_feature", lua_main_del_feature }, |
|
563 |
{ "add_command", lua_main_add_command }, |
|
564 |
{ "del_command", lua_main_del_command }, |
|
565 |
{ "print_info", lua_main_print_info }, |
|
566 |
{ "beep", lua_main_beep }, |
|
567 |
{ "run", lua_main_run }, |
|
568 |
{ "status", lua_main_status }, |
|
569 |
{ "roster", lua_main_roster }, |
|
570 |
{ "current_buddy", lua_main_current_buddy }, |
|
571 |
{ "buddy_info", lua_main_buddy_info }, |
|
572 |
{ "timer", lua_main_timer }, |
|
573 |
{ "bgread", lua_main_bgread }, |
|
574 |
{ NULL, NULL }, |
|
0 | 575 |
}; |
576 |
||
577 |
const gchar *g_module_check_init (GModule *module) |
|
578 |
{ |
|
1 | 579 |
char *initfile; |
0 | 580 |
|
1 | 581 |
lua = lua_newstate (lua_alloc, NULL); |
582 |
if (!lua) { |
|
583 |
scr_LogPrint (LPRINT_LOGNORM, "lua: Initialization error"); |
|
584 |
return "Lua initialization error"; |
|
585 |
} |
|
0 | 586 |
|
1 | 587 |
luaL_openlibs (lua); |
0 | 588 |
|
1 | 589 |
luaL_register (lua, "main", lua_reg_main); |
590 |
lua_pop (lua, 1); // XXX |
|
591 |
lua_register (lua, "dopath", lua_global_dopath); |
|
592 |
lua_register (lua, "print", lua_global_print ); |
|
593 |
||
594 |
initfile = mcabber_config_filename ("mcabberrc.lua"); |
|
595 |
if (!initfile) |
|
596 |
scr_LogPrint (LPRINT_LOGNORM, "lua: Cannot determine config file name"); |
|
597 |
else { |
|
598 |
if (luaL_loadfile(lua, initfile)) { |
|
599 |
scr_LogPrint (LPRINT_LOGNORM, "lua: Unable to compile rc file: %s", lua_tostring (lua, -1)); |
|
600 |
lua_pop (lua, 1); |
|
601 |
} else if (lua_pcall (lua, 0, LUA_MULTRET, 0)) { |
|
602 |
scr_LogPrint (LPRINT_LOGNORM, "lua: Runtime error in rc file: %s", lua_tostring(lua, -1)); |
|
603 |
lua_pop (lua, 1); |
|
604 |
} else |
|
605 |
scr_LogPrint (LPRINT_LOGNORM, "Loaded mcabberrc.lua"); |
|
606 |
g_free (initfile); |
|
607 |
} |
|
0 | 608 |
|
1 | 609 |
hk_add_handler ((hk_handler_t) lua_hook, lua); |
0 | 610 |
|
1 | 611 |
lua_getglobal (lua, "hook_start"); |
612 |
if (!lua_isfunction (lua, -1)) |
|
613 |
lua_pop (lua, 1); |
|
614 |
else if (lua_pcall (lua, 0, 0, 0)) { |
|
615 |
scr_LogPrint (LPRINT_NORMAL, "lua: Error in hook_start: %s", lua_tostring (lua, -1)); |
|
616 |
lua_pop (lua, 1); |
|
617 |
} |
|
618 |
return NULL; |
|
0 | 619 |
} |
620 |
||
2
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
621 |
static void lua_features_destroy (char *xmlns, gpointer ignore) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
622 |
{ |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
623 |
xmpp_del_feature (xmlns); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
624 |
g_free (xmlns); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
625 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
626 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
627 |
static void lua_commands_destroy (char *name, gpointer ignore) |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
628 |
{ |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
629 |
lua_command_callback_t *cb = cmd_del (name); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
630 |
if (cb) { |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
631 |
luaL_unref (cb->L, LUA_REGISTRYINDEX, cb->reference); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
632 |
luaL_free (cb->L, cb); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
633 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
634 |
g_free (name); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
635 |
} |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
636 |
|
0 | 637 |
void g_module_unload (GModule *module) |
638 |
{ |
|
1 | 639 |
if (lua) { |
640 |
lua_getglobal (lua, "hook_quit"); |
|
641 |
if (!lua_isfunction (lua, -1)) |
|
642 |
lua_pop (lua, 1); |
|
643 |
else if (lua_pcall (lua, 0, 0, 0)) { |
|
644 |
scr_LogPrint (LPRINT_NORMAL, "lua: Error in hook_quit: %s", lua_tostring (lua, -1)); |
|
645 |
lua_pop (lua, 1); |
|
646 |
} |
|
2
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
647 |
|
1 | 648 |
hk_del_handler ((hk_handler_t) lua_hook, lua); |
0 | 649 |
|
2
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
650 |
g_slist_foreach (lua_added_features, (GFunc) lua_features_destroy, NULL); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
651 |
g_slist_free (lua_added_features); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
652 |
lua_added_features = NULL; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
653 |
|
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
654 |
g_slist_foreach (lua_added_commands, (GFunc) lua_commands_destroy, NULL); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
655 |
g_slist_free (lua_added_commands); |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
656 |
lua_added_commands = NULL; |
a88a395e6868
Delete commands and features on unloading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
657 |
|
1 | 658 |
lua_close (lua); |
659 |
lua = NULL; |
|
660 |
} |
|
0 | 661 |
} |
662 |