{NULL, NULL}
};
-int my_lua_panic (lua_State *lua) {
- lua_getfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND");
- LUABackend* lb = (LUABackend*)lua_touserdata(lua, -1);
+int my_lua_panic (lua_State *lua_state) {
+ lua_getfield(lua_state, LUA_REGISTRYINDEX, "__LUABACKEND");
+ LUABackend* lb = (LUABackend*)lua_touserdata(lua_state, -1);
- assert(lua == lb->lua);
+ assert(lua_state == lb->lua);
stringstream e;
- e << lb->backend_name << "LUA PANIC! '" << lua_tostring(lua,-1) << "'" << endl;
+ e << lb->backend_name << "LUA PANIC! '" << lua_tostring(lua_state,-1) << "'" << endl;
throw LUAException (e.str());
return 0;
}
-int l_arg_get (lua_State *lua) {
- int i = lua_gettop(lua);
+int l_arg_get (lua_State *lua_state) {
+ int i = lua_gettop(lua_state);
if (i < 1)
return 0;
- lua_getfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND");
- LUABackend* lb = (LUABackend*)lua_touserdata(lua, -1);
+ lua_getfield(lua_state, LUA_REGISTRYINDEX, "__LUABACKEND");
+ LUABackend* lb = (LUABackend*)lua_touserdata(lua_state, -1);
- string a = lua_tostring(lua, 1);
+ string a = lua_tostring(lua_state, 1);
if (lb->my_isEmpty(a))
- lua_pushnil(lua);
+ lua_pushnil(lua_state);
else
- lua_pushstring(lua, lb->my_getArg(a).c_str());
+ lua_pushstring(lua_state, lb->my_getArg(a).c_str());
return 1;
}
-int l_arg_mustdo (lua_State *lua) {
- int i = lua_gettop(lua);
+int l_arg_mustdo (lua_State *lua_state) {
+ int i = lua_gettop(lua_state);
if (i < 1)
return 0;
- lua_getfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND");
- LUABackend* lb = (LUABackend*)lua_touserdata(lua, -1);
+ lua_getfield(lua_state, LUA_REGISTRYINDEX, "__LUABACKEND");
+ LUABackend* lb = (LUABackend*)lua_touserdata(lua_state, -1);
- string a = lua_tostring(lua, 1);
+ string a = lua_tostring(lua_state, 1);
if (lb->my_isEmpty(a))
- lua_pushnil(lua);
+ lua_pushnil(lua_state);
else
- lua_pushboolean(lua, lb->my_mustDo(a));
+ lua_pushboolean(lua_state, lb->my_mustDo(a));
return 1;
}
-int l_dnspacket (lua_State *lua) {
- lua_getfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND");
- LUABackend* lb = (LUABackend*)lua_touserdata(lua, -1);
+int l_dnspacket (lua_State *lua_state) {
+ lua_getfield(lua_state, LUA_REGISTRYINDEX, "__LUABACKEND");
+ LUABackend* lb = (LUABackend*)lua_touserdata(lua_state, -1);
if (lb->dnspacket == NULL) {
- lua_pushnil(lua);
+ lua_pushnil(lua_state);
return 1;
}
- lua_pushstring(lua, lb->dnspacket->getRemote().toString().c_str());
- lua_pushinteger(lua, lb->dnspacket->getRemotePort());
- lua_pushstring(lua, lb->dnspacket->getLocal().toString().c_str());
- lua_pushstring(lua, lb->dnspacket->getRealRemote().toString().c_str());
+ lua_pushstring(lua_state, lb->dnspacket->getRemote().toString().c_str());
+ lua_pushinteger(lua_state, lb->dnspacket->getRemotePort());
+ lua_pushstring(lua_state, lb->dnspacket->getLocal().toString().c_str());
+ lua_pushstring(lua_state, lb->dnspacket->getRealRemote().toString().c_str());
return 4;
}
-int l_logger (lua_State *lua) {
+int l_logger (lua_State *lua_state) {
- int i = lua_gettop(lua);
+ int i = lua_gettop(lua_state);
if (i < 1)
return 0;
- lua_getfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND");
- LUABackend* lb = (LUABackend*)lua_touserdata(lua, -1);
+ lua_getfield(lua_state, LUA_REGISTRYINDEX, "__LUABACKEND");
+ LUABackend* lb = (LUABackend*)lua_touserdata(lua_state, -1);
int log_level = 0;
stringstream s;
int j;
const char *ss;
- log_level = lua_tointeger(lua, 1);
+ log_level = lua_tointeger(lua_state, 1);
string space = "";
for(j=2; j<=i; j++) {
- ss = lua_tostring(lua, j);
+ ss = lua_tostring(lua_state, j);
s << space << ss;
space = " ";
}
return 0;
}
-void register_lua_functions(lua_State *lua) {
- lua_gc(lua, LUA_GCSTOP, 0); // stop collector during initialization
+void register_lua_functions(lua_State *lua_state) {
+ lua_gc(lua_state, LUA_GCSTOP, 0); // stop collector during initialization
const luaL_Reg *lib = lualibs;
for (; lib->func; lib++) {
#if LUA_VERSION_NUM < 502
- lua_pushcfunction(lua, lib->func);
- lua_pushstring(lua, lib->name);
- lua_call(lua, 1, 0);
+ lua_pushcfunction(lua_state, lib->func);
+ lua_pushstring(lua_state, lib->name);
+ lua_call(lua_state, 1, 0);
#else
- luaL_requiref(lua, lib->name, lib->func, 1);
- lua_pop(lua, 1); /* remove lib */
+ luaL_requiref(lua_state, lib->name, lib->func, 1);
+ lua_pop(lua_state, 1); /* remove lib */
#endif
}
- lua_gc(lua, LUA_GCRESTART, 0);
+ lua_gc(lua_state, LUA_GCRESTART, 0);
- lua_pushinteger(lua, Logger::All);
- lua_setglobal(lua, "log_all");
+ lua_pushinteger(lua_state, Logger::All);
+ lua_setglobal(lua_state, "log_all");
- lua_pushinteger(lua, Logger::Alert);
- lua_setglobal(lua, "log_alert");
+ lua_pushinteger(lua_state, Logger::Alert);
+ lua_setglobal(lua_state, "log_alert");
- lua_pushinteger(lua, Logger::Critical);
- lua_setglobal(lua, "log_critical");
+ lua_pushinteger(lua_state, Logger::Critical);
+ lua_setglobal(lua_state, "log_critical");
- lua_pushinteger(lua, Logger::Error);
- lua_setglobal(lua, "log_error");
+ lua_pushinteger(lua_state, Logger::Error);
+ lua_setglobal(lua_state, "log_error");
- lua_pushinteger(lua, Logger::Warning);
- lua_setglobal(lua, "log_warning");
+ lua_pushinteger(lua_state, Logger::Warning);
+ lua_setglobal(lua_state, "log_warning");
- lua_pushinteger(lua, Logger::Notice);
- lua_setglobal(lua, "log_notice");
+ lua_pushinteger(lua_state, Logger::Notice);
+ lua_setglobal(lua_state, "log_notice");
- lua_pushinteger(lua, Logger::Info);
- lua_setglobal(lua, "log_info");
+ lua_pushinteger(lua_state, Logger::Info);
+ lua_setglobal(lua_state, "log_info");
- lua_pushinteger(lua, Logger::Debug);
- lua_setglobal(lua, "log_debug");
+ lua_pushinteger(lua_state, Logger::Debug);
+ lua_setglobal(lua_state, "log_debug");
- lua_pushinteger(lua, Logger::None);
- lua_setglobal(lua, "log_none");
+ lua_pushinteger(lua_state, Logger::None);
+ lua_setglobal(lua_state, "log_none");
- lua_pushcfunction(lua, l_dnspacket);
- lua_setglobal(lua, "dnspacket");
+ lua_pushcfunction(lua_state, l_dnspacket);
+ lua_setglobal(lua_state, "dnspacket");
- lua_pushcfunction(lua, l_logger);
- lua_setglobal(lua, "logger");
+ lua_pushcfunction(lua_state, l_logger);
+ lua_setglobal(lua_state, "logger");
- lua_pushcfunction(lua, l_arg_get);
- lua_setglobal(lua, "getarg");
+ lua_pushcfunction(lua_state, l_arg_get);
+ lua_setglobal(lua_state, "getarg");
- lua_pushcfunction(lua, l_arg_mustdo);
- lua_setglobal(lua, "mustdo");
+ lua_pushcfunction(lua_state, l_arg_mustdo);
+ lua_setglobal(lua_state, "mustdo");
- lua_newtable(lua);
+ lua_newtable(lua_state);
for(vector<QType::namenum>::const_iterator iter = QType::names.begin(); iter != QType::names.end(); ++iter) {
- lua_pushinteger(lua, iter->second);
- lua_setfield(lua, -2, iter->first.c_str());
+ lua_pushinteger(lua_state, iter->second);
+ lua_setfield(lua_state, -2, iter->first.c_str());
}
- lua_pushinteger(lua, 3);
- lua_setfield(lua, -2, "NXDOMAIN");
- lua_setglobal(lua, "QTypes");
+ lua_pushinteger(lua_state, 3);
+ lua_setfield(lua_state, -2, "NXDOMAIN");
+ lua_setglobal(lua_state, "QTypes");
}
bool LUABackend::getValueFromTable(lua_State *lua_state, const std::string& key, string& value) {