]> source.dussan.org Git - rspamd.git/commitdiff
* Add routines to perl api to access new results adding function and getting param...
authorcebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru>
Wed, 24 Sep 2008 14:49:08 +0000 (18:49 +0400)
committercebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru>
Wed, 24 Sep 2008 14:49:08 +0000 (18:49 +0400)
  this allows accessing to modules config from perl modules

perl/rspamd.xs

index 6bbaaddf1feaad02218686c08c8b0d45d4996547..60c670f6c47595974ed2bcaa0e8c09b85111a872 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "../config.h"
 #include "../main.h"
+#include "../cfg_file.h"
 #include "../perl.h"
 #include "../mem_pool.h"
 
@@ -116,6 +117,43 @@ recall_filter (r)
        perl_set_session (r);
     process_filters (r);
 
+void
+insert_result (r, metric, symbol, flag)
+       CODE:
+       struct worker_task *r;
+       char *metric, *symbol;
+       int flag;
+       STRLEN metriclen, symbollen;
+
+       perl_set_session (r);
+       metric = (char *) SvPV (ST(1), metriclen);
+       symbol = (char *) SvPV (ST(2), symbollen);
+       flag = (int) SvIV (ST(3));
+
+       insert_result (r, metric, symbol, flag);
+
+void
+get_module_param (r, modulename, paramname)
+       CODE:
+       struct worker_task *r;
+       char *module, *param, *value;
+       STRLEN modulelen, paramlen;
+
+       dXSTARG;
+       perl_set_session (r);
+       module = (char *) SvPV (ST(1), modulelen);
+       param = (char *) SvPV (ST(2), paramlen);
+
+       value = get_module_opt (r->worker->srv->cfg, module, param);
+       if (value == NULL) {
+               XSRETURN_UNDEF;
+       }
+
+       sv_upgrade(TARG, SVt_PV);
+       sv_setpv(TARG, value);
+
+       ST(0) = TARG;
+
 void
 read_memcached_key (r, key, datalen, callback)
     CODE: