require Exporter;
our @ISA = qw(Exporter);
+our @EXPORT = qw(
+ module_init
+ module_reload
+ LOG_ERROR
+ LOG_WARNING
+ LOG_MESSAGE
+ LOG_INFO
+ LOG_DEBUG
+);
our $VERSION = '0.0.1';
require XSLoader;
XSLoader::load('rspamd', $VERSION);
+
+sub module_init {
+ my ($cfg) = @_;
+}
+
+sub module_reload {
+ my ($cfg) = @_;
+}
+
+use constant LOG_ERROR => 1 << 3;
+use constant LOG_WARNING => 1 << 4;
+use constant LOG_MESSAGE => 1 << 5;
+use constant LOG_INFO => 1 << 6;
+use constant LOG_DEBUG => 1 << 7;
+
1;
__END__
RETVAL
void
-rspamd_task_get_module_param (r, modulename, paramname)
+rspamd_config_get_module_param (r, modulename, paramname)
CODE:
struct config_file *r;
char *module, *param, *value;
sv_setpv(TARG, value);
ST(0) = TARG;
+
+MODULE = rspamd PACKAGE = rspamd_log PREFIX = rspamd_log_
+PROTOTYPES: DISABLE
+
+void
+rspamd_log_log (level, str)
+ CODE:
+ int level;
+ char *str;
+
+ level = (int)SvIV (ST(0));
+ str = (char *)SvPV_nolen (ST(1));
+
+ g_log (G_LOG_DOMAIN, level, "%s", str);
+ XSRETURN_EMPTY;
+
/* 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;
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;
}
}
}
#define DEFAULT_METRIC "default"
/* Logging in postfix style */
-#define msg_err g_error
+#define msg_err g_critical
#define msg_warn g_warning
#define msg_info g_message
#define msg_debug g_debug