#!/usr/athena/bin/perl

$ppdir = ($ENV{'PPDIR'} || '/afs/sipb.mit.edu/project/periodic-postings');
$news = ($ENV{'PPNEWS'} || "$ppdir/data/periodic-posting-news");

$parts = 1;
$part = 1;
$out = undef;
$usage = "Usage: $0 [ -parts parts ] [ -part part ] [ -dir dir ]
	[ -prefix prefix ] [ -out filename ]
	Specify part 0 to get the diff posting.
	If $news exists,
	  it will be put at the top of part 1 and the diff posting,
	  preceded and followed by a blank line.";

$headtemplate = <<EOF;
Path: senator-bedfellow.mit.edu!news-answers-request
Newsgroups: news.lists.misc,news.answers
Distribution: world
Followup-To: poster
From: news-answers-request@MIT.EDU (the *.answers moderation team)
Reply-To: news-answers-request@MIT.EDU (the *.answers moderation team)
Approved: news-answers-request@MIT.EDU

EOF

$subject = "Subject: List of Periodic Informational Postings, Part xPARTNUMx/xNUMPARTSx\n";

$header1 = <<EOF;
Archive-name: periodic-postings/partxPARTNUMx

xNEWSx

[The most recent version of the postings making up the List of
Periodic Informational Postings can be found in the newsgroups
news.lists.misc and news.answers.  They can also obtained by anonymous
FTP from rtfm.mit.edu:/pub/usenet/news.answers/periodic-postings/.  If
you do not have access to anonymous FTP, you can retrieve them by
sending email to mail-server@rtfm.mit.edu with the command "send
usenet/news.answers/periodic-postings/*" in the message.]

----------------

This and all other parts of the List of Periodic Informational Postings
(c) Copyright 1991-1996 by the *.answers moderators, all rights
reserved.  Redistribution of this document is hereby freely granted so
long as the document is redistributed in its entirety (here
interpreted as all text which were not automated generated by software
as part of the distribution process); in particular, with attributions
and this copyright notice.  We would appreciate hearing about any
interesting redistributions.

----------------

Many Usenet newsgroups contain informational postings which are posted
on a periodic basis.  These postings are often useful for both novice
and experienced readers of the newsgroup, as they usually fall into
one or more of these categories:

  * Introductory notes about one or more newsgroups, covering
    policies (if any) for submissions to that group, newsgroup
    charter, etiquette and standards, etc.
  * Common questions and answers about the newsgroup's topic,
    often referred to as FAQ's (Frequently Asked Questions).
  * How-to documents containing tutorial information about how
    to accomplish certain tasks in detail.
  * Indices of archives, or pointers to archives for various
    newsgroups, periodic newsletters, calendars, and publications.
  * Statistical information and reports about Usenet; tables of
    Usenet hosts, links, etc.
  * Miscellany, including small useful sources, "fun" lists, etc.

This is a list of the periodic postings known to the maintainers of
the List of Periodic Informational Postings at this time (including,
but not restricted to, all articles approved for cross-posting into
the *.answers newsgroups).  Each posting is listed in an entry that
includes who posts the article, which newsgroup(s) it appears in, what
Subject line is used, and how often the article is posted.  The
entries in the list are sorted first by the Newsgroups lines and then
by the Subject line.

Where multiple postings would have identical entries except for the
Subject line, the entries may be collapsed into a single entry; this
is why some entries have multiple Subject lines.  The character '*' is
used as a wildcard for parts of the Subject line which may change from
posting to posting, or when multiple postings with similar Subject
lines are collapsed into a single listing for brevity.  For example,
"v*INF1" matches "v01INF1", "v02INF1", etc., while "Part */*" matches
"Part 1/3", "Part 4/17", etc.

The Date in an entry, where given, indicates when the posting last
appeared.  However, it may be inaccurate if: (a) the maintainer of the
posting has changed the Subject line; (b) the most recent posting has
not reached our local news site; or (c) the entry corresponds to
multiple postings.

The Archive-name, where present, indicates the archive name that
appeared in the posting when it was last posted.  Note that if an
entry matches multiple postings, then only one archive name will
appear; you should expect postings in a single entry to have similar
archive name.  Similarly, the Summary indicates the summary that
appeared in the posting(s).

----------------

Many of these postings can be obtained from the rtfm.mit.edu
[18.181.0.24] archives.  Below are sample headers to demonstrate how
to find archived copies of a given posting entry:

  Newsgroups: misc.bar,alt.discuss.bar,misc.answers,alt.answers,news.answers
  Subject: misc.bar Frequently Asked Questions (FAQ)
  ....

If such a posting were listed in the List of Periodic Informational
Postings, and has been fairly recently posted, it will be available
via anonymous FTP to rtfm.mit.edu as the files listed below, in
one-to-one correspondence with normal non-*.answers newsgroups:

  /pub/usenet/misc.bar/misc.bar_Frequently_Asked_Questions_(FAQ)
  /pub/usenet/alt.discuss.bar/misc.bar_Frequently_Asked_Questions_(FAQ)

[Special names are given to the copies of postings archived in the
*.answers newsgroups' directories.  See "Introduction to the *.answers
newsgroup" referenced below for more details.]

Archived postings can also be retrieved using the specialized mail
server running on rtfm.mit.edu by sending the following email message:

	To: mail-server@rtfm.mit.edu
	Subject: doesn't matter

	send usenet/misc.bar/misc.bar_Frequently_Asked_Questions_(FAQ)

Note that the path is slightly truncated from the path necessary for
retrieving files via anonymous FTP.

[Send a message containing "help" to get general information about the
mail server.]

----------------

Please note that nearly all of these periodic informational postings
are copyrighted by their respective maintainers.  (Even postings
without explicit copyright notices are copyrighted under the
international Berne Convention, in effect in most countries.)  Some of
the postings, although certainly not all, prohibit redistribution for
any commercial purposes without prior approval; other kinds of
restrictions may also be imposed by the maintainers.

If you have any doubts about whether you may redistribute a particular
posting for some particular purpose, contact its author.

----------------

Several other archives of periodic informational Usenet postings
exist.  To find out more about them and how to access those archives,
see the posting entitled "Introduction to the *.answers newsgroup" in
the news.answers newsgroup.  If you do not know how to get
news.answers, or your news site doesn't carry it, or you can't find
the posting in it, you can retrieve the posting via anonymous FTP from
rtfm.mit.edu in /pub/usenet/news.answers/news-answers/introduction.
If you do not have access to anonymous FTP, you can retrieve it by
sending email to mail-server@rtfm.mit.edu with the command "send
usenet/news.answers/news-answers/introduction" in the message.

Posters interested in having their periodic informational postings
approved for cross-posting to *.answers newsgroups in addition to
being listed in the List of Periodic Informational Postings should
consult the "*.answers submission guidelines" article posted
periodically in news.answers, or available via anonymous FTP as
rtfm.mit.edu:/pub/usenet/news.answers/news-answers/guidelines.  If you
do not have access to anonymous FTP, you can retrieve it by sending
email to mail-server@rtfm.mit.edu with the command "send
usenet/news.answers/news-answers/guidelines" in the message.

----------------

Corrections and additions to this listing are very welcome.  New
entries for the list should be submitted (via e-mail to
<news-answers-request@mit.edu>) in the same form as the entries below,
with From, Newsgroups, Subject, Frequency, and (optionally) Comments
lines, in that order.

EOF

$headern = <<EOF;
Archive-name: periodic-postings/partxPARTNUMx


This is part xPARTNUMx of the List of Periodic Informational Postings.  See
the posting entitled "List of Periodic Informational Postings, Part
1/xNUMPARTSx" for more information.
EOF

$diffposting = <<EOF;
Archive-name: periodic-postings/diff

xNEWSx

This posting contains a human-readable list of the changes that have
been made since the last time the List of Periodic Informational
Postings was posted.  Lines prefixed by '-' were removed from the list
in the past month, and lines prefixed by '+' were added.

See the posting entitled "List of Periodic Informational Postings,
Part 1/xNUMPARTSx" for more information about the List.
EOF

$diffsubject = "Subject: Changes to List of Periodic Informational Postings\n";

$trailer = <<EOF;

----------------------------------------------------------------------

EOF

while (($_ = $ARGV[0]) && /^-/) {
    shift @ARGV;
    if (/^-parts$/) {
	defined($parts = shift @ARGV) || die "Missing argument to \"-parts\" option.\n$usage";
	next;
    }
    elsif (/^-part$/) {
	defined($part = shift @ARGV) || die "Missing argument to \"-part\" option.\n$usage";
	next;
    }
    elsif (/^-dir$/) {
	defined($dir = shift @ARGV) || die "Missing argument to \"-dir\" option.\n$usage";
	next;
    }
    elsif (/^-prefix$/) {
	defined($prefix = shift @ARGV) || die "Missing argument to \"-prefix\" option.\n$usage";
	next;
    }
    elsif (/^-out$/) {
	defined($out = shift @ARGV) || die "Missing argument to \"-out\" option.\n$usage";
	next;
    }
    else {
	die "Unknown option \"$_\".\n$usage";
    }
}

if (@ARGV > 0) {
    die "$usage\n";
}

if (($parts !~ /^[0-9]+$/) || ($parts < 1)) {
    die "The argument to \"-parts\" must be an integer greater than 0.\n";
}

if (($part !~ /^[0-9]+$/) || ($part < 0) || ($part > $parts)) {
    die "The argument to \"-part\" must be an integer between 1 and $parts.\n";
}


if ($part == 0) {
    eval "\$msg = \$diffsubject . \$headtemplate . \$diffposting . \$trailer";
}
elsif ($part == 1) {
    eval "\$msg = \$subject . \$headtemplate . \$header1 . \$trailer";
}
else {
    eval "\$msg = \$subject . \$headtemplate . \$headern . \$trailer";
}

$msg =~ s/xPARTNUMx/$part/g;
$msg =~ s/xNUMPARTSx/$parts/g;
$news = `cat $news 2>/dev/null`;
$msg =~ s/xNEWSx\n/$news/;

if ($out) {
    open(STDOUT, ">$out") || die "Opening $out for write: $!.\n";
}
else {
    $out = "STDOUT";
}

print STDOUT $msg || die "Writing to $out: $!.\n";
close(STDOUT) || die "Closing $out: $!.\n";
