]> git.deb.at Git - pkg/t-prot.git/blob - contrib/filter_innd.pl
Imported Upstream version 1.49
[pkg/t-prot.git] / contrib / filter_innd.pl
1 # $Id: filter_innd.pl,v 1.4 2004/10/10 20:26:24 jochen Exp $
2 # Copyright (c) 2004 Jochen Striepe <t-prot@tolot.escape.de>
3 #
4 # This file is provided as an example how t-prot can be used for
5 # Perl filtering with INN2. It is NOT meant for production use.
6 # Read the README.perl_hook coming with your version of INN2, and
7 # adapt the script to your needs.
8 #
9 # Please see t-prot's man page for command line parameter details.
10 #
11 # Requirements/Bugs: mktemp(1) should be quite widely spread by
12 # now -- if it is not installed on your system, get the sources
13 # from Debian Linux or OpenBSD. Of course, rm(1) is POSIX and will
14 # be present on any reasonably Unix-like system.
15 # The script should not be run on any heavy-duty machines -- the
16 # writes to /tmp will be costly when many articles are committed
17 # at the same time. Sadly, there seems to be no really clean,
18 # portable, and standard way to realize a two-way pipe with perl.
19 # Please point me to some documentation if I am wrong. Thank you. :)
20 #
21 # License: This file is part of the t-prot package and therefore
22 # available under the same conditions. See t-prot's man page for
23 # details.
24 # The whole idea is robbed from Martin Dietze -- see his version at
25 #   http://www.fh-wedel.de/pub/fh-wedel/staff/herbert/linux/
26 # Please note that there is no code copied from there, so the files
27 # in the t-prot package are *not* available under the terms of the
28 # GPL.
29
30 sub filter_art {
31         my $rval = "" ; # Assume we'll accept. Cannot be `0'
32
33         if ($hdr{'Newsgroups'} =~ /^local\./) {
34                 my $foo = $hdr{'__BODY__'};
35                 $foo =~ s/\r\n/\n/gs;
36
37                 open(TMP, '/usr/bin/mktemp -q /tmp/INN2.tmp.XXXXXX | tr -d \'\n\'|')
38                         || return '';
39                 my $f = <TMP>;
40                 close TMP;
41
42                 open(OUT, ">$f")
43                         || return '';
44                 print OUT $foo;
45                 close OUT;
46
47                 open(IN, "/usr/bin/t-prot -m -t -p --check -i $f|")
48                         || goto FINISH;
49                 $rval = <IN>;
50                 close IN;
51
52                 FINISH: system('/bin/rm', $f);
53         }
54
55         $rval ;
56 }
57
58 sub filter_mode {
59 }
60
61 sub filter_messageid {
62     $rval = '';
63     $rval;
64 }
65