aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_common.h
blob: ab06166b3b7f137dbd766ce3e36cb5060fa31e47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef RSPAMD_LUA_H
#define RSPAMD_LUA_H

#include "../config.h"
#ifdef WITH_LUA

#include "../main.h"
#include "../cfg_file.h"
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>

/* Interface definitions */
#define LUA_FUNCTION_DEF(class, name) static int lua_##class##_##name(lua_State *L)
#define LUA_INTERFACE_DEF(class, name) { #name, lua_##class##_##name }

extern const luaL_reg null_reg[];

void lua_newclass (lua_State *L, const char *classname, const struct luaL_reg *func);
void lua_setclass (lua_State *L, const char *classname, int objidx);
void lua_set_table_index (lua_State *L, const char *index, const char *value);
int lua_class_tostring (lua_State *L);
int luaopen_message (lua_State *L);
int luaopen_task (lua_State *L);
int luaopen_config (lua_State *L);
int luaopen_metric (lua_State *L);
int luaopen_textpart (lua_State *L);
void init_lua_filters (struct config_file *cfg);

int lua_call_filter (const char *function, struct worker_task *task);
int lua_call_chain_filter (const char *function, struct worker_task *task, int *marks, unsigned int number);
double lua_consolidation_func (struct worker_task *task, const char *metric_name, const char *function_name);
void add_luabuf (const char *line);

#endif /* WITH_LUA */
#endif /* RSPAMD_LUA_H */