#! /usr/bin/perl

# But the first way is preferable, because we have a trick (below) that
# allows perl to be _anywhere_ in the user's path.  The intent is to reduce
# the need to edit this file.

eval 'exec perl $0 ${1+"$@"}'
if 0;  # tee hee! This is on a separate line, so /bin/sh never sees it.

# use strict;

#-----------------------------------------------
# DESCRIPTION

# Tired of spam and other net abuse?  Report it!  Most service providers
# terminate accounts used for such purposes.

# Adcomplain is a tool for reporting inappropriate commercial e-mail and
# Usenet postings, as well as chain letters and "make money fast" postings.

# It automatically analyzes the message, composes an abuse report, and mails
# the report to the offender's internet service provider.  The report is
# displayed for your approval prior to mailing.  Adcomplain can be invoked
# from the command line or automatically from many news and mail readers.

# Adcomplain runs under Unix, Windows-NT, Windows-95, and OS/2.  Adcomplain
# does _not_ currently run on Macintosh systems.  [URL for a Macintosh solution
# TBA...]

# You must have Perl  installed on your system to run this.  (Either perl
# version, 4 or 5, will work.)  Perl can be obtained at:  http://www.perl.com/

# adcomplain was created in the belief that a single concise message is the
# most appropriate way to complain.  Mail bombing (e-mailing megabytes of
# useless data) and public flaming (replying on Usenet, causing your complaint
# to be duplicated on every machine in the network) are discouraged.

# The default letter meets ISP standards (such as those required by netcom) for
# abuse reports.  The letter hopefully makes its point without wasting value
# computer or human bandwidth.  It marks itself as being machine-generated, so
# that system administrators can quickly recognize its format and content.

# A third-party forwarding service called "abuse.net" is used for complaints to
# the offender's provider.  This ensures that the best known complaint address
# is used.  The first time you use abuse.net, you will receive a message asking
# you to register.  See http://www.abuse.net for more information.

#-----------------------------------------------
# USAGE
# Pipe the Usenet posting or e-mail into this program.  It may detect
# mail forgeries or other problems and ask you to confirm by pressing return.
# It will then compose the message and display it for approval before mailing.
# You have opportunities to edit or list the message, or to just abort.

# SYNOPSIS
# adcomplain [-b] [-c] [-f template] [-m] [-o outname] [-p inname] [-q] [-s]
#	[-u] [-v] [newsgroup]

# OPTIONS
# Any combination of options may be used together. For example, -c and
# -m may be used together to complain about a chain letter received via
# e-mail.

# You may supply a newsgroup name (or comma separated newsgroups list)
# as the last argument. If not supplied, the contents of the
# 'Newsgroups' header, if present, will be used. 

# -b
#   Batch mode.  This is not recommended; adcomplain is not as smart as
#   a human, and automated responses will often be sent to an inappropriate
#   site.  This switch has been added by user demand, but your are implored
#   in the strongest possible terms to originate, examine, and approve each
#   one of your complaints individually.  Violations of terms of service are
#   serious offenses, and each complaint deserves your personal attention.

# -c
#   Chain letter mode. Composes and mails a complaint about chain
#   letters, such as Make Money Fast.

# -f template
#   Use the contents of the specified file as the complaint text.
#   The contents of this file will have perl variables expanded before
#   proceeding.  Some useful ones are:
#
#   $header_analysis -- list of header anomalies in the message
#   $newsgroups -- news groups this was posted to
#   $postmaster -- postmaster at the originator's site

# -l
#   (Legal letter)  Set this if the e-mail or posting is legal, but
#   merely inappropriate.  If this is not set, mail will be cc'd to
#   the authorities (see $authorities).

# -m
#   Force the input to be regarded as a mail message.  This is not
#   necessary in most instances; adcomplain will correctly infer whether the
#   message is a mail or a Usenet message.

# -o outname
# 	Specify a file in which to place the generated complaint message;
#	this option also prevents adcomplain from mailing the complaint.

# -p inname
#  Read the ad from given file.  You _must_ use this option on
#  Windows-NT, Windows-95, and OS/2 systems.

# -q
#   Quiet mode.  Doesn't ask any questions except whether to send the message.
#   You must still examine the message, and you are given an opportunity to
#   modify the message or abort it.

# -s
#   Don't append your .signature.  Adcomplain normally appends your signature
#   (though this behavior can be changed at configuration time);  this switch
#   ensures that your signature is omitted.

# -u
#   Don't resolve.  Regard the message syntactically, i.e. don't try to confirm
#   host names and domains.  This is useful if you are behind a firewall
#   and have absolutely no way to confirm the hostnames within the message.

# -v
#   Verbose mode. Diagnostic messages will be printed.

# NOTE: the -t switch is a regression test mode.  It runs the header analysis
# in verbose mode and stops before sending the message.  It is not intended
# for normal use.

#-----------------------------------------------
# ENVIRONMENT VARIABLES
# The following environment variables influence the operation:

# $ADCOMPLAIN_DOMAINS is used to set a list of domain names that should _not_
# be construed as valid origination domains for spam.  The default is
# empty.  The list should be space-delimited, i.e.,
#
# (in Windows-NT, Windows-95, and OS/2):
# set ADCOMPLAIN_DOMAINS=domain1.com domain2.com
# (Unix, ksh):
# export ADCOMPLAIN_DOMAINS="domain1.com domain2.com"

# $ADCOMPLAIN_FROM will specify the "From:" address in the resulting complaint
# message.  This is a convenience for individuals who use adcomplain in
# multiple mail domains but want to register with abuse.net only once.
# Users on Windows-95 _must_ set this.

# $ADCOMPLAIN_HOSTS is a file that is searched before the regular
# gethostbyname() # and gethostbyaddr() functions are called.  (This is
# mainly used by adcomplain's internal regression test suite.)

# $ADCOMPLAIN_MAILHOST is the name of the host to use to relay (SMTP)
# our complaints.  The default is the current host or the value of $mailhost
# in the configuration section below.
# Win-95 and Win-NT users must almost always set this, because these systems
# do not have a sendmail daemon.

# $ADCOMPLAIN_MDOMAIN will specify your mail domain.  The intended use
# for this would be in a shared installation where multiple hosts use one
# copy of this script, but adcomplain is unable to determine your mail domain
# on its own.  This is not needed if $ADCOMPLAIN_FROM is set.  Administrators
# may wish to set this parameter directly in the script, i.e.:
#  $ENV{'ADCOMPLAIN_MDOMAIN'} = 'juno.com';

# $ADCOMPLAIN_OPTS is an additional list of switches that should be added to
# every invocation of adcomplain.

# $EDITOR -- the editor to use to edit the message, if $VISUAL is not
# defined.  If not defined, the default is "vi" on Unix, "notepad" on
# win32, and "e" on OS/2.

# $PAGER -- The message is always displayed prior to mailing using this
# program.  If $PAGER is not defined, the default is "more" on Unix,
# and the internal pager on Windows-NT, Windows-95, and OS/2.  You can specify
# the builtin pager by setting $PAGER to "builtin".

# $SIGNATURE -- name of a file that holds your signature.  The default
# is $HOME/.signature.

# $VISUAL -- the editor to use to edit the message, when an editor is requested.
# If not defined, $EDITOR is used.

#-----------------------------------------------
# INSTALLATION
# You must have either perl 4.036 or perl 5.0 installed.
# Perl can be obtained at:  http://www.perl.com/

# Installation on Windows-NT, Windows-95, and OS/2 Systems:
# --------------------------------------------------
# Save this script in a convenient place on your system.

# Make sure your system is configured to run TCP/IP, and that you
# have perl5 installed or your system.

# If you are running on Windows 95, you _must_ set the following
# environment variables:
#	COMPUTERNAME -- the name of your host, as used in TCP/IP
#	ADCOMPLAIN_FROM -- your return e-mail address

# If you are running on OS/2, you _must_ set the following environment
# variables:
#	HOSTNAME -- the name of your host, as used in TCP/IP
#	ADCOMPLAIN_FROM -- your return e-mail address

# You can either put a line like
#	$ENV{'ADCOMPLAIN_FROM'} = 'myname@somedomain.com';
# in the configuration section, or put "set" commands in your autoexec file
# and reboot.  Your pick.

# Examine the configuration section carefully and adjust to taste.  Note
# that you _must_ set $mailhost, unless you've actually bought and
# installed a sendmail program on your machine.

# To test, send an e-mail message to yourself, save the message in a
# file, and type "adcomplain -p file", where "file" is the file in which
# you saved the message.  Edit the resulting message to send the complaint
# to yourself, and let adcomplain mail the message.  You should receive the
# mail message shortly.

# Installation on Unix Systems:
# -----------------------------
# Type "echo $PATH" to list the directories in your search path.
#
# Go to one of those directories and save this script in a file named
# "adcomplain".
#
# Examine the Configuration Section and make sure it is correct for your
# system.  You will probably want to change the value for $mailhost to
# match your system.
#
# Type "chmod +x adcomplain" to make it executable.
#
# Type "rehash" to add it to the search path.
#
# To test, send an e-mail message to yourself, save the message in a
# file, and type "adcomplain <file", where "file" is the file in which
# you saved the message.  Edit the resulting message to send the complaint
# to yourself, and let adcomplain mail the message.  You should receive the
# mail message shortly.

# There are reports that the complex "#!" exec-line causes trouble on some
# primitive BSD systems.  You may have to find perl (try "/bin/which perl"
# "/usr/bin/which perl", or "type perl") and modify the first line per the
# comments at the front of this file.

#-----------------------------------------------
# NEWSREADER CONFIGURATION
# You can configure many newsreaders to allow easy response to Usenet spam.

# =================
# rn, trn, and strn:

# Put the following in your ~/.rnmac file to map adcomplain to the 'a' key:
#
# a %(%m=[pa]?|adcomplain %C\n:a)
#
# In addition, rn users can complain about chain letters by mapping the
# 'A' key as follows:
#
# A %(%m=[pa]?|adcomplain -c\n:A)
#
# rn users can also customize the message based on the current newsgroup
#   by using adcomplain's -f mode as shown in the following example:
#
# Z %(%m=[pa]?%(%C=aaa.forsale?|adcomplain -f aaa_complaint\n:%(%C=bbb.forsale?|adcomplain -f bbb_complaint\n:%(%C=ccc.forsale?|adcomplain -f ccc_complaint\n:%(%C=ddd.forsale?|adcomplain -f ddd_complaint\n:Z)))))
#
# When 'Z' is pressed, the above macro checks the newsgroup name, and if
# it matches one of four choices (aaa.forsale, bbb.forsale, ccc.forsale,
# ddd.forsale), uses a complaint message specific to that newsgroup.
# You can use it to complain about foreign postings in local newsgroups,
# for example (e.g., "aaa.forsale is for items for sale in the Podunk
# area.")

# =================
# nn:

# Put the following in your ~/.nn/init file to map adcomplain
# to ctrl-A and chain mail complain to ctrl-B:
# 
# map both ^A (
# :!! cat /dev/null > /tmp/junk$(USER)
# save-full "//tmp/junk$(USER)"
# :! echo; adcomplain $G < /tmp/junk$(USER)
# :!! rm -rf /tmp/junk$(USER)
# )
# map both ^B (
# :!! cat /dev/null > /tmp/junk$(USER)
# save-full "//tmp/junk$(USER)"
# :! echo; adcomplain -c $G < /tmp/junk$(USER)
# :!! rm -rf /tmp/junk$(USER)
# )
#

# =================
# tin:

# Type "|" at the article level to pipe the article into
# adcomplain. Type "adcomplain" when it asks for the command name.

# =================
# SLRN newsreader (thanks to Ralf Hildebrandt <R.Hildebrandt@tu-bs.de>)

# Put an additional line in the ~/.slrnrc :
#	interpret ".slrn.sl"
#
# The file ~/.slrn.sl contains:
#
# define pipe_to_adcomplain ()
# {
#    pipe_article ("adcomplain -q");
# }
# definekey ("pipe_to_adcomplain", "S", "article");
#
# This binds the key "S" to adcomplain -q "article".

#-----------------------------------------------
# DISCLAIMER, LICENSE, AND TERMS OF USE

# The latest version of the Gnu Copyright ("copyleft") hereby constitutes
# your terms of use and redistribution.  The Gnu Copyright, which is included
# with each Free Software Foundation distribution, is available from your
# favorite Gnu archive.

# IN NON-LEGAL TERMS, the Gnu Copyright gives you the right to use,
# redistribute, modify, or even borrow part or all of this program.  You
# are explicitly prohibited from selling this program or incorporating parts
# of it in software for profit.  Read the copyright for the exact terms and
# conditions.

# When you use this program you assume all risk and liability; it has no
# warranty.  A portion of the Gnu Copyright addressing the warranty is herein
# reproduced:

#                             NO WARRANTY
# 
#   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
# FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
# OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
# PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
# OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
# TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
# PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
# REPAIR OR CORRECTION.
# 
#   12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
# WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
# REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
# INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
# OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
# TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
# YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
# PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.

#-----------------------------------------------
# BACKGROUND, CREDITS, and BUG REPORTING

# adcomplain is the brainchild of "Bill McFadden" billmc@agora.rdrop.com,
# who wrote it originally in csh (!!!).

# "D. Jason Penney" <jason@gemstone.com> transcribed it to run in perl,
# significantly augmented the header processing, and added domain name
# verification.

# Acknowledgements and thanks also go out to:
#   "Denis N. Antonioli" <antonioli@ifi.unizh.ch>
#   "Andrey A. Chernov" <ache@nietzsche.net>
#   "Jeff Salisbury" <jeff@cobra.sdl.usu.edu>
#   "Kelly Roach" <kbroach@daisy.uwaterloo.ca>
#   "Martin Ward" <Martin.Ward@durham.ac.uk>
#   "Wolfgang Weisselberg" <weissel@ph-cip.Uni-Koeln.DE>
#   "Wm" <wm_tarr@bigfoot.com>

# The latest version of this file is available at:
# http://www.rdrop.com/users/billmc

# Please mail ideas and bug reports to
# billmc@agora.rdrop.com or jason@gemstone.com.

# Be sure to include the version number and a test case in your bug report.

# $Id: adcomplain.pl,v 3.52 1999/05/10 16:51:28 jason Exp $
#-----------------------------------------------
local(
  $addsig, 		# set if you want ~/.signature to be added
  $cc, 			# list of cc'd recipiets
  $complaintFile, 	# predefined complaint text, if you don't like ours
  $fqdnWithoutHost,	# whether the fqdn should include the name of the host
  $mailhost, 		# host that is running your sendmail daemon
  $mailscript, 		# program for delivering the mail
  @mydomains, 		# list of domains that map to your current domain
  $noinclude, 		# set if you don't want to copy the ad in the letter
  $recipient		# whether it should go to poster, postmaster, or both
  );

#-----------------------------------------------
# CONFIGURATION SECTION
#-----------------------------------------------

# This section allows you to customize the default operation at your site.
# Example lines are included in comments, and a normal set of defaults are
# currently active.  Please examine each default and make a decision if
# the current settings are appropriate to your system.

# Default host for smtp traffic?  This is specific to GemStone; you
# will probably want to delete this.  This is overridden by
# $ADCOMPLAIN_MAILHOST.
#$mailhost = "mailhost";

# Include your .signature file?
# Set to 0 if you don't want to include your signature.
# Normally, adcomplain will append your signature unless -s is specified.
# $addsig = 0;
$addsig = 1;

# Are there authorities to which you should report illegal e-mails such
# as pyramid schemes and unsolicited commercial e-mail?  Comma-separated
# if more than one.
$authorities = "uce\@ftc.gov"; # Consult http://www.ftc.gov for details.
# $authorities = ""; # ...ftc.gov is only appropriate if your are in the USA.

# CC List -- Do you want a copy of the complaint sent to someone else?
# This is comma-separated if there is more than one.
$cc = "";

# Customize your complaint text?
# This is the default name of the file to use for the complaint text.  If the
# file name is empty, the default text will be used.  Override with the
# "-f <filename>" switch.
$complaintFile = "";

# Customize mail delivery?
# Adcomplain normally contacts a mail delivery agent directly.  If $mailscript
# is set, adcomplain runs the specified program directly instead, once per
# recipient.  Two arguments are passed:
#   1. The name of a file to send.  It contains all of the sendmail headers,
#      so your program will have to use or modify them appropriately.
#   2. "batch" or "interactive", in case the script wants to make
#      different UI decisions
# Suggested usage: PGP-signing the mail message, ...?
# $mailscript = "/usr/lib/sendmail -t <";

# Friendly Mail Domains?
# One spammer trick is to directly originate the mail message on your local
# host.  In other words, they contact the MTA at your mail site directly and
# originate the message at your site.  This is similar to the way adcomplain
# sends your response ;-).  If your MTA does not have appropriate security
# measures, adcomplain might decide that your complaint should be addressed to
# your own postmaster!  This is a list of domain names for your system; names
# in this list are excluded from consideration when selecting a complaint
# address.
#
# It may also be desirable to set this list if your domain has multiple names,
# or if you regularly get mail forwarded from another domain.
#
# If the ADCOMPLAIN_DOMAINS environment variable is set, it will be read
# as a space-delimited list of domains to use and will be _added_ to the
# default list set here.
#
# an example:  @mydomains = ('gemstone.com', 'slc.com');
@mydomains = ();

