comparison dccifd/dccif-test/dccif-test.pl @ 0:c7f6b056b673

First import of vendor version
author Peter Gervai <grin@grin.hu>
date Tue, 10 Mar 2009 13:49:58 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c7f6b056b673
1 #! /usr/local/bin/perl
2
3 # test sample Perl interface to the DCC interface daemon
4
5 # Copyright (c) 2008 by Rhyolite Software, LLC
6 #
7 # This agreement is not applicable to any entity which sells anti-spam
8 # solutions to others or provides an anti-spam solution as part of a
9 # security solution sold to other entities, or to a private network
10 # which employs the DCC or uses data provided by operation of the DCC
11 # but does not provide corresponding data to other users.
12 #
13 # Permission to use, copy, modify, and distribute this software without
14 # changes for any purpose with or without fee is hereby granted, provided
15 # that the above copyright notice and this permission notice appear in all
16 # copies and any distributed versions or copies are either unchanged
17 # or not called anything similar to "DCC" or "Distributed Checksum
18 # Clearinghouse".
19 #
20 # Parties not eligible to receive a license under this agreement can
21 # obtain a commercial license to use DCC by contacting Rhyolite Software
22 # at sales@rhyolite.com.
23 #
24 # A commercial license would be for Distributed Checksum and Reputation
25 # Clearinghouse software. That software includes additional features. This
26 # free license for Distributed ChecksumClearinghouse Software does not in any
27 # way grant permision to use Distributed Checksum and Reputation Clearinghouse
28 # software
29 #
30 # THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL
31 # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
32 # OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC
33 # BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
34 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
35 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
36 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
37 # SOFTWARE.
38 # Rhyolite Software DCC 1.3.103-1.7 $Revision$
39
40 use strict 'subs', 'vars';
41 use Getopt::Std;
42
43
44 my $usage = "usage: [-h homedir] [-o opts] [-c clnt-name] [-l heLo]"
45 . " [-f env_from]\n"
46 . " [-I infile] [-O outfile]"
47 . " [-r rcpt1[:user1][,rcpt2[:user2],...]]\n";
48
49 my(%opts, $clnt_addr, $clnt_name, $rcpt, @rcpts, $body, @result);
50
51
52 do('../dccif.pl') || die("could not get sample interface ../dccif.pl: $!\n");
53
54 $opts{I} = "-";
55 $opts{O} = "-";
56 if (!getopts('h:o:c:l:f:I:O:t:r:', \%opts) || @ARGV) {
57 print STDERR $usage;
58 exit 1;
59 }
60
61
62 if (! $opts{c}) {
63 $clnt_addr = "";
64 $clnt_name = "";
65 } else {
66 $clnt_name = $opts{c};
67 $clnt_addr = gethostbyname($clnt_name);
68 if (!$clnt_addr) {
69 $clnt_addr = "";
70 } else {
71 $clnt_addr = inet_ntoa($clnt_addr);
72 $clnt_name = "" if ($clnt_addr eq $clnt_name);
73 }
74 }
75
76
77 # make array of env_To recipients
78 # With no recipients, dccifd will understand a target count of 0. The
79 # result is like `dccifd -Q`.
80 @rcpts = ();
81 if ($opts{r}) {
82 my(@raw_rcpts, @raw_rcpt);
83 @raw_rcpts = split(/,/, $opts{r});
84 while (@raw_rcpts) {
85 $rcpt = shift(@raw_rcpts);
86 $rcpt =~ s/;/\r/;
87 push @rcpts, $rcpt;
88 }
89 }
90
91 @result = dccif($opts{O},
92 $opts{o} ? $opts{o} : "",
93 $clnt_addr, $clnt_name,
94 $opts{l} ? $opts{l} : "",
95 $opts{f} ? $opts{f} : "",
96 \@rcpts,
97 $opts{I},
98 $opts{h} ? $opts{h} : "");
99
100 print STDERR "result=@result\n";