]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Add preliminary implementation of lua to rcl converter.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 2 Oct 2013 14:37:56 +0000 (15:37 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 2 Oct 2013 14:37:56 +0000 (15:37 +0100)
src/lua/CMakeLists.txt
src/lua/lua_common.h
src/lua/lua_rcl.c
src/rcl/rcl.h
src/rcl/rcl_parser.c

index 762c9a10de0cb675895ea8eb9ebcc320f04e9174..4713b34051600d5c1c9be9817317c8a9c2aded96 100644 (file)
@@ -3,6 +3,7 @@ SET(LUASRC                        lua_common.c
                                          lua_task.c
                                          lua_message.c
                                          lua_config.c
+                                         lua_rcl.c
                                          lua_classifier.c
                                          lua_cfg_file.c
                                          lua_regexp.c
@@ -15,8 +16,7 @@ SET(LUASRC                      lua_common.c
                                          lua_session.c
                                          lua_buffer.c
                                          lua_dns.c
-                                         lua_rsa.c
-                                         lua_rcl.c)
+                                         lua_rsa.c)
 
 ADD_LIBRARY(rspamd-lua ${LINK_TYPE} ${LUASRC})
 SET_TARGET_PROPERTIES(rspamd-lua PROPERTIES VERSION ${RSPAMD_VERSION})
index c83433d810eef874e774a2ab9aa58af9c71045e0..7416297f772aa06b7daac5bc93a80c72b9416f59 100644 (file)
@@ -109,6 +109,13 @@ void free_lua_locked (struct lua_locked_state *st);
  */
 gint lua_rcl_obj_push (lua_State *L, rspamd_cl_object_t *obj);
 
+/**
+ * Extract rcl object from lua object
+ * @param L
+ * @return
+ */
+rspamd_cl_object_t * lua_rcl_obj_get (lua_State *L);
+
 /**
  * Open libraries functions
  */
index c992b553e6b9979559275fbcaadbd29a6f980e72..1dc17bde5544877773b84c07dd5bdc2167e8c4cb 100644 (file)
@@ -41,7 +41,7 @@ static void
 lua_rcl_obj_push_elt (lua_State *L, const char *key, rspamd_cl_object_t *obj)
 {
        lua_pushstring (L, key);
-       lua_push_obj_simple (L, obj);
+       lua_rcl_obj_push (L, obj);
        lua_settable (L, -3);
 }
 
@@ -146,3 +146,23 @@ lua_rcl_obj_push (lua_State *L, rspamd_cl_object_t *obj)
                return lua_rcl_obj_push_simple (L, obj);
        }
 }
+
+/**
+ * Extract rcl object from lua object
+ * @param L
+ * @return
+ */
+rspamd_cl_object_t *
+lua_rcl_obj_get (lua_State *L)
+{
+       rspamd_cl_object_t *obj;
+       gint t;
+
+       obj = rspamd_cl_object_new ();
+
+       if (obj != NULL) {
+               t = lua_type (L, 1);
+       }
+
+       return obj;
+}
index 3f3e5fa20a8fd6fafd2d79bef5119c480a95f5a0..5cfe03c3b15bdd90ef5e1afe78135576e9828b16 100644 (file)
@@ -80,6 +80,23 @@ typedef struct rspamd_cl_object_s {
        UT_hash_handle hh;                                              /**< hash handle                        */
 } rspamd_cl_object_t;
 
+
+/**
+ * Creates a new object
+ * @return new object
+ */
+static inline rspamd_cl_object_t *
+rspamd_cl_object_new (void)
+{
+       rspamd_cl_object_t *new;
+       new = g_slice_alloc0 (sizeof (rspamd_cl_object_t));
+       if (new != NULL) {
+               new->ref = 1;
+       }
+       return new;
+}
+
+
 /**
  * Converts an object to double value
  * @param obj CL object
index 713330ca80805aaa1692adbdfac36a535ac63bb9..7d981db913c58c926557fa6cc67e310684a29143 100644 (file)
  * The implementation of rcl parser
  */
 
-/**
- * Create a new object
- * @return new object
- */
-static inline rspamd_cl_object_t *
-rspamd_cl_object_new (void)
-{
-       rspamd_cl_object_t *new;
-       new = g_slice_alloc0 (sizeof (rspamd_cl_object_t));
-       new->ref = 1;
-       return new;
-}
-
 /**
  * Move up to len characters
  * @param parser