# Always include a copy of the offending message?
# Set to 0 to include a copy of the posting every time.
# Ordinarily this is not done unless you choose to notify the provider.
# $noinclude = 0;
$noinclude = 1;

# Default Recipient(s)
# Do you want to complain to the poster, to his mail domain, or both?
# $recipient = 1; # ($complain_to_only) only to the authorities;
# $recipient = 2; # ($poster_only) only to the poster
# $recipient = 3; # ($poster_and_complain_to) both 
$recipient = 1; # ($complain_to_only) only to the authorities;

# Degree of qualification of the hostname
# Some domains require the fqdn to include the name of the
# computer to correctly deliver the mail. Others don't.
$fqdnWithoutHost = 0;
#$fqdnWithoutHost = 1;

#-----------------------------------------------
# NO USER SERVICEABLE PARTS INSIDE
#-----------------------------------------------
local(
  $adcomplain_name,     # revision number of this adcomplain
  $adcomplain_revision, # revision number of this adcomplain
  $EXEMPT_LIST, 	# list of domains we don't send complaints to
  %available_hosts, 	# list of possible sites to complain to
  $batchmode, 		# control flag, indicates no interactive input
  $bullet, 		# constant, used when formatting letter
  $bullet2,		# constant, used when formatting letter
  $chainmode, 		# control flag, indicates this is a chain letter
  $complain_to, 	# name we chose to send the complaint to
  $complain_to_only, 	# constant value for $recipient: no complaints to poster
  $dont_resolve, 	# control flag, indicates don't try gethostbyname() etc.
  $editor, 		# name of your editor, for editing the letter
  $from, 		# your e-mail address
  $header_analysis, 	# list of non-RFC compliant problems with the ad
  $hosts_file, 		# list of hosts to be tried before gethostbyname()
  %hosts_to_ips, 	# cached list of results from gethostbyname()
  %ips_to_hosts, 	# cached list of results from gethostbyaddr()
  $local_hostname,	# name of this host (best guess)
  $mailmode,		# optional control flag, indicates this is not USEnet
  @monthNames, 		# constant list of months, as per RFC 822
  $newsgroup,		# name of the newsgroup(s) this ad was posted to
  $omit_signature, 	# control flag, ensures ~/.signature not in your letter
  $opt_err,		# getopt; indicates error parsing options
  $opt_b, 		# getopt (-b, sets $batchmode)
  $opt_c, 		# getopt (-c, sets $chainmode)
  $opt_f, 		# getopt (-f, sets $complaintFile)
  $opt_h, 		# getopt (-h, prints help and exits)
  $opt_l,		# getopt (-l, sets $legal_mode)
  $opt_m, 		# getopt (-m, sets $mailmode)
  $opt_o, 		# getopt (-o, sets $outmode and $outfile)
  $opt_p, 		# getopt (-p)
  $opt_q, 		# getopt (-q, sets $quiet)
  $opt_s,		# getopt (-s, sets $omit_signature)
  $opt_t, 		# getopt (-t, clears $quiet, sets $verbose, $testMode)
  $opt_u, 		# getopt (-u, sets $dont_resolve)
  $opt_v, 		# getopt (-v, sets $verbose)
  $os_kind, 		# the type of OS we're running on
  $outfile, 		# file we write letter to, if $outmode set
  $outmode, 		# control flag, letter gets saved to file, not mailed
  $pager,		# name of your paging program, for displaying letter
  $poster, 		# our guess as to the name of the poster
  $poster_and_complain_to, # constant value for $recipient
  $poster_only, 	# constant value for $recipient
  $postmaster,		# name of postmaster at complaint address
  $quiet, 		# control flag, limits interaction and output
  %rematch_aliases,	# heuristic list, resets priority of another header
  $response, 		# text of letter we will send
  $site, 		# site we will send the complaint to
  @site_exceptions,	# sites that have irregular syntactic form
  $subject, 		# subject header of the ad
  $tempname, 		# name of a temp file, esp. for displaying the letter
  $testMode,		# control flag, omits the mail sending step
  %timezones, 		# constant list of RFC-822 compliant time zone names
  @valid_domains,	# the known valid domain suffixes for countries
  $verbose, 		# control flag, gives noisy narrative of analysis
  @wdayNames, 		# constant list of RFC-822 compliant week day names
  );

&initialize();		# set up our constants, lists, environment
&process_inputs(); 	# parse command line options, read the message
&parse_headers();	# Analyze the message
&check_hosts();		# Analyze the list of possible hosts
&summarize();		# brief discussion of problems found

$response = &compose_message();	# Create the text of the message.

# Place a copy of the message on the disk
open(TEXTFILE, ">$tempname") || die "cannot open $tempname: $!";
printf TEXTFILE "%s", $response;
close TEXTFILE;

# Display the message
if (!$batchmode && !$outmode) {
  print "\n";
  &moref($tempname);
  }

&deliver_message();	# Display, mail, edit, abort...

print "\n";
unlink $tempname;
exit 0;

#-----------------------------------------------
# Process command line options, read the input file.
sub process_inputs {
  local($junk, @junk, $i);

  $junk = $ENV{"ADCOMPLAIN_OPTS"};
  if (defined($junk) && $junk ne "") {
    @junk = split(/\s/, $junk);
    # push(@ARGV, @junk);
    unshift(@ARGV, @junk); # make sure that non-dash opts stay at end
    }
  &Getopts('bcf:hlmo:p:qstuv');
  if ((defined($opt_h) && $opt_h) || $opt_err) {
    print "Usage: $0 [-b] [-c] [-f template] [-o outfile] [-p infile]\n";
    print "                   [-hmqv] [newsgroup]\n";
    print " -b -- batch mode (not recommended)\n";
    print " -c -- chain letter\n";
    print " -f -- text to use instead of standard blurb\n";
    print " -h -- this message\n";
    print " -l -- legal mode, don't cc the authorities ($authorities)\n";
    print " -m -- force input to be regarded as a mail message\n";
    print " -o -- write mail message to a file and quit without mailing\n";
    print " -p -- read the ad from given file\n";
    print " -q -- ask no unnecessary questions\n";
    print " -s -- Omit .signature from resulting letter.\n";
    # -t undocumented: it is a test-mode switch: adcomplain stops after
    # composing the letter but before attempting to mail it.  It is used
    # internally for regression testing.
    print " -u -- Don't attempt to use gethostbyaddr name resolution\n";
    print " -v -- verbose\n";
    print "\n";
    print "Version: $adcomplain_revision\n";
    exit 0;
    }

  $batchmode = 0; $batchmode = 1 if defined($opt_b) && $opt_b;
  $chainmode = 0; $chainmode = 1 if defined($opt_c) && $opt_c;
  $complaintFile = "";
  $complaintFile = $opt_f if (defined($opt_f) && $opt_f ne "");

  $legal_letter = 0; $legal_letter = 1 if defined($opt_l) && $opt_l;
  $mailmode = 0; $mailmode = 1 if defined($opt_m) && $opt_m;
  if (defined($opt_o) && $opt_o ne "") {
    $outfile = $opt_o;
    $outmode = 1;
    }
  else {
    $outfile = "";
    $outmode = 0;
    }
  $quiet = 0; $quiet = 1 if defined($opt_q) && $opt_q;
  $omit_signature = 0; $omit_signature = 1 if defined($opt_s) && $opt_s;
  $dont_resolve = 0; $dont_resolve = 1 if defined($opt_u) && $opt_u;
  $verbose = 0; $verbose = 1 if defined($opt_v) && $opt_v;

  # Resolve conflicting modes
  if (defined($opt_t) && $opt_t) { # test mode
    $quiet = 0;
    $verbose = 1;	# print traces
    $testMode = 1;# quits without mailing
    }

  $junk = $ENV{"ADCOMPLAIN_DOMAINS"};
  if (defined($junk) && $junk ne "") {
    @junk = split(/\s/, $junk);
    push(@mydomains, @junk);
    for ($i = 0; $i < @mydomains; $i ++) {
      $mydomains[$i] = &find_site($mydomains[$i]);
      }
    }
  if (@mydomains != 0 && $verbose) {
    print "adcomplain: home domains: ";
    for (@mydomains) {
      print "$_ ";
      }
    print "\n";
    }

  # copy original Usenet posting from stdin
  if ($opt_p) {
    open(MSG, "<$opt_p") || die "cannot open $opt_p: $!";
    @original = <MSG>;
    close MSG;
    }
  elsif ($os_kind eq "unix") {
    @original = <STDIN>;
    if (!$batchmode) {
      open(STDIN, $CONSOLE) || die "cannot reopen tty"; # UNIX dependency...
      }
    }
  elsif ($os_kind eq "winnt" || $os_kind eq "win32" || $os_kind eq "os2") {
    die "The -p option is required." unless defined($opt_p) && $opt_p ne "";
    }
  else {
    die "Don't know how to scarf stdin and reset console on this os ($os_kind)";
    }
  }

#-----------------------------------------------
# Finish up list of complaints about the message, make sure user sees them.
sub summarize {
  local($ans);

  for (sort(keys(%hosts_to_ips))) {
    $junk = $hosts_to_ips{$_};
    next if $junk ne "";
    $header_analysis .= "${bullet}I cannot find the IP of $_.\n\n";
    }
  for (sort(keys(%ips_to_hosts))) {
    $junk = $ips_to_hosts{$_};
    next if $junk ne "";
    $header_analysis .=
	"${bullet}I cannot convert IP \"$_\" to a host name.\n\n";
    }

  if (!$batchmode) {
    if ($header_analysis ne "") {
      $poster = "";
      $junk = &fmt($header_analysis, 72);
      print "adcomplain: header analysis:\n";
      print "----------------\n";
      print "$junk";
      print "----------------\n";
      }
    if ($verbose || $header_analysis ne "") {
      print "\nSummary of Potential Addressees: (\"$site\" recommended)\n";
      for (sort(keys(%available_hosts))) {
	printf "  %25s %s\n", $_, $available_hosts{$_};
	}
      }
    }

  # Limit the options
  if ($complain_to eq "" && $poster eq "") {
    if ($batchmode) {
      print "ERROR: adcomplain did not detect a valid recipient.\n";
      exit 1;
      }
    else {
      print "ERROR: no valid recipients; edit and correct before sending.\n";
      }
    }
  elsif ($complain_to eq "") {
    $recipient = $poster_only;
    }
  elsif ($poster eq "") {
    $recipient = $complain_to_only;
    }

  if ($testMode) {
    print "TEST MODE: early exit\n";
    exit 0;
    }

  # Make sure critical messages are seen
  if ($quiet || $batchmode) {
    }
  elsif ($poster eq "" || $complain_to eq "" || $header_analysis ne "") {
    print "Press enter to continue.... ";
    $ans = <STDIN>;
    }
  }

#-----------------------------------------------
# send, abort, edit, or list the message
sub deliver_message {
  local($send_to, $cc_to, $each, $ok);

  for (;;) {
    if ($batchmode) {
      $ans = "s";
      }
    else {
      print "\n";
      $ans = &get_answer("Send, abort, edit, or list (s/a/e/l)?", "a");
      }
    if ($ans =~ /s.*/ || $ans =~ /y.*/) {
      # re-extract the addressee from the body
      local(@junk, $junk);
     
      # we only need the headers, so that's all we read. We want to be able
      # to understand continued lines as well.
      open(F, "<$tempname") || die "temp file $tempname has disappeared!";
      for (;;) {	# load the headers
	$junk = <F>;
      	if (!defined($junk) || $junk =~ /^$/) { # end of headers
          push(@junk, $last_line) if $last_line ne "";
          last;
	  }
        if ($junk =~ /^(\S+: .*)/) {   # normal header line
         push(@junk, $last_line) if $last_line ne "";
         $last_line = $junk;
         next;
	 }
       if ($junk =~ /^\s+(.*)/) { # continued header line
         chop $last_line;    # kill the newline
         $last_line .= " "; 
         $last_line .= $1;
         next;
	 }
       }	# load the headers
      close F;

      $send_to = $cc_to = "";
      foreach $each (@junk) {
	last if $each =~ /^$/;		# end of headers
	if ($each =~ /^To: (.*)/i) {
	  $send_to = $1;
	  }
	elsif ($each =~ /^Cc: (.*)/i) {
	  $cc_to = $1;
	  }
	}
      if ($send_to eq "") {
	if ($batchmode) {
	  print "adcomplain: fatal error (no addressee)\n";
	  last;
	  }
	print "no addressee! re-edit and continue\n";
	next;
	}
      if ($outmode) {
	local(@out_array) = ();
	open(OUTFILE, "<$tempname") || die "error opening $tempname: $!";
	@out_array = <OUTFILE>;
	close(OUTFILE);
	open(OUTFILE, ">$outfile") || die "error creating $outfile: $!";
	print OUTFILE @out_array;
	close(OUTFILE);
	print "written to $outfile\n";
	last;  # all done!
	}

      $ok = &send_to_list($from, "$send_to, $cc_to", $tempname);
      if (!$ok) {
	print "send to $send_to failed\n";
	if ($batchmode) {
	  unlink $tempname;
	  exit 1;		# good exit status
	  }
	next;
	}
      print "sent to: $send_to\n";
      last;
      }
    if ($ans =~ /a.*/) {
      print "aborted\n";
      last;
      }
    if ($ans =~ /e.*/) {
      system "$editor $tempname <$CONSOLE";
      next;
      }
    if ($ans =~ /l.*/) {
      &moref($tempname);
      next;
      }
    print "what?\n";
    } # for
  }

#-----------------------------------------------
# Chop newline, respecting RFC-821 end of line conventions
sub rfc822_chop {
  local($text) = @_;

  for (;;) {
    return $text if $text !~ /[\n\r]$/;
    chop($text);
    }
  }

#-----------------------------------------------
# Exchange a line of text with an SMTP daemon
sub send_line {
  local($text) = @_;
  local($response);

  print S "$text\r\n";	# RFC-821, ^M^J is end of line!
  $response = <S>;
  $response = &rfc822_chop($response);
  return $response if $response =~ /^500/;
  print "send_line: response \"$response\"\n" if $verbose;
  return "";
  }

#-----------------------------------------------
# Relay a mail message through an SMTP daemon.
# Note: this is for use with perl-4.  I _know_ perl-5 has better routines.
sub do_sendmail {
  local($from, $body, @list) = @_;
  local ($each);

  local($sockaddr) = 'S n a4 x8';	# magic spell to pack an inet_addr
  local($name, $aliases, $type, $len, $thisaddr, $thataddr);
  local($local_inetaddr, $remote_inetaddr);
  local($targetPort) = "smtp";	# or 25, world-wide standard
  local($response);
  local($local_prot) = (getprotobyname('tcp'))[2];

  if (defined($mailscript) && $mailscript ne "") {
    $name = "$mailscript $body ";
    if ($batchmode) {
      $name .= "batch";
      }
    else {
      $name .= "interactive";
      }
    print "mail command: $name\n" if $verbose;
    $response = system($name) >> 256;
    if ($response != 0) {
      print "mail command \"$name\" failed!\n";
      return 0;
      }
    return 1;
    }

  ($name, $aliases, $targetPort) = getservbyname($targetPort, 'tcp')
      unless $targetPort =~ /^\d+$/;

  # Fill out local side of connection
  ($name, $aliases, $type, $len, $thisaddr) = gethostbyname($local_hostname);

  # Fill out remote side
  if ($mailhost =~ /\d+\.\d+\.\d+\.\d+/) {
    local($a, $b, $c, $d) = split(/\./, $mailhost);
    $thataddr = pack("C4", $a, $b, $c, $d);
    }
  else {
    ($name, $aliases, $type, $len, $thataddr) = gethostbyname($mailhost);
    if (!defined($name) || $name eq "") {
      # $! doesn't have error return here.  Sigh.
      print STDERR "cannot find \"$mailhost\" (gethostbyname)\n";
      return 0;
      }
    }
  
  $local_inetaddr = pack($sockaddr, &AF_INET, 0, $thisaddr);
  $remote_inetaddr = pack($sockaddr, &AF_INET, $targetPort, $thataddr);
  
  #MAKE the socket filehandle.
  if ( ! socket( S, &AF_INET, &SOCK_STREAM, $local_prot)) {
    print STDERR "socket() failure: $!\n";
    return 0;
    }
  
  #GIVE the socket an address.
  if (! bind(S, $local_inetaddr)) {
    print STDERR "bind() failure: $!\n";
    return 0;
    }
  
  #Call up the server.
  if (! connect( S, $remote_inetaddr)) {
    print STDERR "unable to connect() to \"$mailhost\": $!\n";
    return 0;
    }
  print "do_sendmail: contacted \"$mailhost\"\n" if $verbose;
  
  #Set socket to be command buffered.
  select(S); $| =1; select(STDOUT);

  # sometimes you have to be aggressive to get the daemon to talk?
  # print S "\r\nHELO $local_hostname\r\n";
  # $response = <S>;
  # print "do_sendmail: throw-away response \"$response\"\n" if $verbose;

  # Start the dance....
  print S "HELO $local_hostname\r\n";

  # Try to get the initial acknowledgement.  Some SMTP servers are silent
  # until you speak first.  Others speak without being prompted.  The best way
  # out of this ambiguity is to just eat until we see the banner.  We
  # do _not_ check for 500 errors here.
  for (;;) {
    $response = <S>;
    $response = &rfc822_chop($response);
    print "do_sendmail: initial response \"$response\"\n" if $verbose;
    last if $response =~ /^220 /;
    last if $response =~ /^250 /;
    last if $response =~ /^SMTP/;
    }

  $response = &send_line("MAIL FROM: <$from>");
  if ($response ne "") {
    print "do_sendmail: error(MAIL FROM) \"$response\" from sendmail\n";
    close S;
    return 0;
    }

  foreach $each (@list) {
    $response = &send_line("RCPT TO: $each");
    if ($response ne "") {
      print "do_sendmail: error(RCPT TO $each) \"$response\" from sendmail\n";
      close S;
      return 0;
      }
    }

  $response = &send_line("DATA");
  if ($response ne "") {
    print "do_sendmail: error(DATA) \"$response\" from sendmail\n";
    close S;
    return 0;
    }

  if (!open(F, "<$body")) {
    print "do_sendmail: cannot open $body\n";
    close S;
    return 0;
    }
  for (;;) {
    $body = <F>;
    last if !defined($body);
    $body = &rfc822_chop($body);	# put our _own_ line terminator on it
    $body = ".$body" if $body =~ /^\..*/; # rfc821 sec. 4.5.2 transparency
    print S "$body\r\n";
    }
  close F;

  $response = &send_line(".");
  if ($response ne "") {
    print "do_sendmail: error(final) \"$response\" from sendmail\n";
    close S;
    return 0;
    }

  $response = &send_line("QUIT");
  if ($response ne "") {
    print "do_sendmail: error(QUIT) \"$response\" from sendmail\n";
    close S;
    return 0;
    }
  close S;

  return 1;
  }

