Selaa lähdekoodia

Use modules preload for lua.

tags/0.7.0
Vsevolod Stakhov 9 vuotta sitten
vanhempi
commit
c2765b3eb3

+ 12
- 7
src/lua/lua_buffer.c Näytä tiedosto



/* Public prototypes */ /* Public prototypes */
struct rspamd_io_dispatcher_s * lua_check_io_dispatcher (lua_State * L); struct rspamd_io_dispatcher_s * lua_check_io_dispatcher (lua_State * L);
gint luaopen_io_dispatcher (lua_State * L);
void luaopen_io_dispatcher (lua_State * L);


/* Lua bindings */ /* Lua bindings */
LUA_FUNCTION_DEF (io_dispatcher, create); LUA_FUNCTION_DEF (io_dispatcher, create);
return 1; return 1;
} }


static gint
lua_load_dispatcher (lua_State *L)
{
lua_newtable (L);
luaL_register (L, NULL, io_dispatcherlib_f);

return 1;
}


gint

void
luaopen_io_dispatcher (lua_State * L) luaopen_io_dispatcher (lua_State * L)
{ {
luaL_newmetatable (L, "rspamd{io_dispatcher}"); luaL_newmetatable (L, "rspamd{io_dispatcher}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, io_dispatcherlib_m); luaL_register (L, NULL, io_dispatcherlib_m);
luaL_register (L, "rspamd_io_dispatcher", io_dispatcherlib_f);

lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */
rspamd_lua_add_preload (L, "rspamd_io_dispatcher", lua_load_dispatcher);


/* Simple event class */ /* Simple event class */
rspamd_lua_new_class (L, "rspamd{ev_base}", null_reg); rspamd_lua_new_class (L, "rspamd{ev_base}", null_reg);
luaL_register (L, "rspamd_ev_base", null_reg);

lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */


/* Set buffer types globals */ /* Set buffer types globals */
lua_setglobal (L, "IO_BUFFER_CHARACTER"); lua_setglobal (L, "IO_BUFFER_CHARACTER");
lua_pushnumber (L, BUFFER_ANY); lua_pushnumber (L, BUFFER_ANY);
lua_setglobal (L, "IO_BUFFER_ANY"); lua_setglobal (L, "IO_BUFFER_ANY");
return 1;
} }

+ 11
- 4
src/lua/lua_cdb.c Näytä tiedosto

return 0; return 0;
} }


gint
static gint
lua_load_cdb (lua_State *L)
{
lua_newtable (L);
luaL_register (L, NULL, cdblib_f);

return 1;
}

void
luaopen_cdb (lua_State * L) luaopen_cdb (lua_State * L)
{ {
luaL_newmetatable (L, "rspamd{cdb}"); luaL_newmetatable (L, "rspamd{cdb}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, cdblib_m); luaL_register (L, NULL, cdblib_m);
luaL_register (L, "cdb", cdblib_f);

lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */


return 1;
rspamd_lua_add_preload (L, "rspamd_cdb", lua_load_cdb);
} }

+ 2
- 10
src/lua/lua_classifier.c Näytä tiedosto



/* Open functions */ /* Open functions */


gint
void
luaopen_classifier (lua_State * L) luaopen_classifier (lua_State * L)
{ {
rspamd_lua_new_class (L, "rspamd{classifier}", classifierlib_m); rspamd_lua_new_class (L, "rspamd{classifier}", classifierlib_m);
luaL_register (L, "rspamd_classifier", null_reg);

lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }


gint
void
luaopen_statfile (lua_State * L) luaopen_statfile (lua_State * L)
{ {
rspamd_lua_new_class (L, "rspamd{statfile}", statfilelib_m); rspamd_lua_new_class (L, "rspamd{statfile}", statfilelib_m);
luaL_register (L, "rspamd_statfile", null_reg);

lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }



+ 46
- 39
src/lua/lua_common.c Näytä tiedosto



/*** Init functions ***/ /*** Init functions ***/


gint
luaopen_rspamd (lua_State * L)
static gint
lua_load_logger (lua_State *L)
{ {
luaL_register (L, "rspamd", null_reg);
/* make version string available to scripts */
lua_pushstring (L, "_VERSION");
lua_pushstring (L, RVERSION);
lua_rawset (L, -3);
lua_newtable (L);
luaL_register (L, NULL, loggerlib_f);


return 1; return 1;
} }


static gint
static void
luaopen_logger (lua_State * L) luaopen_logger (lua_State * L)
{ {

luaL_register (L, "rspamd_logger", loggerlib_f);
return 1;
rspamd_lua_add_preload (L, "rspamd_logger", lua_load_logger);
} }




L = luaL_newstate (); L = luaL_newstate ();
luaL_openlibs (L); luaL_openlibs (L);


(void)luaopen_rspamd (L);
(void)luaopen_logger (L);
(void)luaopen_mempool (L);
(void)luaopen_config (L);
(void)luaopen_radix (L);
(void)luaopen_hash_table (L);
(void)luaopen_trie (L);
(void)luaopen_task (L);
(void)luaopen_textpart (L);
(void)luaopen_mimepart (L);
(void)luaopen_image (L);
(void)luaopen_url (L);
(void)luaopen_message (L);
(void)luaopen_classifier (L);
(void)luaopen_statfile (L);
(void)luaopen_glib_regexp (L);
(void)luaopen_cdb (L);
(void)luaopen_xmlrpc (L);
(void)luaopen_http (L);
(void)luaopen_redis (L);
(void)luaopen_upstream (L);
(void)lua_add_actions_global (L);
(void)luaopen_session (L);
(void)luaopen_io_dispatcher (L);
(void)luaopen_dns_resolver (L);
(void)luaopen_rsa (L);
(void)luaopen_ip (L);
(void)luaopen_ucl (L);
luaopen_logger (L);
luaopen_mempool (L);
luaopen_config (L);
luaopen_radix (L);
luaopen_hash_table (L);
luaopen_trie (L);
luaopen_task (L);
luaopen_textpart (L);
luaopen_mimepart (L);
luaopen_image (L);
luaopen_url (L);
luaopen_message (L);
luaopen_classifier (L);
luaopen_statfile (L);
luaopen_glib_regexp (L);
luaopen_cdb (L);
luaopen_xmlrpc (L);
luaopen_http (L);
luaopen_redis (L);
luaopen_upstream (L);
lua_add_actions_global (L);
luaopen_session (L);
luaopen_io_dispatcher (L);
luaopen_dns_resolver (L);
luaopen_rsa (L);
luaopen_ip (L);
rspamd_lua_add_preload (L, "ucl", luaopen_ucl);


return L; return L;
} }
luaL_typename (L, narg)); luaL_typename (L, narg));
return luaL_argerror (L, narg, msg); return luaL_argerror (L, narg, msg);
} }


void
rspamd_lua_add_preload (lua_State *L, const gchar *name, lua_CFunction func)
{
lua_getglobal (L, "package");
lua_pushstring (L, "preload");
lua_gettable (L, -2);
lua_pushcfunction (L, func);
lua_setfield (L, -2, name);
lua_pop (L, 1);
}

+ 31
- 25
src/lua/lua_common.h Näytä tiedosto

/** /**
* Open libraries functions * Open libraries functions
*/ */
gint luaopen_message (lua_State *L);
gint luaopen_task (lua_State *L);
gint luaopen_config (lua_State *L);
gint luaopen_metric (lua_State *L);
gint luaopen_radix (lua_State *L);
gint luaopen_hash_table (lua_State *L);
gint luaopen_trie (lua_State * L);
gint luaopen_textpart (lua_State *L);
gint luaopen_mimepart (lua_State *L);
gint luaopen_image (lua_State *L);
gint luaopen_url (lua_State *L);
gint luaopen_classifier (lua_State *L);
gint luaopen_statfile (lua_State * L);
gint luaopen_glib_regexp (lua_State *L);
gint luaopen_cdb (lua_State *L);
gint luaopen_xmlrpc (lua_State * L);
gint luaopen_http (lua_State * L);
gint luaopen_redis (lua_State * L);
gint luaopen_upstream (lua_State * L);
gint luaopen_mempool (lua_State * L);
gint luaopen_session (lua_State * L);
gint luaopen_io_dispatcher (lua_State * L);
gint luaopen_dns_resolver (lua_State * L);
gint luaopen_rsa (lua_State * L);
gint luaopen_ip (lua_State * L);

