diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-07-23 12:53:08 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-07-23 12:53:08 +0100 |
commit | fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b (patch) | |
tree | c84e6a5d4c5cd78a7a2cc3c7adbc7af5d0541682 /src/lua/lua_common.h | |
parent | e0483657ff6cf1adc828ccce457814d61fe90a0d (diff) | |
download | rspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.tar.gz rspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.zip |
Revert "Unify code style."
This reverts commit e0483657ff6cf1adc828ccce457814d61fe90a0d.
Diffstat (limited to 'src/lua/lua_common.h')
-rw-r--r-- | src/lua/lua_common.h | 96 |
1 files changed, 32 insertions, 64 deletions
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index 093d27483..ca0ab6d28 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -4,26 +4,26 @@ #include "config.h" #ifdef WITH_LUA -#include "cfg_file.h" -#include "lua_ucl.h" #include "main.h" +#include "cfg_file.h" #include "ucl.h" -#include <lauxlib.h> +#include "lua_ucl.h" #include <lua.h> +#include <lauxlib.h> #include <lualib.h> #ifndef lua_open -#define lua_open() luaL_newstate () +#define lua_open() luaL_newstate() #endif #ifndef luaL_reg -#define luaL_reg luaL_Reg +#define luaL_reg luaL_Reg #endif #define LUA_ENUM(L, name, val) \ - lua_pushlstring (L, # name, sizeof(# name) - 1); \ - lua_pushnumber (L, val); \ - lua_settable (L, -3); + lua_pushlstring(L, #name, sizeof(#name)-1); \ + lua_pushnumber(L, val); \ + lua_settable(L, -3); #if LUA_VERSION_NUM > 501 static inline void @@ -32,18 +32,17 @@ luaL_register (lua_State *L, const gchar *name, const struct luaL_reg *methods) if (name != NULL) { lua_newtable (L); } - luaL_setfuncs (L, methods, 0); - if (name != NULL) { - lua_pushvalue (L, -1); - lua_setglobal (L, name); - } + luaL_setfuncs (L, methods, 0); + if (name != NULL) { + lua_pushvalue (L, -1); + lua_setglobal (L, name); + } } #endif /* Interface definitions */ -#define LUA_FUNCTION_DEF(class, name) static gint lua_ ## class ## _ ## name ( \ - lua_State * L) -#define LUA_INTERFACE_DEF(class, name) { # name, lua_ ## class ## _ ## name } +#define LUA_FUNCTION_DEF(class, name) static gint lua_##class##_##name(lua_State *L) +#define LUA_INTERFACE_DEF(class, name) { #name, lua_##class##_##name } extern const luaL_reg null_reg[]; @@ -60,18 +59,12 @@ struct lua_locked_state { /** * Create and register new class */ -void lua_newclass (lua_State *L, - const gchar *classname, - const struct luaL_reg *methods); +void lua_newclass (lua_State *L, const gchar *classname, const struct luaL_reg *methods); /** * Create and register new class with static methods */ -void lua_newclass_full (lua_State *L, - const gchar *classname, - const gchar *static_name, - const struct luaL_reg *methods, - const struct luaL_reg *func); +void lua_newclass_full (lua_State *L, const gchar *classname, const gchar *static_name, const struct luaL_reg *methods, const struct luaL_reg *func); /** * Set class name for object at @param objidx position @@ -101,7 +94,7 @@ gpointer lua_check_class (lua_State *L, gint index, const gchar *name); /** * Initialize lua and bindings */ -lua_State * init_lua (struct rspamd_config *cfg); +lua_State* init_lua (struct rspamd_config *cfg); /** * Load and initialize lua plugins @@ -111,7 +104,7 @@ gboolean init_lua_filters (struct rspamd_config *cfg); /** * Initialize new locked lua_State structure */ -struct lua_locked_state * init_lua_locked (struct rspamd_config *cfg); +struct lua_locked_state* init_lua_locked (struct rspamd_config *cfg); /** * Free locked state structure */ @@ -170,54 +163,29 @@ gint luaopen_rsa (lua_State * L); gint luaopen_ip (lua_State * L); gint lua_call_filter (const gchar *function, struct rspamd_task *task); -gint lua_call_chain_filter (const gchar *function, - struct rspamd_task *task, - gint *marks, - guint number); -double lua_consolidation_func (struct rspamd_task *task, - const gchar *metric_name, - const gchar *function_name); -gboolean lua_call_expression_func (gpointer lua_data, - struct rspamd_task *task, - GList *args, - gboolean *res); +gint lua_call_chain_filter (const gchar *function, struct rspamd_task *task, gint *marks, guint number); +double lua_consolidation_func (struct rspamd_task *task, const gchar *metric_name, const gchar *function_name); +gboolean lua_call_expression_func (gpointer lua_data, struct rspamd_task *task, GList *args, gboolean *res); void lua_call_post_filters (struct rspamd_task *task); void lua_call_pre_filters (struct rspamd_task *task); void add_luabuf (const gchar *line); /* Classify functions */ -GList * call_classifier_pre_callbacks (struct rspamd_classifier_config *ccf, - struct rspamd_task *task, - gboolean is_learn, - gboolean is_spam, - lua_State *L); -double call_classifier_post_callbacks (struct rspamd_classifier_config *ccf, - struct rspamd_task *task, - double in, - lua_State *L); - -double lua_normalizer_func (struct rspamd_config *cfg, - long double score, - void *params); +GList *call_classifier_pre_callbacks (struct rspamd_classifier_config *ccf, struct rspamd_task *task, gboolean is_learn, gboolean is_spam, lua_State *L); +double call_classifier_post_callbacks (struct rspamd_classifier_config *ccf, struct rspamd_task *task, double in, lua_State *L); + +double lua_normalizer_func (struct rspamd_config *cfg, long double score, void *params); /* Config file functions */ void lua_post_load_config (struct rspamd_config *cfg); -void lua_process_element (struct rspamd_config *cfg, - const gchar *name, - const gchar *module_name, - struct rspamd_module_opt *opt, - gint idx, - gboolean allow_meta); -gboolean lua_handle_param (struct rspamd_task *task, - gchar *mname, - gchar *optname, - enum lua_var_type expected_type, - gpointer *res); -gboolean lua_check_condition (struct rspamd_config *cfg, - const gchar *condition); +void lua_process_element (struct rspamd_config *cfg, const gchar *name, + const gchar *module_name, struct rspamd_module_opt *opt, gint idx, gboolean allow_meta); +gboolean lua_handle_param (struct rspamd_task *task, gchar *mname, gchar *optname, + enum lua_var_type expected_type, gpointer *res); +gboolean lua_check_condition (struct rspamd_config *cfg, const gchar *condition); void lua_dumpstack (lua_State *L); -struct memory_pool_s * lua_check_mempool (lua_State * L); +struct memory_pool_s *lua_check_mempool (lua_State * L); #endif /* WITH_LUA */ |