home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume33 / mailagnt / part16 < prev    next >
Encoding:
Text File  |  1992-11-20  |  54.0 KB  |  1,759 lines

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