#-----------------------------------------------
# Deliver text to everyone on a list
sub send_to_list {
  local($from, $send_to, $body) = @_;
  local($ok);
  local(@list) = split(/[ \t\n,]+/, $send_to);

  $ok = &do_sendmail($from, $body, @list);
  return $ok;
  }

#-----------------------------------------------
# getopts.pl - a better getopt.pl.  The one shipped with perl has bugs.

# Usage:
# do Getopts('a:bc'); # -a takes arg. -b & -c not. Sets opt_* as a
# # side effect.
# $opt_err set nonzero in case of error.

sub Getopts {
  local($optlist) = @_;
  local(@args, $_, $first, $rest, $pos);
  local(@new_argv, @unused_argv);
  local(@active_argv) = ();

  # Gather up the argv's that we should be examining
  for (;;) {
    last if !@ARGV;
    $each = shift(@ARGV);
    last if ($each eq "--"); # POSIX convention
    push(@active_argv, $each);
    }
  @unused_argv = @ARGV; # remaining args unprocessed
  @new_argv = ();

  $opt_err = 0;
  @args = split(/ */, $optlist);
  for (;;) { # process argv
    last if !@active_argv;

    if (($_ = $active_argv[0]) !~ /^-(.)(.*)/) {
      # Allow non-switch args, as in gnu getopt
      push(@new_argv, $active_argv[0]);
      shift(@active_argv);
      next;
      }
    ($first,$rest) = ($1,$2);

    $pos = index($optlist, $first);
    if ($pos < 0) {
      print STDERR "Unknown option: $first\n";
      ++$opt_err;
      if($rest ne '') {
	$active_argv[0] = "-$rest";
	}
      else {
	shift(@active_argv);
	}
      next;
      }

    if (!defined($args[$pos + 1]) ||
	$args[$pos + 1] ne ':') { # simple switch argument
      eval "\$opt_$first = 1";
      if ($rest eq '') {
	shift(@active_argv);
	}
      else {
	$active_argv[0] = "-$rest";
	}
      next;
      }

    # switch takes argument
    if ($rest ne '') {
      eval "\$opt_$first = \"$rest\"";
      shift(@active_argv);
      next;
      }

    shift(@active_argv);
    if ($rest eq '') { # argument is $active_argv[0]
      if (!@active_argv) {
	print STDERR "-$first: argument missing\n";
	$opt_err ++;
	last;
	}
      $rest = shift(@active_argv);
      if ($rest eq "--") {
	print STDERR "-$first: argument missing\n";
	$opt_err ++;
	last;
	}
      } # argument is $active_argv[0]
    eval "\$opt_$first = \$rest;";
    } # process argv

  # Remaining args are left for caller...
  @ARGV = (@new_argv, @unused_argv);;
} # Getopts

#-----------------------------------------------
# Find the first line that matches the given header and return it.
sub extract_header {
  local($pattern) = @_;
  local($result);

  $result = "";
  for (@original) {
    last if length($_) == 1; # RFC-822: end of headers at first blank line
    if ($result ne "") {
      last if $_ !~ /^\s+(.*)/;	# not a continued header, and we're done.
      $result .= " "; 
      $result .= $1;
      chop($result);
      }
    elsif ($_ =~ /$pattern/i) { # RFC-822 says case-independent
      $result = $_;
      chop($result);
      $result =~ s/$pattern\s*(.*)/$1/i;
      }
    }
  return $result;
} # extract_header

#-----------------------------------------------
# Return true if the given pattern is a private (intra-net) IP
# (from RFC 1597)
# ---------
# 3. Private Address Space 
#    
#    The Internet Assigned Numbers Authority (IANA) has reserved the
#    following three blocks of the IP address space for private networks:
#    
#         10.0.0.0        -   10.255.255.255
#         172.16.0.0      -   172.31.255.255
#         192.168.0.0     -   192.168.255.255

sub is_private_inet_addr {
  local($pat) = @_;

  return 0 unless $pat =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
  return 1 if $1 == 10;
  return 1 if $1 == 172 && $2 >= 16 && $2 <= 31;
  return 1 if $1 == 192 && $2 == 168;
  return 0;
  }

#-----------------------------------------------
# Return true if the given pattern is an inet address, e.g. "192.83.233,4"
sub is_inet_addr {
  local ($pat) = @_;

  return 0 unless $pat =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
  return 0 if $1 > 255;
  return 0 if $2 > 255;
  return 0 if $3 > 255;
  return 0 if $4 > 255;
  return 1;
  }

#-----------------------------------------------
# return the connecting SMTP agent's name for itself
sub helo_name {
  local ($text) = @_;
  local ($probe);

  return "" unless $text =~ /.*from\s*[\w\.-]+.*/;
  ($probe = $text) =~ s/.*from\s*([\w\.-]+).*/$1/;	# get first word

  $probe =~ s/^\((.*)\).*/$1/;	# turn (host) into host
  $probe =~ s/(.*)\(.*\).*/$1/;	# turn host(inet_addr) into host
  $probe =~ s/^(\S+)\s+.*/$1/;	# get first word
  $probe = &good_hostname($probe, 0);	# don't require this name to exist
  return "" if $probe eq "";

  return $probe;
  }

#-----------------------------------------------
# Return name of recipient machine ("by" clause in "Received:" header)
sub by_name {
  local ($text) = @_;
  local ($probe);

  return "" unless $text =~ /.*by\s+([\w\.-]+).*/;
  $probe = &good_hostname($1, 0);	# peer must exist!
  return $probe;
  }

#-----------------------------------------------
# Return (name, inet_addr) of peer name out of received header if they exist
sub received_peer_name {
  local ($text) = @_;
  local ($probe, $probe2);
  local ($peer_name, $inet_addr);

  return ("", "") unless $text =~ /.*from\s*[^(]*\([^)]*\)/;

  $probe = $text;

  # a _very_ thorny problem.  Extract the from-clause (stuff between parens).
  # Ignore any by-clause.
  if ($probe =~ /\(peer crosschecked as: (.*)\)/)  {
    # new stuff from uunet, yay!  Sep '97, they're finally hitting back.
    $probe = $1;
    }
  else {
    $probe =~ s/.*\bfrom\s+(.*)\s+by\s.*/$1/;  # by-clause after from-clause
    $probe =~ s/.*\bby\s+.*\s+from\s+(.*)/$1/;  # from-clause after by-clause
    return "" unless $probe =~ /[^(]*\(([^)]*)\).*/; # must have parens here.
    $probe = $1;			# stuff between parens
    }

  $inet_addr = $probe;
  $probe =~ s/\s*(\S+).*/$1/; # grab first word
  return ("", "") if $probe =~ /.*smail.*/i;  # strange smail header
  return ("", "") if $probe =~ /.*smtp.*/i;  # strange smtpd header
  return ("", "") if $probe =~ /^\d\.\d/;  # strange sendmail header

  # Get the internet address.
  $inet_addr =~ s/^[^[]*\[(.*)\]/$1/;
  $inet_addr = "" if !&is_inet_addr($inet_addr);

  $probe =~ s/^([^[]*)\[.*\]/$1/; # ignore bracketed inet address
  if (&is_inet_addr($probe)) { # mailhost was as puzzled as we are
    $inet_addr = $probe;
    $probe = "";
    }

  $probe = &good_hostname($probe, 0);
  if ($probe eq "localhost" || $inet_addr eq "127.0.0.1") {
    $probe = $inet_addr = "";
    }
  return ($probe, $inet_addr);
  }

#-----------------------------------------------

sub dict_at {
  local($pos) = @_;
  local($b1, $b2, $b3, $b4);

  $pos *= 4;
  $b1 = ord(substr($EXEMPT_LIST, $pos, 1));
  $b2 = ord(substr($EXEMPT_LIST, $pos + 1, 1));
  $b3 = ord(substr($EXEMPT_LIST, $pos + 2, 1));
  $b4 = ord(substr($EXEMPT_LIST, $pos + 3, 1));

  return ($b1 << 24) | ($b2 << 16) | ($b3 << 8) | $b4;
  }

sub dawg_check {
  local($word) = @_;
  local($edgePos);
  local($wordChar, $wordPos);

  $edgePos = 1;			# root node

  $wordPos = 0;
  $wordChar = ord(substr($word, $wordPos, 1));
  for (;;) {
    if ($wordChar == ((&dict_at($edgePos) >> 24) & 0xff)) {
				# character match
      $wordPos ++;		# extract next char in word
      $wordChar = ord(substr($word, $wordPos, 1));
      $wordChar = 0 if !defined($wordChar);
      if ($wordChar == 0) {	# end of word
	return (&dict_at($edgePos) & 0x800000) != 0;
        }
      else {			# jump to new node
        $edgePos = &dict_at($edgePos) & 0x1ffff;
	last if $edgePos == 0;	# null pointer, we're done
	next;
	}
      }
    last if (&dict_at($edgePos) & 0x400000) != 0;	# end of node, no match
    $edgePos ++;		# next entry in this node
    }
  return 0;			# not found
  }

#-----------------------------------------------
# Return 1 if the given name is in the list of exempt sites.
sub is_exempt {
  local ($name) = @_;
  local ($site);

  return 0 if $name eq "";
  $name =~ y/A-Z/a-z/;		# canonicalize to lower case
  $site = &find_site($name);	# site, not host.
#  $site = $name;

  return 0 if !&dawg_check($site);
  print "found exempt domain \"$site\".\n" if $verbose;
  return 1;
}

#-----------------------------------------------
# Return 1 if arg begins with a valid month (RFC-822)
sub is_month {
  local ($text) = @_;
  local ($probe, $each, $result);

  ($probe = $text) =~ s/^\s*(\S\S\S)\s+.*/$1/;
  for (@monthNames) {
    return 1 if $_ =~ /$probe/i;
    }
  return 0;
}

#-----------------------------------------------
# Return 1 if the arg is a legal (RFC-822) day of the week.
sub is_day {
  local ($text) = @_;
  local ($probe, $result);

  ($probe = $text) =~ s/^\s*(\S\S\S).*/$1/;
  $probe =~ s/(\W)/\\$1/g;		# remove special characters
  for (@wdayNames) {
    return 1 if $_ =~ /$probe/i;
    }
  return 0;
  }

#-----------------------------------------------
# Is time zone believable?
sub zone_check {
  local ($datepart) = @_;
  local ($hour_offset, $zone, $zoneStr);
  local (@zone_list, $each);

  $hour_offset = $zone = $datepart;
  if ($hour_offset =~ /(-\d\d\d\d)/) {
    $hour_offset = $1;
    }
  elsif ($hour_offset =~ /\+(\d\d\d\d)/) {
    $hour_offset = $1;
    }
  else {
    $hour_offset =~ s/^.*\D(\d\d\d\d).*/$1/;
    }
  return 1 if $hour_offset eq $datepart;

  # $pattern = "^.*" . $hour_offset . "\s*\(([^)]+)\).*";
  # $zone =~ s/$pattern/$1/;
  $zone =~ s/^.*$hour_offset\s*\(([^)]+)\).*/$1/;
  return 1 if $zone eq $datepart;

  $zoneStr = $timezones{$hour_offset};
  if ($zoneStr eq "") {
    print
      "zone_check:  Unknown time zone \"$hour_offset\" in date \"$datepart\"\n"
	if $verbose;
    $header_analysis .=
	"${bullet}I cannot confirm that the time zone \"$zone\" in \"Received:\"\n";
    $header_analysis .= "header \"$datepart\"\n";
    $header_analysis .= "should have an hour offset of \"$hour_offset\".\n\n";
    return 1;
    }
  @zone_list = split(/,\s*/, $zoneStr);
  for (@zone_list) {
    return 1 if $_ =~ /^$zone$/i; # OK, let it be case-insensitive
    }

  if ($verbose) {
    print "zone_check: hour offset $hour_offset has zone $zone, ";
    print "expected one of: $zoneStr\n";
    }

  # prettify for the message
  $zoneStr = "";
  for (@zone_list) {
    $zoneStr .= ", " if $zoneStr ne "";
    $zoneStr .= "\"$_\"";
    }
  if ($zoneStr =~ /^[^,]+,[^,]+$/) {
    $zoneStr =~ s/(.*), ([^,]*)$/$1 or $2/g;
    }
  else {
    $zoneStr =~ s/(.*), ([^,]*)$/$1, or $2/g;
    }

  $header_analysis .= "${bullet}Time zone in \"Received:\" header \"$datepart\"\n";
  $header_analysis .=
    "is \"$zone\" when it should be one of: $zoneStr.\n";
  $header_analysis .=
	"(This is the signature of the \"Stealth\" spam mailer.)\n"
	if $zone eq "EST";
  $header_analysis .= "\n";

  return 0;
}


#-----------------------------------------------
# Return 1 if the header parses properly
sub parse_received_header {
  local ($text) = @_;
  local ($datepart, $probe, $probe2, $each);

# From rfc822:
# TO DO:  note that "from" must be first, etc.
#     received    =  "Received"    ":"            ; one per relay
#                       ["from" domain]           ; sending host
#                       ["by"   domain]           ; receiving host
#                       ["via"  atom]             ; physical path
#                      *("with" atom)             ; link/mail protocol
#                       ["id"   msg-id]           ; receiver msg id
#                       ["for"  addr-spec]        ; initial form
#                        ";"    date-time         ; time received
#     date        =  1*2DIGIT month 2DIGIT        ; day month year
#                                                 ;  e.g. 20 Jun 82
#     date-time   =  [ day "," ] date time        ; dd mm yy
#                                                 ;  hh:mm:ss zzz
#     day         =  "Mon"  / "Tue" /  "Wed"  / "Thu"
#                 /  "Fri"  / "Sat" /  "Sun"
#     hour        =  2DIGIT ":" 2DIGIT [":" 2DIGIT]
#                                                 ; 00:00:00 - 23:59:59
#     month       =  "Jan"  /  "Feb" /  "Mar"  /  "Apr"
#                 /  "May"  /  "Jun" /  "Jul"  /  "Aug"
#                 /  "Sep"  /  "Oct" /  "Nov"  /  "Dec"
#     time        =  hour zone                    ; ANSI and Military
#     zone        =  "UT"  / "GMT"                ; Universal Time
#                                                 ; North American : UT
#                 /  "EST" / "EDT"                ;  Eastern:  - 5/ - 4
#                 /  "CST" / "CDT"                ;  Central:  - 6/ - 5
#                 /  "MST" / "MDT"                ;  Mountain: - 7/ - 6
#                 /  "PST" / "PDT"                ;  Pacific:  - 8/ - 7
#                 /  1ALPHA                       ; Military: Z = UT;
  if ($text !~ /;/) {
    $header_analysis .= "${bullet}\"Received:\" header \"$text\"\n";
    $header_analysis .= "has no mandatory semicolon (see RFC-822).\n\n";
    return 0;
    }

  # But does it really have a time?
  ($datepart = $text) =~ s/.*;\s*(.*)/$1/;
  $probe = $datepart;

  # Remove comments (thanks to Andrey A. Chernov for this)
  $probe =~ s/(\([^)]*\))//g;

  if ($probe =~ /,/) {
    # process the day field
    ($probe2 = $probe) =~ s/^\s*([^,\s]+)\s*,.*/$1/;
    if (!&is_day($probe)) {
      $header_analysis .=
	  "${bullet}Day of week in \"Received:\" header, \"$datepart\",\n";
      $header_analysis .=
	  "is not standard (see RFC-822).\n\n";
      return 0;
      }
    $probe =~ s/[^,\s]+\s*,(.*)/$1/;  # now looking at date + time
    }
  else {
    # Nonstandard netcom header
    $probe =~ s/^\s*...\s+(.*)/$1/ if &is_day($probe);
    }

  $probe =~ s/^\s*(.*)/$1/; # remove leading spaces

  if ($probe =~ /^\d+\s+(.*)/) { # standard day-month-year
    $probe = $1;		# now must have month

    if (!&is_month($probe)) {
      $header_analysis .=
	"${bullet}Date in \"Received:\" header, \"$datepart\", is not\n";
      $header_analysis .= "standard (see RFC-822).\n\n";
      return 0;
      }
    $probe =~ s/^...\s+(.*)/$1/;
    }
  elsif (&is_month($probe)) {
    # Netcom has non-standard month-day-year
    $probe =~ s/^...\s+(.*)/$1/;
    if ($probe !~ /^\d/) {
      $header_analysis .= "${bullet}(Netcom-style) ";
      $header_analysis .=
	  "date in \"Received:\" header, \"$datepart\", is not standard;\n";
      $header_analysis .= "cannot find day of month (see RFC-822).\n\n";
      return 0;
      }
    }
  else {
    $header_analysis .=
	"${bullet}Date in \"Received:\" header, \"$datepart\", is not\n";
    $header_analysis .= "standard; cannot find day of month (see RFC-822).\n\n";
    return 0;
    }

  # Now for year
  $probe =~ s/^...\s+(.*)/$1/;
  if ($probe !~ /^\d+/) {
    $header_analysis .=
	"${bullet}Date in \"Received:\" header, \"$datepart\", is not\n";
    $header_analysis .= "standard; cannot find the year (see RFC-822).\n\n";
    return 0;
    }
  $probe =~ s/^\d+\s+(.*)/$1/;  # anything left?
  if ($probe !~ /^\d\d:\d\d/) {
    $header_analysis .=
	"${bullet}Date in \"Received:\" header, \"$datepart\", is not\n";
    $header_analysis .= "standard; time is not hh:mm:ss (see RFC-822).\n\n";
    return 0;
    }

  # in practice, time zones are not very consistent, but we'll do our best.
  return 0 if !&zone_check($datepart);

  return 1;
  }

