1# $Id$ 2# Template for perl hook 3# 4# API functions: 5# 6# w_log([level, ]str); 7# outputs a string to hpt log 8# no printf() format, use sprintf()! 9# 10# crc32(str) 11# returns CRC-32 of string 12# 13# alike(s1, s2) 14# return Levenstein distance between parameters (smaller -> more alike) 15# 16# putMsgInArea(area, fromname, toname, fromaddr, toaddr, 17# subject, date, attr, text, addkludges); 18# post to first netmail area if area eq ""; 19# set current date if date eq ""; 20# set fromaddr to ouraka if fromaddr eq ""; 21# attr -- binary or text string (i.e. "pvt loc k/s") (text form DEPRECATED!); 22# date -- unixtime, as in time() 23# addkludges can be: 24# 0 not to add any kludges 25# 1 to add required kludges (will add duplicates if they exist) 26# 2 to add missing kludges (will never modify existing ones) 27# 3 to update or add required kludges corresponding to addresses and flags 28# required kludges are: (netmail) INTL, TOPT, FMPT; (all) FLAGS, MSGID 29# 30# myaddr() 31# returns array of our addresses 32# DEPRECATED! use @{$config{addr}} instead 33# 34# nodelistDir() 35# returns nodelistDir from config 36# DEPRECATED! use $config{nodelistDir} instead 37# 38# str2attr(att) 39# converts attribute string to binary message attributes 40# 41# attr2str(attr) 42# converts binary flags to string representation (Pvt Loc K/s) 43# 44# flv2str(flavour) 45# converts binary flag, corresponding to flavour, to string (direct, crash) 46# 47# date2fts(time) 48# converts unixtime to fts-1 format string ("dd mmm yy hh:mm:ss") 49# 50# fts2date(fts1) 51# converts date in fts-1 format string to unixtime 52# 53# mktime(sec, min, hour, wday, mon, year[, wday, yday[, dst]]) 54# makes unixtime like POSIX mktime, but year: 55# year 0..69 -> 2000..2069, 70..1900 -> 1970..3800, other -> as-is 56# month'es: 0 - January, 1 - February, ..., 11 - December (as in POSIX) 57# dst - daylight saving time flag (1 or 0) 58# WARNING: dst can result in +/-1 hour mismatch; use mktime(localtime) for 59# correct unixtime 60# 61# strftime(format, unixtime) 62# strftime(format, sec, min, hour, wday, mon, year[, wday, yday[, dst]]) 63# converts unixtime or a time structure to string according to format 64# man strftime() for details 65# 66# gmtoff([unixtime]) 67# returns difference between local time and UTC in hours (e.g., can be +4.5) 68# if unixtime is omitted, current time used 69# 70# WARNING: Don't redefine already predefined variable via my() or local(). 71# otherwise their values will not be put back into hpt. 72# 73 74sub filter 75{ 76# predefined variables: 77# $fromname, $fromaddr, $toname, 78# $toaddr (for netmail), 79# $area (for echomail), 80# $subject, $text, $pktfrom, $date, $attr 81# $secure (defined if message from secure link) 82# return "" or reason for moving to badArea 83# set $kill for kill the message (not move to badarea) 84# set $change to update $text, $subject, $fromaddr, $toaddr, 85# $fromname, $toname, $attr, $date 86 return ""; 87} 88 89sub put_msg 90{ 91# predefined variables: 92# $fromname, $fromaddr, $toname, $toaddr, 93# $area (areatag in config), 94# $subject, $text, $date, $attr 95# return: 96# 0 not to put message in base 97# 1 to put message as usual 98# 2 to put message without recoding 99# set $change to update $text, $subject, $fromaddr, $toaddr, 100# $fromname, $toname, $attr, $date 101 return 1; 102} 103 104sub scan 105{ 106# predefined variables: 107# $area, $fromname, $fromaddr, $toname, 108# $toaddr (for netmail), 109# $subject, $text, $date, $attr 110# return "" or reason for dont packing to downlinks 111# set $change to update $text, $subject, $fromaddr, $toaddr, 112# $fromname, $toname, $attr, $date 113# set $kill to 1 to delete message after processing (even if it's not sent) 114# set $addvia to 0 not to add via string when packing 115 return ""; 116} 117 118sub export 119{ 120# predefined variables: 121# $area, $fromname, $toname, $subject, $text, $date, $attr, 122# $toaddr (address of link to export this message to), 123# return "" or reason for dont exporting message to this link 124# set $change to update $text, $subject, $fromname, $toname, $attr, $date 125 return ""; 126} 127 128sub route 129{ 130# $addr = dest addr 131# $from = orig addr 132# $fromname = from user name 133# $toname = to user name 134# $date = message date and time 135# $subj = subject line 136# $text = message text 137# $attr = message attributes 138# $route = default route address (by config rules) 139# $flavour = default route flavour (by config rules) 140# set $change to update $text, $subject, $fromaddr, $toaddr, 141# $fromname, $toname, $attr 142# set $flavour to flag, corresponding to flavour, 143# or string hold|normal|crash|direct|immediate 144# set $addvia to 0 not to add via string when packing 145# return route addr or "" for default routing 146 147 return ""; 148} 149 150sub tossbad 151{ 152# $fromname, $fromaddr, $toname, 153# $toaddr (for netmail), 154# $area (for echomail), 155# $subject, $text, $pktfrom, $date, $attr 156# $reason 157# return non-empty string for kill the message 158# set $change to update $text, $subject, $fromaddr, $toaddr, 159# $fromname, $toname, $attr 160 return ""; 161} 162 163sub hpt_start 164{ 165} 166 167sub hpt_exit 168{ 169} 170 171sub process_pkt 172{ 173# $pktname - name of pkt 174# $secure - defined for secure pkt 175# return non-empty string for rejecting pkt (don't process, rename to *.flt) 176 return ""; 177} 178 179sub pkt_done 180{ 181# $pktname - name of pkt 182# $rc - exit code (0 - OK) 183# $res - reason (text line) 184# 0 - OK ($res undefined) 185# 1 - Security violation 186# 2 - Can't open pkt 187# 3 - Bad pkt format 188# 4 - Not to us 189# 5 - Msg tossing problem 190} 191 192sub after_unpack 193{ 194} 195 196sub before_pack 197{ 198} 199 200sub on_echolist 201{ 202# $_[0] - type (0: %list, 1: %query, 2: %unlinked) 203# $_[1] - reference to array of echotags 204# $_[2] - link aka 205# $_[3] - max tag length in @{$_[1]} 206# return: 207# 0 to generate hpt-standard list 208# 1 to return $report value as result 209# 2 to use $report value as list and append hpt standard footer 210 return 0; 211} 212 213sub on_afixcmd 214{ 215# $_[0] - command code (see #define's in areafix.h) 216# $_[1] - link aka 217# $_[2] - request line 218# return: 219# 0 to process command by hpt logic 220# 1 to skip hpt logic and return $report value as result 221 return 0; 222} 223 224sub on_afixreq 225{ 226# predefined variables: 227# $fromname, $fromaddr, $toname, $toaddr. $subject, $text, $pktfrom 228# return: 229# 0 to ignore any changes 230# 1 to update request parameters from above-mentioned variables 231# (note: only $fromaddr and $text are meaningful for processing) 232 return 0; 233} 234 235sub on_robotmsg 236{ 237# process messages generated by robots 238# predefined variables: 239# $type, $fromname, $fromaddr, $toname, $toaddr. $subject, $text 240# 241# $type is one of the following: "afix", "ffix", "tosysop", or undef 242# for messages from areafix, filefix, messages generated to sysop 243# and of unknown origin, respectively. 244# 245# return: 246# 0 to ignore any changes 247# 1 to update message fields 248 249 return 0; 250} 251