home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume43 / procmail / part09 < prev    next >
Encoding:
Internet Message Format  |  1994-07-05  |  53.9 KB

  1. From: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  2. Newsgroups: comp.sources.misc
  3. Subject: v43i064:  procmail - mail processing package v3.03, Part09/10
  4. Date: 5 Jul 1994 20:50:27 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <2vd2l3$iek@sparky.sterling.com>
  9. X-Md4-Signature: c7505ffa2c5a98fad39d9027a7859107
  10.  
  11. Submitted-by: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  12. Posting-number: Volume 43, Issue 64
  13. Archive-name: procmail/part09
  14. Environment: sendmail, ZMailer, smail, MMDF, mailsurr, UNIX, POSIX
  15. Supersedes: procmail: Volume 38, Issue 19-31
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  procmail-3.03/FEATURES procmail-3.03/Makefile
  22. #   procmail-3.03/Makefile.1 procmail-3.03/Manifest
  23. #   procmail-3.03/SmartList/README procmail-3.03/examples/2procmailrc
  24. #   procmail-3.03/src/common.c procmail-3.03/src/cstdio.c
  25. #   procmail-3.03/src/ecommon.c procmail-3.03/src/exopen.c
  26. #   procmail-3.03/src/fields.c procmail-3.03/src/misc.h
  27. #   procmail-3.03/src/procmail.h procmail-3.03/src/recommend.c
  28. #   procmail-3.03/src/sublib.c
  29. # Wrapped by kent@sparky on Tue Jul  5 20:42:15 1994
  30. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  31. echo If this archive is complete, you will see the following message:
  32. echo '          "shar: End of archive 9 (of 10)."'
  33. if test -f 'procmail-3.03/FEATURES' -a "${1}" != "-c" ; then 
  34.   echo shar: Will not clobber existing file \"'procmail-3.03/FEATURES'\"
  35. else
  36.   echo shar: Extracting \"'procmail-3.03/FEATURES'\" \(3953 characters\)
  37.   sed "s/^X//" >'procmail-3.03/FEATURES' <<'END_OF_FILE'
  38. XFeature summary for procmail:
  39. X    + It's less filling (i.e. small)
  40. X    + Very easy to install (rated PG6 :-)
  41. X    + Simple to maintain and configure because
  42. X      all you need is actually only ONE executable (procmail)
  43. X      and ONE configuration file (.procmailrc)
  44. X    + Is event driven (i.e. gets invoked automagically when mail arrives)
  45. X    + Does not use *any* temporary files
  46. X    + Uses standard egrep regular expressions
  47. X    + It poses a very low impact on your system's resources
  48. X      (it's 1.4 times faster than the average /bin/mail in user-cpu
  49. X       time)
  50. X    + Allows for very-easy-to-use yes-no decisions on where the mail
  51. X      should go (can take the size of the mail into consideration)
  52. X    + Also allows for neural-net-type weighted scoring of mails
  53. X    + Filters, delivers and forwards mail *reliably*
  54. X    + Provides a reliable hook (you might even say anchor :-) for any
  55. X      programs or shell scripts you may wish to start upon mail arrival
  56. X    + Performs heroically under even the worst conditions
  57. X      (file system full, out of swap space, process table full,
  58. X      file table full, missing support files, unavailable executables,
  59. X      denied permissions) and tries to deliver the mail somehow anyway
  60. X    + Absolutely undeliverable mail (after trying every trick in the book)
  61. X      will bounce back to the sender (or not, your choice)
  62. X    + Is one of the few mailers to perform reliable mailbox locking across
  63. X      NFS as well (DON'T use NFS mounted mailboxes WITHOUT installing
  64. X      procmail; you may lose valuable mail one day)
  65. X    + Supports four mailfolder standards: single file folders (standard
  66. X      and nonstandard VNIX format), directory folders that contain one file
  67. X      per message, or the similar MH directory folders (numbered files)
  68. X    + Variable assignment and substitution is an extremely complete subset
  69. X      of the standard /bin/sh syntax
  70. X    + Provides a mail log file, which logs all mail arrival, shows
  71. X      in summary whence it came, what it was about, where it went (what
  72. X      folder) and how long (in bytes) it was
  73. X    + Uses this log file to display a wide range of diagnostic and error
  74. X      messages (if something went wrong)
  75. X    + Does not impose *any* limits on line lengths, mail length (as long
  76. X      as memory permits), or the use of any character (any 8-bit character,
  77. X      including '\0' is allowed) in the mail
  78. X    + It has man pages (boy, does *it* have man pages)
  79. X    + Procmail can be used as a local delivery agent with comsat/biff
  80. X      support (*fully* downwards compatible with /bin/mail); in which case
  81. X      it can heal your system mailbox, if something messes up the
  82. X      permissions
  83. X    + Secure system mailbox handling (contrary to several well known
  84. X      /bin/mail implementations)
  85. X    + Provides for a controlled execution of programs and scripts from
  86. X      the aliases file (i.e. under defined user ids)
  87. X    + Allows you to painlessly shift the system mailboxes into the
  88. X      user's home directories
  89. X    + It runs on virtually all (old and future) operating systems which
  90. X      names start with a 'U' or end in an 'X' :-) (i.e. extremely portable
  91. X      code; POSIX, ANSI C and K&R conforming)
  92. X    + Is clock skew immune (e.g. in the case of NFS mounted mailboxes)
  93. X    + Can be used as a general mailfilter for whole groups of messages
  94. X      (e.g. when called from within sendmail.cf rules).
  95. X    + Works with (among others?) sendmail, smail, MMDF and mailsurr
  96. X
  97. XFeature summary for formail:
  98. X    + Can generate auto-reply headers
  99. X    + Can convert mail into standard mailbox format (so that you can
  100. X      process it with standard mail programs)
  101. X    + Can split up mailboxes into the individual messages
  102. X    + Can split up digests into the individual messages
  103. X    + Can split up saved articles into the individual articles
  104. X    + Can do simple header munging/extraction
  105. X    + Can extract messages from mailboxes
  106. X    + Can recognise duplicate messages
  107. X
  108. XFeature summary for lockfile:
  109. X    + Provides NFS-secure lockfiles to shell script programmers
  110. X    + Gives normal users the ability to lock their system mailbox,
  111. X      regardless of the permissions on the mail-spool directory
  112. END_OF_FILE
  113.   if test 3953 -ne `wc -c <'procmail-3.03/FEATURES'`; then
  114.     echo shar: \"'procmail-3.03/FEATURES'\" unpacked with wrong size!
  115.   fi
  116.   # end of 'procmail-3.03/FEATURES'
  117. fi
  118. if test -f 'procmail-3.03/Makefile' -a "${1}" != "-c" ; then 
  119.   echo shar: Will not clobber existing file \"'procmail-3.03/Makefile'\"
  120. else
  121.   echo shar: Extracting \"'procmail-3.03/Makefile'\" \(4043 characters\)
  122.   sed "s/^X//" >'procmail-3.03/Makefile' <<'END_OF_FILE'
  123. X#$Id: Makefile,v 1.56 1994/06/01 18:52:01 berg Exp $
  124. X
  125. X# change BASENAME to your home directory if need be
  126. XBASENAME = /usr/local
  127. X
  128. X# You can predefine ARCHITECTURE to a bin directory suffix
  129. XARCHITECTURE=
  130. X#ARCHITECTURE=.sun4
  131. X
  132. XBINDIR      = $(BASENAME)/bin$(ARCHITECTURE)
  133. XMANDIR      = $(BASENAME)/man
  134. X# MAN1SUFFIX for regular utility manuals
  135. XMAN1SUFFIX= 1
  136. X# MAN5SUFFIX for file-format descriptions
  137. XMAN5SUFFIX= 5
  138. XMAN1DIR      = $(MANDIR)/man$(MAN1SUFFIX)
  139. XMAN5DIR      = $(MANDIR)/man$(MAN5SUFFIX)
  140. X
  141. X##############################
  142. X# Things that can be made are:
  143. X#
  144. X# init (or makefiles)    Performs some preliminary sanity checks on your system
  145. X#            and generates Makefiles accordingly
  146. X# bins            Preinstalls only the binaries to ./new
  147. X# mans            Preinstalls only the man pages to ./new
  148. X# all            Does both
  149. X# install.bin        Installs the binaries from ./new to $(BINDIR)
  150. X# install.man        Installs the man pages from ./new to $(MAN[15]DIR)
  151. X# install        Does both
  152. X# recommend        Show some recommended suid/sgid modes
  153. X# install-suid        Impose the modes shown by 'make recommend'
  154. X# clean            Attempts to restore the package to pre-make state
  155. X# realclean        Attempts to restore the package to pre-make-init state
  156. X# deinstall        Removes any previously installed binaries and man
  157. X#            pages from your system by careful surgery
  158. X# autoconf.h        Will list your system's anomalies
  159. X# procmail        Preinstalls just all procmail related stuff to ./new
  160. X# formail        Preinstalls just all formail related stuff to ./new
  161. X# lockfile        Preinstalls just all lockfile related stuff to ./new
  162. X# setid            Creates the setid binary needed by the SmartList
  163. X#            installation
  164. X########################
  165. X
  166. X# Makefile.0 - mark, don't (re)move this, a sed script needs it
  167. X
  168. XLOCKINGTEST=__defaults__
  169. X
  170. X#LOCKINGTEST=/tmp .    # Uncomment and add any directories you see fit.
  171. X#            If LOCKINGTEST is defined, autoconf will NOT
  172. X#            prompt you to enter additional directories.
  173. X#            See INSTALL for more information about the
  174. X#            significance of the locking tests.
  175. X
  176. X########################################################################
  177. X# Only edit below this line if you *think* you know what you are doing #
  178. X########################################################################
  179. X
  180. X#LOCKINGTEST=100    # Uncomment (and change) if you think you know
  181. X#            it better than the autoconf lockingtests.
  182. X#            This will cause the lockingtests to be hotwired.
  183. X#            100    to enable fcntl()
  184. X#            010    to enable lockf()
  185. X#            001    to enable flock()
  186. X#            Or them together to get the desired combination.
  187. X
  188. X# Optional system libraries we search for
  189. XSEARCHLIBS = -lm -ldir -lx -lsocket -lnet -linet -lnsl_s -lnsl_i -lnsl -lsun \
  190. X -lgen -lsockdns
  191. X#            -lresolv    # not really needed, is it?
  192. X
  193. X# Informal list of directories where we look for the libraries in SEARCHLIBS
  194. XLIBPATHS=/lib /usr/lib /usr/local/lib
  195. X
  196. XGCC_WARNINGS = -O2 -pedantic -Wimplicit -Wreturn-type -Wunused -Wformat \
  197. X -Wtraditional -Wshadow -Wid-clash-6 -Wpointer-arith -Wconversion \
  198. X -Waggregate-return #-Wuninitialized
  199. X
  200. X# The place to put your favourite extra cc flag
  201. XCFLAGS0 = -O #$(GCC_WARNINGS)
  202. XLDFLAGS0= -s
  203. X
  204. XCFLAGS1 = $(CFLAGS0) #-posix -Xp
  205. XLDFLAGS1= $(LDFLAGS0) #-lcposix
  206. X
  207. X####CC    = cc # gcc
  208. X# object file extension
  209. XO    = o
  210. XRM    = /bin/rm -f
  211. XMV    = mv -f
  212. XLN    = ln
  213. XBSHELL    = /bin/sh
  214. XINSTALL = cp
  215. XDEVNULL = /dev/null
  216. X
  217. XSUBDIRS = src man
  218. XBINSS    = procmail lockfile formail mailstat
  219. XMANS1S    = procmail formail lockfile
  220. XMANS5S    = procmailrc procmailsc procmailex
  221. X
  222. X# Makefile - mark, don't (re)move this, a sed script needs it
  223. X
  224. XHIDEMAKE=$(MAKE)
  225. X
  226. Xall: init
  227. X    $(HIDEMAKE) make $@
  228. X
  229. Xmake:
  230. X    @$(BSHELL) -c "exit 0"
  231. X
  232. X.PRECIOUS: Makefile
  233. X
  234. Xinit:
  235. X    $(BSHELL) ./initmake $(BSHELL) "$(SHELL)" "$(RM)" "$(MV)" "$(LN)" \
  236. X     "$(SEARCHLIBS)" \
  237. X     "$(LIBPATHS)" \
  238. X     $(DEVNULL) "$(HIDEMAKE)" $(O) \
  239. X     "$(CC)" "$(CFLAGS1)" "$(LDFLAGS1)" "$(BINSS)" \
  240. X     "$(MANS1S)" "$(MANS5S)" "$(SUBDIRS)" \
  241. X     "$(BINDIR)"
  242. X
  243. Xmakefiles makefile Makefiles Makefile: init
  244. X    @$(BSHELL) -c "exit 0"
  245. X
  246. Xbins mans install.bin install.man install recommend install-suid clean setid \
  247. Xrealclean veryclean clobber deinstall autoconf.h $(BINSS) multigram: init
  248. X    $(HIDEMAKE) make $@
  249. END_OF_FILE
  250.   if test 4043 -ne `wc -c <'procmail-3.03/Makefile'`; then
  251.     echo shar: \"'procmail-3.03/Makefile'\" unpacked with wrong size!
  252.   fi
  253.   # end of 'procmail-3.03/Makefile'
  254. fi
  255. if test -f 'procmail-3.03/Makefile.1' -a "${1}" != "-c" ; then 
  256.   echo shar: Will not clobber existing file \"'procmail-3.03/Makefile.1'\"
  257. else
  258.   echo shar: Extracting \"'procmail-3.03/Makefile.1'\" \(4618 characters\)
  259.   sed "s/^X//" >'procmail-3.03/Makefile.1' <<'END_OF_FILE'
  260. X#$Id: Makefile.1,v 1.36 1994/06/06 17:33:15 berg Exp $
  261. X
  262. XHIDEMAKE=$(MAKE)
  263. X
  264. Xall: bins mans recommend
  265. X
  266. Xmake:
  267. X    @$(SHELL) -c "exit 0"
  268. X
  269. X.PRECIOUS: Makefile
  270. X
  271. Xbins: config.check src/Makefile
  272. X    cd src; $(MAKE) $(NBINS)
  273. X
  274. Xmans: config.check man/Makefile
  275. X    cd man; $(MAKE) $(NMANS)
  276. X
  277. Xautoconf.h: src/Makefile src/autoconf
  278. X    cd src; $(MAKE) ../$@
  279. X
  280. Xprocmail: config.check src/Makefile man/Makefile
  281. X    cd src; $(MAKE) ../new/$@ ../new/mailstat
  282. X    cd man; $(MAKE) ../new/$@.1 ../new/$@rc.5 ../new/$@ex.5 ../new/$@sc.5
  283. X
  284. Xmailstat: procmail
  285. X
  286. Xformail lockfile: config.check src/Makefile man/Makefile
  287. X    cd src; $(MAKE) ../new/$@
  288. X    cd man; $(MAKE) ../new/$@.1
  289. X
  290. Xsetid multigram: config.check src/Makefile man/Makefile
  291. X    cd src; $(MAKE) $@
  292. X
  293. Xconfig.check: config.h
  294. X    echo Housekeeping file >$@
  295. X    @-mkdir new 2>$(DEVNULL); exit 0
  296. X    @-if $(FGREP) -n -e '`' config.h $(DEVNULL) | $(FGREP) -v EOFName ; \
  297. X     then \
  298. X     echo;echo '    ^^^^^^^^^^^^^^^^^^^^ WARNING ^^^^^^^^^^^^^^^^^^^^^';\
  299. X          echo '    * Having backquotes in there could be unhealthy! *';\
  300. X     echo;fi;exit 0
  301. X
  302. Xrecommend: src/Makefile
  303. X    @cd src; $(MAKE) $@ >$(DEVNULL)
  304. X    @echo ================================================================\
  305. X===============
  306. X    @if $(FGREP) CF_no_procmail_yet autoconf.h >$(DEVNULL); \
  307. X     then echo If you are a system administrator you should consider \
  308. Xintegrating procmail; echo into the mail-delivery system -- for advanced \
  309. Xfunctionality, speed AND; echo SECURITY "--.  For" more information about \
  310. Xthis topic you should look in the; echo examples/advanced file.; elif \
  311. X     cat /usr/lib/sendmail.cf /etc/sendmail.cf 2>$(DEVNULL) | \
  312. X     grep 'Mlocal.*procmail.*F=[a-zA-Z]*u' >$(DEVNULL) ; then \
  313. X     echo The recommendation for the sendmail.cf entry of procmail has \
  314. Xchanged.; echo I suggest you remove the '`u'"'"-flag 'like in:'; echo ; \
  315. X      sed -n 's/.*\(Mlocal.*procmail.*F=[a-zA-Z]*\)u/\1/p' `if test -f \
  316. X     /etc/sendmail.cf; then echo /etc/sendmail.cf; else \
  317. X     echo /usr/lib/sendmail.cf; fi`; fi
  318. X    @echo
  319. X    @echo \
  320. X     "Also, HIGHLY RECOMMENDED (type 'make install-suid' to execute it):"
  321. X    @echo
  322. X    @src/$@ $(BINDIR)/procmail $(BINDIR)/lockfile >suid.sh
  323. X    @src/$@ $(BINDIR)/procmail $(BINDIR)/lockfile
  324. X    @echo ================================================================\
  325. X===============
  326. X
  327. Xsuid.sh: recommend
  328. X
  329. Xinstall-suid: suid.sh install.bin
  330. X    @cat suid.sh
  331. X    @$(SHELL) ./suid.sh
  332. X    @cd $(BINDIR); echo Installed in $(BINDIR); ls -l $(BINSS)
  333. X
  334. X$(MANS): mans
  335. X
  336. X$(BINS): bins
  337. X
  338. X$(BASENAME):
  339. X    mkdir $(BASENAME)
  340. X
  341. Xinstall.man: $(MANS) $(BASENAME)
  342. X    @-mkdir $(MANDIR) 2>$(DEVNULL); exit 0
  343. X    @-mkdir $(MAN1DIR) 2>$(DEVNULL); exit 0
  344. X    @-mkdir $(MAN5DIR) 2>$(DEVNULL); exit 0
  345. X    @chmod 0644 $(MANS)
  346. X    @for a in $(MANS1S); \
  347. X      do $(INSTALL) new/$$a.1 $(MAN1DIR)/$$a.$(MAN1SUFFIX); done
  348. X    @for a in $(MANS5S); \
  349. X      do $(INSTALL) new/$$a.5 $(MAN5DIR)/$$a.$(MAN5SUFFIX); done
  350. X    echo Housekeeping file >install.man
  351. X
  352. Xinstall.bin: $(BINS) $(BASENAME)
  353. X    @-mkdir $(BINDIR) 2>$(DEVNULL); exit 0
  354. X    @chmod 0755 $(BINS)
  355. X    $(INSTALL) $(BINS) $(BINDIR)
  356. X    @-dirname / >$(DEVNULL) || $(INSTALL) examples/dirname $(BINDIR)
  357. X    echo Housekeeping file >install.bin
  358. X
  359. Xinstall:
  360. X    @$(MAKE) install.man install.bin
  361. X    @echo
  362. X    @cd $(BINDIR); echo Installed in $(BINDIR); ls -l $(BINSS)
  363. X    @cd $(MAN1DIR); echo Installed in $(MAN1DIR); ls -l $(MANS1)
  364. X    @cd $(MAN5DIR); echo Installed in $(MAN5DIR); ls -l $(MANS5)
  365. X    @$(MAKE) recommend
  366. X
  367. Xdeinstall:
  368. X    @echo ============================= Deinstalling the procmail package.
  369. X    @$(RM) install.man install.bin
  370. X    @echo ============================= Checking if everything was removed:
  371. X    @-cd $(BINDIR); $(RM) $(BINSS); ls -l $(BINSS); exit 0
  372. X    @-cd $(MAN1DIR); $(RM) $(MANS1); ls -l $(MANS1); exit 0
  373. X    @-cd $(MAN5DIR); $(RM) $(MANS5); ls -l $(MANS5); exit 0
  374. X    @echo ============================= Ready.
  375. X
  376. Xclean: config.check
  377. X    -for a in $(SUBDIRS); do cd $$a; $(MAKE) $@; cd ..; done; exit 0
  378. X    cd SmartList; $(RM) targetdir.h targetdir.tmp install.list
  379. X    $(RM) $(MANS) $(BINS) install.man install.bin suid.sh _Makefile \
  380. X     *core* autoconf.h.tmp
  381. X
  382. Xrealclean: clean _init
  383. X    $(RM) config.check
  384. X    -rmdir new; exit 0
  385. X    -for a in $(SUBDIRS); do $(MV) $$a/Makefile.init $$a/Makefile; done; \
  386. X     exit 0
  387. X
  388. Xveryclean clobber: realclean
  389. X
  390. X_init:
  391. X    sed -e '/^# Makefile.1 - mark/,$$ d' <Makefile >_Makefile
  392. X    cat Makefile.0 >>_Makefile
  393. X    $(MV) _Makefile Makefile
  394. X    $(RM) Makefile.0
  395. X
  396. Xman/Makefile: man/Makefile.0 Makefile
  397. X
  398. Xsrc/Makefile: src/Makefile.0 Makefile
  399. X
  400. Xman/Makefile src/Makefile Makefile: Makefile.1 initmake
  401. X    sed -e '/^# Makefile.1 - mark/,$$ d' <Makefile >_Makefile
  402. X    cat Makefile.0 >>_Makefile
  403. X    $(MV) _Makefile Makefile
  404. X    $(RM) Makefile.0
  405. X    $(HIDEMAKE) init
  406. X
  407. Xinit makefiles Makefiles makefile: man/Makefile src/Makefile
  408. END_OF_FILE
  409.   if test 4618 -ne `wc -c <'procmail-3.03/Makefile.1'`; then
  410.     echo shar: \"'procmail-3.03/Makefile.1'\" unpacked with wrong size!
  411.   fi
  412.   # end of 'procmail-3.03/Makefile.1'
  413. fi
  414. if test -f 'procmail-3.03/Manifest' -a "${1}" != "-c" ; then 
  415.   echo shar: Will not clobber existing file \"'procmail-3.03/Manifest'\"
  416. else
  417.   echo shar: Extracting \"'procmail-3.03/Manifest'\" \(2072 characters\)
  418.   sed "s/^X//" >'procmail-3.03/Manifest' <<'END_OF_FILE'
  419. XMakefile    We all know what that is.
  420. XREADME        Important, read it.
  421. XINSTALL        A description of what has to be done to install procmail.
  422. X
  423. Xconfig.h    The file to edit if you want to change, yes, the configuration.
  424. X
  425. XFAQ        Lists the things you are too lazy to figure out yourself.
  426. XHISTORY        Recent and ancient changes, features (or bugs) documented.
  427. XFEATURES    A summary of all the things procmail is particularly good at.
  428. XManifest    You guessed it.
  429. Xinitmake    A shell script that performs some preliminary tests on your
  430. X        system and prepares the Makefiles.
  431. XMakefile.1    Used by initmake to customise the Makefile.
  432. X
  433. Xsrc/*        The C-sources (in general).
  434. Xsrc/Makefile.0    Used by initmake to customise the Makefile.
  435. X
  436. Xsrc/includes.h    System include files are all referenced here.
  437. Xsrc/autoconf    The shell script that seizes your compiler and machine,
  438. X        and then creates a file called autoconf.h describing the
  439. X        kludges that are going to be applied for your installation.
  440. X
  441. Xnew/*        After a "make", all the files that will be installed can be
  442. X        found here (for inspection, if you like).
  443. X
  444. Xman/*        Yes, the man pages (made in a labour camp) and two additional
  445. X        files which make these man pages auto-adapting.
  446. Xman/Makefile.0    Used by initmake to customise the Makefile.
  447. Xexamples/mailstat
  448. X        A summary generator for procmail generated logfiles.
  449. Xexamples/?procmailrc
  450. X        Sample .procmailrc files.
  451. Xexamples/?rmail
  452. X        Sample shell scripts that demonstrate how to use
  453. X        lockfiles while reading the mail (to ensure mail integrity
  454. X        as soon as you exit the mail program).
  455. Xexamples/dirname
  456. X        Substitute dirname program, for the deprived.
  457. Xexamples/forward
  458. X        A sample .forward file (MMDF users should disregard this file
  459. X        and look in the man page).
  460. Xexamples/advanced
  461. X        Some extra info for network mounted mailboxes, examples of
  462. X        advanced .procmailrc expressions and using procmail as
  463. X        a local delivery agent.
  464. XSmartList/*    All you need to start up lots of mailinglists.
  465. XSmartList/FEATURES
  466. X        A summary of all the SmartList package will take care of.
  467. XSmartList/INTRO
  468. X        Comprehensive introduction on maintaining a mailinglist.
  469. END_OF_FILE
  470.   if test 2072 -ne `wc -c <'procmail-3.03/Manifest'`; then
  471.     echo shar: \"'procmail-3.03/Manifest'\" unpacked with wrong size!
  472.   fi
  473.   # end of 'procmail-3.03/Manifest'
  474. fi
  475. if test -f 'procmail-3.03/SmartList/README' -a "${1}" != "-c" ; then 
  476.   echo shar: Will not clobber existing file \"'procmail-3.03/SmartList/README'\"
  477. else
  478.   echo shar: Extracting \"'procmail-3.03/SmartList/README'\" \(2108 characters\)
  479.   sed "s/^X//" >'procmail-3.03/SmartList/README' <<'END_OF_FILE'
  480. XThe SmartList mailinglist package has been built on top of the procmail
  481. Xmail processing package.  In order to install it you'll need the source
  482. Xof the procmail package as well.
  483. X
  484. XIf you now have just the procmail sources, get the SmartList sources and
  485. Xunpack them on top of the procmail source tree.
  486. XIf you now have just the SmartList sources, get the procmail sources and
  487. Xunpack them on top of the SmartList source tree.
  488. XSee below on where to get the missing part.
  489. X
  490. XThe two source packages should blend together with only this README file
  491. Xand the FEATURES file being duplicated.
  492. X----------------------
  493. XFor installation instructions see the INSTALL file.
  494. X----------------------
  495. XSmartList mailinglist management package.
  496. XCopyright (c) 1993-1994, S.R. van den Berg, The Netherlands.
  497. X
  498. XSome legal stuff:
  499. X
  500. XUse this software package at your own risk.  The programmer cannot
  501. Xbe held liable for any incurred damages, directly or indirectly due to
  502. Xthe use or inability to use this software.
  503. X
  504. XYou are encouraged to distribute this package freely.  This package is
  505. Xhowever not to be sold (minor transfer costs excepted) or included in
  506. Xany commercially sold software package (if you want to do this anyway,
  507. Xcontact me (address below), and we'll work something out).
  508. X
  509. XIf you distribute it, please leave the package intact.    You are allowed to
  510. Xtake parts from this distribution and distribute these separately as long
  511. Xas you retain the copyright messages.  If you redistribute any part of this
  512. Xpackage in a modified form, be sure to mark the parts you changed.
  513. XIf you have some important changes that might be useful to the rest of the
  514. Xworld, contact me instead.
  515. X----------------------
  516. XA recent version of both packages can be picked up at various
  517. Xcomp.sources.misc archives.
  518. XThe latest versions can be obtained directly from the ftp-archive at:
  519. X
  520. X    ftp.informatik.rwth-aachen.de
  521. X
  522. Xas (g)zipped tar files:       /pub/packages/procmail/procmail.tar.gz
  523. X               /pub/packages/procmail/SmartList.tar.gz
  524. Xas compressed tar files:   /pub/packages/procmail/procmail.tar.Z
  525. X               /pub/packages/procmail/SmartList.tar.Z
  526. X----------------------
  527. END_OF_FILE
  528.   if test 2108 -ne `wc -c <'procmail-3.03/SmartList/README'`; then
  529.     echo shar: \"'procmail-3.03/SmartList/README'\" unpacked with wrong size!
  530.   fi
  531.   # end of 'procmail-3.03/SmartList/README'
  532. fi
  533. if test -f 'procmail-3.03/examples/2procmailrc' -a "${1}" != "-c" ; then 
  534.   echo shar: Will not clobber existing file \"'procmail-3.03/examples/2procmailrc'\"
  535. else
  536.   echo shar: Extracting \"'procmail-3.03/examples/2procmailrc'\" \(1989 characters\)
  537.   sed "s/^X//" >'procmail-3.03/examples/2procmailrc' <<'END_OF_FILE'
  538. X# Please check if all the paths in PATH are reachable, remove the ones that
  539. X# are not.
  540. X
  541. XPATH=$HOME/bin:/usr/bin:/usr/ucb:/bin:/usr/local/bin:.
  542. XMAILDIR=$HOME/Mail    # You'd better make sure it exists
  543. XDEFAULT=$MAILDIR/mbox
  544. X            # We don't use a global lockfile here now.
  545. X            # Instead we use local lockfiles everywhere.
  546. X            # This allows mail to arrive in all mailboxes
  547. X            # concurrently, or allows you to read one mailbox
  548. X            # while mail arrives in another.
  549. X
  550. X# The next recipe will split up Digests into their individual messages.
  551. X# Don't do this if you use a global lockfile before this recipe (deadlock)
  552. X
  553. X:0
  554. X* ^Subject:.*Digest
  555. X|formail +1 -d -s procmail
  556. X
  557. XLOGFILE=$MAILDIR/from        # Put it here, in order to avoid logging
  558. X                # the arrival of the digest.
  559. X
  560. X# An alternative and probably more efficient solution to splitting up a digest
  561. X# would be (only works for standard format mailbox files though):
  562. X
  563. X:0:
  564. X* ^Subject:.*Other Digest
  565. X|formail +1 -ds cat >>this_lists_mailbox
  566. X
  567. X# Notice the double : in the next recipe, this will cause a lockfile
  568. X# named "$MAILDIR/todd.lock" to be used if and only if this mail is going
  569. X# into the file "todd".
  570. X
  571. X:0:                # Anything from thf
  572. X* ^From.*thf@somewhere.someplace
  573. Xtodd                # will go to $MAILDIR/todd
  574. X
  575. X
  576. X# The next recipe will likewise use $MAILDIR/uunetbox.lock as a lock file.
  577. X
  578. X:0:                # Anything from people at uunet
  579. X* ^From.*@uunet
  580. Xuunetbox            # will go to $MAILDIR/uunetbox
  581. X
  582. X
  583. X# And here the lockfile will be $MAILDIR/henries.lock of course.
  584. X
  585. X:0:                # Anything from Henry
  586. X* ^From.*henry
  587. Xhenries                # will go to $MAILDIR/henries
  588. X
  589. X
  590. X# But you can specify any lockfile you want, like "myfile".  The following
  591. X# recipe will use "$MAILDIR/myfile" as the lock file.
  592. X
  593. X:0:myfile            # All 'questions' will go to
  594. X* ^Subject:.*questions
  595. Xtoread                # $MAILDIR/toread
  596. X
  597. X# Anything that has not been delivered by now will go to $DEFAULT
  598. X
  599. X# After procmail sees the end of the rcfile, it pretends that it sees a
  600. X# LOCKFILE=$DEFAULT$LOCKEXT
  601. X# Therefore $DEFAULT is always locked.
  602. END_OF_FILE
  603.   if test 1989 -ne `wc -c <'procmail-3.03/examples/2procmailrc'`; then
  604.     echo shar: \"'procmail-3.03/examples/2procmailrc'\" unpacked with wrong size!
  605.   fi
  606.   # end of 'procmail-3.03/examples/2procmailrc'
  607. fi
  608. if test -f 'procmail-3.03/src/common.c' -a "${1}" != "-c" ; then 
  609.   echo shar: Will not clobber existing file \"'procmail-3.03/src/common.c'\"
  610. else
  611.   echo shar: Extracting \"'procmail-3.03/src/common.c'\" \(2572 characters\)
  612.   sed "s/^X//" >'procmail-3.03/src/common.c' <<'END_OF_FILE'
  613. X/************************************************************************
  614. X *    Some routines common to procmail and formail            *
  615. X *                                    *
  616. X *    Copyright (c) 1990-1994, S.R. van den Berg, The Netherlands    *
  617. X *    #include "../README"                        *
  618. X ************************************************************************/
  619. X#ifdef RCS
  620. Xstatic /*const*/char rcsid[]=
  621. X "$Id: common.c,v 1.19 1994/06/28 16:56:01 berg Exp $";
  622. X#endif
  623. X#include "procmail.h"
  624. X#include "sublib.h"
  625. X#include "robust.h"
  626. X#include "shell.h"
  627. X#include "misc.h"
  628. X#include "common.h"
  629. X
  630. Xvoid shexec(argv)const char*const*argv;
  631. X{ int i;char**newargv;const char**p;
  632. X#ifdef SIGXCPU
  633. X  signal(SIGXCPU,SIG_DFL);signal(SIGXFSZ,SIG_DFL);
  634. X#endif
  635. X#ifdef SIGLOST
  636. X  signal(SIGLOST,SIG_DFL);
  637. X#endif                        /* or is it a shell script ? */
  638. X  signal(SIGPIPE,SIG_DFL);execvp(*argv,(char*const*)argv);
  639. X  for(p=(const char**)argv,i=1;i++,*p++;);          /* count the arguments */
  640. X  newargv=malloc(i*sizeof*p);
  641. X  for(*(p=(const char**)newargv)=binsh;*++p= *argv++;);
  642. X  execve(*newargv,newargv,environ);          /* no shell script? -> trouble */
  643. X  nlog("Failed to execute");logqnl(*argv);exit(EX_UNAVAILABLE);
  644. X}
  645. X
  646. Xvoid detab(p)char*p;
  647. X{ while(p=strpbrk(p,"\t\n\v\f\r"))
  648. X     *p=' ';                 /* take out all tabs and other specials */
  649. X}
  650. X
  651. Xchar*skpspace(chp)const char*chp;
  652. X{ for(;;chp++)
  653. X     switch(*chp)
  654. X      { case ' ':case '\t':
  655. X       continue;
  656. X    default:
  657. X       return (char*)chp;
  658. X      }
  659. X}
  660. X
  661. X#ifdef NOstrcspn
  662. Xint strcspn(whole,sub)const char*const whole,*const sub;
  663. X{ const register char*p;
  664. X  p=whole;
  665. X  while(*p&&!strchr(sub,*p))
  666. X     p++;
  667. X  return p-whole;
  668. X}
  669. X#endif
  670. X
  671. Xvoid ultstr(minwidth,val,dest)unsigned long val;char*dest;
  672. X{ int i;unsigned long j;
  673. X  j=val;i=0;                       /* a beauty, isn't it :-) */
  674. X  do i++;                       /* determine needed width */
  675. X  while(j/=10);
  676. X  while(--minwidth>=i)                 /* fill up any excess width */
  677. X     *dest++=' ';
  678. X  *(dest+=i)='\0';
  679. X  do *--dest='0'+val%10;              /* display value backwards */
  680. X  while(val/=10);
  681. X}
  682. X
  683. Xint waitfor(pid)const pid_t pid;          /* wait for a specific process */
  684. X{ int i;pid_t j;
  685. X  while(pid!=(j=wait(&i))||WIFSTOPPED(i))
  686. X     if(-1==j)
  687. X    return NO_PROCESS;
  688. X     else if(!pid)
  689. X    break;
  690. X  return lexitcode=WIFEXITED(i)?WEXITSTATUS(i):-WTERMSIG(i);
  691. X}
  692. X
  693. Xint strnIcmp(a,b,l)register const char*a,*b;register size_t l;
  694. X{ unsigned i,j;
  695. X  if(l)                         /* case insensitive strncmp */
  696. X     do
  697. X      { while(*a&&*a==*b&&--l)
  698. X       a++,b++;
  699. X    if(!l)
  700. X       break;
  701. X    if((i= *a++)-'A'<='Z'-'A')
  702. X       i+='a'-'A';
  703. X    if((j= *b++)-'A'<='Z'-'A')
  704. X       j+='a'-'A';
  705. X    if(j!=i)
  706. X       return i>j?1:-1;
  707. X      }
  708. X     while(i&&j&&--l);
  709. X  return 0;
  710. X}
  711. END_OF_FILE
  712.   if test 2572 -ne `wc -c <'procmail-3.03/src/common.c'`; then
  713.     echo shar: \"'procmail-3.03/src/common.c'\" unpacked with wrong size!
  714.   fi
  715.   # end of 'procmail-3.03/src/common.c'
  716. fi
  717. if test -f 'procmail-3.03/src/cstdio.c' -a "${1}" != "-c" ; then 
  718.   echo shar: Will not clobber existing file \"'procmail-3.03/src/cstdio.c'\"
  719. else
  720.   echo shar: Extracting \"'procmail-3.03/src/cstdio.c'\" \(4014 characters\)
  721.   sed "s/^X//" >'procmail-3.03/src/cstdio.c' <<'END_OF_FILE'
  722. X/************************************************************************
  723. X *    Custom standard-io library                    *
  724. X *                                    *
  725. X *    Copyright (c) 1990-1994, S.R. van den Berg, The Netherlands    *
  726. X *    #include "../README"                        *
  727. X ************************************************************************/
  728. X#ifdef RCS
  729. Xstatic /*const*/char rcsid[]=
  730. X "$Id: cstdio.c,v 1.26 1994/06/28 16:56:03 berg Exp $";
  731. X#endif
  732. X#include "procmail.h"
  733. X#include "robust.h"
  734. X#include "cstdio.h"
  735. X#include "misc.h"
  736. X
  737. Xstatic uchar rcbuf[STDBUF],*rcbufp,*rcbufend;      /* buffer for custom stdio */
  738. Xstatic off_t blasttell;
  739. Xstatic struct dyna_long inced;                  /* includerc stack */
  740. Xstruct dynstring*incnamed;
  741. X
  742. Xvoid pushrc(name)const char*const name;              /* open include rcfile */
  743. X{ struct stat stbuf;                       /* only if size>0 */
  744. X  if(*name&&(stat(name,&stbuf)||!S_ISREG(stbuf.st_mode)||stbuf.st_size))
  745. X   { app_val(&inced,rcbufp?(off_t)(rcbufp-rcbuf):(off_t)0);     /* save old */
  746. X     app_val(&inced,blasttell);app_val(&inced,(off_t)rc);   /* position & fd */
  747. X     if(bopen(name)<0)                  /* and try to open the new one */
  748. X    readerr(name),poprc();               /* we couldn't, so restore rc */
  749. X   }
  750. X}
  751. X
  752. Xvoid duprcs P((void))
  753. X{ size_t i;struct dynstring*dp;
  754. X  dp=incnamed;rclose(rc);
  755. X  if(0>(rc=ropen(dp->ename,O_RDONLY,0)))
  756. X     goto dupfailed;
  757. X  lseek(rc,blasttell+STDBUF,SEEK_SET);
  758. X  for(i=inced.filled;dp=dp->enext,i;i-=2)
  759. X   { int fd;
  760. X     rclose(inced.offs[--i]);
  761. X     if(0>(fd=ropen(dp->ename,O_RDONLY,0)))
  762. Xdupfailed:
  763. X    nlog("Lost"),logqnl(dp->ename),exit(EX_NOINPUT);
  764. X     inced.offs[i]=fd;
  765. X   }
  766. X}
  767. X
  768. Xstatic void closeonerc P((void))
  769. X{ struct dynstring*last;
  770. X  if(rc>=0)
  771. X     rclose(rc),rc= -1,last=incnamed,incnamed=last->enext,free(last);
  772. X}
  773. X
  774. Xint poprc P((void))
  775. X{ closeonerc();                         /* close it in any case */
  776. X  if(skiprc)
  777. X     skiprc=0,nlog("Missing closing brace\n");
  778. X  if(!inced.filled)                  /* include stack is empty? */
  779. X     return 0;          /* restore rc, seekpos, prime rcbuf and restore rcbufp */
  780. X  rc=inced.offs[--inced.filled];lseek(rc,inced.offs[--inced.filled],SEEK_SET);
  781. X  rcbufp=rcbufend;getb();rcbufp=rcbuf+inced.offs[--inced.filled];
  782. X  return 1;
  783. X}
  784. X
  785. Xvoid closerc P((void))                    /* {while(poprc());} */
  786. X{ while(closeonerc(),inced.filled)
  787. X     rc=inced.offs[inced.filled-1],inced.filled-=3;
  788. X}
  789. X                                /* destroys buf2 */
  790. Xint bopen(name)const char*const name;                 /* my fopen */
  791. X{ rcbufp=rcbufend=0;rc=ropen(name,O_RDONLY,0);
  792. X  if(rc>=0)
  793. X   { char*md;         /* if it's a relative name and an absolute $MAILDIR */
  794. X     if(!strchr(dirsep,*name)&&strchr(dirsep,*(md=(char*)tgetenv(maildir))))
  795. X      { strcpy(buf2,md);*(md=strchr(buf2,'\0'))= *dirsep;strcpy(++md,name);
  796. X    md=buf2;                    /* then prepend $MAILDIR */
  797. X      }
  798. X     else
  799. X    md=(char*)name;                  /* pick the original otherwise */
  800. X     newdynstring(&incnamed,md);
  801. X   }
  802. X  return rc;
  803. X}
  804. X
  805. Xint getbl(p)char*p;                          /* my gets */
  806. X{ int i;char*q;
  807. X  for(q=p;;)
  808. X   { switch(i=getb())
  809. X      { case '\n':case EOF:*q='\0';
  810. X       return p!=q;                 /* did we read anything at all? */
  811. X      }
  812. X     *q++=i;
  813. X   }
  814. X}
  815. X
  816. Xint getb P((void))                         /* my fgetc */
  817. X{ if(rcbufp==rcbufend)                           /* refill */
  818. X   { blasttell=tell(rc);rcbufend=rcbuf+rread(rc,rcbufp=rcbuf,STDBUF);
  819. X     if(rcbufp==rcbufend)
  820. X    rcbufp++;
  821. X   }
  822. X  return rcbufp<rcbufend?(int)*rcbufp++:EOF;
  823. X}
  824. X
  825. Xvoid ungetb(x)const int x;    /* only for pushing back original characters */
  826. X{ if(x!=EOF)
  827. X     rcbufp--;                               /* backup */
  828. X}
  829. X
  830. Xint testb(x)const int x;       /* fgetc that only succeeds if it matches */
  831. X{ int i;
  832. X  if((i=getb())==x)
  833. X     return 1;
  834. X  ungetb(i);
  835. X  return 0;
  836. X}
  837. X
  838. Xint sgetc P((void))                /* a fake fgetc for a string */
  839. X{ return *sgetcp?(int)*(uchar*)sgetcp++:EOF;
  840. X}
  841. X
  842. Xint skipspace P((void))
  843. X{ int any=0;
  844. X  while(testb(' ')||testb('\t'))
  845. X     any=1;
  846. X  return any;
  847. X}
  848. X
  849. Xvoid getlline(target)char*target;
  850. X{ char*chp2;
  851. X  for(;getbl(chp2=target)&&*(target=strchr(target,'\0')-1)=='\\';
  852. X   *target++='\n')                       /* read line-wise */
  853. X     if(chp2!=target)                      /* non-empty line? */
  854. X    target++;                  /* then preserve the backslash */
  855. X}
  856. END_OF_FILE
  857.   if test 4014 -ne `wc -c <'procmail-3.03/src/cstdio.c'`; then
  858.     echo shar: \"'procmail-3.03/src/cstdio.c'\" unpacked with wrong size!
  859.   fi
  860.   # end of 'procmail-3.03/src/cstdio.c'
  861. fi
  862. if test -f 'procmail-3.03/src/ecommon.c' -a "${1}" != "-c" ; then 
  863.   echo shar: Will not clobber existing file \"'procmail-3.03/src/ecommon.c'\"
  864. else
  865.   echo shar: Extracting \"'procmail-3.03/src/ecommon.c'\" \(867 characters\)
  866.   sed "s/^X//" >'procmail-3.03/src/ecommon.c' <<'END_OF_FILE'
  867. X/************************************************************************
  868. X *    Some common routines to all programs but procmail        *
  869. X *                                    *
  870. X *    Copyright (c) 1993-1994, S.R. van den Berg, The Netherlands    *
  871. X *    #include "../README"                        *
  872. X ************************************************************************/
  873. X#ifdef RCS
  874. Xstatic /*const*/char rcsid[]=
  875. X "$Id: ecommon.c,v 1.6 1994/05/26 14:12:32 berg Exp $";
  876. X#endif
  877. X#include "includes.h"
  878. X#include "ecommon.h"
  879. X#include "common.h"
  880. X
  881. Xvoid
  882. X nlog P((const char*const a));
  883. X
  884. Xstatic const char outofmem[]="Out of memory\n";
  885. X
  886. Xvoid*tmalloc(len)const size_t len;
  887. X{ void*p;
  888. X  if(p=malloc(len))
  889. X     return p;
  890. X  nlog(outofmem);exit(EX_OSERR);
  891. X}
  892. X
  893. Xvoid*trealloc(old,len)void*old;const size_t len;
  894. X{ if(old=realloc(old,len))
  895. X     return old;
  896. X  nlog(outofmem);exit(EX_OSERR);
  897. X}
  898. X
  899. Xvoid tfree(a)void*a;
  900. X{ free(a);
  901. X}
  902. X
  903. X#include "shell.h"
  904. END_OF_FILE
  905.   if test 867 -ne `wc -c <'procmail-3.03/src/ecommon.c'`; then
  906.     echo shar: \"'procmail-3.03/src/ecommon.c'\" unpacked with wrong size!
  907.   fi
  908.   # end of 'procmail-3.03/src/ecommon.c'
  909. fi
  910. if test -f 'procmail-3.03/src/exopen.c' -a "${1}" != "-c" ; then 
  911.   echo shar: Will not clobber existing file \"'procmail-3.03/src/exopen.c'\"
  912. else
  913.   echo shar: Extracting \"'procmail-3.03/src/exopen.c'\" \(3061 characters\)
  914.   sed "s/^X//" >'procmail-3.03/src/exopen.c' <<'END_OF_FILE'
  915. X/************************************************************************
  916. X *    Collection of NFS resistant exclusive creat routines        *
  917. X *                                    *
  918. X *    Copyright (c) 1990-1994, S.R. van den Berg, The Netherlands    *
  919. X *    #include "../README"                        *
  920. X ************************************************************************/
  921. X#ifdef RCS
  922. Xstatic /*const*/char rcsid[]=
  923. X "$Id: exopen.c,v 1.23 1994/06/28 16:56:05 berg Exp $";
  924. X#endif
  925. X#include "procmail.h"
  926. X#include "acommon.h"
  927. X#include "robust.h"
  928. X#include "misc.h"
  929. X#include "common.h"
  930. X#include "exopen.h"
  931. X
  932. Xint unique(full,p,mode,verbos,chownit)const char*const full;char*p;
  933. X const mode_t mode;const int verbos,chownit;
  934. X{ unsigned long retry=mrotbSERIAL;int i;struct stat filebuf;
  935. X  int nicediff,didnice=0;
  936. X  if(chownit&doCHOWN)          /* semi-critical, try raising the priority */
  937. X   { nicediff=nice(0);SETerrno(0);nicediff-=nice(-NICE_RANGE);
  938. X     if(!errno)
  939. X    didnice=1;
  940. X   }
  941. X  do                          /* create unique file name */
  942. X   { *p=UNIQ_PREFIX;p=ultoan(maskSERIAL&(retry-=irotbSERIAL)+(long)thepid,p+1);
  943. X     strncpy(p,hostname(),HOSTNAMElen);p[HOSTNAMElen]='\0';
  944. X   }
  945. X#ifndef O_CREAT
  946. X#define ropen(path,type,mode)    creat(path,mode)
  947. X#endif
  948. X  while(!lstat(full,&filebuf)||
  949. X    (0>(i=ropen(full,O_WRONLY|O_CREAT|O_EXCL,mode))&&errno==EEXIST)&&
  950. X    retry);        /* casually check if it already exists (highly unlikely) */
  951. X  if(didnice)
  952. X     nice(nicediff);           /* put back the priority to the old level */
  953. X  if(i<0)
  954. X   { if(verbos)                  /* this error message can be confusing */
  955. X    writeerr(full);                     /* for casual users */
  956. X     goto ret0;
  957. X   }
  958. X#ifdef NOfstat
  959. X  if(chownit&doCHOWN)
  960. X   { if(
  961. X#else
  962. X  if(chownit&doCHECK)
  963. X   { struct stat fdbuf;
  964. X     fstat(i,&fdbuf);            /* match between the file descriptor */
  965. X#define NEQ(what)    (fdbuf.what!=filebuf.what)        /* and the file? */
  966. X     if(lstat(full,&filebuf)||filebuf.st_nlink!=1||filebuf.st_size||
  967. X    NEQ(st_dev)||NEQ(st_ino)||NEQ(st_uid)||NEQ(st_gid)||
  968. X     chownit&doCHOWN&&
  969. X#endif
  970. X     chown(full,uid,sgid))
  971. X      { rclose(i);unlink(full);             /* forget it, no permission */
  972. Xret0:    return 0;
  973. X      }
  974. X   }
  975. X  if(chownit&doLOCK)
  976. X     rwrite(i,"0",1);               /* pid 0, `works' across networks */
  977. X  rclose(i);
  978. X  return 1;
  979. X}
  980. X                     /* rename MUST fail if already existent */
  981. Xint myrename(old,newn)const char*const old,*const newn;
  982. X{ int i,serrno;
  983. X  i=hlink(old,newn);serrno=errno;unlink(old);SETerrno(serrno);
  984. X  return i;
  985. X}
  986. X         /* hardlink with fallback for systems that don't support it */
  987. Xint hlink(old,newn)const char*const old,*const newn;
  988. X{ if(link(old,newn))                      /* try a real hardlink */
  989. X   { int i,serrno;struct stat stbuf;
  990. X     serrno=errno;i=lstat(old,&stbuf);SETerrno(serrno);
  991. X     if(i&&S_ISLNK(stbuf.st_mode))        /* no stat or symbolic link? */
  992. X    goto retfail;                     /* yuk, don't accept it */
  993. X     if(stbuf.st_nlink!=2)
  994. X      { if(serrno!=EXDEV)               /* failure due to filesystem? */
  995. X       goto retfail;             /* try it by conventional means */
  996. X#ifdef O_CREAT
  997. X    if(0>(i=ropen(newn,O_WRONLY|O_CREAT|O_EXCL,stbuf.st_mode)))
  998. X#endif
  999. Xretfail:   return -1;
  1000. X    rclose(i);
  1001. X      }
  1002. X   }
  1003. X  return 0;
  1004. X}
  1005. END_OF_FILE
  1006.   if test 3061 -ne `wc -c <'procmail-3.03/src/exopen.c'`; then
  1007.     echo shar: \"'procmail-3.03/src/exopen.c'\" unpacked with wrong size!
  1008.   fi
  1009.   # end of 'procmail-3.03/src/exopen.c'
  1010. fi
  1011. if test -f 'procmail-3.03/src/fields.c' -a "${1}" != "-c" ; then 
  1012.   echo shar: Will not clobber existing file \"'procmail-3.03/src/fields.c'\"
  1013. else
  1014.   echo shar: Extracting \"'procmail-3.03/src/fields.c'\" \(4177 characters\)
  1015.   sed "s/^X//" >'procmail-3.03/src/fields.c' <<'END_OF_FILE'
  1016. X/************************************************************************
  1017. X *    Routines to deal with the header-field objects in formail    *
  1018. X *                                    *
  1019. X *    Copyright (c) 1990-1994, S.R. van den Berg, The Netherlands    *
  1020. X *    #include "../README"                        *
  1021. X ************************************************************************/
  1022. X#ifdef RCS
  1023. Xstatic /*const*/char rcsid[]=
  1024. X "$Id: fields.c,v 1.17 1994/06/28 16:56:07 berg Exp $";
  1025. X#endif
  1026. X#include "includes.h"
  1027. X#include "formail.h"
  1028. X#include "sublib.h"
  1029. X#include "shell.h"
  1030. X#include "common.h"
  1031. X#include "fields.h"
  1032. X#include "ecommon.h"
  1033. X#include "formisc.h"
  1034. X                /* find a field in the linked list of fields */
  1035. Xstruct field*findf(p,ah)const struct field*const p;register struct field**ah;
  1036. X{ size_t i;int uhead;char*chp;register struct field*h;
  1037. X  uhead=ah==&uheader||ah==&Uheader;
  1038. X  for(i=p->id_len,chp=(char*)p->fld_text,h= *ah;h;h= *(ah= &h->fld_next))
  1039. X     if(i>=h->id_len&&!strnIcmp(chp,h->fld_text,h->id_len))
  1040. X      { if(i>h->id_len&&uhead)                 /* finalise the header? */
  1041. X       *ah=0,(*(ah=addfield(ah,chp,i)))->fld_next=h,(h= *ah)->fld_ref=0;
  1042. X    return h;
  1043. X      }
  1044. X  return (struct field*)0;
  1045. X}
  1046. X
  1047. Xvoid clear_uhead(hdr)register struct field*hdr;
  1048. X{ for(;hdr;hdr=hdr->fld_next)
  1049. X     hdr->fld_ref=0;
  1050. X}
  1051. X
  1052. Xstruct field**addfield(pointer,text,totlen)struct field**pointer;
  1053. X const char*const text;const size_t totlen;    /* add field to a linked list */
  1054. X{ register struct field*p,**pp;int idlen;
  1055. X  for(pp=pointer;*pp;pp= &(*pp)->fld_next);   /* skip to the end of the list */
  1056. X  (*pp=p=malloc(FLD_HEADSIZ+totlen))->fld_next=0;idlen=breakfield(text,totlen);
  1057. X  p->id_len=idlen>0?idlen:pp==&rdheader?0:-idlen;        /* copy contents */
  1058. X  tmemmove(p->fld_text,text,p->tot_len=totlen);
  1059. X  return pp;
  1060. X}
  1061. X
  1062. Xstruct field*delfield(pointer)struct field**pointer;
  1063. X{ struct field*fldp;
  1064. X  *pointer=(fldp= *pointer)->fld_next;free(fldp);
  1065. X  return *pointer;
  1066. X}
  1067. X
  1068. Xvoid concatenate(fldp)struct field*const fldp;
  1069. X{ register char*p;register size_t l;        /* concatenate a continued field */
  1070. X  l=fldp->tot_len;
  1071. X  if(!eqFrom_(p=fldp->fld_text))        /* don't concatenate From_ lines */
  1072. X     while(l--)
  1073. X    if(*p++=='\n'&&l)    /* by substituting all newlines except the last */
  1074. X       p[-1]=' ';
  1075. X}
  1076. X
  1077. Xvoid renfield(pointer,oldl,newname,newl)struct field**const pointer;
  1078. X const size_t oldl,newl;const char*const newname;        /* rename fields */
  1079. X{ struct field*p;size_t i;char*chp;
  1080. X  i=(p= *pointer)->tot_len-oldl;          /* length of what we will keep */
  1081. X  *pointer=p=realloc(p,FLD_HEADSIZ+(p->tot_len=i+newl));chp=p->fld_text;
  1082. X  tmemmove(chp+newl,chp+oldl,i);tmemmove(chp,newname,newl);   /* shove, copy */
  1083. X}
  1084. X
  1085. Xstatic void extractfield(p)register struct field*p;
  1086. X{ if(xheader||Xheader)                     /* extracting only? */
  1087. X   { if(findf(p,&xheader))               /* extract field contents */
  1088. X      { putssn((char*)p->fld_text+p->id_len,p->tot_len-p->id_len);
  1089. X    return;
  1090. X      }
  1091. X     if(!findf(p,&Xheader))                   /* extract fields */
  1092. X    return;
  1093. X   }
  1094. X  lputssn(p->fld_text,p->tot_len);              /* display it entirely */
  1095. X}
  1096. X
  1097. Xvoid flushfield(pointer)register struct field**pointer;     /* delete and print */
  1098. X{ register struct field*p,*q;                   /* them as you go */
  1099. X  for(p= *pointer,*pointer=0;p;p=q)
  1100. X     q=p->fld_next,extractfield(p),free(p);
  1101. X}
  1102. X
  1103. Xvoid dispfield(p)register const struct field*p;
  1104. X{ for(;p;p=p->fld_next)                 /* print list non-destructively */
  1105. X     if(p->id_len+1<p->tot_len)             /* any contents to display? */
  1106. X    extractfield(p);
  1107. X}
  1108. X            /* try and append one valid field to rdheader from stdin */
  1109. Xint readhead P((void))
  1110. X{ getline();
  1111. X  if(eqFrom_(buf))                    /* it's a From_ line */
  1112. X   { if(rdheader)
  1113. X    return 0;                   /* the From_ line was a fake! */
  1114. X     for(;buflast=='>';getline());        /* gather continued >From_ lines */
  1115. X   }
  1116. X  else
  1117. X   { if(breakfield(buf,buffilled)<=0)       /* not the start of a valid field */
  1118. X    return 0;
  1119. X     for(;;getline())              /* get the rest of the continued field */
  1120. X      { switch(buflast)                 /* will this line be continued? */
  1121. X     { case ' ':case '\t':                  /* yep, it sure is */
  1122. X          continue;
  1123. X     }
  1124. X    break;
  1125. X      }
  1126. X   }
  1127. X  addbuf();              /* phew, got the field, add it to rdheader */
  1128. X  return 1;
  1129. X}
  1130. X
  1131. Xvoid addbuf P((void))
  1132. X{ addfield(&rdheader,buf,buffilled);buffilled=0;
  1133. X}
  1134. END_OF_FILE
  1135.   if test 4177 -ne `wc -c <'procmail-3.03/src/fields.c'`; then
  1136.     echo shar: \"'procmail-3.03/src/fields.c'\" unpacked with wrong size!
  1137.   fi
  1138.   # end of 'procmail-3.03/src/fields.c'
  1139. fi
  1140. if test -f 'procmail-3.03/src/misc.h' -a "${1}" != "-c" ; then 
  1141.   echo shar: Will not clobber existing file \"'procmail-3.03/src/misc.h'\"
  1142. else
  1143.   echo shar: Extracting \"'procmail-3.03/src/misc.h'\" \(2030 characters\)
  1144.   sed "s/^X//" >'procmail-3.03/src/misc.h' <<'END_OF_FILE'
  1145. X/*$Id: misc.h,v 1.28 1994/05/26 14:13:12 berg Exp $*/
  1146. X
  1147. Xstruct dyna_long{size_t filled,tspace;off_t*offs;};
  1148. Xstruct dynstring{struct dynstring*enext;char ename[255];};
  1149. X
  1150. Xvoid
  1151. X elog P((const char*const newt)),
  1152. X ignoreterm P((void)),
  1153. X shutdesc P((void)),
  1154. X setids P((void)),
  1155. X writeerr P((const char*const line)),
  1156. X progerr P((const char*const line,int xitcode)),
  1157. X chderr P((const char*const dir)),
  1158. X readerr P((const char*const file)),
  1159. X verboff P((void)),
  1160. X verbon P((void)),
  1161. X newid P((void)),
  1162. X zombiecollect P((void)),
  1163. X yell P((const char*const a,const char*const b)),
  1164. X nlog P((const char*const a)),
  1165. X logqnl P((const char*const a)),
  1166. X skipped P((const char*const x)),
  1167. X onguard P((void)),
  1168. X offguard P((void)),
  1169. X sterminate P((void)),
  1170. X Terminate P((void)),
  1171. X suspend P((void)),
  1172. X app_val P((struct dyna_long*const sp,const off_t val)),
  1173. X firstchd P((void)),
  1174. X srequeue P((void)),
  1175. X slose P((void)),
  1176. X sbounce P((void)),
  1177. X catlim P((const char*src)),
  1178. X setdef P((const char*const name,const char*const contents)),
  1179. X metaparse P((const char*p)),
  1180. X setlastfolder P((const char*const folder)),
  1181. X asenv P((const char*const chp)),
  1182. X concatenate P((char*p)),
  1183. X squeeze P((char*target)),
  1184. X initdefenv P((void));
  1185. Xint
  1186. X forkerr Q((const pid_t pid,const char*const a)),
  1187. X nextrcfile P((void)),
  1188. X asenvcpy P((char*src)),
  1189. X alphanum P((const unsigned c)),
  1190. X enoughprivs Q((const struct passwd*const passinvk,const uid_t euid,
  1191. X  const gid_t egid,const uid_t uid,const gid_t gid));
  1192. Xchar
  1193. X *lastdirsep P((const char*filename)),
  1194. X *cat P((const char*const a,const char*const b)),
  1195. X *tstrdup P((const char*const a)),
  1196. X *cstr P((char*const a,const char*const b)),
  1197. X *gobenv P((char*chp)),
  1198. X *egrepin P((char*expr,const char*source,const long len,int casesens));
  1199. Xconst char
  1200. X *tgetenv P((const char*const a)),
  1201. X *newdynstring P((struct dynstring**const adrp,const char*const chp));
  1202. Xlong
  1203. X renvint P((const long i,const char*const env));
  1204. Xconst struct passwd
  1205. X *savepass Q((struct passwd*const spass,const uid_t uid));
  1206. X
  1207. Xextern const char lastfolder[];
  1208. Xextern int didchd;
  1209. Xextern char*globlock;
  1210. END_OF_FILE
  1211.   if test 2030 -ne `wc -c <'procmail-3.03/src/misc.h'`; then
  1212.     echo shar: \"'procmail-3.03/src/misc.h'\" unpacked with wrong size!
  1213.   fi
  1214.   # end of 'procmail-3.03/src/misc.h'
  1215. fi
  1216. if test -f 'procmail-3.03/src/procmail.h' -a "${1}" != "-c" ; then 
  1217.   echo shar: Will not clobber existing file \"'procmail-3.03/src/procmail.h'\"
  1218. else
  1219.   echo shar: Extracting \"'procmail-3.03/src/procmail.h'\" \(2581 characters\)
  1220.   sed "s/^X//" >'procmail-3.03/src/procmail.h' <<'END_OF_FILE'
  1221. X/*$Id: procmail.h,v 1.26 1994/06/24 10:45:08 berg Exp $*/
  1222. X
  1223. X#include "includes.h"
  1224. X
  1225. X#ifdef console
  1226. X#define DEFverbose 1
  1227. X#else
  1228. X#define DEFverbose 0
  1229. X#endif
  1230. X
  1231. X#ifndef DEFsendmail
  1232. X#define DEFsendmail SENDMAIL
  1233. X#endif
  1234. X
  1235. X#ifndef SYSTEM_MBOX
  1236. X#define SYSTEM_MBOX    SYSTEM_MAILBOX
  1237. X#endif
  1238. X
  1239. X#ifndef ETCRC
  1240. X#define ETCRC    0
  1241. X#endif
  1242. X
  1243. X#define MAX32    ((long)(~(unsigned long)0>>1))
  1244. X#define MIN32    (-(long)MAX32)
  1245. X
  1246. X#define XTRAlinebuf    2         /* surplus of LINEBUF (see readparse()) */
  1247. X#ifdef MAXPATHLEN
  1248. X#if MAXPATHLEN>DEFlinebuf        /* to protect people from themselves */
  1249. X#undef DEFlinebuf
  1250. X#define DEFlinebuf MAXPATHLEN
  1251. X#endif
  1252. X#endif
  1253. X
  1254. X#define rc_NOSGID    1              /* you can forget any sgidness */
  1255. X#define rc_NORMAL    2
  1256. X
  1257. X#define MCDIRSEP    (dirsep+STRLEN(dirsep)-1)      /* most common DIRSEP */
  1258. X#define MCDIRSEP_    (dirsep+STRLEN(DIRSEP)-1)
  1259. X
  1260. X#define lck_LOCKFILE    1      /* crosscheck the order of this with msg[] */
  1261. X#define lck_ALLOCLIB    2              /* in sterminate() in retint.c */
  1262. X#define lck_MEMORY    4
  1263. X#define lck_FORK    8
  1264. X#define lck_FILDES    16
  1265. X#define lck_KERNEL    32
  1266. X
  1267. Xextern struct varval{const char*const name;long val;}strenvvar[];
  1268. X#define locksleep    (strenvvar[0].val)
  1269. X#define locktimeout    (strenvvar[1].val)
  1270. X#define suspendv    (strenvvar[2].val)
  1271. X#define noresretry    (strenvvar[3].val)
  1272. X#define timeoutv    (strenvvar[4].val)
  1273. X#define verbose        (*(volatile long*)&strenvvar[5].val)
  1274. X#define lgabstract    (strenvvar[6].val)
  1275. X
  1276. Xextern struct varstr{const char*const sname,*sval;}strenstr[];
  1277. X#define shellmetas    (strenstr[0].sval)
  1278. X#define lockext        (strenstr[1].sval)
  1279. X#define msgprefix    (strenstr[2].sval)
  1280. X#define scomsat        (strenstr[3].sval)
  1281. X#define traps        (strenstr[4].sval)
  1282. X#define shellflags    (strenstr[5].sval)
  1283. X#define fdefault    (strenstr[6].sval)
  1284. X#define sendmail    (strenstr[7].sval)
  1285. X
  1286. Xint
  1287. X eqFrom_ P((const char*const a));
  1288. X
  1289. Xextern char*buf,*buf2,*loclock,*tolock,*Stdout,*themail,*thebody;
  1290. Xextern const char shell[],lockfile[],newline[],binsh[],unexpeof[],*const*gargv,
  1291. X *const*restargv,*sgetcp,*rcfile,dirsep[],devnull[],lgname[],executing[],
  1292. X oquote[],cquote[],whilstwfor[],procmailn[],Mail[],home[],maildir[],host[],
  1293. X *defdeflock,*argv0,errwwriting[],slogstr[];
  1294. Xextern long filled,lastscore;
  1295. Xextern int sh,pwait,retval,retvl2,lcking,rcstate,rc,ignwerr,lexitcode,
  1296. X asgnlastf,accspooldir,crestarg,skiprc,savstdout;
  1297. Xextern size_t linebuf;
  1298. Xextern volatile nextexit;
  1299. Xextern pid_t thepid;
  1300. Xextern uid_t uid;
  1301. Xextern gid_t gid,sgid;
  1302. X
  1303. X/*
  1304. X *    External variables that are checked/changed by the signal handlers:
  1305. X *    volatile time_t alrmtime;
  1306. X *    pid_t pidfilt,pidchild;
  1307. X *    volatile nextexit;
  1308. X *    int lcking;
  1309. X *    static volatile mailread;    in mailfold.c
  1310. X */
  1311. END_OF_FILE
  1312.   if test 2581 -ne `wc -c <'procmail-3.03/src/procmail.h'`; then
  1313.     echo shar: \"'procmail-3.03/src/procmail.h'\" unpacked with wrong size!
  1314.   fi
  1315.   # end of 'procmail-3.03/src/procmail.h'
  1316. fi
  1317. if test -f 'procmail-3.03/src/recommend.c' -a "${1}" != "-c" ; then 
  1318.   echo shar: Will not clobber existing file \"'procmail-3.03/src/recommend.c'\"
  1319. else
  1320.   echo shar: Extracting \"'procmail-3.03/src/recommend.c'\" \(1897 characters\)
  1321.   sed "s/^X//" >'procmail-3.03/src/recommend.c' <<'END_OF_FILE'
  1322. X/************************************************************************
  1323. X *    recommend    Analyses the installation, and makes        *
  1324. X *            recommendations about suid/sgid modes        *
  1325. X ************************************************************************/
  1326. X/*$Id: recommend.c,v 1.9 1994/06/01 17:22:30 berg Exp $*/
  1327. X#include "includes.h"
  1328. X
  1329. X#ifndef SYSTEM_MBOX
  1330. X#define SYSTEM_MBOX    SYSTEM_MAILBOX
  1331. X#endif
  1332. X
  1333. X#define PERMIS    (S_IRWXU|S_IRWXG&~S_IWGRP|S_IRWXO&~S_IWOTH)
  1334. X
  1335. Xchar systm_mbox[]=SYSTEM_MBOX;
  1336. Xconst char dirsep[]=DIRSEP,
  1337. X *const checkf[]={"/bin/mail","/bin/lmail","/usr/lib/sendmail",
  1338. X "/usr/lib/smail",0};
  1339. X                     /* following routine lifted from misc.c */
  1340. Xchar*lastdirsep(filename)const char*filename;     /* finds the next character */
  1341. X{ const char*p;                    /* following the last DIRSEP */
  1342. X  while(p=strpbrk(filename,dirsep))
  1343. X     filename=p+1;
  1344. X  return (char*)filename;
  1345. X}
  1346. X
  1347. Xmain(argc,argv)const int argc;const char*const argv[];
  1348. X{ struct group*grp;struct stat stbuf;gid_t gid=(gid_t)-1;
  1349. X  const char*const*p;mode_t sgid=0;int chmdir=0;
  1350. X  if(argc!=3)
  1351. X   { fprintf(stderr,"Please run this program via 'make recommend'\n");
  1352. X     return EX_USAGE;
  1353. X   }
  1354. X  *lastdirsep(systm_mbox)='\0';
  1355. X  for(p=checkf;*p;p++)
  1356. X     if(!stat(*p,&stbuf)&&stbuf.st_mode&S_ISGID)
  1357. X      { if(stbuf.st_mode&S_ISGID)
  1358. X       sgid=S_ISGID,gid=stbuf.st_gid;
  1359. X    break;
  1360. X      }
  1361. X  if(!stat(systm_mbox,&stbuf)&&!(stbuf.st_mode&S_IWOTH))
  1362. X   { sgid=S_ISGID;gid=stbuf.st_gid;
  1363. X     if(!(stbuf.st_mode&S_IWGRP))
  1364. X    chmdir=1;
  1365. X   }
  1366. X  if(gid!=stbuf.st_gid)
  1367. X     sgid=0;
  1368. X  printf("chown root %s\n",argv[1]);
  1369. X  if(sgid)
  1370. X     if(grp=getgrgid(gid))
  1371. X    printf("chgrp %s %s %s\n",grp->gr_name,argv[1],argv[2]);
  1372. X     else
  1373. X    printf("chgrp %u %s %s\n",(int)gid,argv[1],argv[2]);
  1374. X  printf("chmod %o %s\n",sgid|S_ISUID|PERMIS,argv[1]);
  1375. X  if(sgid)
  1376. X   { printf("chmod %o %s\n",sgid|PERMIS,argv[2]);
  1377. X     if(chmdir)
  1378. X    printf("chmod g+w %s.\n",systm_mbox);
  1379. X   }
  1380. X  return EX_OK;
  1381. X}
  1382. END_OF_FILE
  1383.   if test 1897 -ne `wc -c <'procmail-3.03/src/recommend.c'`; then
  1384.     echo shar: \"'procmail-3.03/src/recommend.c'\" unpacked with wrong size!
  1385.   fi
  1386.   # end of 'procmail-3.03/src/recommend.c'
  1387. fi
  1388. if test -f 'procmail-3.03/src/sublib.c' -a "${1}" != "-c" ; then 
  1389.   echo shar: Will not clobber existing file \"'procmail-3.03/src/sublib.c'\"
  1390. else
  1391.   echo shar: Extracting \"'procmail-3.03/src/sublib.c'\" \(4614 characters\)
  1392.   sed "s/^X//" >'procmail-3.03/src/sublib.c' <<'END_OF_FILE'
  1393. X/************************************************************************
  1394. X *    Collection of standard library substitute routines        *
  1395. X *                                    *
  1396. X *    Copyright (c) 1990-1994, S.R. van den Berg, The Netherlands    *
  1397. X *    #include "../README"                        *
  1398. X ************************************************************************/
  1399. X#ifdef RCS
  1400. Xstatic /*const*/char rcsid[]=
  1401. X "$Id: sublib.c,v 1.13 1994/06/28 16:56:49 berg Exp $";
  1402. X#endif
  1403. X#include "includes.h"
  1404. X#include "sublib.h"
  1405. X
  1406. X#ifdef NOmemmove
  1407. Xvoid*smemmove(To,From,count)void*To;const void*From;register size_t count;
  1408. X#ifdef NObcopy                      /* silly compromise, throw */
  1409. X{ register char*to=To;register const char*from=From;/*void*old;*/
  1410. X  /*old=to;*/count++;to--;from--;  /* away space to be syntactically correct */
  1411. X  if(to<=from)
  1412. X   { goto jiasc;
  1413. X     do
  1414. X      { *++to= *++from;                      /* copy from above */
  1415. Xjiasc:;
  1416. X      }
  1417. X     while(--count);
  1418. X   }
  1419. X  else
  1420. X   { to+=count;from+=count;
  1421. X     goto jidesc;
  1422. X     do
  1423. X      { *--to= *--from;                      /* copy from below */
  1424. Xjidesc:;
  1425. X      }
  1426. X     while(--count);
  1427. X   }
  1428. X  return To/*old*/;
  1429. X#else
  1430. X{ bcopy(From,To,count);
  1431. X  return To;
  1432. X#endif /* NObcopy */
  1433. X}
  1434. X#endif /* NOmemmove */
  1435. X
  1436. X#include "shell.h"
  1437. X
  1438. X#ifdef NOstrpbrk
  1439. Xchar*strpbrk(st,del)const char*const st,*del;
  1440. X{ const char*f=0,*t;
  1441. X  for(f=0;*del;)
  1442. X     if((t=strchr(st,*del++))&&(!f||t<f))
  1443. X    f=t;
  1444. X  return (char*)f;
  1445. X}
  1446. X#endif
  1447. X
  1448. X#ifdef BENCHSIZE                         /* for autoconf */
  1449. X#ifndef SLOWstrstr
  1450. X#define SLOWstrstr
  1451. X#else
  1452. X#undef BENCHSIZE
  1453. X#endif
  1454. X#endif
  1455. X#ifdef SLOWstrstr
  1456. X/*
  1457. X *    My personal strstr() implementation that beats most other algorithms.
  1458. X *    Until someone tells me otherwise, I assume that this is the
  1459. X *    fastest implementation of strstr() in C.
  1460. X *    I deliberately chose not to comment it.     You should have at least
  1461. X *    as much fun trying to understand it, as I had to write it :-).
  1462. X */
  1463. Xtypedef unsigned chartype;
  1464. X
  1465. Xchar*sstrstr(phaystack,pneedle)const char*const phaystack;
  1466. X const char*const pneedle;
  1467. X{ register const uchar*haystack,*needle;register chartype b,c;
  1468. X  haystack=(const uchar*)phaystack;
  1469. X  if(b= *(needle=(const uchar*)pneedle))
  1470. X   { haystack--;                  /* possible ANSI violation */
  1471. X     do
  1472. X    if(!(c= *++haystack))
  1473. X       goto ret0;
  1474. X     while(c!=b);
  1475. X     if(!(c= *++needle))
  1476. X    goto foundneedle;
  1477. X     ++needle;
  1478. X     goto jin;
  1479. X     for(;;)
  1480. X      { ;{ register chartype a;
  1481. X       do
  1482. X        { if(!(a= *++haystack))
  1483. X         goto ret0;
  1484. X          if(a==b)
  1485. X         break;
  1486. X          if(!(a= *++haystack))
  1487. X         goto ret0;
  1488. Xshloop:;    }
  1489. X       while(a!=b);
  1490. Xjin:       if(!(a= *++haystack))
  1491. X          goto ret0;
  1492. X       if(a!=c)
  1493. X          goto shloop;
  1494. X     }
  1495. X    ;{ register chartype a;
  1496. X       ;{ register const uchar*rhaystack,*rneedle;
  1497. X          if(*(rhaystack=haystack--+1)==(a= *(rneedle=needle)))
  1498. X         do
  1499. X          { if(!a)
  1500. X               goto foundneedle;
  1501. X            if(*++rhaystack!=(a= *++needle))
  1502. X               break;
  1503. X            if(!a)
  1504. X               goto foundneedle;
  1505. X          }
  1506. X         while(*++rhaystack==(a= *++needle));
  1507. X          needle=rneedle;           /* took the register-poor aproach */
  1508. X        }
  1509. X       if(!a)
  1510. X          break;
  1511. X     }
  1512. X      }
  1513. X   }
  1514. Xfoundneedle:
  1515. X  return (char*)haystack;
  1516. Xret0:
  1517. X  return (char*)0;
  1518. X}
  1519. X#endif
  1520. X                /* strtol replacement which lacks range checking */
  1521. X#ifdef NOstrtol
  1522. Xlong strtol(start,ptr,base)const char*start,**const ptr;
  1523. X{ long result;const char*str=start;unsigned i;int sign,found;
  1524. X  if(base>=36||base<(sign=found=result=0))
  1525. X     goto fault;
  1526. X  for(;;str++)                      /* skip leading whitespace */
  1527. X   { switch(*str)
  1528. X      { case '\t':case '\n':case '\v':case '\f':case '\r':case ' ':
  1529. X       continue;
  1530. X      }
  1531. X     break;
  1532. X   }
  1533. X  switch(*str)                               /* any signs? */
  1534. X   { case '-':sign=1;
  1535. X     case '+':str++;
  1536. X   }
  1537. X  if(*str=='0')                         /* leading zero(s)? */
  1538. X   { start++;
  1539. X     if((i= *++str)=='x'||i=='X')            /* leading 0x or 0X? */
  1540. X    if(!base||base==16)
  1541. X       base=16,str++;                /* hexadecimal all right */
  1542. X    else
  1543. X       goto fault;
  1544. X     else if(!base)
  1545. X    base=8;                         /* then it is octal */
  1546. X   }
  1547. X  else if(!base)
  1548. X     base=10;                          /* or else decimal */
  1549. X  goto jumpin;
  1550. X  do
  1551. X   { found=1;result=result*base+i;str++;         /* start converting */
  1552. Xjumpin:
  1553. X     if((i=(unsigned)*str-'0')<10);
  1554. X     else if(i-'A'+'0'<='Z'-'A')
  1555. X    i-='A'-10-'0';               /* collating sequence dependency! */
  1556. X     else if(i-'a'+'0'<'z'-'a')
  1557. X    i-='a'-10-'0';               /* collating sequence dependency! */
  1558. X     else
  1559. X    break;                        /* not of this world */
  1560. X   }
  1561. X  while(i<base);                      /* still of this world */
  1562. Xfault:
  1563. X  if(ptr)
  1564. X    *ptr=found?str:start;                   /* how far did we get */
  1565. X  return sign?-result:result;
  1566. X}
  1567. X#else /* NOstrtol */
  1568. X#ifndef SLOWstrstr
  1569. X#ifndef NOstrpbrk
  1570. X#ifndef NOmemmove
  1571. Xint sublib_dummy_var;              /* to prevent insanity in some linkers */
  1572. X#endif
  1573. X#endif
  1574. X#endif
  1575. X#endif /* NOstrtol */
  1576. END_OF_FILE
  1577.   if test 4614 -ne `wc -c <'procmail-3.03/src/sublib.c'`; then
  1578.     echo shar: \"'procmail-3.03/src/sublib.c'\" unpacked with wrong size!
  1579.   fi
  1580.   # end of 'procmail-3.03/src/sublib.c'
  1581. fi
  1582. echo shar: End of archive 9 \(of 10\).
  1583. cp /dev/null ark9isdone
  1584. MISSING=""
  1585. for I in 1 2 3 4 5 6 7 8 9 10 ; do
  1586.     if test ! -f ark${I}isdone ; then
  1587.     MISSING="${MISSING} ${I}"
  1588.     fi
  1589. done
  1590. if test "${MISSING}" = "" ; then
  1591.     echo You have unpacked all 10 archives.
  1592.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1593. else
  1594.     echo You still must unpack the following archives:
  1595.     echo "        " ${MISSING}
  1596. fi
  1597. exit 0
  1598. exit 0 # Just in case...
  1599.