#-----------------------------------------------
# Indicate if the Received: header is forged.
sub forged_received_header {
  local ($text) = @_;
  local ($possibleName);
  local ($probe, $probe2, $result);

  # Many ad hoc checks for a bogus Received: header.
  # Plenty of work needs to be done here.
  # See http://oasis.ot.com/~dmuth/spam-l

  # everything after the 'from'
  ($possibleName = $text) =~ s/^Received:\s*(.*)/$1/i;

  $result = 0;

  for ("CLOAKED!", "may be forged", "unknown host") {
    next unless $possibleName =~ /$_/i;
    print "forged_received_header: found \"$_\" in header.\n" if $verbose;
    $header_analysis .=
	"${bullet}\"Received:\" header has suspicious text: \"$_\".\n\n";
    $result = 1;
    }

  # look for impossible IP address
  $probe2 = $probe = $possibleName;
  for (;;) {
    local ($str1, $str2, $str3, $str4);

    # last if !($probe =~ /\d+\.\d+\.\d+\.\d+/);
    last unless $probe =~ /[\[(]\s*(\d+\.\d+\.\d+\.\d+)\s*[\])]/;
    # idea: require that the inet_addr have enclosing brackets?

    ($str1 = $probe2 = $1) =~ s/\./\\./g;
    $probe =~ s/^(.*)$str1(.*)/$1$2/;	# remove it

    ($str1, $str2, $str3, $str4) = ($probe2 =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)/);

    if ($probe2 =~ /^0\d/ || $probe2 =~ /\.0\d/ ||
      $str1 > 255 || $str2 > 255 || $str3 > 255 || $str4 > 255) {
      print "forged_received_header: impossible IP \"$probe2\".\n" if $verbose;
      $header_analysis .=
	  "${bullet}\"Received:\" header has impossible IP \"$probe2\".\n\n";
      $result = 1;
      }
    }

  $result = 1 if !&parse_received_header($possibleName);
  # bogus Received: header won't have a for-clause with _your_ name in it.
  # for now, just see if it has the right domain name.
  # I wish a Received: header _always_ had a for-clause!
# too aggressive.  How can I make this right?
#    if ($possibleName =~ /for\s+<[^>]+>;/) {
#      $probe = $possibleName;
#      $probe =~ s/.*\sfor\s+<([^>]+)>;.*/$1/;
#      if (!&home_domain($probe)) {
#	print 
#	    "forged_received_header: bogus for-clause <$probe>\n"
#		if $verbose;
#	$header_analysis .= "${bullet}\"Received:\" header has bogus for-clause <$probe>.\n\n";
#	$result = 1;
#        }
#      }

  # bogus Received: header often has incorrect SMTP id
# Relies too much on the implementation of SMTP.
#    if ($possibleName =~ /with smtp id/i) {
#      local ($smtp_id, $smtp_char, $smtp_time, $smtp_hour);
#
#      $smtp_id = $possibleName;
#      $smtp_id =~ s/.*with smtp id (\w+).*/$1/i;
#      $smtp_char = $smtp_id;
#      $smtp_char =~ s/^(.).*$/$1/;
#      $smtp_time = $possibleName;
#      $smtp_time =~ s/.*with smtp id [^;]+;(.*)/$1/i; # entire end of header
#      $smtp_time =~ s/.*\s([0-2]\d:\d\d:\d\d).*/$1/;  # just want hh:mm:ss
#      $smtp_hour = $smtp_time;
#      $smtp_hour =~ s/^([0-2]\d):.*/$1/;	# just the hour
#      if ($smtp_chars{$smtp_char} ne $smtp_hour) {
#	if ($verbose) {
#	  print "forged_received_header: SMTP id \"$smtp_id\" does";
#	  print "    not match time \"$smtp_time\"\n";
#	  }
#	$header_analysis .=
#"${bullet}\"Received:\" header with SMTP id \"$smtp_id\" mismatches \"$smtp_time\".\n\n";
#	$result = 1;
#	}
#      }

  return $result;
  }

#-----------------------------------------------
# Find a line in hosts
sub findLine {
  local ($text) = @_;
  local ($result, $line);

  return "" if $hosts_file eq "";
  open(HOSTS, "<$hosts_file") || die "cannot open $hosts_file: $!";
  $result = "";
  while (<HOSTS>) {
    $line = $_;
    chop($line);
    next if $line =~ /^\s*#.*/;
    # how else do I specify \< and \>?  I miss vi's regex, for once.
    if ($line =~ /^$name$/i ||
        $line =~ /^$name\s+/i ||
        $line =~ /\s+$name$/i ||
        $line =~ /\s+$name\s+/i) {
      $result = $line;
      last;
      }
    next;
    }

  close HOSTS;
  return $result;
  }

#-----------------------------------------------
# search the hosts file.  addrToName looks here first
sub fakeAddrToName {
  local($name) = @_;
  local($result);

  $name =~ s/(\W)/\\$1/g;		# remove special characters
  $result = &findLine($name);

  $result =~ s/^\d+\.\d+\.\d+\.\d+\s+(\S+).*/$1/;
  return $result;
  }

#-----------------------------------------------
# search the hosts file.  nameToAddr looks here first
sub fakeNameToAddr {
  local($name) = @_;
  local($result);

  $name =~ s/(\W)/\\$1/g;		# remove special characters
  $result = &findLine($name);
  $result =~ s/^(\d+\.\d+\.\d+\.\d+)\s+.*/$1/;
  return $result;
  }

#-----------------------------------------------
# Cache the relationship between the given hostname and IP
sub log_mapping {
  local($name, $ip, $type) = @_;

  $ips_to_hosts{$ip} = $name if $ip ne "";
  $hosts_to_ips{$name} = $ip if $name ne "";
  $name = "?" if $name eq "";
  $ip = "?" if $ip eq "";
  print "  $ip -> $name\t# $type\n" if $verbose;
  }


#-----------------------------------------------
# Try to turn an address into a hostname (cover for gethostbyaddr)
sub addrToName {
  local ($text) = @_;
  local ($name, $aliases, $addrtype, $length, @addrs);
  local ($addr_int);
  local ($a, $b, $c, $d);

  $name = $ips_to_hosts{$text};
  return $name if defined($name) && $name ne "";

  $name = &fakeAddrToName($text);
  if ($name ne "") {
    $name = "" if $name eq "BOGUS";
    &log_mapping($name, $text, "hosts");
    return $name;
    }

  ($a, $b, $c, $d) = split(/\./, $text);
  $addr_int = pack("C4", $a, $b, $c, $d);

  ($name, $aliases, $addrtype, $length, @addrs) =
	gethostbyaddr($addr_int, &AF_INET);
  if (defined($name) && $name ne "") {
    &log_mapping($name, $text, "gethostbyaddr");
    return $name;
    }

  &log_mapping("", $text, "gethostbyaddr");
  return "";
  }

#-----------------------------------------------
# Try to turn a hostname into an address (cover for gethostbyname)
sub nameToAddr {
  local ($text) = @_;
  local ($name, $aliases, $addrtype, $length, @addrs);
  local ($a, $b, $c, $d);

  $name = $hosts_to_ips{$text};
  return $name if defined($name) && $name ne "";

  $name = &fakeNameToAddr($text);
  if (defined($name) && $name ne "") {
    $name = "" if $name eq "0.0.0.0";
    &log_mapping($text, $name, "hosts");
    return $name;
    }

  ($name, $aliases, $addrtype, $length, @addrs) = gethostbyname($text);
  if (defined($name) && $name ne "") {
    ($a, $b, $c, $d) = unpack('C4', $addrs[0]);
    $name = "$a.$b.$c.$d";
    &log_mapping($text, $name, "gethostbyname");
    return $name;
    }

  &log_mapping($text, "", "gethostbyname");
  return "";
  }

#-----------------------------------------------
# return 1 if this hostname resolves
sub real_host {
  local ($host) = @_;
  local ($junk);

  return 1 if $dont_resolve;
  $junk = &nameToAddr($host);
  return 0 if $junk eq "";
  return 1;
  }


#-----------------------------------------------
# return "", or best domain from the "Received: from" headers
# The algorithm is fairly involved.  Basically, start with the newest
# Received: header and process until the last one a bogus one is found.
sub do_received {
  local ($message_host) = @_;
  local ($message_site, $inet_addr);
  local ($result, $previous_peer);
  local ($probe, $probe2, $possibleName);
  local ($this, $i, $each);
  local (@all_headers);
  local ($peer_name, $helo_name, $by_name);
  local ($peer_site, $helo_site, $by_site);
  local ($junk2, $peer_is_exempt, $found_public_addr);

  $message_site = &find_site($message_host);

  # get "Received: " headers for later perusal.
  for ($i = 0; $i < @original; $i ++) {
    $line = $original[$i];
    last if length($line) == 1; # RFC-822: end of headers at first blank line
    next unless $line =~ /^Received:\s*/i;	# RFC-822 says case-independent
    $this = $line;
    chop($this);
    while ($i < @original) { # collect multi-line header
      $line = $original[$i + 1];
      last unless $line =~ /^[\s]+/;
      chop($line);
      $this .= $line;
      $i ++;
      }
    $this =~ s/^Received:\s*(.*)/$1/i;
    last if &forged_received_header($this); # don't _even_ put in the list
    push(@all_headers, $this);
    }

  $peer_name = $result = "";
  $found_public_addr = 0;

  # Analyze the headers
  NEXT_HEADER: for ($i = 0; $i < @all_headers; $i ++) {
    $possibleName = $all_headers[$i];

    $previous_peer = $peer_name if $peer_name ne "";
    ($peer_name, $inet_addr) = &received_peer_name($possibleName);
    $helo_name = &helo_name($possibleName);
    $by_name = &by_name($possibleName);
    if ($verbose) {
      print "received:  \"$peer_name\"";
      print " inet: \"$inet_addr\"" if defined($inet_addr) && $inet_addr ne "";
      print " by: \"$by_name\"" if $by_name ne "";
      print " helo: \"$helo_name\"" if $helo_name ne "";
      print "\n";
      }
    if (defined($inet_addr) && $inet_addr ne "") {
      local($is_private) = &is_private_inet_addr($inet_addr);

      if (!$is_private) {
	# we're in the part of the received: path that was on the Internet
        $found_public_addr = 1;
        }
      elsif ($found_public_addr) {
	# we've fallen into the private intranet on the other end.  Stop.
	print "  do_received: found sender's intranet $inet_addr\n"
	  if $verbose;
	last NEXT_HEADER;
	}
      else {
	# we're in the private intranet at the receiving end.  Skip.
	print "  do_received: found receiver's intranet $inet_addr\"\n"
	  if $verbose;
	next NEXT_HEADER;
	}
      }
    $peer_site = &find_site($peer_name);
    &good_hostname($peer_name, 1);	# adds complaint if can't confirm
    $peer_is_exempt = &is_exempt($peer_name);
    $peer_site = "" if $peer_is_exempt;

    $helo_site = &find_site($helo_name);
    # &good_hostname($helo_name, 1);	# adds complaint if can't confirm

    $by_site = &find_site($by_name);
    &good_hostname($by_name, 1);	# adds complaint if can't confirm

    # analyze inet_addr, upgrade notion of peer_name
    if (defined($inet_addr) && $inet_addr ne "" && !$dont_resolve) {
      $probe2 = &addrToName($inet_addr);
      if ($peer_name ne "" && $probe2 eq "") {
	$header_analysis .=
	    "${bullet}Unable to confirm $peer_name is $inet_addr.\n\n";
	$peer_name = $previous_peer if $peer_name eq "";
	}
      elsif ($peer_name ne "" && $probe2 ne "" && !&home_domain($peer_name)) {
	$junk2 = &find_site($probe2);
	if (!$peer_is_exempt && $peer_site ne $junk2) {
	  $header_analysis .= "${bullet}\"Received:\" header says that peer is \"$peer_name\",\n";
	  $header_analysis .= "but address $inet_addr resolves to $probe2.\n\n";
	  $result = $probe2;
	  last NEXT_HEADER;
	  }
	}
      if ($probe2 ne "") {
	if ($peer_name eq "") {
	  $header_analysis .= 
	      "${bullet}\"Received:\" header has empty peer name, but\n";
	  $header_analysis .= "address $inet_addr resolves to $probe2.\n\n";
	  }
	$peer_name = $probe2;
	}
      } # $inet_addr ne ""

    # ignore this header if it comes through/from/by a exempt domain
    if ($peer_is_exempt) {
      $result = $by_name if $by_name ne "";
      last NEXT_HEADER;
      }
    $peer_site = &find_site($peer_name);

    # Look at helo_name.  Don't trust it very far, really.
    if ($helo_name ne "" && $helo_site eq "") {
      $header_analysis .=
	  "${bullet}HELO name \"$helo_name\" is not a valid host name.\n\n";
      print "  do_received: queer helo_name $helo_name\"\n" if $verbose;
      }
    elsif (&is_exempt($helo_name)) {
      $result = $peer_site if $peer_site ne "";  # end of the road
      last NEXT_HEADER;
      }
    elsif ($helo_name ne "" && $helo_name ne $peer_name) { # analyze helo_name
      # Does the helo_name matches the peer_name?
      if ($peer_site ne "" && $helo_site ne $peer_site) {
	$header_analysis .=
	  "${bullet}\"Received:\" header's HELO name \"$helo_name\" significantly\n";
	$header_analysis .= "differs from peer_name \"$peer_name\".\n\n";
	print "  do_received: helo $helo_name != peer $peer_name\n" if $verbose;
        $result = $peer_site;  # end of the road
	last NEXT_HEADER;
	}
      } # analyze helo_name

    # Attempt to match the name of this host with the by_name of the next header
    if ($helo_name ne "" &&
	$i != $#all_headers) { # not oldest header, verification possible
      # Attempt to match the helo_name with the by_name of the next header
      $probe = &by_name($all_headers[$i + 1]);
      $probe2 = &find_site($probe);
      if ($probe2 eq "") {
	print
	    "adcomplain: unable to confirm $helo_name against origination.\n";
	}
      elsif ($helo_site ne "" && $probe2 ne $helo_site) {
	$header_analysis .=
	   "${bullet}HELO name \"$helo_name\" does not match prior header's\n";
	$header_analysis .= "by-name \"$probe\"\n\n";
	print
	    "do_received: helo $helo_name does not match next by_name $probe\n"
	    if $verbose;
	# HELO name is a little queer, so tolerate this, with a comment.
	}
      elsif ($peer_site ne "" && $probe2 ne $peer_site) {
	$header_analysis .=
	   "${bullet}Peer name \"$peer_name\" does not match prior header's\n";
	$header_analysis .= "by-name name \"$probe\"\n\n";
	print
	    "do_received: peer $peer_name does not match by_name $probe\n"
	    if $verbose;
	$result = $peer_site;
	last NEXT_HEADER;	# This is serious!
	}
      } # not oldest header

    # Check for spam insertion that created a Message-Id
    if ($result ne "" && $result eq $message_site &&
	$peer_site ne "" && $peer_site ne $message_site) {
      # No valid message has a Message-Id created on it mid-stream.  If we
      # get here, we have the spam insertion.  Let the victimized postmaster
      # be held accountable.
      $header_analysis .=
	  "${bullet}Message-Id site \"$message_site\" is not at the start"
		. " of the chain of Received: headers.\n\n";
      print 
	"do_received: Message-Id site \"$message_site\" found.\n" if $verbose;
      $result = $peer_site if $peer_site ne "";
      last NEXT_HEADER;
      }

    # $peer_name is definitely the way to go:
    if ($peer_name ne "") {
      $result = $peer_site;
      next NEXT_HEADER;
      }

    # no reverse address.  Could be bogus, DNS transient oddness, or
    # simply that we are behind a firewall.

    # Plan B: use the by-name
    last NEXT_HEADER if &is_exempt($by_name);
    if ($by_name ne "") {
      $result = $by_name;
      next NEXT_HEADER;
      }

    # Go for the helo name (yuccch)
    next NEXT_HEADER if $helo_name eq "";
    last NEXT_HEADER if &is_exempt($helo_name);

    print "do_received: relying on helo_name \"$helo_name\"\n" if $verbose;
    $result = $helo_name;
    } # NEXT_HEADER

  return "" if $result eq "";
  $result = "" if &home_domain($result);
  if ($result ne "") {
    &register_host("Received:", $result);
    print "do_received: result is \"$result\"\n";
    }

  if ($result ne "" && $message_host ne "") {
    $probe = &find_site($result);
    if ($message_site ne $probe) {
      $header_analysis .=
	  "${bullet}Site in \"Message-Id:\" \"$message_site\" does not match\n";
      $header_analysis .=
	  "\"Received:\" origin \"$result\".\n\n";
      print "  do_received: Message-Id site $message_site != result $result\n"
	  if $verbose;
      }
    }

  return $result;
  }