/**
* Add preload function
*/
void rspamd_lua_add_preload (lua_State *L, const gchar *name, lua_CFunction func);

void luaopen_message (lua_State *L);
void luaopen_task (lua_State *L);
void luaopen_config (lua_State *L);
void luaopen_metric (lua_State *L);
void luaopen_radix (lua_State *L);
void luaopen_hash_table (lua_State *L);
void luaopen_trie (lua_State * L);
void luaopen_textpart (lua_State *L);
void luaopen_mimepart (lua_State *L);
void luaopen_image (lua_State *L);
void luaopen_url (lua_State *L);
void luaopen_classifier (lua_State *L);
void luaopen_statfile (lua_State * L);
void luaopen_glib_regexp (lua_State *L);
void luaopen_cdb (lua_State *L);
void luaopen_xmlrpc (lua_State * L);
void luaopen_http (lua_State * L);
void luaopen_redis (lua_State * L);
void luaopen_upstream (lua_State * L);
void luaopen_mempool (lua_State * L);
void luaopen_session (lua_State * L);
void luaopen_io_dispatcher (lua_State * L);
void luaopen_dns_resolver (lua_State * L);
void luaopen_rsa (lua_State * L);
void luaopen_ip (lua_State * L);


gint rspamd_lua_call_filter (const gchar *function, struct rspamd_task *task); gint rspamd_lua_call_filter (const gchar *function, struct rspamd_task *task);
gint rspamd_lua_call_chain_filter (const gchar *function, gint rspamd_lua_call_chain_filter (const gchar *function,

+ 12
- 13
src/lua/lua_config.c Näytä tiedosto

} }
/* Init functions */ /* Init functions */


gint
void
luaopen_config (lua_State * L) luaopen_config (lua_State * L)
{ {
rspamd_lua_new_class (L, "rspamd{config}", configlib_m); rspamd_lua_new_class (L, "rspamd{config}", configlib_m);
luaL_register (L, "rspamd_config", null_reg);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }


gint
void
luaopen_radix (lua_State * L) luaopen_radix (lua_State * L)
{ {
rspamd_lua_new_class (L, "rspamd{radix}", radixlib_m); rspamd_lua_new_class (L, "rspamd{radix}", radixlib_m);
luaL_register (L, "rspamd_radix", null_reg);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }


gint
void
luaopen_hash_table (lua_State * L) luaopen_hash_table (lua_State * L)
{ {
rspamd_lua_new_class (L, "rspamd{hash_table}", hashlib_m); rspamd_lua_new_class (L, "rspamd{hash_table}", hashlib_m);
luaL_register (L, "rspamd_hash_table", null_reg); luaL_register (L, "rspamd_hash_table", null_reg);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */
}

static gint
lua_load_trie (lua_State *L)
{
lua_newtable (L);
luaL_register (L, NULL, trielib_f);


return 1; return 1;
} }


gint
void
luaopen_trie (lua_State * L) luaopen_trie (lua_State * L)
{ {
luaL_newmetatable (L, "rspamd{trie}"); luaL_newmetatable (L, "rspamd{trie}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, trielib_m); luaL_register (L, NULL, trielib_m);
luaL_register (L, "rspamd_trie", trielib_f);
rspamd_lua_add_preload (L, "rspamd_trie", lua_load_trie);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }

+ 13
- 5
src/lua/lua_dns.c Näytä tiedosto



/* Public prototypes */ /* Public prototypes */
struct rspamd_dns_resolver * lua_check_dns_resolver (lua_State * L); struct rspamd_dns_resolver * lua_check_dns_resolver (lua_State * L);
gint luaopen_dns_resolver (lua_State * L);
void luaopen_dns_resolver (lua_State * L);


/* Lua bindings */ /* Lua bindings */
LUA_FUNCTION_DEF (dns_resolver, init); LUA_FUNCTION_DEF (dns_resolver, init);
return 1; return 1;
} }


gint
static gint
lua_load_dns (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, dns_resolverlib_f);

return 1;
}

void
luaopen_dns_resolver (lua_State * L) luaopen_dns_resolver (lua_State * L)
{ {


LUA_ENUM (L, RDNS_REQUEST_AAA, RDNS_REQUEST_SRV); LUA_ENUM (L, RDNS_REQUEST_AAA, RDNS_REQUEST_SRV);
} }


luaL_register (L, NULL, dns_resolverlib_m);
luaL_register (L, "rspamd_resolver", dns_resolverlib_f);
luaL_register (L, NULL, dns_resolverlib_m);
rspamd_lua_add_preload (L, "rspamd_resolver", lua_load_dns);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */
return 1;
} }

