lua: remove LogLua prefix and replace it with Lua

Preparing making code available to more than just output.
pull/1112/head
Victor Julien 11 years ago
parent e0d544fb86
commit fdc73eeba6

@ -76,7 +76,7 @@ const char *LuaGetStringArgument(lua_State *luastate, int argc)
return str; return str;
} }
void LogLuaPushTableKeyValueInt(lua_State *luastate, const char *key, int value) void LuaPushTableKeyValueInt(lua_State *luastate, const char *key, int value)
{ {
lua_pushstring(luastate, key); lua_pushstring(luastate, key);
lua_pushnumber(luastate, value); lua_pushnumber(luastate, value);
@ -87,14 +87,14 @@ void LogLuaPushTableKeyValueInt(lua_State *luastate, const char *key, int value)
* *
* If value is NULL, string "(null")" will be put on the stack. * If value is NULL, string "(null")" will be put on the stack.
*/ */
void LogLuaPushTableKeyValueString(lua_State *luastate, const char *key, const char *value) void LuaPushTableKeyValueString(lua_State *luastate, const char *key, const char *value)
{ {
lua_pushstring(luastate, key); lua_pushstring(luastate, key);
lua_pushstring(luastate, value ? value : "(null)"); lua_pushstring(luastate, value ? value : "(null)");
lua_settable(luastate, -3); lua_settable(luastate, -3);
} }
void LogLuaPushTableKeyValueArray(lua_State *luastate, const char *key, const uint8_t *value, size_t len) void LuaPushTableKeyValueArray(lua_State *luastate, const char *key, const uint8_t *value, size_t len)
{ {
lua_pushstring(luastate, key); lua_pushstring(luastate, key);
LuaPushStringBuffer(luastate, value, len); LuaPushStringBuffer(luastate, value, len);
@ -693,7 +693,7 @@ static int LuaCallbackThreadInfo(lua_State *luastate)
return LuaCallbackThreadInfoPushToStackFromThreadVars(luastate, tv); return LuaCallbackThreadInfoPushToStackFromThreadVars(luastate, tv);
} }
int LogLuaRegisterFunctions(lua_State *luastate) int LuaRegisterFunctions(lua_State *luastate)
{ {
/* registration of the callbacks */ /* registration of the callbacks */
lua_pushcfunction(luastate, LuaCallbackPacketPayload); lua_pushcfunction(luastate, LuaCallbackPacketPayload);

@ -29,11 +29,11 @@
int LuaCallbackError(lua_State *luastate, const char *msg); int LuaCallbackError(lua_State *luastate, const char *msg);
const char *LuaGetStringArgument(lua_State *luastate, int argc); const char *LuaGetStringArgument(lua_State *luastate, int argc);
void LogLuaPushTableKeyValueInt(lua_State *luastate, const char *key, int value); void LuaPushTableKeyValueInt(lua_State *luastate, const char *key, int value);
void LogLuaPushTableKeyValueString(lua_State *luastate, const char *key, const char *value); void LuaPushTableKeyValueString(lua_State *luastate, const char *key, const char *value);
void LogLuaPushTableKeyValueArray(lua_State *luastate, const char *key, const uint8_t *value, size_t len); void LuaPushTableKeyValueArray(lua_State *luastate, const char *key, const uint8_t *value, size_t len);
int LogLuaRegisterFunctions(lua_State *luastate); int LuaRegisterFunctions(lua_State *luastate);
#endif /* HAVE_LUA */ #endif /* HAVE_LUA */

@ -93,7 +93,7 @@ static int LuaTxLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow
/* prepare data to pass to script */ /* prepare data to pass to script */
lua_getglobal(td->lua_ctx->luastate, "log"); lua_getglobal(td->lua_ctx->luastate, "log");
lua_newtable(td->lua_ctx->luastate); lua_newtable(td->lua_ctx->luastate);
LogLuaPushTableKeyValueInt(td->lua_ctx->luastate, "tx_id", (int)(tx_id)); LuaPushTableKeyValueInt(td->lua_ctx->luastate, "tx_id", (int)(tx_id));
int retval = lua_pcall(td->lua_ctx->luastate, 1, 0, 0); int retval = lua_pcall(td->lua_ctx->luastate, 1, 0, 0);
if (retval != 0) { if (retval != 0) {
@ -140,7 +140,7 @@ static int LuaStreamingLogger(ThreadVars *tv, void *thread_data, const Flow *f,
lua_newtable(td->lua_ctx->luastate); lua_newtable(td->lua_ctx->luastate);
if (flags & OUTPUT_STREAMING_FLAG_TRANSACTION) if (flags & OUTPUT_STREAMING_FLAG_TRANSACTION)
LogLuaPushTableKeyValueInt(td->lua_ctx->luastate, "tx_id", (int)(tx_id)); LuaPushTableKeyValueInt(td->lua_ctx->luastate, "tx_id", (int)(tx_id));
int retval = lua_pcall(td->lua_ctx->luastate, 1, 0, 0); int retval = lua_pcall(td->lua_ctx->luastate, 1, 0, 0);
if (retval != 0) { if (retval != 0) {
@ -543,7 +543,7 @@ static lua_State *LuaScriptSetup(const char *filename)
lua_getglobal(luastate, "setup"); lua_getglobal(luastate, "setup");
/* register functions common to all */ /* register functions common to all */
LogLuaRegisterFunctions(luastate); LuaRegisterFunctions(luastate);
/* unconditionally register http function. They will only work /* unconditionally register http function. They will only work
* if the tx is registered in the state at runtime though. */ * if the tx is registered in the state at runtime though. */
LuaRegisterHttpFunctions(luastate); LuaRegisterHttpFunctions(luastate);

Loading…
Cancel
Save