home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume29 / procmail / part02 < prev    next >
Encoding:
Text File  |  1992-05-12  |  54.3 KB  |  1,810 lines

  1. Newsgroups: comp.sources.misc
  2. From: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  3. Subject:  v29i091:  procmail - mail processing program v2.70, Part02/05
  4. Message-ID: <1992May11.151513.28981@sparky.imd.sterling.com>
  5. X-Md4-Signature: 94f20b1567471cada77585de1e4946cd
  6. Date: Mon, 11 May 1992 15:15:13 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  10. Posting-number: Volume 29, Issue 91
  11. Archive-name: procmail/part02
  12. Environment: UNIX, sendmail, smail, MMDF
  13. Supersedes: procmail: Volume 28, Issue 01-05
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 2 (of 5)."
  22. # Contents:  procmail/FAQ procmail/INSTALL procmail/Makefile
  23. #   procmail/includes.h procmail/man/formail.man
  24. #   procmail/man/lockfile.man procmail/man/manconf.c
  25. #   procmail/man/procmailex.man procmail/nonint.c procmail/shell.h
  26. # Wrapped by berg@drunol on Thu Apr 30 13:42:56 1992
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'procmail/FAQ' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'procmail/FAQ'\"
  30. else
  31. echo shar: Extracting \"'procmail/FAQ'\" \(4473 characters\)
  32. sed "s/^X//" >'procmail/FAQ' <<'END_OF_FILE'
  33. X------------------------------------------------------------------------------
  34. X---------------------- Frequently Asked Questions ----------------------------
  35. X------------------------------------------------------------------------------
  36. X
  37. X1. How do I go about setting up a mailinglist?
  38. X
  39. X    Look in the examples/mailinglist file, it describes it in detail.
  40. X
  41. X2. I installed procmail (i.e. typed 'make install'), but how am I supposed to
  42. X   use it?  When I type procmail on the command line it simply does nothing.
  43. X
  44. X    You're not supposed to start procmail from the command line.
  45. X    Be sure to have a .forward and a .procmailrc file in your home
  46. X    directory (see the examples subdirectory or the man page).
  47. X    MMDF users should note that they need a .maildelivery file *instead*
  48. X    of a .forward file (see the man page for more detailed information).
  49. X
  50. X    If however, procmail has been integrated in the maildelivery system
  51. X    (i.e. if your system administrator installed it that way, ask him/her),
  52. X    then you no longer need the .forward files in your home directory,
  53. X    having a .procmailrc file will suffice.
  54. X
  55. X    On some systems .forward files are not checked, in this case it might
  56. X    be worth trying to put a line looking like this:
  57. X        Pipe to /usr/local/bin/procmail
  58. X    as the only line in your mail spool file (e.g. /usr/mail/$USER), as
  59. X    well as doing a "chmod 04600 /usr/mail/$USER".    For more information
  60. X    on such systems, do a "man mail".
  61. X
  62. X3. When I compile everything the compiler complains about invalid or illegal
  63. X   pointer combinations, but it produces the executables anyway.
  64. X   Should I be concerned?
  65. X
  66. X    Ignore these warnings, they simply indicate that either your compiler
  67. X    or your system include files are not ANSI/POSIX compliant.
  68. X    The compiler will produce correct code regardless of these warnings.
  69. X
  70. X4. The compiler seems to issue warnings about "loop not entered at top",
  71. X   is that a problem?
  72. X
  73. X    No, no problem at all, it just means I wrote the code :-)
  74. X    That's just about the only uncommon coding technique I use (don't
  75. X    think I don't try to avoid those jumps in loops, it's just that
  76. X    sometimes they are the best way to code it).  Use gcc if you want
  77. X    to avoid these warnings.
  78. X
  79. X5. The compiler complains about unmodifiable lvalues or assignments to const
  80. X   variables.  Now what?
  81. X
  82. X    Well, if the compiler produces the executables anyway everything
  83. X    probably is all right.    If it doesn't, you might try inserting a
  84. X    "#define const" in the autoconf.h file by hand.     However in any case,
  85. X    your compiler is broken; I would recommend submitting this as a
  86. X    compiler bug to your vendor.  In any case, if this should occur, I'd
  87. X    appreciate a mail from you (so I can try to fix the autoconf script
  88. X    to recognise your compiler).
  89. X
  90. X6. The compiler refuses to compile regexp.c, what is the problem?
  91. X
  92. X    Try compiling that module with optimisation turned off.
  93. X
  94. X7. When I send myself a testmail, the mail bounces with the message: cannot
  95. X   execute binary file.     What am I doing wrong?
  96. X
  97. X    It is very well possible that mail is processed on a different
  98. X    machine from that where you usually read your mail.  Therefore you
  99. X    have to make sure that procmail has the right binary format to
  100. X    execute on those machines on which mail could arrive.  In order to
  101. X    get this right you might need to do some .forward file tweaking,
  102. X    look at the examples/advanced file for some suggestions.
  103. X
  104. X8. Where do I look for examples about:
  105. X    One home directory, several machine architectures?
  106. X    Procmail as an integrated local mail delivery agent?
  107. X    Security considerations (when installing procmail suid root)
  108. X    How to generate autoreplies?
  109. X    `Vacation' functionality
  110. X    Exorbitant rcfile formats?
  111. X    The 'A' flag?
  112. X
  113. X    Well, this probably is your lucky day :-), all these topics are covered
  114. X    in the examples/advanced file.
  115. X
  116. X9. Why do I have to insert my login name after the '#' in the .forward or
  117. X   .maildelivery file?
  118. X
  119. X    Some mailers 'optimise' maildelivery and take out duplicates from
  120. X    Cc:, Bcc: and alias lists before delivery.  If two or more persons on
  121. X    such a list would have identical .forward files, then the mailer will
  122. X    eliminate all but one.    Adding a '#' with your login name following
  123. X    it will make the .forward files unique, and will ensure that the mailer
  124. X    does optimise away some addresses.
  125. X
  126. X10. None of the above topics cover my problem.    Should I panic?
  127. X
  128. X    Let me ask you a question :-), have you examined the CAVEATS, WARNINGS,
  129. X    BUGS and NOTES sections of the manual pages *closely* ?
  130. X    If you have, well, then panic.
  131. END_OF_FILE
  132. if test 4473 -ne `wc -c <'procmail/FAQ'`; then
  133.     echo shar: \"'procmail/FAQ'\" unpacked with wrong size!
  134. fi
  135. # end of 'procmail/FAQ'
  136. fi
  137. if test -f 'procmail/INSTALL' -a "${1}" != "-c" ; then 
  138.   echo shar: Will not clobber existing file \"'procmail/INSTALL'\"
  139. else
  140. echo shar: Extracting \"'procmail/INSTALL'\" \(4735 characters\)
  141. sed "s/^X//" >'procmail/INSTALL' <<'END_OF_FILE'
  142. XDiscusses:
  143. X        1. Getting the lot to compile
  144. X        2. DEBUGGING AID
  145. X        3. Setting up the environment
  146. X        4. Extra options if you are a system administrator
  147. X
  148. X                ---
  149. X
  150. X1. Getting the lot to compile
  151. X   --------------------------
  152. X
  153. XTo install procmail, lockfile and formail: edit Makefile & config.h accordingly
  154. Xand type 'make install'.
  155. XIntended configurable options in Makefile are: the install-destinations
  156. XIntended configurable options in config.h are: KERNEL_LOCKS and MMDF support,
  157. X standard environment presettings, trusted user ids.
  158. X
  159. X'make install' will:
  160. X      - execute autoconf (a shell script that repeatedly calls the C compiler
  161. X    to determine if certain features/symbols are supported), which will
  162. X    create a file named autoconf.h
  163. X      - compile the *.c files, create the three stripped binaries:
  164. X    procmail, lockfile and formail
  165. X      - copy these binaries to $(BINDIR)
  166. X      - copy the man pages to $(MAN1DIR) and $(MAN5DIR)
  167. X
  168. X'make deinstall' will:
  169. X      - remove the just installed files in $(BINDIR)
  170. X      - remove the just installed files in $(MAN1DIR) and $(MAN5DIR)
  171. X
  172. X
  173. XMinimal requirements:
  174. X
  175. Xprocmail must be installed.
  176. Xlockfile needs only to be installed if you plan to read several mailboxes
  177. X    with one of the standard mailers that don't support lockfiles.
  178. Xformail needs only to be installed if mail sometimes arrives in nonstandard
  179. X    mailbox format (or if you want to generate auto replies, split up
  180. X    mailboxes/digests etc., see the man page of formail for more info).
  181. X    Formail is not called by procmail unless *you* tell it to.
  182. X
  183. XIf things don't compile automagically, I suggest you take a look at:
  184. Xautoconf, autoconf.h, config.h, includes.h
  185. X
  186. XFor autoconf to work as intended, your compiler should either be fully ANSI
  187. Xcompliant, or you should NOT turn off all warnings; enabling all warnings
  188. Xshouldn't hurt.     In most cases the default options in the Makefile will do.
  189. X
  190. XThe sources are supposed to be fully ANSI, K&R and POSIX compliant.
  191. X
  192. X                ---
  193. X
  194. X2. DEBUGGING AID
  195. X   -------------
  196. X
  197. XSince procmail is intended to run completely independent of any terminals, it
  198. Xdoesn't use the stderr output to display error messages.  It is recommended,
  199. Xespecially during debugging, to specify a LOGFILE (see man page) in the
  200. Xrcfile or on the command line.    Procmail will log all serious problems it
  201. Xencounters.  Of course, instead of a regular file, one could also specify a
  202. Xterminal as the default logfile.
  203. X
  204. XAlso, procmail can be persuaded to be a lot more verbose by preceding the
  205. Xlogfile name by a colon.
  206. XTherefore a suggested command line for your first trial run would be:
  207. Xprocmail LOGFILE=:/dev/tty
  208. X(now type in a pseudo mail-message)
  209. X
  210. XIf all else fails, you can try uncommenting the "#define console" entry
  211. Xin the config.h file.  This will provide you with the most verbose procmail
  212. Xyou can make.  It is of course a good idea to comment out this line again
  213. Xafter your troubles have been solved.
  214. X
  215. XIf you run procmail by hand and pipe in some sample mail, then make
  216. Xsure that if you kill procmail, you use "kill pid" and NOT "kill -9 pid".
  217. XShould procmail seem to hang, check if the $LOCKFILE is still present.
  218. XIf you kill procmail with "kill pid" it will clean up the $LOCKFILE
  219. Xitself.
  220. X
  221. X                ---
  222. X
  223. X3. Setting up the environment
  224. X   --------------------------
  225. X
  226. XEvery user that wants to use procmail should have a .forward and a
  227. X.procmailrc file in his HOME directory.     For starters, you can look
  228. Xat the supplied example files in "examples".
  229. X(BTW, be sure to make .forward *world* readable).
  230. XMMDF users should note that they need a .maildelivery file *instead* of the
  231. X.forward file (see the man page for more information).
  232. X
  233. X                ---
  234. X
  235. X4. Extra options if you are a system administrator
  236. X   -----------------------------------------------
  237. X
  238. XIf you are a system administrator you can decide to install procmail
  239. Xglobally (i.e. as an equivalent substitute for the local-maildelivery-
  240. Xcapabilities of /bin/mail), this has the advantage that users do not need to
  241. Xhave a .forward file anymore that calls up procmail.  Simply having a
  242. X.procmailrc file in the $HOME directory will suffice.  Operation is transparent
  243. Xin this case (i.e. if no .procmailrc file is present in the $HOME directory,
  244. Xmail will be delivered as usual).
  245. X
  246. XFor direct examples on how to do this, look at the examples/advanced file.
  247. X
  248. X*******************************************************************************
  249. XHIGHLY RECOMMENDED: install procmail setuid root (and/or setgid maildeamon)
  250. X            install lockfile setgid maildaemon (and/or setuid root)
  251. X
  252. XTo obtain specific instructions on the best installation, type "make recommend"
  253. X*******************************************************************************
  254. X
  255. X                ---
  256. X
  257. XFor more info about the program, see the man page or the FAQ list.
  258. END_OF_FILE
  259. if test 4735 -ne `wc -c <'procmail/INSTALL'`; then
  260.     echo shar: \"'procmail/INSTALL'\" unpacked with wrong size!
  261. fi
  262. # end of 'procmail/INSTALL'
  263. fi
  264. if test -f 'procmail/Makefile' -a "${1}" != "-c" ; then 
  265.   echo shar: Will not clobber existing file \"'procmail/Makefile'\"
  266. else
  267. echo shar: Extracting \"'procmail/Makefile'\" \(6248 characters\)
  268. sed "s/^X//" >'procmail/Makefile' <<'END_OF_FILE'
  269. X#$Id: Makefile,v 2.21 1992/04/23 16:46:41 berg Rel $
  270. X
  271. X# change BASENAME to your home directory if need be
  272. XBASENAME = /usr/local
  273. X
  274. X# You can predefine ARCHITECTURE to a bin directory suffix
  275. X#ARCHITECTURE=.sun4
  276. X
  277. XBINDIR      = $(BASENAME)/bin$(ARCHITECTURE)
  278. XMANDIR      = $(BASENAME)/man
  279. XMAN1SUFFIX= 1
  280. XMAN5SUFFIX= 5
  281. XMAN1DIR      = $(MANDIR)/man$(MAN1SUFFIX)
  282. XMAN5DIR      = $(MANDIR)/man$(MAN5SUFFIX)
  283. X
  284. X# Things that can be made are:
  285. X
  286. X# procmail formail lockfile        These are the three programs contained
  287. X#                    in this package
  288. X
  289. X# all            Makes all three binaries and the man pages
  290. X# install.man        Installs the man pages to $(MAN1DIR) and $(MAN5DIR)
  291. X# install        Is a "make all" followed by copying all the binaries
  292. X#            and man pages to $(BINDIR), $(MAN1DIR) and $(MAN5DIR)
  293. X#            respectively
  294. X# recommend        Show some recommended suid/sgid modes
  295. X# suid            Install the by-'make recommend'-shown modes
  296. X# clean            Restores the package to pre-make state
  297. X# deinstall        Removes the previously installed binaries and man
  298. X#            pages by careful surgery
  299. X
  300. X########################################################################
  301. X# Only edit below this line if you *think* you know what you are doing #
  302. X########################################################################
  303. X
  304. X# Directory for the standard include files
  305. XUSRINCLUDE = /usr/include
  306. X
  307. XOCFLAGS = -O #-ansi -pedantic -Wid-clash-6
  308. XOLDFLAGS= -s
  309. X
  310. XCFLAGS    = $(OCFLAGS) #-D_POSIX_SOURCE
  311. XLDFLAGS = $(OLDFLAGS) #-lcposix
  312. X
  313. XCC    = cc # gcc
  314. XMAKE    = make
  315. XSHELL    = /bin/sh
  316. XO    = o
  317. XRM    = /bin/rm -f
  318. XINSTALL = cp
  319. XDEVNULL = /dev/null
  320. X
  321. XBINS=procmail lockfile formail
  322. X
  323. XMANS=man/procmail.1 man/procmailrc.5 man/procmailex.5 man/formail.1 \
  324. X    man/lockfile.1
  325. X
  326. XMANS1=procmail.$(MAN1SUFFIX) formail.$(MAN1SUFFIX) lockfile.$(MAN1SUFFIX)
  327. XMANS5=procmailrc.$(MAN5SUFFIX) procmailex.$(MAN5SUFFIX)
  328. X
  329. XOBJ=nonint.$(O) goodies.$(O) regexp.$(O)
  330. X
  331. XDEP=shell.h procmail.h config.h
  332. X
  333. Xall:    everything recommend
  334. X
  335. Xeverything: autoconf.h $(BINS) $(MANS)
  336. X
  337. Xprocmail: procmail.$(O) $(OBJ) exopen.$(O) common.$(O) retint.$(O) strpbrk.$(O)
  338. X    $(CC) $(CFLAGS) -o procmail procmail.$(O) $(OBJ) exopen.$(O) \
  339. X     common.$(O) retint.$(O) strpbrk.$(O) $(LDFLAGS)
  340. X
  341. Xlockfile: lockfile.$(O) exopen.$(O) strpbrk.$(O)
  342. X    $(CC) $(CFLAGS) -o lockfile lockfile.$(O) exopen.$(O) strpbrk.$(O) \
  343. X     ${LDFLAGS}
  344. X
  345. Xformail: formail.$(O) common.$(O) strpbrk.$(O)
  346. X    $(CC) $(CFLAGS) -o formail formail.$(O) common.$(O) strpbrk.$(O) \
  347. X     ${LDFLAGS}
  348. X
  349. X_autotst: _autotst.$(O)
  350. X    $(CC) $(CFLAGS) -o _autotst _autotst.$(O) $(LDFLAGS)
  351. X
  352. Xautoconf.h: autoconf Makefile
  353. X    $(SHELL) ./autoconf $(O) "$(MAKE)" autoconf.h "$(SHELL)" "$(RM)" \
  354. X$(USRINCLUDE)
  355. X
  356. XMakefile: Manifest
  357. X
  358. XManifest: config.h
  359. X    @touch Manifest
  360. X    @-if fgrep -n -e '`' config.h $(DEVNULL) | fgrep -v -e EOFName ; then \
  361. X     echo;echo '    ^^^^^^^^^^^^^^^^^^^^ WARNING ^^^^^^^^^^^^^^^^^^^^^';\
  362. X          echo '    * Having backquotes in there could be unhealthy! *';\
  363. X     echo;fi;exit 0
  364. X
  365. X$(OBJ): $(DEP)
  366. X
  367. Xretint.$(O): $(DEP)
  368. X
  369. Xprocmail.$(O): $(DEP) patchlevel.h
  370. X
  371. Xexopen.$(O): config.h includes.h exopen.h strpbrk.h
  372. X
  373. Xformail.$(O): config.h includes.h shell.h strpbrk.h
  374. X
  375. Xlockfile.$(O): config.h includes.h exopen.h strpbrk.h
  376. X
  377. Xcommon.$(O): includes.h shell.h
  378. X
  379. Xrecommend.$(O): config.h includes.h strpbrk.h
  380. X    @$(CC) -c $(CFLAGS) recommend.c
  381. X
  382. Xstrpbrk.$(O): strpbrk.h includes.h
  383. X
  384. Xprocmail.h: includes.h exopen.h strpbrk.h
  385. X    touch procmail.h
  386. X
  387. Xincludes.h: autoconf.h
  388. X    touch includes.h
  389. X
  390. X.c.$(O):
  391. X    $(CC) -c $(CFLAGS) $*.c
  392. X
  393. Xman/man.sed: man/manconf.c config.h procmail.h
  394. X    $(CC) $(CFLAGS) -o man/manconf man/manconf.c ${LDFLAGS}
  395. X    man/manconf >man/man.sed
  396. X    rm -f man/manconf
  397. X
  398. Xman/procmail.1: man/man.sed man/procmail.man man/mansed
  399. X    $(SHELL) man/mansed man/procmail.man man/procmail.1 $(SHELL)
  400. X
  401. Xman/procmailrc.5: man/man.sed man/procmailrc.man man/mansed
  402. X    $(SHELL) man/mansed man/procmailrc.man man/procmailrc.5 $(SHELL)
  403. X
  404. Xman/procmailex.5: man/man.sed man/procmailex.man man/mansed
  405. X    $(SHELL) man/mansed man/procmailex.man man/procmailex.5 $(SHELL)
  406. X
  407. Xman/formail.1: man/man.sed man/formail.man man/mansed
  408. X    $(SHELL) man/mansed man/formail.man man/formail.1 $(SHELL)
  409. X
  410. Xman/lockfile.1: man/man.sed man/lockfile.man man/mansed
  411. X    $(SHELL) man/mansed man/lockfile.man man/lockfile.1 $(SHELL)
  412. X
  413. Xrecommend: recommend.$(O) strpbrk.$(O)
  414. X    @echo ----------------------------------------------------------------\
  415. X---------------
  416. X    @echo If you are a system administrator you should consider \
  417. Xintegrating procmail
  418. X    @echo into the mail-delivery system -- for advanced functionality \
  419. XAND SECURITY --.
  420. X    @echo For more information about this topic you should look in the \
  421. Xexamples/advanced
  422. X    @echo file.
  423. X    @echo
  424. X    @echo "Also, HIGLY RECOMMENDED (type 'make suid' to execute it):"
  425. X    @echo
  426. X    @$(CC) $(CFLAGS) -o _autotst recommend.$(O) strpbrk.$(O) ${LDFLAGS}
  427. X    @./_autotst $(BINDIR)/procmail $(BINDIR)/lockfile >suid.sh
  428. X    @./_autotst $(BINDIR)/procmail $(BINDIR)/lockfile
  429. X    @$(RM) _autotst
  430. X    @echo ----------------------------------------------------------------\
  431. X---------------
  432. X
  433. Xsuid.sh: recommend
  434. X
  435. Xsuid:    suid.sh install.bin
  436. X    @cat suid.sh
  437. X    @$(SHELL) ./suid.sh
  438. X    @cd $(BINDIR); echo Installed in $(BINDIR); ls -l $(BINS)
  439. X
  440. Xinstall.man: $(MANS)
  441. X    @-mkdir $(MANDIR) 2>$(DEVNULL); exit 0
  442. X    @-mkdir $(MAN1DIR) 2>$(DEVNULL); exit 0
  443. X    @-mkdir $(MAN5DIR) 2>$(DEVNULL); exit 0
  444. X    @chmod 0644 man/*.1 man/*.5
  445. X    $(INSTALL) man/procmail.1 $(MAN1DIR)/procmail.$(MAN1SUFFIX)
  446. X    $(INSTALL) man/procmailrc.5 $(MAN5DIR)/procmailrc.$(MAN5SUFFIX)
  447. X    $(INSTALL) man/procmailex.5 $(MAN5DIR)/procmailex.$(MAN5SUFFIX)
  448. X    $(INSTALL) man/lockfile.1 $(MAN1DIR)/lockfile.$(MAN1SUFFIX)
  449. X    $(INSTALL) man/formail.1 $(MAN1DIR)/formail.$(MAN1SUFFIX)
  450. X
  451. Xinstall.bin: everything
  452. X    @-mkdir $(BINDIR) 2>$(DEVNULL); exit 0
  453. X    @chmod 0755 $(BINS)
  454. X    $(INSTALL) $(BINS) $(BINDIR)
  455. X
  456. Xinstall: everything install.man install.bin
  457. X    @echo
  458. X    @cd $(BINDIR); echo Installed in $(BINDIR); ls -l $(BINS)
  459. X    @cd $(MAN1DIR); echo Installed in $(MAN1DIR); ls -l $(MANS1)
  460. X    @cd $(MAN5DIR); echo Installed in $(MAN5DIR); ls -l $(MANS5)
  461. X    @$(MAKE) recommend
  462. X
  463. Xdeinstall:
  464. X    cd $(BINDIR); $(RM) $(BINS); ls -l $(BINS)
  465. X    cd $(MAN1DIR); $(RM) $(MANS1); ls -l $(MANS1)
  466. X    cd $(MAN5DIR); $(RM) $(MANS5); ls -l $(MANS5)
  467. X
  468. Xclean:
  469. X    $(RM) $(OBJ) common.$(O) lockfile.$(O) exopen.$(O) retint.$(O) \
  470. X     strpbrk.$(O) formail.$(O) procmail.$(O) $(BINS) autoconf.h _autotst* \
  471. X     lookfor grepfor $(MANS) man/man.sed recommend.$(O) suid.sh
  472. END_OF_FILE
  473. if test 6248 -ne `wc -c <'procmail/Makefile'`; then
  474.     echo shar: \"'procmail/Makefile'\" unpacked with wrong size!
  475. fi
  476. # end of 'procmail/Makefile'
  477. fi
  478. if test -f 'procmail/includes.h' -a "${1}" != "-c" ; then 
  479.   echo shar: Will not clobber existing file \"'procmail/includes.h'\"
  480. else
  481. echo shar: Extracting \"'procmail/includes.h'\" \(4856 characters\)
  482. sed "s/^X//" >'procmail/includes.h' <<'END_OF_FILE'
  483. X/*$Id: includes.h,v 2.18 1992/04/23 16:26:26 berg Rel $*/
  484. X
  485. X#include "autoconf.h"
  486. X    /* not all the "library identifiers" specified here need to be
  487. X       available for all programs in this package; some have substitutes
  488. X       as well (see autoconf); this is just an informal list */
  489. X
  490. X#include <sys/types.h>        /* pid_t mode_t uid_t gid_t */
  491. X#ifndef UNISTD_H_MISSING
  492. X#include <unistd.h>        /* open() read() write() close() dup() pipe()
  493. X                   fork() getuid() getpid() execve()
  494. X                   execvp() sleep() */
  495. X#endif
  496. X#include <stdio.h>        /* setbuf() fclose() stdin stdout stderr
  497. X                   fopen() fread() fwrite() fgetc() getc()
  498. X                   putc() fputs() FILE EOF */
  499. X#ifndef STDDEF_H_MISSING
  500. X#include <stddef.h>        /* ptrdiff_t size_t sigatomic_t */
  501. X#endif
  502. X#ifndef STDLIB_H_MISSING
  503. X#include <stdlib.h>        /* getenv() malloc() realloc() free()
  504. X                   strtol() */
  505. X#endif
  506. X#include <time.h>        /* time() ctime() time_t */
  507. X#include <fcntl.h>        /* O_RDONLY O_WRONLY O_APPEND O_CREAT O_EXCL */
  508. X#include <pwd.h>        /* getpwuid() getpwnam() struct passwd */
  509. X#include <grp.h>        /* getgrgid() struct group */
  510. X#ifndef SYS_WAIT_H_MISSING
  511. X#include <sys/wait.h>        /* wait() WIFEXITED() WIFSTOPPED()
  512. X                   WEXITSTATUS() */
  513. X#endif
  514. X#ifndef SYS_UTSNAME_H_MISSING
  515. X#include <sys/utsname.h>    /* uname() utsname */
  516. X#endif
  517. X#include <sys/stat.h>        /* stat() S_ISDIR() struct stat */
  518. X#include <signal.h>        /* signal() kill() alarm() SIG_IGN SIGHUP
  519. X                   SIGINT SIGQUIT SIGALRM SIGTERM */
  520. X#ifndef STRING_H_MISSING
  521. X#include <string.h>        /* strcpy() strncpy() strcat() strlen()
  522. X                   strspn() strcspn() strchr() strcmp()
  523. X                   strncmp() strpbrk() memmove() */
  524. X#endif
  525. X#include <errno.h>        /* EINTR EEXIST EMFILE ENFILE */
  526. X#ifndef SYSEXITS_H_MISSING
  527. X#include <sysexits.h>        /* EX_OK EX_UNAVAILABLE EX_OSERR EX_OSFILE
  528. X                   EX_CANTCREAT EX_IOERR EX_TEMPFAIL */
  529. X#endif
  530. X
  531. X#ifdef STDLIB_H_MISSING
  532. Xvoid*malloc(),*realloc();
  533. Xconst char*getenv();
  534. X#endif
  535. X#ifdef STRING_H_MISSING
  536. X#include <strings.h>
  537. X#ifndef strchr
  538. Xchar*strchr();
  539. X#endif
  540. Xchar*strpbrk();
  541. X#endif
  542. X#ifdef SYS_UTSNAME_H_MISSING
  543. X#define NOuname
  544. X#endif
  545. X#ifdef SYSEXITS_H_MISSING
  546. X        /* Standard exit codes, original list maintained
  547. X           by Eric Allman (eric@berkeley, ucbvax!eric)     */
  548. X#define EX_OK        0
  549. X#define EX_USAGE    64
  550. X#define EX_UNAVAILABLE    69
  551. X#define EX_OSERR    71
  552. X#define EX_OSFILE    72
  553. X#define EX_CANTCREAT    73
  554. X#define EX_IOERR    74
  555. X#define EX_TEMPFAIL    75
  556. X#endif
  557. X
  558. X#if O_SYNC
  559. X#else
  560. X#undef O_SYNC
  561. X#define O_SYNC        0
  562. X#endif
  563. X#ifndef O_RDONLY
  564. X#define O_RDONLY    0
  565. X#define O_WRONLY    1
  566. X#endif
  567. X#ifndef SEEK_SET
  568. X#define SEEK_SET    0
  569. X#define SEEK_CUR    1
  570. X#define SEEK_END    2
  571. X#endif
  572. X#ifndef tell
  573. X#define tell(fd)    lseek(fd,0L,SEEK_CUR)
  574. X#endif
  575. X
  576. X#ifndef EOF
  577. X#define EOF    (-1)
  578. X#endif
  579. X
  580. X#ifndef S_ISDIR
  581. X#define S_ISDIR(mode)    (((mode)&S_IFMT)==S_IFDIR)
  582. X#ifndef S_IFDIR
  583. X#define S_IFDIR 0040000
  584. X#endif
  585. X#endif
  586. X
  587. X#ifndef S_ISLNK
  588. X#ifndef S_IFLNK
  589. X#define lstat(path,stbuf)    stat(path,stbuf)
  590. X#define S_ISLNK(mode)    0
  591. X#else
  592. X#define S_ISLNK(mode)    (((mode)&S_IFMT)==S_IFLNK)
  593. X#endif
  594. X#endif
  595. X
  596. X#ifndef S_IFMT
  597. X#define S_IFMT    0170000
  598. X#endif
  599. X
  600. X#ifndef S_IRWXU
  601. X#define S_IRWXU 00700
  602. X#define S_IRWXG 00070
  603. X#define S_IRWXO 00007
  604. X#endif
  605. X#ifndef S_IWUSR
  606. X#ifdef S_IREAD
  607. X#define S_IRUSR     S_IREAD
  608. X#define S_IWUSR     S_IWRITE
  609. X#define S_IXUSR     S_IEXEC
  610. X#else
  611. X#define S_IRUSR     0400
  612. X#define S_IWUSR     0200
  613. X#define S_IXUSR     0100
  614. X#endif /* S_IREAD */
  615. X#define S_IRGRP     0040
  616. X#define S_IWGRP     0020
  617. X#define S_IXGRP     0010
  618. X#define S_IROTH     0004
  619. X#define S_IWOTH     0002
  620. X#define S_IXOTH     0001
  621. X#endif /* S_IWUSR */
  622. X#ifndef S_ISGID
  623. X#define S_ISUID 04000
  624. X#define S_ISGID 02000
  625. X#endif
  626. X
  627. X#ifdef WMACROS_NON_POSIX
  628. X#ifdef WIFEXITED
  629. X#undef WIFEXITED
  630. X#endif
  631. X#ifdef WIFSTOPPED
  632. X#undef WIFSTOPPED
  633. X#endif
  634. X#ifdef WEXITSTATUS
  635. X#undef WEXITSTATUS
  636. X#endif
  637. X#endif /* WMACROS_NON_POSIX */
  638. X
  639. X#ifndef WIFEXITED
  640. X#define WIFEXITED(waitval)    (!!((waitval)&255))
  641. X#endif
  642. X#ifndef WIFSTOPPED
  643. X#define WIFSTOPPED(waitval)    (((waitval)&255)==127)
  644. X#endif
  645. X#ifndef WEXITSTATUS
  646. X#define WEXITSTATUS(waitval)    ((waitval)>>8&255)
  647. X#endif
  648. X
  649. Xextern /*const*/char**environ;
  650. Xextern errno;
  651. X
  652. X#ifndef STDIN_FILENO
  653. X#define STDIN    0
  654. X#define STDOUT    1
  655. X#define STDERR    2
  656. X#else
  657. X#define STDIN    STDIN_FILENO
  658. X#define STDOUT    STDOUT_FILENO
  659. X#define STDERR    STDERR_FILENO
  660. X#endif
  661. X
  662. X#ifdef NOrename
  663. X#define rename(old,new) (-(link(old,new)||unlink(old)))
  664. X#endif
  665. X
  666. X#ifdef NOmemmove
  667. X#define memmove(to,from,count) smemmove(to,from,count)
  668. X#endif
  669. X
  670. X#ifndef NOuname
  671. X#ifndef const            /* SINIX V5.23 has the wrong prototype for uname */
  672. Xextern int uname();                     /* so we fix it :-) */
  673. X#define uname_(name)    ((int(*)(struct utsname*))uname)(name)
  674. X#else
  675. X#define uname_(name)    uname(name)                /* no fix needed */
  676. X#endif /* const */
  677. X#endif /* NOuname */
  678. X
  679. X#ifdef oBRAIN_DAMAGE
  680. X#undef offsetof
  681. X#endif
  682. X#ifndef offsetof
  683. X#define offsetof(s,m) ((char*)&(((s*)0)->m)-(char*)0)
  684. X#endif
  685. X
  686. X#define maxindex(x)    (sizeof(x)/sizeof((x)[0])-1)
  687. X#define STRLEN(x)    (sizeof(x)-1)
  688. X#define ioffsetof(s,m)    ((int)offsetof(s,m))
  689. X
  690. X#define mx(a,b)        ((a)>(b)?(a):(b))
  691. END_OF_FILE
  692. if test 4856 -ne `wc -c <'procmail/includes.h'`; then
  693.     echo shar: \"'procmail/includes.h'\" unpacked with wrong size!
  694. fi
  695. # end of 'procmail/includes.h'
  696. fi
  697. if test -f 'procmail/man/formail.man' -a "${1}" != "-c" ; then 
  698.   echo shar: Will not clobber existing file \"'procmail/man/formail.man'\"
  699. else
  700. echo shar: Extracting \"'procmail/man/formail.man'\" \(6218 characters\)
  701. sed "s/^X//" >'procmail/man/formail.man' <<'END_OF_FILE'
  702. X.de Id
  703. X.ds Rv \\$3
  704. X.ds Dt \\$4
  705. X..
  706. X.Id $Id: formail.man,v 2.17 1992/04/29 15:55:09 berg Rel $
  707. X.de Sh
  708. X.br
  709. X.ne 11
  710. X.SH "\\$1"
  711. X..
  712. X.de Ss
  713. X.br
  714. X.ne 10
  715. X.SS "\\$1"
  716. X..
  717. X.de Tp
  718. X.br
  719. X.ne 9
  720. X.TP \\$1
  721. X..
  722. X.de Rs
  723. X.na
  724. X.nf
  725. X.RS
  726. X..
  727. X.de Re
  728. X.RE
  729. X.fi
  730. X.ad
  731. X..
  732. X.TH FORMAIL 1 \*(Dt BuGless
  733. X.SH NAME
  734. X.na
  735. Xformail \- mail (re)formatter
  736. X.SH SYNOPSIS
  737. X.B formail
  738. X.RI [ "\fB\+FM_SKIP+\fPskip" ]
  739. X.RI [ "\fB\+FM_TOTAL+\fPtotal" ]
  740. X.RB [ \-+FM_BOGUS++FM_FORCE++FM_REPLY++FM_KEEPB++FM_TRUST++FM_NOWAIT++FM_EVERY++FM_DIGEST++FM_QUIET+ ]
  741. X.RB [ \-+FM_MINFIELDS+
  742. X.IR "min fields" ]
  743. X.if n .ti +0.5i
  744. X.RB [ \-+FM_EXTRACT+
  745. X.IR "header field" ]
  746. X.RB [ \-+FM_ADD_IFNOT+
  747. X.IR "header field" ]
  748. X.if n .ti +0.5i
  749. X.RB [ \-+FM_REN_INSERT+
  750. X.IR "header field" ]
  751. X.RB [ \-+FM_DEL_INSERT+
  752. X.IR "header field" ]
  753. X.if n .ti +0.5i
  754. X.RB [ \-+FM_SPLIT+
  755. X.I command
  756. X.I arg
  757. X\&.\|.\|.\|]
  758. X.ad
  759. X.Sh DESCRIPTION
  760. X.B formail
  761. Xis a filter that can be used to force mail into mailbox format, perform
  762. X`+FROM+' escaping, generate auto-replying headers, do simple
  763. Xheader munging/extracting or split up a
  764. Xmailbox/digest/articles file.  The mail/mailbox/article contents will be
  765. Xexpected on stdin.
  766. X.PP
  767. XIf formail is supposed to determine the sender of the mail, but is unable
  768. Xto find any, it will substitute `+UNKNOWN+'.
  769. X.PP
  770. XIf formail is started without any command line options, it will force any
  771. Xmail coming from stdin into mailbox format and will escape
  772. X.B all
  773. Xbogus `+FROM+' lines with a `+ESCAP+'.
  774. X.Sh OPTIONS
  775. X.Tp 0.5i
  776. X.B \-+FM_BOGUS+
  777. XDon't escape any bogus mailbox headers (i.e. lines starting with `+FROM+').
  778. X.Tp
  779. X.B \-+FM_FORCE+
  780. XForce formail to simply pass along any non-mailbox format (i.e. don't
  781. Xgenerate a `+FROM+' line as the first line).
  782. X.Tp
  783. X.B \-+FM_REPLY+
  784. XGenerate an auto-reply header.  This will normally throw away all the existing
  785. Xfields in the original message, fields you wish to preserve need to be named
  786. Xusing the
  787. X.B \-+FM_REN_INSERT+
  788. Xoption.
  789. X.Tp
  790. X.B \-+FM_KEEPB+
  791. XWhen generating the auto-reply header, keep the body as well.  If used
  792. Xtogether with the
  793. X.B \-+FM_BOGUS+
  794. Xoption then the body will not be escaped.
  795. X.Tp
  796. X.B \-+FM_TRUST+
  797. XTrust the sender to have used a valid return address in his header.  This
  798. Xoption will be most useful when generating auto-reply headers from news
  799. Xarticles.  If this option is not turned on, formail tries to digest the most
  800. Xprobable valid return address itself.
  801. X.Tp
  802. X.B \-+FM_SPLIT+
  803. XThe input will be split up into seperate mail messages, and piped into
  804. Xa program one by one (a new program is started for every part).
  805. X.B \-+FM_SPLIT+
  806. Xhas to be the last option specified, the first argument following it
  807. Xis expected to be the name of a program, any other arguments will be passed
  808. Xalong to it.
  809. X.Tp
  810. X.B \-+FM_NOWAIT+
  811. XTell formail not to wait for every program to finish before starting the next.
  812. X.Tp
  813. X.B \-+FM_EVERY+
  814. XDo not require empty lines preceding the header of a new message (i.e. the
  815. Xmessages could start on every line).
  816. X.Tp
  817. X.B \-+FM_DIGEST+
  818. XTell formail that the messages it is supposed to split need not be in strict
  819. Xmailbox format (i.e. allows you to split digests/articles or non-standard
  820. Xmailbox formats).
  821. X.Tp
  822. X.I "\fB\-+FM_MINFIELDS+\fP min fields"
  823. XAllows you to specify the number of consecutive fields formail needs to find
  824. Xbefore it decides it found the start of a new message, it defaults to
  825. X+DEFminfields+.
  826. X.Tp
  827. X.B \-+FM_QUIET+
  828. XTells formail to ignore any write errors on stdout.
  829. X.Tp
  830. X.I "\fB\-+FM_EXTRACT+\fP header field"
  831. XExtract this
  832. X.I header field
  833. Xfrom the header, display it as a single line.
  834. X.Tp
  835. X.I "\fB\-+FM_ADD_IFNOT+\fP header field"
  836. XAppend a custom
  837. X.I header field
  838. Xonto the header; but only if a similar field does not exist yet.
  839. X.Tp
  840. X.I "\fB\-+FM_REN_INSERT+\fP header field"
  841. XSame as
  842. X.BR \-+FM_ADD_IFNOT+ ,
  843. Xexcept that any existing similar fields are renamed by prepending
  844. Xan ``+OLD_PREFIX+'' prefix.  If
  845. X.I header field
  846. Xconsists only of a field-name, it will not be appended.
  847. X.Tp
  848. X.I "\fB\-+FM_DEL_INSERT+\fP header field"
  849. XSame as
  850. X.BR \-+FM_REN_INSERT+ ,
  851. Xexcept that any existing similar fields are simply removed.
  852. X.Tp
  853. X.I "\fB\+FM_SKIP+\fPskip"
  854. XSkip the first
  855. X.I skip
  856. Xmessages while splitting.
  857. X.Tp
  858. X.I "\fB\+FM_TOTAL+\fPtotal"
  859. XOutput at most
  860. X.I total
  861. Xmessages while splitting.
  862. X.Sh EXAMPLES
  863. XTo split up a digest one usually uses:
  864. X.Rs
  865. Xformail +FM_SKIP+1 -+FM_DIGEST++FM_SPLIT+ cat >>the_mailbox_of_your_choice
  866. X.Re
  867. Xor
  868. X.Rs
  869. Xformail +FM_SKIP+1 -+FM_DIGEST++FM_SPLIT+ procmail
  870. X.Re
  871. X.PP
  872. XTo supersede the Reply-To: field in a header you could use:
  873. X.Rs
  874. Xformail \-+FM_REN_INSERT+ "Reply-To: foo@bar"
  875. X.Re
  876. X.PP
  877. XTo convert a non-standard mailbox file into a standard mailbox file you can
  878. Xuse:
  879. X.Rs
  880. Xformail -+FM_DIGEST++FM_SPLIT+ cat <old_mailbox >>new_mailbox
  881. X.Re
  882. X.Sh MISCELLANEOUS
  883. XThe regular expression that is used to find `real' postmarks is:
  884. X.Rs
  885. X"\\n\\n+FROM+[\\t ]*[^\\t\\n ]+[\\t ]+[^\\n\\t ]"
  886. X.Re
  887. X.PP
  888. XIn order to make postprocessing of mail easier, formail concatenates any
  889. Xcontinued header fields.
  890. X.Sh "SEE ALSO"
  891. X.na
  892. X.BR mail (1),
  893. X.BR binmail (1),
  894. X.BR sendmail (8),
  895. X.BR procmail (1),
  896. X.BR sh (1)
  897. X.ad
  898. X.Sh DIAGNOSTICS
  899. X.Tp 2.3i
  900. XCan't fork
  901. XToo many processes on this machine.
  902. X.Tp
  903. XCouldn't write to stdout
  904. XThe program that formail was trying to pipe into didn't accept all the data
  905. Xformail sent to it; this diagnostic can be disabled by the
  906. X.B \-+FM_QUIET+
  907. Xoption.
  908. X.Tp
  909. XFailed to execute "x"
  910. XProgram not in path, or not executable.
  911. X.Tp
  912. XFile table full
  913. XToo many open files on this machine.
  914. X.Tp
  915. XInvalid field-name: "x"
  916. XThe specified field-name "x" does not contain a colon or contains control
  917. Xcharacters.
  918. X.Sh WARNINGS
  919. XYou can save yourself and others a lot of mischief if you try to avoid using
  920. Xthis autoreply feature on mails coming through mailinglists.  Depending
  921. Xon the format of the incoming mail (which in turn depends on both the
  922. Xoriginal sender's mail agent and the mailinglist setup) formail could
  923. Xdecide to generate an autoreply header that replies to the list (if
  924. Xthe original sender was careful enough though, formail will be able to pick
  925. Xhis/her address, instead of the list's).  Now if the list is not intelligent
  926. Xenough (most aren't) this autoreply will be widely distributed.
  927. X.Sh BUGS
  928. XNone.  It's perfect :-).
  929. X.Sh AUTHOR
  930. XStephen R. van den Berg at RWTH-Aachen, Germany
  931. X.Rs
  932. Xberg@pool.informatik.rwth-aachen.de
  933. Xberg@physik.tu-muenchen.de
  934. X.Re
  935. END_OF_FILE
  936. if test 6218 -ne `wc -c <'procmail/man/formail.man'`; then
  937.     echo shar: \"'procmail/man/formail.man'\" unpacked with wrong size!
  938. fi
  939. # end of 'procmail/man/formail.man'
  940. fi
  941. if test -f 'procmail/man/lockfile.man' -a "${1}" != "-c" ; then 
  942.   echo shar: Will not clobber existing file \"'procmail/man/lockfile.man'\"
  943. else
  944. echo shar: Extracting \"'procmail/man/lockfile.man'\" \(3233 characters\)
  945. sed "s/^X//" >'procmail/man/lockfile.man' <<'END_OF_FILE'
  946. X.de Id
  947. X.ds Rv \\$3
  948. X.ds Dt \\$4
  949. X..
  950. X.Id $Id: lockfile.man,v 2.6 1992/04/29 15:55:09 berg Rel $
  951. X.de Sh
  952. X.br
  953. X.ne 11
  954. X.SH "\\$1"
  955. X..
  956. X.de Ss
  957. X.br
  958. X.ne 10
  959. X.SS "\\$1"
  960. X..
  961. X.de Tp
  962. X.br
  963. X.ne 9
  964. X.TP \\$1
  965. X..
  966. X.de Rs
  967. X.na
  968. X.nf
  969. X.RS
  970. X..
  971. X.de Re
  972. X.RE
  973. X.fi
  974. X.ad
  975. X..
  976. X.TH LOCKFILE 1 \*(Dt BuGless
  977. X.SH NAME
  978. X.na
  979. Xlockfile \- conditional semaphore-file creator
  980. X.SH SYNOPSIS
  981. X.B lockfile
  982. X.I "\fB\-\fPsleeptime"
  983. X|
  984. X.I "\fB\-r\fPretries"
  985. X|
  986. X.B "\-!"
  987. X|
  988. X.if n .ti +0.5i
  989. X.I "\fB\-l\fPlocktimeout"
  990. X|
  991. X.I "\fB\-s\fPsuspend"
  992. X|
  993. X.B "\-ml"
  994. X|
  995. X.B "\-mu"
  996. X|
  997. X.I filename
  998. X\&.\|.\|.
  999. X.ad
  1000. X.Sh DESCRIPTION
  1001. X.B lockfile
  1002. Xcan be used to create one or more
  1003. X.I semaphore
  1004. X.IR files .
  1005. XIf lockfile can't create all the specified files (in the specified order),
  1006. Xit waits
  1007. X.I sleeptime
  1008. X(defaults to 8) seconds and retries the last file that didn't succeed.
  1009. XYou can specify the number of
  1010. X.I retries
  1011. Xto do until failure is returned.
  1012. XIf the number of
  1013. X.I retries
  1014. Xis 0 (default) lockfile will retry forever.
  1015. X.PP
  1016. XIf the number of
  1017. X.I retries
  1018. Xexpires before all files have been created, lockfile returns failure and
  1019. Xremoves all the files it created up till that point.
  1020. X.PP
  1021. XThe return value of lockfile can be easily inverted by specifying
  1022. X.B \-!
  1023. Xas an argument (comes in handy in shell scripts).
  1024. X.PP
  1025. XAll flags can be specified anywhere on the command line, they will be
  1026. Xprocessed when encountered.  The command line is simply parsed from
  1027. Xleft to right.
  1028. X.PP
  1029. XAll files created by lockfile will have access permission 0, and therefore
  1030. Xwill have to be removed with
  1031. X.B rm
  1032. X.BR \-f .
  1033. X.PP
  1034. XIf you specify a
  1035. X.I locktimeout
  1036. Xthen a lockfile will be removed by force after locktimeout seconds have
  1037. Xpassed since the lockfile was last modified/created.  Lockfile is clock skew
  1038. Ximmune.  After a lockfile has been removed by force, a suspension of
  1039. X.I suspend
  1040. Xseconds (defaults to 16) is taken into account, in order to prevent the
  1041. Xinadvertent immediate removal of any newly created lockfile by another program
  1042. X(compare
  1043. X.BR SUSPEND
  1044. Xin
  1045. X.BR procmail (1)).
  1046. X.Ss "Mailbox locks"
  1047. XIf the permissions on the system mail spool directory allow it, or if lockfile
  1048. Xis suitably setuid or setgid, it will be able to lock and unlock your system
  1049. Xmailbox by using the options
  1050. X.B "\-ml"
  1051. Xand
  1052. X.B "\-mu"
  1053. Xrespectively.
  1054. X.Sh FILES
  1055. X.Tp 2.3i
  1056. X.B  /etc/passwd
  1057. Xto get the invoker's loginname
  1058. X.B +SYSTEM_MBOX++DEFlockext+
  1059. Xlockfile for the system mailbox
  1060. X.Sh "SEE ALSO"
  1061. X.na
  1062. X.BR rm (1),
  1063. X.BR mail (1),
  1064. X.BR binmail (1),
  1065. X.BR sendmail (8),
  1066. X.BR procmail (1)
  1067. X.ad
  1068. X.Sh DIAGNOSTICS
  1069. X.Tp 2.3i
  1070. XForcing lock on "x"
  1071. XSpecified lockfile is going to be removed by force because of a timeout
  1072. X(compare
  1073. X.BR LOCKTIMEOUT
  1074. Xin
  1075. X.BR procmail (1)).
  1076. X.Sh BUGS
  1077. Xlockfile is only a simple program and can't process concatenated options.
  1078. X.Sh NOTES
  1079. XMultiple
  1080. X.B \-!
  1081. Xflags will toggle the return status.
  1082. X.PP
  1083. XSince flags can occur anywhere on the command line, any filename starting
  1084. Xwith a '-' has to be preceded by './'.
  1085. X.PP
  1086. XThe number of
  1087. X.I retries
  1088. Xis global.  That is, it is not reset when a new file is being created.
  1089. XIt can, however, be reset by specifying
  1090. X.RI \-r newretries
  1091. Xafter every file on the command line.
  1092. X.PP
  1093. Xlockfile performs the locking in an NFS-secure way.
  1094. X.Sh AUTHOR
  1095. XStephen R. van den Berg at RWTH-Aachen, Germany
  1096. X.Rs
  1097. Xberg@pool.informatik.rwth-aachen.de
  1098. X.br
  1099. Xberg@physik.tu-muenchen.de
  1100. X.Re
  1101. END_OF_FILE
  1102. if test 3233 -ne `wc -c <'procmail/man/lockfile.man'`; then
  1103.     echo shar: \"'procmail/man/lockfile.man'\" unpacked with wrong size!
  1104. fi
  1105. # end of 'procmail/man/lockfile.man'
  1106. fi
  1107. if test -f 'procmail/man/manconf.c' -a "${1}" != "-c" ; then 
  1108.   echo shar: Will not clobber existing file \"'procmail/man/manconf.c'\"
  1109. else
  1110. echo shar: Extracting \"'procmail/man/manconf.c'\" \(4671 characters\)
  1111. sed "s/^X//" >'procmail/man/manconf.c' <<'END_OF_FILE'
  1112. X/* A sed script generator (for transmogrifying the man pages automagically) */
  1113. X
  1114. X/*$Id: manconf.c,v 2.16 1992/04/29 15:55:09 berg Rel $*/
  1115. X
  1116. X#include "../config.h"
  1117. X#include "../procmail.h"
  1118. X
  1119. X#define pn(name,val)    pnr(name,(long)(val))
  1120. X
  1121. Xconst char devnull[]=DevNull;
  1122. Xconst char*const keepenv[]=KEEPENV,*const prestenv[]=PRESTENV,
  1123. X *const trusted_ids[]=TRUSTED_IDS;
  1124. X
  1125. Xmain()
  1126. X{
  1127. X#ifndef MAILBOX_SEPARATOR
  1128. X  ps("DOT_FORWARD",".forward");
  1129. X  ps("FW_content","\"|IFS=' ';exec /usr/local/bin/procmail #YOUR_LOGIN_NAME\"");
  1130. X#else
  1131. X  ps("DOT_FORWARD",".maildelivery");
  1132. X  ps("FW_content",
  1133. X   "* - | ? \"IFS=' ';exec /usr/local/bin/procmail #YOUR_LOGIN_NAME\"");
  1134. X#endif
  1135. X#ifdef NO_USER_TO_LOWERCASE_HACK
  1136. X  ps("UPPERCASE_USERNAMES","\1.PP\1If the standard\1.BR getpwnam() (3)\1\
  1137. Xis case sensitive, and some users have login names with uppercase letters in\
  1138. X them, procmail will be unable to deliver mail to them, unless started with\
  1139. X their uid.");
  1140. X#else
  1141. X  ps("UPPERCASE_USERNAMES","");
  1142. X#endif
  1143. X  plist("PRESTENV","\1.PP\1Other preset environment variables are "
  1144. X   ,prestenv,".\1",""," and ");
  1145. X  plist("KEEPENV",", except for the values of ",keepenv,"",""," and ");
  1146. X  plist("TRUSTED_IDS",", and procmail is invoked with one of the following\
  1147. X user or group ids: ",trusted_ids,",",""," or ");
  1148. X  ps("SYSTEM_MBOX",SYSTEM_MBOX);
  1149. X#ifdef console
  1150. X  ps("console",console);
  1151. X#else
  1152. X  ps("console",vconsole);
  1153. X#endif
  1154. X  pname("INIT_UMASK");printf("0%lo/g\n",INIT_UMASK);
  1155. X  pn("DEFlinebuf",DEFlinebuf);
  1156. X  ps("BOGUSprefix",BOGUSprefix);
  1157. X  ps("PROCMAILRC",PROCMAILRC);
  1158. X  pn("HOSTNAMElen",HOSTNAMElen);
  1159. X  pn("DEFsuspend",DEFsuspend);
  1160. X  pn("DEFlocksleep",DEFlocksleep);
  1161. X  ps("TOkey",TOkey);
  1162. X  ps("TOsubstitute",TOsubstitute);
  1163. X  ps("DEFshellmetas",DEFshellmetas);
  1164. X  ps("DEFmaildir",DEFmaildir);
  1165. X  ps("DEFdefault",DEFdefault);
  1166. X  ps("DEFdefaultlock",strchr(DEFdefaultlock,'=')+1);
  1167. X  ps("DEFmsgprefix",DEFmsgprefix);
  1168. X  ps("DEFsendmail",DEFsendmail);
  1169. X  ps("DEFlockext",DEFlockext);
  1170. X  ps("DEFshellflags",DEFshellflags);
  1171. X  pn("DEFlocktimeout",DEFlocktimeout);
  1172. X  pn("DEFtimeout",DEFtimeout);
  1173. X  ps("Tmp",Tmp);
  1174. X  pc("DEBUGPREFIX",DEBUGPREFIX);
  1175. X  pc("VERSIONOPT",VERSIONOPT);
  1176. X  pc("PRESERVOPT",PRESERVOPT);
  1177. X  pc("TEMPFAILOPT",TEMPFAILOPT);
  1178. X  pc("FROMWHOPT",FROMWHOPT);
  1179. X  pc("ALTFROMWHOPT",ALTFROMWHOPT);
  1180. X  pc("DELIVEROPT",DELIVEROPT);
  1181. X  pn("MINlinebuf",MINlinebuf);
  1182. X  ps("FROM",FROM);
  1183. X  pc("HEAD_GREP",RECFLAGS[HEAD_GREP]);
  1184. X  pc("BODY_GREP",RECFLAGS[BODY_GREP]);
  1185. X  pc("DISTINGUISH_CASE",RECFLAGS[DISTINGUISH_CASE]);
  1186. X  pc("ALSO_NEXT_RECIPE",RECFLAGS[ALSO_NEXT_RECIPE]);
  1187. X  pc("ALSO_N_IF_SUCC",RECFLAGS[ALSO_N_IF_SUCC]);
  1188. X  pc("PASS_HEAD",RECFLAGS[PASS_HEAD]);
  1189. X  pc("PASS_BODY",RECFLAGS[PASS_BODY]);
  1190. X  pc("FILTER",RECFLAGS[FILTER]);
  1191. X  pc("CONTINUE",RECFLAGS[CONTINUE]);
  1192. X  pc("WAIT_EXIT",RECFLAGS[WAIT_EXIT]);
  1193. X  pc("WAIT_EXIT_QUIET",RECFLAGS[WAIT_EXIT_QUIET]);
  1194. X  pc("IGNORE_WRITERR",RECFLAGS[IGNORE_WRITERR]);
  1195. X  ps("FROM_EXPR",FROM_EXPR);
  1196. X  pc("UNIQ_PREFIX",UNIQ_PREFIX);
  1197. X  pc("ESCAP",ESCAP);
  1198. X  ps("UNKNOWN",UNKNOWN);
  1199. X  ps("OLD_PREFIX",OLD_PREFIX);
  1200. X  pc("FM_SKIP",FM_SKIP);
  1201. X  pc("FM_TOTAL",FM_TOTAL);
  1202. X  pc("FM_BOGUS",FM_BOGUS);
  1203. X  pc("FM_FORCE",FM_FORCE);
  1204. X  pc("FM_REPLY",FM_REPLY);
  1205. X  pc("FM_KEEPB",FM_KEEPB);
  1206. X  pc("FM_TRUST",FM_TRUST);
  1207. X  pc("FM_SPLIT",FM_SPLIT);
  1208. X  pc("FM_NOWAIT",FM_NOWAIT);
  1209. X  pc("FM_EVERY",FM_EVERY);
  1210. X  pc("FM_MINFIELDS",FM_MINFIELDS);
  1211. X  pn("DEFminfields",DEFminfields);
  1212. X  pc("FM_DIGEST",FM_DIGEST);
  1213. X  pc("FM_QUIET",FM_QUIET);
  1214. X  pc("FM_EXTRACT",FM_EXTRACT);
  1215. X  pc("FM_ADD_IFNOT",FM_ADD_IFNOT);
  1216. X  pc("FM_REN_INSERT",FM_REN_INSERT);
  1217. X  pc("FM_DEL_INSERT",FM_DEL_INSERT);
  1218. X  return EX_OK;
  1219. X}
  1220. X
  1221. Xpname(name)const char*const name;
  1222. X{ putchar('s');putchar('/');putchar('\\');putchar('+');putsesc(name);
  1223. X  putchar('\\');putchar('+');putchar('/');
  1224. X}
  1225. X
  1226. Xpnr(name,value)const char*const name;const long value;
  1227. X{ pname(name);printf("%ld/g\n",value);
  1228. X}
  1229. X
  1230. Xplist(name,preamble,list,postamble,ifno,andor)const char*const name,
  1231. X *const preamble,*const postamble,*const ifno,*const andor;
  1232. X const char*const*list;
  1233. X{ pname(name);
  1234. X  if(!*list)
  1235. X     putsesc(ifno);
  1236. X  else
  1237. X   { putsesc(preamble);goto jin;
  1238. X     do
  1239. X      { putsesc(list[1]?", ":andor);
  1240. Xjin:    putsesc(*list);
  1241. X      }
  1242. X     while(*++list);
  1243. X     putsesc(postamble);
  1244. X   }
  1245. X  puts("/g");
  1246. X}
  1247. X
  1248. Xps(name,value)const char*const name,*const value;
  1249. X{ pname(name);putsesc(value);puts("/g");
  1250. X}
  1251. X
  1252. Xpc(name,value)const char*const name;const int value;
  1253. X{ pname(name);putcesc(value);puts("/g");
  1254. X}
  1255. X
  1256. Xputcesc(i)
  1257. X{ switch(i)
  1258. X   { case '\1':i='\n';goto singesc;
  1259. X     case '\t':i='t';goto fin;
  1260. X     case '\n':i='n';
  1261. Xfin:    putchar('\\');
  1262. X     case '\\':putchar('\\');putchar('\\');
  1263. Xsingesc:
  1264. X     case '&':case '/':putchar('\\');
  1265. X   }
  1266. X  putchar(i);
  1267. X}
  1268. X
  1269. Xputsesc(a)const char*a;
  1270. X{ while(*a)
  1271. X     putcesc(*a++);
  1272. X}
  1273. END_OF_FILE
  1274. if test 4671 -ne `wc -c <'procmail/man/manconf.c'`; then
  1275.     echo shar: \"'procmail/man/manconf.c'\" unpacked with wrong size!
  1276. fi
  1277. # end of 'procmail/man/manconf.c'
  1278. fi
  1279. if test -f 'procmail/man/procmailex.man' -a "${1}" != "-c" ; then 
  1280.   echo shar: Will not clobber existing file \"'procmail/man/procmailex.man'\"
  1281. else
  1282. echo shar: Extracting \"'procmail/man/procmailex.man'\" \(5655 characters\)
  1283. sed "s/^X//" >'procmail/man/procmailex.man' <<'END_OF_FILE'
  1284. X.de Id
  1285. X.ds Rv \\$3
  1286. X.ds Dt \\$4
  1287. X..
  1288. X.Id $Id: procmailex.man,v 2.6 1992/04/29 15:55:09 berg Rel $
  1289. X.de Sh
  1290. X.br
  1291. X.ne 11
  1292. X.SH "\\$1"
  1293. X..
  1294. X.de Ss
  1295. X.br
  1296. X.ne 10
  1297. X.SS "\\$1"
  1298. X..
  1299. X.de Tp
  1300. X.br
  1301. X.ne 9
  1302. X.TP \\$1
  1303. X..
  1304. X.de Rs
  1305. X.na
  1306. X.nf
  1307. X.RS
  1308. X..
  1309. X.de Re
  1310. X.RE
  1311. X.fi
  1312. X.ad
  1313. X..
  1314. X.de Sx
  1315. X.PP
  1316. X.ne \\$1
  1317. X.Rs
  1318. X..
  1319. X.de Ex
  1320. X.Re
  1321. X.PP
  1322. X..
  1323. X.TH PROCMAILRC 5 \*(Dt BuGless
  1324. X.SH NAME
  1325. X.na
  1326. Xprocmailex \- procmail rcfile examples
  1327. X.SH SYNOPSIS
  1328. X.B $HOME/+PROCMAILRC+ examples
  1329. X.ad
  1330. X.Sh DESCRIPTION
  1331. XFor a description of the rcfile format see
  1332. X.BR procmailrc (5).
  1333. X.PP
  1334. XThis man page shows several example recipes.  For examples of complete rcfiles
  1335. Xyou can check the NOTES section in
  1336. X.BR procmail (1),
  1337. Xor look at the example rcfiles part of the procmail source distribution
  1338. X(procmail/examples/?procmailrc).
  1339. X.Sh EXAMPLES
  1340. XSort out all mail coming from the scuba-dive mailling list into the mailfolder
  1341. Xscubafile (uses the locallockfile scubafile.lock).
  1342. X.Sx 3
  1343. X::
  1344. X^TOscuba
  1345. Xscubafile
  1346. X.Ex
  1347. XForward all mail from peter about compilers to william (and keep a copy
  1348. Xof it here in petcompil).
  1349. X.Sx 7
  1350. X:2 +CONTINUE+
  1351. X^From.*peter
  1352. X^Subject:.*compilers
  1353. X! william@somewhere.edu
  1354. X
  1355. X   :+ALSO_NEXT_RECIPE+
  1356. X   petcompil
  1357. X.Ex
  1358. XAn equivalent, but slightly slower solution that accomplishes the same:
  1359. X.Sx 9
  1360. X:2 +CONTINUE+
  1361. X^From.*peter
  1362. X^Subject:.*compilers
  1363. X! william@somewhere.edu
  1364. X
  1365. X   :2
  1366. X   ^From.*peter
  1367. X   ^Subject:.*compilers
  1368. X   petcompil
  1369. X.Ex
  1370. XAdd the headers of all messages that didn't come from the postmaster
  1371. Xto your private header collection (for
  1372. Xstatistics or mail debugging); and use the lockfile `headc.lock'.  In order
  1373. Xto make sure the lockfile is not removed until the pipe has finished,
  1374. Xyou have to specify option `+WAIT_EXIT+'; otherwise the lockfile would be
  1375. Xremoved as soon as the pipe has accepted the mail.
  1376. X.Sx 3
  1377. X:+PASS_HEAD++WAIT_EXIT++CONTINUE+:
  1378. X!From +[^ ]*(postmaster|Mailer)
  1379. X| uncompress headc.Z; cat >>headc; compress headc
  1380. X.Ex
  1381. XForward all mails shorter than 1000 bytes to my home address (no lockfile
  1382. Xneeded on this recipe).
  1383. X.Sx 3
  1384. X:
  1385. X< 1000
  1386. X! myname@home
  1387. X.Ex
  1388. XSplit up incoming digests from the surfing mailing list into their individual
  1389. Xmessages, and store them into surfing, using surfing.lock as the locallockfile.
  1390. X.Sx 3
  1391. X::
  1392. X^Subject:.*surfing.*Digest
  1393. X| formail +FM_SKIP+1 \-+FM_DIGEST++FM_SPLIT+ cat >>surfing
  1394. X.Ex
  1395. XStore everything coming from the postmaster or mailer-daemon (like bounced
  1396. Xmail) into the file postm, using postm.lock as the locallockfile.
  1397. X.Sx 3
  1398. X::
  1399. X^From +[^ ]*(postmaster|Mailer)
  1400. Xpostm
  1401. X.Ex
  1402. XA simple autoreply recipe.  It makes sure that neither bouncing mail (from
  1403. Xpostmaster or the mailer-daemon), nor mail coming from yourself will be
  1404. Xautoreplied.  If this precaution would not be taken, disaster could result
  1405. X("ringing" mail).  In order for this recipe to autoreply to all the incoming
  1406. Xmail, you should of course insert it before all other recipes in your rcfile.
  1407. XHowever, it is advisable to put it
  1408. X.I after
  1409. Xany recipes that process the mails from subscribed mailinglists; it generally
  1410. Xis not a good idea to generate autoreplies to mailinglists.
  1411. X.Sx 4
  1412. X: 2 h c
  1413. X!^From +[^ ]*(postmaster|Mailer)
  1414. X!^From +YOUR_LOGIN_NAME
  1415. X| (formail \-+FM_REPY+ ; echo "Mail received.") | $SENDMAIL -t
  1416. X.Ex
  1417. XA more complicated autoreply recipe, that implements the functional equivalent
  1418. Xof the well known
  1419. X.BR vacation (1)
  1420. Xprogram.  This recipe is based on the same principles as the last one (prevent
  1421. X"ringing" mail).  In addition to that however, it maintains a vacation database
  1422. Xby extracting the name of the sender and appending it the file $ALREADYSENT, if
  1423. Xthe name is
  1424. X.B not
  1425. Xalready in there.  If the name was new, an autoreply will be sent (using the
  1426. X`+ALSO_N_IF_SUCC+' flag functionality).  To reliably extract the name of the
  1427. Xsender, I let formail generate an autoreply header (thereby making it figure
  1428. Xout the most appropriate sender address), and then telling it to extract the
  1429. Xvalue of the `To:' field.
  1430. X.Sx 14
  1431. XSHELL=/bin/sh    # for other shells, this might need adjustment
  1432. XALREADYSENT=$MAILDIR/vacation     # the vacation database
  1433. X
  1434. X: 2 hWc:                          # the lockfile is important
  1435. X!^From +[^ ]*(postmaster|Mailer)
  1436. X!^From +YOUR_LOGIN_NAME
  1437. X| FROM="`formail \-+FM_REPLY++FM_EXTRACT+ To:`" ;\\
  1438. X  if fgrep \-e "$FROM" <$ALREADYSENT ;\\
  1439. X  then exit 1 ;\\
  1440. X  else echo "$FROM" >>$ALREADYSENT ;\\
  1441. X  fi
  1442. X
  1443. X   :ahc
  1444. X   | (formail \-+FM_REPLY+ ; echo "Mail received.") | $SENDMAIL \-t
  1445. X.Ex
  1446. XStore all messages concerning TeX in separate, unique filenames, in a directory
  1447. Xnamed texmail (this directory has to exist); there is no need to use lockfiles
  1448. Xin this case, so we won't.
  1449. X.Sx 3
  1450. X:
  1451. X^(To|Apparently-To|Cc|Subject):.*tex[^t]
  1452. Xtexmail
  1453. X.Ex
  1454. XThe same as above, except now we store the mails in numbered files (MH mail
  1455. Xfolder), again the texmail directory has to exist already.
  1456. X.Sx 3
  1457. X:
  1458. X^(To|Apparently-To|Cc|Subject):.*tex[^t]
  1459. Xtexmail/.
  1460. X.Ex
  1461. XThe following one is rather exotic, but it only serves to demonstrate a
  1462. Xfeature.  Suppose you have a file in your HOME directory called ".urgent",
  1463. Xand the (one) person named in that file is the sender of an incoming mail,
  1464. Xyou'd like that mail to be stored in $MAILDIR/urgent instead of in any of the
  1465. Xnormal mailfolder it would have been sorted in.  Then this is what you could do
  1466. X(beware, the filelength of $HOME/.urgent should be well below $LINEBUF,
  1467. Xincrease LINEBUF if necessary):
  1468. X.Sx 5
  1469. XURGMATCH=`cat $HOME/.urgent`
  1470. X
  1471. X:B:
  1472. X$^From.*${URGENT}.*
  1473. Xurgent
  1474. X.Re
  1475. X.Sh "SEE ALSO"
  1476. X.na
  1477. X.BR procmail (1),
  1478. X.BR procmailrc (5),
  1479. X.BR sh (1),
  1480. X.BR csh (1),
  1481. X.BR mail (1),
  1482. X.BR binmail (1),
  1483. X.BR uucp (1C),
  1484. X.BR aliases (5),
  1485. X.BR sendmail (8),
  1486. X.BR egrep (1V),
  1487. X.BR lockfile (1),
  1488. X.BR formail (1)
  1489. X.ad
  1490. X.Sh AUTHOR
  1491. XStephen R. van den Berg at RWTH-Aachen, Germany
  1492. X.Rs
  1493. Xberg@pool.informatik.rwth-aachen.de
  1494. Xberg@physik.tu-muenchen.de
  1495. X.Re
  1496. END_OF_FILE
  1497. if test 5655 -ne `wc -c <'procmail/man/procmailex.man'`; then
  1498.     echo shar: \"'procmail/man/procmailex.man'\" unpacked with wrong size!
  1499. fi
  1500. # end of 'procmail/man/procmailex.man'
  1501. fi
  1502. if test -f 'procmail/nonint.c' -a "${1}" != "-c" ; then 
  1503.   echo shar: Will not clobber existing file \"'procmail/nonint.c'\"
  1504. else
  1505. echo shar: Extracting \"'procmail/nonint.c'\" \(7510 characters\)
  1506. sed "s/^X//" >'procmail/nonint.c' <<'END_OF_FILE'
  1507. X/************************************************************************
  1508. X *    Collection of routines that don't return int            *
  1509. X *                                    *
  1510. X *    Copyright (c) 1990-1992, S.R. van den Berg, The Netherlands    *
  1511. X *    The sources can be freely copied for non-commercial use.    *
  1512. X *    #include "README"                        *
  1513. X *                                    *
  1514. X ************************************************************************/
  1515. X#ifdef RCS
  1516. Xstatic char rcsid[]="$Id: nonint.c,v 2.19 1992/04/09 16:16:41 berg Rel $";
  1517. X#endif
  1518. X#include "config.h"
  1519. X#include "procmail.h"
  1520. X
  1521. X#define nomemretry    noresretry
  1522. X#define noforkretry    noresretry
  1523. X
  1524. Xvoid*tmalloc(len)const size_t len;    /* this malloc can survive a temporary */
  1525. X{ void*p;int i;                    /* "out of swap space" condition */
  1526. X  lcking|=lck_ALLOCLIB;
  1527. X  if(p=malloc(len))
  1528. X     goto ret;
  1529. X  lcking|=lck_MEMORY;
  1530. X  if(p=malloc(1))
  1531. X     free(p);               /* works on some systems with latent free */
  1532. X  for(i=nomemretry;i<0||i--;)
  1533. X   { suspend();             /* problems?  don't panic, wait a few secs till */
  1534. X     if(p=malloc(len))         /* some other process has paniced (and died 8-) */
  1535. Xret:  { lcking&=~(lck_MEMORY|lck_ALLOCLIB);return p;
  1536. X      }
  1537. X   }
  1538. X  nomemerr();
  1539. X}
  1540. X
  1541. Xvoid*trealloc(old,len)void*const old;const size_t len;
  1542. X{ void*p;int i;
  1543. X  lcking|=lck_ALLOCLIB;
  1544. X  if(p=realloc(old,len))
  1545. X     goto ret;                    /* for comment see tmalloc above */
  1546. X  lcking|=lck_MEMORY;
  1547. X  if(p=malloc(1))
  1548. X    free(p);
  1549. X  for(i=nomemretry;i<0||i--;)
  1550. X   { suspend();
  1551. X     if(p=realloc(old,len))
  1552. Xret:  { lcking&=~(lck_MEMORY|lck_ALLOCLIB);return p;
  1553. X      }
  1554. X   }
  1555. X  nomemerr();
  1556. X}
  1557. X
  1558. Xtfree(p)void*const p;
  1559. X{ lcking|=lck_ALLOCLIB;free(p);lcking&=~lck_ALLOCLIB;
  1560. X}
  1561. X               /* line buffered to keep concurrent entries untangled */
  1562. Xlog(newt)const char*const newt;
  1563. X{ int lnew,i;static lold;static char*old;char*p;
  1564. X#ifndef O_CREAT
  1565. X  lseek(STDERR,0L,SEEK_END);          /* locking should be done actually */
  1566. X#endif
  1567. X  if(!(lnew=strlen(newt))||nextexit)                 /* force flush? */
  1568. X     goto flush;
  1569. X  i=lold+lnew;
  1570. X  if(p=lold?realloc(old,i):malloc(i))             /* unshelled malloc */
  1571. X   { memmove((old=p)+lold,newt,(size_t)lnew);               /* append */
  1572. X     if(p[(lold=i)-1]=='\n')                         /* EOL? */
  1573. X    rwrite(STDERR,p,i),lold=0,free(p);        /* flush the line(s) */
  1574. X   }
  1575. X  else                           /* no memory, force flush */
  1576. Xflush:
  1577. X   { if(lold)
  1578. X      { rwrite(STDERR,old,lold);lold=0;
  1579. X    if(!nextexit)
  1580. X       free(old);            /* don't use free in signal handlers */
  1581. X      }
  1582. X     if(lnew)
  1583. X    rwrite(STDERR,newt,lnew);
  1584. X   }
  1585. X}
  1586. X
  1587. X#include "shell.h"
  1588. X
  1589. Xpid_t sfork()                /* this fork can survive a temporary */
  1590. X{ pid_t i;int r;               /* "process table full" condition */
  1591. X  log("");r=noforkretry;              /* flush log, just in case */
  1592. X  while((i=fork())==-1)
  1593. X   { lcking|=lck_FORK;
  1594. X     if(!(r<0||r--))
  1595. X    break;
  1596. X     suspend();
  1597. X   }
  1598. X  lcking&=~lck_FORK;return i;
  1599. X}
  1600. X
  1601. Xvoid srequeue()
  1602. X{ retval=EX_TEMPFAIL;sterminate();
  1603. X}
  1604. X
  1605. Xvoid slose()
  1606. X{ fakedelivery=2;sterminate();
  1607. X}
  1608. X
  1609. Xvoid sbounce()
  1610. X{ retval=EX_CANTCREAT;sterminate();
  1611. X}
  1612. X
  1613. Xextern char*lastexec,*backblock;        /* see retint.c for comment */
  1614. Xextern long backlen;
  1615. Xextern pid_t pidfilt;
  1616. Xextern pbackfd[2];
  1617. X
  1618. Xvoid stermchild()
  1619. X{ if(pidfilt>0)            /* don't kill what is not ours, we might be root */
  1620. X     kill(pidfilt,SIGTERM);
  1621. X  log("Rescue of unfiltered data ");
  1622. X  if(dump(PWRB,backblock,backlen))    /* pump back the data via the backpipe */
  1623. X     log("failed\n");
  1624. X  else
  1625. X     log("succeeded\n");
  1626. X  exit(EX_UNAVAILABLE);
  1627. X}
  1628. X
  1629. Xvoid ftimeout()
  1630. X{ alarm(0);alrmtime=0;
  1631. X  if(pidchild>0&&!kill(pidchild,SIGTERM))       /* careful, killing again */
  1632. X    log("Timeout, terminating"),logqnl(lastexec);
  1633. X  signal(SIGALRM,ftimeout);
  1634. X}
  1635. X
  1636. Xlong dump(s,source,len)const int s;const char*source;long len;
  1637. X{ int i= -1;
  1638. X  if(s>=0)
  1639. X   { fdlock(s);lastdump=len;smboxseparator(s); /* prepend optional separator */
  1640. X#ifndef O_CREAT
  1641. X     lseek(s,0L,SEEK_END);
  1642. X#endif
  1643. X#ifndef NO_NFS_ATIME_HACK
  1644. X     if(len&&tofile)               /* if it is a file, trick NFS into an */
  1645. X    --len,rwrite(s,source++,1),sleep(1);            /* a_time<m_time */
  1646. X#endif
  1647. X     while(i=rwrite(s,source,BLKSIZ<len?BLKSIZ:(int)len))
  1648. X      { if(i<0)
  1649. X     { i=0;goto writefin;
  1650. X     }
  1651. X    len-=i;source+=i;
  1652. X      }
  1653. X     if(!len&&(lastdump<2||!(source[-1]=='\n'&&source[-2]=='\n')))
  1654. X    lastdump++,rwrite(s,newline,1);           /* message always ends with a */
  1655. X     emboxseparator(s);         /* newline and an optional custom separator */
  1656. Xwritefin:
  1657. X     fdunlock();len-=i;i=rclose(s);
  1658. X   }                          /* return an error even if */
  1659. X  return ignwerr?(ignwerr=0):i&&!len?-1:len;       /* nothing was to be sent */
  1660. X}
  1661. X
  1662. Xlong pipin(line,source,len)char*const line;char*source;long len;
  1663. X{ int poutfd[2];
  1664. X  rpipe(poutfd);
  1665. X  if(!(pidchild=sfork()))                    /* spawn program */
  1666. X     rclose(PWRO),rclose(rc),getstdin(PRDO),callnewprog(line);
  1667. X  rclose(PRDO);
  1668. X  if(forkerr(pidchild,line))
  1669. X     return 1;
  1670. X  if(len=dump(PWRO,source,len))                /* dump mail in the pipe */
  1671. X     writeerr(line);               /* pipe was shut in our face, get mad */
  1672. X  if(pwait&&waitfor(pidchild)!=EX_OK)        /* optionally check the exitcode */
  1673. X   { if(!(pwait&2))                  /* do we put in on report? */
  1674. X    progerr(line);
  1675. X     len=1;
  1676. X   }
  1677. X  pidchild=0;
  1678. X  if(!sh)
  1679. X     concatenate(line);
  1680. X  lastfolder=cstr(lastfolder,line);return len;
  1681. X}
  1682. X
  1683. Xchar*readdyn(bf,filled)char*bf;long*const filled;
  1684. X{ int i;long oldsize;
  1685. X  oldsize= *filled;goto jumpin;
  1686. X  do
  1687. X   { *filled+=i;                /* change listed buffer size */
  1688. Xjumpin:
  1689. X#ifdef SMALLHEAP
  1690. X     if((size_t)*filled>=(size_t)(*filled+BLKSIZ))
  1691. X    lcking|=lck_MEMORY,nomemerr();
  1692. X#endif
  1693. X     bf=realloc(bf,*filled+BLKSIZ);    /* dynamically adjust the buffer size */
  1694. Xjumpback:;
  1695. X   }
  1696. X  while(0<(i=rread(STDIN,bf+*filled,BLKSIZ)));            /* read mail */
  1697. X  if(pidchild>0)
  1698. X   { pidchild=0;getstdin(PRDB);               /* filter ready, get backpipe */
  1699. X     if(1==rread(STDIN,buf,1))                  /* backup pipe closed? */
  1700. X      { bf=realloc(bf,(*filled=oldsize+1)+BLKSIZ);bf[oldsize]= *buf;
  1701. X     goto jumpback;                   /* filter goofed, rescue data */
  1702. X      }
  1703. X   }
  1704. X  pidchild=0;                    /* child must be gone by now */
  1705. X  if(!*filled)
  1706. X     return realloc(bf,1);             /* +1 for housekeeping purposes */
  1707. X  return realloc(bf,*filled+1);            /* minimise the buffer space */
  1708. X}
  1709. X
  1710. Xchar*fromprog(name,dest)char*const name;char*dest;
  1711. X{ int pinfd[2];long nls;
  1712. X  rpipe(pinfd);inittmout(name);
  1713. X  if(!(pidchild=sfork()))                    /* spawn program */
  1714. X   { rclose(STDIN);opena(devnull);rclose(PRDI);rclose(rc);rclose(STDOUT);
  1715. X     rdup(PWRI);rclose(PWRI);callnewprog(name);
  1716. X   }
  1717. X  rclose(PWRI);nls=0;
  1718. X  if(!forkerr(pidchild,name))
  1719. X   { while(0<rread(PRDI,dest,1))                /* read its lips */
  1720. X    if(*dest=='\n')                    /* careful with newlines */
  1721. X       nls++;            /* trailing newlines should be discarded */
  1722. X    else
  1723. X     { if(nls)
  1724. X          for(dest[nls]= *dest;*dest++='\n',--nls;);     /* fill them in */
  1725. X       dest++;
  1726. X     }
  1727. X     waitfor(pidchild);
  1728. X   }
  1729. X  pidchild=0;rclose(PRDI);*dest='\0';return dest;
  1730. X}
  1731. X
  1732. Xchar*cat(a,b)const char*const a,*const b;
  1733. X{ return strcat(strcpy(buf,a),b);
  1734. X}
  1735. X
  1736. Xchar*tstrdup(a)const char*const a;
  1737. X{ int i;
  1738. X  i=strlen(a)+1;return tmemmove(malloc(i),a,i);
  1739. X}
  1740. X
  1741. Xconst char*tgetenv(a)const char*const a;
  1742. X{ const char*b;
  1743. X  return(b=getenv(a))?b:"";
  1744. X}
  1745. X
  1746. Xchar*cstr(a,b)char*const a;const char *const b; /* dynamic buffer management */
  1747. X{ if(a)
  1748. X     free(a);
  1749. X  return tstrdup(b);
  1750. X}
  1751. X
  1752. Xlong renvint(i,env)const long i;const char*const env;
  1753. X{ const char*p;long t;
  1754. X  t=strtol(env,(char**)&p,10);return p==env?i:t;  /* parse like a decimal nr */
  1755. X}
  1756. X
  1757. Xchar*egrepin(expr,source,len,casesens)char*expr;const char*source;
  1758. X const long len;
  1759. X{ source=bregexec(expr=bregcomp(expr,!casesens),
  1760. X   source,len>0?(size_t)len:(size_t)0,!casesens);
  1761. X  free(expr);return(char*)source;
  1762. X}
  1763. END_OF_FILE
  1764. if test 7510 -ne `wc -c <'procmail/nonint.c'`; then
  1765.     echo shar: \"'procmail/nonint.c'\" unpacked with wrong size!
  1766. fi
  1767. # end of 'procmail/nonint.c'
  1768. fi
  1769. if test -f 'procmail/shell.h' -a "${1}" != "-c" ; then 
  1770.   echo shar: Will not clobber existing file \"'procmail/shell.h'\"
  1771. else
  1772. echo shar: Extracting \"'procmail/shell.h'\" \(214 characters\)
  1773. sed "s/^X//" >'procmail/shell.h' <<'END_OF_FILE'
  1774. X/*$Id: shell.h,v 2.1 1992/03/19 14:00:28 berg Rel $*/
  1775. X
  1776. X#define malloc(n)    tmalloc((size_t)(n))
  1777. X#define realloc(p,n)    trealloc(p,(size_t)(n))
  1778. X#define free(p)        tfree(p)
  1779. X#define tmemmove(t,f,n) memmove(t,f,(size_t)(n))
  1780. END_OF_FILE
  1781. if test 214 -ne `wc -c <'procmail/shell.h'`; then
  1782.     echo shar: \"'procmail/shell.h'\" unpacked with wrong size!
  1783. fi
  1784. # end of 'procmail/shell.h'
  1785. fi
  1786. echo shar: End of archive 2 \(of 5\).
  1787. cp /dev/null ark2isdone
  1788. MISSING=""
  1789. for I in 1 2 3 4 5 ; do
  1790.     if test ! -f ark${I}isdone ; then
  1791.     MISSING="${MISSING} ${I}"
  1792.     fi
  1793. done
  1794. if test "${MISSING}" = "" ; then
  1795.     echo You have unpacked all 5 archives.
  1796.     rm -f ark[1-9]isdone
  1797. else
  1798.     echo You still need to unpack the following archives:
  1799.     echo "        " ${MISSING}
  1800. fi
  1801. ##  End of shell archive.
  1802. exit 0
  1803. -- 
  1804. Sincerely,                                  berg@pool.informatik.rwth-aachen.de
  1805.            Stephen R. van den Berg (AKA BuGless).    berg@physik.tu-muenchen.de
  1806.  
  1807. "I have a *cunning* plan!"
  1808.  
  1809. exit 0 # Just in case...
  1810.