+ 10
- 4
src/lua/lua_http.c Näytä tiedosto

return 1; return 1;
} }


gint
luaopen_http (lua_State * L)
static gint
lua_load_http (lua_State * L)
{ {
luaL_register (L, "rspamd_http", httplib_m);
lua_newtable (L);
luaL_register (L, NULL, httplib_m);


return 1; return 1;
} }

void
luaopen_http (lua_State * L)
{
rspamd_lua_add_preload (L, "rspamd_http", lua_load_http);
}

+ 11
- 4
src/lua/lua_ip.c Näytä tiedosto

} }
} }


gint
static gint
lua_load_ip (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, iplib_f);

return 1;
}

void
luaopen_ip (lua_State * L) luaopen_ip (lua_State * L)
{ {
luaL_newmetatable (L, "rspamd{ip}"); luaL_newmetatable (L, "rspamd{ip}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, iplib_m); luaL_register (L, NULL, iplib_m);
luaL_register (L, "rspamd_ip", iplib_f);
rspamd_lua_add_preload (L, "rspamd_ip", lua_load_ip);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }

+ 12
- 5
src/lua/lua_mempool.c Näytä tiedosto



/* Public prototypes */ /* Public prototypes */
struct memory_pool_s * rspamd_lua_check_mempool (lua_State * L); struct memory_pool_s * rspamd_lua_check_mempool (lua_State * L);
gint luaopen_mempool (lua_State * L);
void luaopen_mempool (lua_State * L);


/* Lua bindings */ /* Lua bindings */
LUA_FUNCTION_DEF (mempool, create); LUA_FUNCTION_DEF (mempool, create);
return 1; return 1;
} }


gint
static gint
lua_load_mempool (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, mempoollib_f);

return 1;
}

void
luaopen_mempool (lua_State * L) luaopen_mempool (lua_State * L)
{ {
luaL_newmetatable (L, "rspamd{mempool}"); luaL_newmetatable (L, "rspamd{mempool}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, mempoollib_m); luaL_register (L, NULL, mempoollib_m);
luaL_register (L, "rspamd_mempool", mempoollib_f);
rspamd_lua_add_preload (L, "rspamd_mempool", lua_load_mempool);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }

+ 1
- 5
src/lua/lua_message.c Näytä tiedosto

return 1; return 1;
} }


gint
void
luaopen_message (lua_State * L) luaopen_message (lua_State * L)
{ {
rspamd_lua_new_class (L, "rspamd{message}", msglib_m); rspamd_lua_new_class (L, "rspamd{message}", msglib_m);
luaL_register (L, "rspamd_message", null_reg);

lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }

+ 10
- 5
src/lua/lua_redis.c Näytä tiedosto

return 1; return 1;
} }


static gint
lua_load_redis (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, redislib_m);

return 1;
}
/** /**
* Open redis library * Open redis library
* @param L lua stack * @param L lua stack
* @return * @return
*/ */
gint
void
luaopen_redis (lua_State * L) luaopen_redis (lua_State * L)
{ {

luaL_register (L, "rspamd_redis", redislib_m);

return 1;
rspamd_lua_add_preload (L, "rspamd_redis", lua_load_redis);
} }

+ 12
- 5
src/lua/lua_regexp.c Näytä tiedosto

return 0; return 0;
} }


gint
static gint
lua_load_regexp (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, regexplib_f);

return 1;
}

