[comp.sources.unix] v22i067: ELM mail syste, release 2.3, Part08/26

rsalz@uunet.uu.net (Rich Salz) (05/26/90)

Submitted-by: Syd Weinstein <syd@dsinc.dsi.com>
Posting-number: Volume 22, Issue 67
Archive-name: elm2.3/part08

---- Cut Here and unpack ----
#!/bin/sh
# this is part 8 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file doc/newmail.1 continued
#
CurArch=8
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file doc/newmail.1"
sed 's/^X//' << 'SHAR_EOF' >> doc/newmail.1
Xit, and can internally reset 
Xitself if any of the folders shrink in size and 
Xthen grow again.
X.P
XThe default folder to monitor is always your incoming mailbox.
X.SH EXAMPLES
XSome example invocations:
X.nf
X
X	$ \fBnewmail\fR
X
X.fi
Xwill check your imcoming mailbox every 60 seconds.
X.nf
X
X	$ \fBnewmail  -i  15  joe  root\fR
X
X.fi
Xwill monitor the incoming mailboxes for ``joe'' and ``root'',
Xchecking every 15 seconds for new mail.
X.nf
X
X	$ \fBnewmail  "mary=Mary"  +postmaster=POBOX\fR
X
X.fi
Xwill monitor the incoming mailbox for user ``mary'', prefixing
Xall messages with the string ``Mary'', and the folder in 
Xthe users \fImaildir\fR directory called ``postmaster'', 
Xprefixing all of those messages with ``POBOX''.
X.P
XYou can also have more complex monitoring too, for example:
X.nf
X
X	$ \fBnewmail  -i  30  $LOGNAME=me  ${LOGNAME}su=myroot   /tmp/mbox\fR
X
X.fi
Xwill check every 30 seconds for the users mailbox, a mailbox that
Xis the users login-name with ``su'' appended (e.g. ``joe'' would
Xbecome ``joesu'') and the file /tmp/mbox, prefixing new mail
Xfor each with ``me'', ``myroot'' and ``mbox'' respectively.
X.SH AUTHOR
XDave Taylor, Hewlett-Packard Laboratories.
X.SH SEE ALSO
Xnotify in sh(1) or csh(1)
X.SH BUG REPORTS TO
XSyd Weinstein	elm@DSI.COM	(dsinc!elm)
X.SH COPYRIGHTS
X.ps 18
X\fB\(co\fR\s12 Copyright 1986, 1987 by Dave Taylor
X.br
X.ps 18
X\fB\(co\fR\s12 Copyright 1988, 1989, 1990 by The USENET Community Trust
SHAR_EOF
echo "File doc/newmail.1 is complete"
chmod 0444 doc/newmail.1 || echo "restore of doc/newmail.1 fails"
echo "x - extracting doc/printmail.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > doc/printmail.1 &&
X.TH PRINTMAIL 1L "Elm Version 2.3" "USENET Community Trust"
X.SH NAME
Xprintmail - format mail in a readable fashion for printing
X.SH SYNOPSIS
X.B printmail
X{-p}
X{filename}
X.SH DESCRIPTION
X.I Printmail
Xcopies all messages from either the file specified or the
Xdefault user mailbox with each message separated by a line of dashes.
XWith the
X.B \-p
Xoption, the messages are separated by a formfeed instead.
X.sp
XIn fact, this command is actually just a slightly differently
Xformatted call to \fIreadmsg\fR:
X.nf
X	readmsg {-p} {-f \fIfilename\fR} *
X.fi
Xwhich does all the work here.
X.SH EXAMPLE
XA typical usage of this command is;
X.nf
X
X	printmail | lpr 
X
X.fi
X.SH AUTHOR
XDave Taylor, Hewlett-Packard Laboratories.
X.SH SEE\ ALSO
Xreadmsg(1L)
X.SH BUG REPORTS TO
XSyd Weinstein	elm@DSI.COM	(dsinc!elm)
X.SH COPYRIGHTS
X.ps 18
X\fB\(co\fR\s12 Copyright 1986, 1987 by Dave Taylor
X.br
X.ps 18
X\fB\(co\fR\s12 Copyright 1988, 1989, 1990 by The USENET Community Trust
SHAR_EOF
chmod 0444 doc/printmail.1 || echo "restore of doc/printmail.1 fails"
echo "x - extracting doc/readmsg.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > doc/readmsg.1 &&
X.TH READMSG 1L "Elm Version 2.3" "USENET Community Trust"
X.SH NAME
Xreadmsg - read messages from incoming mail
X.SH SYNOPSIS
X.B readmsg 
X[\fB-p\fR]
X[\fB-n\fR]
X[\fB-f filename\fR]
X[\fB-h\fR]
X.br
X.B readmsg
X[\fB-p\fR]
X[\fB-n\fR]
X[\fB-f filename\fR]
X[\fB-h\fR]
Xnumber [number ...]
X.br
X.B readmsg 
X[\fB-p\fR]
X[\fB-n\fR]
X[\fB-f filename\fR]
X[\fB-h\fR]
Xpattern
X.br
X.SH DESCRIPTION
X.I Readmsg
Xis a program that gives the \fIelm\fR user the functionality of
Xthe mailx "~r" command from the editor of their choice.  There
Xare three different ways of using the program;
X.P
XFirst off, if you're actually creating a reply to a message
Xfrom within the \fIelm\fR system then \fIreadmsg\fR without any
Xarguments will include a summary of the headers and the body 
Xof the message being replied
Xto.  If you aren't currently editing a message the program will
Xreturn an error.
X.P
XSecondly, if you want to include certain messages, you can
Xspecify them by listing their ordinal locations in the 
Xmail file (that is, their "message numbers")
Xup to 25 at a time.  The \fImeta-\fRnumber '$' is understood to mean
Xthe last message in the mailfile.  Similarly, '*' is understood to
Xrepresent every message in the file (that is, 1-$)
X.P
XFinally, you can also specify a pattern that occurs in one of
Xthe messages as a way of including it.  This pattern can be
Xtyped in directly (no quotes) if the words are separated by a 
Xsingle space in the actual message.  The pattern matching is case
Xsensitive, so "Hello" and "hello" are NOT the same thing!!
X.sp
X.P
XThe \fB-f\fR flag indicates that you'd rather use the file specified
Xfor the operations specified rather than the default mailbox.
X.P
XThe \fB-h\fR flag instructs the program to include the entire header
Xof the matched message or messages when displaying their
Xtext.  (default is to display the From: Date: and Subject: lines
Xonly)
X.P
XThe \fB-n\fR flag instructs the program to exclude \fIall\fR
Xheaders.  This is used mostly for extracting files mailed and
Xsuch.
X.P
XFinally, the \fB-p\fR flag indicates that the program should
Xput form-feeds (control-L) between message headers.
X.sp
X.SH "EXAMPLES"
XFirst off, to use this from within \fBvi\fR to include the text of the 
Xcurrent message at the end of the current message, you could
Xuse the command;
X.nf
X
X	!!readmsg
X
X.fi
X(as you hit the 'G' the editor will put you at the bottom of the screen
Xwith the '!' prompt).
X.sp 2
XLet's look at something more interesting, however;
X.sp
XSuppose you have the mailfile;
X.nf
X
X   From joe Jun 3 1986 4:45:30 MST
X   Subject: hello
X   
X   Hey Guy!  Wanta go out and have a milk this evening?
X   
X   Joe
X   
X   From john Jun 3 1986 4:48:20 MST
X   Subject: Dinner at Eight
X   From: John Dinley <xyz!john>
X
X   Remember you should show up about eight, okay?
X
X		   - John D -
X
X   From xxzyz!cron Jun 3 1986 5:02:43 MST
X
X   Cannot connect to server: blob
X   Job 43243 deleted from queue.
X   
X.fi
XThe following commands will result in;
X.nf
X
X  $ readmsg 2		
X  [ display the second message, from John ]
X
X  $ readmsg 		
X  [ an error, unless we're calling from \fIelm\fR ]
X
X  $ readmsg BLOB	
X  [ no match - case sensitive! ]
X
X  $ readmsg -h connect to server 
X  [ displays third message, including headers ]
X
X.fi
X.SH FILES
X/usr/mail/<username>   		The incoming mail
X.br
X$HOME/.readmsg			The temp file from \fIelm\fR
X.SH AUTHOR
XDave Taylor, Hewlett-Packard Laboratories
X.SH SEE\ ALSO
Xnewmail(1L), elm(1L)
X.SH BUGS
XThe '*' metacharacter doesn't always work as expected!
X.br
XPerhaps the pattern matching should be case insensitive?
X.SH BUG REPORTS TO
XSyd Weinstein	elm@DSI.COM	(dsinc!elm)
X.SH COPYRIGHTS
X.ps 18
X\fB\(co\fR\s12 Copyright 1986, 1987 by Dave Taylor
X.br
X.ps 18
X\fB\(co\fR\s12 Copyright 1988, 1989, 1990 by The USENET Community Trust
SHAR_EOF
chmod 0444 doc/readmsg.1 || echo "restore of doc/readmsg.1 fails"
echo "x - extracting doc/tmac.n (Text)"
sed 's/^X//' << 'SHAR_EOF' > doc/tmac.n &&
X.\" @(#)$Id: tmac.n,v 4.1 90/04/28 22:41:47 syd Exp $
X.\" The News macro package
X.\"
X.\" This  is  the macro package that is used to format news documents.  It
X.\" was written because many sites do not have one of the -mm or -ms pack-
X.\" ages that the documents use.   This is NOT compatible with EITHER, but
X.\" (I hope) will become the standard for all news  documents  (man  pages
X.\" excepted, since everyone seems to have -man.)
X.\"
X.\" This package was written using  only  the  "NROFF/TROFF Users' Guide",
X.\" and  therefore  if  you  can run NROFF/TROFF, you can legitimately use
X.\" this package.  However, because NROFF/TROFF are proprietary  programs,
X.\" I  cannot  place  this  package in the public domain.  This should not
X.\" matter, because if you legitimately have  NROFF/TROFF,  you  have  the
X.\" documentation; if not, you can't run off the documentation anyway.
X.\"
X.\" This  package may be circulated freely with the news documentation; it
X.\" may not be sold, but is to be distributed with  the  unformatted  news
X.\" documents.  However,  the name of the author and the place at which it
X.\" was written (in the author's own  time,  of  course)  are  not  to  be
X.\" removed  from the package regardless of how it is modified or altered.
X.\" Further, please do not distribute this package if you make any changes
X.\" because  I  don't want to get bug reports of macros I haven't written;
X.\" if you have a goodie you want me to add, send it to me and we'll talk.
X.\" (I really do like feedback!)  I'd really appreciate your cooperation.
X.\"
X.\" Author:	Matt Bishop
X.\"		Research Institute for Advanced Computer Science
X.\"		Mail Stop 230-5
X.\" 		NASA Ames Research Center
X.\"		Moffett Field, CA  94035
X.\"
X.\" version 1.0		September 28, 1985	mab@riacs.arpa
X.\" 	initial version
X.\" version 1.1		October 25, 1985	mab@riacs.arpa
X.\"	fixed an incredibly obscure footnote bug (that occurred twice in
X.\"	the news documentation!) which put footnoted words on  one  page
X.\"	and the footnote on the next if the word was in the next-to-last
X.\"	or last line; commented it, and generally cleaned up
X.\" Version 1.2		October 27, 1985	mab@riacs.arpa
X.\"	Added a few more comments and a check to keep footnotes lined up
X.\"	with the bottom margin.
X.\" Version 1.3		February 12, 1986	mab@riacs.arpa
X.\"	Added an error check to catch unmatched ef's and ed's
X.\" Version 1.4		December 29, 1986	mab@riacs.edu
X.\"	Changed footnote for ux, pd, and vx macros and  added  a  string
X.\"	for rg ("Registered Trademark")
X.\" Version 1.5		January 2, 1989		Matt.Bishop@dartmouth.edu
X.\"	Minor modifications for nroff compatibility
X.\" Version 1.6		March 15, 1989		Matt.Bishop@dartmouth.edu
X.\"						..!bear.dartmouth.edu!bishop
X.\"	Fixed a bug in footnote handling (again, sigh ...)  This one
X.\"	occurred when the the "fo" trap position was reset just beneath
X.\"	the current line; the footnote overflow trap would kick in and
X.\"	never be closed.
X.\"
X.\"
X.\" **********
X.\" these preserve and restore various things
X.\" they are used to shorten other macros
X.de yf					\" restore fonts
X.ft \\n(f2				\" previous font
X.ft \\n(f1				\" current font
X..
X.de yi					\" restore indents
X'in \\n(i2u				\" previous indent
X'in \\n(i1u				\" current indent
X..
X.de ys					\" restore point sizes
X.ps \\n(s2				\" previous point size
X.ps \\n(s1				\" current point size
X..
X.de yv					\" restore vertical spacings
X.vs \\n(v2u				\" previous vertical spacing
X.vs \\n(v1u				\" current vertical spacing
X..
X.de ya					\" restore everything
X.yf					\" restore fonts
X.yi					\" restore indents
X.ys					\" restore point sizes
X.yv					\" restore vertical spacing
X.if \\n(f1==0 .ft CW			\" unknown font, set to CW
X..
X.de zf					\" preserve fonts
X.nr f1 \\n(.f				\" current font
X.ft					\" switch to previous font
X.nr f2 \\n(.f				\" previous font
X.ft					\" back to current font
X..
X.de zi					\" preserve indents
X.nr i1 \\n(.iu				\" current indent
X'in					\" switch to previous indent
X.nr i2 \\n(.iu				\" previous indent
X'in					\" back to current indent
X..
X.de zs					\" preserve point sizes
X.nr s1 \\n(.su				\" current point size
X.ps					\" switch to previous point size
X.nr s2 \\n(.su				\" previous point size
X.ps					\" back to current point size
X..
X.de zv					\" preserve vertical spacings
X.nr v1 \\n(.vu				\" current vertical spacing
X.vs					\" switch to previous vertical spacing
X.nr v2 \\n(.vu				\" previous vertical spacing
X.vs					\" back to current vertical spacing
X..
X.de za					\" save everything
X.zf					\" save fonts
X.zi					\" save indents
X.zs					\" save point sizes
X.zv					\" save vertical spacings
X..
X.\" **********
X.\" these actually print the header and footer titles
X.\" they are defined separately from the "hd" and "fo" macros
X.\" to make user redefinition easy
X.de pt					\" print header title
X.					\" omit header on first page
X.if \\n%>1 \{\
X'	sp |\\$1u			\" move to proper position
X.	ft 1				\" change to default font
X.	ps \\n(ps			\" change to default point size
X.	vs \\n(vs			\" change to default spacing
X.	tl '\\*(h0'\\*(h1'\\*(h2'	\" center title
X.	vs				\" restore current vertical spacing
X.	ps				\" restore current point size
X.	ft				\" restore current font
X.\}
X..
X.de pf					\" print footer title
X.ft 1					\" change to default font
X.ps \\n(ps				\" change to default point size
X.vs \\n(vs				\" change to default spacing
X.ie \\n%=1 .tl '\\*(h0'\\*(h1'\\*(h2'	\" on first page, print the header here
X.el        .tl '\\*(f0'\\*(f1'\\*(f2'	\" on other pages, print the footer
X.vs					\" restore current vertical spacing
X.ps					\" restore current point size
X.ft					\" restore current font
X..
X.\" **********
X.\" these are the top of page (header) and bottom of page (footer) macros
X.\" they don't actually print anything, just call the right macros
X.de hd					\" header -- do top of page processing
X.if t .if \\n(cm .tl '\(rn'''		\" drop cut mark if needed
X.pt \\n(ttu				\" print header
X.nr fc 0 1				\" init footnote count
X.nr fs \\n(.pu-\\n(bmu-1u		\" if any footnotes, start print here
X.nr fp 0-\\n(bmu			\" reset current footer place
X.ch fo -\\n(bmu				\" reset footer trap
X.if \\n(dn .fz				\" put leftover footnotes st bottom
X.ya					\" restore font, etc.
X'sp |\\n(tmu				\" move to top of body
X.ns					\" don't allow any more space
X..
X.de fo					\" footer -- do bottom of page processing
X.za					\" save font, etc.
X.rs					\" you want motions here
X.nr dn 0				\" clobber diversion size register
X.if \\n(fc .fd				\" now print the footnotes, if any
X'bp					\" force out page
X..
X.\" **********
X.\" these are the footnote macros
X.\" here's an overview:
X.\"	Footnotes are processed in environment #1, which is  initialized
X.\"	at the bottom of this package.  When "fn" is called, nroff/troff
X.\"	switches to this environment.  The body of the footnote is saved
X.\"	in  the  diversion  "tf" (for "temporary footnote"), so you will
X.\"	NEVER spring a trap during the first reading of a footnote. When
X.\"	"ef" ("end footnote") is called,  the diversion  is  closed.  If
X.\"	this  is the first footnote on the page (ie, the number register
X.\"	"fc" is 1), and the footnote height (plus the height of 1  line)
X.\"	crosses  the  bottom  margin,  you get the footnoted word on one
X.\"	page and the footnote on the other.  In this case we  just  call
X.\"	"fo"  manually  (taking case it cannot be re-invoked on the same
X.\"	page!)  If this situation does not occur,  we  just  adjust  the
X.\"	footer  trap's  position upwards (we'll get to how far in a min-
X.\"	ute); if this puts the trap above the current line,  we  reposi-
X.\"	tion  the trap just beneath the current line to be sure of trig-
X.\"	triggering it once the current line is forced out.
X.\"	 To reposition the footer trap, we proceed as  follows.  Because
X.\"	the  trap  may be sprung in the middle of a line, it is possible
X.\"	that the footnote will not fit on the page (regardless of  where
X.\"	on the page the footnoted word occurs -- really!) if we move the
X.\"	trap up by the size of  the  footnote  diversion  "tf".  So,  we
X.\"	fudge things a little bit -- for the first footnote on each page
X.\"	we move the footer trap up 1 extra line ("line" being 1v in env-
X.\"	ironment  #0).   Unless  the point size and vertical spacing are
X.\"	increased between the first footnote and the footer trap's being
X.\"	sprung,  this  will  keep  the footnotes on the same page as the
X.\"	footnoted word.  But as there may be now as much as 1v of  space
X.\"	between the footnote and the bottom margin, which looks HIDEOUS,
X.\"	we use the number register "fs" to mark where  the  footer  trap
X.\"	would  REALLY go, and just space to it when it comes time to put
X.\"	out the footnotes.
X.de fd					\" dump footnotes
X.nr gs 1v				\" get a measure of 1 line in env #0
X.ev 1					\" switch to footnote environment
X.nr gs +2v				\" min of 2 lines of footnotes
X.					\" if the number register ns > 0,
X.					\" the last text line may contain a
X.					\" footnote that is too big to fit;
X.					\" this checks for such a note and
X.					\" if so, forces the footnote into
X.					\" the "fy" diversion that carries
X.					\" it onto the next text page
X.ie (\\n(nsu>0)&(\\n(gsu>=\\n(.tu) 'sp \\n(gsu	\" be sure you can get it down
X.el .if \\n(fsu>\\n(nlu 'sp \\n(fsu-\\n(nlu	\" move to footnote start position
X'nf					\" don't reprocess footnotes
X'in 0					\" don't indent them any more either
X.tf					\" drop text of footnotes
X.rm tf
X.if '\\n(.z'fy' .di			\" end overflow diversion, if any
X.nr fc 0				\" re-init footnote count
X.ev					\" return to usual environment
X..
X.de fn					\" start footnote
X.					\" look for nested footnotes -- ILLEGAL
X.ie \\n(if>0 .er "footnote within footnote"
X.el .da tf				\" append footnote to footnote diversion
X.nr if +1				\" increment level of footnoting
X.nr fc +1				\" one more footnote on this page
X.if \\n(fc=1 .nr fp -1v			\" The reason for this "fudge factor"
X.					\" is that there is no way to force
X.					\" NROFF/TROFF to invoke a macro at
X.					\" the end of each line.  At times,
X.					\" the trap boundary will not match up
X.					\" with the bottom of a line, so the
X.					\" "fo" trap which is set at 2320 may
X.					\" not be triggered until 2340 -- and
X.					\" then the footnote won't fit.  This
X.					\" gives some slack so the footnote is
X.					\" more likely to fit. *sigh*
X.ev 1					\" enter footnote environment
X.if \\n(fc=1 .fs			\" drop separator if first footnote
X.br					\" flush out any previous line in footnote
X.fi					\" process footnote in fill mode
X..
X.de ef					\" end footnote
X.br					\" flush out the line in footnote
X.ie \\n(if<=0 .er "end footnote has no corresponding begin footnote"
X.el \{\
X.	nr if -1			\" decrement level of footnoting
X.	nr fg 2v			\" remember this for repositioning fo
X.	ev				\" back to usual environment
X.	if \\n(if=0 \{\
X.		di			\" end of footnote proper
X.		nr fp -\\n(dnu		\" "fo" will be moved at least up this far
X.		nr fs -\\n(dnu		\" increase size of footnote
X.		ch fo \\n(fpu		\" reposition "fo" trap (first guess)
X.					\" the first part of the "ie" clause
X.					\" is taken in the special case
X.					\" described above
X.		ie (\\n(fc=1)&((\\n(nlu+1v+\\n(fgu)>=(\\n(.pu-\\n(bmu)) \{\
X.			nr ns \\n(dnu	\" suppress footnote separator
X.					\" since this footnote contains it
X.					\" keep "fo" from being invoked twice
X.			ch fo \\n(.pu+1i
X.			fo		\" force the page out AT ONCE
X.			nr ns 0		\" re-enable footnote separator
X.		\}
X.					\" footnote won't fit completely
X.					\" invoke the footer trap but
X.					\" don't worry about the footnote
X.					\" separator (it's already there)
X.		el .if (\\n(nlu+1v)>=(\\n(.pu+\\n(fpu) \{\
X.					\" as before we must reposition the
X.					\" "fo" trap to prevent "fo" from
X.					\" being invoked twice
X.			ch fo \\n(.pu+1i
X.			fo		\" force the page out AT ONCE
X.		\}
X.	\}
X.\}
X..
X.de fs					\" drop footnote separator
X.					\" only if not already dropped
X.if \\n(ns=0 \l'1i'
X.nr ns 0				\" in case footnotes are over 1 page long
X..
X.de fx					\" process footnote overflow
X.if \\n(fc .di fy			\" stuff them in the right place
X..
X.de fz					\" deposit footnote overflow
X.fn					\" treat it as a footnote
X.nf					\" it's already been processed
X.in 0					\"   and indented
X.fy					\" "fx" put it here
X.ef					\" end the footnote
X..
X.\" **********
X.\" the ones after here are user-invoked (like "fn" and "ef" above)
X.\" title, author, etc.
X.de mt					\" main title
X\&
X.sp |\\n(mtu				\" space
X.ft 3					\" in bold
X.ps \\n(ps+2p				\" large point size and
X.vs \\n(vs+2p				\" vertical spacing
X.ce 1000				\" center the title
X.nr t2 1				\" space it
X..
X.de au					\" author
X.nr t2 0				\" spacing here
X.sp 2v					\" space
X.ft 2					\" in italics
X.ps \\n(ps				\" usual point size and
X.vs \\n(vs				\" vertical spacing
X.ce 1000				\" center the name(s)
X..
X.de ai					\" author's institution
X.if \\n(t2 .sp 2v			\" space after a title
X.nr t2 0				\" institution
X.ft 2					\" in italics
X.ps \\n(ps				\" usual point size and
X.vs \\n(vs				\" vertical spacing
X.ce 1000				\" center the name(s)
X..
X.de bt					\" begin text macro
X.nr t2 0				\" hold it here
X.nr it +1				\" mark as called
X.ce 0					\" end any centering
X.sn 3v					\" a little bit of space
X..
X.\" paragraph
X.de si					\" start indented section
X.nr lo \\n(lm				\" remember the current level
X.nr lm +1				\" go to the next level
X.ie '\\$1'' .nr l\\n(lm \\n(l\\n(lo+5n	\" if no arg, indent 5n
X.el         .nr l\\n(lm \\$1n		\" otherwise, indent that much
X..
X.de ei					\" end indent
X.nr lm -1				\" down one level
X.if \\n(lm<0 .nr lm 0			\" make sure you don't go too far
X..
X.de pg					\" plain old paragraph
X.if !\\n(it .bt				\" end the title and such
X.sn \\n(pdu				\" inter-paragraph spacing
X.ft 1					\" reset a few things (paranoia)
X.					\" these ONLY if not in footnote
X.ie \\n(if=0 \{\
X.	ps \\n(ps			\" reset point size
X.	vs \\n(vs			\" reset vertical spacing
X.	ne 1v+\\n(.Vu			\" slightly more than 1 line
X.\}
X.el \{\
X.	ps \\n(ps-2p			\" reset point size
X.	vs \\n(vs-2p			\" reset vertical spacing
X.\}
X.in \\n(l\\n(lmu			\" stop any indenting
X.ce 0					\" stop any centering
X.if !'\\$1'L' .if !'\\$1'l' .ti +\\n(piu	\" indent the sucker
X..
X.de lp					\" labelled paragraph
X.pg l					\" reset paragraph
X.if \\n(.$>1 .nr li \\$2n		\" if indent given use it
X.in +\\n(liu				\" indent for paragraph
X.ti -\\n(liu				\" force first line NOT to indent
X.ta +\\n(liu				\" for the label
X\&\\$1\t\c
X.if \\w'\\$1'u>=(\\n(l\\n(lmu+\\n(liu) .br	\" don't overwrite
X..
X.\" The following two macros (hu & hn) have been modified for ELM usage.
X.\" If the macros have text as part of the macro call, the text will be
X.\" increased in size by two points.  After printing the text, the font
X.\" will be returned to normal, otherwise the font will be left bold.
X.\"
X.\" section
X.de hu					\" header, unnumbered
X.					\" format: .hu [text]
X.if !\\n(it .bt				\" end the title and such
X.br					\" force out previous line
X.b
X.ie \\n(hP .ps \\n(hP
X.el        .ps \\n(ps
X.ie \\n(hv .vs \\n(hv
X.el        .vs \\n(vs
X.in \\n(l\\n(lmu			\" stop any indenting
X.sn \\n(hsu				\" inter-section spacing
X.ne 3v+\\n(.Vu				\" slightly more than 3 lines
X.fi					\" process the text, too
X.if \\n(.$>=1 \{\
X.ps +2
X\\$1
X.\}
X.if \\n(.$>=2 \\$2
X.if \\n(.$>=3 \\$3
X.if \\n(.$>=4 \\$4
X.if \\n(.$>=5 \\$5
X.if \\n(.$>=6 \\$6
X.if \\n(.$>=7 \\$7
X.if \\n(.$>=8 \\$8
X.if \\n(.$=9 \\$9
X.if \\n(.$>=1 \{\
X.ps -2
X.br
X.ft 1
X.\}
X..
X.de hn					\" header, numbered
X.					\" format: .hn [level] [text]
X.if !\\n(it .bt				\" end the title and such
X.br					\" force out previous line
X.b
X.ie \\n(hP .ps \\n(hP
X.el        .ps \\n(ps
X.ie \\n(hv .vs \\n(hv
X.el        .vs \\n(vs
X.in \\n(l\\n(lmu			\" stop any indenting
X.sn \\n(hsu				\" inter-section spacing
X.ne 3v+\\n(.Vu				\" slightly more than 3 lines
X.fi					\" process the text, too
X.ie !'\\$1'' .nr hn \\$1
X.el          .nr hn 1
X.ie \\n(hn>0 .nr hn -1
X.el          .nr hn 0
X.ie \\n(hn=0 \{\
X.	nr h0 +1			\" add 1 to main section header
X.	nr h1 0				\" zap remaining section numbers
X.	nr h2 0				\" zap remaining section numbers
X.	nr h3 0				\" zap remaining section numbers
X.ie \\n(.$>=2 \{\
X.ps +2
X\\n(h0.
X.ps -2
X.\}
X.el \\n(h0.
X.\}
X.el .ie \\n(hn=1 \{\
X.	nr h1 +1			\" add 1 to the section header
X.	nr h2 0				\" zap remaining section numbers
X.	nr h3 0				\" zap remaining section numbers
X.ie \\n(.$>=2 \{\
X.ps +2
X\\n(h0.\\n(h1.
X.ps -2
X.\}
X.el \\n(h0.\\n(h1.
X.\}
X.el .ie \\n(hn=2 \{\
X.	nr h2 +1			\" add 1 to the section header
X.	nr h3 0				\" zap remaining section numbers
X.ie \\n(.$>=2 \{\
X.ps +2
X\\n(h0.\\n(h1.\\n(h2.
X.ps -2
X.\}
X.el \\n(h0.\\n(h1.\\n(h2.
X.\}
X.el \{\
X.	nr h3 +1			\" add 1 to the section number
X.ie \\n(.$>=2 \{\
X.ps +2
X\\n(h0.\\n(h1.\\n(h2.\\n(h3.
X.ps -2
X.\}
X.el \\n(h0.\\n(h1.\\n(h2.\\n(h3.
X.\}
X.if \\n(.$>=2 \{\
X.ps +2
X\\$2
X.\}
X.if \\n(.$>=3 \\$3
X.if \\n(.$>=4 \\$4
X.if \\n(.$>=5 \\$5
X.if \\n(.$>=6 \\$6
X.if \\n(.$>=7 \\$7
X.if \\n(.$>=8 \\$8
X.if \\n(.$>=9 \\$9
X.if \\n(.$>=2 \{\
X.br
X.ft 1
X.ps -2
X.\}
X..
X.\" displays (no floats, thank God!)
X.de sd					\" start display
X.					\" look for nested displays -- ILLEGAL
X.ie \\n(id>0 .er "display within display"
X.el \{\
X.	ie '\\$1'c' .nr sf 1		\" center the sucker
X.	el          .nr sf 0		\" don't center it
X.\}
X.sn \\n(pdu				\" a little bit of space
X.ev 2					\" switch to display environment
X.nf					\" what you type is what you get
X.if \\n(id=0 .di dd			\" start saving text
X.rs					\" don't eat leading space
X.nr id +1				\" increment level of display
X..
X.de ed					\" end display
X.br					\" flush line
X.ie \\n(id<=0 .er "end display has no corresponding begin display"
X.el \{\
X.	nr id -1			\" decrement level of display
X.	if \\n(id=0 \{\
X.		di			\" end diversion
X.		fi			\" resume filling
X.		in -\\n(piu		\" dedent
X.		ev			\" pop environment
X.		ne \\n(dnu		\" be sure you have room
X.		nf			\" don't reprocess display
X.		rs			\" don't eat leading space
X.		zi			\" save indents
X.		ie \\n(sf .in (\\n(llu-\\n(dlu)/2u	\" center on the line length
X.		el .in +\\n(piu		\" indent the sucker
X.		dd			\" drop display
X.		yi			\" restore indents
X.	\}
X.\}
X.fi					\" resume filling
X.sn \\n(pdu				\" a little bit of space
X..
X.\" **********
X.\" fonts -- if argument(s), apply only to first
X.de b					\" bold (font 3)
X.ie \\n(.$>0 \\&\\$3\\f3\\$1\\fP\\$2
X.el .ft 3
X..
X.de i					\" italics (font 2)
X.ie \\n(.$>0 \\&\\$3\\f2\\$1\\fP\\$2
X.el .ft 2
X..
X.de r					\" roman (font 1)
X.ft 1					\" just restore it
X..
X.de bi					\" bold italics (embolden font 2)
X\\&\\$3\c
X\\kb\\f2\\$1\\fP\\h'|\\nbu+2u'\\f2\\$1\\fP\\$2
X..
X.\" **********
X.\" point sizes -- if argument(s), apply only to first
X.de sm					\" reduce point size by 2
X.ie \\n(.$>0 \\&\\$3\\s-2\\$1\\s0\\$2
X.el .ps -2
X..
X.de is					\" increase point size by 2
X.ie \\n(.$>0 \\&\\$3\\s+2\\$1\\s0\\$2
X.el .ps +2
X..
X.de nl					\" return to normal size
X.ps \\n(ps				\" just reset the point size
X..
X.\" **********
X.\" handy force space/inhibit more space macros
X.de sn					\" space, then turn on nospace mode
X.sp \\$1				\" space
X.ns					\" ignore any more space requests
X..
X.de sr					\" force out space
X.rs					\" turn on spacing mode
X.sp \\$1				\" space
X..
X.\" **********
X.\" end of text and error macros
X.de et					\" end of text macro
X.					\" this: (1) flushes rest of line
X.					\" (2) trips the footer, taking
X.					\" care of footnotes
X.sp \\n(.pu
X.					\" check for open displays or footnotes
X.if \\n(id>0 .er "unfinished display"
X.if \\n(if>0 .er "unfinished footnote"
X.					\" this one means an -mn bug (*sigh*)
X.if !'\\n(.z'' .er "diversion \\n(.z not closed"
X..
X.de er					\" print error message
X.					\" flag it as an error
X.ds ws "** ERROR **
X.					\" if you have it, give the file name
X.if !'\\*(.f'' .as ws " file \\*(.f,
X.					\" put out the line number
X.as ws " line \\n(.c
X.					\" and finally the error message
X.tm \\*(ws: \\$1
X..
X.\" **********
X.\" macros in this section are VERY specific to the news documentation
X.de pa					\" protocol appellation (darn names!)
X\\&\\$3\\f2\\$1\\fP\\$2
X..
X.de ng					\" news group name
X\\&\\$3\\f3\\$1\\fP\\$2
X..
X.de cn					\" computer name
X\\&\\$3\\f2\\$1\\fP\\$2
X..
X.de hf					\" header field
X\\&\\$3\\*(lq\\$1\\*(rq\\$2
X..
X.de cf					\" contents of field
X\\&\\$3\\*(lq\\$1\\*(rq\\$2
X..
X.de qc					\" quote control char (command)
X\\&\\$3\\f3<\\s-2\\$1\\s0>\\fP\\$2
X..
X.de qp					\" quote printing char (command)
X\\&\\$3\\f3\\$1\\fP\\$2
X..
X.de op					\" option
X\\&\\$3\\f3\\$1\\fP\\$2
X..
X.\" **********
X.\" trademarked names
X.de pd					\" print "PDP-11"
X.ie \\n(p1 \\&\\$2\\s-1PDP\\s0-11\\$1
X.el \{\
X.	nr p1 +1			\" mark footnote as dropped
X\\&\\$2\\s-1PDP\\s0-11\\*(rg\\$1
X.	fn				\" put out the footnote
X\\&\\*(rgPDP-11 is a registered trademark of Digital Equipment Corporation.
X.	ef				\" short and sweet ...
X.\}
X..
X.de ux					\" print "UNIX"
X.ie \\n(ux \\&\\$2\\s-1UNIX\\s0\\$1
X.el \{\
X.	nr ux +1			\" mark footnote as dropped
X\\&\\$2\\s-1UNIX\\s0\\*(rg\\$1
X.	fn				\" put out the footnote
X\\&\\*(rgUNIX is a registered trademark of AT&T.
X.	ef				\" short and sweet ...
X.\}
X..
X.de vx					\" print "VAX"
X.ie \\n(vx \\&\\$2\\s-1VAX\\s0\\$1
X.el \{\
X.	nr vx +1			\" mark footnote as dropped
X\\&\\$2\\s-1VAX\\s0\\*(rg\\$1
X.	fn				\" put out the footnote
X\\&\\*(rgVAX is a trademark of Digital Equipment Corporation.
X.	ef				\" short and sweet ...
X.\}
X..
X.\" **********
X.\" set up string and number registers
X.					\" set up for the date
X.if \n(mo=1  .ds mo January
X.if \n(mo=2  .ds mo February
X.if \n(mo=3  .ds mo March
X.if \n(mo=4  .ds mo April
X.if \n(mo=5  .ds mo May
X.if \n(mo=6  .ds mo June
X.if \n(mo=7  .ds mo July
X.if \n(mo=8  .ds mo August
X.if \n(mo=9  .ds mo September
X.if \n(mo=10 .ds mo October
X.if \n(mo=11 .ds mo November
X.if \n(mo=12 .ds mo December
X.ds dy "\*(mo \n(dy, 19\n(yr
X.if \n(dw=1  .ds dw Sunday
X.if \n(dw=2  .ds dw Monday
X.if \n(dw=3  .ds dw Tuesday
X.if \n(dw=4  .ds dw Wednesday
X.if \n(dw=5  .ds dw Thursday
X.if \n(dw=6  .ds dw Friday
X.if \n(dw=7  .ds dw Saturday
X.					\" NROFF dependencies
X.if n \{\
X.					\" string registers
X.	ds rg (R)
X.	ds lq ""
X.	ds rq ""
X.	ds f1 "\*(dy
X.					\" number registers
X.	nr hs 1v			\" space before section header
X.	nr pd 1v			\" inter-paragraph spacing
X.	nr bm 1.0i			\" height of bottom margin
X.\}
X.					\" NROFF dependencies
X.if t \{\
X.					\" string registers
X.	ds rg \\u\\s-2\\(rg\\s0\\d
X.	ds lq ``
X.	ds rq ''
X.					\" number registers
X.	nr hs 1v			\" space before section header
X.	nr pd 0.3v			\" inter-paragraph spacing
X.	nr bm 1.0i+1v			\" height of bottom margin (wacky laser)
X.\}
X.					\" these are the same for [NT]ROFF
X.ds dg \(dg
X.ds vr "News Version B2.11
X.ds pv "News macros 1.5
X.ds h1 - % -
X.nr bt 0.5i+1v				\" bottom of page to footer
X.nr cm 0				\" no cut marks
X.nr fc 0 1				\" init footnote count
X.nr fl 5.5i				\" footnote line length
X.nr fp 0-\n(bmu				\" fo macro trap location
X.nr h0 0				\" init section header level 0
X.nr h1 0				\" init section header level 1
X.nr h2 0				\" init section header level 2
X.nr h3 0				\" init section header level 3
X.nr id 0				\" 1 in display
X.nr if 0				\" 1 in keep
X.nr it 0				\" 1 when beyond title, etc.
X.nr li 5n				\" indent for labelled paragraph
X.nr ll 6.5i				\" line length
X.nr lm 0				\" left margin
X.nr l0 0				\" first indent level
X.nr mt 1.5i+1v				\" title goes down this far
X.nr pi 5n				\" regular paragraph indent
X.nr po 1.0i				\" page offset
X.nr ps 10				\" point size
X.nr tm 1.0i				\" height of top margin
X.nr tt 0.5i-0.5v			\" top of page to header
X.nr p1 0				\" no PDP-TM message yet
X.nr ux 0				\" no UNIX-TM message yet
X.nr vx 0				\" no VAX-TM message yet
X.nr vs 12				\" vertical spacing
X.\" set things up
X.\" DSINC changes for XROFF
X.nr f1 1
X.nr f2 1
X.nr s1 10
X.nr s2 10
X.nr v1 12
X.nr v2 12
X.ps 10
X.vs 12
X.\" DSINC end changes for XROFF
X.po \n(pou				\" set page offset
X.ps \n(ps				\" set previous, current
X.ps \n(ps				\"   point sizes
X.vs \n(vs				\" set previous, current
X.vs \n(vs				\"   vertical spacings
X.ll \n(llu				\" set line length
X.lt \n(llu				\" set title line length
X.ev 1					\" *** footnote environment
X.ps \n(ps-2p				\" set previous, current
X.ps \n(ps-2p				\"   point sizes
X.vs \n(vs-2p				\" set previous, current
X.vs \n(vs-2p				\"   vertical spacings
X.ll \n(flu				\" set line length
X.lt \n(flu				\" set title line length
X.ev					\" *** pop environment
X.ev 2					\" *** footnote environment
X.ps \n(ps				\" set previous, current
X.ps \n(ps				\"   point sizes
X.vs \n(vs				\" set previous, current
X.vs \n(vs				\"   vertical spacings
X.ll \n(llu				\" set line length
X.lt \n(llu				\" set title line length
X.ev					\" *** pop environment
X.\" now set internal registers (for the first header section)
X.nr f1 \n(.f				\" saved font #1
X.nr f2 \n(.f				\" saved font #2
X.nr s1 \n(.s				\" saved point size #1
X.nr s2 \n(.s				\" saved point size #2
X.nr v1 \n(.v				\" saved vertical spacing #1
X.nr v2 \n(.v				\" saved vertical spacing #2
X.\" install traps
X.wh 0i hd				\" position header trap
X.wh -\n(bmu fo				\" position footer trap
X.wh \n(.pu+1i fx			\" put footnote overflow trap here
X.ch fx -\n(bmu				\" move it over fo
X.wh -\n(btu pf				\" print the bottom margin here
X.em et					\" at end of file, call et
X.\" couple of miscellaneous requests
X.bd S 3 3				\" embolden special font chars if B
X.hy 2					\" don't hyphenate last lines
SHAR_EOF
chmod 0444 doc/tmac.n || echo "restore of doc/tmac.n fails"
echo "x - extracting doc/wnewmail.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > doc/wnewmail.1 &&
X.TH WNEWMAIL 1L "Elm Version 2.3" "USENET Community Trust"
X.SH NAME
Xwnewmail - daemon to asynchronously notify of new mail
X.SH SYNOPSIS
X.B wnewmail
X.br
X.B wnewmail
Xfilename
X.PP
X.SH DESCRIPTION
X.I Wnewmail\^
Xis a daemon designed to run in \fBa window\fR on a windowing
Xsystem (such as an HP or Sun system) and check every 10 seconds
Xto see if there is any new mail for the user that
Xstarted it up.
X.P
XIf there is new mail, the program will "beep", and write to
Xthe window for each of the new messages;
X.nf
X
X   Mail from <name> -- <subject>
X
X.fi
Xwhere <name> is either the name of the person sending it,
Xif available (the ARPA 'From:' line) or machine!login where
Xmachine is the machine the mail was sent from.  If there
Xis no subject, the message "<no subject>" will appear on
Xthe screen.
X.P
XIf the message is a \fIpriority\fR message (that is, the
Xheader contains a line "Priority:"), then the line output
Xwill be "PRIORITY mail from ..." rather than just "Mail from".
X.P
XThis program will run forever, and can internally reset 
Xitself if mail is deleted from the incoming mailbox while
Xtrying to monitor it.
X.P
XIf \fBwnewmail\fR is started up with a filename, it will
Xperform exactly the same, but with the specified file as
Xthe one to check rather than the default users mailbox.
X.SH AUTHOR
XDave Taylor, Hewlett-Packard Laboratories.
X.SH SEE ALSO
Xnotify in sh(1) or csh(1), newmail(1L)
X.SH NOTE
XThis is almost identical to the program \fBnewmail\fR...
X.SH BUG REPORTS TO
XSyd Weinstein	elm@DSI.COM	(dsinc!elm)
X.SH COPYRIGHTS
X.ps 18
X\fB\(co\fR\s12 Copyright 1986, 1987 by Dave Taylor
X.br
X.ps 18
X\fB\(co\fR\s12 Copyright 1988, 1989, 1990 by The USENET Community Trust
SHAR_EOF
chmod 0444 doc/wnewmail.1 || echo "restore of doc/wnewmail.1 fails"
echo "x - extracting filter/Makefile.SH (Text)"
sed 's/^X//' << 'SHAR_EOF' > filter/Makefile.SH &&
Xcase $CONFIG in
X'')
X    if test ! -f config.sh; then
X	ln ../config.sh . || \
X	ln ../../config.sh . || \
X	ln ../../../config.sh . || \
X	(echo "Can't find config.sh."; exit 1)
X    fi
X    . ./config.sh
X    ;;
Xesac
Xcase "$0" in
X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
Xesac
X
Xecho "Extracting filter/Makefile (with variable substitutions)"
Xcat >Makefile <<!GROK!THIS!
X#
X# @(#)$Id: Makefile.SH,v 4.1 90/04/28 22:41:51 syd Exp $
X#  Makefile for the Elm system filter program
X#
X#	Copyright (c) 1986, 1987 Dave Taylor
X#	Copyright (c) 1988, 1989, 1990 USENET Community Trust
X#
X# Bug reports, patches, comments, suggestions should be sent to:
X#
X#	Syd Weinstein - elm@DSI.COM
X#			dsinc!elm
X#
X#  $Log:	Makefile.SH,v $
X# Revision 4.1  90/04/28  22:41:51  syd
X# checkin of Elm 2.3 as of Release PL0
X# 
X#
X# Variables
X#	Variables established by Configure
XCC		=	$cc
XCCFLAGS		=	$ccflags $xencf
XCHGRP		=	$chgrp
XCHMOD		=	$chmod
XCP		=	$cp
XDEST		=	$bin
XECHO		=	$echo
XLFLAGS		=	$ldflags $xenlf
XLIB		=	$lib
XLIB2		= 	$libs
XLIBS		=	$termlib $dbm
XLINT		=	$lint
XMAILGRP		=	$mailgrp
XMAILERMODE	=	$mailermode
XMAKE		=	$make
XMV		=	$mv
XOPTIMIZE	=	$optimize
XRM		= 	$rm -f
XTOUCH		=	$touch
X
X!GROK!THIS!
X
Xcat >>Makefile <<'!NO!SUBS!'
X#	Variables you may want to manually edit
X#		If you want debug logging then you'll
X#		want to uncomment the following.
X#DEBUG		=	-DDEBUG
X
X#	Other variables
XBIN		=	../bin
XINCLDIR		=	../hdrs
XCFLAGS		=	$(CCFLAGS) $(OPTIMIZE) -I$(INCLDIR) $(DEBUG) $(DACSNET) 
XLINTFLAGS	=	-I$(INCLDIR)
XSHELL		=	/bin/sh
X
X# Definitions of variables
XFILTER_SRC	=	actions.c	\
X			buffer.c	\
X			filter.c	\
X			lock.c		\
X			parse.c		\
X			rules.c		\
X			summarize.c	\
X			utils.c		\
X			../src/opt_utils.c
X
XFILTER_OBJ	=	actions.o	\
X			buffer.o	\
X			filter.o	\
X			lock.o		\
X			parse.o		\
X			rules.o		\
X			summarize.o	\
X			utils.o		\
X			../src/opt_utils.o
X
X# Standard targets
Xall:		$(BIN)/filter
X		
Xinstall:	$(DEST)/filter
X
Xuninstall:	
X		$(RM) $(DEST)/filter
X
X#	This is the only target that gets installed even if not out-of-date
X#	with respect the files from which it is installed.
Xrmt-install:	rmt-defined
X		-$(MV) $(DEST)/filter $(DEST)/filter.old
X		-$(RM) $(DEST)/filter.old
X		$(CP) $(REMOTE)$(DEST)/filter $(DEST)/filter
X		$(CHGRP) $(MAILGRP) $(DEST)/filter
X		$(CHMOD) $(MAILERMODE) $(DEST)/filter
X
Xrmt-defined:
X	@(if [ "$(REMOTE)" = "" ];\
X	  then\
X	    $(ECHO) "You need to define 'REMOTE' as the remote file system";\
X	    $(ECHO) "for this particular command. The easiest way to do this";\
X	    $(ECHO) "to type:";\
X	    $(ECHO) "        make REMOTE=<remote file system> rmt-install";\
X	    exit 1;\
X	  fi);
X
Xlint:		
X		$(LINT) $(LINTFLAGS) $(FILTER_SRC) > LINT.OUT
X
Xclean:		
X		$(RM) $(FILTER_OBJ) $(BIN)/filter
X
X# Dependencies and rules
X#	Dependencies of header files upon other header files they include
X.PRECIOUS:		$(INCLDIR)/defs.h $(INCLDIR)/elm.h $(INCLDIR)/headers.h
X
X$(INCLDIR)/defs.h:	$(INCLDIR)/../config.h $(INCLDIR)/sysdefs.h
X			$(CHMOD) u+w $@
X			$(TOUCH) $@
X
X$(INCLDIR)/elm.h:	$(INCLDIR)/curses.h $(INCLDIR)/defs.h
X			$(CHMOD) u+w $@
X			$(TOUCH) $@
X
X$(INCLDIR)/headers.h:	$(INCLDIR)/curses.h $(INCLDIR)/defs.h
X			$(CHMOD) u+w $@
X			$(TOUCH) $@
X
X#	Dependencies and rules for C object files
Xactions.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h
Xfilter.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h
Xlock.o:			$(INCLDIR)/defs.h $(INCLDIR)/filter.h
Xparse.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h
Xrules.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h
Xsummarize.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h
Xutils.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h
X../src/opt_utils.o:
X			cd ../src; $(MAKE) -$(MAKEFLAGS) $(@F)
X
X#	Dependencies and rules for compiling programs
X$(BIN)/filter:	$& $(FILTER_OBJ)
X		$(CC) $(LFLAGS) -o $@ $(FILTER_OBJ) $(LIB2)
X
X#	Dependencies and rules for installing programs from bin directory
X$(DEST)/filter:		$(BIN)/filter
X			-$(MV) $(DEST)/filter $(DEST)/filter.old
X			-$(RM) $(DEST)/filter.old
X			$(CP) $? $@
X			$(CHGRP) $(MAILGRP) $@
X			$(CHMOD) $(MAILERMODE) $@
X!NO!SUBS!
SHAR_EOF
chmod 0444 filter/Makefile.SH || echo "restore of filter/Makefile.SH fails"
echo "x - extracting filter/actions.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > filter/actions.c &&
X
Xstatic char rcsid[] ="@(#)$Id: actions.c,v 4.1 90/04/28 22:41:53 syd Exp $";
X
X/*******************************************************************************
X *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
X *
X * 			Copyright (c) 1986, 1987 Dave Taylor
X * 			Copyright (c) 1988, 1989, 1990 USENET Community Trust
X *******************************************************************************
X * Bug reports, patches, comments, suggestions should be sent to:
X *
X *	Syd Weinstein - elm@DSI.COM
X *			dsinc!elm
X *
X *******************************************************************************
X * $Log:	actions.c,v $
X * Revision 4.1  90/04/28  22:41:53  syd
X * checkin of Elm 2.3 as of Release PL0
X * 
X *
X ******************************************************************************/
X
X
X/** RESULT oriented routines *chuckle*.  These routines implement the
X    actions that result from either a specified rule being true or from
X    the default action being taken.
X**/
X
X#include <stdio.h>
X#include <pwd.h>
X#include <ctype.h>
X#include <fcntl.h>
X
X#include "defs.h"
X#include "filter.h"
X
XFILE *emergency_local_delivery();
X
Xmail_message(address)
Xchar *address;
X{
X	/** Called with an address to send mail to.   For various reasons
X	    that are too disgusting to go into herein, we're going to actually
X	    open the users mailbox and by hand add this message.  Yech.
X	    NOTE, of course, that if we're going to MAIL the message to someone
X	    else, that we'll try to do nice things with it on the fly...
X	**/
X
X	FILE *pipefd, *tempfd, *mailfd;
X	int  in_header = TRUE, line_count = 0, mailunit;
X	char tempfile[SLEN], mailbox[SLEN], lockfile[SLEN],
X	     buffer[VERY_LONG_STRING];
X
X	if (verbose && ! log_actions_only && outfd != NULL)
X	  fprintf(outfd, "filter (%s): Mailing message to %s\n", 
X		   username, address);
X
X	if (! show_only) {
X	  sprintf(tempfile, "%s.%d", filter_temp, getpid());
X
X	  if ((tempfd = fopen(tempfile, "r")) == NULL) {
X	    if (outfd != NULL)
X	      fprintf(outfd, "filter (%s): Can't open temp file %s!!\n", 
X		    username, tempfile);
X	    if (outfd != NULL) fclose(outfd);
X	    exit(1);
X	  }
X	 	
X	  if (strcmp(address, username) != 0) {	/* mailing to someone else */
X	    
X	    if (already_been_forwarded) {	/* potential looping! */
X	      if (contains(from, username)) {
X		if (outfd != NULL)
X	          fprintf(outfd, 
X	"filter (%s): Filter loop detected!  Message left in file %s.%d\n", 
X			username, filter_temp, getpid());
X	        if (outfd != NULL) fclose(outfd);
X	        exit(0);
X	      }
X	    }
X
X	    if (strcmp(sendmail, mailer) == 0)
X	      sprintf(buffer, "%s %s %s", sendmail, smflags, address);
X	    else
X	      sprintf(buffer, "%s %s", mailer, address);
X
X	    if ((pipefd = popen(buffer, "w")) == NULL) {
X	      if (outfd != NULL)
X	        fprintf(outfd, "filter (%s): popen %s failed!\n", username, buffer);
X	      sprintf(buffer, "((%s %s %s ; %s %s) & ) < %s &",
X		      sendmail , smflags, address, remove_cmd, tempfile, tempfile);
X	      system(buffer);
X	      return;
X	    }
X
X	    fprintf(pipefd, "Subject: \"%s\"\n", subject);
X	    fprintf(pipefd, "From: The Filter of %s@%s <%s>\n", 
X		    username, hostname, username);
X	    fprintf(pipefd, "To: %s\n", address);
X	    fprintf(pipefd, "X-Filtered-By: filter, version %s\n\n", VERSION);
X
X	    fprintf(pipefd, "-- Begin filtered message --\n\n");
X	
X	    while (fgets(buffer, SLEN, tempfd) != NULL)
X	      if (already_been_forwarded && in_header)
X	        in_header = (strlen(buffer) == 1? 0 : in_header);
X	      else
X	        fprintf(pipefd," %s", buffer);
X
X	    fprintf(pipefd, "\n-- End of filtered message --\n");
X	    fclose(pipefd);
X	    fclose(tempfd);
X	
X	    return;		/* YEAH!  Wot a slick program, eh? */
X	  
X	  }
X	  
X	  /** OTHERWISE it is to the current user... **/
X
X	  sprintf(mailbox,  "%s%s", mailhome, username);
X	  
X	  if (! lock()) {
X	    if (outfd != NULL) {
X	      fprintf(outfd, "filter (%s): Couldn't create lockfile %s\n",
X		    username, lockfile);
X	      fprintf(outfd, "filter (%s): Can't open mailbox %s!\n",
X			username, mailbox);
X	    }
X	    if ((mailfd = emergency_local_delivery()) == NULL)
X	      exit(1);
X	  }
X	  else if ((mailunit = open(mailbox, O_APPEND | O_WRONLY | O_CREAT, 0600)) >= 0)
X	    mailfd = fdopen(mailunit, "a");
X	  else if ((mailfd = emergency_local_delivery()) == NULL)
X	    exit(1);
X
X	  while (fgets(buffer, sizeof(buffer), tempfd) != NULL) {
X	    line_count++;
X	    if (the_same(buffer, "From ") && line_count > 1)
X	      fprintf(mailfd, ">%s", buffer);
X	    else
X	      fputs(buffer, mailfd);
X	  }
X
X	  fputs("\n", mailfd);
X
X	  fclose(mailfd);
X	  unlock();		/* blamo or not?  Let it decide! */
X	  fclose(tempfd);
X	} /* end if show only */
X}
X
Xsave_message(foldername)
Xchar *foldername;
X{
X	/** Save the message in a folder.  Use full file buffering to
X	    make this work without contention problems **/
X
X	FILE  *fd, *tempfd;
X	char  filename[SLEN], buffer[SLEN];
X	int   fdunit;
X
X	if (verbose && outfd != NULL)
X	  fprintf(outfd, "filter (%s): Message saved in folder %s\n", 
X		  username, foldername);
X	
X	if (!show_only) {
X	  sprintf(filename, "%s.%d", filter_temp, getpid());
X
X	  if ((fdunit = open(foldername, O_APPEND | O_WRONLY | O_CREAT, 0600)) < 0) {
X	    if (outfd != NULL)
X	      fprintf(outfd, 
X		 "filter (%s): can't save message to requested folder %s!\n",
X		    username, foldername);
X	    return(1);
X	  }
X	  fd = fdopen(fdunit,"a");
X
X	  if ((tempfd = fopen(filename, "r")) == NULL) {
X	    if (outfd != NULL)
X	      fprintf(outfd, 
X		     "filter (%s): can't open temp file for reading!\n",
X		     username);
X	     return(1);
X	  }
X
X	  while (fgets(buffer, sizeof(buffer), tempfd) != NULL)
X	    fputs(buffer, fd);
X	
X	  fclose(fd);
X	  fclose(tempfd);
X	}
X
X 	return(0);
X}
X
Xexecute(command)
Xchar *command;
X{
X	/** execute the indicated command, feeding as standard input the
X	    message we have.
X	**/
X
X	char buffer[SLEN];
X
X	if (verbose && outfd != NULL)
X	  fprintf(outfd, "filter (%s): Executing %s\n", username, command);
X
X	if (! show_only) {
X	  sprintf(buffer, "%s %s.%d | %s", cat, filter_temp, getpid(), command);
X	  system(buffer);
X	}
X}
X
XFILE *
Xemergency_local_delivery()
X{
X	/** This is called when we can't deliver the mail to the usual
X	    mailbox in the usual way ...
X	**/
X
X	FILE *tempfd;
X	char  mailbox[SLEN];
X	int   mailunit;
X
X	sprintf(mailbox, "%s/%s", home, EMERGENCY_MAILBOX);
X
X	if ((mailunit = open(mailbox, O_APPEND | O_WRONLY | O_CREAT, 0600)) >= 0) {
X	  if (outfd != NULL)
X	    fprintf(outfd, "filter (%s): Can't open %s either!!\n",
X		    username, mailbox);
X
X	  sprintf(mailbox,"%s/%s", home, EMERG_MBOX); 
X
X	  if ((mailunit = open(mailbox, O_APPEND | O_WRONLY | O_CREAT, 0600)) >= 0) {
X
X	    if (outfd != NULL) {
X	      fprintf(outfd,"filter (%s): Can't open %s either!!!!\n",
X		      username, mailbox);
X	      fprintf(outfd, 
X		      "filter (%s): I can't open ANY mailboxes!  Augh!!\n",
X		       username);
X	     }
X
X	     leave("Cannot open any mailbox");		/* DIE DIE DIE DIE!! */
X	   }
X	   else
X	     if (outfd != NULL)
X	       fprintf(outfd, "filter (%s): Using %s as emergency mailbox\n",
X		       username, mailbox);
X	  }
X	  else
X	    if (outfd != NULL)
X	      fprintf(outfd, "filter (%s): Using %s as emergency mailbox\n",
X		      username, mailbox);
X
X	tempfd = fdopen(mailunit, "a");
X	return((FILE *) tempfd);
X}
SHAR_EOF
chmod 0444 filter/actions.c || echo "restore of filter/actions.c fails"
echo "x - extracting filter/buffer.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > filter/buffer.c &&
X
Xstatic char rcsid[] ="@(#)$Id: buffer.c,v 4.1 90/04/28 22:41:54 syd Exp $";
X
X/*******************************************************************************
X *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
X *
X * 			Copyright (c) 1986, 1987 Dave Taylor
X * 			Copyright (c) 1988, 1989, 1990 USENET Community Trust
X *******************************************************************************
X * Bug reports, patches, comments, suggestions should be sent to:
X *
X *	Syd Weinstein - elm@DSI.COM
X *			dsinc!elm
X *
X *******************************************************************************
X * $Log:	buffer.c,v $
X * Revision 4.1  90/04/28  22:41:54  syd
X * checkin of Elm 2.3 as of Release PL0
X * 
X *
X ******************************************************************************/
X
X#include <stdio.h>
X
Xchar  _vbuf[5*BUFSIZ];		/* space for file buffering */
SHAR_EOF
chmod 0444 filter/buffer.c || echo "restore of filter/buffer.c fails"
echo "x - extracting filter/filter.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > filter/filter.c &&
X
Xstatic char rcsid[] ="@(#)$Id: filter.c,v 4.1 90/04/28 22:41:55 syd Exp $";
X
X/*******************************************************************************
X *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
X *
X * 			Copyright (c) 1986, 1987 Dave Taylor
X * 			Copyright (c) 1988, 1989, 1990 USENET Community Trust
X *******************************************************************************
X * Bug reports, patches, comments, suggestions should be sent to:
X *
X *	Syd Weinstein - elm@DSI.COM
X *			dsinc!elm
X *
X *******************************************************************************
X * $Log:	filter.c,v $
X * Revision 4.1  90/04/28  22:41:55  syd
X * checkin of Elm 2.3 as of Release PL0
X * 
X *
X ******************************************************************************/
X
X
X/** This program is used as a filter within the users ``.forward'' file
X    and allows intelligent preprocessing of mail at the point between
X    when it shows up on the machine and when it is actually put in the
X    mailbox.
X
X    The program allows selection based on who the message is FROM, TO, or
X    what the subject is.  Acceptable actions are for the program to DELETE_MSG
X    the message, SAVE the message in a specified folder, FORWARD the message
X    to a specified user, SAVE the message in a folder, but add a copy to the
X    users mailbox anyway, or simply add the message to the incoming mail.
X
X    Filter also keeps a log of what it does as it goes along, and at the
X    end of each `quantum' mails a summary of actions, if any, to the user.
X
X    Uses the files: $HOME/.filter for instructions to this program, and
X    $HOME/.filterlog for a list of what has been done since last summary.
X
X**/
X
X#include <stdio.h>
X#include <pwd.h>
X#include <ctype.h>
SHAR_EOF
echo "End of part 8"
echo "File filter/filter.c is continued in part 9"
echo "9" > s2_seq_.tmp
exit 0

exit 0 # Just in case...
-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.