home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume12 / vmail / part01 next >
Encoding:
Text File  |  1988-03-13  |  21.0 KB  |  597 lines

  1. Article 998 of comp.sources.unix:
  2. Path: s.cc.purdue.edu!h.cc.purdue.edu!j.cc.purdue.edu!pur-ee!iuvax!inuxc!ihnp4!ptsfa!ames!amdcad!sun!pitstop!sundc!seismo!uunet!munnari!jz
  3. From: jz@mulga.oz.au (Justin Zobel)
  4. Newsgroups: comp.sources.unix
  5. Subject: v12i004:  vmail - screen-based mail handler, Part01/03
  6. Message-ID: <1854@munnari.oz>
  7. Date: 13 Oct 87 21:13:40 GMT
  8. Sender: kre@munnari.oz
  9. Lines: 583
  10. Approved: kre@munnari.oz.au
  11.  
  12. Submitted by: jz@mulga.oz.au
  13. Posting-number: Volume 12, Issue 4
  14. Archive-name: vmail/Part01
  15.  
  16. This is the first of three parts of vmail, an interactive mail
  17. handler that sits on top of MH.
  18.     vmail has a number of advantages over raw MH.  It is screen-based and
  19. faster (and more convenient) than the MH show-scan-rmm refile cycle.
  20. vmail makes it feasible for users to organise and keep track of moderate
  21. volumes of mail without wasting too much time, and is very simple to use.
  22. It has been in use at Melbourne University Computer Science Department
  23. for about six months without any problems, and has become the interface of
  24. choice for many users.
  25.  
  26. : ---------------------------------------- cut here
  27.  
  28. echo x - "READ_ME" 2>&1
  29. sed "s/^X//" >"READ_ME" <<'!The!End!'
  30. XVMAIL is copyright (C) J. Zobel, University of Melbourne, October 1987.
  31. XPermission to copy and modify vmail is given in full, but copies and
  32. Xmodified copies must contain this copyright notice.
  33. X
  34. X    vmail is an interactive mail handler that sits on top of MH6.5.
  35. XBecause vmail updates the MH environment by updating .mh_sequences,
  36. Xit is not compatible with early versions of MH, although it should
  37. Xwork with MH5 and possibly MH4.
  38. X
  39. X    vmail has a number of advantages over raw MH.  It is screen-based and
  40. Xfaster (and more convenient) than the MH show-scan-rmm refile cycle.
  41. XThe `scan' pages for the specified folders are loaded at start up time;
  42. Xfurther folders may be loaded at any time.  `scan' is replaced by paging
  43. Xbetween screens of stored information, `show' by a fork() to a pager,
  44. X`rmm' and `refile' by calls to rename (2).  Other features, such as folder
  45. Xpacking, are also faster, as most of the required information is already
  46. Xknown to the process.  vmail makes it feasible for users to organise and
  47. Xkeep track of moderate volumes of mail without wasting too much time, and
  48. Xis very simple to use.  It has been in use at Melbourne University Computer
  49. XScience Department for about six months without any problems, and has
  50. Xbecome the interface of choice for many users.  Users who (being new to
  51. XUNIX) were introduced to mail with vmail have never tried the MH commands
  52. Xthemselves, being satisfied with the vmail interface and wanting to avoid
  53. Xthe plethora of MH functions and usages.
  54. X
  55. X
  56. XTechnical Notes
  57. X
  58. X    vmail is currently Berkeley specific, in particular use of signal(),
  59. Xvfork(), ioctl() and union wait.  It should work with most versions of MH,
  60. Xbut makes assumptions about the structure of folders, ie, that a folder is
  61. Xa directory containing files whose names are numbers (other files are
  62. Xignored).  By default, a .mh_profile is required to specify alternatives
  63. Xto other defaults such as name of mail directory; the environment variable
  64. XMH may be used to set an alternative profile.  The usual assumptions are
  65. Xmade about the format of mail items - use of fields (if present) such as
  66. X"To:", "From:" and so on, but these also should not cause any difficulties.
  67. X    comp, repl and forw are all forked from vmail rather than imitated,
  68. Xthere being no real time advantage to doing otherwise, but are given by
  69. Xsingle-letter commands rather than longer commands to a shell.  Most MH
  70. Xoptions as set in the profile are ignored (most are not relevant);
  71. Xbecause comp, repl, etc are forks rather than built-ins, this is not
  72. Xreally a problem.  The paths for these executables are in defs.h and
  73. Xmay have to be changed.
  74. X    The most unreliable feature is probably the parsing of inc output in
  75. Xinc.c, used when `i' is given to incorporate new mail.  Because some people
  76. Xlike to give options to inc in their profile, and because inc was too long
  77. Xto consider rewriting, the simplest solution was to parse the inc output -
  78. Xif the format changed this code would break.
  79. X    Some may find the mixture of stdio, curses and ioctl ugly, but it is
  80. Xreasonably orthogonal - stdio is used when tty is in normal mode, curses
  81. Xwhen control is required, and ioctl and signal when processes are being
  82. Xsuspended, woken or forked.
  83. X
  84. XMade with "make" (no arguments).  If cc does not recognize -k option,
  85. Xvalue of make variable STACK must be changed.  The compiler option
  86. X-DUSDATE must be set if dates are to be displayed in US format.
  87. X
  88. XFiles
  89. X
  90. X    READ_ME            This file.
  91. X    vmail.1            Manual entry.
  92. X    Makefile        Version number.
  93. X
  94. X    defs.h            Pathnames, defaults, structs, externs,
  95. X                constants.  Some of these will need to be
  96. X                edited, eg locations of MH routines.
  97. X    macro.h            Simple functions.
  98. X
  99. X    call.c            Forks to MH functions, editor, shell.
  100. X    choose.c        Folder chooser, folder display.
  101. X    cmds.c            Assorted commands.
  102. X    find.c            Searching through headers for strings.
  103. X    inc.c            Handles fork to inc, parsing of inc output.
  104. X    init.c            Startup, interrupt handling.
  105. X    load.c            Loading of folders/mail from mail directory
  106. X                into internal structures.
  107. X    low.c            Some primitive functions.
  108. X    main.c            High-level switch.
  109. X    move.c            Commands for refile, delete, undo.
  110. X    page.c            Commands associated with movement between
  111. X                pages and movement within a page.
  112. X
  113. XNB: All source files are formatted with tabstop=4.
  114. X
  115. X===============================================================================
  116. X
  117. XI would appreciate hearing about bugs/bug fixes/amendments/improvements/
  118. Xadditions; any correspondence should be sent to
  119. X
  120. XUUCP:    ...!munnari!mulga!jz
  121. XARPA:    jz%mulga.oz@uunet.uu.net
  122. XCSNET:    jz%mulga.oz@australia
  123. X
  124. XAny modifications received will be considered for a future release of
  125. Xvmail.  Of particular interest is SYS V compatibility and modifications
  126. Xto suit versions of MH to which I have no access.
  127. !The!End!
  128.  
  129. echo x - "vmail.1" 2>&1
  130. sed "s/^X//" >"vmail.1" <<'!The!End!'
  131. X.TH VMAIL 1 "30 September 1987"
  132. X.UC Melb
  133. X.SH NAME
  134. Xvmail \- tty interface to MH
  135. X.SH SYNOPSIS
  136. X\fBvmail\fR [\-inc] [\-flush] [\-comp] [\-forw] [\-ans]
  137. X[+cur_folder] folders ...
  138. X.SH DESCRIPTION
  139. X\fIvmail\fR is a tty interface to the MH mail system.
  140. XIt combines most of the MH features into a single package, and performs
  141. Xthe most frequently-used functions considerably faster than the
  142. XMH equivalents.
  143. XIn particular, a folder is only scanned once in a \fIvmail\fR
  144. Xsession; the slow scan-show-rmm-scan cycle of MH is eliminated.
  145. XAlso, \fIvmail\fR tends to be simpler for new users to learn than
  146. Xthe MH system.
  147. X.SH "STARTING UP"
  148. X.LP
  149. XWhen \fIvmail\fR is invoked, it loads mail headers for the folders
  150. Xwhich will initially be active.
  151. XThe default is for \fBinbox\fR (or the MH profile field Current-Folder)
  152. Xto be the only active folder.
  153. X(Other folders may be made active during the course of a session.)
  154. XThere are a number of command-line flags.
  155. X\fB\-inc\fR asks \fIvmail\fR to incorporate mail before loading any folders.
  156. X\fB\-flush\fR instructs \fIvmail\fR not to flush typeahead.
  157. X\fB\-comp\fR, \fB\-forw\fR and \fB\-ans\fR specify that \fIcomp\fR, \fIforw\fR
  158. Xand \fIrepl\fR (`answer') respectively do not require that the user give
  159. Xarguments; see the commands \fBc\fR, \fBf\fR and \fBa\fR.
  160. XArguments may also be set by the profile component \fBvmail\fR.
  161. XTypical usage of \fIvmail\fR might be:
  162. X.sp
  163. X    vmail +priv inbox outbox
  164. X.sp
  165. Xto start up \fIvmail\fR with folders \fBpriv\fR, \fBinbox\fR, and
  166. X\fBoutbox\fR active and with \fBpriv\fR as the current folder.
  167. X\fIvmail\fR might then print
  168. X.nf
  169. X.sp
  170. X\f(as    Vmail 9/87 -- reading mail headers
  171. X            inbox: 122-279 (32 items)
  172. X            outbox: 1-95 (19 items)
  173. X            priv: 2-19 (5 items)\fR
  174. X.sp
  175. X.fi
  176. Xas it loaded the named folders.
  177. XWhen loading completed it would bring up the screen
  178. Xrepresenting the mail items in the folder \fBpriv\fR.
  179. X.nf
  180. X.sp
  181. X\f(as     priv (page 1 of 1)
  182. X
  183. X        2  17-06-86  fred@munnari    Just testing << Are you receiving
  184. X        6   7-11-86  To: fred, nerk  A promise << The commitment: Dinn
  185. X        7   9-05-87  bill            thanks for everything, but << wha
  186. X       12  11-05-87 \-bill            Re: thanks for everything, but <<
  187. X       19   9-05-87  To: bill        Re: thanks for everything, but <<\fR
  188. X.sp
  189. X.fi
  190. X(Note that the dates in the example are in British format; a US installation
  191. Xwould have the US form.)
  192. XThe `\fB\-\fR' indicates that a reply has been sent to that piece of mail.
  193. XText to the left of `\fB<<\fR' is the subject, other text is the
  194. Xfirst part of the body.
  195. XThe user could now move up and down between mail items with \fBk\fR and
  196. X\fBj\fR, show the current mail item with \fB<space>\fR, delete the current
  197. Xmail item with \fBd\fR, or forward or answer it with \fBf\fR or \fBa\fR.
  198. X.LP
  199. XIf the folder \fBpriv\fR contained  more mail items than could be
  200. Xdisplayed on a screen, \fBpriv\fR would be broken into a number of pages.
  201. X\fIvmail\fR has one or more pages for each active folder.
  202. XThe user can move between pages, which are ordered alphabetically on
  203. Xfolder name, by typing \fB<return>\fR and \fB<backspace>\fR 
  204. X(forwards and backwards respectively).
  205. X.SH "THE DETAILS"
  206. X.LP
  207. XFor those who like to mix use of MH and \fIvmail\fR, \fIvmail\fR
  208. Xupdates the MH environment on \fBq\fR (quit), \fB!\fR (call shell)
  209. Xand \fB^Z\fR (suspend).
  210. XSpecifically, the fields `Current-Folder' in \fBcontext\fR and
  211. X`cur' in \fBmh-profile\fR are updated to be the current folder and
  212. Xcurrent mail item respectively.
  213. X.LP
  214. XThe following points are relevant to all \fIvmail\fR commands.
  215. XFirst, type-ahead is flushed (as in \fIrn\fR), so any commands
  216. Xtyped ahead of time will be ignored.
  217. XSecond, \fIvmail\fR always remembers the name of an ``alternate
  218. Xfolder'', the last folder other than the current folder with which
  219. Xthere has been an interaction (such as the folder to which an item
  220. Xwas refiled, or the previous current folder).
  221. XThis alternate folder is used by a number of commands.
  222. XThird, some commands may be preceded by a count.
  223. X.LP
  224. XThe following is a complete list of \fIvmail\fR commands.
  225. X.TP 10
  226. X.B <space>
  227. XShow current mail item (like \fIshow\fR).
  228. X.TP 10
  229. X.B <return>
  230. XGo to next active page of mail headers (uses count).
  231. X.TP 10
  232. X.B <backspace>
  233. XGo to previous active page of mail headers (uses count).
  234. X.TP 10
  235. X.B ^,$
  236. XGo to the first (or last) active page of mail headers.
  237. X.TP 10
  238. X.B /,?
  239. XSearch forwards (or backwards) through mail headers for the given
  240. Xregular expression.
  241. X\fB/<return>\fR will repeat search forwards, \fB?<return>\fR will repeat
  242. Xthe search backwards.
  243. XIt is not possible to backspace over \fB/\fR or \fB?\fR; use interrupt
  244. Xinstead.
  245. X.TP 10
  246. X.B .
  247. XRe-execute last command (if one of acdDefirR).
  248. X(On repeat, \fBr\fR will not prompt for a folder name.)
  249. X.TP 10
  250. X.B ^L
  251. XRefresh screen.
  252. X.TP 10
  253. X.B |
  254. XPipe current mail item into command.
  255. X.TP 10
  256. X.B !
  257. XInvoke your favourite shell (\fIcsh\fR by default).
  258. X.TP 10
  259. X.B a
  260. XAnswer current mail item (call to \fIrepl\fR).
  261. X\fIvmail\fR will ask for arguments unless \fB\-ans\fR has been set.
  262. X\fIvmail\fR data structures won't be updated.
  263. X.TP 10
  264. X.B c
  265. XCompose new mail (call to \fIcomp\fR).
  266. X\fIvmail\fR will ask for arguments unless \fB\-comp\fR has been set.
  267. X\fIvmail\fR data structures won't be updated.
  268. X.TP 10
  269. X.B C
  270. XInvoke the folder chooser.
  271. XThis is a screen which permits users to select a current folder
  272. Xby moving the cursor to a folder name with \fIvi\fR movement keys
  273. Xand hitting \fB<space>\fR.
  274. X.TP 10
  275. X.B d
  276. XDelete current mail item (uses count) (like \fIrmm\fR).
  277. XActually, the mail item is moved from maildir/folder/num to maildir/folder/#num.
  278. X\fIvi\fR users beware, \fBdd\fR deletes two items of mail.
  279. X.TP 10
  280. X.B D
  281. XDelete current mail item, show next.
  282. X.TP 10
  283. X.B e
  284. XEdit current mail item.
  285. X.TP 10
  286. X.B f
  287. XForward current mail item (call to \fIforw\fR).
  288. X\fIvmail\fR will ask for arguments unless \fB\-forw\fR has been set.
  289. X\fIvmail\fR data structures won't be updated.
  290. X.TP 10
  291. X.B g,G
  292. XGo to the named (or go to alternate) folder.
  293. X.TP 10
  294. X.B F
  295. XShow all foldernames.
  296. X.TP 10
  297. X.B h
  298. XDisplay the help screen.
  299. X.TP 10
  300. X.B H
  301. XGo to top of page (or as offset by count).
  302. X.TP 10
  303. X.B i
  304. XIncorporate mail (call to \fIinc\fR).
  305. X\fIvmail\fR data structures are updated.
  306. X.TP 10
  307. X.B j
  308. XMove cursor down (uses count).
  309. XAt the bottom of the page, \fBj\fR will go to the top of the next page
  310. Xof the current folder.
  311. X.TP 10
  312. X.B k
  313. XMove cursor up (uses count).
  314. XAt the top of the page, \fBk\fR will go to the bottom of the previous page
  315. Xof the current folder.
  316. X.TP 10
  317. X.B L
  318. XGo to bottom of page (or as offset by count).
  319. X.TP 10
  320. X.B M
  321. XGo to middle of page.
  322. X.TP 10
  323. X.B n
  324. XGo to the next folder, making it active if it is not so already (uses count).
  325. X.TP 10
  326. X.B p
  327. XGo to the previous folder, making it active if it is not so
  328. Xalready (uses count).
  329. X.TP 10
  330. X.B P
  331. XPrint the name of the alternate folder.
  332. X.TP 10
  333. X.B q
  334. XExit.
  335. X.TP 10
  336. X.B r
  337. XRefile current item into the named folder.
  338. X.TP 10
  339. X.B R
  340. XRefile current item into the last folder to which something was refiled.
  341. X.TP 10
  342. X.B s
  343. XSave current mail item in the named file.
  344. XMost filename expansions are not recognized, but `~/' and `~user/' are
  345. Xreplaced by the appropriate paths.
  346. X.TP 10
  347. X.B u
  348. XUndo most recent deletion.
  349. X.TP 10
  350. X.B v
  351. XMake the current folder inactive.
  352. X.TP 10
  353. X.B z
  354. XPack the current folder.
  355. X.LP
  356. XThe commands \fBa\fR, \fBc\fR and \fBf\fR update the physical folders,
  357. Xbut the corresponding pages of mail headers in \fIvmail\fR are not updated.
  358. X\fBv\fR and \fBg\fR can be used in conjunction to force the \fIvmail\fR
  359. Xrepresentation of a folder to come up to date.
  360. X.LP
  361. X\fIvmail\fR recognizes the following environment variables.
  362. XWhere they describe an executable, a full path name should be given.
  363. X.TP 10
  364. X.B SHELL
  365. XSubshell invoked on `!'.
  366. XDefault is \fI/bin/csh\fR.
  367. X.TP 10
  368. X.B PAGER
  369. XDefault is \fI/usr/ucb/more\fR.
  370. X.TP 10
  371. X.B EDITOR
  372. XUsed for editing stored mail.
  373. XThe default is \fI/usr/ucb/vi\fR.
  374. X.TP 10
  375. X.B MH
  376. XUsed to identify the MH profile.
  377. XFrom the profile, \fIvmail\fR recognizes \fBPath\fR, \fBMsg-protect\fR
  378. Xand \fBFolder-protect\fR.
  379. XThe calls to MH utilities use the MH profile as appropriate.
  380. XThe default is \fB~/.mh_profile\fR.
  381. X.SH "PROFILE ENTRIES"
  382. X.LP
  383. XFolder-Protect (protection for new folders)
  384. X.LP
  385. XPath (of mail directory) 
  386. X.LP
  387. XCurrent-Folder (for startup folder)
  388. X.LP
  389. XVmail (list of arguments)
  390. X.SH "SEE ALSO"
  391. Xcomp(1), repl(1), forw(1), inc(1)
  392. X.SH BUGS
  393. X.LP
  394. XCheck the alternate folder before using it unless absolutely sure
  395. Xof its identity; a command may change it unexpectedly.
  396. X.LP
  397. XOnly a couple of formats of "Date:" lines are recognized; if the format is
  398. Xdifferent, the date is replaced by a block of spaces.
  399. X.LP
  400. XStartup time is proportional to the number of items in the current folder.
  401. XIt is therefore better to have a large number of folders each with fewer
  402. Xmail items than a small number of large folders.
  403. XMany first-time vmail users find that their inbox is large enough
  404. X(> 400 items, say) that vmail takes a while to start up \- expect to
  405. Xspend some time initially decluttering inbox and other large folders.
  406. X.SH FILES
  407. X.LP
  408. X$HOME/.mh_profile
  409. X.LP
  410. X$HOME/Mail
  411. X.LP
  412. X$HOME/Mail/context
  413. !The!End!
  414.  
  415. echo x - "Makefile" 2>&1
  416. sed "s/^X//" >"Makefile" <<'!The!End!'
  417. X#    vmail
  418. X#
  419. X#    Interactive screen-based mail handler that sits on top of MH.
  420. X#
  421. X#    Copyright (C) J. Zobel, University of Melbourne, October 1987.
  422. X
  423. XVERS=\"10/87\"
  424. X
  425. XDESTDIR=
  426. XBIN=/usr/local
  427. XOBJ=call.o choose.o cmds.o find.o inc.o init.o load.o low.o main.o move.o page.o
  428. X
  429. XLDFLAGS=
  430. X#    this line is
  431. X#LDFLAGS=-k 48k
  432. X#    if -k option recognized
  433. X#    -k sets required stack space on the PE C compiler
  434. X
  435. XCFLAGS=-DVERSION=$(VERS)
  436. X#    CFLAGS are
  437. X#CFLAGS=-DVERSION=$(VERS) -DUSDATE
  438. X#    if dates required in US format
  439. X
  440. XLIBS=-lcurses -ltermcap
  441. X
  442. Xvmail: $(OBJ)
  443. X    $(CC) $(LDFLAGS) -o vmail $(OBJ) $(LIBS)
  444. X
  445. X$(OBJ): defs.h macro.h Makefile
  446. X
  447. Xinstall: $(DESTDIR)$(BIN)/vmail
  448. X
  449. X$(DESTDIR)$(BIN)/vmail: vmail
  450. X    mv vmail $(DESTDIR)$(BIN)/vmail
  451. X
  452. Xclean:
  453. X    rm $(OBJ) core
  454. !The!End!
  455.  
  456. echo x - "defs.h" 2>&1
  457. sed "s/^X//" >"defs.h" <<'!The!End!'
  458. X/* --------------------
  459. X    vmail -- defs.h
  460. X
  461. X    Interactive screen-based mail handler that sits on top of MH.
  462. X
  463. X    Copyright (C) J. Zobel, University of Melbourne, October 1987.
  464. X-------------------- */
  465. X
  466. X#include <stdio.h>
  467. X#include <pwd.h>
  468. X#include <setjmp.h>
  469. X#include <sgtty.h>
  470. X#include <sys/types.h>
  471. X#include <sys/wait.h>
  472. X#include <sys/dir.h>
  473. X#include <sys/file.h>
  474. X#include <sys/stat.h>
  475. X#include <curses.h>
  476. X
  477. X#define COMP        "/usr/local/mh/comp"    /* MH utilities needed by vmail */
  478. X#define FORW        "/usr/local/mh/forw"
  479. X#define INC            "/usr/local/mh/inc"
  480. X#define REPL        "/usr/local/mh/repl"
  481. X#define PAGER        "/usr/ucb/more"            /* default pager */
  482. X#define EDITOR        "/usr/ucb/vi"            /* default editor */
  483. X#define SHELL        "/bin/csh"                /* default shell */
  484. X#define CAT            "/bin/cat"                /* used as `show' for pipes */
  485. X
  486. X#define LEN            255                        /* standard string length */
  487. X#define MAXITEMS    4097                    /* number of items in folder */
  488. X#define FPROT        0755                    /* standard file protection */
  489. X#define TITLE        0                        /* title line */
  490. X#define STATUS        1                        /* status line */
  491. X#define FIRST        2                        /* first line of info */
  492. X#define PROFILE        ".mh_profile"            /* default profile */
  493. X#define CURFOL        "inbox"                    /* default current folder */
  494. X#define CONTEXT        "context"                /* default context file */
  495. X#define SEQU        ".mh_sequences"            /* default .mh_sequences file */
  496. X#define MAILDIR        "Mail"                    /* default mail directory */
  497. X
  498. X#define    true        1
  499. X#define false        0
  500. X#define EMPTY        2                        /* used to mark empty folders */
  501. X#define CTRL_L        '\014'
  502. X#define ESC            '\033'
  503. X#define DEL            '\177'
  504. X
  505. X/* --------------------
  506. X    Data structures.
  507. X
  508. X    Each folder is divided into pages of (_lines_-2) mail items, _lines_
  509. X    being the number of lines for the tty type.  Pages of folders are
  510. X    stored in a doubly-linked list of pages (struct mail_folder), mail
  511. X    items (struct mail_item) in doubly liked lists of mail.  Folders are
  512. X    sorted alphabetically, and pages of mail items are sorted numerically.
  513. X-------------------- */
  514. Xstruct mail_item {
  515. X    int        number;                        /* number of item */
  516. X    char    *title;                        /* header */
  517. X    struct mail_item *next, *prev;        /* links to other headers */
  518. X};
  519. Xtypedef struct mail_item *item;
  520. X
  521. Xstruct mail_folder {
  522. X    char    *name;                        /* folder name */
  523. X    int        pages, pagenum;                /* no. of pages, no. of page */
  524. X    bool    valid;                        /* true if folder active */
  525. X    item    mail, last;                    /* first and last mail items for page
  526. X                                           - NULL if folder not active */
  527. X    struct mail_folder *next, *prev;    /* linked list of folders */
  528. X};
  529. Xtypedef struct mail_folder *folder;
  530. X
  531. X
  532. Xextern folder    folders,                /* list of all folders */
  533. X                curflr,                    /* current folder */
  534. X                alternate;                /* alternate folder */
  535. Xextern item        curmail;                /* current mail */
  536. Xextern char        **environ,
  537. X                *user,                    /* user name */
  538. X                *pager,                    /* desired pager */
  539. X                *editor,                /* desired editor */
  540. X                *shell,                    /* desired shell */
  541. X                *mail_dir,                /* mail directory */
  542. X                *context;                /* context file */
  543. Xextern int        y,                        /* current Y co-ordinate (for curses) */
  544. X                folder_protect,            /* protection for folders */
  545. X                lines,                    /* lines per screen */
  546. X                cols;                    /* cols per screen */
  547. Xextern bool        top_level,                /* flag used to see if process stopped
  548. X                                           from within subprocess */
  549. X                do_flush,                /* true if input is to be flushed */
  550. X                comp_args,                /* true if calls to comp needs args */
  551. X                repl_args,                /* true if calls to repl needs args */
  552. X                forw_args;                /* true if calls to forw needs args */
  553. Xextern jmp_buf    env;
  554. X
  555. X#include "macro.h"
  556. X
  557. Xvoid    add_page_header(), addstatus(), choose(), comp(), create_mail_record(),
  558. X        cursor_down(), cursor_up(), display_page(), delete_item(), edit(),
  559. X        find_folders(), flatten(), forw(), get_env(), get_home(),
  560. X        read_profile(), get_string(), get_title(), goto_folder(), call_shell(),
  561. X        goto_incorp_folder(), goto_next_folder(), goto_prev_folder(),
  562. X        hold_end(), inactive(), inc(), init(), list_folders(),
  563. X        mark_valid_folders(), move_item(), next_page(), no_control(),
  564. X        prev_page(), repl(), save_item(), search(), show_folder(), show_mail(),
  565. X        show_title(), tint(), to_control(), to_normal(), tstp(), undo(), pack(),
  566. X        cursor_first(), cursor_middle(), cursor_last(), goto_first_page(),
  567. X        goto_last_page(), squash(), get_date(), process_args(), do_pipe();
  568. !The!End!
  569.  
  570. echo x - "macro.h" 2>&1
  571. sed "s/^X//" >"macro.h" <<'!The!End!'
  572. X/* --------------------
  573. X    macro.h -- assorted functions
  574. X
  575. X    Copyright (C) J. Zobel, University of Melbourne, October 1987.
  576. X-------------------- */
  577. X
  578. X#define beep()        printf("%c", 007)
  579. X#define NEWSTR(N)    (char *) malloc(N)
  580. X#define NEW(S)        (struct S *) malloc(sizeof(struct S))
  581. X
  582. X/* --------------------
  583. X    Moving between pages of mail items.
  584. X-------------------- */
  585. X#define PREV_VALID(F)    for(; F != (folder) NULL && ! F->valid ; F=F->prev)
  586. X#define NEXT_VALID(F)    for(; F != (folder) NULL && ! F->valid ; F=F->next)
  587. X#define FRST_OF_NAME(F)    for(; F->prev != (folder) NULL && \
  588. X                                F->name == F->prev->name ; F=F->prev)
  589. X#define LAST_OF_NAME(F)    for(; F->next != (folder) NULL && \
  590. X                                F->name == F->next->name ; F=F->next)
  591. X#define GOTO_NAME(F,S)    for(F=folders ; F != (folder) NULL && \
  592. X                                strcmp(S, F->name) != 0 ; F=F->next)
  593. !The!End!
  594. exit
  595.  
  596.  
  597.