summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-02-12 14:40:51 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-02-12 14:40:51 +0300
commit6c8fc71eafb0f0bb069dba703c805a5247c917c7 (patch)
treeefca07d7ff100a183b56eb1bb5d31602444408b3 /src/main.c
parent54480f21f115b40e76806210a61bdde00d3842f7 (diff)
downloadrspamd-6c8fc71eafb0f0bb069dba703c805a5247c917c7.tar.gz
rspamd-6c8fc71eafb0f0bb069dba703c805a5247c917c7.zip
* Add log function to perl API
* Prepare for more detailed work on rspamd perl API
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index f315367d7..e33d6e8dd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -25,6 +25,8 @@
/* 2 seconds to fork new process in place of dead one */
#define SOFT_FORK_TIME 2
+/* Perl module init function */
+#define MODULE_INIT_FUNC "module_init"
struct config_file *cfg;
@@ -85,10 +87,28 @@ static void
init_filters (struct config_file *cfg)
{
struct perl_module *module;
+ char *init_func, *class;
+ size_t funclen;
+ dSP;
LIST_FOREACH (module, &cfg->perl_modules, next) {
if (module->path) {
require_pv (module->path);
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK (SP);
+ XPUSHs (sv_2mortal (newSVpv (class, 0)));
+ XPUSHs (sv_2mortal (newSViv (PTR2IV (cfg))));
+ PUTBACK;
+ /* Call module init function */
+ funclen = strlen (module->path) + sizeof ("::") + sizeof (MODULE_INIT_FUNC) - 1;
+ init_func = g_malloc (funclen);
+ snptintf (init_func, funclen, "%s::%s", module->path, MODULE_INIT_FUNC);
+ call_method (init_func, G_DISCARD);
+
+ FREETMPS;
+ LEAVE;
}
}
}