diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-07-23 12:57:31 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-07-23 12:57:31 +0100 |
commit | 379055dbbb4af997b4d3ffb161d447872d7ca357 (patch) | |
tree | 3774553d470f93e12ddeb454aad9b3b607cf8918 /src/lua/lua_common.h | |
parent | 602ae7a0b7e215ba2677131b8fdc70abc156b3ca (diff) | |
download | rspamd-379055dbbb4af997b4d3ffb161d447872d7ca357.tar.gz rspamd-379055dbbb4af997b4d3ffb161d447872d7ca357.zip |
Unify style without sorting headers.
Diffstat (limited to 'src/lua/lua_common.h')
-rw-r--r-- | src/lua/lua_common.h | 90 |
1 files changed, 61 insertions, 29 deletions
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index ca0ab6d28..a9f0d399a 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -13,17 +13,17 @@ #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,17 +32,18 @@ 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[]; @@ -59,12 +60,18 @@ 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 @@ -94,7 +101,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 @@ -104,7 +111,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 */ @@ -163,29 +170,54 @@ 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 */ |