#-----------------------------------------------
# The following headers are scanned, in order, to determine the poster:
#   NNTP-Posting-User:
#   Return-Path:
#   Reply-To:
#   From:
#
# A poster's address be of the form user@domain, where domain is
# a legal domain name.  The domain is rejected if it matches our domain.
#
# If the address is of form "user,id <xxx@site>", the
# message will be addressed to xxx@site.
# If the address is of form "Name <address>", set to "address".
# If the address is of form "(address)", set to "address".
# If the address is of form "address(Name)", set to "address".
# Remove extra words, in case header is of form "address (Name)"

sub find_poster {
  local ($this, $junk, $junkhost, $result);
  local (@headers, @search_patterns);

  @headers = ("NNTP-Posting-User:", "Return-Path:", "Reply-To:", "From:");
  @search_patterns = ( '.*NNTP-Posting-User: ',
      '^Return-Path:', '^Reply-To:', '^From:');
  $result = "";
  for (@search_patterns) {
    $this = $headers[0];
    shift @headers;
    $junk = &extract_header($_); 
    next if $junk eq "";

    # Validate the name
    $junk =~ s/[^<]*<([^>]*)>.*/$1/;		# remove angle brackets
    $junk =~ s/([^(\s]*)\s*\([^)]*\)/$1/;	# remove parenthesized name
    ($junkhost = $junk) =~ s/.*@(.*)/$1/;
    $junkhost =~ s/([^\s]*) *\(.*\)/$1/;	# remove proper name
    $junkhost = &good_hostname($junkhost, 0);
    next if $junkhost eq "";
    $result = $junk if $result eq "";	# take first available
    &register_host($this, $junkhost);
    print "find_poster: found '$this' host $junk\n" if $verbose;
    }
  if ($result !~ /.*,.*/) {
    # remove angle brackets from poster's name
    $result =~ s/.*<(.*)>.*/$1/;
    }
  if ($result eq "") {
    print "\nadcomplain: WARNING: cannot determine poster's address.\n\n";
    $result = "";
    }
  else {
    print "find_poster: poster is '$result'\n" if $verbose;
    }
  return $result;
  }

#-----------------------------------------------
# Analyze the "Path:" header, return best possible host
# Basically, we're looking for the oldest (believable) host in the path.
# I used to process the path from left-to-right, with the idea that I
# could stop before the first unconfirmable host.  In practice, it seems
# to be better to just go from the right and stop with the first believable
# one (though I still have reservations about that).
sub do_path {
  local ($path, $result, $chunk, $junk);
  local (@chunks);

  $path = &extract_header("^Path:");
  return "" if $path eq "";
  @chunks = reverse(split(/!/, $path));

  foreach $chunk (@chunks) {
    $chunk = &addrToName($chunk) if &is_inet_addr($chunk);
    $chunk = &good_hostname($chunk, 1);
    # $chunk = &good_hostname($chunk, 0);	# don't require host to exist.
    next if $chunk eq "";
    next if &is_exempt($chunk);
    $result = $chunk;
    last;
    }

  if ($result ne "") {
    print "do_path: Path origin is $result\n" if $verbose;
    &register_host("Path:", $result);
    return $result;
    }
  return "";
  }

#-----------------------------------------------
# Examine and return a hostname based on given header
sub try_host {
  local($pat, $name) = @_;
  local($junk, $junk2);

  $junk = &extract_header($pat);
  return "" if $junk eq "";
  print "try_host: \'$name\' is $junk\n" if $verbose;
  if (&is_inet_addr($junk) && !$dont_resolve) {
    $junk2 = &addrToName($junk);
    $junk = $junk2;
    }
  else {
    $junk = &good_hostname($junk, 0);
    }
  return "" if $junk eq "";
  return "" if &home_domain($junk);
  &register_host($name, $junk);
  return $junk;
}

#-----------------------------------------------
# I've seen these headers and I want to check for them:
# X-Authentication-Warning: quick.t-1net.com: b142.ecom.net [207.13.225.142] didn't use HELO protocol
#X-Authentication-Warning: communique-tech.co.uk: 
#	Host 1Cust40.max15.los-angeles.ca.ms.uu.net [153.34.77.168] claimed 
#	to be hotmail.com
# X-Authentication-Warning: gatekeeper.smltd.com: 
#	mail set sender to <lori@6t9.com> using -f
# X-Authentication-Warning: ns.internetmedia.net: 
#	weginc owned process doing -bs
sub do_auth_warning {
  local ($junk, $junk_site, $name_site);
  local ($name, $inet_addr, $result);

  $junk = &extract_header("X-Authentication-Warning:");
  return "" if $junk eq "";

  $inet_addr = "";
  if ($junk =~ /didn't use HELO protocol/) {
    $junk =~ s/^[^:]+: (.*) didn't use HELO protocol/$1/i;
    $name = $inet_addr = $junk;

    $name =~ s/^\s*([\w\.-]+)\s*.*/$1/;
    $inet_addr =~ s/^.*\[(.*)\].*/$1/;	# remove bracketed name
    $name =~ s/^(.*)\[.*\].*/$1/;	# remove bracketed name
    }
  elsif ($junk =~ /claimed to be/) {
#	Host 1Cust40.max15.los-angeles.ca.ms.uu.net [153.34.77.168] claimed 
# or:
#	oncidium: Host x.y..net claimed to be usinet cziegle

    ($name = $junk) =~ s/.*Host\s+(\S+).*/$1/;

    ($inet_addr = $junk) =~ s/.*\[([^]]*)\].*/$1/
	if $junk =~ /\[\d+\.\d+\.\d+\.\d+\]/;
    }
  elsif ($junk =~ / set sender to /) {
    # nothing else warranted
    $name = "";
    }
  elsif ($junk =~ / owned process doing /) {
    # is this useful?  For now, do nothing.
    $name = "";
    }
  else {
    print "adcomplain: new X-Authentication-Warning header\n";
    print "  Please send this test case to the adcomplain authors.\n";
    return "";
    }

  $result = $name;
  if ($inet_addr ne "" && !$dont_resolve) {
    $junk = &addrToName($inet_addr);
    if ($name ne "" && $junk eq "") {
      $header_analysis .= "${bullet}Unable to confirm $name is $inet_addr.\n\n";
      }
    elsif ($name ne "" && !&home_domain($name)) {
      $result = $junk;
      $junk_site = &find_site($junk);
      $name_site = &find_site($name);
      if ($name_site ne $junk_site) {
	$header_analysis .= "${bullet}\"X-Authentication-Warning:\" header says that peer is \"$name\",\n";
	$header_analysis .= "but address $inet_addr resolves to $junk.\n\n";
	}
      }
    } # $inet_addr ne ""
  print "do_auth_warning: found \"$result\"\n" if $verbose;
  &register_host("X-Authentication-Warning:", $result) if $result ne "";
  return $result;
  }


#-----------------------------------------------
# The following order of preference is used to determine the originating host:
#   the host in the "NNTP-Posting-Host:" header;
#   the host in the "Path:" header;
#   the host in the "Received:" headers;
#   the host in the "Message-Id:" header;
#   the host in the "Sender:" header; else
#   the host of the poster
#
# In any event, recognize and reduce hostnames of the form
#   <id@host>
#   (id@host)
#   host(inet_addr)  [reduce to "host"]
# Make sure to remove extra words, i.e., "address (Name)"
# A hostname must have valid syntax and not match the current domain.

sub find_host {
  local ($message_host, $junk, $this, $result);

  $postmaster = "";
  $complain_to = "";
  $result = "";

  # NNTP-Posting-Host: is first choice.
  $junk = &try_host(".*NNTP-Posting-Host:", "NNTP-Posting-Host:");
  $junk = "" if &home_domain($junk);
  $result = $junk if $result eq "" && $junk ne "";

  $junk = &do_path;	# Path: header is the next most reliable.
  $junk = "" if &home_domain($junk);
  $result = $junk if $result eq "" && $junk ne "";

  # This is used in do_received, so figure it out now.
  $message_host = &try_host("^Message-Id:", "Message-Id:");

  $junk = &do_auth_warning();
  $junk = "" if &home_domain($junk);
  $result = $junk if $result eq "" && $junk ne "";

  $junk = &do_received($message_host);	# ...then, try Received:
  $junk = "" if &home_domain($junk);
  $result = $junk if $result eq "" && $junk ne "";
  print "adcomplain: WARNING: cannot use \"Received:\" headers.\n"
      if $junk eq "" && $mailmode;

  # Now curry any remaining possibilities....
  $result = $message_host if $result eq "" && $message_host ne "";

  $junk = &try_host("^Sender:", "Sender:");
  $result = $junk if $result eq "" && $junk ne "";

  if ($poster ne "") {
    print "find_host: trying poster \"$poster\"...\n" if $verbose;
    $junk = &good_hostname($poster, 0);
    &register_host("Poster:", $junk) if $junk ne "";
    $junk = "" if &home_domain($junk);
    $result = $junk if $result eq "" && $junk ne "";
    }

  if ($result eq "") {
    print "\nadcomplain: WARNING: no valid host name was found\n";
    }
  else {
    print "find_host: host is '$result'\n" if $verbose;
    }
  return $result;
  }

#-----------------------------------------------
# Revise the site name based on some exceptions and known aliases.
sub revise_site {
  local ($site) = @_;
  local ($redirect, $junk);

  $redirect = "";
  ($junk = $site) =~ s/(\W)/\\$1/g;	# remove special characters
  for (keys(%rematch_aliases)) {
    if ($_ =~ /$junk/) {
      $redirect = $_;
      last;
      }
    }
  if ($redirect ne "") {
    $junk = $rematch_aliases{$redirect};
    print "revise_site: $site redirected: '$junk'\n" if $verbose;
    $redirect = &extract_header($junk);
    }
  if ($redirect ne "") {
    $site = &find_site($redirect);
    print "revise_site:  '$redirect' is '$site'\n" if $site ne "" && $verbose;
    }
  return $site;
  }

#-----------------------------------------------
# Get all of the sites feasible from the Complain-To headers
sub do_complain_to {
  local ($junk, $junk2);
  local (@list, $i, $j, $each);

  $complain_to = "";
  for ("Complain-To", "Report-Abuse-To", "X-Complaints-To"
	) { # alternatives
    $junk = &extract_header("^.*$_:");
    next if  $junk eq "";
    print "do_complain_to: $_: is $junk\n" if $verbose;
    @list = split(/[\s,]+/, $junk);
    for ($i = 0; $i < @list; $i ++) { # process list
      $junk2 = &good_hostname($list[$i], 0);
      if ($junk2 ne "") { # good hostname
	if ($i == 0 && $#list == 0) {
	  &register_host("$_:", $junk2);
	  }
	else {
	  $j = $i + 1;
	  &register_host("$_-$j:", $junk2);
	  }
	$complain_to = $junk if $complain_to eq "";
	} # good hostname
      } # process list
    } # alternatives

  if ($complain_to eq "") {
    if ($site eq "") {
      print "\nadcomplain: WARNING: no valid complain_to address was found\n";
      }
    else {
      print "do_complain_to: setting complain_to to site name.\n" if $verbose;
      $complain_to = "$site\@abuse.net";
      }
    }
  else {
    if ($site eq "") {
      @list = split(/[\s,]+/, $complain_to);
      $site = &good_hostname($list[0], 0);
      print "do_complain_to: setting site to $site.\n" if $verbose;
      }
    }

  $complain_to =~ s/,/ /g;     # turn all commas to spaces
  $complain_to =~ s/\s+/, /g;  # and then back to commas
  print "do_complain_to: complain_to is '$complain_to'\n"
      if $complain_to ne "" && $verbose;
  }

#-----------------------------------------------
# Top-level routine that reads and extracts the headers from the message
sub parse_headers {
  local ($this);

  $subject = &extract_header("^Subject:");
  if ($subject eq "") {
    print "\nadcomplain: WARNING: subject not found\n\n";
    }
  else {
    print "subject is '$subject'\n" if $verbose;
    }

  if ($mailmode) {
    # mail mode forced
    if ($ARGV[0] ne "") {
      print 
	  "\nadcomplain: ERROR choose at most one of -m and a newsgroup name\n";
      exit 1;
      }
    $newsgroup = "";
    print "This is a mail message.\n" if $verbose;
    }
  else {
    $this = &extract_header("^Path:");
    $newsgroup = &extract_header("^Newsgroups:");
    if (defined($ARGV[0]) && $ARGV[0] ne "") {
      $newsgroup = $ARGV[0];
      print "newsgroup is from command line argument.\n" if $verbose;
      }
    if ($newsgroup eq "") {
      $mailmode = 1;
      print "Inferring that this is a mail message.\n" if $verbose;
      }
    else {
      $newsgroup =~ s/,/, /g;
      if ($newsgroup =~ /^[^,]+,[^,]+$/) {
	$newsgroup =~ s/(.*), ([^,]*)$/$1 or $2/g;
	}
      else {
	$newsgroup =~ s/(.*), ([^,]*)$/$1, or $2/g;
	}
      print "newsgroup is '$newsgroup'\n" if $verbose;
      }
    }

  $poster = &find_poster;
  $host = &find_host;

  $site = &find_site($host);
  if ($site ne "") {
    print "site is '$site'\n" if $verbose;

    $site = &revise_site($site);
    $postmaster = "postmaster\@$site";
    print "postmaster is '$postmaster'\n" if $verbose;
    }

  &do_complain_to;

  $site = "INSERT_SITE_NAME_HERE" if $site eq "";
} # parse_headers

#-----------------------------------------------
# return 1 if site is in list of exceptions
sub is_exception_site {
  local($site) = @_;

  #for (@site_exceptions) { return 1 if $site =~ /$_$/; }
  #return 0;

  local ($u, $l, $i, $pat);

  return 0 if $site eq "";
  $site =~ y/A-Z/a-z/;		# canonicalize to lower case
  $l = 0;
  $u = $#site_exceptions;
  for (;;) {
    return 0 if $u < $l;
    $i = int(($l + $u) / 2);

    # End if a pattern match is successful
    $pat = $site_exceptions[$i];
    $pat =~ s/(\W)/\\$1/g;		# remove special characters
    $pat = "$pat\$";
    if ($site =~ /$pat/i) {
      print "found exception site \"$site\".\n" if $verbose;
      return 1;
      }

    if ($site lt $site_exceptions[$i]) {
      $u = $i - 1;
      }
    elsif ($site gt $site_exceptions[$i]) {
      $l = $i + 1;
      }
    else {
      die "internal error in is_exception_site(\"$site\")";
      }
    }
  }

