[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5 Perl support in HPT

HPT may be compiled with support for calling Perl subs in some parts of its work. In this case it also provides API for such subs (Perl hooks). Perl subs are located in file filter.pl, which usually located in same directory as HPT's executable file but it's name and location may changed via HptPerlFile configuration option. The following Perl hooks are supported:
1.
after_unpack - called after unpacking an echomail bundle to TempInbound
2.
before_pack - called before packing echomail bundle to one of links
3.
process_pkt - called before processing pkt, the following variables available:
$pktname - name of pkt,
$secure - defined if this pkt from secure link
hook must return "" for normal pkt processing or other string to rename pkt to .flt
4.
pkt_done - called after pkt processing, the following variables available:
$pktname - name of pkt,
$rc - exit code(0-ok),
$res - reason(exit code in text form):
0 - OK ($res undefined),
1 - Security violation,
2 - Can't open pkt,
3 - Bad pkt format,
4 - Not to us,
5 - Msg tossing problem
5.
hpt_exit - called before hpt completely exit if any other Perl hook was called during this session.
6.
route - called just before routing netmail message, the following variables availble:
$addr - message destination address,
$from - message originating address,
$toname - destination user name,
$fromname - originating user name,
$subject - message subject line,
$date - message date and time,
$text - message text,
$attr - message attributes,
$route - default route for this message (derermined
via Route statements in config file (may be empty, this means that either no route at all for this message or it will be routed via one-to-multi routing(Route normal noroute 2:5004/73.*)).

Before return you can set $flavour - to hold|normal|crash|direct|immediate for required flavour of message. return "" for default routing or address via which this message should be sent. example:

 
  sub route {
    if ($from eq "2:5004/75.73") return "2:5004/75.0";
    else return "";
  }

if source address of message is 2:5004/75.73 then route it via 2:5004/75, otherwise route it using default routing

7.
scan - called while scanning messages (hpt scan or hpt pack). The following variables available:
$fromname - originating user name,
$fromaddr - message originating address,
$toname - destination user name,
$toaddr - message destination address (for netmail),
$area - message area (for echomail),
$subject - message subject line,
$date - message date and time,
$text - message text,
$attr - message attributes.
Set $change to update $text, $subject, $fromaddr, $toaddr, $fromname, $toname, $attr. If returns non-empty string (reason), the message will not pack to downlinks.
8.
filter - called for processing every message while tossing. The following variables available:
$fromname - originating user name,
$fromaddr - message originating address,
$toname - destination user name,
$toaddr - message destination address (for netmail),
$area - message area (for echomail),
$subject - message subject line,
$date - message date and time,
$text - message text,
$attr - message attributes,
$pktfrom - address of originating pkt,
$secure - defined if the message received from secure link.
Set $change to update $text, $subject, $fromaddr, $toaddr, $fromname, $toname, $attr. Set $kill for kill message. If returns non-empty string (reason), the message will be moved to badarea.
9.
tossbad - called when message will be put in badArea. The following variables available:
$fromname - originating user name,
$fromaddr - message originating address,
$toname - destination user name,
$toaddr - message destination address (for netmail),
$area - message area (for echomail),
$subject - message subject line,
$date - message date and time,
$text - message text,
$attr - message attributes,
$pktfrom - address of originating pkt,
$reason - reason, why badarea (text string).
Set $change to update $text, $subject, $fromaddr, $toaddr, $fromname, $toname, $attr. If returns non-empty string (reason) for kill the message.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Pavel Andreew on August, 28 2002 using texi2html