void
luaopen_glib_regexp (lua_State * L) luaopen_glib_regexp (lua_State * L)
{ {
luaL_newmetatable (L, "rspamd{regexp}"); luaL_newmetatable (L, "rspamd{regexp}");
lua_pushstring (L, "rspamd{regexp}"); lua_pushstring (L, "rspamd{regexp}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, regexplib_m);
luaL_register (L, "regexp", regexplib_f);
luaL_register (L, NULL, regexplib_m);
rspamd_lua_add_preload (L, "regexp", lua_load_regexp);


regexp_static_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ()); regexp_static_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());

return 1;
} }

+ 46
- 13
src/lua/lua_rsa.c Näytä tiedosto

return 1; return 1;
} }


gint
static gint
lua_load_pubkey (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, rsapubkeylib_f);

return 1;
}

static gint
lua_load_privkey (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, rsaprivkeylib_f);

return 1;
}

static gint
lua_load_signature (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, rsasignlib_f);

return 1;
}

static gint
lua_load_rsa (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, rsalib_f);

return 1;
}

void
luaopen_rsa (lua_State * L) luaopen_rsa (lua_State * L)
{ {
luaL_newmetatable (L, "rspamd{rsa_pubkey}"); luaL_newmetatable (L, "rspamd{rsa_pubkey}");
lua_pushstring (L, "rspamd{rsa_pubkey}"); lua_pushstring (L, "rspamd{rsa_pubkey}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, rsapubkeylib_m);
luaL_register (L, "rsa_pubkey", rsapubkeylib_f);
luaL_register (L, NULL, rsapubkeylib_m);
rspamd_lua_add_preload (L, "rspamd_rsa_pubkey", lua_load_pubkey);


luaL_newmetatable (L, "rspamd{rsa_privkey}"); luaL_newmetatable (L, "rspamd{rsa_privkey}");
lua_pushstring (L, "__index"); lua_pushstring (L, "__index");
lua_pushstring (L, "rspamd{rsa_privkey}"); lua_pushstring (L, "rspamd{rsa_privkey}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, rsaprivkeylib_m);
luaL_register (L, "rsa_privkey", rsaprivkeylib_f);
luaL_register (L, NULL, rsaprivkeylib_m);
rspamd_lua_add_preload (L, "rspamd_rsa_privkey", lua_load_privkey);


luaL_newmetatable (L, "rspamd{rsa_signature}"); luaL_newmetatable (L, "rspamd{rsa_signature}");
lua_pushstring (L, "__index"); lua_pushstring (L, "__index");
lua_pushstring (L, "rspamd{rsa_signature}"); lua_pushstring (L, "rspamd{rsa_signature}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, rsasignlib_m);
luaL_register (L, "rsa_signature", rsasignlib_f);
luaL_register (L, NULL, rsasignlib_m);
rspamd_lua_add_preload (L, "rspamd_rsa_signature", lua_load_signature);


luaL_register (L, "rsa", rsalib_f);
rspamd_lua_add_preload (L, "rspamd_rsa", lua_load_rsa);


return 1;
lua_settop (L, 0);
} }


#else #else
gint
void
luaopen_rsa (lua_State * L) luaopen_rsa (lua_State * L)
{ {
msg_info ("this rspamd version is not linked against openssl, therefore no " msg_info ("this rspamd version is not linked against openssl, therefore no "
"RSA support is available"); "RSA support is available");

return 1;

} }
#endif #endif

+ 12
- 6
src/lua/lua_session.c Näytä tiedosto



/* Public prototypes */ /* Public prototypes */
struct rspamd_async_session * lua_check_session (lua_State * L); struct rspamd_async_session * lua_check_session (lua_State * L);
gint luaopen_session (lua_State * L);
void luaopen_session (lua_State * L);


/* Lua bindings */ /* Lua bindings */
LUA_FUNCTION_DEF (session, register_async_event); LUA_FUNCTION_DEF (session, register_async_event);
return 1; return 1;
} }


gint
static gint
lua_load_session (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, sessionlib_f);

return 1;
}

void
luaopen_session (lua_State * L) luaopen_session (lua_State * L)
{ {
luaL_newmetatable (L, "rspamd{session}"); luaL_newmetatable (L, "rspamd{session}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, sessionlib_m); luaL_register (L, NULL, sessionlib_m);
luaL_register (L, "rspamd_session", sessionlib_f);
rspamd_lua_add_preload (L, "rspamd_session", lua_load_session);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */


/* Simple event class */ /* Simple event class */
rspamd_lua_new_class (L, "rspamd{event}", eventlib_m); rspamd_lua_new_class (L, "rspamd{event}", eventlib_m);
luaL_register (L, "rspamd_event", null_reg);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }

+ 17
- 22
src/lua/lua_task.c Näytä tiedosto

} }


