home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume35 / procmail / part04 < prev    next >
Encoding:
Text File  |  1993-02-04  |  44.9 KB  |  1,443 lines

  1. Newsgroups: comp.sources.misc
  2. From: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  3. Subject: v35i025:  procmail - mail processing package v2.80, Part04/11
  4. Message-ID: <1993Feb5.020341.16449@sparky.imd.sterling.com>
  5. X-Md4-Signature: cc8ad63894c34802989f370b53f58141
  6. Date: Fri, 5 Feb 1993 02:03:41 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 35, Issue 25
  11. Archive-name: procmail/part04
  12. Environment: sendmail, smail, MMDF, mailsurr, UNIX, POSIX
  13. Supersedes: procmail: Volume 31, Issue 40-44
  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 4 (of 11)."
  22. # Contents:  procmail280/FAQ procmail280/INSTALL
  23. #   procmail280/examples/mailstat procmail280/initmake
  24. #   procmail280/man/lockfile.man procmail280/src/formisc.c
  25. #   procmail280/src/locking.c
  26. # Wrapped by berg@hathi on Thu Feb  4 15:27:58 1993
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'procmail280/FAQ' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'procmail280/FAQ'\"
  30. else
  31. echo shar: Extracting \"'procmail280/FAQ'\" \(5786 characters\)
  32. sed "s/^X//" >'procmail280/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 mailinglist directory, start reading the INTRO file,
  40. X    it describes it in detail and should get you started.
  41. X
  42. X2. I installed procmail (i.e. typed 'make install'), but how am I supposed to
  43. X   use it?  When I type procmail on the command line it simply does nothing.
  44. X
  45. X    You're not supposed to start procmail from the command line.
  46. X    Be sure to have a .forward and a .procmailrc file in your home
  47. X    directory (see the examples subdirectory or the man page).
  48. X    MMDF users should note that they need a .maildelivery file *instead*
  49. X    of a .forward file (see the man page for more detailed information).
  50. X
  51. X    If however, procmail has been integrated in the maildelivery system
  52. X    (i.e. if your system administrator installed it that way, ask him/her),
  53. X    then you no longer need the .forward files in your home directory,
  54. X    having a .procmailrc file will suffice.
  55. X
  56. X    On some systems .forward files are not checked, in this case it might
  57. X    be worth trying to put a line looking like this:
  58. X        Forward to "|/usr/local/bin/procmail"
  59. X    or if that doesn't work, try:
  60. X        Pipe to /usr/local/bin/procmail
  61. X    as the only line in your mail spool file (e.g. /usr/mail/$USER), as
  62. X    well as doing a "chmod 06600 /usr/mail/$USER".    For more information
  63. X    on such systems, do a "man mail".
  64. X
  65. X    If all of this doesn't work, procmail can be called on a periodical
  66. X    basis, either via "cron", "at" or whenever you start reading mail (or
  67. X    log in).  The commands you would need in such a case would be
  68. X    something like:
  69. X        lockfile -ml
  70. X        formail -s procmail </usr/mail/$USER
  71. X        cp /dev/null /usr/mail/$USER
  72. X        lockfile -mu
  73. X
  74. X3. When I compile everything the compiler complains about invalid or illegal
  75. X   pointer combinations, but it produces the executables anyway.
  76. X   Should I be concerned?
  77. X
  78. X    Ignore these warnings, they simply indicate that either your compiler
  79. X    or your system include files are not ANSI/POSIX compliant.
  80. X    The compiler will produce correct code regardless of these warnings.
  81. X
  82. X4. The compiler seems to issue warnings about "loop not entered at top",
  83. X   is that a problem?
  84. X
  85. X    No, no problem at all, it just means I wrote the code :-)
  86. X    That's just about the only uncommon coding technique I use (don't
  87. X    think I don't try to avoid those jumps in loops, it's just that
  88. X    sometimes they are the best way to code it).  Use gcc if you want
  89. X    to avoid these warnings.
  90. X
  91. X5. The compiler complains about unmodifiable lvalues or assignments to const
  92. X   variables.  Now what?
  93. X
  94. X    Well, if the compiler produces the executables anyway everything
  95. X    probably is all right.    If it doesn't, you might try inserting a
  96. X    "#define const" in the autoconf.h file by hand.     However in any case,
  97. X    your compiler is broken; I would recommend submitting this as a
  98. X    compiler bug to your vendor.  In any case, if this should occur, I'd
  99. X    appreciate a mail from you (so I can try to fix the autoconf script
  100. X    to recognise your compiler).
  101. X
  102. X6. The compiler refuses to compile regexp.c, what is the problem?
  103. X
  104. X    Try compiling that module with optimisation turned off.
  105. X
  106. X7. When I send myself a testmail, the mail bounces with the message: cannot
  107. X   execute binary file.     What am I doing wrong?
  108. X
  109. X    It is very well possible that mail is processed on a different
  110. X    machine from that where you usually read your mail.  Therefore you
  111. X    have to make sure that procmail has the right binary format to
  112. X    execute on those machines on which mail could arrive.  In order to
  113. X    get this right you might need to do some .forward file tweaking,
  114. X    look at the examples/advanced file for some suggestions.
  115. X
  116. X8. Where do I look for examples about:
  117. X    One home directory, several machine architectures?
  118. X    Procmail as an integrated local mail delivery agent? (generic,
  119. X     sendmail, smail, SysV mail)
  120. X    Changing the mail spool directory to $HOME for all users
  121. X    Security considerations (when installing procmail suid root)
  122. X    Exorbitant rcfile formats?
  123. X    The `A' flag?
  124. X
  125. X    Well, this probably is your lucky day :-), all these topics are covered
  126. X    in the examples/advanced file.
  127. X
  128. X    Other examples (e.g. for autoreplies) are most likely to be found by
  129. X    typing:        man procmailex
  130. X
  131. X9. Why do I have to insert my login name after the '#' in the .forward or
  132. X   .maildelivery file?
  133. X
  134. X    Some mailers `optimise' maildelivery and take out duplicates from
  135. X    Cc:, Bcc: and alias lists before delivery.  If two or more persons on
  136. X    such a list would have identical .forward files, then the mailer will
  137. X    eliminate all but one.    Adding a `#' with your login name following
  138. X    it will make the .forward files unique, and will ensure that the mailer
  139. X    doesn't optimise away some addresses.
  140. X
  141. X10. How do I view the man pages?
  142. X
  143. X    If the man(1) program on your system understands the MANPATH
  144. X    environment variable, make sure that the installation directory listed
  145. X    in the Makefile for the manpages is included in your MANPATH.  If your
  146. X    man program does not support MANPATH, make sure that the man pages
  147. X    are installed in one of the standard man directories, like under
  148. X    /usr/man.  If you do not want to install the man pages before viewing
  149. X    them, you can view an individual man file by typing something like:
  150. X    nroff -man procmail.1 | more
  151. X
  152. X11. None of the above topics cover my problem.    Should I panic?
  153. X
  154. X    Let me ask you a question :-), have you examined the CAVEATS, WARNINGS,
  155. X    BUGS and NOTES sections of the manual pages *closely* ?
  156. X    If you have, well, then panic.    Or, alternatively, you could submit
  157. X    your question to the procmail mailinglist (see the man page for the
  158. X    exact addresses, or try "procmail -v", or look in the patchlevel.h
  159. X    file).
  160. END_OF_FILE
  161. if test 5786 -ne `wc -c <'procmail280/FAQ'`; then
  162.     echo shar: \"'procmail280/FAQ'\" unpacked with wrong size!
  163. fi
  164. # end of 'procmail280/FAQ'
  165. fi
  166. if test -f 'procmail280/INSTALL' -a "${1}" != "-c" ; then 
  167.   echo shar: Will not clobber existing file \"'procmail280/INSTALL'\"
  168. else
  169. echo shar: Extracting \"'procmail280/INSTALL'\" \(5849 characters\)
  170. sed "s/^X//" >'procmail280/INSTALL' <<'END_OF_FILE'
  171. XDiscusses:
  172. X        1. Getting the lot to compile
  173. X        2. DEBUGGING AID
  174. X        3. Setting up the environment
  175. X        4. Extra options if you are a system administrator
  176. X
  177. X                ---
  178. X
  179. X1. Getting the lot to compile
  180. X   --------------------------
  181. X
  182. XTo install procmail, lockfile and formail: edit Makefile & config.h accordingly
  183. Xand type 'make install'.
  184. XIntended configurable options in Makefile are:
  185. X    the install-destinations
  186. XIntended configurable options in config.h are:
  187. X    MMDF support, standard environment presettings, trusted userids.
  188. X
  189. X'make install' will:
  190. X      - implicitly do a 'make init', which will check your basic utilities for
  191. X    POSIX compliance, and generates correcting Makefiles accordingly
  192. X      - execute autoconf (a shell script that repeatedly calls the C compiler
  193. X    to determine if certain features/symbols are supported), which will
  194. X    create a file named autoconf.h
  195. X      - create three stripped binaries, a shell script and five man pages in
  196. X    the new/ subdirectory (all that is needed to install):
  197. X    procmail, lockfile, formail, mailstat, procmail.1, lockfile.1,
  198. X    formail.1, procmailrc.5, procmailex.5
  199. X      - copy these binaries and mailstat to $(BINDIR)
  200. X      - copy the man pages to $(MAN1DIR) and $(MAN5DIR)
  201. X
  202. X'make deinstall' will:
  203. X      - remove the just installed files in $(BINDIR)
  204. X      - remove the just installed files in $(MAN1DIR) and $(MAN5DIR)
  205. X
  206. X
  207. XMinimal requirements (for regular uses):
  208. X
  209. Xprocmail must be installed.
  210. X
  211. XOptional files (depending on your requirements):
  212. X
  213. Xlockfile only needs to be installed if you plan to read several mailboxes
  214. X    with one of the standard mailers that don't support lockfiles.
  215. Xformail only needs to be installed if mail sometimes arrives in nonstandard
  216. X    mailbox format (or if you want to generate auto replies, split up
  217. X    mailboxes/digests etc., see the man page of formail for more info).
  218. Xmailstat is an "example" shell script that can be used as is to produce
  219. X    summaries of the procmail generated logfiles; it is not needed by
  220. X    procmail itself in any way.
  221. X
  222. Xprocmail, lockfile, formail and mailstat are all *standalone* programs, i.e.
  223. Xthey do *not* use any compiled-in paths or files, they all can be used and
  224. Xinstalled independently without the need to install the others.
  225. X
  226. XIf things don't compile automagically, I suggest you take a look at:
  227. Xsrc/autoconf, autoconf.h, config.h, src/includes.h
  228. X
  229. XFor autoconf to work as intended, your compiler should either be fully ANSI
  230. Xcompliant, or you should NOT turn off all warnings; enabling all warnings
  231. Xshouldn't hurt.     In most cases the default options in the Makefile will do.
  232. X
  233. XThe sources are supposed to be fully ANSI, K&R and POSIX compliant.
  234. X
  235. XN.B. If you encounter any difficulty at all in installing procmail (e.g. if you
  236. X     had to change Makefile or config.h in unpredicted ways, or a simple
  237. X     "make install" doesn't work), I'd very much like to hear about it; who
  238. X     knows, next time you might be able to simply "make install" as well.
  239. X
  240. X                ---
  241. X
  242. X2. DEBUGGING AID
  243. X   -------------
  244. X
  245. XSince procmail is intended to run completely independent of any terminals, it
  246. Xdoesn't use the stderr output to display error messages.  It is recommended,
  247. Xespecially during debugging, to specify a LOGFILE (see man page) in the
  248. Xrcfile or on the command line.    Procmail will log all serious problems it
  249. Xencounters.  Of course, instead of a regular file, one could also specify a
  250. Xterminal as the default logfile.
  251. X
  252. XAlso, procmail can be persuaded to be a lot more verbose by inserting the
  253. Xfollowing assignment at the top of your rcfile:
  254. X
  255. X    VERBOSE=on
  256. X
  257. XTherefore a suggested command line for your first trial run (no rcfiles
  258. Xneeded) would be:
  259. X
  260. X    procmail VERBOSE=on LOGFILE=/dev/tty
  261. X
  262. X(now type in a pseudo mail-message)
  263. X
  264. XIf all else fails, you can try uncommenting the "#define console" entry
  265. Xin the config.h file.  This will provide you with the most verbose procmail
  266. Xyou can make.  It is of course a good idea to comment out this line again
  267. Xafter your troubles have been solved.
  268. X
  269. XIf you run procmail by hand and pipe in some sample mail, then make
  270. Xsure that if you kill procmail, you use "kill pid" and NOT "kill -9 pid".
  271. XShould procmail seem to hang, check if the $LOCKFILE is still present.
  272. XIf you kill procmail with "kill pid" it will clean up the $LOCKFILE
  273. Xitself.
  274. X
  275. X                ---
  276. X
  277. X3. Setting up the environment
  278. X   --------------------------
  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. XMMDF users should note that they need a .maildelivery file *instead* of the
  285. X.forward file (see the procmail(1) man page for more information).
  286. X
  287. X                ---
  288. X
  289. X4. Extra options if you are a system administrator
  290. X   -----------------------------------------------
  291. X
  292. XIf you are a system administrator you can decide to install procmail
  293. Xglobally (i.e. as a more robust drop-in replacement for the local-
  294. Xmaildelivery-capabilities of /bin/mail), this has the advantage that users do
  295. Xnot need to have a .forward file anymore that calls up procmail.  Simply
  296. Xhaving a .procmailrc file in the HOME directory will suffice.  Operation is
  297. Xtransparent in this case (i.e. if no .procmailrc file is present in the HOME
  298. Xdirectory, mail will be delivered as usual and procmail behaves like a more
  299. Xreliable /bin/mail substitute).
  300. X
  301. XFor direct examples on how to do this, look at the examples/advanced file.
  302. X
  303. X*******************************************************************************
  304. XHIGHLY RECOMMENDED: install "procmail" suid root (and/or sgid maildaemon)
  305. X            install "lockfile" sgid maildaemon
  306. X
  307. XTo obtain specific instructions on the best installation, type "make recommend"
  308. X*******************************************************************************
  309. X
  310. X                ---
  311. X
  312. XFor more info about the program, see the man page or the FAQ list.
  313. END_OF_FILE
  314. if test 5849 -ne `wc -c <'procmail280/INSTALL'`; then
  315.     echo shar: \"'procmail280/INSTALL'\" unpacked with wrong size!
  316. fi
  317. # end of 'procmail280/INSTALL'
  318. fi
  319. if test -f 'procmail280/examples/mailstat' -a "${1}" != "-c" ; then 
  320.   echo shar: Will not clobber existing file \"'procmail280/examples/mailstat'\"
  321. else
  322. echo shar: Extracting \"'procmail280/examples/mailstat'\" \(5197 characters\)
  323. sed "s/^X//" >'procmail280/examples/mailstat' <<'END_OF_FILE'
  324. X#! /bin/sh
  325. X: &&O= || exec /bin/sh $0 $argv:q # we're in a csh, feed myself to sh
  326. X#################################################################
  327. X#    mailstat    shows mail-arrival statistics        #
  328. X#                                #
  329. X#    Parses a procmail-generated $LOGFILE and displays    #
  330. X#    a summary about the messages delivered to all folders    #
  331. X#    (total size, average size, nr of messages).        #
  332. X#    Exit code 0 if mail arrived, 1 if no mail arrived.    #
  333. X#                                #
  334. X#    For help try, "mailstat -h"                #
  335. X#                                #
  336. X#    Customise to your heart's content, this file is only    #
  337. X#    provided as a guideline.                #
  338. X#                                #
  339. X#    Created by S.R. van den Berg, The Netherlands        #
  340. X#    This file can be freely copied for any use.        #
  341. X#################################################################
  342. X#$Id: mailstat,v 1.11 1993/01/18 18:17:15 berg Exp $
  343. X
  344. X#    This shell script expects the following programs to be in the
  345. X#    PATH (paths given here are the standard locations, your mileage
  346. X#    may vary (if the programs can not be found, extend the PATH or
  347. X#    put their absolute pathnames in here):
  348. X
  349. Xtest=test        # /bin/test    (or built-in in /bin/sh)
  350. Xexpr=expr        # /bin/expr
  351. Xtty=tty            # /bin/tty
  352. Xsed=sed            # /bin/sed
  353. Xsort=sort        # /bin/sort
  354. Xawk=awk            # /bin/awk
  355. Xcat=cat            # /bin/cat
  356. Xmv=mv            # /bin/mv
  357. Xls=ls            # /bin/ls
  358. X
  359. XPATH=/bin:/usr/bin
  360. XSHELL=/bin/sh        # just in case
  361. Xexport SHELL PATH
  362. X
  363. Xumask 077        # we don't allow everyone to read the tmpfiles
  364. XOLDSUFFIX=.old
  365. X
  366. XDEVNULL=/dev/null
  367. XEX_USAGE=64
  368. X
  369. X########
  370. X#    (Concatenated) flags parsing in pure, portable, structured (it
  371. X#    would have been more elegant if gotos were permitted) shellscript
  372. X#    language.  For added pleasure: a quick demonstration of the shell's
  373. X#    quoting capabilities :-).
  374. X########
  375. X
  376. Xwhile $test $# != 0 -a a"$1" != a-- -a \
  377. X \( 0 != `$expr match a"$1" a-.` -o $# != 1 \)
  378. Xdo
  379. X  if $expr match "$1" -. >$DEVNULL    # structured-programming spaghetti
  380. X  then
  381. X     flags="$1"; shift
  382. X  else
  383. X     flags=-h                # force help page
  384. X  fi
  385. X  while flags="`$expr match "$flags" '.\\(.*\\)'`"; $test ."$flags" != .
  386. X  do
  387. X     case "$flags" in
  388. X     k*) MSkeeplogfile=1;;
  389. X     l*) MSlong=1;;
  390. X     m*) MSmergerror=1;;
  391. X     o*) MSoldlog=1; MSkeeplogfile=1;;
  392. X     t*) MSterse=1;;
  393. X     s*) MSsilent=1;;
  394. X     h*|\?*) echo 'Usage: mailstat [-klmots] [logfile]' 1>&2
  395. X        echo '    -k    keep logfile intact' 1>&2
  396. X        echo '    -l    long display format' 1>&2
  397. X        echo '    -m    merge any errors into one line' 1>&2
  398. X        echo '    -o    use the old logfile' 1>&2
  399. X        echo '    -t    terse display format' 1>&2
  400. X        echo '    -s    silent in case of no mail' 1>&2
  401. X        exit $EX_USAGE;;
  402. X     *) echo 'Usage: mailstat [-klmots] [logfile]' 1>&2; exit $EX_USAGE;;
  403. X     esac
  404. X  done
  405. Xdone
  406. X
  407. X$test a"$1" = a-- && shift
  408. X
  409. XLOGFILE="$1"
  410. X
  411. Xcase "$LOGFILE" in
  412. X  *$OLDSUFFIX) MSkeeplogfile=1; OLDLOGFILE="$LOGFILE";;
  413. X  *) OLDLOGFILE="$LOGFILE$OLDSUFFIX";;
  414. Xesac
  415. X
  416. Xif test .$MSoldlog = .1
  417. Xthen
  418. X  LOGFILE="$OLDLOGFILE"
  419. Xfi
  420. X
  421. Xif $test ."$LOGFILE" != .- -a ."$LOGFILE" != .
  422. Xthen
  423. X  if $test ! -s "$LOGFILE"
  424. X  then
  425. X     if $test .$MSsilent = .
  426. X     then
  427. X    if $test -f "$LOGFILE"
  428. X    then
  429. X       echo No mail arrived since `$expr match "\`$ls -l \"$OLDLOGFILE\"
  430. X        \`" '.*[0-9] \\([A-Z][a-z][a-z] .. .....\\) [^ ]'`
  431. X    else
  432. X       echo "Can't find your LOGFILE=$LOGFILE"
  433. X    fi
  434. X     fi
  435. X     exit 1
  436. X  fi
  437. Xelse
  438. X  if $test ."$LOGFILE" != .- && $tty -s
  439. X  then
  440. X     echo \
  441. X      "Most people don't type their own logfiles;  but, what do I care?" 1>&2
  442. X     MSterse=1
  443. X  fi
  444. X  MSkeeplogfile=1; LOGFILE=
  445. Xfi
  446. X
  447. Xif $test .$MSkeeplogfile = .
  448. Xthen $mv "$LOGFILE" "$OLDLOGFILE"; $cat $DEVNULL >>"$LOGFILE"
  449. Xelse OLDLOGFILE="$LOGFILE"
  450. Xfi
  451. X
  452. Xif $test .$MSterse = .
  453. Xthen
  454. X  if $test .$MSlong = .1
  455. X  then
  456. X     echo ""
  457. X     echo "  Total Average  Number Folder"
  458. X     echo "  ----- -------  ------ ------"
  459. X  else
  460. X     echo ""
  461. X     echo "  Total  Number Folder"
  462. X     echo "  -----  ------ ------"
  463. X  fi
  464. Xfi
  465. X
  466. Xif $test .$MSlong = .1
  467. Xthen MSlong='"%7d %7d %7d %s\n",total,total/messages,messages,folder'
  468. Xelse MSlong='"%7d %7d %s\n",total,messages,folder'
  469. Xfi
  470. X
  471. XTMPF=/tmp/maillog.$$
  472. X
  473. Xtrap "rm -f $TMPF; exit 2" 1 2 3 15
  474. Xtrap "rm -f $TMPF; exit 0" 0
  475. X
  476. X########
  477. X#    And now we descend into the wonderful mix if shell-quoting and
  478. X#    portable awk-programming :-)
  479. X########
  480. X
  481. X$cat >$TMPF <<HERE
  482. XBEGIN {
  483. X    FS="\\t";
  484. X  }
  485. X  { if(folder!=\$1)
  486. X     { if(folder!="")
  487. X      printf($MSlong);
  488. X       messages=0;total=0;folder=\$1;
  489. X     }
  490. X    ++messages;total+=\$2;
  491. X  }
  492. XEND {
  493. X    if(folder!="")
  494. X       printf($MSlong);
  495. X  }
  496. XHERE
  497. X
  498. X########
  499. X#    Only to end in a grand finale with your average sed script
  500. X########
  501. X
  502. Xif $test .$MSmergerror = .
  503. Xthen
  504. X  $sed    -e '/^From /d' -e '/^ [Ss][uU][bB][jJ][eE][cC][tT]:/d' \
  505. X   -e '/^  Folder/s/        */    /' \
  506. X   -e '/^  Folder/s/\/msg.[-0-9A-Za-z_][-0-9A-Za-z_]*    /\/    /' \
  507. X   -e '/^  Folder/s/\/[0-9][0-9]*    /\/.    /' \
  508. X   -e 's/^  Folder: \(.*\)/\1/' -e t -e 's/    /\\t/g' \
  509. X   -e 's/^/ ## /' $OLDLOGFILE | $sort | $awk -f $TMPF -
  510. Xelse
  511. X  $sed    -e '/^From /d' -e '/^ [Ss][uU][bB][jJ][eE][cC][tT]:/d' \
  512. X   -e '/^  Folder/s/        */    /' \
  513. X   -e '/^  Folder/s/\/msg.[-0-9A-Za-z_][-0-9A-Za-z_]*    /\/    /' \
  514. X   -e '/^  Folder/s/\/[0-9][0-9]*    /\/.    /' \
  515. X   -e 's/^  Folder: \(.*\)/\1/' -e t \
  516. X   -e 's/.*/ ## diagnostic messages ##/' $OLDLOGFILE | $sort | $awk -f $TMPF -
  517. Xfi
  518. X
  519. X########
  520. X#    Nifty little script, isn't it?
  521. X#    Now why didn't *you* come up with this truly trivial script? :-)
  522. X########
  523. END_OF_FILE
  524. if test 5197 -ne `wc -c <'procmail280/examples/mailstat'`; then
  525.     echo shar: \"'procmail280/examples/mailstat'\" unpacked with wrong size!
  526. fi
  527. chmod +x 'procmail280/examples/mailstat'
  528. # end of 'procmail280/examples/mailstat'
  529. fi
  530. if test -f 'procmail280/initmake' -a "${1}" != "-c" ; then 
  531.   echo shar: Will not clobber existing file \"'procmail280/initmake'\"
  532. else
  533. echo shar: Extracting \"'procmail280/initmake'\" \(6162 characters\)
  534. sed "s/^X//" >'procmail280/initmake' <<'END_OF_FILE'
  535. X#! /bin/sh
  536. X:
  537. X#$Id: initmake,v 1.21 1993/02/02 16:54:03 berg Exp $
  538. X
  539. XPATH=.:$PATH
  540. XBSHELL=$1
  541. Xshift; MSHELL=$1
  542. Xshift; RM="$1"
  543. Xshift; MV="$1"
  544. Xshift; LN="$1"
  545. Xshift; USRINCLUDE=$1
  546. Xshift; LIBPATHS="$1"
  547. Xshift; DEVNULL=$1
  548. Xshift; MAKE="$1"
  549. Xshift; O=$1
  550. Xshift; CC="$1"
  551. Xshift; CFLAGS1="$1"
  552. Xshift; LDFLAGS1="$1"
  553. Xshift; BINSS="$1"
  554. Xshift; MANS1S="$1"
  555. Xshift; MANS5S="$1"
  556. Xshift; SUBDIRS="$1"
  557. X
  558. Xtest 1 != $# &&
  559. X echo "Don't start this script directly, use \`make init'" && exit 1
  560. X
  561. Xtest -z "$MSHELL" || SHELL=$MSHELL
  562. Xcase "$SHELL" in
  563. X  *sh*)
  564. X     case "$SHELL" in
  565. X    *csh*) echo "Warning: really perverted make detected"; SHELL="";;
  566. X     esac;;
  567. X  *) echo "Warning: perverted make detected"; SHELL="";;
  568. Xesac
  569. Xtest -z "$SHELL" && SHELL=$BSHELL
  570. X
  571. Xexport SHELL PATH
  572. X
  573. XFGREP="fgrep"        # POSIX, or not POSIX, that is the question...
  574. Xif test \^hello = "`echo '^hello' | grep -F '^hello' 2>&1`"
  575. Xthen FGREP="grep -F"                # and POSIX it is!
  576. Xfi
  577. X
  578. Xif test ! -f $USRINCLUDE/stdio.h
  579. Xthen echo 2>&1 "Panic!       I can't find your system include-files."
  580. X  echo 2>&1 "I already looked in \"$USRINCLUDE\".  Please edit the Makefile"
  581. X  echo 2>&1 "and make sure that the definition of USRINCLUDE is correct,"
  582. X  echo 2>&1 "before retrying another make."
  583. X  exit 1
  584. Xfi
  585. X
  586. Xcc=""
  587. Xcd src                # diving into the source directory ######
  588. Xcat >_autotst.c <<HERE
  589. Xmain()
  590. X{ return 0;
  591. X}
  592. XHERE
  593. X$RM _autotst.rrr _autotst.$O _autotst
  594. Xfor a in "$CC" cc gcc
  595. Xdo
  596. X  echo $a $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1 >>_autotst.rrr
  597. X  test -z "$cc" -a ! -z "$a" &&
  598. X   ($a $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1) >>_autotst.rrr \
  599. X   2>&1 && cc="$a"
  600. X  echo "::::" >>_autotst.rrr
  601. Xdone
  602. Xif test -z "$cc"
  603. Xthen
  604. X  echo 2>&1 "Whoeaaa!  There's something fishy going on here."
  605. X  echo 2>&1 "You have a look and see if you detect anything uncanny:"
  606. X  echo 2>&1 "-------------------------------------------------------"
  607. X  cat 2>&1 _autotst.rrr
  608. X  echo 2>&1 "-------------------------------------------------------"
  609. X  echo 2>&1 "I suggest you take a look at the definition of CFLAGS* and CC"
  610. X  echo 2>&1 "in the Makefile before you try make again."
  611. X  exit 1
  612. Xfi
  613. X$RM _autotst.rrr _autotst.$O _autotst
  614. Xecho "$cc seems to work fine, using that as the C-compiler"
  615. X
  616. Xcat >_autotst.c <<HERE
  617. X#include <sys/stat.h>
  618. Xmain()
  619. X{ struct stat buf;return!&buf;
  620. X}
  621. XHERE
  622. X
  623. XCFLAGS=""
  624. Xcase "$CFLAGS1" in
  625. X  *-D_POSIX_SOURCE*);;
  626. X  *)
  627. X     if $cc -c $CFLAGS1 _autotst.c >$DEVNULL 2>&1
  628. X     then
  629. X     :
  630. X     else
  631. X    $RM _autotst.$O
  632. X    $cc -c $CFLAGS1 -D_POSIX_SOURCE _autotst.c >$DEVNULL 2>&1 &&
  633. X     CFLAGS=" -D_POSIX_SOURCE"
  634. X     fi;;
  635. Xesac
  636. X
  637. XLDFLAGS=""
  638. Xexport LDFLAGS
  639. X
  640. Xtest -f _autotst.$O || $cc -c $CFLAGS1 $CFLAGS _autotst.c >$DEVNULL 2>&1
  641. X$cc $CFLAGS1 $CFLAGS _autotst.c -o _autotst $LDFLAGS1 -lc >$DEVNULL 2>&1 &&
  642. X LDFLAGS=" -lc"
  643. X$RM _autotst.$O _autotst.c _autotst
  644. Xcd ..            # returning to the main procmail directory ######
  645. X
  646. Xcat >checklib <<HERE
  647. Xname="\$1"
  648. Xfor libpath in $LIBPATHS
  649. Xdo
  650. X  set \$libpath/*lib\$name[A-Z.]*
  651. X  libname="\$1"
  652. X  if test -f \$libname
  653. X  then
  654. X     case "\$libpath" in
  655. X    /usr/local/lib)
  656. X       case "\$LDFLAGS" in
  657. X          *-L\$libpath*) LDFLAGS="\$LDFLAGS -L\$libpath";;
  658. X       esac;;
  659. X     esac
  660. X     echo "\$LDFLAGS -l\$name"
  661. X     exit 0
  662. X  fi
  663. Xdone
  664. Xecho "\$LDFLAGS"
  665. XHERE
  666. Xchmod 0755 checklib
  667. X
  668. X#LDFLAGS=`checklib c`
  669. Xtest ! -f $USRINC/dirent.h -a ! -f $USRINC/ndir.h -a -f $USRINC/sys/ndir.h ||
  670. X LDFLAGS=`checklib dir`
  671. XLDFLAGS=`checklib x`
  672. XLDFLAGS=`checklib net`            # why did everyone have to think up
  673. XLDFLAGS=`checklib inet`            # their own name?
  674. XLDFLAGS=`checklib nsl_s`
  675. XLDFLAGS=`checklib nsl_i`
  676. XLDFLAGS=`checklib nsl`
  677. XLDFLAGS=`checklib gen`
  678. XLDFLAGS=`checklib socket`
  679. XLDFLAGS=`checklib sockdns`
  680. X#LDFLAGS=`checklib resolv`        # not really needed, is it?
  681. XLDFLAGS=`checklib sun`
  682. X$RM checklib
  683. X
  684. Xtest -z "$CFLAGS" || echo "Added CFLAGS=$CFLAGS"
  685. Xtest -z "$LDFLAGS" || echo "Added LDFLAGS=$LDFLAGS"
  686. X
  687. Xfor a in $SUBDIRS
  688. Xdo
  689. X  if test ! -f $a/Makefile.init
  690. X  then
  691. X     $LN $a/Makefile $a/Makefile.init
  692. X     $RM $a/Makefile
  693. X     $LN $a/Makefile.init $a/Makefile
  694. X  fi
  695. Xdone
  696. X
  697. Xtest -f Makefile.0 || sed -e '/^# Makefile - mark/,$ !d' <Makefile >Makefile.0
  698. Xsed -e '/^# Makefile - mark/,$ d' <Makefile >_Makefile
  699. Xecho "# Makefile.1 - mark, don't (re)move this, a sed script needs it
  700. X" >>_Makefile
  701. X
  702. Xtest a$SHELL != a$MSHELL && echo  "SHELL    = $SHELL"    >>_Makefile
  703. Xecho "FGREP    = $FGREP"                >>_Makefile
  704. Xtest -z "$MAKE" && echo "MAKE    = make"            >>_Makefile
  705. Xtest a"$cc" != a"$CC" && echo "CC    = $cc"        >>_Makefile
  706. X
  707. Xecho "CFLAGS    = \$(CFLAGS1)$CFLAGS"            >>_Makefile
  708. Xecho "LDFLAGS    = \$(LDFLAGS1)$LDFLAGS"            >>_Makefile
  709. Xecho                            >>_Makefile
  710. X
  711. XMANSS=""
  712. XMANS1=""
  713. XMANS5=""
  714. XMANS=""
  715. XNMANS=""
  716. XBINS=""
  717. XNBINS=""
  718. Xfor a in $MANS1S
  719. Xdo
  720. X  MANSS="$MANSS $a.1"
  721. X  MANS1="$MANS1 $a.\$(MAN1SUFFIX)"
  722. Xdone
  723. Xfor a in $MANS5S
  724. Xdo
  725. X  MANSS="$MANSS $a.5"
  726. X  MANS5="$MANS5 $a.\$(MAN5SUFFIX)"
  727. Xdone
  728. Xfor a in $MANSS
  729. Xdo
  730. X  MANS="$MANS new/$a"
  731. X  NMANS="$NMANS ../new/$a"
  732. Xdone
  733. Xfor a in $BINSS
  734. Xdo
  735. X  BINS="$BINS new/$a"
  736. X  NBINS="$NBINS ../new/$a"
  737. Xdone
  738. X
  739. Xecho "BINS=$BINS"                    >>_Makefile
  740. Xecho "MANS=$MANS"                    >>_Makefile
  741. Xecho "MANS1=$MANS1"                    >>_Makefile
  742. Xecho "MANS5=$MANS5"                    >>_Makefile
  743. Xecho "MANSS=$MANSS"                    >>_Makefile
  744. Xecho "NBINS=$NBINS"                    >>_Makefile
  745. Xecho "NMANS=$NMANS"                    >>_Makefile
  746. Xecho                            >>_Makefile
  747. X
  748. Xfor a in $SUBDIRS
  749. Xdo
  750. X  sed -e '1,/^# Makefile.0 - mark/ d' <_Makefile >$a/_Makefile
  751. X  cat $a/Makefile.0 >>$a/_Makefile
  752. Xdone
  753. X
  754. Xfor a in $BINSS
  755. Xdo
  756. X  echo                            >>src/_Makefile
  757. X  echo "../new/$a: $a ../new"                >>src/_Makefile
  758. X  echo "    @\$(RM) \$@"                >>src/_Makefile
  759. X  echo "    \$(LN) $a \$@"                >>src/_Makefile
  760. Xdone
  761. X
  762. Xfor a in $MANSS
  763. Xdo
  764. X  echo                            >>man/_Makefile
  765. X  echo "../new/$a: $a ../new"                >>man/_Makefile
  766. X  echo "    @\$(RM) \$@"                >>man/_Makefile
  767. X  echo "    \$(LN) $a \$@"                >>man/_Makefile
  768. Xdone
  769. X
  770. Xfor a in $MANS1S
  771. Xdo
  772. X  echo                            >>man/_Makefile
  773. X  echo "$a.1: $a.man man.sed mansed"            >>man/_Makefile
  774. X  echo \
  775. X   "    \$(SHELL) ./mansed \$(SHELL) $a.man \$@ \"\$(RM)\" \$(DEVNULL)" \
  776. X   >>man/_Makefile
  777. Xdone
  778. X
  779. Xfor a in $MANS5S
  780. Xdo
  781. X  echo                            >>man/_Makefile
  782. X  echo "$a.5: $a.man man.sed mansed"            >>man/_Makefile
  783. X  echo \
  784. X   "    \$(SHELL) ./mansed \$(SHELL) $a.man \$@ \"\$(RM)\" \$(DEVNULL)" \
  785. X   >>man/_Makefile
  786. Xdone
  787. X
  788. Xcat Makefile.1 >>_Makefile
  789. X$MV _Makefile Makefile
  790. X
  791. Xfor a in $SUBDIRS
  792. Xdo
  793. X  $MV $a/_Makefile $a/Makefile
  794. Xdone
  795. END_OF_FILE
  796. if test 6162 -ne `wc -c <'procmail280/initmake'`; then
  797.     echo shar: \"'procmail280/initmake'\" unpacked with wrong size!
  798. fi
  799. chmod +x 'procmail280/initmake'
  800. # end of 'procmail280/initmake'
  801. fi
  802. if test -f 'procmail280/man/lockfile.man' -a "${1}" != "-c" ; then 
  803.   echo shar: Will not clobber existing file \"'procmail280/man/lockfile.man'\"
  804. else
  805. echo shar: Extracting \"'procmail280/man/lockfile.man'\" \(5174 characters\)
  806. sed "s/^X//" >'procmail280/man/lockfile.man' <<'END_OF_FILE'
  807. X.Id $Id: lockfile.man,v 1.7 1993/01/13 15:20:28 berg Exp $
  808. X.TH LOCKFILE 1 \*(Dt BuGless
  809. X.na
  810. X.SH NAME
  811. Xlockfile \- conditional semaphore-file creator
  812. X.SH SYNOPSIS
  813. X.B lockfile
  814. X.I "\fB\-\fPsleeptime"
  815. X|
  816. X.I "\fB\-r \fPretries"
  817. X|
  818. X.if n .ti +0.5i
  819. X.I "\fB\-l \fPlocktimeout"
  820. X|
  821. X.I "\fB\-s \fPsuspend"
  822. X|
  823. X.B "\-!"
  824. X|
  825. X.B "\-ml"
  826. X|
  827. X.B "\-mu"
  828. X|
  829. X.I filename
  830. X\&.\|.\|.
  831. X.ad
  832. X.Sh DESCRIPTION
  833. X.B lockfile
  834. Xcan be used to create one or more
  835. X.I semaphore
  836. X.IR files .
  837. XIf lockfile can't create all the specified files (in the specified order),
  838. Xit waits
  839. X.I sleeptime
  840. X(defaults to +DEFlocksleep+) seconds and retries the last file that didn't
  841. Xsucceed.  You can specify the number of
  842. X.I retries
  843. Xto do until failure is returned.
  844. XIf the number of
  845. X.I retries
  846. Xis -1 (default, i.e.
  847. X.BR \-r\-1 )
  848. Xlockfile will retry forever.
  849. X.PP
  850. XIf the number of
  851. X.I retries
  852. Xexpires before all files have been created, lockfile returns failure and
  853. Xremoves all the files it created up till that point.
  854. X.PP
  855. XThe return value of lockfile can be easily inverted by specifying
  856. X.B \-!
  857. Xas an argument (comes in handy in shell scripts).
  858. X.PP
  859. XAll flags can be specified anywhere on the command line, they will be
  860. Xprocessed when encountered.  The command line is simply parsed from
  861. Xleft to right.
  862. X.PP
  863. XAll files created by lockfile will have access permission 0, and therefore
  864. Xwill have to be removed with
  865. X.B rm
  866. X.BR \-f .
  867. X.PP
  868. XIf you specify a
  869. X.I locktimeout
  870. Xthen a lockfile will be removed by force after locktimeout seconds have
  871. Xpassed since the lockfile was last modified/created (most probably by some
  872. Xother program that unexpectedly died a long time ago, and hence could not clean
  873. Xup any leftover lockfiles).  Lockfile is clock skew immune.  After a lockfile
  874. Xhas been removed by force, a suspension of
  875. X.I suspend
  876. Xseconds (defaults to +DEFsuspend+) is taken into account, in order to prevent
  877. Xthe inadvertent immediate removal of any newly created lockfile by another
  878. Xprogram (compare
  879. X.BR SUSPEND
  880. Xin
  881. X.BR procmail (1)).
  882. X.Ss "Mailbox locks"
  883. XIf the permissions on the system mail spool directory allow it, or if lockfile
  884. Xis suitably setgid, it will be able to lock and unlock your system mailbox by
  885. Xusing the options
  886. X.B "\-ml"
  887. Xand
  888. X.B "\-mu"
  889. Xrespectively.
  890. X.Sh EXAMPLES
  891. XSuppose you want to make sure that access to the file "important" is
  892. Xserialised, i.e. no more than one program or shell script should be allowed
  893. Xto access it.  For simplicity's sake, let's suppose that it is a shell
  894. Xscript.  In this case you could solve it like this:
  895. X.Rs
  896. X\&.\|.\|.
  897. Xlockfile important.lock
  898. X\&.\|.\|.
  899. Xaccess_"important"_to_your_hearts_content
  900. X\&.\|.\|.
  901. Xrm -f important.lock
  902. X\&.\|.\|.
  903. X.Re
  904. XNow if all the scripts that access "important" follow this guideline, you
  905. Xwill be assured that at most one script will be executing between the
  906. X`lockfile' and the `rm' commands.
  907. X.Sh ENVIRONMENT
  908. X.Tp 2.3i
  909. X.B LOGNAME
  910. Xused as a hint to determine the invoker's loginname
  911. X.Sh FILES
  912. X.Tp 2.3i
  913. X.B /etc/passwd
  914. Xto verify and/or correct the invoker's loginname (and to find out his HOME
  915. Xdirectory, if needed)
  916. X.Tp
  917. X.B +SYSTEM_MBOX++DEFlockext+
  918. Xlockfile for the system mailbox, the environment variables present in here
  919. Xwill not be taken from the environment, but will be determined by looking
  920. Xin /etc/passwd
  921. X.Sh "SEE ALSO"
  922. X.na
  923. X.nh
  924. X.BR rm (1),
  925. X.BR mail (1),
  926. X.BR binmail (1),
  927. X.BR sendmail (8),
  928. X.BR procmail (1)
  929. X.hy
  930. X.ad
  931. X.Sh DIAGNOSTICS
  932. X.Tp 2.3i
  933. XFilename too long, .\|.\|.
  934. XUse shorter filenames.
  935. X.Tp
  936. XForced unlock denied on "x"
  937. XNo write permission in the directory where lockfile "x" resides, or more than
  938. Xone lockfile trying to force a lock at exactly the same time.
  939. X.Tp
  940. XForcing lock on "x"
  941. XLockfile "x" is going to be removed by force because of a timeout
  942. X(compare
  943. X.BR LOCKTIMEOUT
  944. Xin
  945. X.BR procmail (1)).
  946. X.Tp
  947. XOut of memory, .\|.\|.
  948. XThe system is out of swap space.
  949. X.Tp
  950. XSignal received, .\|.\|.
  951. XLockfile will remove anything it created till now and terminate.
  952. X.Tp
  953. XSorry, .\|.\|.
  954. XThe
  955. X.I retries
  956. Xlimit has been reached.
  957. X.Tp
  958. XTruncating "x" and retrying lock
  959. X"x" does not seem to be a valid filename.
  960. X.Tp
  961. XTry praying, .\|.\|.
  962. XMissing subdirectories or insufficient privileges.
  963. X.Sh BUGS
  964. XDefinitely less than one.
  965. X.Sh MISCELLANEOUS
  966. XLockfile is NFS-resistant and eight-bit clean.
  967. X.Sh NOTES
  968. XCalling up lockfile with the \-+HELPOPT1+ or \-+HELPOPT2+ options will cause
  969. Xit to display a command-line help page.
  970. X.PP
  971. XMultiple
  972. X.B \-!
  973. Xflags will toggle the return status.
  974. X.PP
  975. XSince flags can occur anywhere on the command line, any filename starting
  976. Xwith a '-' has to be preceded by './'.
  977. X.PP
  978. XThe number of
  979. X.I retries
  980. Xwill not be reset when any following file is being created (i.e. they are
  981. Xsimply used up).  It can, however, be reset by specifying
  982. X.RI \-r newretries
  983. Xafter every file on the command line.
  984. X.PP
  985. XAlthough files with any name can be used as lockfiles, it is common practice
  986. Xto use the extension `.lock' to lock mailfolders (it is appended to the
  987. Xmailfolder name).  In case one does not want to have to worry about too long
  988. Xfilenames and does not have to conform to any other lockfilename convention,
  989. Xthen an excellent way to generate a lockfilename corresponding to some already
  990. Xexisting file is by taking the prefix `lock.' and appending the i-node number
  991. Xof the file which is to be locked.
  992. END_OF_FILE
  993. if test 5174 -ne `wc -c <'procmail280/man/lockfile.man'`; then
  994.     echo shar: \"'procmail280/man/lockfile.man'\" unpacked with wrong size!
  995. fi
  996. # end of 'procmail280/man/lockfile.man'
  997. fi
  998. if test -f 'procmail280/src/formisc.c' -a "${1}" != "-c" ; then 
  999.   echo shar: Will not clobber existing file \"'procmail280/src/formisc.c'\"
  1000. else
  1001. echo shar: Extracting \"'procmail280/src/formisc.c'\" \(4968 characters\)
  1002. sed "s/^X//" >'procmail280/src/formisc.c' <<'END_OF_FILE'
  1003. X/************************************************************************
  1004. X *    Miscellaneous routines used by formail                *
  1005. X *                                    *
  1006. X *    Copyright (c) 1990-1992, S.R. van den Berg, The Netherlands    *
  1007. X *    #include "README"                        *
  1008. X ************************************************************************/
  1009. X#ifdef RCS
  1010. Xstatic /*const*/char rcsid[]=
  1011. X "$Id: formisc.c,v 1.15 1993/02/04 12:44:49 berg Exp $";
  1012. X#endif
  1013. X#include "includes.h"
  1014. X#include "formail.h"
  1015. X#include "sublib.h"
  1016. X#include "shell.h"
  1017. X#include "common.h"
  1018. X#include "ecommon.h"
  1019. X#include "formisc.h"
  1020. X
  1021. Xstatic char*skipcomment(start)char*start;
  1022. X{ for(;;)
  1023. X     switch(*++start)
  1024. X      { case ')':return start;
  1025. X    case '\\':start++;break;
  1026. X    case '(':start=skipcomment(start);
  1027. X      }
  1028. X}
  1029. X                         /* skips an RFC 822 address */
  1030. Xchar*skipwords(start)char*start;
  1031. X{ int delim,hitspc,machref;char*target,*oldstart;
  1032. X  hitspc=machref=0;target=oldstart=start;
  1033. X  if(*start=='<')
  1034. X     start++,machref=1;
  1035. X  for(;;)
  1036. X   { switch(*start)
  1037. X      { case '<':                    /* machine reference */
  1038. X       if(machref)                    /* can not be nested */
  1039. X        { target=oldstart;hitspc=0;goto inc;        /* so start over */
  1040. X        }
  1041. X       goto ret;
  1042. X    case '(':start=skipcomment(start);              /* comment */
  1043. X    case ' ':case '\t':case '\n':hitspc|=1;           /* linear white space */
  1044. Xinc:       start++;continue;
  1045. X    case ',':case ';':          /* sendmail extended RFC-822 behaviour */
  1046. X       if(machref)
  1047. X        { machref=2;goto special;
  1048. X        }
  1049. X       goto retz;
  1050. X    case '\\':*target++='\\';start++;            /* same here */
  1051. X    default:
  1052. X       if(!machref&&hitspc==3&&target>oldstart)
  1053. X    case '\0':case '>':
  1054. X        { if(machref==2)
  1055. X           { *target++='>';tmemmove(oldstart+1,oldstart,target++-oldstart);
  1056. X         *oldstart='<';
  1057. X           }
  1058. Xretz:          *target='\0';
  1059. Xret:          return start;
  1060. X        }
  1061. X       hitspc=2;goto normal;                  /* normal word */
  1062. X    case '@':case ':':case '.':
  1063. Xspecial:   hitspc=0;
  1064. Xnormal:       *target++= *start++;continue;
  1065. X    case '[':delim=']';break;               /* domain-literal */
  1066. X    case '"':*target++=delim='"';start++;
  1067. X      }
  1068. X     ;{ int i;
  1069. X    do
  1070. X       if((i= *target++= *start++)==delim)     /* corresponding delimiter? */
  1071. X          break;
  1072. X       else if(i=='\\'&&*start)            /* skip quoted character */
  1073. X          *target++= *start++;
  1074. X    while(*start);                        /* anything? */
  1075. X      }
  1076. X     hitspc=2;
  1077. X   }
  1078. X}
  1079. X
  1080. Xvoid loadsaved(sp)const struct saved*const sp;         /* load some saved text */
  1081. X{ switch(*sp->rexp)
  1082. X   { default:loadchar(' ');           /* make sure it has leading whitspace */
  1083. X     case ' ':case '\t':;
  1084. X   }
  1085. X  loadbuf(sp->rexp,sp->rexl);
  1086. X}
  1087. X                                /* append to buf */
  1088. Xvoid loadbuf(text,len)const char*const text;const size_t len;
  1089. X{ if(buffilled+len>buflen)              /* buf can't hold the text */
  1090. X     buf=realloc(buf,buflen+=BSIZE);
  1091. X  tmemmove(buf+buffilled,text,len);buffilled+=len;
  1092. X}
  1093. X
  1094. Xvoid loadchar(c)const int c;              /* append one character to buf */
  1095. X{ if(buffilled==buflen)
  1096. X     buf=realloc(buf,buflen+=BSIZE);
  1097. X  buf[buffilled++]=c;
  1098. X}
  1099. X
  1100. Xgetline P((void))               /* read a newline-terminated line */
  1101. X{ if(buflast!=EOF)                 /* do we still have a leftover? */
  1102. X     loadchar(buflast);                  /* load it into the buffer */
  1103. X  if(buflast!='\n')
  1104. X   { int ch;
  1105. X     while((ch=getchar())!=EOF&&ch!='\n')
  1106. X    loadchar(ch);                /* load the rest of the line */
  1107. X     loadchar('\n');            /* make sure (!), it ends with a newline */
  1108. X   }        /* (some code in formail.c depends on a terminating newline) */
  1109. X  return buflast=getchar();            /* look ahead, one character */
  1110. X}
  1111. X
  1112. Xvoid elog(a)const char*const a;                     /* error output */
  1113. X{ fputs(a,stderr);
  1114. X}
  1115. X
  1116. Xvoid tputssn(a,l)const char*a;size_t l;
  1117. X{ while(l--)
  1118. X     putcs(*a++);
  1119. X}
  1120. X
  1121. Xvoid ltputssn(a,l)const char*a;size_t l;
  1122. X{ if(logsummary)
  1123. X     totallen+=l;
  1124. X  else
  1125. X     putssn(a,l);
  1126. X}
  1127. X
  1128. Xvoid lputcs(i)const int i;
  1129. X{ if(logsummary)
  1130. X     totallen++;
  1131. X  else
  1132. X     putcs(i);
  1133. X}
  1134. X
  1135. Xvoid startprog(argv)const char*Const*const argv;
  1136. X{ int poutfd[2];
  1137. X  if(!nrtotal)                    /* no more mails to display? */
  1138. X     goto squelch;
  1139. X  if(nrskip)                  /* should we still skip this mail? */
  1140. X   { nrskip--;                             /* count it */
  1141. Xsquelch:
  1142. X     opensink();return;
  1143. X   }
  1144. X  if(nrtotal>0)
  1145. X     nrtotal--;                             /* count it */
  1146. X  dup(oldstdout);pipe(poutfd);
  1147. X  if(!(child=fork()))    /* DON'T fclose(stdin) here, provokes a bug on HP/UX */
  1148. X   { close(STDIN);close(oldstdout);close(PWRO);dup(PRDO);close(PRDO);
  1149. X     shexec(argv);
  1150. X   }
  1151. X  close(STDOUT);close(PRDO);
  1152. X  if(STDOUT!=dup(PWRO)||!(mystdout=Fdopen(STDOUT,"a")))
  1153. X     nofild();
  1154. X  close(PWRO);
  1155. X  if(-1==child)
  1156. X     nlog("Can't fork\n"),exit(EX_OSERR);
  1157. X}
  1158. X
  1159. Xvoid nofild P((void))
  1160. X{ nlog("File table full\n");exit(EX_OSERR);
  1161. X}
  1162. X
  1163. Xvoid waitforit P((void))
  1164. X{ int i;pid_t j;
  1165. X  while(child!=(j=wait(&i))||WIFSTOPPED(i))
  1166. X    if(-1==j)
  1167. X       return;
  1168. X}
  1169. X
  1170. Xvoid nlog(a)const char*const a;
  1171. X{ elog(NAMEPREFIX);elog(a);
  1172. X}
  1173. X
  1174. Xvoid logqnl(a)const char*const a;
  1175. X{ elog(" \"");elog(a);elog("\"\n");
  1176. X}
  1177. X
  1178. Xvoid closemine P((void))
  1179. X{ if((fclose(mystdout)==EOF||errout==EOF)&&!quiet)
  1180. X     nlog(couldntw),elog("\n"),exit(EX_IOERR);
  1181. X}
  1182. X
  1183. Xvoid opensink P((void))
  1184. X{ if(!(mystdout=fopen(DevNull,"a")))
  1185. X     nofild();
  1186. X}
  1187. END_OF_FILE
  1188. if test 4968 -ne `wc -c <'procmail280/src/formisc.c'`; then
  1189.     echo shar: \"'procmail280/src/formisc.c'\" unpacked with wrong size!
  1190. fi
  1191. # end of 'procmail280/src/formisc.c'
  1192. fi
  1193. if test -f 'procmail280/src/locking.c' -a "${1}" != "-c" ; then 
  1194.   echo shar: Will not clobber existing file \"'procmail280/src/locking.c'\"
  1195. else
  1196. echo shar: Extracting \"'procmail280/src/locking.c'\" \(6399 characters\)
  1197. sed "s/^X//" >'procmail280/src/locking.c' <<'END_OF_FILE'
  1198. X/************************************************************************
  1199. X *    Whatever is needed for (un)locking files in various ways    *
  1200. X *                                    *
  1201. X *    Copyright (c) 1990-1992, S.R. van den Berg, The Netherlands    *
  1202. X *    #include "README"                        *
  1203. X ************************************************************************/
  1204. X#ifdef RCS
  1205. Xstatic /*const*/char rcsid[]=
  1206. X "$Id: locking.c,v 1.11 1993/01/28 14:22:12 berg Exp $";
  1207. X#endif
  1208. X#include "procmail.h"
  1209. X#include "robust.h"
  1210. X#include "shell.h"
  1211. X#include "misc.h"
  1212. X#include "exopen.h"
  1213. X#include "locking.h"
  1214. X
  1215. Xvoid lockit(name,lockp)char*name;char**const lockp;
  1216. X{ int i,permanent=nfsTRY,triedforce=0;struct stat stbuf;time_t t;
  1217. X  if(*lockp)
  1218. X   { if(!strcmp(name,*lockp))    /* compare the previous lockfile to this one */
  1219. X    return;             /* they're equal, save yourself some effort */
  1220. X     unlock(lockp);               /* unlock any previous lockfile FIRST */
  1221. X   }                  /* to prevent deadlocks (I hate deadlocks) */
  1222. X  if(!*name)
  1223. X     return;
  1224. X  name=tstrdup(name); /* allocate now, so we won't hang on memory *and* lock */
  1225. X  for(lcking|=lck_LOCKFILE;;)
  1226. X   { yell("Locking",name);        /* in order to cater for clock skew: */
  1227. X     if(!xcreat(name,LOCKperm,&t,(int*)0))     /* get time t from filesystem */
  1228. X      { *lockp=name;break;               /* lock acquired, hurray! */
  1229. X      }
  1230. X     switch(errno)
  1231. X      { case EEXIST:           /* check if it's time for a lock override */
  1232. X       if(!lstat(name,&stbuf)&&stbuf.st_size<=MAX_LOCK_SIZE&&locktimeout
  1233. X        &&!lstat(name,&stbuf)&&locktimeout<t-stbuf.st_mtime)
  1234. X         /*
  1235. X          * stat() till unlink() should be atomic, but can't guarantee that
  1236. X          */
  1237. X        { if(triedforce)            /* already tried, not trying */
  1238. X         goto faillock;                        /* again */
  1239. X          if(S_ISDIR(stbuf.st_mode)||unlink(name))
  1240. X         triedforce=1,nlog("Forced unlock denied on"),logqnl(name);
  1241. X          else
  1242. X           { nlog("Forcing lock on");logqnl(name);suspend();goto ce;
  1243. X           }
  1244. X        }
  1245. X       else
  1246. X          triedforce=0;         /* legitimate iteration, clear flag */
  1247. X       break;
  1248. X    case ENOENT:case ENOTDIR:case EIO:case EACCES:
  1249. X       if(--permanent)
  1250. X          goto ds;
  1251. X       goto faillock;
  1252. X#ifdef ENAMETOOLONG
  1253. X    case ENAMETOOLONG:     /* maybe filename too long, shorten and retry */
  1254. X       if(0<(i=strlen(name)-1)&&!strchr(dirsep,name[i-1]))
  1255. X        { nlog("Truncating");logqnl(name);elog(" and retrying lock\n");
  1256. X          name[i]='\0';permanent=nfsTRY;goto ce;
  1257. X        }
  1258. X#endif
  1259. X    default:
  1260. Xfaillock:  nlog("Lock failure on");logqnl(name);goto term;
  1261. X    case ENOSPC:;
  1262. X#ifdef EDQUOT
  1263. X    case EDQUOT:;
  1264. X#endif
  1265. X      }
  1266. X     permanent=nfsTRY;
  1267. Xds:  sleep((unsigned)locksleep);
  1268. Xce:  if(nextexit)
  1269. Xterm: { free(name);break;             /* drop the preallocated buffer */
  1270. X      }
  1271. X   }
  1272. X  lcking&=~lck_LOCKFILE;
  1273. X  if(nextexit)
  1274. X   { elog(whilstwfor);elog("lockfile");logqnl(name);terminate();
  1275. X   }
  1276. X}
  1277. X
  1278. Xvoid lcllock P((void))                    /* lock a local lockfile */
  1279. X{ char*lckfile;
  1280. X  if(!strcmp(lckfile=tolock?tolock:strcat(buf2,tgetenv(lockext)),
  1281. X   tgetenv(lockfile)))
  1282. X     nlog("Deadlock attempted on"),logqnl(lckfile);
  1283. X  else
  1284. X     lockit(lckfile,&loclock);
  1285. X}
  1286. X
  1287. Xvoid unlock(lockp)char**const lockp;
  1288. X{ lcking|=lck_LOCKFILE;
  1289. X  if(*lockp)
  1290. X   { yell("Unlocking",*lockp);
  1291. X     if(unlink(*lockp))
  1292. X    nlog("Couldn't unlock"),logqnl(*lockp);
  1293. X     if(!nextexit)               /* if not inside a signal handler */
  1294. X    free(*lockp);
  1295. X     *lockp=0;
  1296. X   }
  1297. X  lcking&=~lck_LOCKFILE;
  1298. X  if(nextexit==1)        /* make sure we are not inside terminate already */
  1299. X     elog(newline),terminate();
  1300. X}
  1301. X                    /* an NFS secure exclusive file open */
  1302. Xxcreat(name,mode,tim,chowned)const char*const name;const mode_t mode;
  1303. X time_t*const tim;int*const chowned;
  1304. X{ char*p;int j= -2,i;
  1305. X  i=lastdirsep(name)-name;strncpy(p=malloc(i+UNIQnamelen),name,i);
  1306. X  if(unique(p,p+i,mode,verbose))       /* try and rename the unique filename */
  1307. X   { if(chowned)
  1308. X    *chowned=chown(p,uid,sgid);             /* try and chown it */
  1309. X     if(tim)
  1310. X      { struct stat stbuf;     /* return the filesystem time to the caller */
  1311. X    stat(p,&stbuf);*tim=stbuf.st_mtime;
  1312. X      }
  1313. X     j=myrename(p,name);
  1314. X   }
  1315. X  free(p);return j;
  1316. X}
  1317. X    /* if you've ever wondered what conditional compilation was good for */
  1318. X#ifndef fdlock                        /* watch closely :-) */
  1319. X#ifdef USEflock
  1320. X#ifndef SYS_FILE_H_MISSING
  1321. X#include <sys/file.h>
  1322. X#endif
  1323. X#define REITflock    1
  1324. X#else
  1325. X#define REITflock    0
  1326. X#endif /* USEflock */
  1327. Xstatic oldfdlock= -1;                    /* the fd we locked last */
  1328. X#ifndef NOfcntl_lock
  1329. Xstatic struct flock flck;        /* why can't it be a local variable? */
  1330. X#define REITfcntl    1
  1331. X#else
  1332. X#define REITfcntl    0
  1333. X#endif /* NOfcntl_lock */
  1334. X#ifdef USElockf
  1335. Xstatic long oldlockoffset;
  1336. X#define REITlockf    1
  1337. X#else
  1338. X#define REITlockf    0
  1339. X#endif /* USElockf */
  1340. X
  1341. Xfdlock(fd)
  1342. X{ int ret;
  1343. X#if REITfcntl+REITflock+REITlockf>1
  1344. X  for(;;nlog("Reiterating kernel-lock\n"),sleep((unsigned)locksleep))
  1345. X#endif
  1346. X   {
  1347. X#ifndef NOfcntl_lock
  1348. X     flck.l_type=F_WRLCK;flck.l_whence=SEEK_SET;flck.l_len=0;
  1349. X     flck.l_start=tell(fd);
  1350. X#endif
  1351. X#ifdef USElockf
  1352. X     oldlockoffset=tell(fd);
  1353. X#endif
  1354. X     lcking|=lck_KERNEL;
  1355. X#ifndef NOfcntl_lock
  1356. X     ret=fcntl(fd,F_SETLKW,&flck);
  1357. X#ifdef USElockf
  1358. X     if((ret|=lockf(fd,F_TLOCK,0L))&&(errno==EAGAIN||errno==EACCES||
  1359. X      errno==EWOULDBLOCK))
  1360. Xufcntl:
  1361. X      { flck.l_type=F_UNLCK;fcntl(fd,F_SETLK,&flck);continue;
  1362. X      }
  1363. X#ifdef USEflock
  1364. X     if((ret|=flock(fd,LOCK_EX|LOCK_NB))&&(errno==EAGAIN||errno==EACCES||
  1365. X      errno==EWOULDBLOCK))
  1366. X      { lockf(fd,F_ULOCK,0L);goto ufcntl;
  1367. X      }
  1368. X#endif /* USEflock */
  1369. X#else /* USElockf */
  1370. X#ifdef USEflock
  1371. X     if((ret|=flock(fd,LOCK_EX|LOCK_NB))&&(errno==EAGAIN||errno==EACCES||
  1372. X      errno==EWOULDBLOCK))
  1373. X      { flck.l_type=F_UNLCK;fcntl(fd,F_SETLK,&flck);continue;
  1374. X      }
  1375. X#endif /* USEflock */
  1376. X#endif /* USElockf */
  1377. X#else /* NOfcntl_lock */
  1378. X#ifdef USElockf
  1379. X     ret=lockf(fd,F_LOCK,0L);
  1380. X#ifdef USEflock
  1381. X     if((ret|=flock(fd,LOCK_EX|LOCK_NB))&&(errno==EAGAIN||errno==EACCES||
  1382. X      errno==EWOULDBLOCK))
  1383. X      { lockf(fd,F_ULOCK,0L);continue;
  1384. X      }
  1385. X#endif /* USEflock */
  1386. X#else /* USElockf */
  1387. X#ifdef USEflock
  1388. X     ret=flock(fd,LOCK_EX);
  1389. X#endif /* USEflock */
  1390. X#endif /* USElockf */
  1391. X#endif /* NOfcntl_lock */
  1392. X     oldfdlock=fd;lcking&=~lck_KERNEL;return ret;
  1393. X   }
  1394. X}
  1395. X
  1396. Xfdunlock P((void))
  1397. X{ int i;
  1398. X  if(oldfdlock<0)
  1399. X     return -1;
  1400. X  i=0;
  1401. X#ifdef USEflock
  1402. X  i|=flock(oldfdlock,LOCK_UN);
  1403. X#endif
  1404. X#ifdef USElockf
  1405. X  lseek(oldfdlock,oldlockoffset,SEEK_SET);i|=lockf(oldfdlock,F_ULOCK,0L);
  1406. X#endif
  1407. X#ifndef NOfcntl_lock
  1408. X  flck.l_type=F_UNLCK;i|=fcntl(oldfdlock,F_SETLK,&flck);
  1409. X#endif
  1410. X  oldfdlock= -1;return i;
  1411. X}
  1412. X#endif /* fdlock */
  1413. END_OF_FILE
  1414. if test 6399 -ne `wc -c <'procmail280/src/locking.c'`; then
  1415.     echo shar: \"'procmail280/src/locking.c'\" unpacked with wrong size!
  1416. fi
  1417. # end of 'procmail280/src/locking.c'
  1418. fi
  1419. echo shar: End of archive 4 \(of 11\).
  1420. cp /dev/null ark4isdone
  1421. MISSING=""
  1422. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  1423.     if test ! -f ark${I}isdone ; then
  1424.     MISSING="${MISSING} ${I}"
  1425.     fi
  1426. done
  1427. if test "${MISSING}" = "" ; then
  1428.     echo You have unpacked all 11 archives.
  1429.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1430. else
  1431.     echo You still need to unpack the following archives:
  1432.     echo "        " ${MISSING}
  1433. fi
  1434. ##  End of shell archive.
  1435. exit 0
  1436. -- 
  1437. Sincerely,                                  berg@pool.informatik.rwth-aachen.de
  1438.            Stephen R. van den Berg (AKA BuGless).    berg@physik.tu-muenchen.de
  1439.  
  1440. "Be spontaneous!"
  1441.  
  1442. exit 0 # Just in case...
  1443.