[Exim] [PATCH] Exim & perl variables import/export

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Dmitry Sergienko
Datum:  
To: exim-users
Betreff: [Exim] [PATCH] Exim & perl variables import/export
This is a multi-part message in MIME format.
--
Hi!

I need to import variables from exim into perl and export them from perl back
to exim.

This patch exports variables $acl_[cm][0-9] into perl before invoking perl
function and fetches them after perl function is finished.

--
Best wishes,
Dmitry Sergienko (SDA104-RIPE)
Trifle Co., Ltd.
--
--- perl-orig.c    Mon Aug 18 15:52:56 2003
+++ perl-my.c    Thu Nov 27 16:10:44 2003
@@ -112,9 +112,14 @@
 {
   dSP;
   SV *sv;
+  SV *perl_acl_var[ACL_C_MAX+ACL_M_MAX];
+  char aclname[7];
   STRLEN len;
   uschar *str;
   int items;
+  int acl_idx;
+  char *ptr;
+  int i;


   if (!interp_perl)
     {
@@ -122,6 +127,18 @@
     return 0;
     }


+  for (i=0; i<ACL_C_MAX+ACL_M_MAX; i++) {
+      if (i<ACL_C_MAX)
+          sprintf(aclname, "acl_c%1d", i);
+      else
+          sprintf(aclname, "acl_m%1d", i-ACL_C_MAX);
+
+      perl_acl_var[i] = perl_get_sv(aclname, TRUE);
+      if (acl_var[i])
+          sv_setpv(perl_acl_var[i], acl_var[i]);
+      else
+          sv_setpv(perl_acl_var[i], (const char *)&PL_sv_undef);
+  }
   ENTER;
   SAVETMPS;
   PUSHMARK(SP);
@@ -145,6 +162,16 @@
   yield = string_cat(yield, sizep, ptrp, str, (int)len);
   FREETMPS;
   LEAVE;
+
+  for (i=0; i<ACL_C_MAX+ACL_M_MAX; i++) {
+      if (i<ACL_C_MAX)
+          sprintf(aclname, "acl_c%1d", i);
+      else
+          sprintf(aclname, "acl_m%1d", i-ACL_C_MAX);
+      ptr = SvPV(perl_get_sv(aclname, FALSE), len);
+      if (ptr && len)
+          acl_var[i] = string_copy(ptr);
+  }


return yield;
}
--