/* Init part */ /* Init part */
gint
luaopen_task (lua_State * L)

static gint
lua_load_task (lua_State * L)
{ {
rspamd_lua_new_class_full (L, "rspamd{task}", "rspamd_task", tasklib_m, tasklib_f);
lua_newtable (L);
luaL_register (L, NULL, tasklib_f);


return 1;
}

void
luaopen_task (lua_State * L)
{
rspamd_lua_new_class (L, "rspamd{task}", tasklib_m);
lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */


return 1;
rspamd_lua_add_preload (L, "rspamd_task", lua_load_task);
} }


gint
void
luaopen_textpart (lua_State * L) luaopen_textpart (lua_State * L)
{ {
rspamd_lua_new_class (L, "rspamd{textpart}", textpartlib_m); rspamd_lua_new_class (L, "rspamd{textpart}", textpartlib_m);
luaL_register (L, "rspamd_textpart", null_reg); luaL_register (L, "rspamd_textpart", null_reg);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }


gint
void
luaopen_mimepart (lua_State * L) luaopen_mimepart (lua_State * L)
{ {
rspamd_lua_new_class (L, "rspamd{mimepart}", mimepartlib_m); rspamd_lua_new_class (L, "rspamd{mimepart}", mimepartlib_m);
luaL_register (L, "rspamd_mimepart", null_reg);

lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }


gint
void
luaopen_image (lua_State * L) luaopen_image (lua_State * L)
{ {
rspamd_lua_new_class (L, "rspamd{image}", imagelib_m); rspamd_lua_new_class (L, "rspamd{image}", imagelib_m);
luaL_register (L, "rspamd_image", null_reg);

lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }


gint
void
luaopen_url (lua_State * L) luaopen_url (lua_State * L)
{ {
rspamd_lua_new_class (L, "rspamd{url}", urllib_m); rspamd_lua_new_class (L, "rspamd{url}", urllib_m);
luaL_register (L, "rspamd_url", null_reg);

lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }



+ 20
- 5
src/lua/lua_upstream.c Näytä tiedosto

return 1; return 1;
} }


static gint
lua_load_upstream (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, upstream_f);


gint
return 1;
}

static gint
lua_load_upstream_list (lua_State * L)
{
lua_newtable (L);
luaL_register (L, NULL, upstream_list_f);

return 1;
}

void
luaopen_upstream (lua_State * L) luaopen_upstream (lua_State * L)
{ {
luaL_newmetatable (L, "rspamd{upstream_list}"); luaL_newmetatable (L, "rspamd{upstream_list}");
lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, upstream_list_m); luaL_register (L, NULL, upstream_list_m);
luaL_register (L, "upstream_list", upstream_list_f);
rspamd_lua_add_preload (L, "upstream_list", lua_load_upstream_list);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */


lua_rawset (L, -3); lua_rawset (L, -3);


luaL_register (L, NULL, upstream_m); luaL_register (L, NULL, upstream_m);
luaL_register (L, "upstream", upstream_f);
rspamd_lua_add_preload (L, "upstream", lua_load_upstream);


lua_pop (L, 1); /* remove metatable from stack */ lua_pop (L, 1); /* remove metatable from stack */

return 1;
} }

+ 10
- 4
src/lua/lua_xmlrpc.c Näytä tiedosto

return 1; return 1;
} }


gint
luaopen_xmlrpc (lua_State * L)
static gint
lua_load_xmlrpc (lua_State * L)
{ {
luaL_register (L, "rspamd_xmlrpc", xmlrpclib_m);
lua_newtable (L);
luaL_register (L, NULL, xmlrpclib_m);


return 1; return 1;
} }


void
luaopen_xmlrpc (lua_State * L)
{
rspamd_lua_add_preload (L, "rspamd_xmlrpc", lua_load_xmlrpc);
}


Loading…
Peruuta
Tallenna