]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output-lua: move LuaPrintStack to common
authorVictor Julien <victor@inliniac.net>
Thu, 20 Feb 2014 14:45:33 +0000 (15:45 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 15 Aug 2014 11:58:25 +0000 (13:58 +0200)
It's a utility function that will be used in several other places
as well.

src/output-lua-common.c
src/output-lua.c

index 027d4ef8020de12dce0106d991c4b71b6f44c122..ae4384ed9f70cee629e01057e317a3b41cdd5fa8 100644 (file)
 #include <lualib.h>
 #include <lauxlib.h>
 
+/** \brief dump stack from lua state to screen */
+void LuaPrintStack(lua_State *state) {
+    int size = lua_gettop(state);
+    int i;
+
+    for (i = 1; i <= size; i++) {
+        int type = lua_type(state, i);
+        printf("Stack size=%d, level=%d, type=%d, ", size, i, type);
+
+        switch (type) {
+            case LUA_TFUNCTION:
+                printf("function %s", lua_tostring(state, i) ? "true" : "false");
+                break;
+            case LUA_TBOOLEAN:
+                printf("bool %s", lua_toboolean(state, i) ? "true" : "false");
+                break;
+            case LUA_TNUMBER:
+                printf("number %g", lua_tonumber(state, i));
+                break;
+            case LUA_TSTRING:
+                printf("string `%s'", lua_tostring(state, i));
+                break;
+            case LUA_TTABLE:
+                printf("table `%s'", lua_tostring(state, i));
+                break;
+            default:
+                printf("other %s", lua_typename(state, type));
+                break;
+
+        }
+        printf("\n");
+    }
+}
+
 extern const char lualog_ext_key_tx;
 
 void *LuaStateGetTX(lua_State *luastate)
index fc579991edf75c5b820e9f707f95010087252108..8ed2a1062db6fb3b06a0b318fad30acf4807e5aa 100644 (file)
@@ -53,6 +53,7 @@
 #include <lualib.h>
 #include <lauxlib.h>
 
+#include "output-lua-common.h"
 #include "output-lua-http.h"
 
 #define MODULE_NAME "LuaLog"
@@ -69,40 +70,6 @@ typedef struct LogLuaThreadCtx_ {
 
 const char lualog_ext_key_tx[] = "suricata:lualog:tx:ptr";
 
-/** \brief dump stack from lua state to screen */
-void LuaPrintStack(lua_State *state) {
-    int size = lua_gettop(state);
-    int i;
-
-    for (i = 1; i <= size; i++) {
-        int type = lua_type(state, i);
-        printf("Stack size=%d, level=%d, type=%d, ", size, i, type);
-
-        switch (type) {
-            case LUA_TFUNCTION:
-                printf("function %s", lua_tostring(state, i) ? "true" : "false");
-                break;
-            case LUA_TBOOLEAN:
-                printf("bool %s", lua_toboolean(state, i) ? "true" : "false");
-                break;
-            case LUA_TNUMBER:
-                printf("number %g", lua_tonumber(state, i));
-                break;
-            case LUA_TSTRING:
-                printf("string `%s'", lua_tostring(state, i));
-                break;
-            case LUA_TTABLE:
-                printf("table `%s'", lua_tostring(state, i));
-                break;
-            default:
-                printf("other %s", lua_typename(state, type));
-                break;
-
-        }
-        printf("\n");
-    }
-}
-
 static int LuaTxLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, void *alstate, void *txptr, uint64_t tx_id)
 {
     SCEnter();