post-faq-0.10.orig/ 40755 1750 1750 0 6622664173 13124 5ustar rolandwizardpost-faq-0.10.orig/Makefile.base100644 1750 1750 3062 6622664125 15570 0ustar rolandwizard# See README for instructions on how to configure and install. # # $Id: Makefile.base,v 1.20 1994/02/22 01:21:48 jik Exp $ BINDIR=#bindir# MANDIR=#mandir# LIBDIR=#libdir# EXPORTS=Makefile post_faq.pl post_faq.man GENFILES=${EXPORTS} config.sed post_faq.shar SHARS=README Makefile.base config.awk config.dat.in \ post_faq.man.base post_faq.pl.base faqfile.pl \ config.sample PATCHLEVEL all prepare: ${EXPORTS} Makefile: Makefile.base config.sed -rm -f Makefile.bak -mv Makefile Makefile.bak sed -f config.sed Makefile.base >Makefile chmod -w Makefile post_faq.pl: post_faq.pl.base config.sed -rm -f post_faq.pl.bak -mv post_faq.pl post_faq.pl.bak sed -f config.sed post_faq.pl.base >post_faq.pl chmod +x post_faq.pl chmod -w post_faq.pl post_faq.man: post_faq.man.base config.sed -rm -f post_faq.man.bak -mv post_faq.man post_faq.man.bak sed -f config.sed post_faq.man.base >post_faq.man chmod -w post_faq.man config.sed: config.awk config.dat -rm -f config.sed.bak -mv config.sed config.sed.bak awk -f config.awk config.dat >config.sed chmod -w config.sed #If you don't supply your own data file, use the defaults: config.dat: cp config.dat.in config.dat install: ${EXPORTS} FRC install -c -m 0755 post_faq.pl ${DESTDIR}${BINDIR}/post_faq.pl install -c -m 0644 post_faq.man ${DESTDIR}${MANDIR}/post_faq.1 install -c -m 0644 faqfile.pl ${DESTDIR}${LIBDIR}/faqfile.pl clean: rm -f ${GENFILES} *~ post_faq.shar shar: $(SHARS) shar $(SHARS) > post_faq.shar patch: $(SHARS) makepatch $(SHARS) mv patch post_faq.patch`cat PATCHLEVEL` FRC: .PHONY: FRC post-faq-0.10.orig/PATCHLEVEL100644 1750 1750 3 6622664126 14502 0ustar rolandwizard10 post-faq-0.10.orig/README100644 1750 1750 3665 6622664126 14111 0ustar rolandwizard post_faq - automatic FAQ poster The purpose of this package is to handle the posting of periodic informational postings to the USENET. It is written in Perl, and is known to work with Perl version 4.036 (it may or may not work with earlier versions of Perl). Your distribution should contain the following files: README This file. Makefile.base The base Makefile for the package. It is configured (see below) by a script which produces a Makefile. config.awk The script used to configure Makefile.base and other *.base files. config.dat.in The template configuration file, which you should copy and edit to do local configuration. See below. post_faq.pl.base The pre-configured main script. post_faq.man.base The pre-configured man page for the post_faq.pl script. faqfile.pl A Perl library used by post_faq.pl. config.sample A sample post_faq.pl configuration file (see the man page for documentation of the configuration file format). PATCHLEVEL A file containing the current patch level of the package. To configure the program for your site, copy the file "config.dat.in" into config.dat (or type "make -f Makefile.base config.dat") and then edit it so that all of the defaults are correct for your site. Then, type "make -f Makefile.base Makefile" to build the Makefile, "make" to build the script and man page, and "make install" to install. The man page provides pretty thorough documentation of the program and its options. You might want to read or scan it before trying to edit config.dat, because it provides background information that you may need in order to decide what the appropriate settings are for you. The most recent version of this program is available via anonymous ftp to rtfm.mit.edu, in /pub/post_faq, or via mail to mail-server@rtfm.mit.edu (send a message with "help" in the body for more information). Please report problems to news-answers-request@mit.edu. $Id: README,v 1.7 1994/01/25 19:44:22 jik Exp $ post-faq-0.10.orig/config.awk100644 1750 1750 405 6622664125 15146 0ustar rolandwizard# post_faq.awk # Input file contains lines of the form # name value # Comment lines start with "#". # Outputs a SED script to change #name# to value BEGIN { name = ++i val = ++i } /^[^#]/ { printf "s%%#%s#%%%s%%g\n",$name,$val } post-faq-0.10.orig/config.dat.in100644 1750 1750 3456 6622664125 15572 0ustar rolandwizard# The format of this file is name value # Comment lines, obviously, start with `#'. Blank lines are also # ignored. # INSTALLATION DIRECTORIES # Where to put locally-modified executable post_faq script. bindir /afs/sipb.mit.edu/project/periodic-postings/post_faq/install/bin # Where to put perl library files that the post_faq script needs libdir /afs/sipb.mit.edu/project/periodic-postings/post_faq/install/lib # Where to put locally-modified post_faq documentation. mandir /afs/sipb.mit.edu/project/periodic-postings/post_faq/install/man/man1 # The path of the program (usually inews, but sometimes others) to # which to feed the prepared article # # If you want to call inews with arguments (e.g., if you want to # suppress signature inclusion with INN inews by passing it the "-S" # argument), then don't add the arguments here. Instead, either (a) # create a wrapper script which calls inews with the appropriate # arguments, and put it here, or (b) modify post_faq.pl.base to # include the extra argument(s) (search for "-h" in the file and add # the other arguments there). inews /afs/sipb.mit.edu/project/sipb/bin/inews # SITE INFORMATION # Path for PERL interpreter perl /usr/local/bin/perl # The host name to put into Message IDs after the '@' idhost rtfm.mit.edu # The defaut NNTP server (if not using NNTP, this setting does not # matter) server news.mit.edu # PACKAGE CONFIGURATION INFORMATION # The default posting interval; if 0, post whenever the script is run interval 0 # If nonempty, local maintainer maintainer news-answers-request@mit.edu # Signature file to append to postings, or "none" for none sigfile none # If you want Expires searching to be enabled by default on cron-like # intervals (see the man page), set this to 1. Otherwise, set it to # undef. expire_search undef post-faq-0.10.orig/config.sample100644 1750 1750 5724 6622664125 15676 0ustar rolandwizard# $Header: /afs/sipb.mit.edu/project/periodic-postings/post_faq/RCS/config.sample,v 1.1 1994/01/25 19:47:20 jik Exp $ # # Sample post_faq configuration file. # # Copyright (c) 1994 Jonathan I. Kamens. See the GNU Public License # (any version) for terms of distribution. # # Note that this entire introductory text is ignored by post_faq # because its lines start with '#'. Lines containing only whitespace # are also ignored. # The format of FAQ lines in the post_faq configuration file is as # follows: # # idname file timestamp interval sigfile force parent # # Fields are whitespace separated. Empty fields are signified by a # single period ('.'). The comment at the beginning of the parse_faq # function in faqfile.pl documents each of the fields in detail, as # does the post_faq man page, so all that information will not be # repeated here. # Here's an FAQ that has never been posted before, should be posted # every thirty days, shouldn't have any signature file appended to it, # and has no parent. # # Note that the first time the FAQ is posted, the '.' in the timestamp # field will be replaced with the timestamp of the time at which it # was posted. sample1 /home/joeruser/doc/sample1.txt . 30 none . . # Here's an FAQ which is similar to the one above, but which will # posted whether it's due or not the next time post_faq is run. After # it's posted, the '1' in the force field will be replaced with '.'. sample2 /home/joeruser/doc/sample2.txt . 30 none 1 . # Here's an FAQ which will be posted whether it's due or not every # time post_faq is run, and which was last posted on January 25, 1994. sample3 /home/joeruser/doc/sample3.txt 759522778 30 none 2 . # Here's an FAQ which will never be posted, until it is unsuspended by # changing the force field to something other than -1. sample4 /home/joeruser/doc/sample4.txt . 30 none -1 . # Here's an FAQ with a signature file which will be posted on the # first Monday of every month, along with a child which will always be # posted with it and never otherwise. # # Some notes about parents and children: # # * A child will be posted only when its parent is, and never # otherwise. However, if its interval is different than its # parent's, or if its force field specifies that it should not be # posted, it might not be posted when its parent is. # * A child must appear after its parent in the configuration file. # # Note that post_faq will not put an "Expires" line in an FAQ being # posted with cron-like intervals, unless -expire_search is specified # on the command line (or expire_search is set to true in config.dat # before installing post_faq). sample5.p1 /home/joeruser/doc/sample5.p1 . '($wday == 1) && ($mday <= 7)' /home/joeruser/.signature . . sample5.p2 /home/joeruser/doc/sample5.p1 . '($wday == 1) && ($mday <= 7)' /home/joeruser/.signature . sample5.p1 # If you think that this file should contain other examples, please # let me know what you think needs to be added. post-faq-0.10.orig/faqfile.pl100644 1750 1750 33227 6622664125 15211 0ustar rolandwizard# $Id: faqfile.pl,v 1.20 1994/02/22 01:39:57 jik Exp $ # # Copyright (c) 1992 Jonathan I. Kamens. See the GNU Public License # (any version) for terms of distribution. package faqfile; $default_interval = 0; $default_sigfile = "none"; $default_force = 0; $check_duplicates = 1; $; = "\034"; # Set this only at the beginning of FAQ config file operations! $file_version = 1; sub parse_faq { # The format of an individual FAQ specification line in the config # file is as follows: # # idname file timestamp interval sigfile force parent # # The fields are separated by blank space. If the $file_version # variable is greater than 1, An entire field can be # quoted by enclosing it in single or double quotes and any # character can be quoted by preceding it by backslash. # Otherwise, fields cannot include spaces or tabs, and backslashes # are treated literally. # # A blank field should be indiated with a single period. # # idname -- The string to use as the unique name of the FAQ in the # Message ID of the posted article. # file -- The file containing the text of the FAQ. This should be # readable from the current directory. # timestamp -- The timestamp of when the article was last posted. # If unspecified, the article is assumed not to have been # posted. This field is filled in automatically by the program # when it rewrites the config file after doing a set of # postings. # interval -- If a number, the number of days to wait after the # last posting before posting the FAQ again. Defaults to the # interval hard-coded into the program, or to the interval # specified with the "-interval" command-line option. # # If not a number, and the $file_version variable is greater # than 1, then a perl expression to be evaluated to determine # whether or not to post the FAQ. When the expression is # evaluated, the following variables will be defined: # # $minute the current minute in the hour, 0 through 59 # $hour the current hour, 0 through 23 # $mday the current day of the month, 0 through 31 # $month the current month, 0 through 11 # $year the current year # $wday the current day of the week, 0 through 6 (0 is # Sunday) # $yday the current day in the year # $interval the number of days since the last posting, or # undef if there is no previous posting timestamp # # The expression should evaluate to true if the FAQ should be # posted. # # sigfile -- The signature file to append to the bottom of the # message, with "-- \n" prepended to it. If unspecified, # defaults to the hard-coded path or to the file specified with # "-sigfile". If "none", don't include a signature file. So, # you can't have a signature file named "none" in the current # working directory; use "./none". So sue me. # force -- If specified, then treat the contents as a number. If # it is 0, then never force the posting of this article. If it # is a 1, then force the posting of this article just once, and # replace the 1 with an empty field ('.') when done doing so. # If it is a 2, then always force the posting of this article. # If it is a 3, then force the posting of this article just # once, and replace the 3 with -2 when done doing so. If it is # a -1 or -2, then force the article NOT to be posted, no matter # what. Any other values are illegal. If not specified, the # hard-coded force parameter or the presence or absence of # "-force" on the command line is used to decide whether or not # to force. # parent -- The ID name of the parent article of this one, if any. # The parent's FAQ specification must appear earlier in the # config file than the child's. If a parent is specified, then # the child article will not be posted unless the parent was # posted successfully. Note that *if* the parent posts # successfully, the child won't post unless its interval has # expired, so if you want the child to post whenever the parent # did, make sure to use "force" (see above). # # Blank lines, lines with only whitespace, and lines starting with # '#' in the config file are ignored. local($line) = @_; local($whitespace); local(@fields); return undef if (($line =~ /^[ \t]*$/) || ($line =~ /^\#/)); if ($file_version < 2) { @fields = split(' ', $line); } else { ($whitespace, @fields) = &split_fields($line); } if (! @fields) { warn "Malformatted FAQ specification \"$line\". Ignoring FAQ.\n"; return undef; } elsif (@fields != 7) { warn "Wrong number of fields in FAQ specification \"$line\". Ignoring FAQ.\n"; return undef; } local($idname) = shift @fields; if ($idname eq "") { warn "No ID name specified in FAQ specification \"$line\". Ignoring FAQ.\n"; return undef; } if ($check_duplicates && $faqs{$idname,"file"}) { warn "Duplicate ID name $idname. Ignoring FAQ.\n"; return undef; } local($file) = shift @fields; if ($file eq "") { warn "No file specified in FAQ specification in \"$line\". Ignoring FAQ.\n"; return undef; } local($timestamp) = shift @fields; if ($timestamp eq ".") { $timestamp = undef; } elsif ($timestamp !~ /^[0-9]+$/) { warn "Timestamp \"$timestamp\" in FAQ specification \"$line\" is invalid. Ignoring FAQ.\n"; return undef; } local($interval) = shift @fields; if ($interval eq ".") { $interval = undef; } elsif ($interval !~ /^[0-9.]+$/) { if ($file_version < 2) { warn "Interval \"$interval\" in FAQ specification \"$line\" is invalid. Ignoring FAQ.\n"; return undef; } } local($sigfile) = shift @fields; ($sigfile = undef) if ($sigfile eq "."); local($force) = shift @fields; if ($force eq ".") { $force = undef; } elsif (($force !~ /^(-|)[0-9]+$/) || ($force < -2) || ($force > 3)) { warn "Force parameter \"$force\" in FAQ specification \"$line\" is invalid. Ignoring FAQ.\n"; return undef; } local($parent) = shift @fields; if ($parent eq ".") { $parent = undef; } elsif (! $faqs{$parent,"file"}) { warn "FAQ specification \"$line\" has unknown parent \"$parent\". Ignoring FAQ.\n"; return undef; } $faqs{$idname,"file"} = $file; $faqs{$idname,"timestamp"} = $timestamp; $faqs{$idname,"interval"} = $interval; $faqs{$idname,"sigfile"} = $sigfile; $faqs{$idname,"force"} = $force; $faqs{$idname,"parent"} = $parent; if ($file_version > 1) { $faqs{$idname,'whitespace'} = $whitespace; } else { $faqs{$idname,"configline"} = $line; } return($idname, eval "\"$file\"", $timestamp, $interval ? $interval : $default_interval, $sigfile ? $sigfile : $default_sigfile, $force ? $force : $default_force, $parent); } sub get_file { $faqs{$_[0],"file"}; } sub get_timestamp { $faqs{$_[0],"timestamp"}; } sub get_interval { if ($faqs{$_[0],"file"}) { $faqs{$_[0],"interval"} || $default_interval; } else { undef; } } sub get_sigfile { if ($faqs{$_[0],"file"}) { $faqs{$_[0],"sigfile"} || $default_sigfile; } else { undef; } } sub get_force { if ($faqs{$_[0],"file"}) { $faqs{$_[0],"force"} || $default_force; } else { undef; } } sub get_parent { $faqs{$_[0],"parent"}; } sub set_posted { $faqs{$_[0],"posted"}++; } sub set_name { local($old, $new) = @_; for ("file", "timestamp", "interval", "sigfile", "force", "parent", "configline") { $faqs{$new,$_} = $faqs{$old,$_}; } &delete($old); } sub set_file { return if (! $_[1]); $faqs{$_[0],"file"} = $_[1]; } sub set_timestamp { local($idname, $timestamp) = @_; ($timestamp = ".") if (! $timestamp); $faqs{$idname,"timestamp"} = $timestamp; } sub set_interval { local($idname, $interval) = @_; ($interval = ".") if (! $interval); $faqs{$idname,"interval"} = $interval; } sub set_sigfile { local($idname, $sigfile) = @_; ($sigfile = ".") if (! $sigfile); $faqs{$_[0],"sigfile"} = $sigfile; } sub set_force { local($idname, $force) = @_; ($force = ".") if (! $force); $faqs{$idname,"force"} = $force; } sub set_parent { local($idname, $parent) = @_; ($parent = ".") if (! $parent); $faqs{$idname,"parent"} = $parent; } sub configline { local($id) = $_[0]; local($_); local($fi, $t, $i, $s, $fo, $p) = ($faqs{$id,"file"}, $faqs{$id,"timestamp"}, $faqs{$id,"interval"}, $faqs{$id,"sigfile"}, $faqs{$id,"force"}, $faqs{$id,"parent"}); $t = "." if (! $t); $i = "." if (! $i); $s = "." if (! $s); $fo = "." if (! $fo); $p = "." if (! $p); if ($file_version > 1) { local($line, @whitespace); @whitespace = split($;, $faqs{$id,"whitespace"}); $line = shift @whitespace; for ($id, $fi, $t, $i, $s, $fo, $p) { s/[\'\"\\ \t]/$1/g; $line .= $_ . (shift @whitespace); } # Catch any whitespace at the end of the line $line .= (shift @whitespace) if (@whitespace); # This needs to be "return $line" rather than just "$line", because # it's local to this block, because of a bug in Perl 4.036, which # Larry said he'll figure out how ti fix in Perl 5. return $line; } else { if ($faqs{$id,"configline"} !~ s/^(\s*)[^\s]+(\s+)[^\s]+(\s+)[^\s]+(\s+)[^\s]+(\s+)[^\s]+(\s+)[^\s]+(\s+)[^\s]+(\s*)$/$1$id$2$fi$3$t$4$i$5$s$6$fo$7$p$8/) { die sprintf("possible internal error in faqfile'configline\n(For archive name %s, configline is\n%s", $id, $faqs{$id,"configline"}); } $faqs{$id,"configline"}; } } sub was_posted { $faqs{$_[0],"posted"}; } sub timestamp { $faqs{$_[0],"timestamp"}; } sub new_configline { local($idname, $file, $timestamp, $interval, $sigfile, $force, $parent) = @_; local($_); if ($file_version > 1) { for ($idname, $file, $timestamp, $interval, $sigfile, $force, $parent) { s/([\'\"\\ \t])/$1/g; } } sprintf("%s\t%s\t%s\t%s\t%s\t%s\t%s", $idname, $file, $timestamp ? $timestamp : ".", $interval ? $interval : ".", $sigfile ? $sigfile : ".", $force ? $force : ".", $parent ? $parent : "."); } sub delete { local($name) = @_; for ("file", "timestamp", "interval", "sigfile", "force", "parent", "configline", "whitespace") { delete $faqs{$name,$_}; } } sub split_fields { local($_) = $_[0]; local(@fields); local(@whitespace); local($whitespace); while (1) { if (s/^(\s*)([\"\'])(([^\2\\]|\\.)*)\2//) { push(@whitespace, $1); push(@fields, $3); } elsif (/^\s*[^\'\"]/ && s/^(\s*)(([^\\ \t]|\\.)+)//) { push(@whitespace, $1); push(@fields, $2); } else { return undef if (/\S/); push(@whitespace, $_); last; } } grep(s/\\(.)/$1/g, @fields); $whitespace = join($;, @whitespace); ($whitespace, @fields); } sub should_post { local($idname, $time) = @_; local($parent); local($post_interval); local($timestamp); local($second, $minute, $hour, $mday, $month, $year, $wday, $yday, $interval); local($do_post); local($force); # Uses the following criteria to determine whether or not an FAQ # should be posted: # 1. If its force field is negative, don't post. # 2. If it has a parent that wasn't posted, don't post. # 3. If the force field is positive, post. # 4. If its interval field contains just a number which is smaller # than the number of days since the last posting, then post. # 5. If the interval field contains something other than a number, # then evaluate it as described in the comments above and post if # it is true. This only works if $file_version > 1. # 6. Otherwise, don't post. if (($force = &get_force($idname)) < 0) { return(0, "force field is negative"); } elsif (($parent = &get_parent($idname)) && !&was_posted($parent)) { return(0, "parent was not posted"); } elsif ($force) { return(1, "force field is positive"); } $post_interval = &get_interval($idname); $timestamp = &get_timestamp($idname); if ($timestamp) { $interval = (time - $timestamp) / (60 * 60 * 24); } if ($post_interval =~ /^[0-9]+$/) { local($scheduled); return(1, "no previous timestamp") if (! $interval); return(1, "posting interval expired") if ($interval > $post_interval); $scheduled = &date($timestamp + 60 * 60 * 24 * $post_interval); return(0, "scheduled to be posted on or around $scheduled"); } else { ($second, $minute, $hour, $mday, $month, $year, $wday, $yday) = localtime($time || time); $year += 1900; $do_post = eval $post_interval; if ($@) { local($foo) = "Interval expression \"$post_interval\" had error during eval: $@"; warn "$foo.\n"; return(0, $foo); } return(1, "interval expression \"$post_interval\" is true") if $do_post; return(0, "interval expression \"$post_interval\" is false"); } } sub expire_search { local($idname, $time) = @_; local($count); local($timeout, $reason); return undef if (! &get_interval($idname)); $time = time if (! $time); while (1) { $time += 60 * 60 * 24; # one day ($timeout, $reason) = &should_post($idname, $time); return $time if ($timeout); warn "Finished $count iterations for $idname in \&faqfile'expire_search; Possibly looping?\n" if ((++$count % 100) == 0); } } @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); sub date { ($sec, $min, $hour, $mday, $mon, $year) = localtime($_[0]); sprintf("%s %d, %d", $months[$mon], $mday, 1900 + $year); } 1; post-faq-0.10.orig/post_faq.man.base100644 1750 1750 25350 6622664126 16466 0ustar rolandwizard.\" $Id: post_faq.man.base,v 1.19 1994/02/23 21:43:03 jik Exp $ .\" .\" Copyright (c) 1991 Jonathan I. Kamens. See the GNU Public License .\" (any version) for terms of distribution. .\" .TH post_faq.pl 1 .SH NAME post_faq.pl \- post a USENET periodic posting .SH SYNOPSIS post_faq.pl .BI \-config " filename" [ .B \-interval .I days | .I expression ] [ .BI \-inewscmd " command" ] [ .BI \-server " server" ] [ .BI \-idhost " hostname" ] [ .BI \-sigfile " filename" ] [ .BI \-only " list" | .BI \-omit " list" ] [ .BI \-quiet " level" ] [ .B \-force ] [ .B \-expire_search ] [ .B \-debug ] .SH DESCRIPTION The .I post_faq.pl .IR perl (1) script reads USENET periodic postings (a.k.a. "FAQs") and posts them with appropriate .BR Message-ID , .BR Expires , .BR Supersedes , and .B References headers added. If, when reading an FAQ in order to post it, the script sees a string in the format "@message-id idname@", then it will substitute in place of it the Message ID that it thinks would be used to post the posting with ID name "idname" during the current run of posting. I realize that the previous sentence is extremely confusing; if you don't understand it, and you want to use Message ID substitution, then you can read the script to see exactly what it does :-). Similarly, if the script sees a string in the format "@old-id idname@", it will look for a posting with the specified ID name earlier in the configuration file, and substitute the Message ID used the last time that posting was posted. A warning is printed if the specified posting was not encountered earlier in the configuration file, in which case the string "" is substituted. These "@...@" escapes are meant to be used in the body of a posting; don't use them to put the Message-ID and Supersedes fields into a posting header, since the script will do that automatically. The following command-line options are supported, and may be specified in any order: .TP .BI \-config " filename" Specifies the configuration file from which to read information about the FAQs that should be posted. See the section entitled "CONFIGURATION FILE" below for a description of the format of the file. This option must be specified, since a configuration file must be provided. .TP .BI \-interval " days \fR|\fI expression" If a number is specified, it is the default periodicity (in days) with which FAQs should be posted. If the script is run and the interval for an FAQ has not expired, a message to that effect is printed and the FAQ is not posted. This is useful if you want to (for example) run the script once a day from .IR cron (8), and have it automatically figure out when to post. The default interval is #interval#\c .ie #interval#=0 , which .el \&. An interval of 0 means that posting always occurs (and that no .B Expires header is added to the posting). If a non-numerical expression is specified, then it is evaluated to determine whether or not the FAQ should be posted. When the expression is evaluated, the following variables are set: $minute (the current minute in the hour), $hour (the current hour), $mday (the current day of the month), $month (the current month, 0 through 11), $year (the current year), $wday (the current day of the week, 0 through 6, 0 is Sunday), $yday (the current day in the year), and $interval (the number of days since the last posting, or undef if there is no previous posting timestamp). For example, to post every monday, use `$wday==1'. To post on the seventh of every month, use `$mday==7'. To post on the second Monday in every month, use `$wday==1 && $mday>7'. You will probably want to use single quotes to protect the interval expression you specify from the shell. Also, beware of using something like `1' as an expression to always post the FAQ, since that will be interpreted as a numerical interval value. Note that specifying an interval expression of `$interval>x', where `x' is some integer, is equivalent to just specifying `x' as the interval expression. If an FAQ is posted with forcing enabled (see the .B \-force option below), then the interval is ignored. Also, note that intervals specified in the configuration file override both the default and the interval specified on the command line. .TP .BI \-inewscmd " command" Specifies the command to pipe into to post the message. Defaults to "#inews#". Note that if you specify the .B \-debug option (see below) and also specify a posting command with this option, the command you specify .B will be used, even though debugging is enabled. .TP .BI \-server " server" Specifies an NNTP server to put into the NNTPSERVER environment variable before running the posting command. Defaults to "#server#". If you don't use NNTP, you don't have to do anything with this. .TP .BI \-idhost " hostname" Specifies the host name to put after the `@' in the Message ID. Defaults to "#idhost#". .TP .BI \-sigfile " filename" Specifies the default signature file, which should contain a signature to be appended to the bottom of the posted message, preceded by "-- \en". .ie "#sigfile#"none" The default is no signature. .el \{\ Defaults to "#sigfile#". If "none" is specified, then no signature will be appended. Signature file specifications in the configuration file override the default and the command-line specification. .\} .TP .BI \-only " list" A comma-separated list of the ID names (see the "CONFIGURATION FILE" section) of the FAQs that should be examined and posted if necessary. The other FAQs in the configuration file will be ignored. This option takes precedence over the .B \-omit option (see below). .TP .BI \-omit " list" A comma-separated list of the ID names of FAQS that should be ignored. If .B \-only is specified, then this option is ignored. .TP .BI \-quiet " level" Specifies how quiet .I post_faq.pl should be when performing its work. The default is 0. If 1 is specified, then progress messages will not be printed, but reports of successful posting will. If 2 is specified, then reports of successful posting will also be omitted, and only errors will be printed. .TP .B \-expire_search When an evaluated Perl expression, rather than a number, is specified for an interval (as described above), .I post_faq.pl normally will not insert an .B Expires header in the posted FAQ. However, if .B \-expire_search is specified, or if it is enabled by default when .I post_faq.pl is installed, then the script will attempt to search forward for the next posting date for the FAQ, and use that as the basis for an .B Expires header. It does this by counting forward one day at a time and checking if the FAQ should be posted at each subsequent time. Note that if the interval expression is worded in such a way that this forward counting will never land on a timestamp when the FAQ would be posted, the script will loop forever trying to determine when the posting should expire. Therefore, the script prints a warning for every 100 days it goes into the future, to draw the user's attention to a possible infinite loop. .TP .B \-force Forces FAQs to be posted even if they should not be when judging by their timestamps and posting intervals. Force specifications in the configuration file override this flag (i.e., if the configuration file says not to force an FAQ, it will not be forced even when this flag is specified, and if the configuration file says to force, it will be forced even if this flag is omitted). .TP .B \-debug Turns on debugging. The message is sent to stdout instead of posted, and timestamp files are not changed in any way. .SH CONFIGURATION FILE Each line in the configuration file (excluding lines containing whitespace only and lines starting with '#', which are ignored) represents one FAQ for the program to deal with. Each line contains seven whitespace-separated fields: idname, file, timestamp, interval, sigfile, force, and parent. Empty fields (for the timestamp, interval, sigfile, force and parent fields, which are allowed to be empty) are indicated with a single period. A field can be enclosed in single or double quotes to protect whitespace inside it, and a backslash can be used to quote any character in a field (including quotes and whitespace). The meaning of each field is as follows: .TP .B idname The ID name of the FAQ. Each FAQ in the configuration file must have a unique ID name. The name is used by .I post_faq.pl when printing messages about the FAQ and when creating its Message-ID. Also, it is used to specify FAQs with the .B \-only and .B \-omit options (see above). .TP .B file The file in which the text of the FAQ is located. It should be in the correct format for a USENET posting, including a posting header (excluding the header fields that will be added by .IR post_faq.pl ). .TP .B timestamp The timestamp of when the FAQ was last posted. If adding an FAQ to the configuration file for the first time, this should contain a period. .I post_faq.pl will update this field in the configuration file when it posts the FAQ. .TP .B interval The posting interval, as described above. If unspecified, the default or command-line-specified interval is used. Be careful to quote the interval if you are using an expression with spaces or tabs in it. .TP .B sigfile The signature file, as described above. If unspecified, the default or command-line-specified signature file is used. .TP .B force Whether or not to force the posting of the FAQ, ignoring the interval. If unspecified, the default or command-line-specified value is used. If specified, it should be one of the following numbers: .RS .IP 0 Don't force -- post the FAQ if its interval says that it should be posted. .IP 1 Force the FAQ to be posted the next time .I post_faq.pl is run, and then switch the force field back to the default value. .IP 2 Always force the FAQ to be posted, without changing the force field when done. .IP 3 Force the FAQ to be posted the next time .I post_faq.pl is run, and then set the force field to -2. .IP "-1 or -2" Never post the FAQ. .PP Any other values are illegal. .RE .TP .B parent The ID name of the parent article of this one. The parent must appear earlier in the configuration file. If specified, then the current FAQ will not be posted unless the parent FAQ was posted successfully. However, note that if the interval for the current FAQ has not expired, it will not be posted even if the parent was posted, unless "force" is true as well. .SH FILES The files used by .I post_faq.pl are the configuration file specified on the command line and the files, specified in the configuration file, containing the text of each FAQ. Furthermore, note that a backup of the configuration file with a ".old" extension is saved when the script is run without the .B \-debug option. .SH AUTHOR Jonathan I. Kamens . .if !"#maintainer#"" \{\ .SH LOCAL MAINTAINER #maintainer# .\} .SH SEE ALSO perl(1), inews(1), cron(8) .SH DIAGNOSTICS Should be self-explanatory. post-faq-0.10.orig/post_faq.pl.base100755 1750 1750 20701 6622664126 16324 0ustar rolandwizard#!#perl# # # $Id: post_faq.pl.base,v 1.42 1994/11/01 17:36:25 tkoenig Exp $ # # Copyright (c) 1991 Jonathan I. Kamens. See the GNU Public License # (any version) for terms of distribution. push(@INC, "#libdir#"); require 'faqfile.pl'; $SIG{'PIPE'} = 'sigpipe'; # These variables can be overridden by command-line options. $server = '#server#'; # News server to which to connect, if NNTP $default_inews = "#inews#"; # Inews program to use $idhost = '#idhost#'; # Host name to put in Message ID's $configfile = undef; $faqfile'file_version = 2; $expire_search = #expire_search#; # These can be overridden by each FAQ. $faqfile'default_interval = #interval#; # Default interval to wait between postings $faqfile'default_sigfile = "#sigfile#"; # Signature file to append to posting $faqfile'default_force = 0; # Force posting of this FAQ? # These can't be overridden at all without editing the script. @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); # This controls the number of days added to the posting interval in # order to determine how many days into the future the "Expires" # header date should be set. I've picked a value of 14, which # means that I'm assuming that an article will make it to the entire # USENET within 14 days of when it is posted. $expire_slop = 14; %faqs = (); %only = (); %omit = (); $quiet = 0; $newstamp = time; $usage = "Usage: $0 -config file-name [ -interval days ] [ -inewscmd command ] [ -server nntp-server ] [ -idhost host-name ] [ -sigfile file-name ] [ -quiet number ] [ -omit id-list ] [ -only id-list ] [ -force ] [ -expire_search ] [ -debug ]"; # Parse command line arguments while ($_ = $ARGV[0], /^-/) { shift; if (/^-interval$/) { ((@ARGV > 0) || die "Missing argument to \"-interval\" option.\n") && ($faqfile'default_interval = shift) && next; } elsif (/^-inewscmd$/) { ((@ARGV > 0) || die "Missing argument to \"-inewscmd\" option.\n") && ($inews = shift) && next; } elsif (/^-server$/) { ((@ARGV > 0) || die "Missing argument to \"-server\" option.\n") && ($server = shift) && next; } elsif (/^-idhost$/) { ((@ARGV > 0) || die "Missing argument to \"-idhost\" option.\n") && ($idhost = shift) && next; } elsif (/^-sigfile$/) { ((@ARGV > 0) || die "Missing argument to \"-sigfile\" option.\n") && ($faqfile'default_sigfile = shift) && next; } elsif (/^-config$/) { ((@ARGV > 0) || die "Missing argument to \"-config\" option.\n") && ($configfile = shift) && next; } elsif (/^-quiet$/) { ((@ARGV > 0) || die "Missing argument to \"-quiet\" option.\n"); $quiet = shift; next; } elsif (/^-omit$/) { if (@ARGV > 0) { foreach $i (split(/,/, shift)) { $omit{$i}++; } next; } else { die "Missing argument to \"-omit\" option.\n"; } } elsif (/^-only$/) { if (@ARGV > 0) { foreach $i (split(/,/, shift)) { $only{$i}++; } next; } else { die "Missing argument to \"-only\" option.\n"; } } elsif (/^-force$/) { ($faqfile'default_force = 2) && next; } elsif (/^-debug$/) { ++$debug && next; } elsif (/^-expire_search$/) { ++$expire_search && next; } die "Unknown option \"$_\".\n$usage\n"; } die "No config file specified!\n$usage\n" if (! $configfile); ($faqfile'default_sigfile = undef) if ($faqfile'default_sigfile eq "none"); if (! defined($inews)) { if ($debug) { $inews = "cat"; } else { $inews = $default_inews . " -h"; } } $ENV{'NNTPSERVER'} = $server; if ($debug) { $configin = $configfile; $configout = "/dev/null"; print "Not modifying config file, because -debug specified.\n" if ($quiet < 1); } else { if (-z $configfile) { die "Configuration file is zero size.... aborting!\n"; } $configin = "$configfile.old"; $configout = $configfile; rename($configout, $configin) || die "Renaming $configout: $!.\n"; } open(CONFIG, "$configin") || die "Opening $configin to read: $!.\n"; open(CONFIGOUT, ">$configout") || die "Opening $configout to write: $!.\n"; while () { chop; local($idname, $file, $oldstamp, $interval, $sigfile, $force, $parent) = &faqfile'parse_faq($_); ($sigfile = $faqfile'default_sigfile) if (! $sigfile); if (! $idname) { print CONFIGOUT $_, "\n" || die "Writing to $configout: $!.\n"; next; } if (%only) { if (!$only{$idname}) { print "Skipping $idname because of -only.\n" if ($quiet < 1); goto nextone; } } elsif (%omit) { if ($omit{$idname}) { print "Skipping $idname because of -omit.\n" if ($quiet < 1); goto nextone; } } ($timeout, $reason) = &faqfile'should_post($idname); if (! $timeout) { print("Skipping $idname ($reason).\n") if ($quiet < 1); goto nextone; } else { print "Posting $idname ($reason).\n" if ($quiet < 1); $inews_pid = open(INEWS, "|$inews"); open(FAQ, $file) || (warn("Opening $file (for $idname): $!.\n"), goto nextone); printf(INEWS "Message-ID: %s\n", &message_id($idname, $newstamp, $idhost)) || (warn("Printing to $inews pipe: $!.\n"), goto nextone); if ($oldstamp) { printf(INEWS "Supersedes: %s\n", &message_id($idname, $oldstamp, $idhost)) || (warn("Printing to $inews pipe: $!.\n"), goto nextone); } $expire_time = undef; if ($interval =~ /^[0-9]+$/) { if ($interval > 0) { $expire_time = $newstamp + ($interval + $expire_slop) * (60 * 60 * 24); } } elsif ($expire_search) { $expire_time = &faqfile'expire_search($idname, $newstamp) + $expire_slop * (60 * 60 * 24); } if ($expire_time) { ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime($expire_time); $year += 1900; printf(INEWS "Expires: %d %s %d %02d:%02d:%02d GMT\n", $mday, $months[$mon], $year, $hour, $min, $sec) || (warn("Printing to $inews pipe: $!.\n"), goto nextone); } if ($parent) { printf(INEWS "References: %s\n", &message_id($parent, &faqfile'timestamp($parent), $idhost)) || (warn("Printing to $inews pipe: $!.\n"), goto nextone); } while () { while (/\@message-id +([^ \@]+) *\@/i) { local($newid) = &message_id($1, $newstamp, $idhost); $_ = $` . $newid . $'; #` } while (/\@old-id +([^ \@]+) *\@/i) { local($time) = &faqfile'timestamp($1); local($newid); if ($time) { $newid = &message_id($1, $time, $idhost); } else { warn "$idname requests Message ID of unknown posting $1.\n"; $newid = ""; } $_ = $` . $newid . $'; #` } print INEWS $_ || (warn("Printing to $inews pipe: $!.\n"), goto nextone); } if ($sigfile && ($sigfile ne "none")) { if (! open(SIGFILE, $sigfile)) { warn "Opening \"$sigfile\": $!.\nSignature will not be included on $idname.\n"; } else { print INEWS "-- \n" || (warn("Printing to $inews pipe: $!.\n"), goto nextone); while () { print INEWS $_ || (warn("Printing to $inews pipe: $!.\n"), goto nextone); } } } close(INEWS); $inews_pid = undef; if ($?) { warn "$inews exited with non-zero status posting $idname.\n"; goto nextone; } close(FAQ); printf("Article %s posted successfully.\n", &message_id($idname, $newstamp, $idhost)) if ($quiet < 2); if ($force == 1) { &faqfile'set_force($idname, undef); print "Force disabled on $idname.\n" if ($quiet < 2); } elsif ($force == 3) { &faqfile'set_force($idname, -2); print "Force replaced with suspend on $idname.\n" if ($quiet < 2); } &faqfile'set_posted($idname); &faqfile'set_timestamp($idname, $newstamp); } nextone: kill('TERM', $inews_pid) if ($inews_pid); print CONFIGOUT &faqfile'configline($idname), "\n" || die "Writing to $configout: $!.\n"; } close(CONFIG); close(CONFIGOUT) || die "Closing $configout: $!.\n"; sub message_id { # Takes three arguments -- an ID name, a time, and a host name -- # and returns the message ID to use. If you want to do custom # message ID's for some or all of your FAQs, this is the routine # to modify. # # Beware that this routine is used to generate message IDs of # parent articles as well as message IDs of articles currently # being posted, so don't put in any implicit dependencies that # won't work. local($idname, $time, $host) = @_; "<${idname}_${time}\@${host}>"; } sub sigpipe { # Don't do anything; we'll notice it because $? will be non-zero # when the file handle is closed. }