return LuaCallbackTuplePushToStackFromPacket(luastate, p);
}
+static int LuaCallbackLogPath(lua_State *luastate)
+{
+ const char *ld = ConfigGetLogDirectory();
+ if (ld == NULL)
+ return LuaCallbackError(luastate, "internal error: no log dir");
+
+ return LuaReturnStringBuffer(luastate, (const uint8_t *)ld, strlen(ld));
+}
+
int LogLuaRegisterFunctions(lua_State *luastate)
{
/* registration of the callbacks */
lua_pushcfunction(luastate, LuaCallbackTuple);
lua_setglobal(luastate, "SCPacketTuple");
+ lua_pushcfunction(luastate, LuaCallbackLogPath);
+ lua_setglobal(luastate, "SCLogPath");
return 0;
}
lua_getglobal(luastate, "setup");
- if (lua_pcall(luastate, 0, 0, 0) != 0) {
- SCLogError(SC_ERR_LUAJIT_ERROR, "couldn't run script 'setup' function: %s", lua_tostring(luastate, -1));
- goto error;
- }
-
/* register functions common to all */
LogLuaRegisterFunctions(luastate);
/* unconditionally register http function. They will only work
* if the tx is registered in the state at runtime though. */
LogLuaRegisterHttpFunctions(luastate);
+ if (lua_pcall(luastate, 0, 0, 0) != 0) {
+ SCLogError(SC_ERR_LUAJIT_ERROR, "couldn't run script 'setup' function: %s", lua_tostring(luastate, -1));
+ goto error;
+ }
+
SCLogDebug("lua_State %p is set up", luastate);
return luastate;
error: