[mod.sources] v06i029: Elm mail system

sources-request@mirror.UUCP (06/30/86)

Submitted by: Dave Taylor <pyramid!hplabs!hpldat!taylor>
Mod.sources: Volume 6, Issue 29
Archive-name: elm/Part04

[  This posting is in a different SHAR format because Dave sent me
   an update to one of the files herein and I had to repack.  --r$ ]

#!/bin/sh
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
# Contents:  doc/ hdrs/ doc/Users.guide doc/elm.1 hdrs/curses.h
#	hdrs/defs.h hdrs/elm.h hdrs/headers.h hdrs/help.h hdrs/sysdefs.h
 
if test ! -d doc
then
  echo creating directory doc
  mkdir doc
  chmod u=rwx,g=rwx,o=rwx doc
fi

if test ! -d hdrs
then
  echo creating directory hdrs
  mkdir hdrs
  chmod u=rwx,g=rwx,o=rwx hdrs
fi

echo x - doc/Users.guide
sed 's/^XX//' > "doc/Users.guide" <<'@//E*O*F doc/Users.guide//'
XX.PH ""
XX.tm I trust we've run this through tbl first...
XX\"
XX\"  Users guide to the ELM mail system.
XX\"  format with 'tbl Users.guide | troff -mm > Users.fmtd
XX\"  or something similar.
XX\"  (C) Copyright 1985 Dave Taylor
XX\"
XX\"  Last update: May 14th, 1986
XX\"
XX.PF ""
XX\"  Define the big box macro for troff
XX.de eb
XX.sp -1	
XX.nf
XX\h'-.5n'\L'|\\nau-1'\l'\\n(.lu+1n\(ul'\L'-|\\nau+1'\l'|0u-.5n\(ul'
XX.fi
XX..
XX.ds HF 3  3 
XX.ds HP 12 12
XX.SA 1
XX.nr Hy 1
XX.nr Pt 1
XX.nr Pi 8
XX.lg 1
XX.HM 1 1
XX.rs
XX.sp 5
XX.ce 99
XX.ps 20
XX\fBElm Users Guide\fR
XX.sp 2
XX.ps 12
XX\fIA painless introduction to electronic mail 
XXusing the \fBElm\fP mailer\fR
XX.sp 5
XXDave Taylor
XX.sp 
XXHewlett-Packard Laboratories
XX1501 Page Mill Road
XXPalo Alto CA
XX94304
XX.sp
XXemail: taylor\s10@\s12hplabs or hplabs!taylor
XX.ps 10
XX.sp 7
XX\fBABSTRACT\fR
XX.ce 0
XX.sp
XX.DS CB F
XXWhile various parts of the Unix system have been
XXupdated into the `CRT' age (rather than the `teletype')
XXthe electronic mail systems haven't.  This document 
XXpresents the \fIElm\fR mail system which remedies
XXthis problem.  This mailer offers all the features of
XX\fI/bin/mail\fR, \fImailx\fR, \fIMail\fR, \fIuumail\fR and \fINmail\fR in an
XXunified and intuitive fashion.
XX.DE
XX.sp 5
XX.ce
XX.ps 18
XX\fB\(co\fR\s12 Copyright 1986 by Dave Taylor
XX.ps 10
XX.SK
XX.ce 99
XX.ps 14
XX\fBElm Users Guide\fR
XX.ps 10
XX.sp
XX(version 1.1)
XX.sp 2
XXDave Taylor
XXHewlett-Packard Laboratories
XX1501 Page Mill Road
XXPalo Alto CA
XX94304
XX.sp
XXemail: taylor@hplabs or hplabs!taylor
XX.sp 2
XX\*(DT
XX.ce 0
XX.nr P 1
XX.PH "'Elm Users Guide''Version 1.1'"
XX.PF "''Page \\\\nP''"
XX.sp 3
XX.H 1 "Introduction"
XX.P 1
XXThe Unix\v'-.3'\s5TM\s10\v'.3' operating system was originally 
XXwritten on a small PDP machine
XXto work with teletypewriters.  Consequently, all the original software for
XXthe operating system was written with a `tty' in mind - they were all 
XXline oriented, rather than screen oriented.
XX.P
XXGradually this began to change, and, with the addition of the Berkeley
XX.I vi
XXvisual shell to the 
XX.I ed
XXline editor, the trend seemed to be brought to the attention of 
XXUnix systems designers.  
XX.FS " "
XXHistorical note: shrewd users will recognize this as the old Unix 
XX.lg 0
XX\fIMsg\fR
XX.lg 1
XXmailer.  The name was changed to avoid a conflict with an old DEC-20
XXmailer, and because the new name stands for \fBEL\fRectronic \fBM\fRail,
XXwhich I think works out better!
XX.FE
XX.P
XXApparently, however, this wasn't enough of a significant event, as
XX.I vi
XXand
XX.I notes
XXare the only screen oriented software available
XX(other than games, which are a taboo subject with managers
XXand the like!).  Consequently, after becoming more and more 
XXdisenchanted
XXwith the existing electronic mail facilities (\fImail\fR
XXand \fImailx\fR, both of which are essentially line editors) I decided
XXto write my own!
XX.P
XXThis document discusses the 
XX.B Elm
XXmailer, and includes a set of example screens and a discussion
XXof configuration (for systems administrators).  It is broken
XXinto three main parts, the \fIElm Users Guide\fR, which you're holding,
XXthe \fIElm Reference Guide\fR, and the \fIElm Alias Users Guide\fR.
XX.P
XXThis guide contains;
XXthis introduction, a session with the mailer, a
XXdiscussion of non-interactive uses of \fBElm\fR,
XXa brief foray into the \fBElm\fR utilities,
XXand finally, credits and references.
XX.P
XXThe \fIElm Reference Guide\fR contains;
XXa discussion of the \fI.elmrc\fR file,
XXstarting options of 
XX.B Elm,
XXoutgoing mail processing,
XXresponses of various commands,
XXthe mail archive file,
XXthe Notes system,
XXthe Alias system,
XXsystem aliases etc,
XXmore on the utilities,
XXand a section for expert users.
XX.P
XXThe \fIElm Alias Users Guide\fR contains;
XXa further discussion of \fIuser aliases\fR
XXand \fIgroup aliases\fR,  System aliases,
XXhow to edit and install new aliases,
XXthe hostname routing database,
XXthe domain routing database,
XXand so on.
XX.P
XXAny comments or problems with any of the documention or the program
XXitself are welcome: all installed systems should have an alias
XXthat will ensure that I receive any mail sent to `elm'.
XX.sp 2
XX.H 1 "The Main System"
XX.P 1
XXUpon entry to the program, the main screen will be 
XXdisplayed as below;
XX\" display start, constant width, remember loc for BOX
XX.DS CB
XX.mk a)
XX.mk a)
XX.ce
XXMailbox is '/usr/mail/mymail' with 15 messages.  [Version 1.1]

XX.TS
XXr c r l l l l.
XX ->		1	Apr 3	rob	(24)	Doing anything tonight?
XX		2	Apr 5	Joe	(154)	bug in gammon game
XX		3	Apr 5	root	(13)
XX		4	Apr 6	root	(7)	(continuation of previous message)
XX	U	5	Apr 8	decvax!mouse	(68)	Re: net.music article decvax:495
XX		6	Apr 13	John Jacobs	(194)	How can you hate RUSH?
XX		7	Apr 15	kevin	(27)	More software requests
XX	N	8	Apr 18	games	(26)	Hi there
XX	N	9	Apr 18	Don Knuth	(354)	Your version of TeX...
XX	N	10	Apr 23	Carl Smith	(53)	(More silly stuff
XX	N	11	Apr 24	jad@hpcnoe	(84)	Chico?  Why go there?
XX	N	12	Apr 24	Larry Fenske	(49)	hi there...
XX.TE
XX.sp
XX.ce 3
XX|=pipe, !=shell, ?=help, <n>=set current to n, /=search pattern
XXA)lias, C)hange mailbox, D)elete, E)dit, F)orward, G)roup reply, M)ail, 
XXN)ext, O)ptions, P)rint, R)eply, S)ave, T)ag, Q)uit, U)ndelete, or eX)it
XX                                                            
XXElm : @
XX.sp 2
XX\" draw box, proportional Roman font back, display end
XX.eb
XX.DE
XX.P 0
XXThere are a number of things to notice about this screen;
XX.BL 4
XX.LI
XXFirst off, it's quite possible that on your screen the current message will
XXbe indicated by an inverse bar rather than an arrow. 
XXDon't worry about it - it's just harder to have an inverse
XXbar in a document than an arrow!
XX.LI
XXThe top line always displays the current mail file, 
XXthe number of messages in the file, and the current 
XX.B Elm
XXversion number.
XX.LI
XXThe arrow (``->'') (or bar) always points to the current message.  
XX.LI
XXThe first few characters on each line can indicate the following:
XX.VL 6 5
XX.LI "U"
XX-  an \fIU\fRrgent message
XX.LI "N"
XX-  a \fIN\fRew message since you last read mail
XX.LI "E"
XX-  an \fIE\fRxpired message (not implemented)
XX.LI "A"
XX-  an \fIA\fRction is associated with the message
XX.LI "D"
XX-  the message is marked for \fID\fReletion
XX.LI "+"
XX-  the message is \fITagged\fR.
XX.LE
XX.LI
XXContinuing from left to right, the next field is the message
XXnumber.  For the most part you can ignore these unless you want
XXto quickly move to a specific message (as we'll see later)
XX.LI
XXThe date associated with each message is the date the person
XX.I sent 
XXthe message.  
XX.LI 
XXThe next field displayed indicates who the message is from.  
XX\fBElm\fR will try to display the \fIname\fR of the person who 
XXsent the message, rather than the their return address/login.  
XXSome systems don't generate the correct headers, though, hence 
XXmessages like number 11, where it's
XXthe return address of the sender...
XX.LI
XXThe number in parentheses is the number of lines in the message.
XX.LI
XXThe final field is the (optional) subject of the message.  Note
XXthat message 3 has no subject.
XX.LI
XXA maximum of twelve messages are displayed at one time*.
XX.FS *
XXOn terminals with greater than 25 lines, more messages will be 
XXdisplayed automatically.  
XX.FE
XXFurther into
XXthe document we'll learn how to change 'pages' in the mailbox. 
XX.LI
XXThe three line mini-menu will always 
XXindicate what commands are available at 
XXthe current moment.  
XX.LI
XXFinally, the '@' character indicates where the cursor would be, awaiting
XXyour input.
XX.LE
XX.P 0
XXThe typical action at this point is to use the 
XX.I <return>
XXkey to read the current message.  This particular option actually isn't
XXnoted in the mini-menu, but choosing the '?=help' option will
XXinform you of a number of choices other than those in the 
XXbasic menu!
XX.P 0
XXPressing this key will clear the screen and display the 
XXmessage using the local pager 
XX(see \fIpager\fR in the \fI.elmrc\fR file).
XX.P 0
XXWhile reading is perhaps the most fundamental function that the
XX.B Elm
XXprogram performs, there are a number of other options available,
XXnamely;
XX\" ensure we get a reasonable chunk of this table on the page...
XX.ne 10
XX.sp
XX.VL 25 0 1
XX.LI "Command"
XXAction
XX.LE
XX.sp
XX.VL 22 3 1
XX.LI "|"
XXPipe current message or tagged messages to specified system command.
XX.LI "!"
XXShell escape.
XX.LI "?"
XXHelp mode - any key pressed will be explained.
XX.LI "+, <space>,"
XX.LI "  or <NEXT>"
XXNext page of headers
XX.LI "-, or <PREV>"
XXPrevious page of headers
XX.LI "=, or <HOME>"
XXSet current message to 1
XX.LI "*, or "
XX.LI " <SHIFT>-<HOME>"
XXSet current to last message.
XX.LI "<n>"
XXSet current message to number n.
XX.LI "/"
XXSearch for pattern in subject/from lines.
XX.LI "//"
XXSearch for pattern in entire mailbox.
XX.LI "<"
XXScan message for calendar entries*
XX.FS *
XXSome sites might opt not to have this feature
XXavailable.
XX.FE
XX.LI ">"
XXA synonym for `s' - \fIsave\fR message or messages.
XX.sp
XX.LI "a"
XXAlias, change to 'alias' mode 
XX.LI "b"
XXBounce - remail message**
XX.LI "c"
XXChange to new mail file
XX.LI "d"
XXDelete current message
XX.LI "<control>-D"
XXDelete all messsages matching specified pattern
XX.LI "e"
XXEdit mailbox file, resyncing upon reentry.
XX.LI "f"
XXForward message to specified user**
XX.FS **
XXThe difference between \fIForward\fR and \fIBounce\fR is rather 
XXsubtle -- a forwarded message is ``from'' you, with the
XXoriginal message included, whereas a bounced message
XXis still from the original sender.  
XX.FE
XX.LI "g" 
XXGroup reply - reply to everyone who received the current message
XX.LI "h"
XXDisplay message + headers
XX.LI "j"
XXIncrement current message by one
XX.LI "k"
XXDecrement current message by one
XX.LI "m"
XXMail to arbitrary user(s)
XX.LI "n or <return>"
XXNext message (Read current, then increment)
XX.LI "o"
XXAlter current system options.
XX.LI "p"
XXPrint current message or tagged messages.
XX.LI "r"
XXReply to the author of current message
XX.LI "s"
XXSave current message or tagged messages to file
XX.LI "t"
XXTag current message.
XX.LI "<control>-T"
XXTag all messages matching specified pattern.
XX.LI "q"
XXQuit - mail deleted, saved in mbox or left.
XX.LI "u"
XXUndelete current message
XX.LI "x"
XXExit - don't record as read, don't save...
XX.sp
XX.LI "^L"
XXRewrite screen.
XX.LI "^M (<return>)"
XXRead current message
XX.LI "^Q, DEL"
XXExit - don't record as read, don't save...
XX.LE
XX.sp
XX.P 0
XXThat are all the commands available at the main level of the
XX.B Elm
XXprogram!  Easy to remember, right?
XX.sp 2
XX\" again, make sure we start on a new page please
XX.ne 10
XX.P 0
XXAs an example, let's enter a series of commands and indicate
XXwhat the display would be after each one;
XX.sp
XX.P 0
XXFirst off, let's go to the next page of mail with `\fI+\fR';
XX.DS CB
XX.mk a)
XX.ce
XXMailbox is '/usr/mail/mymail' with 15 messages.  [Version 1.1]

XX.TS
XXr c r l l l l.
XX ->	N	13	Apr 3	Jack	(17)	Wanna buy some albums cheap?
XX	N	14	Apr 5	Jack	(8)	Cancel the previous offer!
XX	N	15	Apr 5	sdcsvax!dx	(420)	Moving day (long) 
XX.TE
XX     
XX  
XX     
XX     
XX  
XX  
XX  
XX  
XX  

XX.ce 3
XX|=pipe, !=shell, ?=help, <n>=set current to n, /=search pattern 
XXA)lias, C)hange mailbox, D)elete, E)dit, F)orward, G)roup reply, M)ail
XXN)ext, O)ptions, P)rint, R)eply, S)ave, T)ag, Q)uit, U)ndelete, or eX)it
XX                                                            
XXElm : @
XX.sp 2
XX.eb
XX.DE
XX.P 0
XXLet's read the new current message, 13, by typing <\fIreturn\fR>.
XX.DS CB
XX.mk a)
XX.tl 'Message #13 from Jack''Mailed April 3, 1985 at 8:45 pm'

XXHey Dave! I've got some old AC/DC and KISS albums, and as I know
XXyou are a collector, do you want to buy them off of me before
XXI make ashtrays out of them (or frisbees...)?

XX                        Humourously,
XX                                        Jack 








XXMore: @
XX.eb
XX.DE
XX.P 0
XXNeedless to say, we can't let this message go by without replying!
XXSo let's press <\fIreturn\fR> to return to the main menu, 
XXthen use the
XX.I "reply"
XXcommand to respond.
XX.P 0
XXAfter pressing the `\fIr\fR' key, the program asks if a copy of the 
XXmessage is desired (the character under the cursor indicates the
XXdefault if <return> is pressed.  In this case, the default is 'no');
XX.sp
XX.nf
XX    copy message? (y/n) @
XX.fi
XX.P 0
XXWe choose to answer no, so press the `\fIn\fR' key.  Next 
XX.B Elm
XXverifies that the subject is okay;
XX.sp
XX.nf
XX    Subject: Re: Wanna buy some albums cheap?@
XX.fi
XX.sp
XXTyping anything other than <return> will allow us
XXto change the subject to something more appropriate.
XXWe decide, however, to leave it be and press <\fIreturn\fR> again.
XX.sp
XXFinally, we're asked if we want to send copies of this
XXmessage to anyone.  We don't, so we press <\fIreturn\fR> one
XXmore time.
XX.P 0
XXThe program then puts us
XXin the
XX.I vi
XXeditor with a newly created file.
XX.P 0
XXAfter having entered a suitable reply, and left the editor,
XXthe 
XX.B Elm
XXsystem then verifies that we really want to send the message with;
XX.sp
XX    Are you sure you want to send this message? (y/n) @
XX.sp
XXTo which the response is `\fIy\fR' for 'yes'.  It then sends the message off
XXto Jack, who will receive it hopefully quite soon (or at least
XXbefore he makes ashtrays out of the albums!)  (we'll ignore the
XXnext message, which seems to be relevent, because these little 
XXdisplays are eating up space in this document anyway!!)
XX.sp
XX.P 0
XXMessage 13 is still the current message,
XXso, now let's save it and the one after it from Jack, message 14,
XXby \fItagging\fR them both.  We press `\fIt\fR' for \fItag\fR, which 
XXputs the '+' tag indicator on this message, move to the next
XXmessage with the `\fIj\fR' key, then press `\fIs\fR' for \fIsave\fR*
XX.FS *
XXAnother subtle note: operations that work with tagged messages also
XXalways work with the current message, so we don't need to actually
XX\fItag\fR message 14.
XX.FE
XXThis prompts for the file to save to;
XX.nf

XX   Save messages to: @

XX.fi
XXto which we answer \fIjack\fR.  The two messages are then saved to
XXthe specified file, marked for deletion, and the \fItags\fR are
XXremoved from them.
XX.P 0
XXThe screen is now;
XX.DS CB
XX.mk a)
XX.ce
XXMailbox is '/usr/mail/mymail' with 15 messages.  [Version 1.1]
XX.nf

XX.TS
XXr c r l l l l.
XX ->	\ D	13	Apr 3	Jack	(17)	Wanna buy some albums cheap?
XX	\ D	14	Apr 5	Jack	(8)	Cancel the previous offer!
XX	N	15	Apr 5	sdcsvax!dx	(420)	Moving day (long) 
XX.TE
XX.sp 10    
XX.ce 3
XX|=pipe, !=shell, ?=help, <n>=set current to n, /=search pattern
XXA)lias, C)hange mailbox, D)elete, E)dit, F)orward, G)roup reply, M)ail, 
XXN)ext, O)ptions, P)rint, R)eply, S)ave, T)ag, Q)uit, U)ndelete, or eX)it
XX                                                            
XXElm : @
XX.sp 2
XX.eb
XX.DE
XX.P 0
XXNow lets go back to the first page of messages by typing '\fI=\fR';
XX.DS CB
XX.mk a)
XX.ce
XXMailbox is '/usr/mail/mymail' with 15 messages.  [Version 1.1]
XX.nf

XX.TS
XXr c r l l l l.
XX ->		1	Apr 3	rob	(24)	Doing anything tonight?
XX		2	Apr 5	Joe	(154)	bug in gammon game
XX		3	Apr 5	root	(13)
XX		4	Apr 6	root	(7)	(continuation of previous message)
XX	U	5	Apr 8	decvax!mouse	(68)	Re: net.music article decvax:495
XX		6	Apr 13	John Jacobs	(194)	How can you hate RUSH?
XX		7	Apr 15	kevin	(27)	More software requests
XX	N	8	Apr 18	games	(26)	Hi there
XX	N	9	Apr 18	Don Knuth	(354)	Your version of TeX...
XX	N	10	Apr 23	Carl Smith	(53)	(More silly stuff
XX	N	11	Apr 24	jad@hpcnoe	(84)	Chico?  Why go there?
XX	N	12	Apr 24	Larry Fenske	(49)	hi there...
XX.TE
XX.sp
XX.ce 3
XX|=pipe, !=shell, ?=help, <n>=set current to n, /=search pattern
XXA)lias, C)hange mailbox, D)elete, E)dit, F)orward, G)roup reply, M)ail, 
XXN)ext, O)ptions, P)rint, R)eply, S)ave, T)ag, Q)uit, U)ndelete, or eX)it
XX                                                            
XXElm : @
XX.sp 2
XX.eb
XX.DE
XX.P 0
XXGee..note five not only looks mildly interesting but it's an 
XX\fBU\fRrgent message too!  So 
XXlet's read it by typing \fI5<return>\fR
XXto make that the current message, and press <\fIreturn\fR> again
XXto read it.  After reading
XXthe message we decide that it's utterly worthless, not even worth
XXreplying to, let alone saving, so we'll mark it
XXfor future deletion with the `d' \fIdelete\fR key.
XX.P 0
XXA `D' is put next to the message now...
XX.P 0
XXBefore we finish up, we suddenly remember that one of the 
XXmessages was supposed to be about how to write decent 
XXdocumentation for Unix software, so let's try to find it...
XX.P 0
XXFirst off, we'll move back to message one with the `\fI=\fR'
XXkey and then use the `/' \fIpattern matching\fR command:
XX.nf

XX    Elm : Pattern               	/ = match anywhere in messages
XX    Match pattern: @

XX.fi
XXwe'll type in \fIdocument\fR (it's case insensitive) and see if the system 
XXcan find it.  After a brief second or two it returns 'pattern not found.'
XXHmm...maybe it's not either the from or the subject of
XXany of the messages...In case that's true, let's try using 
XXthe \fImatch anywhere in message\fR command;
XX.P 0
XXWe again type `/' for \fIpattern matching\fR;
XX.nf

XX    Elm : Pattern              		/ = match anywhere in messages
XX    Match pattern: @

XX.fi
XXAnd now we'll use `/' again to get the match anywhere in file
XXoption.  Now the bottom of the screen looks like;
XX.nf

XX    Elm : Pattern             		/ = match anywhere in messages
XX    Match pattern (in entire mailbox): @

