diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-10-02 15:37:56 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-10-02 15:37:56 +0100 |
commit | f2d1109c8f7a450febae4d160b23bdd8f2a27465 (patch) | |
tree | 277e53af859eaf360c5227babbd9c3bdbdeb0a8c /src | |
parent | 33d45e26503db6e1a770e982e31f87ae31854ba7 (diff) | |
download | rspamd-f2d1109c8f7a450febae4d160b23bdd8f2a27465.tar.gz rspamd-f2d1109c8f7a450febae4d160b23bdd8f2a27465.zip |
Add preliminary implementation of lua to rcl converter.
Diffstat (limited to 'src')
-rw-r--r-- | src/lua/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/lua/lua_common.h | 7 | ||||
-rw-r--r-- | src/lua/lua_rcl.c | 22 | ||||
-rw-r--r-- | src/rcl/rcl.h | 17 | ||||
-rw-r--r-- | src/rcl/rcl_parser.c | 13 |
5 files changed, 47 insertions, 16 deletions
diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt index 762c9a10d..4713b3405 100644 --- a/src/lua/CMakeLists.txt +++ b/src/lua/CMakeLists.txt @@ -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}) diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index c83433d81..7416297f7 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -110,6 +110,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 */ gint luaopen_message (lua_State *L); diff --git a/src/lua/lua_rcl.c b/src/lua/lua_rcl.c index c992b553e..1dc17bde5 100644 --- a/src/lua/lua_rcl.c +++ b/src/lua/lua_rcl.c @@ -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; +} diff --git a/src/rcl/rcl.h b/src/rcl/rcl.h index 3f3e5fa20..5cfe03c3b 100644 --- a/src/rcl/rcl.h +++ b/src/rcl/rcl.h @@ -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 diff --git a/src/rcl/rcl_parser.c b/src/rcl/rcl_parser.c index 713330ca8..7d981db91 100644 --- a/src/rcl/rcl_parser.c +++ b/src/rcl/rcl_parser.c @@ -32,19 +32,6 @@ */ /** - * 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 * @param begin |