#-----------------------------------------------
# Return "" if the given address has a valid suffix, else the invalid
# suffix.
sub is_valid_domain {
  local($host) = @_;
  local($junk);

  ($junk = $host) =~ s/.*\.([^.\s]*)\s*/$1/;	# get that tail
  # for (@valid_domains) { return "" if $junk eq $_; }
  # return $junk;

  local ($u, $l, $i, $pat);

  return "." if $junk eq "";	# empty suffix...
  $junk =~ y/A-Z/a-z/;		# canonicalize to lower case
  $l = 0;
  $u = $#valid_domains;
  for (;;) {
    return ".$junk" if $u < $l;
    $i = int(($l + $u) / 2);

    # End if a pattern match is successful
    $pat = $valid_domains[$i];
    $pat =~ y/A-Z/a-z/;		# canonicalize to lower case
    if ($junk eq $pat) {
      # print "found valid domain \"$junk\".\n" if $verbose;
      return "";
      }

    if ($junk lt $pat) {
      $u = $i - 1;
      }
    elsif ($junk gt $pat) {
      $l = $i + 1;
      }
    else {
      die "internal error in is_valid_domain(\"$host\")";
      }
    }
  }

#-----------------------------------------------
# returns 0 or else a cleaned up hostname
sub good_hostname {
  local ($host, $must_be_real) = @_;
  local ($junk, $each);

  # clean up the hostname
  $host =~ s/.*<(.*)>.*/$1/;	# remove angle brackets, if any
  $host =~ s/.*\((.*)\).*/$1/;	# remove parens, if any
  $host =~ s/\(.*\)//;		# remove parenthesized text
  $host =~ s/.*@(.*)/$1/;
  $host =~ y/A-Z/a-z/;		# lowercase

  # print "good_hostname: $host $must_be_real\n";
  # return "" if !($host =~ /^[A-Z]/i);  # hostname must begin with a letter
  return "" unless $host =~ /.*\..*/;    # hostname must have at least one dot
  return "" if &is_inet_addr($host);

  # check for illegal characters
  for (
	# from rfc822
	"\\(", "\\)", "<", ">", "@", ",", ";", ":", "\\\\", "\\\"",
	"\\[", "\\]", # ".",
	# questionable ones added by Jason
	"#", "\\^", "\\&", "\\*", "=", "\\+", "\\|", "\\?", "`", "~", "\\/") {
    if ($host =~ /$_/) {
      print "good_hostname: \"$host\" has illegal char \"$_\".\n" if $verbose;
      return "";
      }
    }

  # Look at the irregular site names first.
  return $host if &is_exception_site($host);

  $junk = &is_valid_domain($host);
  if ($junk ne "") {
    print "good_hostname: \"$host\" has invalid suffix \"$junk\"\n" if $verbose;
    return "";
    }

  if ($must_be_real && !&home_domain($host)) {
    $host = "" if !&real_host($host);
    }

  return $host;
  }

#-----------------------------------------------
# Reduce a hostname to a site; i.e.:
#   If last field of $host >= 3 characters long (e.g., "com", "edu"),
#     set $site to last two fields (e.g., "company.com" or "college.edu")
#     unless three field version found in exceptions list,
#   otherwise, set $site to last three fields (e.g., "canadian.site.ca")
#     unless two field version found in exceptions list.
sub find_site {
  local ($host) = @_;
  local ($site, $site2, $site3, $junk);

  $host =~ s/<(.*)>/$1/;		# remove angle brackets
  $host =~ s/[^@]*@(\S*)\s*/$1/;	# extract domain-name part

  ($site2 = $host) =~ s/.*\.(.*\..*)/$1/;
  ($site3 = $host) =~ s/.*\.(.*\..*\..*)/$1/;
  ($junk = $host) =~ s/.*\.(.*)/$1/;
  if (length($junk) >= 3) {
    ($junk = $site3) =~ s/(\W)/\\$1/g;	# remove special characters

    if (grep(/^$junk$/, @site_exceptions) != 0) {
      $site = $site3;
      }
    else {
      $site = $site2;
      }
    }
  else {
    ($junk = $site2) =~ s/(\W)/\\$1/g;	# remove special characters

    if (grep(/^$junk$/, @site_exceptions) != 0) {
      $site = $site2;
      }
    else {
      $site = $site3;
      }
    }
  $site =~ y/A-Z/a-z/;		# lowercase
  return $site;
  }

#-----------------------------------------------
# Add the given site to the list of sites
sub register_host {
  local ($key, $value) = @_;

  $available_hosts{$key} = &find_site($value);
  }

#-----------------------------------------------
# Analyze the list of available hosts.  Generate diagnostic if 
# headers are inconsistent.
sub check_hosts {
  local ($firstkey, $secondkey, $firstval, $secondval);
  local (@order) = ("Path:", "Received:", # "NNTP-Posting-Host:",
	# "Message-Id:", "Sender:", "NNTP-Posting-User:",
	# "Return-Path", "Reply-To:", "From:"
	);

  foreach $firstkey (@order) {
    $firstval = $available_hosts{$firstkey};
    next if !defined($firstval) || $firstval eq "";
    foreach $secondkey (@order) {
      $secondval = $available_hosts{$secondkey};
      next if !defined($secondval) || $secondval eq "";
      if ($firstval ne $secondval) {
	$header_analysis .= "${bullet}Site implied by \"$firstkey\" header ($firstval)";
	$header_analysis .= " is not consistent with site implied by";
	$header_analysis .= " \"$secondkey\" header ($secondval).\n\n";
	return;
	}
      }
    }
  }

#-----------------------------------------------
# Return 1 if the argument refers to the home domain
sub home_domain {
  local ($probe) = @_;
  local ($each);

  for (@mydomains) {
    return 1 if $probe =~ /$_$/i;
    }
  return 0;
  }

#-----------------------------------------------
# perl code by Denis N. Antonioli <antonioli@ifi.unizh.ch>
# original C code by David Laur, Rainsound, 9/96,
# posted in comp.sys.sgi.apps <3246E9D5.41C6@rainsound.com>

# original comments:
# attempt to construct a fully-qualified hostname
# not likely to work on multi-homed or multi-addressed machines
sub fqdn_name {
  local($in) = @_;
  local($result) = $in;
  local($name, $aliases, $addrtype, $length, @addrs);
  local($nd, $cd);

  # Jason's original hack:  a reverse-DNS lookup often yields
  # a better (FQDN) name.
  ($name, $aliases, $addrtype, $length, @addrs) = gethostbyname($in);
  $result = $name if defined($name) && $name ne "";

  local($nd) = ($in =~ tr/././);
  local($cd) = ($name =~ tr/././);
  if ($cd > $nd) { # authorized name is longer; take it.
    $nd = $cd;
    $result = $name;
    }
  # Pick the alias with the _most_ dots
  local($alias);
  foreach $alias (split(' ', $aliases)) {
    $cd = ($alias =~ tr/././);
    if ($cd > $nd) {
      $result = $alias;
      $nd = $cd;
      }
    }

  # If our name has two or more dots, we're done!
  return $result if $nd >= 2;

  # Need to add the domain name to the host name.
  # ADCOMPLAIN_MDOMAIN env variable?
  local($domain) = $ENV{'ADCOMPLAIN_MDOMAIN'} || '';
  local($etc);

  if ($os_kind eq "unix") {
    $etc = "/etc";
    }
  elsif ($os_kind eq "os2") {
    $etc = $ENV{"ETC"};
    }
  elsif ($os_kind eq "winnt" || $os_kind eq "win32") {
    $etc = "";	# I might be able to do better here....
    }
  else {
    die "does $os_kind have an etc directory?";
    }

  # Try /etc/resolv.conf.  This will work on a surprising number of
  # machines!
  if ($domain eq '' && $etc ne "") {
    if (open(FD, "$etc/resolv.conf")) {
      while (<FD>) {
	if (/^domain\s+(\S+)\s*$/) {
	  $domain = $1;
	  last;
	  }
	# N.B. -- it is against BIND rules to have both 'domain' and 'search'
	# directives.
	if (/^search\s+(\S+)\s*$/) {
	  $domain = $1;
	  last;
	  }
	}
      close(FD);
      }
    }

  # Try /etc/defaultdomain.  This is much more questionable; this returns the
  # name of the NIS domain, which may or may not have anything to do with the
  # mail domain.  On the other hand, if we get this far, we're pretty stuck,
  # so we have nothing to lose....
  if ($domain eq '' && $etc ne "") {
    if (open(FD, "$etc/defaultdomain")) {
      $domain = <FD>;
      close(FD);
      }
    }
  $domain =~ s/^\s*(\S+)\s*/$1/g unless $domain eq '';
  $result .= '.' . $domain unless $domain eq '';
  return $result;
  }

