aboutsummaryrefslogtreecommitdiffstats
path: root/perl/Rspamd/InternetAddress.xs
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-02-26 18:09:28 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-02-26 18:09:28 +0300
commitcfb5348f75790ef694edd5a9c131890eeceec204 (patch)
tree55c6bc5ff03a346ced6008dcae0a70ba6b36fb32 /perl/Rspamd/InternetAddress.xs
parent5d77f4552b6e39ab1072d2c91b219dac2498ac88 (diff)
downloadrspamd-cfb5348f75790ef694edd5a9c131890eeceec204.tar.gz
rspamd-cfb5348f75790ef694edd5a9c131890eeceec204.zip
* Completely rewrite and reorganize perl API
* Add documentation for Mail::Rspamd * Add install targets to cmake --HG-- rename : perl/rspamd.pm => perl/Rspamd.pm rename : perl/rspamd.xs => perl/Rspamd.xs
Diffstat (limited to 'perl/Rspamd/InternetAddress.xs')
-rw-r--r--perl/Rspamd/InternetAddress.xs124
1 files changed, 124 insertions, 0 deletions
diff --git a/perl/Rspamd/InternetAddress.xs b/perl/Rspamd/InternetAddress.xs
new file mode 100644
index 000000000..834117bbe
--- /dev/null
+++ b/perl/Rspamd/InternetAddress.xs
@@ -0,0 +1,124 @@
+MODULE = Mail::Rspamd PACKAGE = Mail::Rspamd::InternetAddress PREFIX = rspamd_internet_address_
+
+Mail::Rspamd::InternetAddress
+rspamd_internet_address_new (Class, name, address)
+ CASE: items <= 1
+ char * Class
+ CODE:
+ RETVAL = internet_address_new ();
+ plist = g_list_prepend (plist, RETVAL);
+ OUTPUT:
+ RETVAL
+ CASE: items == 2
+ char * Class
+ char * name
+ CODE:
+ RETVAL = internet_address_new_group (name);
+ plist = g_list_prepend (plist, RETVAL);
+ OUTPUT:
+ RETVAL
+ CASE: items == 3
+ char * Class
+ char * name
+ char * address
+ CODE:
+ RETVAL = internet_address_new_name (name, address);
+ plist = g_list_prepend (plist, RETVAL);
+ OUTPUT:
+ RETVAL
+
+void
+DESTROY(ia)
+ Mail::Rspamd::InternetAddress ia
+ CODE:
+ if (g_list_find (plist,ia)) {
+ internet_address_unref (ia);
+ plist = g_list_remove (plist, ia);
+ }
+
+AV *
+rspamd_internet_address_parse_string (str)
+ const char * str
+ PREINIT:
+ InternetAddressList * addrlist;
+ AV * retav;
+ CODE:
+ addrlist = internet_address_parse_string (str);
+ retav = newAV ();
+ while (addrlist) {
+ SV * address = newSViv (0);
+ sv_setref_pv (address, "Mail::Rspamd::InternetAddress", (Mail__Rspamd__InternetAddress)(addrlist->address));
+ av_push (retav, address);
+ addrlist = addrlist->next;
+ }
+ RETVAL = retav;
+ OUTPUT:
+ RETVAL
+
+void
+interface_ia_set (ia, value)
+ Mail::Rspamd::InternetAddress ia
+ char * value
+ INTERFACE_MACRO:
+ XSINTERFACE_FUNC
+ XSINTERFACE_FUNC_RSPAMD_IA_SET
+ INTERFACE:
+ set_name
+ set_addr
+
+SV *
+rspamd_internet_address_to_string (ia, encode = TRUE)
+ Mail::Rspamd::InternetAddress ia
+ gboolean encode
+ PREINIT:
+ char * textdata;
+ CODE:
+ textdata = internet_address_to_string (ia, encode);
+ if (textdata == NULL) {
+ XSRETURN_UNDEF;
+ }
+ RETVAL = newSVpv (textdata, 0);
+ OUTPUT:
+ RETVAL
+
+void
+rspamd_internet_address_set_group (ia, ...)
+ Mail::Rspamd::InternetAddress ia
+ PREINIT:
+ Mail__Rspamd__InternetAddress addr;
+ InternetAddressList * addrlist = NULL;
+ int i;
+ CODE:
+ if (items < 2) {
+ XSRETURN_UNDEF;
+ }
+ for (i = items - 1; i > 0; --i) {
+ /* retrieve each address from the perl array */
+ if (sv_derived_from (ST (items - i), "Mail::Rspamd::InternetAddress")) {
+ IV tmp = SvIV ((SV*)SvRV (ST (items - i)));
+ addr = INT2PTR (Mail__Rspamd__InternetAddress, tmp);
+ }
+ if (addr) {
+ internet_address_list_append (addrlist, addr);
+ }
+ }
+ if (addrlist) {
+ internet_address_set_group (ia, addrlist);
+ }
+
+void
+rspamd_internet_address_add_member (ia, member)
+ Mail::Rspamd::InternetAddress ia
+ Mail::Rspamd::InternetAddress member
+ CODE:
+ internet_address_add_memeber (ia, member);
+
+Mail::Rspamd::InternetAddressType
+rspamd_internet_address_type (ia)
+ Mail::Rspamd::InternetAddress ia
+ CODE:
+ RETVAL = ia->type;
+ OUTPUT:
+ RETVAL
+
+