home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume17 / procmail / part01 next >
Encoding:
Internet Message Format  |  1991-03-02  |  54.3 KB

  1. From: berg@marvin.e17.physik.tu-muenchen.de (Stephen R. van den Berg)
  2. Newsgroups: comp.sources.misc
  3. Subject: v17i031:  procmail - mail processing package, Part01/02
  4. Message-ID: <1991Mar2.004704.16888@sparky.IMD.Sterling.COM>
  5. Date: 2 Mar 91 00:47:04 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: dcfc8213 ea1ac849 f50ab45d 529eca40
  8. X-Checksum-Snefru: 4e1f6733 2be9cdad 47f71b72 337a3d19
  9.  
  10. Submitted-by: Stephen R. van den Berg <berg@marvin.e17.physik.tu-muenchen.de>
  11. Posting-number: Volume 17, Issue 31
  12. Archive-name: procmail/part01
  13. Supersedes: procmail: Volume 16, Issue 103
  14.  
  15. The Procmail mail processing package. (v1.30 1991-01-03)
  16.  
  17. Can be used to create mail-servers, mailing lists, sort your incoming mail
  18. (real convenient when subscribing to one or more mailing lists),
  19. preprocess your mail, or selectively forward certain incoming mail
  20. automatically to someone, etc...
  21.  
  22. Procmail was designed to deliver the mail under the worst conditions
  23. (file system full, out of swap space (**NEW**), process table full,
  24. missing support files, unavailable executables; it all doesn't matter).
  25. Should (in the unlikely event) procmail be unable to deliver your mail
  26. somewhere, the mail will bounce back to the sender.
  27.  
  28. Advantages: This package is small (boils down to one executable)
  29.             and therefore robust, but still doesn't lack any mayor
  30.             features you would want.
  31.  
  32. Cheers,
  33.        Stephen R. van den Berg  at RWTH-Aachen, Germany.
  34.  
  35. ---- Cut Here and feed the following to sh ----
  36. #!/bin/sh
  37. # This is procmail, a shell archive (produced by shar 3.49)
  38. # To extract the files from this archive, save it to a file, remove
  39. # everything above the "!/bin/sh" line above, and type "sh file_name".
  40. #
  41. # made 03/01/1991 11:56 UTC by berg@marvin.e17.physik.tu-muenchen.de
  42. # Source directory /tmp_mnt/tmp/.am/baghira/berg
  43. #
  44. # existing files will NOT be overwritten unless -c is specified
  45. #
  46. # This shar contains:
  47. # length  mode       name
  48. # ------ ---------- ------------------------------------------
  49. #   2428 -rw-r--r-- procmail/HISTORY
  50. #    729 -rw-r--r-- procmail/Makefile
  51. #    999 -rw-r--r-- procmail/Manifest
  52. #   3420 -rw-r--r-- procmail/README
  53. #   2474 -rw-r--r-- procmail/lockfile.1
  54. #   1908 -rw-r--r-- procmail/lockfile.c
  55. #  15169 -rw-r--r-- procmail/procmail.1
  56. #   9798 -rw-r--r-- procmail/procmail.c
  57. #   3914 -rw-r--r-- procmail/nonint.c
  58. #   1929 -rw-r--r-- procmail/config.h
  59. #    279 -rw-r--r-- procmail/sysexits.h
  60. #   1158 -rw-r--r-- procmail/procmail.h
  61. #    130 -rw-r--r-- procmail/shell.h
  62. #   9549 -rw-r--r-- procmail/retint.c
  63. #     29 -rw-r--r-- procmail/examples/forward
  64. #    381 -rw-r--r-- procmail/examples/1rmail
  65. #   1587 -rw-r--r-- procmail/examples/2procmailrc
  66. #   1255 -rw-r--r-- procmail/examples/3procmailrc
  67. #    373 -rw-r--r-- procmail/examples/2rmail
  68. #    738 -rw-r--r-- procmail/examples/3rmail
  69. #    638 -rw-r--r-- procmail/examples/1procmailrc
  70. #    589 -rw-r--r-- procmail/includes.h
  71. #
  72. # ============= procmail/HISTORY ==============
  73. if test ! -d 'procmail'; then
  74.     echo 'x - creating directory procmail'
  75.     mkdir 'procmail'
  76. fi
  77. if test -f 'procmail/HISTORY' -a X"$1" != X"-c"; then
  78.     echo 'x - skipping procmail/HISTORY (File already exists)'
  79. else
  80. echo 'x - extracting procmail/HISTORY (Text)'
  81. sed 's/^X//' << 'SHAR_EOF' > 'procmail/HISTORY' &&
  82. X1990-12-07: v1.00
  83. X        First release (after 2 weeks of coding and testing)
  84. X1990-12-12: v1.01
  85. X        Added fsync to procmail.c
  86. X        Removed longjmp in lockfile.c out of the signal handler
  87. X        (not portable, so I'm told)
  88. X1991-02-04: v1.02
  89. X        Changes to procmail.c:
  90. X           Added physical-write-error check
  91. X           Altered egrep invocation (left out the -s flag, not supported
  92. X          on all machines; this didn't change functionality though)
  93. X           Avoided the 'dirty' allocation of one more byte than needed by
  94. X          rewriting the bogus_header_replace routine
  95. X           Made the finding bogus headers more robust
  96. X        Added sysV lines in Makefile
  97. X1991-02-13: v1.10
  98. X        Changes to procmail.c:
  99. X           Fixed slight error in parsing the recipe when 'h' and 'b' where
  100. X          specified
  101. X           Started using the official exit codes
  102. X           Made sure that the procmail is not influenced by falsely
  103. X          set environment variables like LOCKSLEEP
  104. X1991-02-21: v1.20
  105. X        Changes to procmail.c:
  106. X           Removed library conflict on some machines for 'locking'
  107. X           Added uname call as alternative for gethostname
  108. X           Changed name of SHELLMETA to SHELLMETAS (for conformance
  109. X          with dmake)
  110. X           Added LOCKTIMEOUT to learn procmail to decide wether or not
  111. X          a certain lockfile is still 'valid'
  112. X           Added the function sputenv (smart-putenv) to avoid library
  113. X          problems and to finally have a putenv that works the
  114. X          way it was supposed to work all along (you wouldn't believe
  115. X          how brain damaged this library function is :-)
  116. X           Changed environment variable assignment to skip trailing blanks
  117. X          only, and allow intermediate blanks (parsing like make)
  118. X1991-02-22: v1.21
  119. X        Split up procmail.c in procmail.c, nonint.c, retint.c, procmail.h,
  120. X           config.h, sysexits.h, shell.h
  121. X        Changes to lockfile.c:
  122. X           Added -l option (locktimeout)
  123. X        Moved virtually all configuration stuff from Makefile into
  124. X           config.h
  125. X        Added -v option to procmail
  126. X1991-03-01: v1.30
  127. X        Added out of memory/swap space immunity  (NOMEMRETRY)
  128. X        Made forced terminations of procmail more reliable and verbose
  129. X           (previously, procmail would display erroneous error messages
  130. X           if an attempt was made to kill procmail more than once in
  131. X           rapid succession)
  132. X        Fixed up man pages and comments
  133. X        Included more example files
  134. X        Made sure that variable substitution works in locallockfile-
  135. X           specifications too
  136. SHAR_EOF
  137. chmod 0644 procmail/HISTORY ||
  138. echo 'restore of procmail/HISTORY failed'
  139. Wc_c="`wc -c < 'procmail/HISTORY'`"
  140. test 2428 -eq "$Wc_c" ||
  141.     echo 'procmail/HISTORY: original size 2428, current size' "$Wc_c"
  142. fi
  143. # ============= procmail/Makefile ==============
  144. if test -f 'procmail/Makefile' -a X"$1" != X"-c"; then
  145.     echo 'x - skipping procmail/Makefile (File already exists)'
  146. else
  147. echo 'x - extracting procmail/Makefile (Text)'
  148. sed 's/^X//' << 'SHAR_EOF' > 'procmail/Makefile' &&
  149. X# change BASENAME to your home directory if need be
  150. XBASENAME = /global
  151. X
  152. XBINDIR     = ${BASENAME}/bin
  153. XMANDIR     = ${BASENAME}/man/man1
  154. X
  155. XOCFLAGS     = -O
  156. XOLDFLAGS = -s
  157. X
  158. X# Uncomment appropiately (for sysV and the like):
  159. XCFLAGS    = ${OCFLAGS} #-DSYSV
  160. XLDFLAGS = ${OLDFLAGS} #-lbsd 
  161. X
  162. XCC = cc
  163. XINSTALL= mv
  164. XRM= rm -f
  165. X
  166. XOBJ=procmail.o nonint.o retint.o
  167. X
  168. Xall:    procmail lockfile
  169. X
  170. Xprocmail: ${OBJ}
  171. X    ${CC} ${CFLAGS} -o procmail ${OBJ} ${LDFLAGS}
  172. X
  173. Xlockfile: lockfile.o
  174. X    ${CC} ${CFLAGS} -o lockfile lockfile.o ${LDFLAGS}
  175. X
  176. X.c.o:
  177. X    ${CC} ${CFLAGS} -c $*.c
  178. X
  179. Xinstall: all
  180. X    chmod 755 procmail lockfile
  181. X    ${INSTALL} procmail lockfile ${BINDIR}
  182. X    chmod 644 procmail.1 lockfile.1
  183. X    cp procmail.1 lockfile.1 ${MANDIR}
  184. X
  185. Xclean:
  186. X    ${RM} ${OBJ} lockfile.o procmail lockfile
  187. SHAR_EOF
  188. chmod 0644 procmail/Makefile ||
  189. echo 'restore of procmail/Makefile failed'
  190. Wc_c="`wc -c < 'procmail/Makefile'`"
  191. test 729 -eq "$Wc_c" ||
  192.     echo 'procmail/Makefile: original size 729, current size' "$Wc_c"
  193. fi
  194. # ============= procmail/Manifest ==============
  195. if test -f 'procmail/Manifest' -a X"$1" != X"-c"; then
  196.     echo 'x - skipping procmail/Manifest (File already exists)'
  197. else
  198. echo 'x - extracting procmail/Manifest (Text)'
  199. sed 's/^X//' << 'SHAR_EOF' > 'procmail/Manifest' &&
  200. XMakefile    We all know what that is.
  201. XREADME        Important, read it.
  202. XHISTORY        Recent and ancient changes (or bugs) documented.
  203. Xlockfile.1    Man page for lockfile.
  204. Xlockfile.c    You guessed it.
  205. XManifest    Right again.
  206. Xprocmail.1    Yes, the man page for procmail (writing man pages gobbles up
  207. X        sooo much time, here you can see why :-).
  208. Xprocmail.c    main program for procmail.
  209. Xnonint.c    Collection of routines that don't return ints.
  210. Xretint.c    Collection of routines that return ints.
  211. Xprocmail.h    Include file with all declarations.
  212. X
  213. Xincludes.h    System include files are all referenced here.
  214. Xconfig.h    The file to edit if you want to change, yes, the configuration.
  215. X
  216. Xshell.h        Defines a few 'shell' macros for malloc and the like.
  217. Xsysexits.h    Standard exit codes.
  218. Xexamples/?procmailrc
  219. X        Sample .procmailrc files.
  220. Xexamples/?rmail
  221. X        Sample shell scripts that demonstrate how to use
  222. X        lockfiles while reading the mail (to ensure mail integrity
  223. X        as soon as you exit the mail program).
  224. Xexamples/forward
  225. X        A sample .forward file.
  226. SHAR_EOF
  227. chmod 0644 procmail/Manifest ||
  228. echo 'restore of procmail/Manifest failed'
  229. Wc_c="`wc -c < 'procmail/Manifest'`"
  230. test 999 -eq "$Wc_c" ||
  231.     echo 'procmail/Manifest: original size 999, current size' "$Wc_c"
  232. fi
  233. # ============= procmail/README ==============
  234. if test -f 'procmail/README' -a X"$1" != X"-c"; then
  235.     echo 'x - skipping procmail/README (File already exists)'
  236. else
  237. echo 'x - extracting procmail/README (Text)'
  238. sed 's/^X//' << 'SHAR_EOF' > 'procmail/README' &&
  239. XSome legal stuff:
  240. X
  241. XUse this software package at your own risk.  The programmer can not
  242. Xbe held liable for any incurred damages due to the use of this software.
  243. X
  244. XYou are encouraged to distribute this package freely.  This package is
  245. Xhowever not to be not sold (minor transfer costs excepted) or included in
  246. Xany commercially sold software package (if you want to do this anyway,
  247. Xcontact me (address below), and we'll work something out).
  248. X
  249. XIf you distribute it, please leave the package in tact.     If you have some
  250. Ximportant changes that might be usefull to the rest of the world, contact
  251. Xme instead.
  252. X
  253. X----------------------
  254. X
  255. XThe Procmail mail processing package. (v1.30 1991-01-03)
  256. X
  257. XCan be used to create mail-servers, mailing lists, sort your incoming mail
  258. X(real convenient when subscribing to one or more mailing lists),
  259. Xpreprocess your mail, or selectively forward certain incoming mail
  260. Xautomatically to someone.
  261. X
  262. XTo install it, edit config.h (!) and Makefile accordingly (if it doesn't
  263. Xcompile at first, check if some extra header files (in includes.h) should
  264. Xbe included (or left out) in order to make any used types/defines/declarations
  265. Xfor the library compatible).
  266. X
  267. XBTW, the warnings you get about 'loop not entered at top': they're normal :-).
  268. XSome older compilers could complain about ambiguous assignments, if they
  269. Xassume normal assigns, you're safe.
  270. X
  271. XIf you run procmail by hand and pipe in some sample mail, then make
  272. Xsure that if you kill procmail, you use "kill pid" and NOT "kill -9 pid".
  273. XShould procmail seem to hang, check if the $LOCKFILE is still present.
  274. XIf you kill procmail with "kill pid" it will clean up the $LOCKFILE
  275. Xitself.
  276. X
  277. XThough be sure to skim through config.h and in particular check out
  278. Xthe t_buf declaration.
  279. X
  280. XEvery user that wants to use procmail should have a .forward and a
  281. X.procmailrc file in his HOME directory.     For starters, you can look
  282. Xat the supplied example files in "examples".
  283. X(BTW, be sure to make .forward *world* readable).
  284. X
  285. XFor more info about the program, see the man page.
  286. X
  287. X----------------------
  288. X
  289. XAlthough I can't guarantee that the procmail (or lockfile) program
  290. Xwill perform as required, I must say that I made the utmost effort
  291. Xto make procmail as robust as any program can be.
  292. X
  293. XProcmail was designed to deliver the mail under the worst conditions
  294. X(file system full, out of swap space, process table full,
  295. Xmissing support files, unavailable executables; it all doesn't matter).
  296. XShould (in the unlikely event) procmail be unable to deliver your mail
  297. Xsomewhere, the mail will bounce back to the sender.
  298. X
  299. XHowever, as with any program, bugs can not be completely ruled out.
  300. XI tested the program extensively, and believe it should be relatively
  301. Xbug free (no known bug at the time).  Should, however, anyone
  302. Xfind any bugs (highly unlikely :-), I would be pleased (well, sort of :-)
  303. Xto hear about it.  Please send me the patches or bug report.
  304. XI'll look at them and will try to fix it in a future release.
  305. X(BTW, if you should find any spelling or grammar errors in these files,
  306. Xit's not priority one, but if you were sending me mail anyway, I don't
  307. Xmind if you point them out to me; I like correct English just as much
  308. Xas you do).
  309. X
  310. XCheers,
  311. X       Stephen R. van den Berg    at RWTH-Aachen, Germany.
  312. X
  313. XInternet E-mail:        berg@marvin.e17.physik.tu-muenchen.de
  314. Xor if the above bounces:    berg@cip-s01.informatik.rwth-aachen.de
  315. X
  316. XOr:    P.O.Box 21074
  317. X    6369 ZG Simpelveld
  318. X    The Netherlands
  319. SHAR_EOF
  320. chmod 0644 procmail/README ||
  321. echo 'restore of procmail/README failed'
  322. Wc_c="`wc -c < 'procmail/README'`"
  323. test 3420 -eq "$Wc_c" ||
  324.     echo 'procmail/README: original size 3420, current size' "$Wc_c"
  325. fi
  326. # ============= procmail/lockfile.1 ==============
  327. if test -f 'procmail/lockfile.1' -a X"$1" != X"-c"; then
  328.     echo 'x - skipping procmail/lockfile.1 (File already exists)'
  329. else
  330. echo 'x - extracting procmail/lockfile.1 (Text)'
  331. sed 's/^X//' << 'SHAR_EOF' > 'procmail/lockfile.1' &&
  332. X.\" @(#)lockfile.1 1.29 91/03/01 SMI;
  333. X.de Sh
  334. X.br
  335. X.ne 6
  336. X.SH \\$1
  337. X..
  338. X.de Ss
  339. X.br
  340. X.ne 6
  341. X.SS \\$1
  342. X..
  343. X.de Tp
  344. X.br
  345. X.ne 6
  346. X.TP \\$1
  347. X..
  348. X.TH LOCKFILE 1 "1 March 1991"
  349. X.SH NAME
  350. Xlockfile \- conditional semaphore-file creator
  351. X.SH SYNOPSIS
  352. X.B lockfile
  353. X.RI [ " \fB\-\fPsleeptime " ]
  354. X.RI [ " \fB\-r\fPretries " ]
  355. X.RB [ " \-! ]
  356. X.if n .ti +0.5i
  357. X.RI [ " \fB\-l\fPlocktimeout " ]
  358. X.I filename
  359. X\&.\|.\|.
  360. X.Sh "DESCRIPTION"
  361. X.B lockfile
  362. Xcan be used to create one or more
  363. X.I semaphore
  364. X.IR files .
  365. XIf
  366. X.B lockfile
  367. Xcan't create all the specified files (in the specified order), it waits
  368. X.I sleeptime
  369. X(defaults to 8) seconds and retries the last file that didn't succeed.
  370. XYou can specify the number of
  371. X.I retries
  372. Xto do until failure is returned.
  373. XIf the number of
  374. X.I retries
  375. Xis 0 (default)
  376. X.B lockfile
  377. Xwill retry forever.
  378. X.LP
  379. XIf the number of
  380. X.I retries
  381. Xexpires before all files have been created,
  382. X.B lockfile
  383. Xreturns failure and removes all the files it created up till that point.
  384. X.LP
  385. XThe return value of
  386. X.B lockfile
  387. Xcan be easily inverted by specifying
  388. X.B \-!
  389. Xas an argument (handy in shell scripts).
  390. X.LP
  391. XAll flags can be specified anywhere on the command line, they will be
  392. Xprocessed when encountered.  The command line is simply parsed from
  393. Xleft to right.
  394. X.LP
  395. XAll files created by
  396. X.B lockfile
  397. Xwill have access permission 0, and therefore will have to be removed
  398. Xwith
  399. X.B rm
  400. X.BR \-f .
  401. X.LP
  402. XIf you specify a
  403. X.I locktimeout
  404. Xthen a
  405. X.B lockfile
  406. Xwill be removed by force after
  407. X.I locktimeout
  408. Xseconds have passed since the
  409. X.B lockfile
  410. Xwas last modified/created.
  411. X.Sh "SEE ALSO"
  412. X.LP
  413. X.BR rm (1),
  414. X.BR mail (1),
  415. X.BR binmail (1),
  416. X.BR sendmail (8),
  417. X.BR procmail (1)
  418. X.Sh "DIAGNOSTICS"
  419. X.Tp 23
  420. XForcing lock on "x"
  421. Xspecified
  422. X.B lockfile
  423. Xis going to be removed by force because of a timeout (compare
  424. X.BR LOCKTIMEOUT
  425. Xin
  426. X.BR procmail (1))
  427. X.Sh "BUGS & SPECIAL FEATURES"
  428. X.LP
  429. X.B lockfile
  430. Xis only a simple program and can't process concatenated options.
  431. X.LP
  432. XMultiple
  433. X.B \-!
  434. Xflags will not toggle the return status.
  435. X.Sh "NOTES"
  436. X.LP
  437. XSince flags can occur anywhere on the command line, any filename starting
  438. Xwith an '-' has to be preceded by another '-'.
  439. X.LP
  440. XThe number of
  441. X.I retries
  442. Xis global.  That is, it is not reset when a new file is being created.
  443. XIt can, however, be reset by specifying
  444. X.RI \-r newretries
  445. Xafter every file on the command line.
  446. X.Sh "AUTHOR"
  447. X.LP
  448. XStephen R. van den Berg at RWTH-Aachen, Germany
  449. X.RS
  450. Xberg@marvin.e17.physik.tu-muenchen.de (preferred)
  451. X.br
  452. Xberg@cip-s01.informatik.rwth-aachen.de (alternative)
  453. X.RE
  454. SHAR_EOF
  455. chmod 0644 procmail/lockfile.1 ||
  456. echo 'restore of procmail/lockfile.1 failed'
  457. Wc_c="`wc -c < 'procmail/lockfile.1'`"
  458. test 2474 -eq "$Wc_c" ||
  459.     echo 'procmail/lockfile.1: original size 2474, current size' "$Wc_c"
  460. fi
  461. # ============= procmail/lockfile.c ==============
  462. if test -f 'procmail/lockfile.c' -a X"$1" != X"-c"; then
  463.     echo 'x - skipping procmail/lockfile.c (File already exists)'
  464. else
  465. echo 'x - extracting procmail/lockfile.c (Text)'
  466. sed 's/^X//' << 'SHAR_EOF' > 'procmail/lockfile.c' &&
  467. X/************************************************************************
  468. X *    lockfile.c    a conditional semaphore-file creator        *
  469. X *                                    *
  470. X *    Version 1.30 1991-01-03                        *
  471. X *    Is relatively bug free.                        *
  472. X *                                    *
  473. X *    Created by S.R.van den Berg, The Netherlands            *
  474. X *    This file can be freely copied for any use.            *
  475. X *                                    *
  476. X *    If you have had to make major changes in order to get it    *
  477. X *    running on a different machine, please send me the patches.    *
  478. X *    That way I might include them in a future version.        *
  479. X ************************************************************************/
  480. X#include "config.h"    /* I know, a bit overkill, need NO_ANSI_PROT */
  481. X#include "includes.h"
  482. X
  483. Xint exitflag;
  484. X
  485. Xvoid failure(){
  486. X exitflag=1;}
  487. X
  488. Xmain(argc,argv)char*argv[];{int sleepsec,retries,i,invert,force;char**p,*cp;
  489. X sleepsec=8;force=retries=invert=0;
  490. X if(argc<2){
  491. X   putse("Usage: lockfile [-nnn] [-rnnn] [-!] [-lnnn] file ...\n");return 2;}
  492. Xagain:
  493. X p=argv+1;signal(SIGHUP,failure);signal(SIGINT,failure);
  494. X signal(SIGQUIT,failure);signal(SIGTERM,failure);
  495. X do
  496. X    if(*(cp=*p)=='-')
  497. X       switch(cp[1]){
  498. X       case'!':invert=1;break;
  499. X       case'r':retries=strtol(cp+2,NULL,10);break;
  500. X       case'l':force=strtol(cp+2,NULL,10);break;
  501. X       case'-':cp++;goto filename;
  502. X       default:
  503. X      if(sleepsec>=0)
  504. X         sleepsec=strtol(cp+1,NULL,10);}
  505. X    else
  506. Xfilename:
  507. X      if(sleepsec<0)
  508. X     unlink(cp);
  509. X      else{
  510. X     while(0>(i=open(cp,O_WRONLY|O_CREAT|O_EXCL|O_SYNC,0))){
  511. X        struct stat buf;
  512. X        if(exitflag||retries==1){
  513. X           sleepsec=-1;*p=0;goto again;}
  514. X        if(force&&!stat(cp,&buf)&&force<time((time_t*)0)-buf.st_mtime){
  515. X           putse("Forcing lock on \"");putse(cp);putse("\"\n");
  516. X           unlink(cp);}
  517. X        sleep(sleepsec);
  518. X        if(retries)
  519. X           retries--;}
  520. X     close(i);}
  521. X while(*++p);
  522. Xreturn invert^(sleepsec<0);}
  523. X
  524. X#define STDERR    2
  525. X
  526. Xputse(a)char*a;{char*b;
  527. X b=a-1;
  528. X while(*++b);
  529. X write(STDERR,a,b-a);}
  530. SHAR_EOF
  531. chmod 0644 procmail/lockfile.c ||
  532. echo 'restore of procmail/lockfile.c failed'
  533. Wc_c="`wc -c < 'procmail/lockfile.c'`"
  534. test 1908 -eq "$Wc_c" ||
  535.     echo 'procmail/lockfile.c: original size 1908, current size' "$Wc_c"
  536. fi
  537. # ============= procmail/procmail.1 ==============
  538. if test -f 'procmail/procmail.1' -a X"$1" != X"-c"; then
  539.     echo 'x - skipping procmail/procmail.1 (File already exists)'
  540. else
  541. echo 'x - extracting procmail/procmail.1 (Text)'
  542. sed 's/^X//' << 'SHAR_EOF' > 'procmail/procmail.1' &&
  543. X.\" @(#)procmail.1 1.29 91/03/01 SMI;
  544. X.de Sh
  545. X.br
  546. X.ne 6
  547. X.SH \\$1
  548. X..
  549. X.de Ss
  550. X.br
  551. X.ne 6
  552. X.SS \\$1
  553. X..
  554. X.de Tp
  555. X.br
  556. X.ne 6
  557. X.TP \\$1
  558. X..
  559. X.TH PROCMAIL 1 "1 March 1991"
  560. X.SH NAME
  561. Xprocmail \- autonomous mail processor
  562. X.SH SYNOPSIS
  563. X.B procmail
  564. X.RB [ " \-v " ]
  565. X.RI [ " parameter\fB=\fPvalue " | " rcfile " ]
  566. X\&.\|.\|.
  567. X.Sh "DESCRIPTION"
  568. X.LP
  569. XFor a quick start, see
  570. X.B NOTES
  571. Xat the end.
  572. X.LP
  573. X.B procmail
  574. Xfirst sets some environment variables to default values, then, if no
  575. Xarguments are specified, it reads the mail message from stdin until an
  576. XEOF, separates
  577. Xthe body from the header and starts to look for a file named
  578. X.B .procmailrc
  579. Xin your home directory.
  580. X.LP
  581. X.Ss "Defaults"
  582. X.Tp 22
  583. X.B "USER, HOME and SHELL"
  584. XYour (the recipient's) defaults
  585. X.Tp
  586. X.B SHELLMETAS
  587. X"'`&#{}()[]*?|<>~;!\\
  588. X.Tp
  589. X.B SHELLFLAGS
  590. X-c
  591. X.Tp
  592. X.B MAILDIR
  593. X$HOME
  594. X.Tp
  595. X.BR DEFAULT
  596. X$MAILDIR/.mailbox
  597. X.Tp
  598. X.B ORGMAIL
  599. X/var/spool/mail/$USER
  600. X.Tp
  601. X.B GREP
  602. X/usr/bin/egrep
  603. X.Tp
  604. X.B SENDMAIL
  605. X/usr/lib/sendmail
  606. X.Tp
  607. X.B LOCKEXT
  608. X\&.lock
  609. X.Tp
  610. X.B LOCKSLEEP
  611. X8
  612. X.Tp
  613. X.B LOCKTIMEOUT
  614. X3600
  615. X.Tp
  616. X.B NOMEMRETRY
  617. X2
  618. X.Ss "Environment"
  619. X.Tp 12
  620. X.B MAILDIR
  621. XDefault directory while procmail is executing (that means that all paths
  622. Xare relative to $MAILDIR).
  623. X.Tp
  624. X.B DEFAULT
  625. XDefault
  626. X.B mailbox
  627. Xfile (if not told otherwise, procmail will dump mail in this file)
  628. X.Tp
  629. X.B LOGFILE
  630. XAll incoming messages will be logged here with their 'From' and 'Subject'
  631. Xlines in the header.  This file will also contain any error or diagnostic
  632. Xmessages from procmail.
  633. X(Normally none :-).  If this file is not specified it defaults to
  634. X.BR /dev/null .
  635. X.Tp
  636. X.B ORGMAIL
  637. XUsually the system mailbox (\fBOR\fPi\fBG\fPinal \fBMAIL\fPbox).  If, for
  638. Xsome obscure reason (like "\fBfilesystem full\fP") the mail could not be
  639. Xdelivered, then this file will be the last resort.  If procmail
  640. Xfails to save the mail in here (deep, deep trouble :-), then the mail
  641. Xwill bounce back to the sender.
  642. X.Tp
  643. X.B LOCKFILE
  644. XGlobal semaphore file.    If this file already exists, procmail
  645. Xwill wait until it has gone before proceeding, and will create it itself
  646. X(cleaning it up when ready, of course).     If more than one
  647. X.I lockfile
  648. Xare specified, then the previous one will be removed before trying to create
  649. Xthe new one.
  650. X.Tp
  651. X.B LOCKEXT
  652. XDefault extension that is appended to a destination file to determine
  653. Xwhat local
  654. X.I lockfile
  655. Xto use (only if turned on, on a per-recipe basis).
  656. X.Tp
  657. X.B LOCKSLEEP
  658. XNumber of seconds procmail will sleep before retrying on a
  659. X.I lockfile
  660. X(if it already existed).
  661. X.Tp
  662. X.B LOCKTIMEOUT
  663. XNumber of seconds that have to have passed since a
  664. X.I lockfile
  665. Xwas last modified/created before procmail decides that this must be an
  666. Xerroneously leftover lockfile that can be removed by force now.     If zero,
  667. Xthen no timeout will be used and procmail will wait forever until the
  668. Xlockfile is removed.  This variable is usefull to prevent indefinite
  669. Xhangups of
  670. X.BR sendmail /procmail.
  671. X.Tp
  672. X.B HOST
  673. XIf this is not the
  674. X.I hostname
  675. Xof the machine, processing of the current
  676. X.I rcfile
  677. Xwill immediately cease. If other rcfiles were specified on the
  678. Xcommand line, processing will continue with the next one.  If all rcfiles
  679. Xare exhausted, the program will terminate, but will not generate an error
  680. X(i.e. to the mailer it will seem that the mail has been delivered).
  681. X.Tp
  682. X.B UMASK
  683. XThe name says it all (if it doesn't, then forget about this one :-).  It
  684. Xis taken as an
  685. X.B octal
  686. Xnumber.     If not specified, it defaults to 077.
  687. X.Tp
  688. X.B GREP
  689. XThe program that gets called for parsing regular expressions.
  690. X.br
  691. XIt is called as: $GREP -e "$*" [-i];
  692. X.Tp
  693. X.B SHELLMETAS
  694. XIf any of the characters in SHELLMETAS appears in the line specifying
  695. Xa filter or program, the line will be fed to $SHELL
  696. Xinstead of being executed directly.
  697. X.Tp
  698. X.B SHELLFLAGS
  699. XAny invocation of $SHELL will be like:
  700. X.br
  701. X$SHELL $SHELLFLAGS "$*";
  702. X.Tp
  703. X.B SENDMAIL
  704. XIf you're not using the
  705. X.I forwarding
  706. Xfacility don't worry about this one.  It specifies the program being
  707. Xcalled to forward any mail.
  708. X.br
  709. XIt gets invoked as: $SENDMAIL $*;
  710. X.Tp
  711. X.B NOMEMRETRY
  712. XNumber of retries that are to be made if any "\fBout of memory\fP" or
  713. X"\fBout of swap space\fP" error should occur.  If this number is negative,
  714. Xthen procmail will retry indefinitely.    The retries occur with a 16
  715. Xsecond interval.  The idea behind this is, that if the
  716. X.I swap
  717. X.I space
  718. Xhas been exhausted, usually several other programs will either detect this
  719. Xand abort or crash 8-), and thereby freeing valuable swap space for procmail.
  720. X.Sh "OPTIONS"
  721. X.LP
  722. XIf you specify the
  723. X.B \-v
  724. Xoption as the first argument, all
  725. X.B procmail
  726. Xdoes is print the version number and exit.
  727. X.Sh "ARGUMENTS"
  728. X.LP
  729. XAny arguments containing an '=' are considered to be environment variable
  730. Xassignments, they will
  731. X.I all
  732. Xbe evaluated after the default values have been
  733. Xassigned and before the
  734. X.I first
  735. Xrcfile is parsed.
  736. X.LP
  737. XAny other arguments are presumed to be rcfiles; procmail
  738. Xwill start with the first one it finds on the command line.  The following
  739. Xones will only be parsed if the preceding ones have a not matching
  740. XHOST-directive entry.
  741. X.LP
  742. XIf no rcfiles are specified, it looks for
  743. X.BR $HOME/.procmailrc .
  744. XIf not even that can be found processing will continue according to
  745. Xthe default settings of the environment variables and the ones specified
  746. Xon the command line.
  747. X.Sh "RCFILE FORMAT"
  748. X.LP
  749. XEnvironment variable
  750. X.B assignments
  751. Xand
  752. X.B recipes
  753. Xcan be freely intermixed in the rcfile. If any environment variable has
  754. Xa special meaning to procmail, it will be used appropiately the moment
  755. Xit is parsed. (i.e. you can change the default directory whenever you
  756. Xwant by specifying a new
  757. X.BR MAILDIR ,
  758. Xswitch lockfiles by specifying a new
  759. X.B LOCKFILE
  760. X(usually one won't need this particular application though), change
  761. Xthe umask at any time, etc., the possibilities are endless :-).
  762. X.LP
  763. XValues being assigned to environment variables (in the rcfile) can not
  764. Xcontain any tab, newline or '#' characters.  Spaces will be stripped
  765. Xon both ends.  Anything on a line from the first '#' till EOL is
  766. Xconsidered comment.
  767. X.Ss "Recipes"
  768. X.LP
  769. XA line starting with ':' marks the beginning of a recipe.  It has the
  770. Xfollowing format:
  771. X.LP
  772. X:
  773. X.RI [ " number " ]
  774. X.RI [ " options " ]
  775. X.RI "[ : [" " locallockfile " "] ]"
  776. X.LP
  777. XThe
  778. X.I number
  779. Xis optional (defaults to 1) and specifies the number of conditionals
  780. Xfollowing this line.  Conditionals are complete lines that are passed onto
  781. X$GREP
  782. X.BR literally ,
  783. Xconditionals are anded; if
  784. X.I number
  785. Xis zero, then the condition is always true and no conditionals are expected
  786. Xnext.
  787. X.LP
  788. X.I Options
  789. Xcan be any of the following (don't insert spaces in between, from the first
  790. Xcharacter that is not a valid option, on till EOL will be skipped without notice):
  791. X.Tp 5
  792. X.B H
  793. XFeed the header to $GREP (default)
  794. X.Tp
  795. X.B B
  796. XFeed the body to $GREP
  797. X.Tp
  798. X.B I
  799. XTell $GREP to ignore case
  800. X.Tp
  801. X.B h
  802. XFeed the header to the pipe (default)
  803. X.Tp
  804. X.B b
  805. XFeed the body to the pipe (default)
  806. X.Tp
  807. X.B f
  808. XConsider the pipe as a filter (ignored if a file)
  809. X.Tp
  810. X.B c
  811. XContinue processing rcfile even if this recipe matches (not needed if 'f'
  812. Xspecified)
  813. X.Tp
  814. X.B w
  815. XWait for the pipe or program to finish (and check if it was successfull,
  816. Xnormally ignored).  If you specify 'f' and it matches, then the original mailer
  817. Xwill be told that the mail has already been delivered.    If you want
  818. Xprocmail to stall telling the mailer that the mail has been delivered, until
  819. Xit really has been delivered, you'll have to specify 'w' together with
  820. Xevery 'f'.  If you don't, the mailer will be told that the mail has been
  821. Xdelivered
  822. Xsuccesfully as soon as the first 'f' without a 'w' has been processed.
  823. XThis option is also advisable if you specified any
  824. X.I locallockfile
  825. Xon this recipe.
  826. X.Tp
  827. X.B s
  828. XMake procmail secure.     If any fork fails in the current recipe, retry
  829. Xuntil it succeeds (usefull when running on machines that occasionally have
  830. Xa full process tables, to ensure normal delivery in any case).     If a fork
  831. Xfails and 's' is not specified, it simply is logged in $LOGFILE and parsing
  832. Xof the rcfile continues (eventually delivering to $DEFAULT if no more
  833. Xrecipes match).
  834. X.Ss "Local lockfile"
  835. X.LP
  836. XIf you put a second ':' on the first recipe line, then procmail will use a
  837. X.I locallockfile
  838. X(for this recipe only).     You optionally can specify the locallockfile
  839. Xto use; if you don't however, procmail
  840. Xwill use the filename specified as the destination (or the filename
  841. Xfollowing the first '>>') and will append $LOCKEXT to it.
  842. X.Ss "Recipe destination"
  843. X.LP
  844. XThe next line can start with the following characters:
  845. X.Tp
  846. X.B !
  847. XForwards to all the specified mail addresses (comments are 
  848. X.B not
  849. Xignored on this line).
  850. X.Tp
  851. X.B |
  852. XStarts the specified program, possibly in $SHELL if any
  853. Xof the $METASHELL characters are found (that means comments are normally
  854. Xprocessed by the shell on
  855. X.B this
  856. Xline).
  857. X.LP
  858. XAnything else will be taken as a filename (relative to the last specified
  859. X$MAILDIR).  After the filename everything will be ignored till EOL.
  860. X.Sh "EXAMPLES"
  861. X.LP
  862. XSome example recipes are listed below:
  863. X.LP
  864. XSort out all mail to mailling list scuba-dive.
  865. X.RS
  866. X.LP
  867. X:
  868. X.PD 0
  869. X.LP
  870. X^TOscuba
  871. X.LP
  872. Xscubafile
  873. X.PD
  874. X.LP
  875. X.RE
  876. XForward all mail from peter about compilers to william (and keep a copy
  877. Xof it here in petcompil).
  878. X.RS
  879. X.LP
  880. X:2 bc
  881. X.PD 0
  882. X.LP
  883. X^From.*peter
  884. X.LP
  885. X^Subject:.*compilers
  886. X.LP
  887. X! william@somewhere.edu
  888. X.LP
  889. X:2
  890. X.LP
  891. X^From.*peter
  892. X.LP
  893. X^Subject:.*compilers
  894. X.LP
  895. Xpetcompil
  896. X.PD
  897. X.RE
  898. X.LP
  899. XAdd the headers of all messages to your private header collection (for
  900. Xstatistics or mail debugging); and use the lockfile "headc.lock".  In order
  901. Xto make sure the lockfile is not removed until the pipe has finished,
  902. Xyou have to specify option 'w'; otherwise the lockfile would be removed as
  903. Xsoon as the pipe had accepted the mail.
  904. X.RS
  905. X.LP
  906. X:0hwc:
  907. X.PD 0
  908. X.LP
  909. X| uncompress headc.Z; cat >>headc; compress headc
  910. X.RE
  911. X.PD
  912. X.LP
  913. XPrepend a linecount at the beginning of all multi part messages
  914. X(and don't allow
  915. X.B procmail
  916. Xto terminate early if the filter succeeds).  Use "templock" as lockfile.
  917. X.RS
  918. X.LP
  919. X:wbf:templock
  920. X.PD 0
  921. X.LP
  922. X^Subject:.*\\(.*(/|of).*\\)
  923. X.LP
  924. X|echo "wc output:";tee tempf|wc;cat tempf;rm tempf
  925. X.PD
  926. X.RE
  927. X.LP
  928. XDump all mail from at jobs into one file, filter out the interesting
  929. Xparts of the header first.
  930. X.LP
  931. X.RS
  932. X:2fh
  933. X.PD 0
  934. X.LP
  935. X^From root
  936. X.LP
  937. X^Subject: Output from "at" job
  938. X.LP
  939. X|echo "From at job";echo;egrep "^Date:"
  940. X.LP
  941. X:b
  942. X.LP
  943. X^From at job
  944. X.LP
  945. Xatjunk
  946. X.RE
  947. X.PD
  948. X.Sh "FILES"
  949. X.PD 0
  950. X.Tp 22
  951. X.B /etc/passwd
  952. Xto get the recipients USER, HOME and SHELL variable defaults
  953. X.Tp
  954. X.B /var/spool/mail/$USER
  955. Xdefault last resort to put mail
  956. X.Tp 
  957. X.B $HOME/.procmailrc
  958. Xdefault rc file
  959. X.Tp
  960. X.B $HOME/.mailbox
  961. Xdefault mailbox
  962. X.Tp
  963. X.B /var/spool/mail/$USER.lock
  964. Xlockfile for standard system mail directory (not used by
  965. X.B procmail
  966. Xunless you explicitly tell it to)
  967. X.Tp
  968. X.B /lib/sendmail
  969. Xdefault mail forwarder
  970. X.Tp
  971. X.B /usr/bin/egrep
  972. Xdefault regular expression parser
  973. X.PD
  974. X.Sh "SEE ALSO"
  975. X.LP
  976. X.BR sh (1),
  977. X.BR csh (1),
  978. X.BR mail (1),
  979. X.BR binmail (1),
  980. X.BR uucp (1C),
  981. X.BR aliases (5),
  982. X.BR sendmail (8),
  983. X.BR egrep (1V),
  984. X.BR lockfile (1)
  985. X.Sh "DIAGNOSTICS"
  986. X.Tp 23
  987. XError while writing to "x"
  988. Xnonexistent subdirectory, no write permission, or disk full
  989. X.Tp
  990. XFailed forking "x"
  991. Xnot possible if 's' flag specified on the recipe
  992. X.Tp
  993. XProgram failure of "x"
  994. Xsome pipe or program that was started by procmail returned a non-null value
  995. X.Tp
  996. XFailed to execute "x"
  997. Xprogram not in path, or not executable
  998. X.Tp
  999. XCouldn't unlink "x"
  1000. Xlockfile was already gone, or write permission to the directory were the
  1001. Xlockfile is has been denied
  1002. X.Tp
  1003. XOut of memory
  1004. Xprobably a runaway filter that dumps junk into procmail,
  1005. Xor the system could be out of swap space
  1006. X.Tp
  1007. XLockfailure on "x"
  1008. Xcan only occur if you specify some real weird (and illegal) lockfilenames
  1009. Xor if the
  1010. X.B lockfile
  1011. Xcould not be created because of insufficient permissions or noexistent
  1012. Xsubdirectories
  1013. X.Tp
  1014. XForcing lock on "x"
  1015. Xspecified
  1016. X.B lockfile
  1017. Xis going to be removed by force because of a timeout (see also:
  1018. X.BR LOCKTIMEOUT )
  1019. X.Tp
  1020. XForced unlock denied on "x"
  1021. Xno write permission in the directory where
  1022. X.B lockfile
  1023. Xresides
  1024. X.Tp
  1025. XTerminating prematurely
  1026. Xprocmail received a signal and is bailing out
  1027. X.Tp
  1028. XTerminating prematurely whilst waiting for lockfile "x"
  1029. Xprocmail received a signal while it was waiting for a lockfile to
  1030. Xdisappear
  1031. X.PD
  1032. X.Sh "BUGS & SPECIAL FEATURES"
  1033. X.LP
  1034. XIf you don't explicitly tell procmail
  1035. Xto wait (option 'w') for the pipe or program to finish, it won't wait
  1036. Xand will terminate early (not knowing if the pipe or program returns
  1037. Xsuccess).
  1038. X.LP
  1039. XThe only substitutions of environment variables that can be handled by
  1040. Xprocmail itself are of the type $name.
  1041. X.LP
  1042. XA line buffer of 2048 bytes is used when processing the
  1043. X.IR rcfile ,
  1044. Xany environment variable expansions
  1045. X.B have
  1046. Xto fit within this limit.
  1047. X.LP
  1048. XDon't put comments on the lines in a recipe that get fed to $GREP,
  1049. Xthese lines are fed to $GREP
  1050. X.IR literally .
  1051. X.LP
  1052. XRace conditions sometimes result in a failure to remove a lock file
  1053. X(e.g. forwarding mail to yourself (on the same account) could (not
  1054. Xnecessarily) be a problem).
  1055. X.LP
  1056. XIn the unlikely event that you absolutely need to kill
  1057. Xprocmail before it has finished, then first try and use
  1058. Xthe regular kill command
  1059. X.RB ( SIGTERM ),
  1060. Xotherwise some
  1061. X.I lockfiles
  1062. Xmight not get removed.
  1063. X.LP
  1064. XYou should create a shell script that uses
  1065. X.BR lockfile (1)
  1066. Xbefore invoking
  1067. Xthe mail program on any mailbox file other than the system mailbox.
  1068. X.LP
  1069. XAny default values that procmail has for some environment variables will
  1070. X.B always
  1071. Xoverride the ones that were already defined.  If you really want to
  1072. X.B override
  1073. Xthe
  1074. X.BR defaults ,
  1075. Xyou either have to put them in the
  1076. X.B .procmailrc
  1077. Xor on the command line.
  1078. X.LP
  1079. XThe values of
  1080. X.BR LOCKSLEEP ,
  1081. X.B LOCKTIMEOUT
  1082. Xand
  1083. X.B NOMEMRETRY
  1084. Xare parsed as if they were C constants (octal, decimal and hexadecimal format
  1085. Xare understood).
  1086. X.Sh "NOTES"
  1087. X.LP
  1088. XAny program executed from within procmail will be searched for in the PATH
  1089. Xvariable (you have to specify it though).  It is advisable however, to
  1090. Xspecify an absolute path for $GREP, because it gets executed fairly often.
  1091. X.LP
  1092. XIf the regular expression starts with "\fB^TO\fP" it will be substituted by
  1093. X"\fB^(To|Cc|Apparently-To):.*\fP", which should catch all destination
  1094. Xspecifications.
  1095. X.LP
  1096. XAny lines in the body of the message that look like postmarks are prepended
  1097. Xwith '>' (disarms bogus mailheaders).  The regular expression that is used
  1098. Xto search for these postmarks is:
  1099. X.RS
  1100. X\\n\\nFrom +[^\\t\\n ]+ +[^\\n\\t]
  1101. X.RE
  1102. X.LP
  1103. XShould the uid procmail is running under, have no corresponding /etc/passwd
  1104. Xentry, then HOME will default to /tmp, USER will default to #uid.
  1105. X.LP
  1106. XFor
  1107. X.I really
  1108. Xcomplicated processing you can even consider calling
  1109. X.B procmail
  1110. Xrecursively.
  1111. X.LP
  1112. XYour $HOME/.forward (beware, it
  1113. X.B has
  1114. Xto be world readable) file should contain (include the quotes,
  1115. X.I must
  1116. Xbe an
  1117. X.I absolute
  1118. Xpath):
  1119. X.LP
  1120. X"|exec /global/bin/procmail"
  1121. X.Ss "A sample small .procmailrc:"
  1122. X.PD 0
  1123. X.LP
  1124. XPATH=/bin:/usr/bin:/global/bin:/usr/local/bin
  1125. X.LP
  1126. XMAILDIR=$HOME/Mail    #you'd better make sure it exists
  1127. X.LP
  1128. XDEFAULT=$MAILDIR/mbox
  1129. X.LP
  1130. XLOGFILE=$MAILDIR/from
  1131. X.LP
  1132. XLOCKFILE=$HOME/.lockmail
  1133. X.LP
  1134. X:
  1135. X.LP
  1136. X^From.*berg
  1137. X.LP
  1138. Xfrom_me
  1139. X.LP
  1140. X:
  1141. X.LP
  1142. X^Subject:.*Flame
  1143. X.LP
  1144. X/dev/null
  1145. X.PD
  1146. X.Sh "AUTHOR"
  1147. X.LP
  1148. XStephen R. van den Berg at RWTH-Aachen, Germany
  1149. X.RS
  1150. Xberg@marvin.e17.physik.tu-muenchen.de (preferred)
  1151. X.br
  1152. Xberg@cip-s01.informatik.rwth-aachen.de (alternative)
  1153. X.RE
  1154. SHAR_EOF
  1155. chmod 0644 procmail/procmail.1 ||
  1156. echo 'restore of procmail/procmail.1 failed'
  1157. Wc_c="`wc -c < 'procmail/procmail.1'`"
  1158. test 15169 -eq "$Wc_c" ||
  1159.     echo 'procmail/procmail.1: original size 15169, current size' "$Wc_c"
  1160. fi
  1161. # ============= procmail/procmail.c ==============
  1162. if test -f 'procmail/procmail.c' -a X"$1" != X"-c"; then
  1163.     echo 'x - skipping procmail/procmail.c (File already exists)'
  1164. else
  1165. echo 'x - extracting procmail/procmail.c (Text)'
  1166. sed 's/^X//' << 'SHAR_EOF' > 'procmail/procmail.c' &&
  1167. X/************************************************************************
  1168. X *    procmail.c    an autonomous mail processor            *
  1169. X *                                    *
  1170. X *    Version 1.30 1991-03-01                        *
  1171. X *    Seems to be relatively bug free.                *
  1172. X *                                    *
  1173. X *    Copyright (c) 1990-1991, S.R.van den Berg, The Netherlands    *
  1174. X *    The sources can be freely copied for non-commercial use.    *
  1175. X *    See the accompanying README file for more info.            *
  1176. X *                                    *
  1177. X *    Don't complain about the formatting, I know it's        *
  1178. X *    unconventional, but it's my standard format (I have my        *
  1179. X *    reasons).  If you don't like it, feed it through your        *
  1180. X *    favourite C beautifier.     The program has been tested on        *
  1181. X *    SUN's, but should work on almost every *NIX system that        *
  1182. X *    has a fork() and execvp() command.  The only things that    *
  1183. X *    might need some changes are the include files.            *
  1184. X *    There might be one problem if your system doesn't know        *
  1185. X *    fsync(fd).  Define NOfsync in that case.            *
  1186. X *                                    *
  1187. X *    If you have had to make major changes in order to get it    *
  1188. X *    running on a different machine, please send me the patches.    *
  1189. X *    That way I might include them in a future version.        *
  1190. X *                                    *
  1191. X *    Please note that this program essentially is supposed to be    *
  1192. X *    static, that means no extra features (IMHO no more are        *
  1193. X *    needed) are supposed to be added (though any usefull        *
  1194. X *    suggestions will be appreciated and evaluated if time permits). *
  1195. X ************************************************************************/
  1196. X#include "config.h"
  1197. X#define MAIN
  1198. X#include "procmail.h"
  1199. X#include "sysexits.h"
  1200. X#include "shell.h"
  1201. X
  1202. X#define VERSION "Procmail v1.30 1991-03-01 written by Stephen R.van den Berg\n"
  1203. X#define VERSIONOPT    "-v"            /* option to display version */
  1204. X
  1205. Xchar buf[BFSIZ],buf2[BFSIZ],maildir[]="MAILDIR",defaultf[]="DEFAULT",
  1206. X logfile[]="LOGFILE",lockfile[]="LOCKFILE",grep[]="GREP",host[]="HOST",
  1207. X locksleep[]="LOCKSLEEP",orgmail[]="ORGMAIL",eumask[]="UMASK",
  1208. X shellmetas[]="SHELLMETAS",shellflags[]="SHELLFLAGS",shell[]="SHELL",
  1209. X sendmail[]="SENDMAIL",lockext[]="LOCKEXT",locktimeout[]="LOCKTIMEOUT",
  1210. X devnull[]="/dev/null",newline[]="\n",binsh[]="/bin/sh",home[]="HOME",
  1211. X tmp[]="/tmp",user[]="USER",nomemretry[]="NOMEMRETRY",*rcfile=PROCMAILRC,
  1212. X **gargv,*globlock,*loclock,*tolock;
  1213. Xint retval=EX_CANTCREAT,flaggerd=1,verrgrandchild,sh,pwait,secur,lcking,
  1214. X nextexit,locknext;
  1215. Xpid_t mother;
  1216. XFILE*rc;
  1217. X
  1218. Xmain(argc,argv)char*argv[];{static char flags[10];int i;
  1219. X char*themail,*thebody,*chp,*startchar,*chp2;long tobesent,filled,rcoffset;
  1220. X if((chp=argv[1])&&!strcmp(chp,VERSIONOPT)){
  1221. X   log(VERSION);return EX_OK;}
  1222. X mother=getpid();setbuf(stdin,(void*)0);umask(077);
  1223. X sprintf(buf,"%u",i=getuid());setpwent();
  1224. X {struct passwd*pass;
  1225. X if(pass=getpwuid(i)){            /* find user defaults in /etc/passwd */
  1226. X   setdef(home,pass->pw_dir);chdir(pass->pw_dir);
  1227. X   setdef(user,pass->pw_name?pass->pw_name:buf);setdef(shell,pass->pw_shell);}
  1228. X else{             /* user could not be found, set reasonable defaults */
  1229. X   setdef(home,tmp);chdir(tmp);setdef(user,buf);setdef(shell,binsh);}}
  1230. X endpwent();setdef(shellmetas,DEFshellmetas);setdef(shellflags,DEFshellflags);
  1231. X setdef(maildir,DEFmaildir);setdef(defaultf,DEFdefault);
  1232. X setdef(orgmail,DEForgmail);setdef(grep,DEFgrep);setdef(sendmail,DEFsendmail);
  1233. X setdef(lockext,DEFlockext);setdef(locksleep,DEFlocksleeps);
  1234. X setdef(locktimeout,DEFlocktimeout);setdef(nomemretry,DEFnomemretry);
  1235. X chdir(getenv(maildir));fdreopena(devnull,STDERR);fdreopena(devnull,STDOUT);
  1236. X gargv=argv+1;nextrcfile();
  1237. X thebody=themail=malloc(argc=1);filled=rcoffset=0;
  1238. Xchangedmail:
  1239. X themail=readdyn(themail,&filled);             /* read in the mail */
  1240. Xonlyhead:
  1241. X startchar=filled+(thebody=themail);
  1242. X while(thebody<startchar&&*thebody++=='\n');         /* skip leading garbage */
  1243. X thebody=findel(thebody,startchar);     /* find the end of the header         */
  1244. X chp=thebody;
  1245. X do{                     /* search for bogus headers         */
  1246. X   if(startchar-chp<8)             /* we're looking for:             */
  1247. X      break;                 /* "\n\nFrom +[^\t\n ]+ +[^\n\t]"   */
  1248. X   if(0>=sscanf(chp,"From%1[ ]",buf))     /* thats the regular expression     */
  1249. X      continue;                 /* that defines the start of a mail */
  1250. X   chp2=chp;chp+=5;             /* message.                 */
  1251. X#define SKIPWHILE(x)    while(x){ if(++chp>=startchar) break;}
  1252. X   SKIPWHILE(*chp==' ')
  1253. X   SKIPWHILE((i=*chp)&&i!=' '&&i!='\t'&&i!='\n')
  1254. X   SKIPWHILE(*chp==' ')
  1255. X   if((i=*chp)&&i!='\n'&&i!='\t'){       /* insert '>' before bogus header */
  1256. X      i=startchar[-1];tmemmove(chp2+1,chp2,(startchar-chp2)-1);
  1257. X      *chp2='>';themail=realloc(chp2=themail,++filled);
  1258. X#define ADJUST(x)    ((x)=themail+((x)-chp2))
  1259. X      ADJUST(thebody);ADJUST(startchar);ADJUST(chp);*startchar++=i;}}
  1260. X while(startchar>(chp=findel(chp,startchar)));
  1261. X waitflagger();         /* if we're a child, wait for the parental guidance */
  1262. Xchangerc:
  1263. X rc=fopen(strcat(cat(getenv(home),"/"),rcfile),"r");
  1264. X fseek(rc,rcoffset,SEEK_SET);signal(SIGINT,sterminate);
  1265. X signal(SIGQUIT,sterminate);signal(SIGTERM,sterminate);signal(SIGHUP,SIG_IGN);
  1266. Xgoon:
  1267. X while(unlock(&loclock),!feof(rc)||argv[argc]){
  1268. X   while(chp=argv[argc]){           /* interpret command line specs first */
  1269. X      argc++;strcpy(buf2,chp);
  1270. X      if(chp=strchr(buf2,'=')){
  1271. X     chp++;goto argenv;}}
  1272. X   if(tscrc(" %1[:]",flags)){                   /* check for a recipe */
  1273. X      skipblanks();i=sh=1;
  1274. X      if(tscrc("%[0-9]",buf2)){
  1275. X     sscanf(buf2,"%d",&sh);skipblanks();}
  1276. X      *flags='\0';scrc("%9[HBIhbfcws]",flags);skipblanks();
  1277. X      if(tolock)         /* clear temporary buffer for lockfile name */
  1278. X     free(tolock);
  1279. X      tolock=0;
  1280. X      if((locknext=(tscrc("%1[:]",buf)))&&
  1281. X     (skipblanks(),tscrc("%[^ \t\n#]",buf2))){
  1282. X     parse();tolock=tstrdup(buf);}
  1283. X      startchar=themail;tobesent=thebody-themail;
  1284. X      if(strchr(flags,'B'))        /* what needs to be piped into grep? */
  1285. X     if(strchr(flags,'H'))
  1286. X        tobesent=filled;
  1287. X     else{
  1288. X        startchar=thebody;tobesent=filled-tobesent;}
  1289. X      while(sh--){                    /* any conditions (left) */
  1290. X     skiptoeol();scrc("%[^\n]",buf2);
  1291. X     if(!strncmp(buf2,TOkey,TOkeylen))
  1292. X        cat(TOsubstitute,buf2+TOkeylen);
  1293. X     else
  1294. X        strcpy(buf,buf2);
  1295. X     if(i)                     /* check out all conditions */
  1296. X        i=!grepin(buf,startchar,tobesent,!strchr(flags,'I'));}
  1297. X      startchar=themail;tobesent=filled;        /* body, header or both? */
  1298. X      if(strchr(flags,'h')){
  1299. X     if(!strchr(flags,'b'))
  1300. X        tobesent=thebody-themail;}
  1301. X      else if(strchr(flags,'b'))
  1302. X     tobesent-=(startchar=thebody)-themail;
  1303. X      chp=buf+strlen(cat(getenv(sendmail)," "));sh=0;
  1304. X      pwait=!!strchr(flags,'w');secur=!!strchr(flags,'s');
  1305. X      if(tscrc(" ! %[^\n]",chp)){             /* forward the mail */
  1306. X     if(i)
  1307. X        goto forward;}
  1308. X      else if(tscrc("| %[^\n]",buf2)){                /* pipe the mail */
  1309. X     if(i){
  1310. X        if(sh=!!strpbrk(buf2,getenv(shellmetas)))
  1311. X           strcpy(buf,buf2);
  1312. X        else
  1313. X           parse();
  1314. X        chp=buf;*buf2='\0';
  1315. X        while(i=*chp)      /* find the implicit lockfile name ('>>name') */
  1316. X          if(chp++,i=='>'&&*chp=='>'){
  1317. X         while((i=*++chp)==' '||i=='\t');
  1318. X         sscanf(chp,"%[^ \t\n#'\");|<>]",buf2);break;}
  1319. X        lcllock();
  1320. X        if(strchr(flags,'f')){
  1321. X           if(startchar==themail&&tobesent!=filled){      /* if only 'h' */
  1322. X          char*dest;long dfilled=0;
  1323. X          if(pipthrough(buf,startchar,tobesent))
  1324. X             goto goon;
  1325. X          dest=readdyn(malloc(1),&dfilled);filled-=tobesent;
  1326. X          if(tobesent<dfilled)     /* adjust buffer size (only bigger) */
  1327. X             themail=realloc(themail,dfilled+filled);
  1328. X          tmemmove(themail+dfilled,themail+tobesent,filled);
  1329. X          tmemmove(themail,dest,dfilled);free(dest);
  1330. X          themail=realloc(themail,filled+=dfilled);
  1331. X          goto onlyhead;}       /* and determine the header again */
  1332. X           rcoffset=ftell(rc);    /* needed because we have to fclose it */
  1333. X           if(pipthrough(buf,startchar,tobesent))
  1334. X          goto goon;
  1335. X           filled=startchar-themail;goto changedmail;}
  1336. Xforward:    if(!pipin(buf,startchar,tobesent)&&!strchr(flags,'c'))
  1337. X           goto mailed;}}
  1338. X      else{                    /* append the mail to a file */
  1339. X     scrc("%s",buf2);skipcomment();
  1340. X     if(i){
  1341. X        parse();strcpy(buf2,buf);lcllock();
  1342. X        if(!dump(opena(buf),startchar,tobesent)&&!strchr(flags,'c'))
  1343. X           goto mailed;}}}
  1344. X   else if(tscrc("%[A-Z_a-z0-9] = ",buf)){  /* then it must be an assignment */
  1345. X      *(chp=buf+strlen(buf))='=';*++chp='\0';scrc("%[^\t\n#]",chp);
  1346. X      for(chp2=chp+strlen(chp);*--chp2==' ';);         /* skip trailing blanks */
  1347. X      chp2[1]='\0';skipcomment();strcpy(buf2,buf);
  1348. Xargenv:
  1349. X      parse();sputenv(buf);chp[-1]='\0';
  1350. X      if(!strcmp(buf,maildir))
  1351. X     chdir(chp);
  1352. X      else if(!strcmp(buf,logfile))
  1353. X     fdreopena(chp,STDERR);
  1354. X      else if(!strcmp(buf,lockfile))
  1355. X     lockit(chp,&globlock);
  1356. X      else if(!strcmp(buf,eumask)){
  1357. X     sscanf(chp,"%o",&i);umask(i);}
  1358. X      else if(!strcmp(buf,host)){
  1359. X#ifndef NOuname
  1360. X     struct utsname name;
  1361. X     uname(&name);
  1362. X     if(strcmp(chp,name.nodename)){
  1363. X#else
  1364. X     *buf2='\0';gethostname(buf2,BFSIZ);
  1365. X     if(strcmp(chp,buf2)){
  1366. X#endif
  1367. X        if(nextrcfile()){
  1368. X           fclose(rc);rcoffset=0;goto changerc;}
  1369. X        retval=EX_OK;terminate();}}}
  1370. X   else if(!skipcomment()){            /* either comment or garbage */
  1371. X      scrc("%[^\n] ",buf);log("Skipped:");logqnl(buf);}}
  1372. X if(dump(opena(chp=getenv(defaultf)),themail,filled)){     /* default maildest */
  1373. X   writeerr(chp);        /* if it fails, don't panic, try the last resort */
  1374. X   if(dump(opena(chp=getenv(orgmail)),themail,filled))
  1375. X      writeerr(chp);goto mailerr;}            /* now you can panic */
  1376. Xmailed:
  1377. X retval=EX_OK;                  /* we're home free, mail delivered */
  1378. Xmailerr:
  1379. X unlock(&loclock);            /* any local lock file still around? */
  1380. X do{
  1381. X   chp=buf-1;
  1382. X   while(themail<thebody&&chp<buf+BFSIZ-1&&(*++chp=*themail++)!='\n');
  1383. X   if(chp<buf)
  1384. X      chp++;
  1385. X   *chp='\0';
  1386. X   if(0<sscanf(buf,"From%*1[^:]%[^\n]",buf2)){
  1387. X      log("From ");goto foundsorf;}
  1388. X   else if(0<sscanf(buf,"Subject:%[^\n]",buf2)){
  1389. X      log(" Subject:");
  1390. Xfoundsorf:
  1391. X      log(buf2);log(newline);}}                 /* log it's arrival */
  1392. X while(themail<thebody);
  1393. X terminate();}
  1394. SHAR_EOF
  1395. chmod 0644 procmail/procmail.c ||
  1396. echo 'restore of procmail/procmail.c failed'
  1397. Wc_c="`wc -c < 'procmail/procmail.c'`"
  1398. test 9798 -eq "$Wc_c" ||
  1399.     echo 'procmail/procmail.c: original size 9798, current size' "$Wc_c"
  1400. fi
  1401. # ============= procmail/nonint.c ==============
  1402. if test -f 'procmail/nonint.c' -a X"$1" != X"-c"; then
  1403.     echo 'x - skipping procmail/nonint.c (File already exists)'
  1404. else
  1405. echo 'x - extracting procmail/nonint.c (Text)'
  1406. sed 's/^X//' << 'SHAR_EOF' > 'procmail/nonint.c' &&
  1407. X/************************************************************************
  1408. X *    Collection of routines that don't return int            *
  1409. X *                                    *
  1410. X *    Copyright (c) 1990-1991, S.R.van den Berg, The Netherlands    *
  1411. X *    The sources can be freely copied for non-commercial use.    *
  1412. X *    See the accompanying README file for more info.            *
  1413. X *                                    *
  1414. X *    Don't complain about the formatting, I know it's        *
  1415. X *    unconventional, but it's my standard format (I have my        *
  1416. X *    reasons).  If you don't like it, feed it through your        *
  1417. X *    favourite C beautifier.                        *
  1418. X ************************************************************************/
  1419. X
  1420. X#include "config.h"
  1421. X#include "procmail.h"
  1422. X#include "sysexits.h"
  1423. X
  1424. X#ifdef NOmemmove
  1425. Xvoid*memmove(to,from,count)register void*to,*from;register t_buf count;{
  1426. X void*old;
  1427. X old=to;count++;--(char*)to;--(char*)from;
  1428. X if(to<=from){
  1429. X   goto jiasc;
  1430. X   do{
  1431. X      *++(char*)to=*++(char*)from;
  1432. Xjiasc:;}
  1433. X   while(--count);}
  1434. X else{
  1435. X   (char*)to+=count;(char*)from+=count;
  1436. X   goto jidesc;
  1437. X   do{
  1438. X      *--(char*)to=*--(char*)from;
  1439. Xjidesc:;}
  1440. X   while(--count);}
  1441. X return old;}
  1442. X#endif
  1443. X
  1444. Xvoid*tmalloc(len)t_buf len;{void*p;int i;      /* this malloc can survive */
  1445. X if(p=malloc(len))        /* a temporary "out of swap space" condition */
  1446. X   return p;
  1447. X for(i=renvint(iDEFnomemretry,nomemretry);i<0||i--;){
  1448. X   sleep(SUSPENSION);         /* problems?  don't panic, wait a few secs till */
  1449. X   if(p=malloc(len))         /* some other process has paniced (and died 8-) */
  1450. X      return p;}
  1451. X nomemerr();}
  1452. X
  1453. Xvoid*trealloc(old,len)void*old;t_buf len;{int i; /* this realloc can survive */
  1454. X if(old=realloc(old,len))    /* a temporary "out of swap space" condition */
  1455. X    return old;
  1456. X for(i=renvint(iDEFnomemretry,nomemretry);i<0||i--;){
  1457. X   sleep(SUSPENSION);         /* problems?  don't panic, wait a few secs till */
  1458. X   if(old=realloc(old,len))  /* some other process has paniced (and died 8-) */
  1459. X      return old;}
  1460. X nomemerr();}
  1461. X
  1462. X#include "shell.h"
  1463. X
  1464. Xpid_t sfork(){pid_t i;               /* if secur is set, it doesn't return */
  1465. X while((i=fork())&&secur&&i==-1)       /* until the fork was successfull     */
  1466. X   sleep(SUSPENSION);
  1467. X return i;}
  1468. X
  1469. Xvoid sterminate(){
  1470. X if(!nextexit){
  1471. X   log("Terminating prematurely");
  1472. X   if(!lcking){
  1473. X      log(newline);terminate();}}
  1474. X nextexit=1;}
  1475. X
  1476. Xvoid flagger(){                    /* hey, we received a SIGHUP */
  1477. X flaggerd=1;}
  1478. X
  1479. Xvoid errgrandchild(){               /* my grandchildren scream in despair */
  1480. X verrgrandchild=1;}
  1481. X
  1482. Xlong dump(s,source,len)int s;char*source;long len;{int i;long ol;
  1483. X if(s>=0){
  1484. X    ol=len;
  1485. X    while(i=rwrite(s,source,BLKSIZ<len?BLKSIZ:(int)len)){
  1486. X       if(i<0){
  1487. X      i=0;goto writefin;}
  1488. X       len-=i;source+=i;}
  1489. X    if(!len&&(ol<2||!(source[-1]=='\n'&&source[-2]=='\n')))
  1490. X       rwrite(s,newline,1);           /* message always ends with a newline */
  1491. Xwritefin:
  1492. X    if(fsync(s)&&errno!=EINVAL)
  1493. X       len++;                   /* if there is a physical write error */
  1494. X    rclose(s);return len-i;}
  1495. X return len?len:-1;}       /* return an error even if nothing was to be sent */
  1496. X
  1497. Xlong pipin(line,source,len)char*line,*source;long len;{pid_t pid;
  1498. X int poutfd[2];
  1499. X pipe(poutfd);
  1500. X if(!(pid=sfork())){
  1501. X   rclose(PWRITE);redirect(PREAD);callnewprog(line);}
  1502. X rclose(PREAD);forkerr(pid,line);
  1503. X if(len=dump(PWRITE,source,len))
  1504. X   writeerr(line);
  1505. X if(pwait&&waitfor(pid)!=EX_OK){
  1506. X   progerr(line);len=1;}
  1507. X return len;}
  1508. X
  1509. Xchar*readdyn(bf,filled)char*bf;long*filled;{int i;
  1510. X goto jumpin;
  1511. X do{
  1512. X   *filled+=i;
  1513. Xjumpin:
  1514. X   bf=realloc(bf,*filled+BLKSIZ);}               /* dynamic adjust */
  1515. X while(0<(i=read(STDIN,bf+*filled,BLKSIZ)));
  1516. X if(!*filled)
  1517. X   return realloc(bf,1);
  1518. X return realloc(bf,*filled);}            /* minimize the buffer space */
  1519. X
  1520. Xchar*cat(a,b)char*a,*b;{
  1521. X return strcat(strcpy(buf,a),b);}
  1522. X
  1523. Xchar*findel(start,end)register char*start,*end;{/* find the first empty line */
  1524. X while(start<end)
  1525. X   if(*start++=='\n'&&start<end&&*start=='\n')
  1526. X      return start+1;
  1527. X return end;}
  1528. X
  1529. Xchar*tstrdup(a)char*a;{int i;
  1530. X i=strlen(a)+1;return tmemmove(malloc(i),a,i);}
  1531. SHAR_EOF
  1532. chmod 0644 procmail/nonint.c ||
  1533. echo 'restore of procmail/nonint.c failed'
  1534. Wc_c="`wc -c < 'procmail/nonint.c'`"
  1535. test 3914 -eq "$Wc_c" ||
  1536.     echo 'procmail/nonint.c: original size 3914, current size' "$Wc_c"
  1537. fi
  1538. # ============= procmail/config.h ==============
  1539. if test -f 'procmail/config.h' -a X"$1" != X"-c"; then
  1540.     echo 'x - skipping procmail/config.h (File already exists)'
  1541. else
  1542. echo 'x - extracting procmail/config.h (Text)'
  1543. sed 's/^X//' << 'SHAR_EOF' > 'procmail/config.h' &&
  1544. X/*#define SYSV        /* you guessed it, uncomment if sysV machine    */
  1545. X
  1546. X#define NOmemmove    /* if your library has it, comment this line    */
  1547. X
  1548. X/*#define NO_ANSI_PROT    /* uncomment if you don't have ANSI headers    */
  1549. X
  1550. X/*#define void char    /* uncomment if your compiler is brain damaged    */
  1551. X#ifdef SYSV
  1552. X# define NOfsync    /* in my experience no sysV machine has it    */
  1553. X#else
  1554. X# define NOuname    /* some BSD machines seem to have it anyway    */
  1555. X#endif
  1556. X
  1557. X/*#define NOfsync    /* if you don't want to use it or don't have it */
  1558. X
  1559. X#ifndef t_buf        /* should not be a macro anyway            */
  1560. Xtypedef unsigned t_buf; /* comment out if already defined        */
  1561. X            /* when in doubt, please check if this is the    */
  1562. X            /* correct type for your library as the size    */
  1563. X            /* argument to malloc, realloc and memmove    */
  1564. X            /* this is important, since it determines the    */
  1565. X            /* maximum message length that can be processed */
  1566. X            /* by procmail                    */
  1567. X#endif
  1568. X
  1569. X/* If need be, you can change some of the defines below, for most
  1570. X   people these defaults should do however                */
  1571. X
  1572. X#define BFSIZ        2048             /* max expanded line length */
  1573. X#define BLKSIZ        (1<<14)          /* blocksize while reading/writing */
  1574. X#define PROCMAILRC    ".procmailrc"
  1575. X#define SUSPENSION    16         /* multi-purpose 'idle loop' period */
  1576. X#define DEFlocksleep    8
  1577. X#define DEFlocksleeps    "8"
  1578. X#define TOkey        "^TO"
  1579. X#define TOkeylen    3            /* should be length of TOkey */
  1580. X#define TOsubstitute    "^(To|Cc|Apparently-To):.*"
  1581. X#define DEFshellmetas    "\"'`&#{}()[]*?|<>~;!\\"    /* never put '$' in here */
  1582. X#define DEFmaildir    "$HOME"
  1583. X#define DEFdefault    "$MAILDIR/.mailbox"
  1584. X#define DEForgmail    "/var/spool/mail/$USER"
  1585. X#define DEFgrep        "/usr/bin/egrep"
  1586. X#define DEFsendmail    "/usr/lib/sendmail"
  1587. X#define DEFlockext    ".lock"
  1588. X#define DEFshellflags    "-c"
  1589. X#define DEFlocktimeout    "3600"                 /* defaults to one hour */
  1590. X#define iDEFnomemretry    2        /* standard nr of retries if no mem left */
  1591. X                    /* valid as soon as procmail runs */
  1592. X#define DEFnomemretry    "2"
  1593. SHAR_EOF
  1594. chmod 0644 procmail/config.h ||
  1595. echo 'restore of procmail/config.h failed'
  1596. Wc_c="`wc -c < 'procmail/config.h'`"
  1597. test 1929 -eq "$Wc_c" ||
  1598.     echo 'procmail/config.h: original size 1929, current size' "$Wc_c"
  1599. fi
  1600. # ============= procmail/sysexits.h ==============
  1601. if test -f 'procmail/sysexits.h' -a X"$1" != X"-c"; then
  1602.     echo 'x - skipping procmail/sysexits.h (File already exists)'
  1603. else
  1604. echo 'x - extracting procmail/sysexits.h (Text)'
  1605. sed 's/^X//' << 'SHAR_EOF' > 'procmail/sysexits.h' &&
  1606. X/*#include <sysexits.h> /* uncomment if your system has it */
  1607. X
  1608. X#ifndef EX_OK
  1609. X        /* Standard exit codes, original list maintained
  1610. X           by Eric Allman (eric@berkeley, ucbvax!eric)     */
  1611. X# define EX_OK        0
  1612. X# define EX_UNAVAILABLE 69
  1613. X# define EX_OSERR    71
  1614. X# define EX_CANTCREAT    73
  1615. X#endif
  1616. SHAR_EOF
  1617. chmod 0644 procmail/sysexits.h ||
  1618. echo 'restore of procmail/sysexits.h failed'
  1619. Wc_c="`wc -c < 'procmail/sysexits.h'`"
  1620. test 279 -eq "$Wc_c" ||
  1621.     echo 'procmail/sysexits.h: original size 279, current size' "$Wc_c"
  1622. fi
  1623. # ============= procmail/procmail.h ==============
  1624. if test -f 'procmail/procmail.h' -a X"$1" != X"-c"; then
  1625.     echo 'x - skipping procmail/procmail.h (File already exists)'
  1626. else
  1627. echo 'x - extracting procmail/procmail.h (Text)'
  1628. sed 's/^X//' << 'SHAR_EOF' > 'procmail/procmail.h' &&
  1629. X#include "includes.h"
  1630. X
  1631. X#ifdef    NOsync            /* If you don't want syncs at all define */
  1632. X# define fsync(fd) 0        /* NOsync.  Only recommended if procmail */
  1633. X# define sync() 0        /* isn't used in a networked environment */
  1634. X#else
  1635. X# ifdef NOfsync            /* If you don't have fsync, define NOfsync */
  1636. X#  define fsync(fd) 0        /* sync will be used instead.  Is a bit       */
  1637. X# endif                /* slower, but works nevertheless       */
  1638. X#endif
  1639. X
  1640. X#define PREAD    (poutfd[0])
  1641. X#define PWRITE    (poutfd[1])
  1642. X#define tscrc(a,b)    (0<fscanf(rc,a,b))
  1643. X#define scrc(a,b)    fscanf(rc,a,b)
  1644. X
  1645. X#ifndef MAIN
  1646. Xextern char buf[],buf2[],maildir[],defaultf[],logfile[],lockfile[],grep[],
  1647. X host[],locksleep[],orgmail[],eumask[],shellmetas[],shellflags[],shell[],
  1648. X sendmail[],lockext[],locktimeout[],devnull[],newline[],binsh[],home[],
  1649. X tmp[],user[],nomemretry[],*rcfile,**gargv,*globlock,*loclock,*tolock;
  1650. Xextern retval,flaggerd,verrgrandchild,sh,pwait,secur,lcking,nextexit,locknext;
  1651. Xextern pid_t mother;
  1652. Xextern FILE*rc;
  1653. X#endif
  1654. X
  1655. X#ifdef NOmemmove
  1656. Xvoid*memmove();
  1657. X#endif
  1658. X
  1659. Xvoid*tmalloc(),*trealloc();
  1660. Xpid_t sfork();
  1661. Xvoid sterminate(),flagger(),errgrandchild();
  1662. Xlong dump(),pipin();
  1663. Xchar*readdyn(),*cat(),*findel(),*tstrdup();
  1664. SHAR_EOF
  1665. chmod 0644 procmail/procmail.h ||
  1666. echo 'restore of procmail/procmail.h failed'
  1667. Wc_c="`wc -c < 'procmail/procmail.h'`"
  1668. test 1158 -eq "$Wc_c" ||
  1669.     echo 'procmail/procmail.h: original size 1158, current size' "$Wc_c"
  1670. fi
  1671. # ============= procmail/shell.h ==============
  1672. if test -f 'procmail/shell.h' -a X"$1" != X"-c"; then
  1673.     echo 'x - skipping procmail/shell.h (File already exists)'
  1674. else
  1675. echo 'x - extracting procmail/shell.h (Text)'
  1676. sed 's/^X//' << 'SHAR_EOF' > 'procmail/shell.h' &&
  1677. X#define malloc(n)    tmalloc((t_buf)(n))
  1678. X#define realloc(p,n)    trealloc(p,(t_buf)(n))
  1679. X#define tmemmove(t,f,n) memmove(t,f,(t_buf)(n))
  1680. SHAR_EOF
  1681. chmod 0644 procmail/shell.h ||
  1682. echo 'restore of procmail/shell.h failed'
  1683. Wc_c="`wc -c < 'procmail/shell.h'`"
  1684. test 130 -eq "$Wc_c" ||
  1685.     echo 'procmail/shell.h: original size 130, current size' "$Wc_c"
  1686. fi
  1687. true || echo 'restore of procmail/retint.c failed'
  1688. echo End of part 1, continue with part 2
  1689. exit 0
  1690. -- 
  1691.  
  1692. exit 0 # Just in case...
  1693. -- 
  1694. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1695. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1696. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1697. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1698.