#-----------------------------------------------
# Initialize the constants and lists.  Also sets $os_kind, because it's
# needed quite early.
sub get_constants_and_environment {
  local ($dollar_control_O);

  # control characters don't survive shar very well!
  $dollar_control_O = "\$dollar_control_O = \$\017;";
  eval $dollar_control_O;	# will be empty in perl4

  # Start by figuring out which OS we're on.  Fortunately, we don't
  # need to distinguish different Unixes (that would be the problem if
  # we used $^O, which is only in perl5 anyway).
  if (defined($ENV{"OS"}) && $ENV{"OS"} eq "Windows_NT") {
    # Always set by the operating system
    $os_kind = "winnt";
    }
  elsif (defined($ENV{"OS2_SHELL"}) && $ENV{"OS2_SHELL"} ne "") {
    # Always set by the operating system
    $os_kind = "os2";
    }
  elsif (defined($dollar_control_O) && $dollar_control_O eq "MSWin32") {
    # Windows 95.  Same perl as above, but %OS% will not be set.
    $os_kind = "win32";
    }
  elsif (-x "/bin/uname") { # SVr4
    $os_kind = "unix";
    }
  elsif (-x "/usr/bin/uname") { # BSD
    $os_kind = "unix";
    }
  else {
    die "what is your os?";
    }

  # Fix AF_INET and SOCK_STREAM
  if ($os_kind eq "unix") {
    # an apology here: the Unix perl4's at gemstone.com were installed _many_
    # years ago by someone who _really_ didn't know what he was doing.
    # The host-specific libraries just aren't, and reinstalling
    # _all_ of the perls for _all_ of the architectures is not worth my time.

    # So, what we'll do is make sure the values are properly set for my
    # Greatest Hits list of architectures.

    $junk = -x "/bin/uname" ? `/bin/uname -rs` : `/usr/bin/uname -rs`;

    if ($junk =~ /^SunOS 5.*/		# Solaris
       || $junk =~ /^IRIX*/i		# IRIX
	) {
      # solaris and irix just _had_ to be different
      eval 'sub AF_INET { return 2; }';
      eval 'sub SOCK_STREAM { return 2; }';
      }
    elsif ($junk =~ /^HP-UX.*/i  	# HP-UX
	|| $junk =~ /^AIX.*/i 		# AIX
	|| $junk =~ /^SunOS 4.*/i 	# SunOS
        || $junk =~ /^OSF1.*/i 		# OSF1
	|| $junk =~ /^Linux*/i          # Linux
	) {
      # the rest of the world, it seems
      eval 'sub AF_INET { return 2; }';
      eval 'sub SOCK_STREAM { return 1; }';
      }
    else {
      # Sorry, can't guess.  Your perl better be properly installed.
      require "sys/socket.ph";
      }
    }
  elsif ($os_kind eq "winnt" || $os_kind eq "win32" || $os_kind eq "os2") {
    # from winsock.h
    eval 'sub AF_INET { return 2; }';
    eval 'sub SOCK_STREAM { return 1; }';
    }
  else {
    die "cannot set AF_INET and SOCK_STREAM properly";
    }

  @monthNames = (
	"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
	"Oct", "Nov", "Dec");
  @wdayNames = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");

  # Now that I've discovered IEEE 1003.1, I just want to cry.  But here's
  # a modest attempt at time zones.  Complain away if you think it's wrong....
  %timezones = (
    "-1200", "IDLW, M",		# International Date Line West
    "-1100", "NT, SST, L",	# Nome, Samoa
    "-1000", "HST, AHST, CAT, HAST, K", # Hawaii Standard
    "-0900", "YST, HDT, AKADT, HADT, I", # Yukon Standard
    "-0800", "AKDT, PST, YDT, H", # Pacific Standard, Yukon Daylight
    "-0700", "MST, PDT, G",	# Mountain Standard, Pacific Daylight
    "-0600", "CST, MDT, F", 	# Central Standard, Mountain Daylight
    "-0500", "EST, CDT, AST, E",# Eastern Standard, Central Daylight,
				# Brazil/Acre
    "-0400", "AST, EDT, WST, ADT, CST, D",
				# Atlantic Standard, Eastern Daylight,
				# Brazil Western, Brazil/Acre, Chile Standard
    "-0330", "NST, CDT",	# Newfoundland Standard, Chile Daylight
    "-0300", "ADT, EST, WDT, C",# Atlantic Daylight, Brazil
    "-0230", "NDT",		# Newfoundland Daylight
    "-0200", "EDT, FST, AT, B",	# Brazil Eastern Daylight, Brazil/deNoronha,
				# Azores
    "-0100", "FDT, WAT, A",	# Brazil/deNoronha, West Africa
    "0000", "GMT, UTC, WET, UT, Z", # Greenwich Mean,
				# Universal Time, Western Europe
    "0100", "BST, WET DST, MET, CET, FWT, MEWT, SWT, N", 
				# Western Daylight, Middle Europe
    "0200", "EET, MET DST, METDST, MEST, MESZ, SST, FST, O, SAT, CEST, IST",
				# Middle Europe Daylight
				# Swedish Summer Time, French Summer Time,
				# South African Time, Israel
    "0300", "IDT, EET DST, MSK, BT, P", # Israel Daylight, Turkey, Moscow
    "0330", "IT",		# Iran?
    "0400", "MSD, ZP4, Q",
    "0500", "ZP5, R",		# USSR Zone 4
    "0530", "IST",		# India Standard Time
    "0600", "ZP6, S",		# USSR Zone 5
    "0630", "NST",		# North Sumatra?
    "0700", "WAST, T",		# Western Austrailia
    "0730", "JT",		# Java?
    "0800", "CST, SST, SGT, HKT, WST, CCT, WADT, U, MYT", # China & Taiwan,
				# Singapore Standard, Hong Kong, West Australia,
				# Maylasia
    "0900", "KST, CDT, JST, V",	# Korea, China, Japan
    "0930", "CST, CAST",	# North Australia, South Australia
    "1000", "KDT, EAST, EST, GST, W",
				# Korea,  Eastern Australia, Guam
    "1100", "EDT, EADT, X",
    "1200", "NZST, IDLE, NZT, Y",# New Zealand, International Date Line East
    "1300", "NZDT",		# New Zealand Daylight Time?
    );

  # Valid country domains
  @valid_domains = (
      # Countries
      "uk",  # Non-standard but frequently used.
      "su",  # Non-standard but frequently used.
      "af", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw",
      "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm",
      "bt", "bo", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh",
      "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km",
      "cg", "ck", "cr", "ci", "hr", "cu", "cy", "cz", "dk", "dj", "dm", "do",
      "tp", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi",
      "fr", "fx", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr",
      "gl", "gd", "gp", "gu", "gt", "gn", "gw", "gy", "ht", "hm", "hn", "hk",
      "hu", "is", "in", "id", "ir", "iq", "ie", "il", "it", "jm", "jp", "jo",
      "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr",
      "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt",
      "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "ms", "ma",
      "mz", "mm", "na", "nr", "np", "nl", "an", "nc", "nz", "ni", "ne", "ng",
      "nu", "nf", "mp", "no", "om", "pk", "pw", "pa", "pg", "py", "pe", "ph",
      "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "kn", "lc", "vc",
      "ws", "sm", "st", "sa", "sn", "sc", "sl", "sg", "sk", "si", "sb", "so",
      "za", "gs", "es", "lk", "sh", "pm", "sd", "sr", "sj", "sz", "se", "ch",
      "sy", "tw", "tj", "tz", "th", "tg", "tk", "to", "tt", "tn", "tr", "tm",
      "tc", "tv", "ug", "ua", "ae", "gb", "us", "um", "uy", "uz", "vu", "va",
      "ve", "vn", "vg", "vi", "wf", "eh", "ye", "yu", "zr", "zm", "zw",

      # Organization Domains
      "com", "edu", "gov", "int", "mil", "net", "org",

      # Following at http://www.edns.net/registries.htm
      # unsanctioned but currently supported by a number of nameservers
      "biz", "corp", "earth", "exp", "k12", "ltd", "lnx", "med", "nic", "npo", 
      "per", "usa", "web", "xxx",

      # Following at http://www.iahc.org/press-final.html, dated 4 Feb 97.
      # Also want to hear more before accepting these....
      # "arts", "firm", "info", "nom", "rec", "store", "web",
      );
  @valid_domains = sort @valid_domains;  # needed for bsearch to work

  # mnemonics for $recipient
  $complain_to_only = 1;
  $poster_only = 2;
  $poster_and_complain_to = 3;

  # This is a simple way to match the first letter of an SMTP id with the
  # expected hour of the day....
#  %smtp_chars = ( "A", "00", "B", "01", "C", "02", "D", "03", "E", "04",
#		  "F", "05", "G", "06", "H", "07", "I", "08", "J", "09",
#		  "K", "10", "L", "11", "M", "12", "N", "13", "O", "14",
#		  "P", "15", "Q", "16", "R", "17", "S", "18", "T", "19",
#		  "U", "20", "V", "21", "W", "22", "X", "23");

  # Exceptions List
  # Please mail additions and corrections to billmc@agora.rdrop.com.

  # DESCRIPTION
  # These are site names that don't follow the convention of two fields for
  # names with three-letter suffixes (e.g., company.com) or three fields for
  # names with two-letter suffixes (e.g., canadian.site.ca).

  @site_exceptions = (
	'ab.umd.edu',
	'acc.ca',
	'ada.se',
	'adenet.es',
	'ai.mit.edu',
	'alameda-coe.k12.ca.us',
	'algonet.se',
	'austria.eu.net',
	'aware.nl',
	'banat-crisana.ro',
	'bcm.tmc.edu',
	'bctel.ca',
	'berlingske.dk',
	'bluewin.ch',
	'bme.hu',
	'bureau1.utcc.utoronto.ca',
	'bureau2.utcc.utoronto.ca',
	'bureau3.utcc.utoronto.ca',
	'bureau4.utcc.utoronto.ca',
	'bureau5.utcc.utoronto.ca',
	'bureau6.utcc.utoronto.ca',
	'bureau7.utcc.utoronto.ca',
	'campus.mci.net',
	'canit.se',
	'casema.nl',
	'casinos.at',
	'c.4biz.net',
	'.cc',
	'ceta.es',
	'chalmers.se',
	'cisnews.cisnet.com',
	'coast.to',
	'columbus.rr.com',
	'cs.umass.edu',
	'ct.rr.com',
	'cybernet.za',
	'datanet.hu',
	'demon.co.uk',
	'dial-access.att.net',
	'dial.pipex.com',
	'digibel.be',
	'direct.ca',
	'dis.dk',
	'easynet.de',
	'econnect.ca',
	'edcoe.k12.ca.us',
	'egate.ca',
	'elektrobit.fi',
	'elp.rr.com',
	'epfl.ch',
	'escape.ca',
	'eunet.be',
	'eunet.ch',
	'eunet.fi',
	'expedia.msn.com',
	'extrabit.fi',
	'fastlane.ca',
	'flashmail.cc',
	'forfree.at',
	'fun.ee',
	'futurnet.es',
	'germany.eu.net',
	'get2net.dk',
	'glo.be',
	'glas.apc.org',
	'glue.umd.edu',
	'gmx.de',
	'gnu.ai.mit.edu',
	'greenhill.pvt.k12.tx.us',
	'gregg.world-access.com',
	'grolier.fr',
	'gu.se',
	'hawaii.rr.com',
	'hl-technik.de',
	'hol.fr',
	'home.se',
	'hungarnet.hu',
	'hvu.nl',
	'iaf.nl',
	'ibernet.es',
	'ican.ca',
	'iif.hu',
	'indigo.ie',
	'inext.ro',
	'innovplace.saskatoon.sk.ca',
	'iol.ie',
	'ireq.ca',
	'isky.ca',
	'istar.ca',
	'iteso.mx',
	'ivm.de',
	'lakeheadu.ca',
	'loki.silkspin.com',
	'lserv.utcc.utoronto.ca',
	'mail.icongrp.com',
	'mail.memorystorage.com',
	'maine.rr.com',
	'med.wayne.edu',
	'mediatech.de',
	'messer.de',
	'metronet.de',
	'midsouth.rr.com',
	'mpg.de',
	'msfc.nasa.gov',
	'nacamar.de',
	'nemo.fi',
	'netcom.ca',
	'netinc.ca',
	'netway.at',
	'neuhaus.de',
	'nordbayern.de',
	'norgesnett.no',
	'nstn.ca',
	'.nu',
	'nycap.rr.com',
	'nym.alias.net',
	'odn.de',
	'on.the.net',
	'online.no',
	'oup.es',
	'oupcan.mail.net',
	'oupchile.cl',
	'oxford.pl',
	'oxford.satlink.net',
	'oxford.spin.com.mx',
	'pangea.ca',
	'pi.se',
	'pine.nl',
	'ping.at',
	'planet.eon.net',
	'pluto.spearhead.net',
	'pop.tc',
	'psi.ca',
	'postag.de',
	'pubnet.sk',
	'rba.ch',
	'redestb.es',
	'rmcs.cranfield.ac.uk',
	'ruhr-uni-bochum.de',
	'san.rr.com',
	'schwaben.de',
	'seicom.de',
	'siemens.de',
	'siemensnixdorf.de',
	'sigov.si',
	'silsoe.cranfield.ac.uk',
	'sky.fr',
	'smart.is',
	'sn.no',
	'snerpa.is',
	'sni.de',
	'sol.no',
	'spectranet.ca',
	'sprint.ca',
	'sprintcanada.ca',
	'.st',
	'stack.nl',
	'sun-denshi.co.jp',
	'sunrise.it',
	'sympatico.ca',
	'sztaki.hu',
	'tampabay.rr.com',
	'tao.ca',
	'tele2.dk',
	'telegate.nl',
	'telegate.se',
	'teleglobe.ca',
	'telepac.pt',
	'terminal.cz',
	'terranova.fi',
	'tfi.be',
	'tfi.de',
	'tin.it',
	'.tj',
	'.to',
	'tsqware.fr',
	'twcny.rr.com',
	'ualberta.ca',
	'uk.uu.net',
	'uni2.dk',
	'uni-c.dk',
	'unibe.ch',
	'unicall.be',
	'unik.no',
	'uunet.ca',
	'usask.ca',
	'uvic.ca',
	'varney.idbsu.edu',
	'videotron.ca',
	'vma.verio.net',
	'wam.umd.edu',
	'wanadoo.fr',
	'windsor.igs.net',
	'worldnet.att.net',
	'worldnet.fr',
	'worldonline.nl',
	'wwonline.ca',
	'wxs.nl',
	'xs4all.nl',
	);
    @site_exceptions = sort @site_exceptions; # needed for bsearch to work

    %rematch_aliases = (
    'nonexistent.com',  'X-NNTP-Posting-Host:',
    'nym.alias.net', 'Message-Id:',
	);

# START EXEMPT LIST
$EXEMPT_LIST = <<'END';
M```6Q3$``6`R``%N,P`!?30``9$U``&9-@`!G3<``:XX``&V80`#4&(`!&!C
M``:99``'A64`"']F``F*9P`*4F@`"K9I``O`:@`+_6L`##=L``S.;0`.*VX`
M#PMO``^<<``0YW$`$0QR`!&*<P`3F70`%*%U`!3W=@`5@W<`%FQX`!:2>0`6
MMWI`%L(`````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````````!```!MP```;T`!
M`6-``0(N0`$#;$`!!&%``05B0`$&;T`!!VQ``0AG0`$)=,```&5``0MN0`$,
M+D`!#65``0YL0`$/84`!$&1``1%R0`$294`!$V1``11U0`$584`!%FQ``1<N
M0`$8=$`!&3!``1ID0`$$;$`!'')``1UO0`$>=T`!'W1``01L0`$A=4`!(F1`
M`2-O0`$.80`!)&=``24Q``$@,T`!)F5``05T0`$J;T`!*VA``2PV0`$M.4`!
M+C!``2]S0`$$=$`!,7)``3)O0`$S<$`!-'-``35W0`$V=T`!-SA``3@P``$P
M.$`!.65``01N0`$\:4`!/6Q``3YN0`$_;T`!0&Q``4%L0`%"84`!0W9``3QI
M0`%%<D`!1F1``4=T0`%(94`!27A``01X0`%+>$`!3#%``4UN0`%.;D`!'&]`
M`5!C0`%1>4`!!&Q``5-I0`%4;4`!575``3UT0`%7<D`!6&$``59O0`%9+@`!
M#69``5IE``%2=$`!7"T``0HP``$;,@`!*#@``3IK``$.;0`!1&X``4IO``%/
M<T`!7CE``00Y0`%I.$`!!&Y``01O0`%L,``!:C(``5`U``%K=D`!;6-``01N
M0`%R:4`!<VE``71E0`$Q<T`!=G-``7=E0`%X9$`!>61``7IO0`%[9``!=6=`
M`7QK0`$$<D`!?V]``8!W0`&!=$`!@F5``8-N0`&$,4`!A6,``0)N0`$,+D`!
MAW1``79I0`&*<T`!BV)``8QW0`$$90`!C7E``8XQ``&&=0`!B7=``8]P0`$$
M=4`!E&1``95N0`&684`!ES!``9AR0`$$94`!FFA``9LY``&<=$`!:7-``0YE
M0`&?:4`!H'1``:%I0`&B84`!!&E``:1N0`&E;D`!IF5``:=L0`&H;$`!J6E`
M`:IM0`&K:$`!K&,``:-T0`&M:4`!=FM``;!O0`&Q;T`!LF-``;,P0`&T,$`!
MM6E``00Y0`&W.$`!N'1``;DP0`&Z,4`!NW)``0YC``&]9$`!#G-``85R0`'`
M94`!P79``<)E0`'#:4`!Q&A``<5C0`'&84`!QV1``3$M``'(84`!R7)``2%A
M0`',;4`!S71``05N0`'/:4`!T&,``<IS``'.=D`!T6=``01N0`'5:4`!UFQ`
M`==L0`'8:4`!V6)``=IU0`';<T`!,6Q``3%T0`$.94`!WVY``>!E0`'A+@`!
M`V5``=]N0`'C8P`!W&4``=UI``'>;0`!XG5``>5A0`%+;4`!ZVE``4MF0`'M
M84`![G)``>]V0`&;;$`!\6E``?)S0`'S>$`!]&%``?5H0`$R9T`!]VE``?AT
M0`$\:4`!^F]``3%E0`'\9$`!_6E``?YT0`&;<T`"`&%``@%M0`("8D`"`V5`
M`@1N``'Y<P`!^W8``?]W0`(%8D`!FVU``@IA0`(+:$`"#&Y``51O0`(.<T`"
M#V5``A!Y0`(194`!O71``A-N0`(4:$`!!&-``A9T0`(784`"&"T``@9C``(-
M90`"$FD``A5S``'Y=T`"&71``AIL0`(@:T`!(6U``B(M0`(C94`")&=``B5A
M0`(F=$`")VY``BAT0`'794`"*FM``BMR0`(L84`"+6U``BYN0`(O:4`",'-`
M`C%E0`(R<D`",W5``C1T0`(U=4`!!"X``0,T0`(W94`".'-``CII0`([=$`"
M/&X``C9R0`(]80`"*64``CYN0`$$;T`!/2T``>QG``'P;0`!]G4``B%V``)`
M>D`"0V%``9]E0`)*;D`"2V]``7]O0`)-;$`"3G1``D]S0`)0<D`"46%``=5M
M0`)3<T`"5')``E5U0`)6;T`"5VA``EAR0`)994`"6FD``E)T0`);:$`!#F-`
M`EYE0`)?=$`"8&4``F%I0`&?-$`"-W1``F1S0`)E;T`"9G-``:1R``)A<P`!
M#G5``F@P0`$$,$`";#!``FTQ``$$,D`";FU``01I0`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]`%E!A0`)?
M80`/8&5`%E)S0`Y@94`656E`%E9R0!9794`66"T``M9L`!9/<``647(`%E-S
M0!999$`66F0`%DIK`!9,;$`67W)`%F!E0`2==$`69&E`%F5J0`&:8P`!'&0`
M!#AE``)V;4`-#F$`%9IB`!6?8P`#,F0``6QE`!8%:``6'&D`%D)J``&W;@`6
M26\`%F-R`!9F<P`69W=`%FAI0`%_=$`6>6%`%GIT0!9[<T`6?&%`%!-R0!9^
M94`6?VU`%H!E0!:!<@`6@G9``01M``,A<T`2"&Y``\=R0!:'=4`6B&]`%HER
M0`?\;T`6BW1`%HPM`!:%:@`6BG-`%HUX0!:.+0`6?64``8EO``4Q<``!,70`
M%H-X0!:1;T`-4F-`%IAK0!:9:T`"$V-`%IME0!:<9T`!!F5`%IYL0!:?<T`6
MH'1`%J%I0!:B<$`6HV]`"EMH``R3:4`&DW5``51R0!:H=$`6J2T`%J9I``:3
M;0`$$VX`";AS0!:J9T`6I65`%K!G`!:E<@`6JW9`%K%U0!:R:$`2A#(`%IIB
M`!:=90`6I&\`%K5U0!:V:4`$T&Q`%KPT0!:]=$`6OG-`%K]G0`%M90`6P&\`
*!3ER``+\>4`6P0``
END
# END EXEMPT LIST
  $EXEMPT_LIST = unpack("u", $EXEMPT_LIST);
  } # get_constants_and_environment

#-----------------------------------------------
# j-random initialization, including reading environment variables
# and initializing result data.
sub initialize {
  local ($pat, $aliases, $addrtype, $length, @addrs);

  # Determine the OS, set up networking constants, establish constant
  # lists, such as legal mail domain suffixes.
  &get_constants_and_environment();

  $adcomplain_name = '$RCSfile: adcomplain.pl,v $';	# filled in by RCS
  $pat = 'RCSfile:';				# have to fool rcs
  $adcomplain_name =~ s/\$$pat (.*),v \$/$1/;
  $adcomplain_revision = '$Revision: 3.52 $';	# filled in by RCS
  $pat = 'Revision:';				# have to fool rcs
  $adcomplain_revision =~ s/\$$pat (.*) \$/$1/;

  # Determine the editor
  $editor = $ENV{"VISUAL"};
  $editor = $ENV{"EDITOR"} if !defined($editor) || $editor eq "";
  if (!defined($editor) || $editor eq "") {
    if ($os_kind eq "unix") {
      $editor = "vi";
      }
    elsif ($os_kind eq "winnt" || $os_kind eq "win32") {
      $editor = "notepad";
      }
    elsif ($os_kind eq "os2") {
      $editor = "e";
      }
    else {
      die "don't know default editor for os $os_kind";
      }
    }

  # Determine the pager
  $pager = $ENV{"PAGER"};
  $pager = "" if !defined($pager);
  if ($pager eq "" && $os_kind eq "unix") {
    # better default on Unix
    $pager = "more";
    }
  $pager = "" if $pager eq "builtin";

  # Get $local_hostname
  if ($os_kind eq "unix") {
    local($hname) = "/bin/hostname";			# most unixes
    $hname = "/usr/bsd/hostname" if ! -x $hname;	# irix :-(
    die "Cannot find your hostname command" if ! -x $hname;

    chop($local_hostname = `$hname`);
    die "$hname failure" if $local_hostname eq "";
    }
  elsif ($os_kind eq "winnt") {
    $local_hostname = $ENV{"COMPUTERNAME"};

    die "%COMPUTERNAME% is not set, what's wrong with your installation?"
	if $local_hostname eq "";
    }
  elsif ($os_kind eq "win32") {
    # I wish there was a better way of doing this....
    $local_hostname = $ENV{"COMPUTERNAME"};
    
    die "Please set the COMPUTERNAME environment variable"
	if $local_hostname eq "";
    }
  elsif ($os_kind eq "os2") {
    # I wish there was a better way of doing this....
    $local_hostname = $ENV{"HOSTNAME"};
    
    die "Please set the HOSTNAME environment variable"
	if $local_hostname eq "";
    }
  else {
    die "cannot determine local hostname on this os ($os_kind)";
    }

  # Try to make it fully qualified
  $local_hostname = &fqdn_name($local_hostname);
  if (&good_hostname($local_hostname, 0) eq "") {
    print "WARNING: unable to determine mail address of this computer.\n";
    print "         (\"$local_hostname\" doesn't look right.)\n";
    print "         Be sure to edit before sending.  Set ADCOMPLAIN_MDOMAIN\n";
    print "         in your environment to permanently rectify this.\n";
    }

  # Don't pull the hostname off of the domain.  Some mail domains require
  # even the computername in order to do proper delivery.
  if ($fqdnWithoutHost && $local_hostname =~ /^[^\.]+\.(.+)$/) {
    $local_hostname = $1;
    }


  $mailhost = $ENV{"ADCOMPLAIN_MAILHOST"}
	if defined($ENV{"ADCOMPLAIN_MAILHOST"});
  if (!defined($mailhost) || $mailhost eq "") {
    if ($os_kind eq "unix") {
      # Unix: assume sendmail is running locally
      $mailhost = $local_hostname;
      }
    else {
      die "configuration error: MAILHOST not set";
      }
    }

  $SIG{'PIPE'} = 'IGNORE';
  $header_analysis = "";
  $bullet = "*  ";	# used in formatting header_analysis
  $bullet2 = "   ";	# for hanging indent

  # Make stderr and stdout unbuffered.
  select(STDERR); $| = 1;
  select(STDOUT); $| = 1;

  if ($os_kind eq "unix") {
    $tempname="/tmp/adcomplain-$$";
    $CONSOLE = "/dev/tty";
    }
  elsif ($os_kind eq "winnt" || $os_kind eq "win32" || $os_kind eq "os2") {
    # Two weird conventions for a temp directory on Windows NT
    local($tmp) = $ENV{"TMP"};
    $tmp = $ENV{"TEMP"} if !defined($tmp) || $tmp eq "";
    $tempname="$tmp\\adcomplain-$$";	# ?? is there a better way?
    $tempname =~ s#/#\\#g;	# in case Unix-isms crept in

    $CONSOLE = "con:";
    }
  else {
    die "need tempname and console for this os ($os_kind)";
    }

  $hosts_file = $ENV{"ADCOMPLAIN_HOSTS"};
  $hosts_file = "" if !defined($hosts_file) || $hosts_file eq ""
	|| ! -f $hosts_file;

  %hosts_to_ips = ();
  %ips_to_hosts = ();

  $from = $ENV{"ADCOMPLAIN_FROM"};
  if (!defined($from) || $from eq "") {
    # username
    if ($os_kind eq "unix") { # safe to call getpwuid
      local($USER,@garbage) = getpwuid($<);
      @garbage = @garbage;	# shut up perl -w
      $from = $USER;
      $from = $ENV{"USER"} if $from eq "";			# desperation
      $from = $ENV{"LOGNAME"} if $from eq "";			# ...then panic
      die "I can't figure out who you are!" if $from eq "";	# ...then death
      }
    elsif ($os_kind eq "winnt") {
      $from = $ENV{"USERNAME"};
      die "%USERNAME% is not set, what's wrong with your installation?"
	  if $from eq "";
      }
    elsif ($os_kind eq "win32" || $os_kind eq "os2") {
      # This might be buried in the registry somewhere....
      $from = $ENV{"USERNAME"};
      die "Please set %ADCOMPLAIN_FROM% or %USERNAME% in your autoexec"
	  if $from eq "";
      }
    else {
      die "how do I get your username on this os? ($os_kind)";
      }
    $from = "$from\@$local_hostname";
    }
  if (&good_hostname($from, 0) eq "") {
    print "WARNING: your return address \"$from\" is not valid.\n";
    print "         Be sure to edit before sending.  Set ADCOMPLAIN_FROM\n";
    print "         (or ADCOMPLAIN_MDOMAIN) in your environment to\n";
    print "         permanently rectify this.\n";
    }

  # This is a dictionary of the hostnames we've found.
  %available_hosts = ();

} # initialize