XX.fi
XXto which we respond \fIdocument\fR again.  
XX.P 0
XXThe mailer then searches through each line of all the messages in 
XXthe file and moves the current message pointer to message 
XXnumber 7.  A quick check reveals that this message indeed
XXcontains the word `document', but it's not the one we want,
XXso we're going to just get outta here!
XX.P 0
XXWe've had enough mail for today, so lets quit, leaving
XXall the mail in the incoming mailbox, except those few we've
XXmarked for deletion;
XX.sp
XX.I Quit
XXprompts;
XX.sp
XX.nf
XX   Delete messages? (y/n) @
XX.fi
XX.sp
XXto which we answer `\fIy\fR' for yes.  The next prompt is then;
XX.sp
XX.nf
XX   Keep mail in incoming mailbox? (y/n) @
XX.fi
XX.sp
XXto which we also answer yes...the program then quickly saves
XXthe files, removing message 5, 13 and 14 as it goes along, and exits.
XX.sp 2
XX.P 0
XXAs you can see, the program is pretty easy to use!  In fact, it was
XXdesigned to be used without this documentation at all, so you 
XXcould toss this right now (but don't - think of the tree that 
XXsacrificed it's precious life to allow this printout!)
XX.sp 2
XX.H 1 "Non-Interactive Uses of Elm"
XX.P 1
XXBefore we discuss the \fBElm\fR utilities, it's worth noting that 
XXthere are a couple of other ways to use the main mail
XXsystem, namely to 'send only' and to send files (batchmail).
XX.P
XXTo send a message to someone without any of the associated 
XXoverhead of the main system being loaded, you can invoke the
XXmailer with the name(s) of the people to send to.  The 
XXmailer will then prompt for Subject, Copies, and then drop
XXyou in your editor (defined in the ".elmrc" file) to compose
XXthe message.   When composition is complete, the program 
XXverifies transmission then terminates.  For example;
XX.nf

XX  $ \fBelm dave_taylor\fR
XX  To: hplabs!taylor
XX  Subject: \fBthis is a test\fR
XX  Copies To: \fB<return>\fR

XX  <invokes editor, message composed, then>

XX  Are you sure you want to send this? (y/n) \fBy\fR

XX  mail sent.

XX  $

XX.fi
XXNote that the user input is in \fBbold\fR face, so you can see that
XXthe mailer verified the alias expansion too!
XX.sp
XX.P
XXThe mailer also supports batch type mailing, of files and so on,
XXby using the following starting sequence;
XX.nf

XX  $ \fBelm -s "File help.c" dave_taylor < help.c\fR

XX.fi
XXwhich will read in the file and transmit it to the specified user
XXwith the specified subject.  Note that the program is intelligent
XXenough to check to see what the standard input is from this 
XXinvocation, so a command of the form
XX.nf

XX  $ \fBelm -s "file help.c" dave_taylor\fR

XX.fi
XXwould result in the following sequence since the program is reading
XXthe "standard in" for information;
XX.nf

XX  $ \fBelm -s "file help.c" dave_taylor\fR
XX  To: hplabs!taylor
XX  Subject: file help.c

XX  Enter your message, ending with ^D

XX  \fBthis is the message
XX  Please don't ask me why I used this wierd mode!

XX  ^D\fR
XX  <end-of-message>

XX  $

XX.fi
XXwhich is reasonable behaviour!!  (not only that, but this is 
XXalmost exactly what \fI/bin/mail\fR does in the same situation!!)
XX.sp 2
XX.H 1 "The Elm Utilities"
XX.sp
XX.P
XXThe \fBElm\fR program is really much more than a single
XXprogram for reading and writing mail.  It's a unified 
XXenvironment for intelligently dealing with electronic
XXmail.  As a consequence, it contains a number of other
XXprograms to aid in the easy processing of email, 
XXincluding the following pieces;
XX.VL 14 2
XX.LI "checkalias"
XXA script that contains the line \fBelm -c \$*\fR.
XX.LI "newalias"
XXThis program installs new aliases - please see the 
XX\fIElm Alias Users Guide\fR for more information.
XX.LI "newmail"
XXThis program is designed to be put into `background' and then
XXmonitors your incoming mailbox for new mail.  Whenever you
XXreceive new mail, the program will asynchronously write to the
XXscreen a notification, including whom the new mail is from and 
XXwhat the subjects of the messages are.  The output looks like;
XX.DS
XXNew mail has arrived;

XXFrom Jimmy Carter - Urgent matters of state
XXFrom joe@ucbvax.arpa - Did I hear someone say PARTY??
XX.DE
XXThis is quite helpful for deciding in `real time' whether it's
XXnecessary to read the mail immediately or not.
XX.LI "wnewmail"
XXThis is extremely similar to \fInewmail\fR but is 
XXslightly modified to run in a windowing environment.
XXThe differences are that it stays in `foreground' (thereby
XXtaking over a window entirely), and outputs for new 
XXmail in a slightly more succint format;
XX.DS
XXMail from Jimmy Carter -- Urgent matters of state
XXMail From joe@ucbvax.arpa -- Did I hear someone say PARTY??
XX.DE
XX.LI "readmsg"
XXThis handy little program can be used in two ways...first off,
XXit can be used to easily read a specific message in the
XXincoming mailbox, specified by ordinal number, by a string that
XXthe message contains, or by the metacharacter `$' which 
XXrepresents the last message in the mailbox.
XX.P 0
XXFor example;
XX.DS
XX$ \fBreadmsg 4 5 9 | lpr\fR
XX.DE 
XXwould generate a printout, \fIsans\fR headers, of the fourth,
XXfifth and ninth messages in your mailbox.
XX.DS
XX$ \fBreadmsg Carter | page\fR
XX.DE
XXwould be a fast way to read what `ole Jimmy has to say...
XXand
XX.DS
XX$ \fBreadmsg -h hear someone say\fR
XX.DE
XXwould list, including the message headers, the message
XXcontaining the string ``hear someone say''.
XX.LI "from"
XXSimilar to the Berkeley \fIfrom\fR command, this will
XXgive you a ``table of contents'' of either the current
XXmailbox or a mailbox of your choice.   It's useful to
XXsee what mail is pending, or what's in a mailbox.
XX.LI "printmail"
XXThis is a formatting routine that knows that mailboxes look
XXlike and inserts either formfeeds or dashed lines between
XXmessages.  It can be used in either of two ways - either 
XXa mailbox file can be \fIpiped\fR to it or it can be given
XXa list of mailbox file names to format.  The only option
XXon the program is `-d' which indicates that you want to have
XXa dashed line separating messages rather than a formfeed.
XX.P 0
XXFor example;
XX.DS
XX$ \fBprintmail -d | lpr\fR
XX.DE
XXwill print out your current incoming mailbox, separating the messages
XXby a dashed line.
XX.DS
XX$ \fBreadmsg 3 4 10 | printmail | lpr\fR
XX.DE
XXwill print messages 3, 4, and 10 from your incoming mailbox,
XXseparated by formfeeds (that is, each message will start on it's
XXown page).
XX.P 0
XXFinally,
XX.DS
XX$ \fBprintmail ~/mbox ~/Mail/mail.sent | lpr\fR
XX.DE
XXwill print all the messages saved in \fImbox\fR and in your \fImail.sent\fR
XXfiles.  The second file will be started on a new page regardless of
XXthe presence or absence of the `-d' dashed line option.
XX.LI "newalias"
XXThis is used to install new user/group aliases.  Please see the
XX\fIElm Alias Users Guide\fR for further information on this!
XX.LI "fastmail"
XXSometimes you want to have a batchmailing system that works as
XXquickly as possible, not bothering with aliases or any of the
XXother ``deluxe'' features of \fBElm\fR.  An example of this would
XXbe if you have a large mailing list for a newsletter, say.
XXThis command, \fIfastmail\fR, is designed just for that purpose.
XXIt avoids the lengthy startup time of \fBElm\fR while still
XXgenerating valid \fIRFC-822\fR* mail.
XX.FS *
XXIf you don't know what RFC-822 is, don't worry about it!
XX.FE
XXPlease see the `man' entry for more information on this
XXcommand (use \fBman fastmail\fR after installation).
XX.LE
XX.sp 3
XX.H 1 "Credits and So on"
XX.P
XXThis mailer has been evolving over the past year or so with
XXinvaluable comments on the interface and general mail 
XXissues from the following people;
XXWalter Underwood, Larry Fenske, Rob Sartin,
XXJohn Dilley (who got the SPECTRUM version checked out, too!) and Carl DierschowX.
XX.sp
XXFor the Berkeley implementation, lots of help came from
XXJohn Lebovitz and Ken Stone.
XX.sp
XXFor the Amdahl/UTS implementation, thanks to Scott McGregor and
XXStan Isaacs.
XX.sp
XXFor the Sun problems, Dave England in Lancaster (UK) turned out to be
XX``bloody useful'', as he would no doubt say.
XX.sp
XXThe Pyramid version is due to the work of Steve Malone
XXof the University of Washington.
XX.sp
XXA few others have been amazingly disciplined at reporting problems
XXand (usually, much to my relief) indicating the fixes needed,
XXnamely Guy Hillyer and Bruce Townsend. 
XX.sp
XXThere have been many, many others, too numerous to mention, that
XXhave inspired me with questions like "Why can't Elm..." or 
XX"Why does it ..." or "Can we make it..." too.  
XX.sp
XXAlso helpful was the ability to have my `own' machine to 
XXclose up the many many iterative loops that this software
XXhas gone through - since being on a big multi-user machine
XXtends to slow it down to a standstill...
XXFor that, I thank HP Colorado Networks Division for their 
XXsupport, and now HP Labs for the wonderful working environment
XXthat I have here (more than any one person is safe having!)
XX.P
XXFinally, it's also been a very useful experience overall,
XXconfirming my beliefs that iterative software design and
XXkeeping a close watch on users (not to mention an open
XXmind and mailbox!) improves a product manyfold.
@//E*O*F doc/Users.guide//
chmod u=rw,g=r,o=r doc/Users.guide
 
echo x - doc/elm.1
sed 's/^XX//' > "doc/elm.1" <<'@//E*O*F doc/elm.1//'
XX.TH ELM 1L 
XX.ad b
XX.SH NAME
XXelm - an interactive mail system
XX.SH SYNOPSIS
XX.B elm
XX[
XX.B \-achkmrswz
XX] [
XX.B \-f
XX<
XX.B file
XX>] [
XX.B \-d
XX<
XX.B level
XX>]
XX.br
XX.B elm 
XX[
XX.B \-S 
XX<
XX.B subject
XX>] <
XX.B "list of aliases or addresses"
XX>
XX.PP
XX.SH HP-UX COMPATIBILITY
XX.TP 10
XXLevel:
XXHP-UX/STANDARD
XX.TP
XXOrigin:
XXHewlett-Packard
XX.SH DESCRIPTION
XX.I Elm\^
XXis a new interactive mailer program that supercedes 
XX.I mail
XXand 
XX.I mailx.
XX.PP
XXThere are three main ways to use the \fBelm\fR mailer; 
XXone way to use the mailer is to specify a list of addresses on the
XXcommand line when the mailer is invoked.  This will allow sending
XXof a single message to the specified recipients with all the
XXoptions usually available in the \fBelm\fR system itself.
XX.PP
XXThe second way, used most commonly when transmitting files and such,
XXis to specify the subject of the message and the recipients using
XXthe command line and redirect a file as standard input.  For example,
XXthe command 
XX.nf

XX	elm -s testing joe < test.c 

XX.fi
XXwould mail a copy of the
XXfile test.c to alias joe, with the subject "testing" indicated.
XX.PP
XXOtherwise, the starting options are;
XX.TP 1.0i
XX.B "-a"
XXArrow - force the arrow cursor (instead of the inverse bar)
XX.B "-c"
XXCheckalias - expand the following aliases and return.
XX.B "-d <level>"
XXDebug - set specified debug level - Output to "$HOME/Elm:debug.info"
XX.TP
XX.B "-f <file>"
XXFile - read file (specified) rather than the incoming mailbox.
XX.TP
XX.B "-h"
XXHelp - give a list of starting options.
XX.TP
XX.B "?"
XXSynonymous with the "-h" option.
XX.TP
XX.B "-k"
XXKeypad - force knowledge of HP terminal keyboard, to allow
XXthe use of the NEXT, PREV and HOME/SHIFT-HOME keys.
XX.TP
XX.B "-K"
XXKeypad + softkeys - enable use of softkeys on HP terminals only.
XX.TP
XX.B "-m"
XXMenu off - Use the extra lines for more message headers.
XX.TP
XX.B "-s"
XXSubject - specify subject for message to mail.
XX.TP
XX.B "-z"
XXZero - don't enter \fBElm\fR if no mail is pending.
XX.SH AUTHOR
XXDave Taylor, Hewlett-Packard Laboratories
XX.SH SEE ALSO
XX.I "Elm Users Guide", 
XXby Dave Taylor
XX.sp
XX.br
XX.I "Elm Reference Guide"
XXby Dave Taylor
XX.sp 
XX.br
XX.I "Elm Alias Users Guide"
XXby Dave Taylor
XX.sp 
XX.br
XXnewalias(1L), checkalias(1L), mail(1), mailx(1), from(1L), printmail(1L)
XX.SH FILES
XX/usr/local/bin/elm-help.main      help file
XX.br
XX/usr/mail/.alias_hash             system alias hash table
XX.br
XX/usr/mail/.alias_data             system alias data table
XX.br
XX$home/.alias_hash                 user alias hash table
XX.br
XX$home/.alias_data                 user alias data table
XX.br
XX/tmp/snd*                         outgoing mail edit buffer
XX.br
XX/tmp/mbox*                        temporary mailbox
XX.br
XX$HOME/ELM:debug.info              Debug output if turned on
XX.SH DIAGNOSTICS
XXShould know about keyboards/softkey terminals other than HP.  (If only 
XXtermcap were that powerful!)
@//E*O*F doc/elm.1//
chmod u=rw,g=r,o=r doc/elm.1
 
echo x - hdrs/curses.h
sed 's/^XX//' > "hdrs/curses.h" <<'@//E*O*F hdrs/curses.h//'
XX/*** 			curses.h			***/

XX/*** (C) Copyright 1986 Dave Taylor			***/

XX     /*** Include file for seperate compilation.  ***/

XX#define OFF		0
XX#define ON 		1

XXint  InitScreen(),      /* This must be called before anything else!! */

XX     ClearScreen(), 	 CleartoEOLN(),

XX     MoveCursor(),
XX     CursorUp(),         CursorDown(), 
XX     CursorLeft(),       CursorRight(), 

XX     StartBold(),        EndBold(), 
XX     StartUnderline(),   EndUnderline(), 
XX     StartHalfbright(),  EndHalfbright(),
XX     StartInverse(),     EndInverse(),
XX	
XX     transmit_functions(),

XX     Raw(),              ReadCh();

XXchar *return_value_of();
@//E*O*F hdrs/curses.h//
chmod u=rw,g=r,o=r hdrs/curses.h
 
echo x - hdrs/defs.h
sed 's/^XX//' > "hdrs/defs.h" <<'@//E*O*F hdrs/defs.h//'
XX/**		defs.h			**/

XX/**  define file for ELM mail system.  **/

XX/**  (C) Copyright 1985 Dave Taylor    **/

XX#include "sysdefs.h"	/* system/configurable defines */

XX#define VERSION		"1.1" /* Version number!  WHAT_STRING should agree */

XX#define WHAT_STRING	"@(#) Version 1.1, initial release - June 1986"

XX#define SLEN		256	    /* long for ensuring no overwrites... */
XX#define SHORT		5	    /* super short strings!		  */
XX#define NLEN		20	    /* name length for aliases            */
XX#define SHORT_SLEN      40
XX#define STRING		100	/* reasonable string length for most..      */
XX#define LONG_SLEN	250	/* for mail addresses from remote machines! */
XX#define LONG_STRING	500	/* even longer string for group expansion   */
XX#define VERY_LONG_STRING 2500	/* huge string for group alias expansion    */

XX#define BREAK		(char)  0	/* default interrupt    */
XX#define BACKSPACE	(char)  8	/* backspace character  */
XX#define TAB		(char)  9       /* tab character        */
XX#define RETURN		(char) 13	/* carriage return char */
XX#define LINE_FEED	(char) 10	/* line feed character  */
XX#define FORMFEED	(char) 12	/* form feed (^L) char  */
XX#define COMMA		','		/* comma character      */
XX#define SPACE		' '		/* space character      */
XX#define DOT		'.'		/* period/dot character */
XX#define BANG		'!'		/* exclaimation mark!   */
XX#define AT_SIGN		'@'		/* at-sign character    */
XX#define PERCENT		'%'		/* percent sign char.   */
XX#define COLON		':'		/* the colon ..		*/
XX#define ESCAPE		(char) 27	/* the escape		*/
XX#define NO_OP_COMMAND	'\0'		/* no-op for timeouts   */

XX#define STANDARD_INPUT  0		/* file number of stdin */

XX#ifndef TRUE
XX#define TRUE		1
XX#define FALSE		0
XX#endif

XX#define OUTGOING	0		/* defines for lock file   */
XX#define INCOMING	1		/* creation..see lock()    */

XX#define SH		0		/* defines for system_call */
XX#define USER_SHELL	1		/* to work correctly!      */

XX#define EXECUTE_ACCESS	01		/* These five are 	   */
XX#define WRITE_ACCESS	02		/*    for the calls	   */
XX#define READ_ACCESS	04		/*       to access()       */
XX#define ACCESS_EXISTS	00		/*           <etc>         */
XX#define EDIT_ACCESS	06		/*  (this is r+w access)   */

XX#define BIG_NUM		999999		/* big number!             */
XX#define BIGGER_NUM	9999999 	/* bigger number!          */

XX#define START_ENCODE	"[encode]"
XX#define END_ENCODE	"[clear]"

XX#define DONT_SAVE	"[no save]"

XX#define alias_file	".aliases"
XX#define group_file	".groups"
XX#define system_file	".systems"

XX/** some defines for the "status" field of the header record **/

XX#define TAGGED		1		/* these are bit masks */
XX#define DELETED		2
XX#define EXPIRED		4
XX#define ACTION		8
XX#define NEW		16
XX#define PRIORITY	32

XX/** some months... **/

XX#define JANUARY		0			/* months of the year */
XX#define FEBRUARY	1
XX#define MARCH		2
XX#define APRIL		3
XX#define MAY		4
XX#define JUNE		5
XX#define JULY		6
XX#define AUGUST		7
XX#define SEPTEMBER	8
XX#define OCTOBER		9
XX#define NOVEMBER	10
XX#define DECEMBER	11

XX#define equal(s,w)	(strcmp(s,w) == 0)
XX#define min(a,b)	a < b? a : b
XX#define ctrl(c)	        c - 'A' + 1	/* control character mapping */
XX#define plural(n)	n == 1 ? "" : "s"
XX#define lastch(s)	s[strlen(s)-1]
XX#define no_ret(s)	if (lastch(s) == '\n') lastch(s) = '\0' 
XX#define first_word(s,w) (strncmp(s,w, strlen(w)) == 0)
XX#define ClearLine(n)	MoveCursor(n,0); CleartoEOLN()
XX#define whitespace(c)	(c == ' ' || c == '\t')
XX#define quote(c)	(c == '"' || c == '\'') 
XX#define onoff(n)	(n == 0 ? "OFF" : "ON")

XX/** The next function is so certain commands can be processed from the showmsg
XX    routine without rewriting the main menu in between... **/

XX#define special(c)	(c == 'j' || c == 'k')

XX/** and a couple for dealing with status flags... **/

XX#define ison(n,mask)	(n & mask)
XX#define isoff(n,mask)	(~ison(n, mask))

XX#define setit(n,mask)		n |= mask
XX#define clearit(n, mask)	n &= ~mask

XX/** a few for the usage of function keys... **/

XX#define f1	1
XX#define f2	2
XX#define f3	3
XX#define f4	4
XX#define f5	5
XX#define f6	6
XX#define f7	7
XX#define f8	8

XX#define MAIN	0
XX#define ALIAS   1
XX#define YESNO	2
XX#define CHANGE  3
XX#define READ	4

XX/** some possible sort styles... **/

XX#define REVERSE		-		/* for reverse sorting           */
XX#define SENT_DATE	1		/* the date message was sent     */
XX#define RECEIVED_DATE	2		/* the date message was received */
XX#define SENDER		3		/* the name/address of sender    */
XX#define SIZE		4		/* the # of lines of the message */
XX#define SUBJECT		5		/* the subject of the message    */
XX#define STATUS		6		/* the status (deleted, etc)     */

XX/* wouldn't it be nice to have variable argument macros... */

XX#define dprint0(n,s)	     if (debug >= n) { \
XX				fprintf(debugfile, s); fflush(debugfile); }

XX#define dprint1(n,s,a)	     if (debug >= n) { \
XX				fprintf(debugfile, s, a);  fflush(debugfile); }

XX#define dprint2(n,s,a,b)     if (debug >= n) { \
XX			        fprintf(debugfile, s, a, b); fflush(debugfile);}

XX#define dprint3(n,s,a,b,c)   if (debug >= n) { fprintf(debugfile, \
XX				s, a, b, c); fflush(debugfile); }

XX#define dprint4(n,s,a,b,c,d)  if (debug >= n) { fprintf(debugfile, \
XX				s, a, b, c, d); fflush(debugfile); }

XX#define dprint5(n,s,a,b,c,d,e) if (debug >= n) { fprintf(debugfile, \
XX			        s, a, b, c, d, e); fflush(debugfile); }

XX#define dprint6(n,s,a,b,c,d,e,f) if (debug >= n) { fprintf(debugfile, \
XX			        s, a, b, c, d, e, f); fflush(debugfile); }

XX/* I guess this corrects it, though.  Wretched stuff though! */

XX/* some random records... */

XXstruct date_rec {
XX	int  month;		/** this record stores a **/
XX	int  day;		/**   specific date and  **/
XX	int  year;		/**     time...		 **/
XX	int  hour;
XX	int  minute;
XX       };

XXstruct header_rec {
XX	int  lines;		/** # of lines in the message  **/
XX	int  status;		/** Urgent, Deleted, Expired?  **/
XX	int  index_number;	/** relative loc in file...    **/
XX	long offset;		/** offset in bytes of message **/
XX	struct date_rec received; /** when elm received here   **/
XX	char from[STRING];	/** who sent the message?      **/
XX	char to[STRING];	/** who it was sent to	       **/
XX	char dayname[8];	/**  when the                  **/
XX	char month[10];		/**        message             **/
XX	char day[3];		/**          was 	       **/
XX	char year[5];		/**            sent            **/
XX	char time[NLEN];	/**              to you!       **/
XX	char subject[STRING];   /** The subject of the mail    **/
XX       };

XXstruct alias_rec {
XX	char   name[NLEN];	/* alias name 			     */
XX	long   byte;		/* offset into data file for address */
XX       };

XXstruct lsys_rec {
XX	char   name[NLEN];	/* name of machine connected to      */
XX	struct lsys_rec *next;	/* linked list pointer to next       */
XX       };

XXstruct addr_rec {
XX	 char   address[NLEN];	/* machine!user you get mail as      */
XX	 struct addr_rec *next;	/* linked list pointer to next       */
XX	};
@//E*O*F hdrs/defs.h//
chmod u=rw,g=r,o=r hdrs/defs.h
 
echo x - hdrs/elm.h
sed 's/^XX//' > "hdrs/elm.h" <<'@//E*O*F hdrs/elm.h//'
XX/**		elm.h			**/

XX/**  header file for ELM mail system.  **/

XX/**  (C) Copyright 1986, Dave Taylor   **/

XX#include <stdio.h>
XX#include <fcntl.h>

XX#include "../hdrs/curses.h"
XX#include "../hdrs/defs.h"

XX/******** static character string containing the copyright notice  *******/

XXstatic char copyright[] = { "(C) Copyright 1986, Dave Taylor" };

XX/******** and another string for the version number and so on     ********/

XXstatic char ident[] = { WHAT_STRING };

XX/******** global variables accessable by all pieces of the program *******/

XXint current = 0;		/* current message number  */
XXint header_page = 0;     	/* current header page     */
XXint last_header_page = -1;     	/* last header page        */
XXint message_count = 0;		/* max message number      */
XXint headers_per_page;		/* number of headers/page  */
XXchar infile[SLEN];		/* name of current mailbox */
XXchar hostname[SLEN];		/* name of machine we're on*/
XXchar username[SLEN];		/* return address name!    */
XXchar full_username[SLEN];	/* Full username - gecos   */
XXchar home[SLEN];		/* home directory of user  */
XXchar folders[SLEN];		/* folder home directory   */
XXchar mailbox[SLEN];		/* mailbox name if defined */
XXchar editor[SLEN];		/* editor for outgoing mail*/
XXchar printout[SLEN];		/* how to print messages   */
XXchar savefile[SLEN];		/* name of file to save to */
XXchar calendar_file[SLEN];	/* name of file for clndr  */
XXchar prefixchars[SLEN];		/* prefix char(s) for msgs */
XXchar shell[SLEN];		/* current system shell    */
XXchar pager[SLEN];		/* what pager to use       */
XXchar batch_subject[SLEN];	/* subject buffer for batchmail */

XXchar backspace,			/* the current backspace char */
XX     kill_line;			/* the current kill-line char */

XXchar up[SHORT], down[SHORT];	/* cursor control seq's    */
XXint  cursor_control = FALSE;	/* cursor control avail?   */

XXchar start_highlight[SHORT],
XX     end_highlight[SHORT];	/* stand out mode...       */

XXint  has_highlighting = FALSE;	/* highlighting available? */

XXchar *weedlist[MAX_IN_WEEDLIST];
XXint  weedcount;

XXint file_changed = 0;		/* flag: true if infile changed     */
XXint mini_menu = 1;		/* flag: menu specified?	    */
XXint mbox_specified = 0;		/* flag: specified alternate mbox?  */
XXint check_first = 1;		/* flag: verify mail to be sent!    */
XXint auto_copy = 0;		/* flag: automatically copy source? */
XXint filter = 0;			/* flag: weed out header lines?	    */
XXint resolve_mode = 1;		/* flag: delete saved mail?	    */
XXint auto_cc = 0;		/* flag: mail copy to user?	    */
XXint noheader = 0;		/* flag: copy + header to file?     */
XXint title_messages = 0;		/* flag: title message display?     */
XXint edit_outbound = 0;		/* flag: edit outbound headers?	    */
XXint read_aliases = 1;		/* flag: read in alias files?	    */
XXint hp_terminal = 0;		/* flag: are we on HP term?	    */
XXint hp_softkeys = 0;		/* flag: are there softkeys?        */
XXint save_by_name = 0;		/* flag: save mail by login name?   */
XXint notesfile = 0;		/* flag: is input file from notes?  */
XXint mail_only = 0;		/* flag: send mail then leave?      */
XXint check_only = 0;		/* flag: check aliases then leave?  */
XXint move_when_paged = 0;	/* flag: move when '+' or '-' used? */
XXint point_to_new = 1;		/* flag: start pointing at new msg? */
XXint bounceback = 0;		/* flag: bounce copy off remote?    */
XXint signature = 0;		/* flag: include $home/.signature?  */
XXint always_leave = 0;		/* flag: always leave msgs pending? */
XXint always_del = 0;		/* flag: always delete marked msgs? */
XXint arrow_cursor = 0;		/* flag: use "->" cursor regardless?*/
XXint debug = 0; 			/* flag: default is no debug!       */

XX#ifdef UTS
XX int isatube = 0;		/* flag: are we on an IBM 3270?     */
XX#endif

XXint sortby = REVERSE SENT_DATE;	/* how to sort incoming mail...     */

XXlong timeout = 0L;		/* timeout (secs) on main prompt    */

XXint mailbox_defined = 0;	/** mailbox specified?    **/

XXint LINES=23;			/** lines per screen      **/
XXint COLUMNS=80;			/** columns per page      **/

XXint size_of_pathfd;		/** size of pathfile, 0 if none **/

XXFILE *mailfile;			/* current mailbox file     */
XXFILE *debugfile;		/* file for debug output    */
XXFILE *pathfd;			/* path alias file          */
XXFILE *domainfd;			/* domain file		    */

XXlong mailfile_size;		/* size of current mailfile */

XXstruct header_rec header_table[MAX_HEADERS];

XXstruct alias_rec user_hash_table[MAX_UALIASES];
XXstruct alias_rec system_hash_table[MAX_SALIASES];

XXstruct date_rec last_read_mail; /* last time we read mailbox  */

XXstruct lsys_rec *talk_to_sys;   /* what machines do we talk to? */

XXstruct addr_rec *alternative_addresses;	/* how else do we get mail? */

XXint system_files = 0;		/* do we have system aliases? */
XXint user_files = 0;		/* do we have user aliases?   */

XXint system_data;		/* fileno of system data file */
XXint user_data;			/* fileno of user data file   */

XXint userid;			/* uid for current user	      */
XXint groupid;			/* groupid for current user   */
@//E*O*F hdrs/elm.h//
chmod u=rw,g=r,o=r hdrs/elm.h
 
echo x - hdrs/headers.h
sed 's/^XX//' > "hdrs/headers.h" <<'@//E*O*F hdrs/headers.h//'
XX/**		headers.h		**/

XX/**  header file for ELM mail system.  **/

XX/**  (C) Copyright 1985, Dave Taylor   **/

XX#include <stdio.h>
XX#include <fcntl.h>

XX#include "curses.h"
XX#include "defs.h"

XX/******** global variables accessable by all pieces of the program *******/

XXextern int current;		/* current message number  */
XXextern int header_page;         /* current header page     */
XXextern int last_header_page;    /* last header page        */
XXextern int message_count;	/* max message number      */
XXextern int headers_per_page;	/* number of headers/page  */
XXextern char infile[SLEN];	/* name of current mailbox */
XXextern char hostname[SLEN];	/* name of machine we're on*/
XXextern char username[SLEN];	/* return address name!    */
XXextern char full_username[SLEN];/* Full username - gecos   */
XXextern char home[SLEN];		/* home directory of user  */
XXextern char folders[SLEN];	/* folder home directory   */
XXextern char mailbox[SLEN];	/* mailbox name if defined */
XXextern char editor[SLEN];	/* default editor for mail */
XXextern char printout[SLEN];	/* how to print messages   */
XXextern char savefile[SLEN];	/* name of file to save to */
XXextern char calendar_file[SLEN];/* name of file for clndr  */
XXextern char prefixchars[SLEN];	/* prefix char(s) for msgs */
XXextern char shell[SLEN];	/* default system shell    */
XXextern char pager[SLEN];	/* what pager to use...    */
XXextern char batch_subject[SLEN];/* subject buffer for batchmail */

XXextern char backspace,		/* the current backspace char  */
XX	    kill_line;		/* the current kill_line char  */

XXextern char up[SHORT], 
XX	    down[SHORT];	/* cursor control seq's    */
XXextern int  cursor_control;	/* cursor control avail?   */

XXextern char start_highlight[SHORT],
XX	    end_highlight[SHORT];  /* standout mode... */

XXextern int  has_highlighting;	/* highlighting available? */

XX/** the following two are for arbitrary weedout lists.. **/

XXextern char *weedlist[MAX_IN_WEEDLIST];
XXextern int  weedcount;		/* how many headers to check?        */

XXextern int  file_changed;	/* flag: true iff infile changed      */
XXextern int  mini_menu;		/* flag: display menu?     	      */
XXextern int  mbox_specified;     /* flag: specified alternate mailbox? */
XXextern int  check_first;	/* flag: verify mail to be sent!      */
XXextern int  auto_copy;		/* flag: auto copy source into reply? */
XXextern int  filter;		/* flag: weed out header lines?	      */
XXextern int  resolve_mode;	/* flag: resolve before moving mode?  */
XXextern int  auto_cc;		/* flag: mail copy to yourself?       */
XXextern int  noheader;		/* flag: copy + header to file?       */
XXextern int  title_messages;	/* flag: title message display?       */
XXextern int  edit_outbound;	/* flag: edit outbound headers?       */
XXextern int  read_aliases;	/* flag: read in alias files??	      */
XXextern int  hp_terminal;	/* flag: are we on an hp terminal?    */
XXextern int  hp_softkeys;	/* flag: are there softkeys?          */
XXextern int  save_by_name;  	/* flag: save mail by login name?     */
XXextern int  notesfile;		/* flag: is input file from notes?    */
XXextern int  mail_only;		/* flag: send mail then leave?        */
XXextern int  check_only;		/* flag: check aliases and leave?     */
XXextern int  move_when_paged;	/* flag: move when '+' or '-' used?   */
XXextern int  point_to_new;	/* flag: start pointing at new msgs?  */
XXextern int  bounceback;		/* flag: bounce copy off remote?      */
XXextern int  signature;		/* flag: include $home/.signature?    */
XXextern int  always_leave;	/* flag: always leave mail pending?   */
XXextern int  always_del;		/* flag: always delete marked msgs?   */
XXextern int  arrow_cursor;	/* flag: use "->" regardless?	      */
XXextern int  debug;		/* flag: debugging mode on?           */

XX#ifdef UTS
XXextern int  isatube;		/* flag: are we on an IBM 3270 tube?  */
XX#endif

XXextern int  sortby;		/* how to sort mailboxes	      */

XXextern long timeout;		/* seconds for main level timeout     */

XXextern int mailbox_defined;	/** specified mailbox?  **/

XXextern int LINES;		/** lines per screen    **/
XXextern int COLUMNS;		/** columns per line    **/

XXextern int size_of_pathfd;	/** size of pathfile, 0 if none **/

XXextern FILE *mailfile;		/* current mailbox file     */
XXextern FILE *debugfile;		/* file for debut output    */
XXextern FILE *pathfd;		/* path alias file          */
XXextern FILE *domainfd;		/* domains file 	    */

XXextern long mailfile_size;	/* size of current mailfile */

XXextern struct header_rec header_table[MAX_HEADERS];

XXextern struct alias_rec user_hash_table  [MAX_UALIASES];
XXextern struct alias_rec system_hash_table[MAX_SALIASES];

XXextern struct date_rec last_read_mail;

XXextern struct lsys_rec *talk_to_sys;	/* who do we talk to? */

XXextern struct addr_rec *alternative_addresses;	/* how else do we get mail? */

XXextern int system_files;	/* do we have system aliases? */
XXextern int user_files;		/* do we have user aliases?   */

XXextern int system_data;		/* fileno of system data file */
XXextern int user_data;		/* fileno of user data file   */

XXextern int userid;		/* uid for current user	      */
XXextern int groupid;		/* groupid for current user   */
@//E*O*F hdrs/headers.h//
chmod u=rw,g=r,o=r hdrs/headers.h
 
echo x - hdrs/help.h
sed 's/^XX//' > "hdrs/help.h" <<'@//E*O*F hdrs/help.h//'
XX	case '!': s = 
XX           "Escape to the Unix shell of your choice, or just to enter commands";
XX	   break;
XX	case '@': s = 
XX	   "Debug - display a summary of the notes on the header page";
XX	   break;
XX	case '|': s = 
XX	 "Pipe the current message or tagged messages to the command specified";
XX	   break;
XX	case '#': s = 
XX	  "Debug - display all information known about current message";
XX	  break;
XX	case '%': s = 
XX           "Debug - display the computed return address of the current message";
XX	   break;
XX	case '*': s = "Go to the last message in the current mailbox";
XX	   break;
XX	case '-': s = 
XX	   "Go to the previous page of messages in the current mailbox";
XX	   break;
XX	case '=': s = "Go to the first message in the current mailbox";
XX	   break;
XX	case ' ': s = "Go to the next page of messages in the current mailbox";
XX	   break;
XX	case '+': s = "Go to the next page of messages in the current mailbox";
XX	   break;
XX	case '/': s = "Search for specified pattern in mailbox";
XX	   break;
XX	case '<': s = "Scan current message for calendar entries (if enabled)";
XX	   break;
XX	case '>': s = 
XX	   "Save current message or tagged messages to specified file";
XX	   break;
XX	case '^': s = 
XX	   "Toggle the Delete/Undelete status of the current message";
XX	   break;
XX	case 'a': s = 
XX	   "Enter the alias sub-menu section.  Create and display aliases";
XX	   break;
XX	case 'b': s = 
XX	   "Bounce (remail) a message to someone as if you have never seen it";
XX	   break;
XX	case 'c': s = 
XX	   "Change mailboxes, leaving the current mailbox as if 'quitting'";
XX	   break;
XX	case 'd': s = "Mark the current message for future deletion";
XX	   break;
XX	case 'e': s = 
XX           "Invoke the editor on the entire mailbox, resync'ing when done";
XX	   break;
XX	case 'f': s = 
XX           "Forward the current message to someone, return address is yours";
XX	   break;
XX	case 'g': s = 
XX         "Group reply not only to the sender, but to everyone who received msg";
XX	   break;
XX	case 'h': s = "Display message with all Headers (ignore weedout list)";
XX	   break;
XX	case 'j': s = 
XX           "Go to the next message.  This is the same as the DOWN arrow";
XX	   break;
XX	case 'k': s = 
XX           "Go to the previous message.  This is the same as the UP arrow";
XX	   break;
XX	case 'm': s = 
XX           "Create and send mail to the specified person or persons";
XX	   break;
XX	case 'n': s = 
XX           "Read the current message, then move current to next messge";
XX	   break;
XX	case 'o': s = "Go to the options submenu";
XX	   break;
XX	case 'p': s = "Print the current message or the tagged messages";
XX	   break;
XX	case 'q': s = "Quit the mailer, asking about deletion, saving, etc";
XX	   break;
XX	case 'r': s = 
XX      "Reply to the message.  This only sends to the originator of the message";
XX	   break;
XX	case 's': s = 
XX           "Save current message or tagged messages to specified file";
XX	   break;
XX	case 't': s = 
XX           "Tag a message for further operations (or untag if tagged)";
XX	   break;
XX	case 'u': s = "Undelete - remove the deletion mark on the message";
XX	   break;
XX	case 'x': s = "Exit the mail system quickly";
XX	   break;
XX	
XX	case '\n':
XX	case '\r': s = "Read the current message";
XX	   break;

XX	case ctrl('L'): s = "Rewrite the screen";	
XX	   break;
XX        case ctrl('?'):					    /* DEL */
XX	case ctrl('Q'): s = "Exit the mail system quickly";
XX	   break;
XX	default : 
XX	
XX		/** first off, is it a digit the user entered?? **/

XX	          if (isdigit(ch)) 
XX	            s = "Make specified number the current message";
@//E*O*F hdrs/help.h//
chmod u=rw,g=rw,o=rw hdrs/help.h
 
echo x - hdrs/sysdefs.h
sed 's/^XX//' > "hdrs/sysdefs.h" <<'@//E*O*F hdrs/sysdefs.h//'

XX/**			sysdefs.h			**/

XX/**  System level, configurable, defines for the ELM mail system.  **/

XX/**  (C) Copyright 1986 Dave Taylor                                **/

XX/** define the following if you think that the information in messages
XX    that have "Reply-To:" and/or "From:" fields with addresses will
XX    contain valid addressing information.  If this isn't defined, the
XX    calculated return address will ALWAYS be used instead.  (note that
XX    this doesn't necessarily preclude the use of G)roup replies).

XX#define USE_EMBEDDED_ADDRESSES	

XX**/

XX#define FIND_DELTA	10		/* byte region where the binary search
XX					   on the path alias file is fruitless 
XX                                           (can't be within this boundary)    */

XX#define MAX_HEADERS	500	/* max number of messages in one file!   */	
XX#define MAX_SALIASES	503	/* number of system aliases allowed      */
XX#define MAX_UALIASES	251	/* number of user aliases allowed 	 */
XX#define MAX_IN_WEEDLIST 50	/* max headers to weed out               */

XX#define MAX_HOPS	35	/* max hops in return addr to E)veryone  */

XX#define MAX_ATTEMPTS	6	/* #times to attempt lock file creation */

XX/** see leavembox.c to determine if this should be defined or not....The 
XX    default is to NOT have it defined.

XX#define REMOVE_AT_LAST

XX**/

XX#define DEFAULT_BATCH_SUBJECT  "no subject (file transmission)"

XX/** If you want to have the mailer know about valid mailboxes on the
XX    host machine (assumes no delivery agent aliases) then you should
XX    undefine this (the default is to have it defined)...


XX#define NOCHECK_VALIDNAME

XX**/

XX/** If your machine doesn't have virtual memory (specifically the vfork() 
XX    command) then you should define the following....		

XX#define NO_VM

XX**/

XX/** If you want the mailer to check the pathalias database BEFORE it
XX    looks to see if a specified machine is in the L.sys database (in
XX    some cases routing is preferable to direct lines) then you should
XX    define the following...

XX#define LOOK_CLOSE_AFTER_SEARCH

XX**/

XX/** If you'd rather the program automatically used the 'uuname' command
XX    to figure out what machines it talks to (instead of trying to get
XX    it from L.sys first) then define the following...

XX#define USE_UUNAME

XX**/

XX/** If you'd like "newmail" to automatically go into background when you
XX    start it up (instead of the "newmail &" junk with the process id output,
XX    then define the following...

XX#define AUTO_BACKGROUND

XX**/

XX/** If you'd rather your mail transport agent (ie sendmail) put the From:
XX    line into the message, define the following...


XX#define DONT_ADD_FROM

XX**/

XX/** If your machine prefers the Internet notation of user@host for the
XX    From: line and addresses, define the following...(the default is to 
XX    use this rather than the USENET notation - check your pathalias file!)

XX#define INTERNET_ADDRESS_FORMAT

XX**/

XX/** If you're on a machine that prefers UUCP to Internet addresses, then
XX    define the following (the basic change is that on a machine that
XX    receives messages of the form <path>!user@<localhost> the displayed
XX    address will be <path>!user instead of user@<localhost>.

XX    BOGUS_INTERNET is the address that your local system appends to 
XX    messages occasionally.  The algorithm is simply to REMOVE the
XX    BOGUS_INTERNET string.  This is horrible.  *sigh*

XX#define PREFER_UUCP
XX#define BOGUS_INTERNET	"@hplabs.HP.COM"

XX**/

XX/** If you're running ACSNET and/or want to have your domain name
XX    attached to your hostname on outbound mail then you can define
XX    the following (default are not defined)

XX#define USE_DOMAIN
XX#define DOMAIN		"<enter your domain here>"

XX**/

XX/** If you are going to be running the mailer with setgid mail (or
XX    something similar) you'll need to define the following to ensure
XX    that the users mailbox in the spool directory has the correct
XX    group (NOT the users group)
XX**/

XX#define SAVE_GROUP_MAILBOX_ID

XX/**
XX**/

XX/** If you want a neat feature that enables scanning of the message
XX    body for entries to add to the users ".calendar" (or whatever)
XX    file, define this.
XX**/

XX#define ENABLE_CALENDAR
XX#define dflt_calendar_file	"calendar"	/* in HOME directory */

XX/**
XX**/

XX#define NOTES_HEADER		"/***** "
XX#define NOTES_FOOTER		"/* ---------- */"

XX#ifdef BSD
XX# define system_hash_file	"/usr/spool/mail/.alias_hash"
XX# define system_data_file	"/usr/spool/mail/.alias_data"
XX#else
XX# define system_hash_file	"/usr/mail/.alias_hash"
XX# define system_data_file	"/usr/mail/.alias_data"
XX#endif

XX#define pathfile		"/usr/lib/nmail.paths"
XX#define domains			"/usr/lib/domains"

XX#define Lsys			"/usr/lib/uucp/L.sys"

XX/** where to put the output of the elm -d command... (in home dir) **/
XX#define DEBUG		"ELM:debug.info"

XX#define temp_file	"/tmp/snd."
XX#define temp_mbox	"/tmp/mbox."
XX#define temp_print      "/tmp/print."
XX#define mailtime_file	".last_read_mail"
XX#define readmsg_file	".readmsg"
XX#define signature_file	".signature"

XX#ifdef BSD
XX# define default_editor	"/usr/ucb/vi"
XX# define mailhome	"/usr/spool/mail/"
XX# define default_pager	"/usr/ucb/page"
XX#else
XX# define default_editor	"/usr/bin/vi"
XX# define mailhome	"/usr/mail/"
XX# define default_pager	"/usr/bin/more"
XX#endif

XX#define sendmail	"/usr/lib/sendmail"
XX#define smflags		"-oi"
XX#define mailer		"/bin/rmail"
XX#define mailx		"/usr/bin/mailx"

XX#define cutfile		"/usr/local/bin/cutfile"

XX#define helphome	"/usr/local/lib"
XX#define helpfile	"elm-help.main"

XX#define elmrcfile	"/.elmrc"
XX#define mailheaders	".elmheaders"
XX#define unedited_mail	"emergency.mbox"
XX#define newalias	"newalias -q 1>&2 > /dev/null"
XX#define readmsg		"readmsg"
XX#define printmail	"printmail"

XX#define remove		"/bin/rm -f"		/* how to remove a file */
XX#define cat		"/bin/cat"		/* how to display files */
XX#define uuname		"uuname"		/* how to get a uuname  */


XX/** -- end of file sysdefsh. -- **/

@//E*O*F hdrs/sysdefs.h//
chmod u=rw,g=rw,o=rw hdrs/sysdefs.h
 
echo Inspecting for damage in transit...
temp=/tmp/sharin$$; dtemp=/tmp/sharout$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
     874    4393   25463 Users.guide
     127     456    2788 elm.1
      27      54     620 curses.h
     209    1034    6693 defs.h
     125     777    4889 elm.h
     120     748    5082 headers.h
     105     558    3466 help.h
     201     794    5805 sysdefs.h
    1788    8814   54806 total
!!!
wc  doc/Users.guide doc/elm.1 hdrs/curses.h hdrs/defs.h hdrs/elm.h hdrs/headers.h hdrs/help.h hdrs/sysdefs.h | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if test -s $dtemp
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0