]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Move function to the common routines
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 1 Jan 2020 19:45:48 +0000 (19:45 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 1 Jan 2020 19:46:31 +0000 (19:46 +0000)
src/lua/lua_common.c
src/lua/lua_common.h
src/lua/lua_regexp.c

index 80a9423d997818f8132c404cd57d84fecadf4535..248f1dbc350523f1c79697b503390703544530c7 100644 (file)
@@ -2346,4 +2346,35 @@ rspamd_lua_push_words (lua_State *L, GArray *words,
        }
 
        return 1;
+}
+
+gchar *
+rspamd_lua_get_module_name (lua_State *L)
+{
+       lua_Debug d;
+       gchar *p;
+       gchar func_buf[128];
+
+       if (lua_getstack (L, 1, &d) == 1) {
+               (void) lua_getinfo (L, "Sl", &d);
+               if ((p = strrchr (d.short_src, '/')) == NULL) {
+                       p = d.short_src;
+               }
+               else {
+                       p++;
+               }
+
+               if (strlen (p) > 20) {
+                       rspamd_snprintf (func_buf, sizeof (func_buf), "%10s...]:%d", p,
+                                       d.currentline);
+               }
+               else {
+                       rspamd_snprintf (func_buf, sizeof (func_buf), "%s:%d", p,
+                                       d.currentline);
+               }
+
+               return g_strdup (func_buf);
+       }
+
+       return NULL;
 }
\ No newline at end of file
index 7980272eac80b77dba0ba943d505505cc5364e99..935a7c7d76baa6c7c4dbc0c1a2af1529edbb5495 100644 (file)
@@ -559,6 +559,13 @@ enum rspamd_lua_words_type {
 gint rspamd_lua_push_words (lua_State *L, GArray *words,
                                                        enum rspamd_lua_words_type how);
 
+/**
+ * Returns newly allocated name for caller module name
+ * @param L
+ * @return
+ */
+gchar *rspamd_lua_get_module_name (lua_State *L);
+
 /* Paths defs */
 #define RSPAMD_CONFDIR_INDEX "CONFDIR"
 #define RSPAMD_LOCAL_CONFDIR_INDEX "LOCAL_CONFDIR"
index 70a5a5df402181a14e5298872e44cebe69ada895..b782ef7f107fd09629eb465d937990801d88c496 100644 (file)
@@ -81,37 +81,6 @@ lua_check_regexp (lua_State * L, gint pos)
        return ud ? *((struct rspamd_lua_regexp **)ud) : NULL;
 }
 
-static gchar *
-rspamd_lua_get_module_name (lua_State *L)
-{
-       lua_Debug d;
-       gchar *p;
-       gchar func_buf[128];
-
-       if (lua_getstack (L, 1, &d) == 1) {
-               (void) lua_getinfo (L, "Sl", &d);
-               if ((p = strrchr (d.short_src, '/')) == NULL) {
-                       p = d.short_src;
-               }
-               else {
-                       p++;
-               }
-
-               if (strlen (p) > 20) {
-                       rspamd_snprintf (func_buf, sizeof (func_buf), "%10s...]:%d", p,
-                                       d.currentline);
-               }
-               else {
-                       rspamd_snprintf (func_buf, sizeof (func_buf), "%s:%d", p,
-                                       d.currentline);
-               }
-
-               return g_strdup (func_buf);
-       }
-
-       return NULL;
-}
-
 /***
  * @function rspamd_regexp.create(pattern[, flags])
  * Creates new rspamd_regexp