#-----------------------------------------------
# Create standard text for a response.
sub insert_standard_text {
  local ($response);

  $response = "[generated by $adcomplain_name $adcomplain_revision]\n\n";

  if ($header_analysis ne "") {
    $response .= "I am complaining about ";
    if ($chainmode) {
      $response .= "an illegal chain letter ";
      }
    else {
      $response .= "a commercial advertisement ";
      }
    if ($mailmode) {
      $response .= "sent to my e-mail address.";
      }
    else {
      $response .= "posted to $newsgroup.";
      }
    $response .= "\n";
    $response .= <<'END';
This message apparently passed through your site.  It may even have originated
with you.  However, there are inconsistencies in the RFC-822 mail 
headers.  It is possible that a mail program was buggy or misconfigured, but it
is much more likely that the sender has intentionally obscured the message's
true origin.  It follows that the sender is aware of the dishonest and
illegal nature of this message.

The problems I see with these headers are:

END
    $response .= "$header_analysis";
    } # $header_analysis
  else { # legit headers
    $response .= "Please ";
    if ($recipient != $complain_to_only) {
      $response .= "don't ";
      }
    else {
      $response .= "advise this user not to ";
      }
    if ($mailmode) {
      $response .= "mail ";
      }
    else {
      $response .= "post ";
      }
    $response .= "these ";
    if ($chainmode) {
      $response .= "illegal chain letters ";
      }
    else {
      $response .= "unsolicited commercial advertisements ";
      }
    $response .= "to ";
    if ($mailmode) {
      $response .= "people's e-mail addresses.  ";
      }
    else {
      $response .= "$newsgroup.  ";
      }
    $response .= "My site must pay to receive and store them.\n";
    } # legit headers
  if (!$chainmode && !$mailmode && !$quiet) {
    $ans = &get_answer("Is \"$subject\" relevant to $newsgroup (y/n)?",
	"n");
    if ($ans eq "n") {
      $response .= "\nIn addition, \"$subject\"\n";
      $response .= "has nothing to do with $newsgroup.\n";
      }
    }
  if (!$noinclude || $recipient ne $poster_only) {
    $response .= "\nI forward the entire text of the message, with ";
    $response .= "headers, to the end of this message.\n";
    }
  $response .= "\n";

  if ($chainmode) {
    $response .= <<'END';
This sort of chain letter is a pyramid scheme, which in turn is a form of fraud.
It violates a U.S. federal statute, 18 U.S.C. sec. 1343.

If at any point the U.S. Mail is used, this is also a violation of 18 U.S.C
sec. 1302, the Postal Lottery Statute.  See

     http://www.usps.gov/websites/depart/inspect/chainlet.htm
     http://www.usps.gov/websites/depart/inspect/usc18/mailfr.htm

This sort of chain letter is outlawed in Canada under the Section 206(1)(e) of
the Criminal Code and under Section 55 of the Competition Act.

END
    }
  else { # advertising
    if ($mailmode) {
      $response .= <<'END';
These advertisements are illegal in many countries; please consult an attorney
for your applicable statutes.

END
      }
    else { # Usenet
      if ($recipient != $complain_to_only) {
	$response .= <<'END';
The biz.marketplace and ads newsgroup hierarchies are the correct places for
commercial ads. (Ads may be inappropriate in some biz newsgroups, so please
check first.)

For more information about Usenet etiquette, see news.announce.newusers.

END
	}
      } # Usenet
    } # advertising

  if (!$mailmode && $recipient != $complain_to_only) { # cancel your post
    $response .= <<'END';
Most text-based newsreaders will allow you to cancel a posting by finding your
article and pressing 'C' or 'D'.

(Netscape users can select 'Cancel Message' in the 'Edit' menu.)
If you need help, contact
END
    if ($postmaster ne "") {
      $response .= "your postmaster at\n\n";
      $response .= "     <$postmaster>.\n";
      }
    else {
      $response .= "postmaster.\n";
      }
    $response .= "\n";
    } # cancel your post

  $response .= "Thank you for your cooperation.\n\n";

  # batchmode
  if ($batchmode && !$outmode) {
    $response .= <<'END';

P.S. -- I used the questionable "batch mode" in adcomplain to create
this message.  If this message was addressed improperly, it is because I
did not proofread the list of recipients before mailing.  Direct
your complaints to me, not to the authors of adcomplain.  Thank you.
END
    }
  # format the response
  $response = &fmt($response, 72);

  return $response;
  }

#-----------------------------------------------
# compose a message out of all of the elements so far
sub compose_message {
  local ($response);
  local($header);

  ## find out where to send message
  if ($batchmode || $quiet) {
    }
  elsif ($poster ne "" && $complain_to ne "") {
    print "Send to:\n";
    print " 1 = $complain_to\n";
    print " 2 = $poster\n";
    print " 3 = both\n";
    print " 4 = <abort>\n";
    $ans = &get_answer("Send to whom?", $recipient);
    if ($ans == 4) {
      print "aborted\n";
      exit 0;
      }
    $recipient = $ans if $ans ne "" && $ans >= 1 && $ans <= 3;
    }

  if ($complaintFile eq "") {
    $response = &insert_standard_text;
    }
  else {
    $response = "";
    if ($complaintFile ne "") {
      if (-f $complaintFile) {
	if (!open(TEXTFILE, "$complaintFile")) {
	  print "adcomplain: cannot open $complaintFile: $!\n";
	  }
	else {
	  local(@text);
	  @text = <TEXTFILE>;
	  $response = join('', @text);
	  close TEXTFILE;
	  @text = (); # garbage collection
	  }
	}
      else {
	print "adcomplain: $complaintFile: no such file.\n";
	#require "getcwd.pl";
	#$cwd = &getcwd;
	#print "adcomplain: (current directory is $cwd)\n";
	}

      # interpolate perl variables into the response string
      $response = eval "\"" . "$response" . "\"";
      }
    } # $complaintFile given

  ## include copy of posting if needed
  if (!$noinclude || $recipient ne $poster_only) {
    $response .= "\n--------forwarded message--------\n";
    for (@original) {
      $response .= $_;
      }
    $response .= "-----end of forwarded message-----\n\n";
    }

  ## append signature if needed
  $siggie = $ENV{"SIGNATURE"};
  if (!defined($siggie) || $siggie eq "") {
    $siggie = $ENV{"HOME"};
    $siggie .= "/.signature" if defined($siggie) && $siggie ne "";
    }

  if (!$omit_signature && $addsig && defined($siggie) && -f $siggie) {
    if (!open(TEXTFILE, $siggie)) {
      print "adcomplain: cannot open $siggie: $!\n";
      }
    else {
      local(@text);

      $response .= "-- \n";
      @text = <TEXTFILE>;
      # in case siggie already has the delim....
      shift(@text) if $text[0] eq "-- \n" || $text[0] eq "--\n";
      for (@text) {
	$response .= $_;
	}
      close TEXTFILE;
      @text = (); # garbage collection
      }
    }

  ## prepend message header
  $header = "";

  { # Add RFC-822 "Date:" header
    local ($Date);
    local ($sec,$min,$hour,$mday,$mon,$year,$wday,$junk) = gmtime(time);

    $junk = sprintf("%02d:%02d:%02d", $hour, $min, $sec);
    $mday = sprintf("%02d", $mday);
    $mon = $monthNames[$mon];
    $year += 1900;
    $wday = $wdayNames[$wday];

    # TO DO:  we could actually put the time zone in.  For now, use GMT
    $Date = "$wday, $mday $mon $year $junk +0000 (GMT)";
    $header .= "Date: $Date\n";
  }

  # Add "From:"
  $header .= "From: $from\n";

  # who is it to?
  if ($recipient == $complain_to_only) {
    $header .= "To: $complain_to\n";
    }
  else {
    $header .= "To: $poster\n";
    }

  # and who gets copies?
  if (!$legal_letter) {
    $cc = ", $cc" if $cc ne "";
    $cc = "$authorities$cc";
    }
  if ($recipient == $poster_and_complain_to) {
    $cc = ", $cc" if $cc ne "";
    $cc = "$complain_to$cc";
    }
  $header .= "Cc: $cc\n" if $cc ne "";

  $subject = "no subject" if $subject eq "";
  $header .= "Subject: ";
  if ($recipient == $complain_to_only) {
    $header .= "Abuse report:  ";
    }
  else {
    $header .= "Re: your ";
    }
  if ($mailmode) {
    $header .= "email ";
    }
  else {
    $header .= "Usenet article ";
    }
  $header .= "titled \"$subject\"\n";
  $header .= "\n"; # RFC822 end of headers
  $response = $header . $response;

  return $response;
} # compose_message

#-----------------------------------------------
# Ask a question and get a reply from /dev/tty, use default if no reply given:
sub get_answer {
  local($prompt, $default) = @_;
  local($ans);
  local($/) = "\n";

  print "$prompt [$default] ";
  $ans = <STDIN>;
  chop($ans);
  return $ans if ($ans ne "");
  return $default;
  }

#-----------------------------------------------
# format a string into paragraphs with given maximum line length.
sub fmt {
  local($str, $len) = @_;
  local(@lines) = split(/\n/, $str);
  # local(@paras) = split(/\n{2,}/, $str);
  local(@paras);
  local($para, $result, $left, $word);
  local($last_was_bullet, $is_bullet, $junk);

  # split into paragraphs
  @paras = ();
  $para = "";
  for (@lines) {
    if ($_ eq "\n" || $_ eq "") {
      # blank line delimits beginning of paragraph
      push(@paras, $para);
      push(@paras, "");
      $para = "";
      next;
      }
    $_ =~ s/\n/ /g;
    if ($_ =~ /^[\s]+.*/) { # so does a line beginning with white space
      push(@paras, $para) if $para ne "";
      $para = "";
      }

    # Join the line, using proper respect for punctuation
    if ($para =~ /.*\.\s*$/) { # ends in a period
      $para =~ s/(.*\.)\s*$/$1  /;
      }
    elsif ($para =~ /.*:\s*$/) { # ends in a colon
      $para =~ s/(.*:)\s*$/$1  /;
      }
    elsif ($para =~ /.*!\s*$/) { # ends in an exclamation
      $para =~ s/(.*!)\s*$/$1  /;
      }
    else {
      $para .= " " if $para ne "";
      }
    $para .= $_;
    }
  push(@paras, $para) if $para ne "";

  # Reformat the paragraphs
  $result = "";
  $last_was_bullet = 0;
  $junk = $bullet;
  $junk =~ s/(\W)/\\$1/g;		# remove special characters
  $junk = "^$junk.*";
  for (@paras) {
    $left = $len;
    $is_bullet = ($_ =~ /$junk/) ? 1 : 0;

    # special case:  indentation at beginning of paragraph is preserved
    if ($_ =~ /^\s+/) {
      ($word = $_) =~ s/^(\s+).*/$1/;
      $left -= length($word);
      $result .= $word;
      }

    # Now start adding the words
    while ($_ =~ s/^\s*(\S+\s*)//) {
      $word = $1;
      if (length($word) < $left) {
	$result .= $word;
	$left -= length($word);
	}
      else {
	if ($is_bullet) {
	  $result .= "\n$bullet2$word";
	  }
	else {
	  $result .= "\n$word";
	  }
	$left = $len - length($word);
	}
      }
  $result .= "\n" if !$last_was_bullet;
  $last_was_bullet = $is_bullet;
  }
return $result;
}

#-----------------------------------------------
# display a screen's worth; used by moref().
sub display {
  local($my_name, $start, $count, @lines) = @_;
  local($i, $max);

  if ($start + $count <= $#lines) {
    $max = $start + $count;
    }
  else {
    $max = $#lines;
    }
  for ($i = $start; $i < $max; $i ++) {
    print $lines[$i];
    }
  printf "- $my_name: %d/$#lines: ", $start + 1;
  }

#-----------------------------------------------
# a cheap internal pager
sub moref {
  local($tempname) = @_;  # the file to display
  local($my_name) = "moref";
  local ($line_count) = 0;
  local ($lines_per_screen) = 22;
  local ($kbd_cmd, $front, $back);
  local (@all_lines);

  if ($pager ne "") {
    if ($os_kind eq "unix") {
      system "$pager $tempname <$CONSOLE";
      }
    elsif ($os_kind eq "winnt" || $os_kind eq "win32" || $os_kind eq "os2") {
      system "$pager $tempname";
      }
    else {
      die "how do I run your pager on this system?";
      }
    return;
    }

  if (defined($ENV{"LINES"}) && $ENV{"LINES"} != 0) {
    # Unix termcap convention
    $lines_per_screen = $ENV{"LINES"} - 1;
    }

  open (MOREF, "<$tempname") || die "$my_name: can't open $tempname:  $!"; 
  @all_lines = <MOREF>;
  close MOREF;

  # At this point it's still possible that some of the lines may be oversize,
  # because we don't format the original mail message from the sender; we go
  # the entire message and break up any oversized lines.
  for ($i = 0; $i <= $#all_lines; $i ++) {
    next if length($all_lines[$i]) < 80;
    $front = substr($all_lines[$i], 0, 79);
    $back = substr($all_lines[$i], 79);
    $all_lines[$i] = "$front\n";
    splice(@all_lines, $i + 1, 0, $back);
    }

  $line_count = 0;
  for (;;) {
    &display($my_name, $line_count, $lines_per_screen, @all_lines);
    $kbd_cmd = <STDIN>;
    chop($kbd_cmd);
    if ($kbd_cmd eq "") {
      $line_count += $lines_per_screen;
      $line_count = $#all_lines if $line_count > $#all_lines;
      next;
      }
    elsif ($kbd_cmd =~ /^\?.*/) {
      print "? - this message\n";
      print "<enter> - next page\n";
      print "b - back a page\n";
      print "nnnn -- start with given number line\n";
      print "q - quit\n";
      print "press enter to continue... ";
      $kbd_cmd = <STDIN>;
      }
    elsif ($kbd_cmd =~ /^b.*/i) {
      $line_count -= $lines_per_screen;
      $line_count = 0 if $line_count < 0;
      next;
      }
    elsif ($kbd_cmd =~ /^q.*/i) {
      last;
      }
    elsif ($kbd_cmd =~ /^\d+$/) {
      $line_count = $kbd_cmd - 1;	# take input as one-based line number
      $line_count = $#all_lines if $line_count > $#all_lines;
      next;
      }
    else {
      print "what? (\"?<Enter>\" at the prompt for help): ";
      print "for now, press enter to continue... ";
      $kbd_cmd = <STDIN>;
      }
    }
}
