2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or (at
5 * your option) any later version.
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * Copyright © 2007 Pierre Habouzit
20 #include <lib-lib/lib-lib.h>
30 static const luaL_Reg lualibs[] = {
32 {LUA_LOADLIBNAME, luaopen_package},
33 {LUA_TABLIBNAME, luaopen_table},
34 {LUA_IOLIBNAME, luaopen_io},
35 {LUA_STRLIBNAME, luaopen_string},
36 {LUA_MATHLIBNAME, luaopen_math},
37 {LUA_DBLIBNAME, luaopen_debug},
40 static const struct luaL_Reg madmutt_module_funcs[] = {
47 } madmutt_module_vars[] = {
48 { "version", VERSION },
51 ** \fIThis is a read-only system property and specifies madmutt's
54 { "sysconfdir", SYSCONFDIR },
57 ** \fIThis is a read-only system property and specifies madmutt's
58 ** subversion revision string.\fP
63 ** \fIThis is a read-only system property and specifies the
64 ** directory containing the madmutt binary.\fP
66 { "docdir", PKGDOCDIR },
69 ** \fIThis is a read-only system property and specifies the
70 ** directory containing the madmutt documentation.\fP
73 #if defined(HAVE_QDBM)
74 {"hcache_backend", "qdbm" },
75 #elif defined(HAVE_GDBM)
76 {"hcache_backend", "gdbm" },
77 #elif defined(HAVE_DB4)
78 {"hcache_backend", "db4" },
80 {"hcache_backend", "unknown" },
84 ** \fIThis is a read-only system property and specifies the
85 ** header chaching's database backend.\fP
91 void mlua_initialize(void)
96 for (i = 0; i < countof(lualibs); i++) {
97 lua_pushcfunction(L, lualibs[i].func);
98 lua_pushstring(L, lualibs[i].name);
101 luaL_register(L, "madmutt", madmutt_module_funcs);
103 for (i = 0; i < countof(madmutt_module_vars); i++) {
106 snprintf(buffer, sizeof(buffer), "madmutt.%s = \"%s\";",
107 madmutt_module_vars[i].key,
108 madmutt_module_vars[i].value);
109 (void)luaL_dostring(L, buffer);
113 void mlua_shutdown(void)
119 int mlua_dofile(const char *filename)
121 return luaL_dofile(L, filename);
124 int mlua_wrap(void (*errfun)(const char *fmt, ...), int status)
127 (*errfun)("-[lua]-: %s\n", lua_tostring(L, -1));