home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sources / misc / 4113 < prev    next >
Encoding:
Text File  |  1992-11-20  |  54.2 KB  |  1,765 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: ram@eiffel.com (Raphael Manfredi)
  4. Subject:  v33i108:  mailagent - Rule Based Mail Filtering, Part16/17
  5. Message-ID: <1992Nov20.231321.28251@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: 46ebaf2f69ca6f5d95abebb40247377e
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v33i093=mailagent.230117@sparky.IMD.Sterling.COM>
  11. Date: Fri, 20 Nov 1992 23:13:21 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 1750
  14.  
  15. Submitted-by: ram@eiffel.com (Raphael Manfredi)
  16. Posting-number: Volume 33, Issue 108
  17. Archive-name: mailagent/part16
  18. Environment: Perl, Sendmail, UNIX
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then feed it
  22. # into a shell via "sh file" or similar.  To overwrite existing files,
  23. # type "sh file -c".
  24. # Contents:  agent/README agent/examples/mchk agent/examples/nocmds
  25. #   agent/files/distribs agent/filter/Jmakefile agent/filter/environ.h
  26. #   agent/filter/io.h agent/filter/lock.h agent/filter/logfile.h
  27. #   agent/filter/misc.c agent/filter/parser.h agent/pl/checklock.pl
  28. #   agent/pl/extern.pl agent/pl/fatal.pl agent/pl/free_file.pl
  29. #   agent/pl/jobnum.pl agent/pl/locate.pl agent/pl/makedir.pl
  30. #   agent/pl/rangeargs.pl agent/test/Jmakefile agent/test/cmd/back.t
  31. #   agent/test/cmd/keep.t agent/test/cmd/leave.t agent/test/cmd/perl.t
  32. #   agent/test/cmd/save.t agent/test/cmd/store.t
  33. #   agent/test/cmd/strip.t agent/test/filter/backref.t
  34. #   agent/test/filter/default.t agent/test/filter/multiple.t
  35. #   agent/test/filter/not.t agent/test/option/d.t
  36. #   agent/test/option/e.t agent/test/option/f.t agent/test/option/l.t
  37. #   agent/test/option/q.t agent/test/pl/mail.pl
  38. # Wrapped by kent@sparky on Wed Nov 18 22:42:34 1992
  39. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  40. echo If this archive is complete, you will see the following message:
  41. echo '          "shar: End of archive 16 (of 17)."'
  42. if test -f 'agent/README' -a "${1}" != "-c" ; then 
  43.   echo shar: Will not clobber existing file \"'agent/README'\"
  44. else
  45.   echo shar: Extracting \"'agent/README'\" \(1190 characters\)
  46.   sed "s/^X//" >'agent/README' <<'END_OF_FILE'
  47. X[The following is the README file which was found in the dist 2.8 PL13
  48. Xdistribution, where the mailagent was only one of the programs provided.
  49. XThe final revision of the mailagent will appear in dist 3.0, along with
  50. Xmetaconfig, patching tools and jmake--RAM]
  51. X
  52. XThis is the root directory for mailagent.
  53. X
  54. XIf you choose to install the mailagent, you will enable people to
  55. Xask for patches and eventually distributions. You need kit 2.0
  56. X(at least PL 9) and cshar 3.0 for the mailagent's PROCESS command to
  57. Xwork properly. If you miss one of those, you can request them from my
  58. Xown mailagent.
  59. X
  60. XYou will also have access to filtering abilities, specified using
  61. Xlex-like rules. The mailagent will delete all those mails you do not
  62. Xwish to read, forward others (e.g. rebroadcasting a mailing list),
  63. Xand file mail into folders for delayed reading.
  64. X
  65. XInstructions for configuring and setting your mailagent are found
  66. Xin the manual page. Once all is installed, run "man mailagent".
  67. XYou can also go to the man/ subdirectory and run the following:
  68. X"nroff -man mailagent.1 | more -s".
  69. X
  70. XLook at the README file in the filter/ directory for hints on choosing
  71. Xbetween the C or the shell version of the filter.
  72. END_OF_FILE
  73.   if test 1190 -ne `wc -c <'agent/README'`; then
  74.     echo shar: \"'agent/README'\" unpacked with wrong size!
  75.   fi
  76.   # end of 'agent/README'
  77. fi
  78. if test -f 'agent/examples/mchk' -a "${1}" != "-c" ; then 
  79.   echo shar: Will not clobber existing file \"'agent/examples/mchk'\"
  80. else
  81.   echo shar: Extracting \"'agent/examples/mchk'\" \(932 characters\)
  82.   sed "s/^X//" >'agent/examples/mchk' <<'END_OF_FILE'
  83. X#! /bin/sh
  84. X# @(#) Scans all the mailboxes to spot any new mail
  85. X
  86. X# Compute location of the spool mailbox
  87. Xspool=/usr/spool/mail
  88. Xif test -d /usr/mail; then
  89. X    spool=/usr/mail;
  90. Xfi
  91. Xspool=$spool/`(logname || whoami) 2>/dev/null`
  92. X
  93. X# First look for a ~/.mailfolders file, otherwise parse $MAILPATH, and
  94. X# finally use the spool mailbox if none of those worked.
  95. Xif test -f $HOME/.mailfolders; then
  96. X    set X $spool \
  97. X        `sed -e "/^[     ]*#/d" -e "s|^~|$HOME|" <$HOME/.mailfolders`
  98. Xelif test "$MAILPATH"; then
  99. X    set X `echo $MAILPATH | tr ':' '\012'`
  100. Xelse
  101. X    set X $spool
  102. Xfi
  103. Xshift
  104. X
  105. X# Loop over the computed locations and print the name of the mailboxes
  106. X# which are not empty. If a location is a directory, scan all the files
  107. X# found in that directory.
  108. Xfor location in $*
  109. Xdo
  110. X    if test -d "$location"; then
  111. X        for file in $location/*
  112. X        do
  113. X            if test -s "$file"; then
  114. X                echo "$file"
  115. X            fi
  116. X        done
  117. X    elif test -s "$location"; then
  118. X        echo "$location"
  119. X    fi
  120. Xdone
  121. X
  122. END_OF_FILE
  123.   if test 932 -ne `wc -c <'agent/examples/mchk'`; then
  124.     echo shar: \"'agent/examples/mchk'\" unpacked with wrong size!
  125.   fi
  126.   chmod +x 'agent/examples/mchk'
  127.   # end of 'agent/examples/mchk'
  128. fi
  129. if test -f 'agent/examples/nocmds' -a "${1}" != "-c" ; then 
  130.   echo shar: Will not clobber existing file \"'agent/examples/nocmds'\"
  131. else
  132.   echo shar: Extracting \"'agent/examples/nocmds'\" \(818 characters\)
  133.   sed "s/^X//" >'agent/examples/nocmds' <<'END_OF_FILE'
  134. X[This is a recording -- Last revision was made on %T]
  135. X
  136. XDear %N:
  137. X
  138. XI have received your command mail dated %[Date].
  139. X
  140. XI am truly sorry, but the mailagent access has been denied to you for various
  141. Xreasons. Your mail however was not lost but filtered normally, which means
  142. XI will have a look at it. I may eventually execute the command myself, if
  143. Xnecessary and needed.
  144. X
  145. XThe main reason for the mailagent access denial is an interest conflict
  146. Xbetween ISE and myself, which prevents me from letting a program execute
  147. Xcommands automatically. Please accept my apologies.
  148. X
  149. XThank you for your understanding.
  150. X--
  151. XRaphael Manfredi <ram@eiffel.com>
  152. XInteractive Software Engineering Inc.
  153. X270 Storke Road, Suite #7                      / Tel +1 (805) 685-1006 \
  154. XGoleta, California 93117, USA                  \ Fax +1 (805) 685-6869 /
  155. END_OF_FILE
  156.   if test 818 -ne `wc -c <'agent/examples/nocmds'`; then
  157.     echo shar: \"'agent/examples/nocmds'\" unpacked with wrong size!
  158.   fi
  159.   # end of 'agent/examples/nocmds'
  160. fi
  161. if test -f 'agent/files/distribs' -a "${1}" != "-c" ; then 
  162.   echo shar: Will not clobber existing file \"'agent/files/distribs'\"
  163. else
  164.   echo shar: Extracting \"'agent/files/distribs'\" \(807 characters\)
  165.   sed "s/^X//" >'agent/files/distribs' <<'END_OF_FILE'
  166. X# Distributions (under vi, use ':set ts=4')
  167. X
  168. X# prog version         path                  archiv    .Z patches
  169. X
  170. Xkit        1.0        ~/home/projects/kit            n    n    o
  171. Xkit        2.0        ~/home/projects/kit            n    n    y
  172. Xdist    2.0        ~/home/projects/dist        n    n    y
  173. Xmatrix    1.1        ~/home/projects/matrix        n    n    y
  174. Xcshar    3.0        ~/home/projects/cshar-3.0    n    n    y
  175. Xfile    ---        ~/arch/dist/file            y    y    n
  176. Xrcs        5.5        ~/arch/dist/rcs-5.5            y    y    n
  177. Xcops    ---        ~/arch/dist/cops            y    y    n
  178. Xflex    2.3        ~/arch/dist/flex2.3            y    y    n
  179. Xxfmt    ---        ~/arch/dist/xfmt            y    y    n
  180. Xet        ---        ~/arch/dist/et                y    y    n
  181. Xless    123        ~/arch/dist/less            y    y    n
  182. Xundel    2.0        ~/arch/dist/undel2            y    y    n
  183. Xperl    3.0        ~/arch/dist/perl-3.0        n    n    n
  184. Xperl    4.0        ~/arch/dist/perl-4.0        n    n    p
  185. Xpatch    2.0        ~/arch/dist/patch            y    y    n
  186. X
  187. X#rcs    4.3        ~/arch/dist/rcs.4_3            y    y    n
  188. X#undel    1.0        ~/arch/dist/UNDEL            y    y    n
  189. X#dither    1.0        ~/arch/dist/DITHER            y    y    y
  190. END_OF_FILE
  191.   if test 807 -ne `wc -c <'agent/files/distribs'`; then
  192.     echo shar: \"'agent/files/distribs'\" unpacked with wrong size!
  193.   fi
  194.   # end of 'agent/files/distribs'
  195. fi
  196. if test -f 'agent/filter/Jmakefile' -a "${1}" != "-c" ; then 
  197.   echo shar: Will not clobber existing file \"'agent/filter/Jmakefile'\"
  198. else
  199.   echo shar: Extracting \"'agent/filter/Jmakefile'\" \(805 characters\)
  200.   sed "s/^X//" >'agent/filter/Jmakefile' <<'END_OF_FILE'
  201. X/*
  202. X * Jmakefile for filter
  203. X */
  204. X
  205. X;# $Id: Jmakefile,v 2.9 92/07/14 18:41:10 ram Exp $
  206. X;#
  207. X;#  Copyright (c) 1991, Raphael Manfredi
  208. X;#
  209. X;#  You may redistribute only under the terms of the GNU General Public
  210. X;#  Licence as specified in the README file that comes with dist.
  211. X;#
  212. X;# $Log:    Jmakefile,v $
  213. X;# Revision 2.9  92/07/14  18:41:10  ram
  214. X;# 3.0 beta baseline.
  215. X;# 
  216. X
  217. X;# Files used to build the application
  218. XSRC = environ.c hash.c io.c lock.c logfile.c main.c misc.c msg.c parser.c \
  219. X    user.c
  220. X
  221. X;# Derived object file names
  222. XOBJ = \
  223. X|expand f!$(SRC)!
  224. X    !f:\.c=.o \
  225. X-expand \\
  226. X
  227. X;# File config.h is in the top-level directory
  228. XCFLAGS = -I$(TOP)
  229. XDPFLAGS = -I$(TOP)
  230. X
  231. X>PRIVLIB    /* Force metaconfig to ask for privlib location */
  232. X
  233. XDependTarget()
  234. XNormalProgramTarget(filter,$(SRC),$(OBJ))
  235. XInstallProgram(filter, $(PRIVLIB))
  236. END_OF_FILE
  237.   if test 805 -ne `wc -c <'agent/filter/Jmakefile'`; then
  238.     echo shar: \"'agent/filter/Jmakefile'\" unpacked with wrong size!
  239.   fi
  240.   # end of 'agent/filter/Jmakefile'
  241. fi
  242. if test -f 'agent/filter/environ.h' -a "${1}" != "-c" ; then 
  243.   echo shar: Will not clobber existing file \"'agent/filter/environ.h'\"
  244. else
  245.   echo shar: Extracting \"'agent/filter/environ.h'\" \(1232 characters\)
  246.   sed "s/^X//" >'agent/filter/environ.h' <<'END_OF_FILE'
  247. X/*
  248. X
  249. X ######  #    #  #    #     #    #####    ####   #    #          #    #
  250. X #       ##   #  #    #     #    #    #  #    #  ##   #          #    #
  251. X #####   # #  #  #    #     #    #    #  #    #  # #  #          ######
  252. X #       #  # #  #    #     #    #####   #    #  #  # #   ###    #    #
  253. X #       #   ##   #  #      #    #   #   #    #  #   ##   ###    #    #
  254. X ######  #    #    ##       #    #    #   ####   #    #   ###    #    #
  255. X
  256. X    Declarations for envrironment routines.
  257. X*/
  258. X
  259. X/*
  260. X * $Id: environ.h,v 2.9 92/07/14 16:48:06 ram Exp $
  261. X *
  262. X *  Copyright (c) 1992, Raphael Manfredi
  263. X *
  264. X *  You may redistribute only under the terms of the GNU General Public
  265. X *  Licence as specified in the README file that comes with dist.
  266. X *
  267. X * $Log:    environ.h,v $
  268. X * Revision 2.9  92/07/14  16:48:06  ram
  269. X * 3.0 beta baseline.
  270. X * 
  271. X */
  272. X
  273. X#ifndef _environ_h_
  274. X#define _environ_h_
  275. X
  276. Xextern void print_env();            /* Print the environment */
  277. Xextern void init_env();                /* Initializes the environment table */
  278. Xextern char **make_env();            /* Make a new system environment */
  279. Xextern int append_env();            /* Append value to environment */
  280. Xextern int prepend_env();            /* Prepend value to environment */
  281. Xextern int set_env();                /* Set environment value */
  282. X
  283. X#endif
  284. END_OF_FILE
  285.   if test 1232 -ne `wc -c <'agent/filter/environ.h'`; then
  286.     echo shar: \"'agent/filter/environ.h'\" unpacked with wrong size!
  287.   fi
  288.   # end of 'agent/filter/environ.h'
  289. fi
  290. if test -f 'agent/filter/io.h' -a "${1}" != "-c" ; then 
  291.   echo shar: Will not clobber existing file \"'agent/filter/io.h'\"
  292. else
  293.   echo shar: Extracting \"'agent/filter/io.h'\" \(773 characters\)
  294.   sed "s/^X//" >'agent/filter/io.h' <<'END_OF_FILE'
  295. X/*
  296. X
  297. X    #     ####           #    #
  298. X    #    #    #          #    #
  299. X    #    #    #          ######
  300. X    #    #    #   ###    #    #
  301. X    #    #    #   ###    #    #
  302. X    #     ####    ###    #    #
  303. X
  304. X    Declarations of I/O routines.
  305. X*/
  306. X
  307. X/*
  308. X * $Id: io.h,v 2.9 92/07/14 16:48:16 ram Exp $
  309. X *
  310. X *  Copyright (c) 1992, Raphael Manfredi
  311. X *
  312. X *  You may redistribute only under the terms of the GNU General Public
  313. X *  Licence as specified in the README file that comes with dist.
  314. X *
  315. X * $Log:    io.h,v $
  316. X * Revision 2.9  92/07/14  16:48:16  ram
  317. X * 3.0 beta baseline.
  318. X * 
  319. X */
  320. X
  321. X#ifndef _io_h_
  322. X#define _io_h_
  323. X
  324. Xextern void process();                /* Process mail */
  325. Xextern int emergency_save();        /* Save mail in emeregency file */
  326. Xextern int was_queued();            /* Was mail safely queued or not? */
  327. X
  328. X#endif
  329. END_OF_FILE
  330.   if test 773 -ne `wc -c <'agent/filter/io.h'`; then
  331.     echo shar: \"'agent/filter/io.h'\" unpacked with wrong size!
  332.   fi
  333.   # end of 'agent/filter/io.h'
  334. fi
  335. if test -f 'agent/filter/lock.h' -a "${1}" != "-c" ; then 
  336.   echo shar: Will not clobber existing file \"'agent/filter/lock.h'\"
  337. else
  338.   echo shar: Extracting \"'agent/filter/lock.h'\" \(870 characters\)
  339.   sed "s/^X//" >'agent/filter/lock.h' <<'END_OF_FILE'
  340. X/*
  341. X
  342. X #        ####    ####   #    #          #    #
  343. X #       #    #  #    #  #   #           #    #
  344. X #       #    #  #       ####            ######
  345. X #       #    #  #       #  #     ###    #    #
  346. X #       #    #  #    #  #   #    ###    #    #
  347. X ######   ####    ####   #    #   ###    #    #
  348. X
  349. X    Declarations for locking routines.
  350. X*/
  351. X
  352. X/*
  353. X * $Id: lock.h,v 2.9 92/07/14 16:48:20 ram Exp $
  354. X *
  355. X *  Copyright (c) 1992, Raphael Manfredi
  356. X *
  357. X *  You may redistribute only under the terms of the GNU General Public
  358. X *  Licence as specified in the README file that comes with dist.
  359. X *
  360. X * $Log:    lock.h,v $
  361. X * Revision 2.9  92/07/14  16:48:20  ram
  362. X * 3.0 beta baseline.
  363. X * 
  364. X */
  365. X
  366. X#ifndef _lock_h_
  367. X#define _lock_h_
  368. X
  369. Xextern int filter_lock();        /* Lock filter */
  370. Xextern void release_lock();        /* Release lock if necessary */
  371. Xextern int is_locked();            /* Do we have a lock file? */
  372. X
  373. X#endif
  374. END_OF_FILE
  375.   if test 870 -ne `wc -c <'agent/filter/lock.h'`; then
  376.     echo shar: \"'agent/filter/lock.h'\" unpacked with wrong size!
  377.   fi
  378.   # end of 'agent/filter/lock.h'
  379. fi
  380. if test -f 'agent/filter/logfile.h' -a "${1}" != "-c" ; then 
  381.   echo shar: Will not clobber existing file \"'agent/filter/logfile.h'\"
  382. else
  383.   echo shar: Extracting \"'agent/filter/logfile.h'\" \(1274 characters\)
  384.   sed "s/^X//" >'agent/filter/logfile.h' <<'END_OF_FILE'
  385. X/*
  386. X
  387. X #        ####    ####   ######     #    #       ######          #    #
  388. X #       #    #  #    #  #          #    #       #               #    #
  389. X #       #    #  #       #####      #    #       #####           ######
  390. X #       #    #  #  ###  #          #    #       #        ###    #    #
  391. X #       #    #  #    #  #          #    #       #        ###    #    #
  392. X ######   ####    ####   #          #    ######  ######   ###    #    #
  393. X
  394. X    Declarations for logging.
  395. X*/
  396. X
  397. X/*
  398. X * $Id: logfile.h,v 2.9 92/07/14 16:48:25 ram Exp $
  399. X *
  400. X *  Copyright (c) 1992, Raphael Manfredi
  401. X *
  402. X *  You may redistribute only under the terms of the GNU General Public
  403. X *  Licence as specified in the README file that comes with dist.
  404. X *
  405. X * $Log:    logfile.h,v $
  406. X * Revision 2.9  92/07/14  16:48:25  ram
  407. X * 3.0 beta baseline.
  408. X * 
  409. X */
  410. X
  411. X#ifndef _logfile_h_
  412. X#define _logfile_h_
  413. X
  414. X#include "config.h"
  415. X
  416. X/* Routine defined by logging package */
  417. Xextern void add_log();            /* Add logging message */
  418. Xextern int open_log();            /* Open logging file */
  419. Xextern void close_log();        /* Close logging file */
  420. Xextern void set_loglvl();        /* Set logging level */
  421. X
  422. X/* The following need to be set externally but are defined here */
  423. Xextern char *progname;            /* Program name */
  424. Xextern Pid_t progpid;            /* Program PID */
  425. X
  426. X#endif
  427. X
  428. END_OF_FILE
  429.   if test 1274 -ne `wc -c <'agent/filter/logfile.h'`; then
  430.     echo shar: \"'agent/filter/logfile.h'\" unpacked with wrong size!
  431.   fi
  432.   # end of 'agent/filter/logfile.h'
  433. fi
  434. if test -f 'agent/filter/misc.c' -a "${1}" != "-c" ; then 
  435.   echo shar: Will not clobber existing file \"'agent/filter/misc.c'\"
  436. else
  437.   echo shar: Extracting \"'agent/filter/misc.c'\" \(1071 characters\)
  438.   sed "s/^X//" >'agent/filter/misc.c' <<'END_OF_FILE'
  439. X/*
  440. X
  441. X #    #     #     ####    ####            ####
  442. X ##  ##     #    #       #    #          #    #
  443. X # ## #     #     ####   #               #
  444. X #    #     #         #  #        ###    #
  445. X #    #     #    #    #  #    #   ###    #    #
  446. X #    #     #     ####    ####    ###     ####
  447. X
  448. X    Miscellaneous routines.
  449. X*/
  450. X
  451. X/*
  452. X * $Id: misc.c,v 2.9 92/07/14 16:48:29 ram Exp $
  453. X *
  454. X *  Copyright (c) 1992, Raphael Manfredi
  455. X *
  456. X *  You may redistribute only under the terms of the GNU General Public
  457. X *  Licence as specified in the README file that comes with dist.
  458. X *
  459. X * $Log:    misc.c,v $
  460. X * Revision 2.9  92/07/14  16:48:29  ram
  461. X * 3.0 beta baseline.
  462. X * 
  463. X */
  464. X
  465. X#include "config.h"
  466. X#include "portable.h"
  467. X
  468. Xextern char *malloc();                /* Memory allocation */
  469. X
  470. Xpublic char *strsave(string)
  471. Xchar *string;
  472. X{
  473. X    /* Save string somewhere in memory and return a pointer to the new string
  474. X     * or NULL if there is not enough memory.
  475. X     */
  476. X
  477. X    char *new = malloc(strlen(string) + 1);        /* +1 for \0 */
  478. X    
  479. X    if (new == (char *) 0)
  480. X        fatal("no more memory to save strings");
  481. X
  482. X    strcpy(new, string);
  483. X    return new;
  484. X}
  485. X
  486. END_OF_FILE
  487.   if test 1071 -ne `wc -c <'agent/filter/misc.c'`; then
  488.     echo shar: \"'agent/filter/misc.c'\" unpacked with wrong size!
  489.   fi
  490.   # end of 'agent/filter/misc.c'
  491. fi
  492. if test -f 'agent/filter/parser.h' -a "${1}" != "-c" ; then 
  493.   echo shar: Will not clobber existing file \"'agent/filter/parser.h'\"
  494. else
  495.   echo shar: Extracting \"'agent/filter/parser.h'\" \(1058 characters\)
  496.   sed "s/^X//" >'agent/filter/parser.h' <<'END_OF_FILE'
  497. X/*
  498. X
  499. X #####     ##    #####    ####   ######  #####           #    #
  500. X #    #   #  #   #    #  #       #       #    #          #    #
  501. X #    #  #    #  #    #   ####   #####   #    #          ######
  502. X #####   ######  #####        #  #       #####    ###    #    #
  503. X #       #    #  #   #   #    #  #       #   #    ###    #    #
  504. X #       #    #  #    #   ####   ######  #    #   ###    #    #
  505. X
  506. X    Configuration variable parsing routines.
  507. X*/
  508. X
  509. X/*
  510. X * $Id: parser.h,v 2.9 92/07/14 16:48:39 ram Exp $
  511. X *
  512. X *  Copyright (c) 1992, Raphael Manfredi
  513. X *
  514. X *  You may redistribute only under the terms of the GNU General Public
  515. X *  Licence as specified in the README file that comes with dist.
  516. X *
  517. X * $Log:    parser.h,v $
  518. X * Revision 2.9  92/07/14  16:48:39  ram
  519. X * 3.0 beta baseline.
  520. X * 
  521. X */
  522. X
  523. X#ifndef _parser_h_
  524. X#define _parser_h_
  525. X
  526. Xextern struct htable symtab;        /* Symbol table */
  527. Xextern void read_conf();            /* Read configuration file */
  528. Xextern void set_env_vars();            /* Set correct environment variables */
  529. Xextern char *homedir();                /* Location of the home directory */
  530. X
  531. X#endif
  532. END_OF_FILE
  533.   if test 1058 -ne `wc -c <'agent/filter/parser.h'`; then
  534.     echo shar: \"'agent/filter/parser.h'\" unpacked with wrong size!
  535.   fi
  536.   # end of 'agent/filter/parser.h'
  537. fi
  538. if test -f 'agent/pl/checklock.pl' -a "${1}" != "-c" ; then 
  539.   echo shar: Will not clobber existing file \"'agent/pl/checklock.pl'\"
  540. else
  541.   echo shar: Extracting \"'agent/pl/checklock.pl'\" \(1000 characters\)
  542.   sed "s/^X//" >'agent/pl/checklock.pl' <<'END_OF_FILE'
  543. X;# $Id: checklock.pl,v 2.9 92/07/14 16:49:41 ram Exp $
  544. X;#
  545. X;#  Copyright (c) 1991, Raphael Manfredi
  546. X;#
  547. X;#  You may redistribute only under the terms of the GNU General Public
  548. X;#  Licence as specified in the README file that comes with dist.
  549. X;#
  550. X;# $Log:    checklock.pl,v $
  551. X;# Revision 2.9  92/07/14  16:49:41  ram
  552. X;# 3.0 beta baseline.
  553. X;# 
  554. X;#
  555. X;# The $lockext variable must be correctly set.
  556. X;#
  557. X# Make sure lock lasts for a reasonable time
  558. Xsub checklock {
  559. X    local($file) = shift(@_);                # Full path name
  560. X    local($lockfile) = $file . $lockext;    # Add lock extension
  561. X    if (-f $lockfile) {
  562. X        # There is a lock file -- look for how long it's been there
  563. X        ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
  564. X            $atime,$mtime,$ctime,$blksize,$blocks) = stat($lockfile);
  565. X        if ((time - $mtime) > 3600) {
  566. X            # More than one hour !! Something must have gone wrong
  567. X            unlink $lockfile;
  568. X            $file =~ s|.*/(.*)|$1|;    # Keep only basename
  569. X            do add_log("UNLOCKED $file (lock older than one hour)")
  570. X                if ($loglvl > 5);
  571. X        }
  572. X    }
  573. X}
  574. X
  575. END_OF_FILE
  576.   if test 1000 -ne `wc -c <'agent/pl/checklock.pl'`; then
  577.     echo shar: \"'agent/pl/checklock.pl'\" unpacked with wrong size!
  578.   fi
  579.   # end of 'agent/pl/checklock.pl'
  580. fi
  581. if test -f 'agent/pl/extern.pl' -a "${1}" != "-c" ; then 
  582.   echo shar: Will not clobber existing file \"'agent/pl/extern.pl'\"
  583. else
  584.   echo shar: Extracting \"'agent/pl/extern.pl'\" \(1041 characters\)
  585.   sed "s/^X//" >'agent/pl/extern.pl' <<'END_OF_FILE'
  586. X;# $Id: extern.pl,v 2.9.1.1 92/08/26 13:10:33 ram Exp $
  587. X;#
  588. X;#  Copyright (c) 1992, Raphael Manfredi
  589. X;#
  590. X;#  You may redistribute only under the terms of the GNU General Public
  591. X;#  Licence as specified in the README file that comes with dist.
  592. X;#
  593. X;# $Log:    extern.pl,v $
  594. X;# Revision 2.9.1.1  92/08/26  13:10:33  ram
  595. X;# patch8: created
  596. X;# 
  597. X;# 
  598. X;# External variables are stored in the dbr database. They provide persistent
  599. X;# values accross different invocations of the mailagent.
  600. X;#
  601. X#
  602. X# Persitent variables handling
  603. X#
  604. X
  605. Xpackage extern;
  606. X
  607. X# Fetch value of a persistent variable
  608. Xsub val {
  609. X    local($name) = @_;
  610. X    local($time, $linenum, @value) = &dbr'info($name, 'VARIABLE');
  611. X    join("\t", @value);        # TAB is the record separator in dbr
  612. X}
  613. X
  614. X# Update value of a persistent variable
  615. Xsub set {
  616. X    local($name, $value) = @_;
  617. X    &dbr'update($name, 'VARIABLE', undef, $value);
  618. X}
  619. X
  620. X# Fetch age of the variable (elapsed time since last modification)
  621. Xsub age {
  622. X    local($name) = @_;
  623. X    local($time, $linenum) = &dbr'info($name, 'VARIABLE');
  624. X    time - $time;
  625. X}
  626. X
  627. Xpackage main;
  628. X
  629. END_OF_FILE
  630.   if test 1041 -ne `wc -c <'agent/pl/extern.pl'`; then
  631.     echo shar: \"'agent/pl/extern.pl'\" unpacked with wrong size!
  632.   fi
  633.   # end of 'agent/pl/extern.pl'
  634. fi
  635. if test -f 'agent/pl/fatal.pl' -a "${1}" != "-c" ; then 
  636.   echo shar: Will not clobber existing file \"'agent/pl/fatal.pl'\"
  637. else
  638.   echo shar: Extracting \"'agent/pl/fatal.pl'\" \(809 characters\)
  639.   sed "s/^X//" >'agent/pl/fatal.pl' <<'END_OF_FILE'
  640. X;# $Id: fatal.pl,v 2.9.1.1 92/08/26 13:11:03 ram Exp $
  641. X;#
  642. X;#  Copyright (c) 1991, Raphael Manfredi
  643. X;#
  644. X;#  You may redistribute only under the terms of the GNU General Public
  645. X;#  Licence as specified in the README file that comes with dist.
  646. X;#
  647. X;# $Log:    fatal.pl,v $
  648. X;# Revision 2.9.1.1  92/08/26  13:11:03  ram
  649. X;# patch8: added emergency routine for signal handlers
  650. X;# 
  651. X;# Revision 2.9  92/07/14  16:49:55  ram
  652. X;# 3.0 beta baseline.
  653. X;# 
  654. X;#
  655. X# In case of fatal error, the program does not simply die
  656. X# but also records the failure in the log.
  657. Xsub fatal {
  658. X    local($reason) = @_;            # Why did we get here ?
  659. X    &add_log("FAILED ($reason)") if $loglvl > 0;
  660. X    die "$prog_name: $reason\n";
  661. X}
  662. X
  663. X# Emergency signal was caught
  664. Xsub emergency {
  665. X    local($sig) = @_;            # First argument is signal name
  666. X    &fatal("trapped SIG$sig");
  667. X}
  668. X
  669. END_OF_FILE
  670.   if test 809 -ne `wc -c <'agent/pl/fatal.pl'`; then
  671.     echo shar: \"'agent/pl/fatal.pl'\" unpacked with wrong size!
  672.   fi
  673.   # end of 'agent/pl/fatal.pl'
  674. fi
  675. if test -f 'agent/pl/free_file.pl' -a "${1}" != "-c" ; then 
  676.   echo shar: Will not clobber existing file \"'agent/pl/free_file.pl'\"
  677. else
  678.   echo shar: Extracting \"'agent/pl/free_file.pl'\" \(764 characters\)
  679.   sed "s/^X//" >'agent/pl/free_file.pl' <<'END_OF_FILE'
  680. X;# $Id: free_file.pl,v 2.9 92/07/14 16:50:00 ram Exp $
  681. X;#
  682. X;#  Copyright (c) 1991, Raphael Manfredi
  683. X;#
  684. X;#  You may redistribute only under the terms of the GNU General Public
  685. X;#  Licence as specified in the README file that comes with dist.
  686. X;#
  687. X;# $Log:    free_file.pl,v $
  688. X;# Revision 2.9  92/07/14  16:50:00  ram
  689. X;# 3.0 beta baseline.
  690. X;# 
  691. X;#
  692. X# Remove the lock on a file. Returns 0 if ok, -1 otherwise
  693. Xsub free_file {
  694. X    local($file) = @_;
  695. X
  696. X    if ( -f "$file.lock") {
  697. X        # if lock exists, check for pid
  698. X        open(FILE, "$file.lock");
  699. X        $_ = <FILE>;
  700. X        close FILE;
  701. X        if (int($_) == $$) {
  702. X            # pid is correct
  703. X            $result = 0;
  704. X            unlink "$file.lock";
  705. X        } else {
  706. X            # pid is not correct
  707. X            $result = -1;
  708. X        }
  709. X    } else {
  710. X        # no lock file
  711. X        $result = 0;
  712. X    }
  713. X    $result;    # return status
  714. X}
  715. X
  716. END_OF_FILE
  717.   if test 764 -ne `wc -c <'agent/pl/free_file.pl'`; then
  718.     echo shar: \"'agent/pl/free_file.pl'\" unpacked with wrong size!
  719.   fi
  720.   # end of 'agent/pl/free_file.pl'
  721. fi
  722. if test -f 'agent/pl/jobnum.pl' -a "${1}" != "-c" ; then 
  723.   echo shar: Will not clobber existing file \"'agent/pl/jobnum.pl'\"
  724. else
  725.   echo shar: Extracting \"'agent/pl/jobnum.pl'\" \(965 characters\)
  726.   sed "s/^X//" >'agent/pl/jobnum.pl' <<'END_OF_FILE'
  727. X;# $Id: jobnum.pl,v 2.9.1.1 92/08/26 13:14:57 ram Exp $
  728. X;#
  729. X;#  Copyright (c) 1992, Raphael Manfredi
  730. X;#
  731. X;#  You may redistribute only under the terms of the GNU General Public
  732. X;#  Licence as specified in the README file that comes with dist.
  733. X;#
  734. X;# $Log:    jobnum.pl,v $
  735. X;# Revision 2.9.1.1  92/08/26  13:14:57  ram
  736. X;# patch8: created
  737. X;# 
  738. X;# 
  739. X;# Depends on the following external routines:
  740. X;#  checklock() to check for locks older than one hour
  741. X;#  acs_rqst() to get a lock on file
  742. X;#  free_file() to release lock on file
  743. X;#
  744. X# Computes a new job number
  745. Xsub jobnum {
  746. X    local($job);                        # Computed job number
  747. X    &checklock($cf'seqfile);            # Check for old lock
  748. X    if (0 != &acs_rqst($cf'seqfile)) {
  749. X        $job = "?";
  750. X    } else {
  751. X        local($njob);
  752. X        open(FILE, "$cf'seqfile");
  753. X        $njob = int(<FILE>);
  754. X        close FILE;
  755. X        $njob++;
  756. X        open(FILE, ">$cf'seqfile");
  757. X        print FILE "$njob\n";
  758. X        close FILE;
  759. X        $job = "$njob";
  760. X        &free_file("$cf'seqfile");
  761. X    }
  762. X    $job;        # Return job number to be used
  763. X}
  764. X
  765. END_OF_FILE
  766.   if test 965 -ne `wc -c <'agent/pl/jobnum.pl'`; then
  767.     echo shar: \"'agent/pl/jobnum.pl'\" unpacked with wrong size!
  768.   fi
  769.   # end of 'agent/pl/jobnum.pl'
  770. fi
  771. if test -f 'agent/pl/locate.pl' -a "${1}" != "-c" ; then 
  772.   echo shar: Will not clobber existing file \"'agent/pl/locate.pl'\"
  773. else
  774.   echo shar: Extracting \"'agent/pl/locate.pl'\" \(1122 characters\)
  775.   sed "s/^X//" >'agent/pl/locate.pl' <<'END_OF_FILE'
  776. X;# $Id: locate.pl,v 2.9 92/07/14 16:50:14 ram Exp $
  777. X;#
  778. X;#  Copyright (c) 1992, Raphael Manfredi
  779. X;#
  780. X;#  You may redistribute only under the terms of the GNU General Public
  781. X;#  Licence as specified in the README file that comes with dist.
  782. X;#
  783. X;# $Log:    locate.pl,v $
  784. X;# Revision 2.9  92/07/14  16:50:14  ram
  785. X;# 3.0 beta baseline.
  786. X;# 
  787. X;# 
  788. X# If the file name does not start with a '/', then it is assumed to be found
  789. X# in the mailfilter directory if defined, maildir otherwise, and the home
  790. X# directory finally. The function returns the full path of the file derived
  791. X# from those rules but does not actually check whether file exists or not.
  792. Xsub locate_file {
  793. X    local($filename) = @_;            # File we are trying to locate
  794. X    $filename =~ s/~/$cf'home/g;    # ~ substitution
  795. X    unless ($filename =~ m|^/|) {    # Do nothing if already a full path
  796. X        if (defined($XENV{'mailfilter'})) {
  797. X            $filename = $XENV{'mailfilter'} . "/$filename";
  798. X        } elsif (defined($XENV{'maildir'})) {
  799. X            $filename = $XENV{'maildir'} . "/$filename";
  800. X        } else {
  801. X            $filename = $cf'home . "/$filename";
  802. X        }
  803. X    }
  804. X    $filename =~ s/~/$cf'home/g;    # ~ substitution
  805. X    $filename;
  806. X}
  807. X
  808. END_OF_FILE
  809.   if test 1122 -ne `wc -c <'agent/pl/locate.pl'`; then
  810.     echo shar: \"'agent/pl/locate.pl'\" unpacked with wrong size!
  811.   fi
  812.   # end of 'agent/pl/locate.pl'
  813. fi
  814. if test -f 'agent/pl/makedir.pl' -a "${1}" != "-c" ; then 
  815.   echo shar: Will not clobber existing file \"'agent/pl/makedir.pl'\"
  816. else
  817.   echo shar: Extracting \"'agent/pl/makedir.pl'\" \(792 characters\)
  818.   sed "s/^X//" >'agent/pl/makedir.pl' <<'END_OF_FILE'
  819. X;# $Id: makedir.pl,v 2.9 92/07/14 16:50:18 ram Exp $
  820. X;#
  821. X;#  Copyright (c) 1992, Raphael Manfredi
  822. X;#
  823. X;#  You may redistribute only under the terms of the GNU General Public
  824. X;#  Licence as specified in the README file that comes with dist.
  825. X;#
  826. X;# $Log:    makedir.pl,v $
  827. X;# Revision 2.9  92/07/14  16:50:18  ram
  828. X;# 3.0 beta baseline.
  829. X;# 
  830. X;# 
  831. X# Make directories for files
  832. X# E.g, for /usr/lib/perl/foo, it will check for all the
  833. X# directories /usr, /usr/lib, /usr/lib/perl and make
  834. X# them if they do not exist.
  835. Xsub makedir {
  836. X    local($_) = shift(@_);            # The name of the directory to create
  837. X    local($dir) = $_;
  838. X    if (!-d && $_ ne '') {
  839. X        # Make dirname first
  840. X        do makedir($_) if s|(.*)/.*|\1|;
  841. X        if (! -d $dir) {
  842. X            mkdir($dir, 0700);
  843. X            do add_log("creating directory $dir") if $loglvl > 19;
  844. X        }
  845. X    }
  846. X}
  847. X    
  848. END_OF_FILE
  849.   if test 792 -ne `wc -c <'agent/pl/makedir.pl'`; then
  850.     echo shar: \"'agent/pl/makedir.pl'\" unpacked with wrong size!
  851.   fi
  852.   # end of 'agent/pl/makedir.pl'
  853. fi
  854. if test -f 'agent/pl/rangeargs.pl' -a "${1}" != "-c" ; then 
  855.   echo shar: Will not clobber existing file \"'agent/pl/rangeargs.pl'\"
  856. else
  857.   echo shar: Extracting \"'agent/pl/rangeargs.pl'\" \(1080 characters\)
  858.   sed "s/^X//" >'agent/pl/rangeargs.pl' <<'END_OF_FILE'
  859. X;# $Id: rangeargs.pl,v 2.9 92/07/14 16:50:36 ram Exp $
  860. X;#
  861. X;#  Copyright (c) 1991, Raphael Manfredi
  862. X;#
  863. X;#  You may redistribute only under the terms of the GNU General Public
  864. X;#  Licence as specified in the README file that comes with dist.
  865. X;#
  866. X;# $Log:    rangeargs.pl,v $
  867. X;# Revision 2.9  92/07/14  16:50:36  ram
  868. X;# 3.0 beta baseline.
  869. X;# 
  870. X;#
  871. X# Expand a patch list
  872. Xsub rangeargs {
  873. X    local(@val);
  874. X    local($maxspec) = shift;    # maximum patch value
  875. X    local($args) = $#_;            # number of parameters
  876. X
  877. X    while ($args-- >= 0) {
  878. X        $_ = shift;        # first value remaining in @_
  879. X        while (/./) {
  880. X            if (s/^(\d+)-(\d+)//) {
  881. X                $min = $1;
  882. X                $max = $2;
  883. X            } elsif (s/^(\d+)-//) {
  884. X                $min = $1;
  885. X                $max = $maxspec;
  886. X            } elsif (s/^-(\d+)//) {
  887. X                $max = $1;
  888. X                $min = 1;
  889. X            } elsif (s/^(\d+)//) {
  890. X                $max = $min = $1;
  891. X            } elsif (s/^,//) {
  892. X                $min = 1;
  893. X                $max = 0;    # won't print anything
  894. X            } else {
  895. X                # error in format: skip char
  896. X                s/.//;
  897. X            }
  898. X            for ($i = $min; $i <= $max; ++$i) {
  899. X                push(@val, $i) unless $wanted{$i};    # record only once
  900. X                $wanted{$i} = 1;
  901. X            }
  902. X        }
  903. X    }
  904. X    join(' ', @val);
  905. X}
  906. X
  907. END_OF_FILE
  908.   if test 1080 -ne `wc -c <'agent/pl/rangeargs.pl'`; then
  909.     echo shar: \"'agent/pl/rangeargs.pl'\" unpacked with wrong size!
  910.   fi
  911.   # end of 'agent/pl/rangeargs.pl'
  912. fi
  913. if test -f 'agent/test/Jmakefile' -a "${1}" != "-c" ; then 
  914.   echo shar: Will not clobber existing file \"'agent/test/Jmakefile'\"
  915. else
  916.   echo shar: Extracting \"'agent/test/Jmakefile'\" \(1080 characters\)
  917.   sed "s/^X//" >'agent/test/Jmakefile' <<'END_OF_FILE'
  918. X/*
  919. X * Jmakefile for regression test suite.
  920. X */
  921. X
  922. X;# $Id: Jmakefile,v 2.9.1.1 92/08/02 16:14:36 ram Exp $
  923. X;#
  924. X;#  Copyright (c) 1991, Raphael Manfredi
  925. X;#
  926. X;#  You may redistribute only under the terms of the GNU General Public
  927. X;#  Licence as specified in the README file that comes with dist.
  928. X;#
  929. X;# $Log:    Jmakefile,v $
  930. X;# Revision 2.9.1.1  92/08/02  16:14:36  ram
  931. X;# patch2: last test is now run with the non dataloaded mailagent
  932. X;# 
  933. X;# Revision 2.9  92/07/14  16:50:57  ram
  934. X;# 3.0 beta baseline.
  935. X;# 
  936. X;# 
  937. X
  938. X>RM
  939. Xall::
  940. X    @echo "The following may take a while..."
  941. X    @echo "Don't panic if any of these tests fails and do not stop make."; \
  942. X    ./TEST
  943. X    @if test -f OK; then \
  944. X        echo "Failure detected, retrying one more time, just in case..."; \
  945. X        echo "Successful tests will not be rerun but flagged as 'done'."; \
  946. X        sleep 2; \
  947. X        ./TEST; \
  948. X        if test -f OK; then \
  949. X            echo "Hmm... Still failed... There might be a real problem."; \
  950. X            echo "I shall be using the plain (non dataloaded) version."; \
  951. X            sleep 2;\
  952. X            ./TEST -n; \
  953. X        fi \
  954. X    fi
  955. X
  956. Xtest:
  957. X    ./TEST -i
  958. X
  959. Xlocal_clean::
  960. X    $(RM) -r out
  961. X    $(RM) OK
  962. END_OF_FILE
  963.   if test 1080 -ne `wc -c <'agent/test/Jmakefile'`; then
  964.     echo shar: \"'agent/test/Jmakefile'\" unpacked with wrong size!
  965.   fi
  966.   # end of 'agent/test/Jmakefile'
  967. fi
  968. if test -f 'agent/test/cmd/back.t' -a "${1}" != "-c" ; then 
  969.   echo shar: Will not clobber existing file \"'agent/test/cmd/back.t'\"
  970. else
  971.   echo shar: Extracting \"'agent/test/cmd/back.t'\" \(558 characters\)
  972.   sed "s/^X//" >'agent/test/cmd/back.t' <<'END_OF_FILE'
  973. X# Test BACK command
  974. Xdo '../pl/cmd.pl';
  975. Xunlink 'output';
  976. X
  977. Xopen(PGM, ">pgm") || print "1\n";
  978. Xprint PGM '/bin/echo "RUN /bin/echo it works! > output; SAVE other"', "\n";
  979. Xclose PGM;
  980. Xchmod 0755, 'pgm';
  981. X
  982. X&add_header('X-Tag: back');
  983. X`$cmd`;
  984. X$? == 0 || print "2\n";
  985. X-f 'output' || print "3\n";        # Where output is created
  986. Xchop($output = `cat output 2>/dev/null`);
  987. X$output eq 'it works!' || print "4\n";
  988. X-f 'other' || print "5\n";        # Mail also saved
  989. X-f "$user" && print "6\n";        # So default action does not apply
  990. X
  991. Xunlink 'pgm', 'output', 'mail', 'other';
  992. Xprint "0\n";
  993. END_OF_FILE
  994.   if test 558 -ne `wc -c <'agent/test/cmd/back.t'`; then
  995.     echo shar: \"'agent/test/cmd/back.t'\" unpacked with wrong size!
  996.   fi
  997.   # end of 'agent/test/cmd/back.t'
  998. fi
  999. if test -f 'agent/test/cmd/keep.t' -a "${1}" != "-c" ; then 
  1000.   echo shar: Will not clobber existing file \"'agent/test/cmd/keep.t'\"
  1001. else
  1002.   echo shar: Extracting \"'agent/test/cmd/keep.t'\" \(1094 characters\)
  1003.   sed "s/^X//" >'agent/test/cmd/keep.t' <<'END_OF_FILE'
  1004. X# Test KEEP command
  1005. Xdo '../pl/cmd.pl';
  1006. Xunlink 'ok', 'no_resync';
  1007. X
  1008. X&add_header('X-Tag: keep');
  1009. X&add_header('X-Long-Line: this is a long line and has a continuation');
  1010. X&add_header('  right below it with a MARK token');
  1011. X&add_header('  and another with the MARK token');
  1012. X&add_header('X-Removed-Line: this is a long line and has a continuation');
  1013. X&add_header('  right below it with another mark TOKEN');
  1014. X&add_header('  and another with the mark TOKEN');
  1015. X`$cmd`;
  1016. X$? == 0 || print "1\n";
  1017. X-f "$user" && print "2\n";        # Mail saved...
  1018. X-f 'ok' || print "3\n";            # ...here
  1019. X&get_log(4, 'ok');
  1020. X¬_log('^Received:', 5);        # Make sure Received: disappeared
  1021. X&check_log('^To:', 6);            # But To: still here
  1022. X&check_log('^From:', 7);
  1023. X&check_log('^Subject:', 8);
  1024. X¬_log('^X-None:', 9);
  1025. X&check_log('MARK', 10) == 2 || print "11\n";        # Continuation line kept
  1026. X&check_log('X-Long-Line:', 12);    # So is the parent field
  1027. X¬_log('X-Removed-Line:', 13);
  1028. X¬_log('TOKEN', 14);            # This continuation was removed
  1029. X-f 'no_resync' || print "15\n";    # Ensure header not disturbed
  1030. X
  1031. Xunlink 'ok', 'no_resync', 'mail';
  1032. Xprint "0\n";
  1033. END_OF_FILE
  1034.   if test 1094 -ne `wc -c <'agent/test/cmd/keep.t'`; then
  1035.     echo shar: \"'agent/test/cmd/keep.t'\" unpacked with wrong size!
  1036.   fi
  1037.   # end of 'agent/test/cmd/keep.t'
  1038. fi
  1039. if test -f 'agent/test/cmd/leave.t' -a "${1}" != "-c" ; then 
  1040.   echo shar: Will not clobber existing file \"'agent/test/cmd/leave.t'\"
  1041. else
  1042.   echo shar: Extracting \"'agent/test/cmd/leave.t'\" \(1222 characters\)
  1043.   sed "s/^X//" >'agent/test/cmd/leave.t' <<'END_OF_FILE'
  1044. X# Test LEAVE command
  1045. Xdo '../pl/cmd.pl';
  1046. X
  1047. X&add_header('X-Tag: leave');
  1048. X`$cmd`;
  1049. X$? == 0 || print "1\n";
  1050. X-f "$user" || print "2\n";        # Mail saved here by default
  1051. X
  1052. X# When mailbox protected against writing...
  1053. Xunlink <emerg/*>;
  1054. X$size = -s "$user";
  1055. Xchmod 0444, "$user";
  1056. X`$cmd`;
  1057. X$? == 0 || print "3\n";
  1058. X-f "$user" || print "4\n";                # Must still be there
  1059. X$size == -s "$user" || print "5\n";        # And not altered
  1060. X@emerg = <emerg/*>;
  1061. X@emerg == 1 || print "6\n";                # Emeregency as LEAVE failed
  1062. X
  1063. X# There is no X-Filter mail in the emergency saving
  1064. X`grep -v X-Filter: $user > ok`;
  1065. X$? == 0 || print "7\n";
  1066. X-s $emerg[0] eq -s 'ok' || print "8\n";    # Full mail saved, of course
  1067. X
  1068. X# Make sure From within body is escaped if preceded by blank line
  1069. X&add_header("\nFrom mailagent");        # In effect adds an EOH
  1070. X&add_body(<<'NEW');
  1071. XThe following introduces a leading
  1072. XFrom line NOT preceded by a blank line
  1073. X
  1074. XFrom my point of view,
  1075. Xthe preceding should be escaped.
  1076. XNEW
  1077. Xunlink "$user";
  1078. X`$cmd`;
  1079. X$? == 0 || print "9\n";
  1080. X-f "$user" || print "10\n";                # Must still be there
  1081. X&get_log(11, $user);
  1082. X&check_log('^>From', 12) == 2 || print "13\n";
  1083. X&check_log('^From line', 14) == 1 || print "15\n";
  1084. X
  1085. Xunlink <emerg/*>;
  1086. Xunlink "$user", 'mail', 'ok';
  1087. Xprint "0\n";
  1088. END_OF_FILE
  1089.   if test 1222 -ne `wc -c <'agent/test/cmd/leave.t'`; then
  1090.     echo shar: \"'agent/test/cmd/leave.t'\" unpacked with wrong size!
  1091.   fi
  1092.   # end of 'agent/test/cmd/leave.t'
  1093. fi
  1094. if test -f 'agent/test/cmd/perl.t' -a "${1}" != "-c" ; then 
  1095.   echo shar: Will not clobber existing file \"'agent/test/cmd/perl.t'\"
  1096. else
  1097.   echo shar: Extracting \"'agent/test/cmd/perl.t'\" \(688 characters\)
  1098.   sed "s/^X//" >'agent/test/cmd/perl.t' <<'END_OF_FILE'
  1099. X# Test PERL command
  1100. Xdo '../pl/cmd.pl';
  1101. Xunlink 'perl.1', 'perl.2', 'never', 'always';
  1102. X
  1103. Xopen(PERL, ">perl.1") || print "1\n";
  1104. Xprint PERL <<'EOP';
  1105. X&save('always') || &save('never');
  1106. X&reject('-t');
  1107. X&save('never');
  1108. XEOP
  1109. Xclose PERL;
  1110. X
  1111. Xopen(PERL, ">perl.2") || print "2\n";
  1112. Xprint PERL <<'EOP';
  1113. Xunlink 'always' if -d '../out';
  1114. X&exit(0) if $ARGV[1] != 'arg 1' || $ARGV[2] != 'arg 2';
  1115. X&perl('perl.1');        # Recursion
  1116. X&save('never');
  1117. XEOP
  1118. Xclose PERL;
  1119. X
  1120. X&add_header('X-Tag: perl');
  1121. X`$cmd`;
  1122. X$? == 0 || print "3\n";
  1123. X-f "$user" && print "4\n";
  1124. X-f 'never' && print "5\n";
  1125. X&get_log(6, 'always');
  1126. X&check_log('^To: ram', 7) == 2 || print "8\n";
  1127. X
  1128. Xunlink 'mail', 'perl.1', 'perl.2', 'never', 'always';
  1129. Xprint "0\n";
  1130. END_OF_FILE
  1131.   if test 688 -ne `wc -c <'agent/test/cmd/perl.t'`; then
  1132.     echo shar: \"'agent/test/cmd/perl.t'\" unpacked with wrong size!
  1133.   fi
  1134.   # end of 'agent/test/cmd/perl.t'
  1135. fi
  1136. if test -f 'agent/test/cmd/save.t' -a "${1}" != "-c" ; then 
  1137.   echo shar: Will not clobber existing file \"'agent/test/cmd/save.t'\"
  1138. else
  1139.   echo shar: Extracting \"'agent/test/cmd/save.t'\" \(1131 characters\)
  1140.   sed "s/^X//" >'agent/test/cmd/save.t' <<'END_OF_FILE'
  1141. X# The SAVE command
  1142. Xdo '../pl/cmd.pl';
  1143. X$mbox = 'mbox';
  1144. X
  1145. X&add_header('X-Tag: save #1');
  1146. X`$cmd`;
  1147. X$? == 0 || print "1\n";
  1148. X-f "$mbox" || print "2\n";        # Mail saved here
  1149. X-f "$user" && print "3\n";        # Must not exist (yet)
  1150. X
  1151. X# When mailbox protected against writing...
  1152. Xunlink <emerg/*>;
  1153. X$size = -s "$mbox";
  1154. Xchmod 0444, "$mbox";
  1155. X`$cmd`;
  1156. X$? == 0 || print "4\n";
  1157. X-f "$mbox" || print "5\n";                # Must still be there
  1158. X$size == -s "$mbox" || print "6\n";        # And not altered
  1159. X@emerg = <emerg/*>;
  1160. X@emerg == 1 || print "7\n";                # Emeregency as SAVE failed
  1161. X-f "$user" || print "8\n";                # Not saved -> leave in mbox
  1162. X-s "$user" == -s "$mbox" || print "9\n";
  1163. X
  1164. X# There is no X-Filter mail in the emergency saving
  1165. X`grep -v X-Filter: $mbox > ok`;
  1166. X$? == 0 || print "10\n";
  1167. X-s $emerg[0] eq -s 'ok' || print "11\n";    # Full mail saved, of course
  1168. Xunlink "$mbox", "$user";
  1169. X
  1170. X# Make sure SAVE creates full path when needed
  1171. X&replace_header('X-Tag: save #2');
  1172. X`rm -rf path` if -d 'path';
  1173. X`$cmd`;
  1174. X$? == 0 || print "12\n";
  1175. X-f 'path/another/third/mbox' || print "13\n";
  1176. X
  1177. X`rm -rf path` if -d 'path';
  1178. Xunlink <emerg/*>;
  1179. Xunlink "$mbox", "$user", 'mail', 'ok';
  1180. Xprint "0\n";
  1181. END_OF_FILE
  1182.   if test 1131 -ne `wc -c <'agent/test/cmd/save.t'`; then
  1183.     echo shar: \"'agent/test/cmd/save.t'\" unpacked with wrong size!
  1184.   fi
  1185.   # end of 'agent/test/cmd/save.t'
  1186. fi
  1187. if test -f 'agent/test/cmd/store.t' -a "${1}" != "-c" ; then 
  1188.   echo shar: Will not clobber existing file \"'agent/test/cmd/store.t'\"
  1189. else
  1190.   echo shar: Extracting \"'agent/test/cmd/store.t'\" \(1263 characters\)
  1191.   sed "s/^X//" >'agent/test/cmd/store.t' <<'END_OF_FILE'
  1192. X# The STORE command
  1193. Xdo '../pl/cmd.pl';
  1194. X$mbox = 'mbox';
  1195. X
  1196. X&add_header('X-Tag: store #1');
  1197. X`$cmd`;
  1198. X$? == 0 || print "1\n";
  1199. X-f "$mbox" || print "2\n";        # Mail saved here
  1200. X-f "$user" || print "3\n";        # Leave copy in mailbox
  1201. X-s "$mbox" == -s "$user" || print "4\n";    # Same content
  1202. X
  1203. X# When mailbox protected against writing...
  1204. Xunlink <emerg/*>;
  1205. Xunlink "$user";
  1206. X$size = -s "$mbox";
  1207. Xchmod 0444, "$mbox";
  1208. X`$cmd`;
  1209. X$? == 0 || print "5\n";
  1210. X-f "$mbox" || print "6\n";                # Must still be there
  1211. X$size == -s "$mbox" || print "7\n";        # And not altered
  1212. X-f "$user" || print "8\n";                # Left only copy in mailbox
  1213. X$size == -s "$user" || print "9\n";        # Which must also match in size
  1214. X@emerg = <emerg/*>;
  1215. X@emerg == 1 || print "10\n";            # Emeregency as SAVE failed
  1216. X
  1217. X# There is no X-Filter mail in the emergency saving
  1218. X`grep -v X-Filter: $mbox > ok`;
  1219. X$? == 0 || print "11\n";
  1220. X-s $emerg[0] eq -s 'ok' || print "12\n";    # Full mail saved, of course
  1221. Xunlink "$mbox", "$user";
  1222. X
  1223. X# Make sure STORE creates full path when needed
  1224. X&replace_header('X-Tag: store #2');
  1225. X`rm -rf path` if -d 'path';
  1226. X`$cmd`;
  1227. X$? == 0 || print "13\n";
  1228. X-f 'path/another/third/mbox' || print "14\n";
  1229. X-f "$user" || print "15\n";
  1230. X
  1231. X`rm -rf path` if -d 'path';
  1232. Xunlink <emerg/*>;
  1233. Xunlink "$mbox", "$user", 'mail', 'ok';
  1234. Xprint "0\n";
  1235. END_OF_FILE
  1236.   if test 1263 -ne `wc -c <'agent/test/cmd/store.t'`; then
  1237.     echo shar: \"'agent/test/cmd/store.t'\" unpacked with wrong size!
  1238.   fi
  1239.   # end of 'agent/test/cmd/store.t'
  1240. fi
  1241. if test -f 'agent/test/cmd/strip.t' -a "${1}" != "-c" ; then 
  1242.   echo shar: Will not clobber existing file \"'agent/test/cmd/strip.t'\"
  1243. else
  1244.   echo shar: Extracting \"'agent/test/cmd/strip.t'\" \(1105 characters\)
  1245.   sed "s/^X//" >'agent/test/cmd/strip.t' <<'END_OF_FILE'
  1246. X# Test STRIP command
  1247. Xdo '../pl/cmd.pl';
  1248. Xunlink 'ok', 'no_resync';
  1249. X
  1250. X&add_header('X-Tag: strip');
  1251. X&add_header('X-Long-Line: this is a long line and has a continuation');
  1252. X&add_header('  right below it with a MARK token');
  1253. X&add_header('  and another with the MARK token');
  1254. X&add_header('X-Kept-Line: this is a long line and has a continuation');
  1255. X&add_header('  right below it with another mark TOKEN');
  1256. X&add_header('  and another with the mark TOKEN');
  1257. X`$cmd`;
  1258. X$? == 0 || print "1\n";
  1259. X-f "$user" && print "2\n";        # Mail saved...
  1260. X-f 'ok' || print "3\n";            # ...here
  1261. X&get_log(4, 'ok');
  1262. X¬_log('^Received:', 5);        # Make sure Received: disappeared
  1263. X&check_log('^To:', 6);            # But To: still here
  1264. X&check_log('^From:', 7);
  1265. X&check_log('^Subject:', 8);
  1266. X¬_log('^X-None:', 9);
  1267. X¬_log('MARK', 10);            # Continuation line must have been stripped too
  1268. X¬_log('X-Long-Line:', 11);    # As well as its parent
  1269. X&check_log('TOKEN', 12) == 2 || print "13\n";        # This one has been kept
  1270. X&check_log('X-Kept-Line:', 14);
  1271. X-f 'no_resync' || print "15\n";    # Ensure header not disturbed
  1272. X
  1273. Xunlink 'ok', 'no_resync', 'mail';
  1274. Xprint "0\n";
  1275. END_OF_FILE
  1276.   if test 1105 -ne `wc -c <'agent/test/cmd/strip.t'`; then
  1277.     echo shar: \"'agent/test/cmd/strip.t'\" unpacked with wrong size!
  1278.   fi
  1279.   # end of 'agent/test/cmd/strip.t'
  1280. fi
  1281. if test -f 'agent/test/filter/backref.t' -a "${1}" != "-c" ; then 
  1282.   echo shar: Will not clobber existing file \"'agent/test/filter/backref.t'\"
  1283. else
  1284.   echo shar: Extracting \"'agent/test/filter/backref.t'\" \(663 characters\)
  1285.   sed "s/^X//" >'agent/test/filter/backref.t' <<'END_OF_FILE'
  1286. X# Test backreferences
  1287. Xdo '../pl/filter.pl';
  1288. Xunlink 'output', 'comp.unix.wizards';
  1289. X
  1290. X&add_header('X-Tag: backref #1');
  1291. X`$cmd`;
  1292. X$? == 0 || print "1\n";
  1293. X-f "$user" && print "2\n";        # Must have been deleted
  1294. X-f 'output' || print "3\n";        # Created by RUN
  1295. Xchop($output = `cat output 2>/dev/null`);
  1296. X$output eq 'ref,,ram@eiffel.com,melting technology' || print "4\n";
  1297. X
  1298. X&replace_header('X-Tag: backref #2');
  1299. X&add_header('Newsgroups: comp.mail.mh,comp.unix.wizards,talk.bizarre');
  1300. X`$cmd`;
  1301. X$? == 0 || print "5\n";
  1302. X-f "$user" && print "6\n";                # Must have been saved
  1303. X-f 'comp.unix.wizards' || print "7\n";    # Created by SAVE
  1304. X
  1305. Xunlink 'output', 'comp.unix.wizards';
  1306. Xprint "0\n";
  1307. END_OF_FILE
  1308.   if test 663 -ne `wc -c <'agent/test/filter/backref.t'`; then
  1309.     echo shar: \"'agent/test/filter/backref.t'\" unpacked with wrong size!
  1310.   fi
  1311.   # end of 'agent/test/filter/backref.t'
  1312. fi
  1313. if test -f 'agent/test/filter/default.t' -a "${1}" != "-c" ; then 
  1314.   echo shar: Will not clobber existing file \"'agent/test/filter/default.t'\"
  1315. else
  1316.   echo shar: Extracting \"'agent/test/filter/default.t'\" \(861 characters\)
  1317.   sed "s/^X//" >'agent/test/filter/default.t' <<'END_OF_FILE'
  1318. X# Make sure default actions apply correctly
  1319. Xdo '../pl/filter.pl';
  1320. X
  1321. X&add_header('X-Tag: default #1');
  1322. X`$cmd`;
  1323. X$? == 0 || print "1\n";
  1324. X-f "$user" && print "2\n";        # Must have been deleted
  1325. X
  1326. X&replace_header('X-Tag: default #2');
  1327. X`$cmd`;
  1328. X$? == 0 || print "3\n";
  1329. X-f "$user" || print "4\n";        # A NOP -> default action leave
  1330. X&get_mbox(5);
  1331. X
  1332. X&replace_header('X-Tag: never matched');
  1333. X`$cmd`;
  1334. X$? == 0 || print "6\n";
  1335. X-f "$user" || print "7\n";        # No match -> default action
  1336. X&get_mbox(8);
  1337. X$mbox2 eq $mbox1 || print "9\n";
  1338. X
  1339. X&replace_header('X-Tag: unknonw');
  1340. X`$cmd`;
  1341. X$? == 0 || print "10\n";
  1342. X-f "$user" || print "11\n";        # Unknown action without previous saving
  1343. X&get_mbox(12);
  1344. X$mbox2 eq $mbox1 || print "13\n";
  1345. Xunlink 'mail';
  1346. Xprint "0\n";
  1347. X
  1348. Xsub get_mbox {
  1349. X    local($num);
  1350. X    undef $/;
  1351. X    open(MBOX, "$user");
  1352. X    eval "$mbox$num = <MBOX>";
  1353. X    close MBOX;
  1354. X    $/ = "\n";
  1355. X    unlink "$user";
  1356. X}
  1357. X
  1358. END_OF_FILE
  1359.   if test 861 -ne `wc -c <'agent/test/filter/default.t'`; then
  1360.     echo shar: \"'agent/test/filter/default.t'\" unpacked with wrong size!
  1361.   fi
  1362.   # end of 'agent/test/filter/default.t'
  1363. fi
  1364. if test -f 'agent/test/filter/multiple.t' -a "${1}" != "-c" ; then 
  1365.   echo shar: Will not clobber existing file \"'agent/test/filter/multiple.t'\"
  1366. else
  1367.   echo shar: Extracting \"'agent/test/filter/multiple.t'\" \(656 characters\)
  1368.   sed "s/^X//" >'agent/test/filter/multiple.t' <<'END_OF_FILE'
  1369. X# Test matches with multiple headers
  1370. Xdo '../pl/filter.pl';
  1371. X
  1372. Xfor ($i = 1; $i <= 3; $i++) {
  1373. X    unlink "$user.$i";
  1374. X}
  1375. X
  1376. X&add_header('X-Tag: multiple #1');
  1377. X`$cmd`;
  1378. X$? == 0 || print "1\n";
  1379. X-f "$user.1" || print "2\n";    # Selection worked
  1380. Xunlink "$user.1";
  1381. X
  1382. X&replace_header('X-Tag: multiple #2');
  1383. X&add_header('X-Other: multiple #2');
  1384. X`$cmd`;
  1385. X$? == 0 || print "3\n";
  1386. X-f "$user.2" || print "4\n";    # Selection worked
  1387. Xunlink "$user.2";
  1388. X
  1389. X&add_header('X-Other: another');
  1390. X`$cmd`;
  1391. X$? == 0 || print "5\n";
  1392. X-f "$user.3" || print "6\n";    # Selection worked
  1393. X-f "$user.2" || print "7\n";    # Selection on non-existent field
  1394. Xunlink "$user.2", "$user.3";
  1395. X
  1396. Xunlink 'mail';
  1397. Xprint "0\n";
  1398. END_OF_FILE
  1399.   if test 656 -ne `wc -c <'agent/test/filter/multiple.t'`; then
  1400.     echo shar: \"'agent/test/filter/multiple.t'\" unpacked with wrong size!
  1401.   fi
  1402.   # end of 'agent/test/filter/multiple.t'
  1403. fi
  1404. if test -f 'agent/test/filter/not.t' -a "${1}" != "-c" ; then 
  1405.   echo shar: Will not clobber existing file \"'agent/test/filter/not.t'\"
  1406. else
  1407.   echo shar: Extracting \"'agent/test/filter/not.t'\" \(681 characters\)
  1408.   sed "s/^X//" >'agent/test/filter/not.t' <<'END_OF_FILE'
  1409. X# Test negation pattern matching with '!'
  1410. Xdo '../pl/filter.pl';
  1411. Xunlink 'never', 'always', 'always.2', 'always.3';
  1412. X
  1413. X&add_header('X-Tag: not #1');
  1414. X`$cmd`;
  1415. X$? == 0 || print "1\n";
  1416. X-f "$user" && print "2\n";        # Mail has been deleted
  1417. X-f 'never' && print "3\n";        # Cannot match
  1418. X-f 'always' || print "4\n";        # This one must have matched
  1419. X-f 'always.2' || print "5\n";    # Did not match, but '!' saves us
  1420. X-f 'always.3' || print "6\n";    # No pattern from file matched
  1421. Xunlink 'never', 'always', 'always.2', 'always.3';
  1422. X
  1423. X&replace_header('X-Tag: not #2');
  1424. X`$cmd`;
  1425. X$? == 0 || print "7\n";
  1426. X-f "$user" && print "8\n";        # Mail has been saved
  1427. X-f 'always' || print "9\n";
  1428. Xunlink 'always';
  1429. X
  1430. Xprint "0\n";
  1431. END_OF_FILE
  1432.   if test 681 -ne `wc -c <'agent/test/filter/not.t'`; then
  1433.     echo shar: \"'agent/test/filter/not.t'\" unpacked with wrong size!
  1434.   fi
  1435.   # end of 'agent/test/filter/not.t'
  1436. fi
  1437. if test -f 'agent/test/option/d.t' -a "${1}" != "-c" ; then 
  1438.   echo shar: Will not clobber existing file \"'agent/test/option/d.t'\"
  1439. else
  1440.   echo shar: Extracting \"'agent/test/option/d.t'\" \(739 characters\)
  1441.   sed "s/^X//" >'agent/test/option/d.t' <<'END_OF_FILE'
  1442. X# -d: dump filter rules (special)
  1443. Xdo '../pl/init.pl';
  1444. Xdo '../pl/logfile.pl';
  1445. Xchdir '../out';
  1446. Xunlink '.rules';
  1447. X# With no rule file, verify it dumps the default rules
  1448. X$output = `$mailagent -d`;
  1449. X$? == 0 || print "1\n";
  1450. X@log = split(/\n/, $output);    # want to use check_log()
  1451. X&check_log('# Rule 1', 2);
  1452. X&check_log('PROCESS', 3);
  1453. X# With an empty rule file, we must also have the default rules
  1454. Xopen(RULES, ">.rules");
  1455. Xclose RULES;
  1456. X$output_bis = `$mailagent -d`;
  1457. X$? == 0 || print "4\n";
  1458. X$output_bis eq $output || print "5\n";
  1459. X# Now check with some rules
  1460. X`cp ../rules .rules`;
  1461. X$output = `$mailagent -d`;
  1462. X$? == 0 || print "6\n";
  1463. X@log = split(/\n/, $output);    # want to use check_log()
  1464. X&check_log('# Rule 1', 7);
  1465. X&check_log('DELETE', 8);
  1466. Xprint "0\n";
  1467. END_OF_FILE
  1468.   if test 739 -ne `wc -c <'agent/test/option/d.t'`; then
  1469.     echo shar: \"'agent/test/option/d.t'\" unpacked with wrong size!
  1470.   fi
  1471.   # end of 'agent/test/option/d.t'
  1472. fi
  1473. if test -f 'agent/test/option/e.t' -a "${1}" != "-c" ; then 
  1474.   echo shar: Will not clobber existing file \"'agent/test/option/e.t'\"
  1475. else
  1476.   echo shar: Extracting \"'agent/test/option/e.t'\" \(1041 characters\)
  1477.   sed "s/^X//" >'agent/test/option/e.t' <<'END_OF_FILE'
  1478. X# -e : enter rules to be applied
  1479. Xdo '../pl/init.pl';
  1480. Xdo '../pl/logfile.pl';
  1481. Xchdir '../out';
  1482. X$output = `$mailagent -e '{ OWN_RULE_1 };' -e '{OWN_RULE_2 };' -d`;
  1483. X$? == 0 || print "1\n";
  1484. X@log = split(/\n/, $output);    # want to use check_log()
  1485. X&check_log('OWN_RULE_1', 2);
  1486. X&check_log('OWN_RULE_2', 3);
  1487. X# Single rule may not be specified between {}
  1488. X$output = `$mailagent -e 'SINGLE' -d`;
  1489. X$? == 0 || print "4\n";
  1490. X$output_bis = `$mailagent -e '{ SINGLE }' -d`;
  1491. X$? == 0 || print "5\n";
  1492. X$output eq $output_bis || print "6\n";
  1493. X$output = `$mailagent -e 'SINGLE' -e '{ OTHER }' -d`;
  1494. X$? == 0 || print "7\n";
  1495. X$output_bis = `$mailagent -e '{ SINGLE };' -e '{ OTHER }' -d`;
  1496. X$? == 0 || print "8\n";
  1497. X$output ne $output_bis || print "9\n";
  1498. X@log = split(/\n/, $output);
  1499. Xgrep(/# Rule 2/, @log) && print "10\n";            # Only one rule
  1500. Xgrep(/Subject: SINGLE/, @log) || print "11\n";    # No selector -> Subject
  1501. X@log = split(/\n/, $output_bis);
  1502. Xgrep(/# Rule 2/, @log) || print "12\n";            # Two rules
  1503. Xgrep(/Subject: \*/, @log) || print "13\n";        # No pattern -> *
  1504. Xprint "0\n";
  1505. END_OF_FILE
  1506.   if test 1041 -ne `wc -c <'agent/test/option/e.t'`; then
  1507.     echo shar: \"'agent/test/option/e.t'\" unpacked with wrong size!
  1508.   fi
  1509.   # end of 'agent/test/option/e.t'
  1510. fi
  1511. if test -f 'agent/test/option/f.t' -a "${1}" != "-c" ; then 
  1512.   echo shar: Will not clobber existing file \"'agent/test/option/f.t'\"
  1513. else
  1514.   echo shar: Extracting \"'agent/test/option/f.t'\" \(1191 characters\)
  1515.   sed "s/^X//" >'agent/test/option/f.t' <<'END_OF_FILE'
  1516. X# -f: get messages from UNIX-style mailbox file
  1517. Xdo '../pl/init.pl';
  1518. Xdo '../pl/logfile.pl';
  1519. Xchdir '../out';
  1520. Xunlink 'agentlog';
  1521. X$user = $ENV{'USER'};
  1522. Xunlink "$user";
  1523. Xopen(MBOX, ">mbox") || print "1\n";
  1524. Xprint MBOX <<'EOM';
  1525. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1526. XFrom: ram
  1527. XTo: ram
  1528. XSubject: test #1
  1529. X
  1530. XBody #1
  1531. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1532. XPrevious line is just a dummy From line.
  1533. X
  1534. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1535. XFrom: ram
  1536. XTo: ram
  1537. XSubject: test #2
  1538. X
  1539. XBody #2
  1540. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1541. XFrom: nearly a header!!
  1542. XPrevious 2 lines are just dummy lines.
  1543. X
  1544. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1545. XFrom: ram
  1546. XTo: ram
  1547. XSubject: test #3
  1548. X
  1549. XBody #3
  1550. XEOM
  1551. Xclose MBOX;
  1552. X`$mailagent -e 'LEAVE' -f mbox 2>/dev/null`;
  1553. X$? == 0 || print "2\n";
  1554. X-s "$user" || print "3\n";
  1555. X&get_log(4);
  1556. X@queued = grep(/QUEUED/, @log);
  1557. X@queued == 3 || print "5\n";
  1558. X@subject = grep(/ABOUT.*test/, @log);
  1559. X@subject == 3 || print "6\n";
  1560. X@filtered = grep(/FILTERED/, @log);
  1561. X@filtered == 3 || print "7\n";
  1562. X@files = <queue/*>;
  1563. X@files == 0 || print "8\n";
  1564. Xopen(MBOX, "$user") || print "9\n";
  1565. X@mbox = <MBOX>;
  1566. Xclose MBOX;
  1567. X@msg = grep(/^X-Filter:/, @mbox);
  1568. X@msg == 3 || print "10\n";
  1569. Xunlink 'agentlog', "$user", 'mbox';
  1570. Xprint "0\n";
  1571. END_OF_FILE
  1572.   if test 1191 -ne `wc -c <'agent/test/option/f.t'`; then
  1573.     echo shar: \"'agent/test/option/f.t'\" unpacked with wrong size!
  1574.   fi
  1575.   # end of 'agent/test/option/f.t'
  1576. fi
  1577. if test -f 'agent/test/option/l.t' -a "${1}" != "-c" ; then 
  1578.   echo shar: Will not clobber existing file \"'agent/test/option/l.t'\"
  1579. else
  1580.   echo shar: Extracting \"'agent/test/option/l.t'\" \(1040 characters\)
  1581.   sed "s/^X//" >'agent/test/option/l.t' <<'END_OF_FILE'
  1582. X# -l: list message queue (special)
  1583. Xdo '../pl/init.pl';
  1584. Xchdir '../out';
  1585. Xunlink <queue/*>;
  1586. Xopen(MBOX, ">mbox") || print "1\n";
  1587. Xprint MBOX <<'EOM';
  1588. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1589. XFrom: ram
  1590. XTo: ram
  1591. XSubject: test #1
  1592. X
  1593. XBody #1
  1594. X
  1595. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1596. XFrom: ram
  1597. XTo: ram
  1598. XSubject: test #2
  1599. X
  1600. XBody #2
  1601. X
  1602. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1603. XFrom: ram
  1604. XTo: ram
  1605. XSubject: test #3
  1606. X
  1607. XBody #3
  1608. XEOM
  1609. Xclose MBOX;
  1610. X`$mailagent -f mbox -e 'QUEUE' 2>/dev/null`;
  1611. X$? == 0 || print "2\n";
  1612. X@output = split(/\n/, $output = `$mailagent -l 2>/dev/null`);
  1613. X@files = <queue/*>;
  1614. X@files == 3 || print "3\n";    # Not a -l failure, but that will get our attention
  1615. Xforeach $file (@files) {
  1616. X    $file =~ s|^queue/||;
  1617. X    eval "grep(/$file/, \@output)" || $failed++;
  1618. X}
  1619. X$failed == 0 || print "4\n";
  1620. X# Invoking mailagent as `mailqueue' lists the queue.
  1621. Xunlink 'mailqueue';
  1622. X`ln $mailagent_path ./mailqueue 2>/dev/null`;
  1623. X$? == 0 || print "5\n";
  1624. X$output_bis = `./mailqueue 2>/dev/null`;
  1625. X$output eq $output_bis || print "6\n";
  1626. Xunlink <queue/*>, 'mbox', 'mailqueue';
  1627. Xprint "0\n";
  1628. END_OF_FILE
  1629.   if test 1040 -ne `wc -c <'agent/test/option/l.t'`; then
  1630.     echo shar: \"'agent/test/option/l.t'\" unpacked with wrong size!
  1631.   fi
  1632.   # end of 'agent/test/option/l.t'
  1633. fi
  1634. if test -f 'agent/test/option/q.t' -a "${1}" != "-c" ; then 
  1635.   echo shar: Will not clobber existing file \"'agent/test/option/q.t'\"
  1636. else
  1637.   echo shar: Extracting \"'agent/test/option/q.t'\" \(900 characters\)
  1638.   sed "s/^X//" >'agent/test/option/q.t' <<'END_OF_FILE'
  1639. X# -q: process the queue (special)
  1640. Xdo '../pl/init.pl';
  1641. Xchdir '../out';
  1642. Xunlink <queue/*>;
  1643. Xopen(MBOX, ">mbox") || print "1\n";
  1644. Xprint MBOX <<'EOM';
  1645. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1646. XFrom: ram
  1647. XTo: ram
  1648. XSubject: test #1
  1649. X
  1650. XBody #1
  1651. X
  1652. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1653. XFrom: ram
  1654. XTo: ram
  1655. XSubject: test #2
  1656. X
  1657. XBody #2
  1658. X
  1659. XFrom ram Sat Jul 11 17:17:12 PDT 1992
  1660. XFrom: ram
  1661. XTo: ram
  1662. XSubject: test #3
  1663. X
  1664. XBody #3
  1665. XEOM
  1666. Xclose MBOX;
  1667. X`$mailagent -f mbox -e 'QUEUE' 2>/dev/null`;
  1668. X$? == 0 || print "2\n";
  1669. X$user = $ENV{'USER'};
  1670. Xunlink "$user";
  1671. X`$mailagent -e 'LEAVE' -q 2>/dev/null`;
  1672. X-f "$user" && print "3\n";
  1673. X@queue = <queue/*>;
  1674. X@queue == 3 || print "4\n";        # Still deferred for 30 minutes
  1675. X$now = time;
  1676. X$now -= 31 * 60;
  1677. Xutime $now, $now, @queue;
  1678. X`$mailagent -e 'LEAVE' -q 2>/dev/null`;
  1679. X-f "$user" || print "5\n";
  1680. X@queue = <queue/*>;
  1681. X@queue == 0 || print "6\n";        # Mails have been processed
  1682. Xunlink "$user", 'mbox';
  1683. Xprint "0\n";
  1684. END_OF_FILE
  1685.   if test 900 -ne `wc -c <'agent/test/option/q.t'`; then
  1686.     echo shar: \"'agent/test/option/q.t'\" unpacked with wrong size!
  1687.   fi
  1688.   # end of 'agent/test/option/q.t'
  1689. fi
  1690. if test -f 'agent/test/pl/mail.pl' -a "${1}" != "-c" ; then 
  1691.   echo shar: Will not clobber existing file \"'agent/test/pl/mail.pl'\"
  1692. else
  1693.   echo shar: Extracting \"'agent/test/pl/mail.pl'\" \(916 characters\)
  1694.   sed "s/^X//" >'agent/test/pl/mail.pl' <<'END_OF_FILE'
  1695. X# Utilities to twinkle default mail message
  1696. X
  1697. X# Add header line within message
  1698. Xsub add_header {
  1699. X    local($header, $file) = @_;
  1700. X    $file = 'mail' unless $file;
  1701. X    local($_);
  1702. X    open(NEW, ">$file.x");
  1703. X    open(OLD, "$file");
  1704. X    while (<OLD>) {
  1705. X        print NEW $header, "\n" if (1../^$/) && /^$/;
  1706. X        print NEW;
  1707. X    }
  1708. X    close NEW;
  1709. X    close OLD;
  1710. X    rename("$file.x", "$file");
  1711. X}
  1712. X
  1713. X# Change first matching header with new value
  1714. Xsub replace_header {
  1715. X    local($header, $file) = @_;
  1716. X    $file = 'mail' unless $file;
  1717. X    local($field) = $header =~ /^(\S+):/;
  1718. X    local($_);
  1719. X    open(NEW, ">$file.x");
  1720. X    open(OLD, "$file");
  1721. X    while (<OLD>) {
  1722. X        if ((1../^$/) && eval "/^$field:/") {
  1723. X            print NEW $header, "\n";
  1724. X            next;
  1725. X        }
  1726. X        print NEW;
  1727. X    }
  1728. X    close NEW;
  1729. X    close OLD;
  1730. X    rename("$file.x", "$file");
  1731. X}
  1732. X
  1733. X# Add line at the end of the mail message
  1734. Xsub add_body {
  1735. X    local($line, $file) = @_;
  1736. X    $file = 'mail' unless $file;
  1737. X    open(NEW, ">>$file");
  1738. X    print NEW $line, "\n";
  1739. X    close NEW;
  1740. X}
  1741. X
  1742. END_OF_FILE
  1743.   if test 916 -ne `wc -c <'agent/test/pl/mail.pl'`; then
  1744.     echo shar: \"'agent/test/pl/mail.pl'\" unpacked with wrong size!
  1745.   fi
  1746.   # end of 'agent/test/pl/mail.pl'
  1747. fi
  1748. echo shar: End of archive 16 \(of 17\).
  1749. cp /dev/null ark16isdone
  1750. MISSING=""
  1751. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; do
  1752.     if test ! -f ark${I}isdone ; then
  1753.     MISSING="${MISSING} ${I}"
  1754.     fi
  1755. done
  1756. if test "${MISSING}" = "" ; then
  1757.     echo You have unpacked all 17 archives.
  1758.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1759. else
  1760.     echo You still must unpack the following archives:
  1761.     echo "        " ${MISSING}
  1762. fi
  1763. exit 0
  1764. exit 0 # Just in case...
  1765.