diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-09 22:36:18 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-09 22:36:18 +0000 |
commit | b0684dcde39eac33709c16ee27db197a1dfa5724 (patch) | |
tree | 6df26af33b598d21bab8e95957b5dfafc5e89419 /src/lua_worker.c | |
parent | b12ed1722e350bd55a13e34f2eb6f8d41134581d (diff) | |
download | rspamd-b0684dcde39eac33709c16ee27db197a1dfa5724.tar.gz rspamd-b0684dcde39eac33709c16ee27db197a1dfa5724.zip |
Unbreak lua_worker with ucl.
Diffstat (limited to 'src/lua_worker.c')
-rw-r--r-- | src/lua_worker.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/lua_worker.c b/src/lua_worker.c index 0849415c6..8b04b8838 100644 --- a/src/lua_worker.c +++ b/src/lua_worker.c @@ -77,6 +77,8 @@ struct rspamd_lua_worker_ctx { gint cbref_fin; /* Config file */ struct config_file *cfg; + /* The rest options */ + ucl_object_t *opts; }; /* Lua bindings */ @@ -185,13 +187,11 @@ lua_worker_register_exit_callback (lua_State *L) } /* XXX: This fucntions should be rewritten completely */ -#warning "lua_worker_get_option is broken" static int lua_worker_get_option (lua_State *L) { struct rspamd_lua_worker_ctx *ctx = lua_check_lua_worker (L); - GList *val; - gint i; + ucl_object_t *val; const gchar *name; if (ctx) { @@ -201,19 +201,12 @@ lua_worker_get_option (lua_State *L) lua_pushnil (L); } else { - val = g_hash_table_lookup (ctx->params, name); + val = ucl_object_find_key (ctx->opts, name); if (val == NULL) { lua_pushnil (L); } else { - /* Push the array */ - i = 1; - lua_newtable (L); - while (val) { - lua_pushstring (L, val->data); - lua_rawseti (L, -2, i++); - val = g_list_next (val); - } + lua_rcl_obj_push (L, val, TRUE); } } } @@ -399,6 +392,16 @@ lua_accept_socket (gint fd, short what, void *arg) } } +static gboolean +rspamd_lua_worker_parser (ucl_object_t *obj, gpointer ud) +{ + struct rspamd_lua_worker_ctx *ctx = ud; + + ctx->opts = obj; + + return TRUE; +} + gpointer init_lua_worker (struct config_file *cfg) { @@ -415,6 +418,8 @@ init_lua_worker (struct config_file *cfg) rspamd_rcl_parse_struct_string, ctx, G_STRUCT_OFFSET (struct rspamd_lua_worker_ctx, file), 0); + rspamd_rcl_register_worker_parser (cfg, type, rspamd_lua_worker_parser, ctx); + return ctx; } |