490b96e6d1bdbc5ca11c9cd080d0aa3d81172dff
[screen-lua.git] / src / lua.c
blob490b96e6d1bdbc5ca11c9cd080d0aa3d81172dff
1 /* Lua scripting support
3 * Copyright (c) 2008 Sadrul Habib Chowdhury (sadrul@users.sf.net)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program (see the file COPYING); if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
20 ****************************************************************
22 #include <sys/types.h>
23 #include "config.h"
24 #include "screen.h"
25 #include <sys/stat.h>
26 #include <unistd.h>
28 #include <stdio.h>
29 #include <string.h>
30 #include <stdlib.h>
32 #include "extern.h"
33 #include "logfile.h"
35 #include <lua.h>
36 #include <lauxlib.h>
37 #include <lualib.h>
39 extern struct win *windows, *fore;
40 extern struct display *displays, *display;
41 extern struct LayFuncs WinLf;
42 extern struct layer *flayer;
44 static int LuaDispatch(void *handler, const char *params, va_list va);
45 static int LuaRegEvent(lua_State *L);
46 static int LuaUnRegEvent(lua_State *L);
48 /** Template {{{ */
50 #define CHECK_TYPE(name, type) \
51 static type * \
52 check_##name(lua_State *L, int index) \
53 { \
54 type **var; \
55 luaL_checktype(L, index, LUA_TUSERDATA); \
56 var = (type **) luaL_checkudata(L, index, #name); \
57 if (!var || !*var) \
58 luaL_typerror(L, index, #name); \
59 return *var; \
62 #define PUSH_TYPE(name, type) \
63 static void \
64 push_##name(lua_State *L, type **t) \
65 { \
66 if (!t || !*t) \
67 lua_pushnil(L); \
68 else \
69 { \
70 type **r; \
71 r = (type **)lua_newuserdata(L, sizeof(type *)); \
72 *r = *t; \
73 luaL_getmetatable(L, #name); \
74 lua_setmetatable(L,-2); \
75 } \
78 /* Much of the following template comes from:
79 * http://lua-users.org/wiki/BindingWithMembersAndMethods
82 static int get_int (lua_State *L, void *v)
84 lua_pushinteger (L, *(int*)v);
85 return 1;
88 static int set_int (lua_State *L, void *v)
90 *(int*)v = luaL_checkint(L, 3);
91 return 0;
94 static int get_number (lua_State *L, void *v)
96 lua_pushnumber(L, *(lua_Number*)v);
97 return 1;
100 static int set_number (lua_State *L, void *v)
102 *(lua_Number*)v = luaL_checknumber(L, 3);
103 return 0;
106 static int get_string (lua_State *L, void *v)
108 lua_pushstring(L, (char*)v );
109 return 1;
112 static int set_string (lua_State *L, void *v)
114 *(const char**)v = luaL_checkstring(L, 3);
115 return 0;
118 typedef int (*Xet_func) (lua_State *L, void *v);
120 /* member info for get and set handlers */
121 struct Xet_reg
123 const char *name; /* member name */
124 Xet_func func; /* get or set function for type of member */
125 size_t offset; /* offset of member within the struct */
126 int (*absolute)(lua_State *);
129 static void Xet_add (lua_State *L, const struct Xet_reg *l)
131 if (!l)
132 return;
133 for (; l->name; l++)
135 lua_pushstring(L, l->name);
136 lua_pushlightuserdata(L, (void*)l);
137 lua_settable(L, -3);
141 static int Xet_call (lua_State *L)
143 /* for get: stack has userdata, index, lightuserdata */
144 /* for set: stack has userdata, index, value, lightuserdata */
145 const struct Xet_reg *m = (const struct Xet_reg *)lua_touserdata(L, -1); /* member info */
146 lua_pop(L, 1); /* drop lightuserdata */
147 luaL_checktype(L, 1, LUA_TUSERDATA);
148 if (m->absolute)
149 return m->absolute(L);
150 return m->func(L, *(char**)lua_touserdata(L, 1) + m->offset);
153 static int index_handler (lua_State *L)
155 /* stack has userdata, index */
156 lua_pushvalue(L, 2); /* dup index */
157 lua_rawget(L, lua_upvalueindex(1)); /* lookup member by name */
158 if (!lua_islightuserdata(L, -1))
160 lua_pop(L, 1); /* drop value */
161 lua_pushvalue(L, 2); /* dup index */
162 lua_gettable(L, lua_upvalueindex(2)); /* else try methods */
163 if (lua_isnil(L, -1)) /* invalid member */
164 luaL_error(L, "cannot get member '%s'", lua_tostring(L, 2));
165 return 1;
167 return Xet_call(L); /* call get function */
170 static int newindex_handler (lua_State *L)
172 /* stack has userdata, index, value */
173 lua_pushvalue(L, 2); /* dup index */
174 lua_rawget(L, lua_upvalueindex(1)); /* lookup member by name */
175 if (!lua_islightuserdata(L, -1)) /* invalid member */
176 luaL_error(L, "cannot set member '%s'", lua_tostring(L, 2));
177 return Xet_call(L); /* call set function */
180 static int
181 struct_register(lua_State *L, const char *name, const luaL_reg fn_methods[], const luaL_reg meta_methods[],
182 const struct Xet_reg setters[], const struct Xet_reg getters[])
184 int metatable, methods;
186 /* create methods table & add it to the table of globals */
187 luaL_register(L, name, fn_methods);
188 methods = lua_gettop(L);
190 /* create metatable & add it to the registry */
191 luaL_newmetatable(L, name);
192 luaL_register(L, 0, meta_methods); /* fill metatable */
194 /* To identify the type of object */
195 lua_pushstring(L, "_objname");
196 lua_pushstring(L, name);
197 lua_settable(L, -3);
199 metatable = lua_gettop(L);
201 lua_pushliteral(L, "__metatable");
202 lua_pushvalue(L, methods); /* dup methods table*/
203 lua_rawset(L, metatable); /* hide metatable:
204 metatable.__metatable = methods */
206 lua_pushliteral(L, "__index");
207 lua_pushvalue(L, metatable); /* upvalue index 1 */
208 Xet_add(L, getters); /* fill metatable with getters */
209 lua_pushvalue(L, methods); /* upvalue index 2 */
210 lua_pushcclosure(L, index_handler, 2);
211 lua_rawset(L, metatable); /* metatable.__index = index_handler */
213 lua_pushliteral(L, "__newindex");
214 lua_newtable(L); /* table for members you can set */
215 Xet_add(L, setters); /* fill with setters */
216 lua_pushcclosure(L, newindex_handler, 1);
217 lua_rawset(L, metatable); /* metatable.__newindex = newindex_handler */
219 lua_pop(L, 1); /* drop metatable */
220 return 1; /* return methods on the stack */
223 /** }}} */
225 /** Window {{{ */
227 PUSH_TYPE(window, struct win)
229 CHECK_TYPE(window, struct win)
231 static int get_window(lua_State *L, void *v)
233 push_window(L, (struct win **)v);
234 return 1;
237 static int
238 window_change_title(lua_State *L)
240 struct win *w = check_window(L, 1);
241 unsigned int len;
242 const char *title = luaL_checklstring(L, 2, &len);
243 ChangeAKA(w, (char *)title, len);
244 return 0;
247 static int
248 window_get_monitor_status(lua_State *L)
250 struct win *w = check_window(L, 1);
251 int activity = luaL_checkint(L, 2);
252 if (activity)
253 /*monitor*/
254 lua_pushinteger(L, w->w_monitor != MON_OFF);
255 else
256 /*silence*/
257 lua_pushinteger(L, w->w_silence == SILENCE_ON ? w->w_silencewait: 0);
259 return 1;
262 static const luaL_reg window_methods[] = {
263 {"get_monitor_status", window_get_monitor_status},
264 {"hook", LuaRegEvent},
265 {0, 0}
268 static int
269 window_tostring(lua_State *L)
271 char str[128];
272 struct win *w = check_window(L, 1);
273 snprintf(str, sizeof(str), "{window #%d: '%s'}", w->w_number, w->w_title);
274 lua_pushstring(L, str);
275 return 1;
278 static int
279 window_equality(lua_State *L)
281 struct win *w1 = check_window(L, 1), *w2 = check_window(L, 2);
282 lua_pushboolean(L, (w1 == w2 || (w1 && w2 && w1->w_number == w2->w_number)));
283 return 1;
286 static const luaL_reg window_metamethods[] = {
287 {"__tostring", window_tostring},
288 {"__eq", window_equality},
289 {0, 0}
292 static const struct Xet_reg window_setters[] = {
293 {"title", 0, 0, window_change_title/*absolute setter*/},
294 {0, 0}
297 static const struct Xet_reg window_getters[] = {
298 {"title", get_string, offsetof(struct win, w_title) + 8},
299 {"number", get_int, offsetof(struct win, w_number)},
300 {"dir", get_string, offsetof(struct win, w_dir)},
301 {"tty", get_string, offsetof(struct win, w_tty)},
302 {"pid", get_int, offsetof(struct win, w_pid)},
303 {"group", get_window, offsetof(struct win, w_group)},
304 {"bell", get_int, offsetof(struct win, w_bell)},
305 {0, 0}
309 /** }}} */
311 /** AclUser {{{ */
313 PUSH_TYPE(user, struct acluser)
315 CHECK_TYPE(user, struct acluser)
317 static int
318 get_user(lua_State *L, void *v)
320 push_user(L, (struct acluser **)v);
321 return 1;
324 static const luaL_reg user_methods[] = {
325 {0, 0}
328 static int
329 user_tostring(lua_State *L)
331 char str[128];
332 struct acluser *u = check_user(L, 1);
333 snprintf(str, sizeof(str), "{user '%s'}", u->u_name);
334 lua_pushstring(L, str);
335 return 1;
338 static const luaL_reg user_metamethods[] = {
339 {"__tostring", user_tostring},
340 {0, 0}
343 static const struct Xet_reg user_setters[] = {
344 {0, 0}
347 static const struct Xet_reg user_getters[] = {
348 {"name", get_string, offsetof(struct acluser, u_name)},
349 {"password", get_string, offsetof(struct acluser, u_password)},
350 {0, 0}
353 /** }}} */
355 /** Canvas {{{ */
357 PUSH_TYPE(canvas, struct canvas)
359 CHECK_TYPE(canvas, struct canvas)
361 static int
362 get_canvas(lua_State *L, void *v)
364 push_canvas(L, (struct canvas **)v);
365 return 1;
368 static int
369 canvas_select(lua_State *L)
371 struct canvas *c = check_canvas(L, 1);
372 if (!display || D_forecv == c)
373 return 0;
374 SetCanvasWindow(c, Layer2Window(c->c_layer));
375 D_forecv = c;
377 /* XXX: the following all is duplicated from process.c:DoAction.
378 * Should these be in some better place?
380 ResizeCanvas(&D_canvas);
381 RecreateCanvasChain();
382 RethinkDisplayViewports();
383 ResizeLayersToCanvases(); /* redisplays */
384 fore = D_fore = Layer2Window(D_forecv->c_layer);
385 flayer = D_forecv->c_layer;
386 #ifdef RXVT_OSC
387 if (D_xtermosc[2] || D_xtermosc[3])
389 Activate(-1);
390 break;
392 #endif
393 RefreshHStatus();
394 #ifdef RXVT_OSC
395 RefreshXtermOSC();
396 #endif
397 flayer = D_forecv->c_layer;
398 CV_CALL(D_forecv, LayRestore();LaySetCursor());
399 WindowChanged(0, 'F');
400 return 1;
403 static const luaL_reg canvas_methods[] = {
404 {"select", canvas_select},
405 {0, 0}
408 static const luaL_reg canvas_metamethods[] = {
409 {0, 0}
412 static const struct Xet_reg canvas_setters[] = {
413 {0, 0}
416 static int
417 canvas_get_window(lua_State *L)
419 struct canvas *c = check_canvas(L, 1);
420 struct win *win = Layer2Window(c->c_layer);
421 if (win)
422 push_window(L, &win);
423 else
424 lua_pushnil(L);
425 return 1;
428 static const struct Xet_reg canvas_getters[] = {
429 {"next", get_canvas, offsetof(struct canvas, c_next)},
430 {"xoff", get_int, offsetof(struct canvas, c_xoff)},
431 {"yoff", get_int, offsetof(struct canvas, c_yoff)},
432 {"xs", get_int, offsetof(struct canvas, c_xs)},
433 {"ys", get_int, offsetof(struct canvas, c_ys)},
434 {"xe", get_int, offsetof(struct canvas, c_xe)},
435 {"ye", get_int, offsetof(struct canvas, c_ye)},
436 {"window", 0, 0, canvas_get_window},
437 {0, 0}
440 /** }}} */
442 /** Layout {{{ */
444 PUSH_TYPE(layout, struct layout)
445 CHECK_TYPE(layout, struct layout)
447 static const struct Xet_reg layout_getters[] = {
448 {0,0}
451 static int
452 get_layout(lua_State *L, void *v)
454 push_layout(L, (struct layout **)v);
455 return 1;
458 /** }}} */
460 /** Display {{{ */
462 PUSH_TYPE(display, struct display)
464 CHECK_TYPE(display, struct display)
466 static int
467 display_get_canvases(lua_State *L)
469 struct display *d;
470 struct canvas *iter;
471 int count;
473 d = check_display(L, 1);
474 lua_newtable(L);
475 for (iter = d->d_cvlist, count = 0; iter; iter = iter->c_next, count++) {
476 lua_pushinteger(L, count);
477 push_canvas(L, &iter);
478 lua_settable(L, -3);
481 return 1;
484 static const luaL_reg display_methods[] = {
485 {"get_canvases", display_get_canvases},
486 {0, 0}
489 static int
490 display_tostring(lua_State *L)
492 char str[128];
493 struct display *d = check_display(L, 1);
494 snprintf(str, sizeof(str), "{display: tty = '%s', term = '%s'}", d->d_usertty, d->d_termname);
495 lua_pushstring(L, str);
496 return 1;
499 static const luaL_reg display_metamethods[] = {
500 {"__tostring", display_tostring},
501 {0, 0}
504 static const struct Xet_reg display_setters[] = {
505 {0, 0}
508 static const struct Xet_reg display_getters[] = {
509 {"tty", get_string, offsetof(struct display, d_usertty)},
510 {"term", get_string, offsetof(struct display, d_termname)},
511 {"fore", get_window, offsetof(struct display, d_fore)},
512 {"other", get_window, offsetof(struct display, d_other)},
513 {"width", get_int, offsetof(struct display, d_width)},
514 {"height", get_int, offsetof(struct display, d_height)},
515 {"user", get_user, offsetof(struct display, d_user)},
516 {"layout", get_layout, offsetof(struct display, d_layout)},
517 {0, 0}
520 /** }}} */
522 /** Screen {{{ */
524 static int
525 screen_get_windows(lua_State *L)
527 struct win *iter;
528 int count;
530 lua_newtable(L);
531 for (iter = windows, count = 0; iter; iter = iter->w_next, count++) {
532 lua_pushinteger(L, iter->w_number);
533 push_window(L, &iter);
534 lua_settable(L, -3);
537 return 1;
540 static int
541 screen_get_displays(lua_State *L)
543 struct display *iter;
544 int count;
546 lua_newtable(L);
547 for (iter = displays, count = 0; iter; iter = iter->d_next, count++) {
548 lua_pushinteger(L, count);
549 push_display(L, &iter);
550 lua_settable(L, -3);
553 return 1;
556 static int
557 screen_get_display(lua_State *L)
559 push_display(L, &display);
560 return 1;
563 static int
564 screen_exec_command(lua_State *L)
566 const char *command;
567 unsigned int len;
569 command = luaL_checklstring(L, 1, &len);
570 if (command)
571 RcLine((char *)command, len);
573 return 0;
576 static int
577 screen_append_msg(lua_State *L)
579 const char *msg, *color;
580 int len;
581 msg = luaL_checklstring(L, 1, &len);
582 if (lua_isnil(L, 2))
583 color = NULL;
584 else
585 color = luaL_checklstring(L, 2, &len);
586 AppendWinMsgRend(msg, color);
587 return 0;
590 static const luaL_reg screen_methods[] = {
591 {"windows", screen_get_windows},
592 {"displays", screen_get_displays},
593 {"display", screen_get_display},
594 {"command", screen_exec_command},
595 {"append_msg", screen_append_msg},
596 {"hook", LuaRegEvent},
597 {"unhook", LuaUnRegEvent},
598 {0, 0}
601 static const luaL_reg screen_metamethods[] = {
602 {0, 0}
605 static const struct Xet_reg screen_setters[] = {
606 {0, 0}
609 static const struct Xet_reg screen_getters[] = {
610 {0, 0}
613 /** }}} */
615 /** Public functions {{{ */
616 static lua_State *L;
617 int LuaInit(void)
619 L = luaL_newstate();
621 luaL_openlibs(L);
623 #define REGISTER(X) struct_register(L, #X , X ## _methods, X##_metamethods, X##_setters, X##_getters)
625 REGISTER(screen);
626 REGISTER(window);
627 REGISTER(display);
628 REGISTER(user);
629 REGISTER(canvas);
631 return 0;
634 /* An error message on top of the stack. */
635 static void
636 LuaShowErr(lua_State *L)
638 struct display *d = display;
639 unsigned int len;
640 const char *message = luaL_checklstring(L, -1, &len);
641 LMsg(0, "%s", message ? message : "Unknown error");
642 lua_pop(L, 1);
643 display = d;
646 struct fn_def
648 void (*push_fn)(lua_State *, void*);
649 void *value;
652 static int
653 LuaCallProcess(const char *name, struct fn_def defs[])
655 int argc = 0;
657 lua_settop(L, 0);
658 lua_getfield(L, LUA_GLOBALSINDEX, name);
659 if (lua_isnil(L, -1))
660 return 0;
661 for (argc = 0; defs[argc].push_fn; argc++)
662 defs[argc].push_fn(L, defs[argc].value);
663 if (lua_pcall(L, argc, 0, 0) == LUA_ERRRUN && lua_isstring(L, -1))
665 LuaShowErr(L);
666 return 0;
668 return 1;
671 int LuaSource(const char *file, int async)
673 if (!L)
674 return 0;
675 struct stat st;
676 if (stat(file, &st) == -1)
677 Msg(errno, "Error loading lua script file '%s'", file);
678 else
680 int len = strlen(file);
681 if (len < 4 || strncmp(file + len - 4, ".lua", 4) != 0)
682 return 0;
683 if (luaL_dofile(L, file) && lua_isstring(L, -1))
685 LuaShowErr(L);
687 return 1;
689 return 0;
692 int LuaFinit(void)
694 if (!L)
695 return 0;
696 lua_close(L);
697 L = (lua_State*)0;
698 return 0;
702 LuaProcessCaption(const char *caption, struct win *win, int len)
704 if (!L)
705 return 0;
706 struct fn_def params[] = {
707 {lua_pushstring, caption},
708 {push_window, &win},
709 {lua_pushinteger, len},
710 {NULL, NULL}
712 return LuaCallProcess("process_caption", params);
715 static void
716 push_stringarray(lua_State *L, char **args)
718 int i;
719 lua_newtable(L);
720 for (i = 1; args && *args; i++) {
721 lua_pushinteger(L, i);
722 lua_pushstring(L, *args++);
723 lua_settable(L, -3);
728 LuaPushParams(lua_State *L, const char *params, va_list va)
730 int num = 0;
731 while (*params)
733 switch (*params)
735 case 's':
736 lua_pushstring(L, va_arg(va, char *));
737 break;
738 case 'S':
739 push_stringarray(L, va_arg(va, char **));
740 break;
741 case 'i':
742 lua_pushinteger(L, va_arg(va, int));
744 params++;
745 num++;
747 return num;
750 int LuaCall(char *func, char **argv)
752 int argc;
753 if (!L)
754 return 0;
756 lua_getfield(L, LUA_GLOBALSINDEX, func);
757 for (argc = 0; *argv; argv++, argc++)
759 lua_pushstring(L, *argv);
761 if (lua_pcall(L, argc, 0, 0) == LUA_ERRRUN)
763 if(lua_isstring(L, -1))
765 LuaShowErr(L);
766 return 0;
769 return 1;
772 static int
773 LuaDispatch(void *handler, const char *params, va_list va)
775 const char *func = handler;
776 int argc;
778 /*FIXME:Really need this?*/
779 lua_settop(L, 0);
781 lua_getfield(L, LUA_GLOBALSINDEX, func);
782 if (lua_isnil(L, -1))
783 return 0;
784 argc = LuaPushParams(L, params, va);
786 if (lua_pcall(L, argc, 0, 0) == LUA_ERRRUN && lua_isstring(L, -1))
788 LuaShowErr(L);
789 return 0;
791 return 1;
794 int LuaForeWindowChanged(void)
796 struct fn_def params[] = {
797 {push_display, &display},
798 {push_window, display ? &D_fore : &fore},
799 {NULL, NULL}
801 if (!L)
802 return 0;
803 return LuaCallProcess("fore_changed", params);
808 LuaCommandExecuted(const char *command, const char **args, int argc)
810 if (!L)
811 return 0;
812 struct fn_def params[] = {
813 {lua_pushstring, command},
814 {push_stringarray, args},
815 {NULL, NULL}
817 return LuaCallProcess("command_executed", params);
820 #define SEVNAME_MAX 30
821 static int
822 LuaRegEvent(lua_State *L)
824 /* signature: hook(obj, event, handler, priv);
825 * or: hook(event, handler, priv)
826 * returns: A ticket for later unregister. */
827 int idx = 1, argc = lua_gettop(L);
828 int priv = 31; /* Default privilege */
830 char *obj = NULL;
831 const char *objname = "global";
833 static char evbuf[SEVNAME_MAX];
834 const char *event, *handler;
836 struct script_event *sev;
838 /* Identify the object, if specified */
839 if (luaL_getmetafield(L, 1, "_objname"))
841 objname = luaL_checkstring(L, -1);
842 lua_pop(L, 1);
843 if (!strcmp("screen", objname))
844 objname = "global";
845 else
846 obj = *(char **)lua_touserdata(L, 1);
847 idx++;
850 event = luaL_checkstring(L, idx++);
851 snprintf(evbuf, SEVNAME_MAX, "%s_%s", objname, event);
852 handler = luaL_checkstring(L, idx++);
853 if (idx <= argc)
854 priv = luaL_checkinteger(L, idx);
856 sev = object_get_event(obj, evbuf);
857 if (sev)
859 struct listener *l;
860 l = (struct listener *)malloc(sizeof(struct listener));
861 if (!l)
862 return luaL_error(L, "Out of memory");
863 l->handler = (void *)handler;
864 l->priv = priv;
865 l->dispatcher = LuaDispatch;
866 if (register_listener(sev, l))
868 free(l);
869 return luaL_error(L, "Handler %s has already been registered", handler);
871 /*Return the handler for un-register*/
872 lua_pushlightuserdata(L, l);
874 else
875 return luaL_error(L, "Invalid event specified: %s for object %s", event, objname);
877 return 1;
880 static int
881 LuaUnRegEvent(lua_State *L)
883 /* signature: release([obj], ticket, handler)
884 * returns: true of success, false otherwise */
885 int idx = 1;
886 struct listener *l;
887 const char *handler;
889 /* If the param is not as expected */
890 if (!lua_islightuserdata(L, idx))
892 /* Then it should be the userdata to be ignore, but if not ... */
893 if (!lua_isuserdata(L, idx))
894 luaL_checktype(L, idx, LUA_TLIGHTUSERDATA);
895 idx++;
896 luaL_checktype(L, idx, LUA_TLIGHTUSERDATA);
899 l = (struct listener*)lua_touserdata(L, idx++);
900 handler = luaL_checkstring(L, idx++);
902 /*Validate the listener structure*/
903 if (!l || !l->handler
904 || strncmp((char *)handler, (char *)l->handler, SEVNAME_MAX))
906 /* invalid */
907 lua_pushboolean(L,0);
909 else
911 unregister_listener(l);
912 lua_pushboolean(L, 1);
915 return 1;
918 /** }}} */
920 struct ScriptFuncs LuaFuncs =
922 LuaForeWindowChanged,
923 LuaProcessCaption
926 struct binding lua_binding =
928 "lua", /*name*/
929 0, /*inited*/
930 0, /*registered*/
931 LuaInit,
932 LuaFinit,
933 LuaCall,
934 LuaSource,
935 0, /*b_next*/
936 &LuaFuncs