home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume41 / mailagnt / part21 < prev    next >
Encoding:
Text File  |  1993-12-03  |  54.7 KB  |  1,717 lines

  1. Newsgroups: comp.sources.misc
  2. From: Raphael Manfredi <ram@acri.fr>
  3. Subject: v41i021:  mailagent - Flexible mail filtering and processing package, v3.0, Part21/26
  4. Message-ID: <1993Dec3.213510.22993@sparky.sterling.com>
  5. X-Md4-Signature: 3c5d388e6d8c5962220eea2d4b3b6c42
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Advanced Computer Research Institute, Lyon, France.
  8. Date: Fri, 3 Dec 1993 21:35:10 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: Raphael Manfredi <ram@acri.fr>
  12. Posting-number: Volume 41, Issue 21
  13. Archive-name: mailagent/part21
  14. Environment: UNIX, Perl
  15. Supersedes: mailagent: Volume 33, Issue 93-109
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  22. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  23. # Contents:  agent/files/help/newpower.SH agent/files/help/release.SH
  24. #   agent/files/help/user.SH agent/filter/hash.h agent/filter/msg.c
  25. #   agent/filter/user.c agent/mailhelp.SH agent/pl/include.pl
  26. #   agent/pl/mailhook.pl agent/pl/once.pl agent/test/basic/filter.t
  27. #   agent/test/cmd/keep.t agent/test/cmd/once.t
  28. #   agent/test/cmd/record.t agent/test/cmd/store.t
  29. #   agent/test/cmd/strip.t agent/test/cmd/unique.t
  30. #   agent/test/cmd/write.t agent/test/misc/mh.t
  31. #   agent/test/misc/newcmd.t agent/test/option/s.t misc/unkit/rules
  32. # Wrapped by ram@soft208 on Mon Nov 29 16:49:57 1993
  33. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  34. echo If this archive is complete, you will see the following message:
  35. echo '          "shar: End of archive 21 (of 26)."'
  36. if test -f 'agent/files/help/newpower.SH' -a "${1}" != "-c" ; then 
  37.   echo shar: Will not clobber existing file \"'agent/files/help/newpower.SH'\"
  38. else
  39.   echo shar: Extracting \"'agent/files/help/newpower.SH'\" \(1900 characters\)
  40.   sed "s/^X//" >'agent/files/help/newpower.SH' <<'END_OF_FILE'
  41. Xcase $CONFIG in
  42. X'')
  43. X    if test -f config.sh; then TOP=.;
  44. X    elif test -f ../config.sh; then TOP=..;
  45. X    elif test -f ../../config.sh; then TOP=../..;
  46. X    elif test -f ../../../config.sh; then TOP=../../..;
  47. X    elif test -f ../../../../config.sh; then TOP=../../../..;
  48. X    else
  49. X        echo "Can't find config.sh."; exit 1
  50. X    fi
  51. X    . $TOP/config.sh
  52. X    ;;
  53. Xesac
  54. Xcase "$0" in
  55. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  56. Xesac
  57. Xecho "Extracting agent/files/help/newpower (with variable substitutions)"
  58. X$spitshell >/dev/null <<!GROK!THIS!
  59. X# $Id: newpower.SH,v 3.0 1993/11/29 13:47:57 ram Exp ram $
  60. X#
  61. X#  Copyright (c) 1990-1993, Raphael Manfredi
  62. X#  
  63. X#  You may redistribute only under the terms of the Artistic License,
  64. X#  as specified in the README file that comes with the distribution.
  65. X#  You may reuse parts of this distribution only within the terms of
  66. X#  that same Artistic License; a copy of which may be found at the root
  67. X#  of the source tree for mailagent 3.0.
  68. X#
  69. X# $Log: newpower.SH,v $
  70. X# Revision 3.0  1993/11/29  13:47:57  ram
  71. X# Baseline for mailagent 3.0 netwide release.
  72. X#
  73. X!GROK!THIS!
  74. X$spitshell >newpower <<'!NO!SUBS!'
  75. XNAME
  76. X
  77. X    newpower -- Adds a new power to the system
  78. X
  79. XSYNOPSIS
  80. X
  81. X    newpower power password [alias]
  82. X    ... users ...
  83. X    EOF
  84. X
  85. XDESCRIPTION
  86. X
  87. XThis command creates a new server power and assigns a password to protect it.
  88. XIf the power name is longer than 12 characters, you may specify an alias for
  89. Xthat power, which will be used internally by mailagent to reference it, or
  90. Xleave the field blank and mailagent will generate one for you.
  91. X
  92. XThe 'system' power is normally required to create a new power. The 'security'
  93. Xpower is required to create the root power and the 'root' power is needed to
  94. Xcreate 'security'. In order to bootstrap either power, please refer to the
  95. Xmailagent manual page where this is explained in detail.
  96. X
  97. XEXAMPLE
  98. X
  99. X    newpower list-power mypasswd
  100. X    ram@acri.fr
  101. X    ram@eiffel.com
  102. X    EOF
  103. X!NO!SUBS!
  104. Xchmod 644 newpower
  105. END_OF_FILE
  106.   if test 1900 -ne `wc -c <'agent/files/help/newpower.SH'`; then
  107.     echo shar: \"'agent/files/help/newpower.SH'\" unpacked with wrong size!
  108.   fi
  109.   chmod +x 'agent/files/help/newpower.SH'
  110.   # end of 'agent/files/help/newpower.SH'
  111. fi
  112. if test -f 'agent/files/help/release.SH' -a "${1}" != "-c" ; then 
  113.   echo shar: Will not clobber existing file \"'agent/files/help/release.SH'\"
  114. else
  115.   echo shar: Extracting \"'agent/files/help/release.SH'\" \(1745 characters\)
  116.   sed "s/^X//" >'agent/files/help/release.SH' <<'END_OF_FILE'
  117. Xcase $CONFIG in
  118. X'')
  119. X    if test -f config.sh; then TOP=.;
  120. X    elif test -f ../config.sh; then TOP=..;
  121. X    elif test -f ../../config.sh; then TOP=../..;
  122. X    elif test -f ../../../config.sh; then TOP=../../..;
  123. X    elif test -f ../../../../config.sh; then TOP=../../../..;
  124. X    else
  125. X        echo "Can't find config.sh."; exit 1
  126. X    fi
  127. X    . $TOP/config.sh
  128. X    ;;
  129. Xesac
  130. Xcase "$0" in
  131. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  132. Xesac
  133. Xecho "Extracting agent/files/help/release (with variable substitutions)"
  134. X$spitshell >/dev/null <<!GROK!THIS!
  135. X# $Id: release.SH,v 3.0 1993/11/29 13:47:58 ram Exp ram $
  136. X#
  137. X#  Copyright (c) 1990-1993, Raphael Manfredi
  138. X#  
  139. X#  You may redistribute only under the terms of the Artistic License,
  140. X#  as specified in the README file that comes with the distribution.
  141. X#  You may reuse parts of this distribution only within the terms of
  142. X#  that same Artistic License; a copy of which may be found at the root
  143. X#  of the source tree for mailagent 3.0.
  144. X#
  145. X# $Log: release.SH,v $
  146. X# Revision 3.0  1993/11/29  13:47:58  ram
  147. X# Baseline for mailagent 3.0 netwide release.
  148. X#
  149. X!GROK!THIS!
  150. X$spitshell >release <<'!NO!SUBS!'
  151. XNAME
  152. X
  153. X    release -- Releases power
  154. X
  155. XSYNOPSIS
  156. X
  157. X    release name
  158. X
  159. XDESCRIPTION
  160. X
  161. XThis command releases the specified power.
  162. X
  163. XIf the 'root' power is releases, other powers obtained while root or before
  164. Xare kept. That way, it makes sense to ask for powers while root, when the
  165. Xpassword for some minor power has been change, since you do not need to
  166. Xsupply it. Then 'root' may be released and the work continued with the
  167. Xminor power handy.
  168. X
  169. XIt is not recommend to run an entire session with 'root' privileges, unless
  170. Xneeded to bypass some restrictions like the maximum number of commands that
  171. Xmay be issued in a session.
  172. X
  173. XEXAMPLE
  174. X
  175. X    release list
  176. X!NO!SUBS!
  177. Xchmod 644 release
  178. END_OF_FILE
  179.   if test 1745 -ne `wc -c <'agent/files/help/release.SH'`; then
  180.     echo shar: \"'agent/files/help/release.SH'\" unpacked with wrong size!
  181.   fi
  182.   chmod +x 'agent/files/help/release.SH'
  183.   # end of 'agent/files/help/release.SH'
  184. fi
  185. if test -f 'agent/files/help/user.SH' -a "${1}" != "-c" ; then 
  186.   echo shar: Will not clobber existing file \"'agent/files/help/user.SH'\"
  187. else
  188.   echo shar: Extracting \"'agent/files/help/user.SH'\" \(1958 characters\)
  189.   sed "s/^X//" >'agent/files/help/user.SH' <<'END_OF_FILE'
  190. Xcase $CONFIG in
  191. X'')
  192. X    if test -f config.sh; then TOP=.;
  193. X    elif test -f ../config.sh; then TOP=..;
  194. X    elif test -f ../../config.sh; then TOP=../..;
  195. X    elif test -f ../../../config.sh; then TOP=../../..;
  196. X    elif test -f ../../../../config.sh; then TOP=../../../..;
  197. X    else
  198. X        echo "Can't find config.sh."; exit 1
  199. X    fi
  200. X    . $TOP/config.sh
  201. X    ;;
  202. Xesac
  203. Xcase "$0" in
  204. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  205. Xesac
  206. Xecho "Extracting agent/files/help/user (with variable substitutions)"
  207. X$spitshell >/dev/null <<!GROK!THIS!
  208. X# $Id: user.SH,v 3.0 1993/11/29 13:48:01 ram Exp ram $
  209. X#
  210. X#  Copyright (c) 1990-1993, Raphael Manfredi
  211. X#  
  212. X#  You may redistribute only under the terms of the Artistic License,
  213. X#  as specified in the README file that comes with the distribution.
  214. X#  You may reuse parts of this distribution only within the terms of
  215. X#  that same Artistic License; a copy of which may be found at the root
  216. X#  of the source tree for mailagent 3.0.
  217. X#
  218. X# $Log: user.SH,v $
  219. X# Revision 3.0  1993/11/29  13:48:01  ram
  220. X# Baseline for mailagent 3.0 netwide release.
  221. X#
  222. X!GROK!THIS!
  223. X$spitshell >user <<'!NO!SUBS!'
  224. XNAME
  225. X
  226. X    user -- Runs a command on behalf of another user
  227. X
  228. XSYNOPSIS
  229. X
  230. X    user [name [command]]
  231. X
  232. XDESCRIPTION
  233. X
  234. XThis command may be used to execute some other commands on behalf of a user.
  235. X
  236. XIf a command is specified, it is immediately executed under the new identity
  237. X(which is merely an e-mail address), and that new identity only lasts for
  238. Xthat single command. Otherwise, the remaining commands are executed with the
  239. Xnew identity.
  240. X
  241. XIf no user name is specified, the original sender identity is restored.
  242. X
  243. XAll the powers are lost when the 'user' command is executed, but this is
  244. Xonly temporary when a command is specified on the same line.
  245. X
  246. XNote that it is up to the command to make use of this "effective" user
  247. Xidentity, by looking at the proper environment variables.
  248. X
  249. XEXAMPLES
  250. X
  251. X    user root@acri.fr
  252. X    ... some commands ...
  253. X    user
  254. X    user ram@acri.fr subscribe agent-users
  255. X!NO!SUBS!
  256. Xchmod 644 user
  257. END_OF_FILE
  258.   if test 1958 -ne `wc -c <'agent/files/help/user.SH'`; then
  259.     echo shar: \"'agent/files/help/user.SH'\" unpacked with wrong size!
  260.   fi
  261.   chmod +x 'agent/files/help/user.SH'
  262.   # end of 'agent/files/help/user.SH'
  263. fi
  264. if test -f 'agent/filter/hash.h' -a "${1}" != "-c" ; then 
  265.   echo shar: Will not clobber existing file \"'agent/filter/hash.h'\"
  266. else
  267.   echo shar: Extracting \"'agent/filter/hash.h'\" \(1960 characters\)
  268.   sed "s/^X//" >'agent/filter/hash.h' <<'END_OF_FILE'
  269. X/*
  270. X
  271. X #    #    ##     ####   #    #          #    #
  272. X #    #   #  #   #       #    #          #    #
  273. X ######  #    #   ####   ######          ######
  274. X #    #  ######       #  #    #   ###    #    #
  275. X #    #  #    #  #    #  #    #   ###    #    #
  276. X #    #  #    #   ####   #    #   ###    #    #
  277. X
  278. X    Declarations for hash table.
  279. X*/
  280. X
  281. X/*
  282. X * $Id: hash.h,v 3.0 1993/11/29 13:48:09 ram Exp ram $
  283. X *
  284. X *  Copyright (c) 1990-1993, Raphael Manfredi
  285. X *  
  286. X *  You may redistribute only under the terms of the Artistic License,
  287. X *  as specified in the README file that comes with the distribution.
  288. X *  You may reuse parts of this distribution only within the terms of
  289. X *  that same Artistic License; a copy of which may be found at the root
  290. X *  of the source tree for mailagent 3.0.
  291. X *
  292. X * $Log: hash.h,v $
  293. X * Revision 3.0  1993/11/29  13:48:09  ram
  294. X * Baseline for mailagent 3.0 netwide release.
  295. X *
  296. X */
  297. X
  298. X#ifndef _hash_h
  299. X#define _hash_h
  300. X
  301. X/* Structure which describes the hash table: array of keys and array of
  302. X * values, along with the table's size and the number of recorded elements.
  303. X */
  304. Xstruct htable {
  305. X    int32 h_size;        /* Size of table (prime number) */
  306. X    int32 h_items;        /* Number of items recorded in table */
  307. X    char **h_keys;        /* Array of keys (strings) */
  308. X    int h_pos;            /* Last position in table (iterations) */
  309. X    char **h_values;    /* Array of values (strings) */
  310. X};
  311. X
  312. X/* Function declaration */
  313. Xextern int ht_create();                /* Create H table */
  314. Xextern char *ht_value();            /* Get value given some key */
  315. Xextern char *ht_put();                /* Insert value in H table */
  316. Xextern char *ht_force();            /* Like ht_put, but replace old value */
  317. Xextern int ht_xtend();                /* Extend size of full H table */
  318. Xextern int ht_start();                /* Start iteration over H table */
  319. Xextern int ht_next();                /* Go to next item in H table */
  320. Xextern char *ht_ckey();                /* Fetch current key */
  321. Xextern char *ht_cvalue();            /* Fetch current value */
  322. Xextern int ht_count();                /* Number of items in H table */
  323. X
  324. X#endif
  325. END_OF_FILE
  326.   if test 1960 -ne `wc -c <'agent/filter/hash.h'`; then
  327.     echo shar: \"'agent/filter/hash.h'\" unpacked with wrong size!
  328.   fi
  329.   # end of 'agent/filter/hash.h'
  330. fi
  331. if test -f 'agent/filter/msg.c' -a "${1}" != "-c" ; then 
  332.   echo shar: Will not clobber existing file \"'agent/filter/msg.c'\"
  333. else
  334.   echo shar: Extracting \"'agent/filter/msg.c'\" \(1957 characters\)
  335.   sed "s/^X//" >'agent/filter/msg.c' <<'END_OF_FILE'
  336. X/*
  337. X
  338. X #    #   ####    ####            ####
  339. X ##  ##  #       #    #          #    #
  340. X # ## #   ####   #               #
  341. X #    #       #  #  ###   ###    #
  342. X #    #  #    #  #    #   ###    #    #
  343. X #    #   ####    ####    ###     ####
  344. X
  345. X    Fatal messages.
  346. X*/
  347. X
  348. X/*
  349. X * $Id: msg.c,v 3.0 1993/11/29 13:48:17 ram Exp ram $
  350. X *
  351. X *  Copyright (c) 1990-1993, Raphael Manfredi
  352. X *  
  353. X *  You may redistribute only under the terms of the Artistic License,
  354. X *  as specified in the README file that comes with the distribution.
  355. X *  You may reuse parts of this distribution only within the terms of
  356. X *  that same Artistic License; a copy of which may be found at the root
  357. X *  of the source tree for mailagent 3.0.
  358. X *
  359. X * $Log: msg.c,v $
  360. X * Revision 3.0  1993/11/29  13:48:17  ram
  361. X * Baseline for mailagent 3.0 netwide release.
  362. X *
  363. X */
  364. X
  365. X#include "config.h"
  366. X#include "portable.h"
  367. X#include <stdio.h>
  368. X#include <sys/types.h>
  369. X#include "sysexits.h"
  370. X#include "logfile.h"
  371. X#include "lock.h"
  372. X#include "io.h"
  373. X#include "confmagic.h"
  374. X
  375. X#define MAX_STRING    1024        /* Maximum length for error string */
  376. X
  377. X/* VARARGS2 */
  378. Xpublic void fatal(reason, arg1, arg2, arg3, arg4, arg5)
  379. Xchar *reason;
  380. Xint arg1, arg2, arg3, arg4, arg5;
  381. X{
  382. X    /* Fatal error -- die with a meaningful error status for sendmail. If the
  383. X     * logfile has been opened, the reason will also be logged there.
  384. X     */
  385. X    char buffer[MAX_STRING];
  386. X    int status;                        /* Status from emergency_save() */
  387. X    
  388. X    status = emergency_save();        /* Attempt emergency saving */
  389. X
  390. X    fprintf(stderr, "%s: ", progname);
  391. X    fprintf(stderr, reason, arg1, arg2, arg3, arg4, arg5);
  392. X    fputc('\n', stderr);
  393. X    sprintf(buffer, "FATAL %s", reason);
  394. X    add_log(1, buffer, arg1, arg2, arg3, arg4, arg5);
  395. X    release_lock();
  396. X
  397. X    if (!was_queued()) {
  398. X        add_log(6, "NOTICE leaving mail in MTA's queue");
  399. X        exit(EX_TEMPFAIL);
  400. X    } else if (status == -1) {
  401. X        add_log(5, "WARNING no saving was ever done");
  402. X        add_log(6, "NOTICE leaving mail in MTA's queue");
  403. X        exit(EX_TEMPFAIL);
  404. X    }
  405. X
  406. X    exit(EX_OK);
  407. X}
  408. X
  409. END_OF_FILE
  410.   if test 1957 -ne `wc -c <'agent/filter/msg.c'`; then
  411.     echo shar: \"'agent/filter/msg.c'\" unpacked with wrong size!
  412.   fi
  413.   # end of 'agent/filter/msg.c'
  414. fi
  415. if test -f 'agent/filter/user.c' -a "${1}" != "-c" ; then 
  416.   echo shar: Will not clobber existing file \"'agent/filter/user.c'\"
  417. else
  418.   echo shar: Extracting \"'agent/filter/user.c'\" \(1915 characters\)
  419.   sed "s/^X//" >'agent/filter/user.c' <<'END_OF_FILE'
  420. X/*
  421. X
  422. X #    #   ####   ######  #####            ####
  423. X #    #  #       #       #    #          #    #
  424. X #    #   ####   #####   #    #          #
  425. X #    #       #  #       #####    ###    #
  426. X #    #  #    #  #       #   #    ###    #    #
  427. X  ####    ####   ######  #    #   ###     ####
  428. X
  429. X    Compute user login name.
  430. X*/
  431. X
  432. X/*
  433. X * $Id: user.c,v 3.0 1993/11/29 13:48:21 ram Exp ram $
  434. X *
  435. X *  Copyright (c) 1990-1993, Raphael Manfredi
  436. X *  
  437. X *  You may redistribute only under the terms of the Artistic License,
  438. X *  as specified in the README file that comes with the distribution.
  439. X *  You may reuse parts of this distribution only within the terms of
  440. X *  that same Artistic License; a copy of which may be found at the root
  441. X *  of the source tree for mailagent 3.0.
  442. X *
  443. X * $Log: user.c,v $
  444. X * Revision 3.0  1993/11/29  13:48:21  ram
  445. X * Baseline for mailagent 3.0 netwide release.
  446. X *
  447. X */
  448. X
  449. X#include "config.h"
  450. X#include "portable.h"
  451. X#include <sys/types.h>                    /* For uid_t */
  452. X#include <pwd.h>
  453. X
  454. X#ifdef I_STRING
  455. X#include <string.h>
  456. X#else
  457. X#include <strings.h>
  458. X#endif
  459. X#include "confmagic.h"
  460. X
  461. X#define LOGIN_LEN    8                    /* Maximum login name length */
  462. X
  463. Xextern struct passwd *getpwuid();        /* Get password entry for UID */
  464. Xextern Uid_t geteuid();                    /* Effective user UID */
  465. X
  466. Xpublic char *logname()
  467. X{
  468. X    /* Return pointer to static data holding the user login name. Note that we
  469. X     * look-up in /etc/passwd. Hence, if the user has duplicate entries in the
  470. X     * file, the first one will be reported. This may or may not bother you.
  471. X     * NB: we use the *effective* user ID, not the real one.
  472. X     */
  473. X    
  474. X    static char login[LOGIN_LEN + 1];    /* Where login name is stored */
  475. X    struct passwd *pw;                    /* Pointer to password entry */
  476. X
  477. X    pw = getpwuid(geteuid());            /* Get first entry matching UID */
  478. X    if (pw == (struct passwd *) 0)
  479. X        return (char *) 0;                /* User not found */
  480. X
  481. X    strncpy(login, pw->pw_name, LOGIN_LEN);
  482. X    login[LOGIN_LEN] = '\0';
  483. X
  484. X    return login;
  485. X}
  486. X
  487. END_OF_FILE
  488.   if test 1915 -ne `wc -c <'agent/filter/user.c'`; then
  489.     echo shar: \"'agent/filter/user.c'\" unpacked with wrong size!
  490.   fi
  491.   # end of 'agent/filter/user.c'
  492. fi
  493. if test -f 'agent/mailhelp.SH' -a "${1}" != "-c" ; then 
  494.   echo shar: Will not clobber existing file \"'agent/mailhelp.SH'\"
  495. else
  496.   echo shar: Extracting \"'agent/mailhelp.SH'\" \(2462 characters\)
  497.   sed "s/^X//" >'agent/mailhelp.SH' <<'END_OF_FILE'
  498. Xcase $CONFIG in
  499. X'')
  500. X    if test -f config.sh; then TOP=.;
  501. X    elif test -f ../config.sh; then TOP=..;
  502. X    elif test -f ../../config.sh; then TOP=../..;
  503. X    elif test -f ../../../config.sh; then TOP=../../..;
  504. X    elif test -f ../../../../config.sh; then TOP=../../../..;
  505. X    else
  506. X        echo "Can't find config.sh."; exit 1
  507. X    fi
  508. X    . $TOP/config.sh
  509. X    ;;
  510. Xesac
  511. Xcase "$0" in
  512. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  513. Xesac
  514. Xecho "Extracting agent/mailhelp (with variable substitutions)"
  515. X$spitshell >mailhelp <<!GROK!THIS!
  516. X$startperl
  517. X    eval "exec perl -S \$0 \$*"
  518. X        if \$running_under_some_shell;
  519. X
  520. X# $Id: mailhelp.SH,v 3.0 1993/11/29 13:48:23 ram Exp ram $
  521. X#
  522. X#  Copyright (c) 1990-1993, Raphael Manfredi
  523. X#  
  524. X#  You may redistribute only under the terms of the Artistic License,
  525. X#  as specified in the README file that comes with the distribution.
  526. X#  You may reuse parts of this distribution only within the terms of
  527. X#  that same Artistic License; a copy of which may be found at the root
  528. X#  of the source tree for mailagent 3.0.
  529. X#
  530. X# $Log: mailhelp.SH,v $
  531. X# Revision 3.0  1993/11/29  13:48:23  ram
  532. X# Baseline for mailagent 3.0 netwide release.
  533. X#
  534. X
  535. X\$mversion = '$VERSION';
  536. X\$patchlevel = '$PATCHLEVEL';
  537. X!GROK!THIS!
  538. X
  539. X$spitshell >>mailhelp <<'!NO!SUBS!'
  540. X
  541. X$prog_name = $0;                # Who I am
  542. X$prog_name =~ s|^.*/(.*)|$1|;    # Keep only base name
  543. X
  544. X&read_config;        # First, read configuration file (in ~/.mailagent)
  545. X
  546. X# take job number and command from environment
  547. X# (passed by mailagent)
  548. X$jobnum = $ENV{'jobnum'};
  549. X$fullcmd = $ENV{'fullcmd'};
  550. X
  551. X$dest=shift;                            # Who should the help be sent to
  552. X$dest = $ENV{'path'} if $dest eq '';    # If dest was ommitted
  553. X
  554. X# A single '-' as first argument stands for return path
  555. X$dest = $ENV{'path'} if $dest eq '-';
  556. X
  557. Xopen(HELP, "$cf'spool/agenthelp") || &fatal("no help file!\n");
  558. Xopen(MAILER, "|$cf'sendmail $cf'mailopt $dest");
  559. Xprint MAILER
  560. X"To: $dest
  561. XSubject: How to use my mail agent
  562. XX-Mailer: mailagent [version $mversion PL$patchlevel]
  563. X
  564. X";
  565. Xwhile (<HELP>) {
  566. X    # Replace some tokens by parameters
  567. X    s/=DEST=/$dest/g;
  568. X    s/=MAXSIZE=/$cf'maxsize/g;
  569. X    print MAILER;
  570. X}
  571. Xprint MAILER
  572. X"
  573. X-- $prog_name speaking for $cf'user
  574. X";
  575. Xclose MAILER;
  576. Xif ($?) {
  577. X    &add_log("ERROR couldn't send help to $dest") if $loglvl > 0;
  578. X} else {
  579. X    &add_log("SENT help to $dest") if $loglvl > 2;
  580. X}
  581. Xclose HELP;
  582. X
  583. X!NO!SUBS!
  584. X$grep -v '^;#' pl/fatal.pl >>mailhelp
  585. X$grep -v '^;#' pl/add_log.pl >>mailhelp
  586. X$grep -v '^;#' pl/read_conf.pl >>mailhelp
  587. X$grep -v '^;#' pl/secure.pl >>mailhelp
  588. Xchmod 755 mailhelp
  589. X$eunicefix mailhelp
  590. END_OF_FILE
  591.   if test 2462 -ne `wc -c <'agent/mailhelp.SH'`; then
  592.     echo shar: \"'agent/mailhelp.SH'\" unpacked with wrong size!
  593.   fi
  594.   chmod +x 'agent/mailhelp.SH'
  595.   # end of 'agent/mailhelp.SH'
  596. fi
  597. if test -f 'agent/pl/include.pl' -a "${1}" != "-c" ; then 
  598.   echo shar: Will not clobber existing file \"'agent/pl/include.pl'\"
  599. else
  600.   echo shar: Extracting \"'agent/pl/include.pl'\" \(1799 characters\)
  601.   sed "s/^X//" >'agent/pl/include.pl' <<'END_OF_FILE'
  602. X;# $Id: include.pl,v 3.0 1993/11/29 13:48:52 ram Exp ram $
  603. X;#
  604. X;#  Copyright (c) 1990-1993, Raphael Manfredi
  605. X;#  
  606. X;#  You may redistribute only under the terms of the Artistic License,
  607. X;#  as specified in the README file that comes with the distribution.
  608. X;#  You may reuse parts of this distribution only within the terms of
  609. X;#  that same Artistic License; a copy of which may be found at the root
  610. X;#  of the source tree for mailagent 3.0.
  611. X;#
  612. X;# $Log: include.pl,v $
  613. X;# Revision 3.0  1993/11/29  13:48:52  ram
  614. X;# Baseline for mailagent 3.0 netwide release.
  615. X;#
  616. X;# 
  617. X# Process "include-file" requests. The file is allowed to have shell comments
  618. X# and leading spaces are trimmed. The function returns an array, each item
  619. X# being one of the non-comment lines found in the file.
  620. Xsub include_file {
  621. X    local($inc) = shift(@_);    # Include request "file-name"
  622. X    local($what) = shift(@_);    # What we are looking for (singular)
  623. X    local(*INCLUDE);            # Local file handle
  624. X    local($filename) = $inc =~ /^"(.*)"$/;
  625. X    local(@result);
  626. X    local($_);
  627. X    # Find file using mailfilter, maildir variables if not specified with an
  628. X    # absolute pathname (starting iwht a '/').
  629. X    $filename = &locate_file($filename);
  630. X    &add_log("loading ".&plural($what)." from $filename") if $loglvl > 18;
  631. X    if ($filename ne '' && open(INCLUDE, "$filename")) {
  632. X        while (<INCLUDE>) {
  633. X            next if /^\s*#/;    # Skip shell comments
  634. X            chop;
  635. X            s/^\s+//;            # Remove leading spaces
  636. X            push(@result, $_);
  637. X            &add_log("loaded $what '$_'") if $loglvl > 19;
  638. X        }
  639. X        close INCLUDE;
  640. X    } elsif ($filename ne '') {        # Could not open file
  641. X        &add_log("WARNING couldn't open $filename for ".&plural($what).": $!")
  642. X            if $loglvl > 4;
  643. X    } else {
  644. X        &add_log("WARNING incorrect file inclusion request: $inc")
  645. X            if $loglvl > 4;
  646. X    }
  647. X    @result;        # List of non-comment lines held in file
  648. X}
  649. X
  650. END_OF_FILE
  651.   if test 1799 -ne `wc -c <'agent/pl/include.pl'`; then
  652.     echo shar: \"'agent/pl/include.pl'\" unpacked with wrong size!
  653.   fi
  654.   # end of 'agent/pl/include.pl'
  655. fi
  656. if test -f 'agent/pl/mailhook.pl' -a "${1}" != "-c" ; then 
  657.   echo shar: Will not clobber existing file \"'agent/pl/mailhook.pl'\"
  658. else
  659.   echo shar: Extracting \"'agent/pl/mailhook.pl'\" \(2231 characters\)
  660.   sed "s/^X//" >'agent/pl/mailhook.pl' <<'END_OF_FILE'
  661. X;# $Id: mailhook.pl,v 3.0 1993/11/29 13:48:58 ram Exp ram $
  662. X;#
  663. X;#  Copyright (c) 1990-1993, Raphael Manfredi
  664. X;#  
  665. X;#  You may redistribute only under the terms of the Artistic License,
  666. X;#  as specified in the README file that comes with the distribution.
  667. X;#  You may reuse parts of this distribution only within the terms of
  668. X;#  that same Artistic License; a copy of which may be found at the root
  669. X;#  of the source tree for mailagent 3.0.
  670. X;#
  671. X;# $Log: mailhook.pl,v $
  672. X;# Revision 3.0  1993/11/29  13:48:58  ram
  673. X;# Baseline for mailagent 3.0 netwide release.
  674. X;#
  675. X;# 
  676. X#
  677. X# Various hook utilities
  678. X# (name in package hook, compiled in package mailhook)
  679. X#
  680. X
  681. Xpackage mailhook;
  682. X
  683. X# Parse mail and initialize special variables. The perl script used as hook
  684. X# does not have (usually) to do any parsing on the mail. Headers of the mail
  685. X# are available via the %header array and some special variables are set as
  686. X# conveniences.
  687. Xsub hook'initvar {
  688. X    local($package) = @_;        # Package into which variables should be set
  689. X    local($init) = &'q(<<'EOP');
  690. X:    *header = *main'Header;        # User may fetch headers via %header
  691. X:    $sender = $header{'Sender'};
  692. X:    $subject = $header{'Subject'};
  693. X:    $precedence = $header{'Precedence'};
  694. X:    $from = $header{'From'};
  695. X:    $to = $header{'To'};
  696. X:    $cc = $header{'Cc'};
  697. X:    $envelope = $header{'Envelope'};
  698. X:    ($reply_to) = &'parse_address($header{'Reply-To'});
  699. X:    ($address, $friendly) = &'parse_address($from);
  700. X:    $login = &'login_name($address);
  701. X:    @to = split(/,/, $to);
  702. X:    @cc = split(/,/, $to);
  703. X:    # Leave only the address part in @to and @cc
  704. X:    grep(($_ = (&'parse_address($_))[0], 0), @to);
  705. X:    grep(($_ = (&'parse_address($_))[0], 0), @cc);
  706. XEOP
  707. X    eval(<<EOP);                # Initialize variables inside package
  708. X    package $package;
  709. X    $init
  710. XEOP
  711. X}
  712. X
  713. X# Load hook script and run it
  714. Xsub hook'run {
  715. X    local($hook) = @_;
  716. X    open(HOOK, $hook) || &'fatal("cannot open $hook: $!");
  717. X    local($body) = ' ' x (-s HOOK);
  718. X    {
  719. X        local($/) = undef;
  720. X        $body = <HOOK>;            # Slurp whole file
  721. X    }
  722. X    close(HOOK);
  723. X    unshift(@INC, $'privlib);    # Files first searched for in mailagent's lib
  724. X    eval $body;                    # Load, compile and execute within mailhook
  725. X    if (chop($@)) {
  726. X        $@ =~ s/ in file \(eval\)//;
  727. X        &'add_log("ERROR $@") if $'loglvl;
  728. X        die("$hook aborted");
  729. X    }
  730. X}
  731. X
  732. Xpackage main;
  733. X
  734. END_OF_FILE
  735.   if test 2231 -ne `wc -c <'agent/pl/mailhook.pl'`; then
  736.     echo shar: \"'agent/pl/mailhook.pl'\" unpacked with wrong size!
  737.   fi
  738.   # end of 'agent/pl/mailhook.pl'
  739. fi
  740. if test -f 'agent/pl/once.pl' -a "${1}" != "-c" ; then 
  741.   echo shar: Will not clobber existing file \"'agent/pl/once.pl'\"
  742. else
  743.   echo shar: Extracting \"'agent/pl/once.pl'\" \(1871 characters\)
  744.   sed "s/^X//" >'agent/pl/once.pl' <<'END_OF_FILE'
  745. X;# $Id: once.pl,v 3.0 1993/11/29 13:49:04 ram Exp ram $
  746. X;#
  747. X;#  Copyright (c) 1990-1993, Raphael Manfredi
  748. X;#  
  749. X;#  You may redistribute only under the terms of the Artistic License,
  750. X;#  as specified in the README file that comes with the distribution.
  751. X;#  You may reuse parts of this distribution only within the terms of
  752. X;#  that same Artistic License; a copy of which may be found at the root
  753. X;#  of the source tree for mailagent 3.0.
  754. X;#
  755. X;# $Log: once.pl,v $
  756. X;# Revision 3.0  1993/11/29  13:49:04  ram
  757. X;# Baseline for mailagent 3.0 netwide release.
  758. X;#
  759. X;# 
  760. X;# Handling of the "once" directory for ONCE commands. A once command is
  761. X;# tagged with a tuple (name,ruletag). The name is used for hashing, and
  762. X;# the ruletag sepecifies the entry to be used by the command for timestamp
  763. X;# recording. The dbr package is used to maintain the database
  764. X;#
  765. X# Given a tuple (name, tag) and a period, make sure the command may be
  766. X# executed. If it can, update the timestamp and return true. false otherwise.
  767. Xsub once_check {
  768. X    local($hname, $tag, $period) = @_;
  769. X    $hname =~ s/\s//g;                    # There cannot be spaces in the name
  770. X    local($ok) = 1;                        # Is once ok ?
  771. X    local($timestamp) = 0;                # Time stamp attached to entry
  772. X    local($linenum) = 0;                # Line where entry was found
  773. X    if (-f $file) {
  774. X        ($timestamp, $linenum) = &dbr'info($hname, 'ONCE', $tag);
  775. X        return 0 if $timestamp == -1;    # An error occurred
  776. X    }
  777. X    local($now) = time;                    # Number of seconds since The Epoch
  778. X    if (($timestamp + $period) > $now) {
  779. X        &'add_log("we have to wait for ($hname, $tag)") if $'loglvl > 18;
  780. X        return 0;
  781. X    }
  782. X    # Now we know we can execute the command. So update the database entry.
  783. X    # If the timestamp is 0, then an append has to be done, otherwise it's
  784. X    # a single replacement.
  785. X    if ($timestamp > 0) {
  786. X        &dbr'update($hname, 'ONCE', $linenum, $tag);
  787. X    } else {
  788. X        &dbr'update($hname, 'ONCE', 0, $tag);
  789. X    }
  790. X    1;
  791. X}
  792. X
  793. END_OF_FILE
  794.   if test 1871 -ne `wc -c <'agent/pl/once.pl'`; then
  795.     echo shar: \"'agent/pl/once.pl'\" unpacked with wrong size!
  796.   fi
  797.   # end of 'agent/pl/once.pl'
  798. fi
  799. if test -f 'agent/test/basic/filter.t' -a "${1}" != "-c" ; then 
  800.   echo shar: Will not clobber existing file \"'agent/test/basic/filter.t'\"
  801. else
  802.   echo shar: Extracting \"'agent/test/basic/filter.t'\" \(2249 characters\)
  803.   sed "s/^X//" >'agent/test/basic/filter.t' <<'END_OF_FILE'
  804. X# Make sure filter queues messages correctly
  805. X
  806. X# $Id: filter.t,v 3.0 1993/11/29 13:49:24 ram Exp ram $
  807. X#
  808. X#  Copyright (c) 1990-1993, Raphael Manfredi
  809. X#  
  810. X#  You may redistribute only under the terms of the Artistic License,
  811. X#  as specified in the README file that comes with the distribution.
  812. X#  You may reuse parts of this distribution only within the terms of
  813. X#  that same Artistic License; a copy of which may be found at the root
  814. X#  of the source tree for mailagent 3.0.
  815. X#
  816. X# $Log: filter.t,v $
  817. X# Revision 3.0  1993/11/29  13:49:24  ram
  818. X# Baseline for mailagent 3.0 netwide release.
  819. X#
  820. X
  821. Xdo '../pl/init.pl';
  822. Xdo '../pl/logfile.pl';
  823. Xchdir '../out' || exit 0;
  824. Xopen(WAIT, ">queue/agent.wait") || print "1\n";
  825. Xclose WAIT;
  826. X`chmod u-w queue`;
  827. X$? == 0 || print "2\n";
  828. X# Use the special undocumented -t option from filter to get HOME directory
  829. X# via environment instead of /etc/passwd.
  830. Xopen(FILTER, "|$filter -t >/dev/null 2>&1") || print "3\n";
  831. Xprint FILTER <<EOF;
  832. XDummy mail
  833. XEOF
  834. Xclose FILTER;
  835. X$? == 0 || print "4\n";        # Must terminate correctly (stored in agent.wait)
  836. X&get_log(5);
  837. X&check_log('memorized', 6);    # Make sure mail has been memorized
  838. X-s 'queue/agent.wait' || print "7\n";
  839. X$file = <emerg/*>;
  840. Xif (-f "$file") {
  841. X    chop($what = `cat queue/agent.wait`);
  842. X    chop($pwd = `pwd`);
  843. X    $what eq "$pwd/$file" || print "8\n";
  844. X    unlink "$file";
  845. X} else {
  846. X    print "8\n";
  847. X}
  848. X`chmod u+w queue`;
  849. Xunlink 'queue/agent.wait', 'agentlog';
  850. Xopen(FILTER, "|$filter -t >/dev/null 2>&1") || print "9\n";
  851. Xprint FILTER <<EOF;
  852. XDummy mail
  853. XEOF
  854. Xclose FILTER;
  855. X$? == 0 || print "10\n";    # Must terminate correctly (queued)
  856. X&get_log(11);
  857. X&check_log('QUEUED', 12);    # Mail was queued
  858. X$file = <queue/qm*>;
  859. X-f "$file" || print "13\n";    # Must have been left in queue
  860. Xunlink "$file", 'agentlog';
  861. X# Make sure file is correctly queued when another filter is running
  862. X`cp /dev/null filter.lock`;
  863. X$? == 0 || print "14\n";
  864. Xopen(FILTER, "|$filter -t >/dev/null 2>&1") || print "15\n";
  865. Xprint FILTER <<EOF;
  866. XDummy mail
  867. XEOF
  868. Xclose FILTER;
  869. X$? == 0 || print "16\n";    # Must terminate correctly (queued)
  870. X&get_log(17);
  871. X&check_log('QUEUED', 18);    # Mail was queued
  872. X$file = <queue/fm*>;
  873. X-f "$file" || print "19\n";    # Must have been left in queue as a 'fm' file
  874. Xunlink "$file", 'agentlog', 'filter.lock';
  875. Xprint "0\n";
  876. END_OF_FILE
  877.   if test 2249 -ne `wc -c <'agent/test/basic/filter.t'`; then
  878.     echo shar: \"'agent/test/basic/filter.t'\" unpacked with wrong size!
  879.   fi
  880.   # end of 'agent/test/basic/filter.t'
  881. fi
  882. if test -f 'agent/test/cmd/keep.t' -a "${1}" != "-c" ; then 
  883.   echo shar: Will not clobber existing file \"'agent/test/cmd/keep.t'\"
  884. else
  885.   echo shar: Extracting \"'agent/test/cmd/keep.t'\" \(1830 characters\)
  886.   sed "s/^X//" >'agent/test/cmd/keep.t' <<'END_OF_FILE'
  887. X# Test KEEP command
  888. X
  889. X# $Id: keep.t,v 3.0 1993/11/29 13:49:33 ram Exp ram $
  890. X#
  891. X#  Copyright (c) 1990-1993, Raphael Manfredi
  892. X#  
  893. X#  You may redistribute only under the terms of the Artistic License,
  894. X#  as specified in the README file that comes with the distribution.
  895. X#  You may reuse parts of this distribution only within the terms of
  896. X#  that same Artistic License; a copy of which may be found at the root
  897. X#  of the source tree for mailagent 3.0.
  898. X#
  899. X# $Log: keep.t,v $
  900. X# Revision 3.0  1993/11/29  13:49:33  ram
  901. X# Baseline for mailagent 3.0 netwide release.
  902. X#
  903. X
  904. Xdo '../pl/cmd.pl';
  905. Xunlink 'ok', 'no_resync';
  906. X
  907. Xopen(LIST, '>header-list') || print "17\n";
  908. Xprint LIST <<EOL;
  909. XTo
  910. XSubject
  911. XU*
  912. XX*
  913. XEOL
  914. Xclose LIST;
  915. X
  916. X&add_header('X-Tag: keep');
  917. X&add_header('X-Long-Line: this is a long line and has a continuation');
  918. X&add_header('  right below it with a MARK token');
  919. X&add_header('  and another with the MARK token');
  920. X&add_header('X-Removed-Line: this is a long line and has a continuation');
  921. X&add_header('  right below it with another mark TOKEN');
  922. X&add_header('  and another with the mark TOKEN');
  923. X&add_header('unusual-header: None');
  924. X`$cmd`;
  925. X$? == 0 || print "1\n";
  926. X-f "$user" && print "2\n";        # Mail saved...
  927. X-f 'ok' || print "3\n";            # ...here
  928. X&get_log(4, 'ok');
  929. X¬_log('^Received:', 5);        # Make sure Received: disappeared
  930. X&check_log('^To:', 6);            # But To: still here
  931. X&check_log('^From:', 7);
  932. X&check_log('^Subject:', 8);
  933. X¬_log('^X-None:', 9);
  934. X&check_log('MARK', 10) == 2 || print "11\n";        # Continuation line kept
  935. X&check_log('^X-Long-Line:', 12);    # So is the parent field
  936. X¬_log('^X-Removed-Line:', 13);
  937. X¬_log('TOKEN', 14);            # This continuation was removed
  938. X&check_log('^unusual-header:', 16);
  939. X-f 'no_resync' || print "15\n";    # Ensure header not disturbed
  940. X
  941. X# Last: 17
  942. Xunlink 'ok', 'no_resync', 'mail', 'header-list';
  943. Xprint "0\n";
  944. END_OF_FILE
  945.   if test 1830 -ne `wc -c <'agent/test/cmd/keep.t'`; then
  946.     echo shar: \"'agent/test/cmd/keep.t'\" unpacked with wrong size!
  947.   fi
  948.   # end of 'agent/test/cmd/keep.t'
  949. fi
  950. if test -f 'agent/test/cmd/once.t' -a "${1}" != "-c" ; then 
  951.   echo shar: Will not clobber existing file \"'agent/test/cmd/once.t'\"
  952. else
  953.   echo shar: Extracting \"'agent/test/cmd/once.t'\" \(1837 characters\)
  954.   sed "s/^X//" >'agent/test/cmd/once.t' <<'END_OF_FILE'
  955. X# The ONCE command and autocleaning feature
  956. X
  957. X# $Id: once.t,v 3.0 1993/11/29 13:49:37 ram Exp ram $
  958. X#
  959. X#  Copyright (c) 1990-1993, Raphael Manfredi
  960. X#  
  961. X#  You may redistribute only under the terms of the Artistic License,
  962. X#  as specified in the README file that comes with the distribution.
  963. X#  You may reuse parts of this distribution only within the terms of
  964. X#  that same Artistic License; a copy of which may be found at the root
  965. X#  of the source tree for mailagent 3.0.
  966. X#
  967. X# $Log: once.t,v $
  968. X# Revision 3.0  1993/11/29  13:49:37  ram
  969. X# Baseline for mailagent 3.0 netwide release.
  970. X#
  971. X
  972. Xdo '../pl/cmd.pl';
  973. Xunlink 'one', 'two', 'three', 'four', "$user";
  974. X
  975. X&add_header('X-Tag: once');
  976. X`rm -rf dbr` if -d 'dbr';
  977. X`$cmd`;
  978. X$? == 0 || print "1\n";
  979. X-f "$user" && print "2\n";
  980. X-f 'one' || print "3\n";
  981. X-f 'two' && print "4\n";
  982. X-f 'three' || print "5\n";
  983. X-f 'four' || print "6\n";
  984. X-d 'dbr' || print "7\n";
  985. X@files = <dbr/*/*>;
  986. X@files == 3 || print "8\n";
  987. X
  988. X# Make sure ONCE dbr database not disturbed by autocleaning, and, along
  989. X# the way, check that auto cleaning is correctly run.
  990. X
  991. X$level = $ENV{'LEVEL'};
  992. X`$mailagent -L $level -q -o 'autoclean: ON' 2>/dev/null`;
  993. X$? == 0 || print "9\n";
  994. X@new_files = <dbr/*/*>;
  995. X@new_files == @files || print "10\n";
  996. Xunlink 'one', 'two', 'three', 'four', "$user";
  997. X-f 'context' || print "11\n";
  998. X
  999. X`$cmd`;
  1000. X$? == 0 || print "12\n";
  1001. X-f "$user" && print "13\n";
  1002. X-f 'one' && print "14\n";
  1003. X-f 'two' && print "15\n";
  1004. X-f 'three' && print "16\n";
  1005. X-f 'four' || print "17\n";
  1006. X-d 'dbr' || print "18\n";
  1007. X
  1008. X# Make sure autocleaning leaves things in a coherent state
  1009. X
  1010. X`$mailagent -q -L $level -o 'autoclean: ON' -o 'agemax: 0m' 2>/dev/null`;
  1011. X-d 'dbr' && print "19\n";
  1012. X-f 'context' || print "20\n";
  1013. X
  1014. X`$mailagent -q -L $level 2>/dev/null`;
  1015. X-f 'context' && print "21\n";
  1016. X
  1017. Xunlink 'one', 'two', 'three', 'four', "$user", 'mail';
  1018. Xprint "0\n";
  1019. END_OF_FILE
  1020.   if test 1837 -ne `wc -c <'agent/test/cmd/once.t'`; then
  1021.     echo shar: \"'agent/test/cmd/once.t'\" unpacked with wrong size!
  1022.   fi
  1023.   # end of 'agent/test/cmd/once.t'
  1024. fi
  1025. if test -f 'agent/test/cmd/record.t' -a "${1}" != "-c" ; then 
  1026.   echo shar: Will not clobber existing file \"'agent/test/cmd/record.t'\"
  1027. else
  1028.   echo shar: Extracting \"'agent/test/cmd/record.t'\" \(1845 characters\)
  1029.   sed "s/^X//" >'agent/test/cmd/record.t' <<'END_OF_FILE'
  1030. X# The RECORD command
  1031. X
  1032. X# $Id: record.t,v 3.0 1993/11/29 13:49:42 ram Exp ram $
  1033. X#
  1034. X#  Copyright (c) 1990-1993, Raphael Manfredi
  1035. X#  
  1036. X#  You may redistribute only under the terms of the Artistic License,
  1037. X#  as specified in the README file that comes with the distribution.
  1038. X#  You may reuse parts of this distribution only within the terms of
  1039. X#  that same Artistic License; a copy of which may be found at the root
  1040. X#  of the source tree for mailagent 3.0.
  1041. X#
  1042. X# $Log: record.t,v $
  1043. X# Revision 3.0  1993/11/29  13:49:42  ram
  1044. X# Baseline for mailagent 3.0 netwide release.
  1045. X#
  1046. X
  1047. Xdo '../pl/cmd.pl';
  1048. Xunlink "$user.1", "$user.2", "$user.3";
  1049. X
  1050. X&add_header('X-Tag: record #1');
  1051. X`rm -rf dbr` if -d 'dbr';
  1052. X`$cmd`;
  1053. X$? == 0 || print "1\n";
  1054. X-f "$user.1" || print "2\n";    # Was saved, first time.
  1055. Xunlink "$user.1";
  1056. X
  1057. X-d 'dbr' || print "3\n";        # Make sure history recording works
  1058. X-f 'dbr/i/e' || print "4\n";    # Hashing done on domain name
  1059. X
  1060. X`$cmd`;
  1061. X$? == 0 || print "5\n";
  1062. X-f "$user.1" && print "6\n";    # We rejected this time, in SEEN mode
  1063. X-f "$user.2" || print "7\n";    # And saved it here
  1064. Xunlink "$user.2";
  1065. X
  1066. X&replace_header('X-Tag: record #2');
  1067. X`$cmd`;
  1068. X$? == 0 || print "8\n";
  1069. X-f "$user.1" && print "9\n";    # We restarted this time
  1070. X-f "$user.3" || print "10\n";    # And caught that rule in RECORD mode
  1071. X-f "$user" && print "11\n";        # Nothing here
  1072. Xunlink "$user.3";
  1073. X
  1074. X&replace_header('X-Tag: record #3');
  1075. X`$cmd`;
  1076. X$? == 0 || print "12\n";
  1077. X-f "$user.1" && print "13\n";    # We aborted
  1078. X-f "$user" || print "14\n";        # Must be there (aborted, no match)
  1079. Xunlink "$user.1", "$user";
  1080. X
  1081. X&replace_header('X-Tag: record #4');
  1082. X`$cmd`;
  1083. X$? == 0 || print "15\n";
  1084. X-f "$user.1" && print "16\n";    # We rejected
  1085. X-f "$user.2" || print "17\n";    # Must be there (saved in mode RECORD)
  1086. X-f "$user" && print "18\n";
  1087. X
  1088. X`rm -rf dbr` if -d 'dbr';
  1089. Xunlink "$user", "$user.1", "$user.2", "$user.3", 'mail';
  1090. Xprint "0\n";
  1091. END_OF_FILE
  1092.   if test 1845 -ne `wc -c <'agent/test/cmd/record.t'`; then
  1093.     echo shar: \"'agent/test/cmd/record.t'\" unpacked with wrong size!
  1094.   fi
  1095.   # end of 'agent/test/cmd/record.t'
  1096. fi
  1097. if test -f 'agent/test/cmd/store.t' -a "${1}" != "-c" ; then 
  1098.   echo shar: Will not clobber existing file \"'agent/test/cmd/store.t'\"
  1099. else
  1100.   echo shar: Extracting \"'agent/test/cmd/store.t'\" \(1804 characters\)
  1101.   sed "s/^X//" >'agent/test/cmd/store.t' <<'END_OF_FILE'
  1102. X# The STORE command
  1103. X
  1104. X# $Id: store.t,v 3.0 1993/11/29 13:49:50 ram Exp ram $
  1105. X#
  1106. X#  Copyright (c) 1990-1993, Raphael Manfredi
  1107. X#  
  1108. X#  You may redistribute only under the terms of the Artistic License,
  1109. X#  as specified in the README file that comes with the distribution.
  1110. X#  You may reuse parts of this distribution only within the terms of
  1111. X#  that same Artistic License; a copy of which may be found at the root
  1112. X#  of the source tree for mailagent 3.0.
  1113. X#
  1114. X# $Log: store.t,v $
  1115. X# Revision 3.0  1993/11/29  13:49:50  ram
  1116. X# Baseline for mailagent 3.0 netwide release.
  1117. X#
  1118. X
  1119. Xdo '../pl/cmd.pl';
  1120. X$mbox = 'mbox';
  1121. X
  1122. X&add_header('X-Tag: store #1');
  1123. X`$cmd`;
  1124. X$? == 0 || print "1\n";
  1125. X-f "$mbox" || print "2\n";        # Mail saved here
  1126. X-f "$user" || print "3\n";        # Leave copy in mailbox
  1127. X-s "$mbox" == -s "$user" || print "4\n";    # Same content
  1128. X
  1129. X# When mailbox protected against writing...
  1130. Xunlink <emerg/*>;
  1131. Xunlink "$user";
  1132. X$size = -s "$mbox";
  1133. Xchmod 0444, "$mbox";
  1134. X`$cmd`;
  1135. X$? == 0 || print "5\n";
  1136. X-f "$mbox" || print "6\n";                # Must still be there
  1137. X$size == -s "$mbox" || print "7\n";        # And not altered
  1138. X-f "$user" || print "8\n";                # Left only copy in mailbox
  1139. X$size == -s "$user" || print "9\n";        # Which must also match in size
  1140. X@emerg = <emerg/*>;
  1141. X@emerg == 1 || print "10\n";            # Emeregency as SAVE failed
  1142. X
  1143. X# There is no X-Filter mail in the emergency saving
  1144. X`grep -v X-Filter: $mbox > ok`;
  1145. X$? == 0 || print "11\n";
  1146. X-s $emerg[0] eq -s 'ok' || print "12\n";    # Full mail saved, of course
  1147. Xunlink "$mbox", "$user";
  1148. X
  1149. X# Make sure STORE creates full path when needed
  1150. X&replace_header('X-Tag: store #2');
  1151. X`rm -rf path` if -d 'path';
  1152. X`$cmd`;
  1153. X$? == 0 || print "13\n";
  1154. X-f 'path/another/third/mbox' || print "14\n";
  1155. X-f "$user" || print "15\n";
  1156. X
  1157. X`rm -rf path` if -d 'path';
  1158. Xunlink <emerg/*>;
  1159. Xunlink "$mbox", "$user", 'mail', 'ok';
  1160. Xprint "0\n";
  1161. END_OF_FILE
  1162.   if test 1804 -ne `wc -c <'agent/test/cmd/store.t'`; then
  1163.     echo shar: \"'agent/test/cmd/store.t'\" unpacked with wrong size!
  1164.   fi
  1165.   # end of 'agent/test/cmd/store.t'
  1166. fi
  1167. if test -f 'agent/test/cmd/strip.t' -a "${1}" != "-c" ; then 
  1168.   echo shar: Will not clobber existing file \"'agent/test/cmd/strip.t'\"
  1169. else
  1170.   echo shar: Extracting \"'agent/test/cmd/strip.t'\" \(1847 characters\)
  1171.   sed "s/^X//" >'agent/test/cmd/strip.t' <<'END_OF_FILE'
  1172. X# Test STRIP command
  1173. X
  1174. X# $Id: strip.t,v 3.0 1993/11/29 13:49:51 ram Exp ram $
  1175. X#
  1176. X#  Copyright (c) 1990-1993, Raphael Manfredi
  1177. X#  
  1178. X#  You may redistribute only under the terms of the Artistic License,
  1179. X#  as specified in the README file that comes with the distribution.
  1180. X#  You may reuse parts of this distribution only within the terms of
  1181. X#  that same Artistic License; a copy of which may be found at the root
  1182. X#  of the source tree for mailagent 3.0.
  1183. X#
  1184. X# $Log: strip.t,v $
  1185. X# Revision 3.0  1993/11/29  13:49:51  ram
  1186. X# Baseline for mailagent 3.0 netwide release.
  1187. X#
  1188. X
  1189. Xdo '../pl/cmd.pl';
  1190. Xunlink 'ok', 'no_resync';
  1191. X
  1192. Xopen(LIST, '>header-list') || print "17\n";
  1193. Xprint LIST <<EOL;
  1194. XUnusual-Header
  1195. XX-Long*
  1196. XEOL
  1197. Xclose LIST;
  1198. X
  1199. X&add_header('X-Tag: strip');
  1200. X&add_header('X-Long-Line: this is a long line and has a continuation');
  1201. X&add_header('  right below it with a MARK token');
  1202. X&add_header('  and another with the MARK token');
  1203. X&add_header('X-Kept-Line: this is a long line and has a continuation');
  1204. X&add_header('  right below it with another mark TOKEN');
  1205. X&add_header('  and another with the mark TOKEN');
  1206. X&add_header('unusual-header: None');
  1207. X`$cmd`;
  1208. X$? == 0 || print "1\n";
  1209. X-f "$user" && print "2\n";        # Mail saved...
  1210. X-f 'ok' || print "3\n";            # ...here
  1211. X&get_log(4, 'ok');
  1212. X¬_log('^Received:', 5);        # Make sure Received: disappeared
  1213. X&check_log('^To:', 6);            # But To: still here
  1214. X&check_log('^From:', 7);
  1215. X&check_log('^Subject:', 8);
  1216. X¬_log('^X-None:', 9);
  1217. X¬_log('MARK', 10);            # Continuation line must have been stripped too
  1218. X¬_log('^X-Long-Line:', 11);    # As well as its parent
  1219. X&check_log('TOKEN', 12) == 2 || print "13\n";        # This one has been kept
  1220. X&check_log('^X-Kept-Line:', 14);
  1221. X¬_log('^unusual-header:', 16);
  1222. X-f 'no_resync' || print "15\n";    # Ensure header not disturbed
  1223. X
  1224. X# Last: 17
  1225. Xunlink 'ok', 'no_resync', 'mail', 'header-list';
  1226. Xprint "0\n";
  1227. END_OF_FILE
  1228.   if test 1847 -ne `wc -c <'agent/test/cmd/strip.t'`; then
  1229.     echo shar: \"'agent/test/cmd/strip.t'\" unpacked with wrong size!
  1230.   fi
  1231.   # end of 'agent/test/cmd/strip.t'
  1232. fi
  1233. if test -f 'agent/test/cmd/unique.t' -a "${1}" != "-c" ; then 
  1234.   echo shar: Will not clobber existing file \"'agent/test/cmd/unique.t'\"
  1235. else
  1236.   echo shar: Extracting \"'agent/test/cmd/unique.t'\" \(1836 characters\)
  1237.   sed "s/^X//" >'agent/test/cmd/unique.t' <<'END_OF_FILE'
  1238. X# The UNIQUE command
  1239. X
  1240. X# $Id: unique.t,v 3.0 1993/11/29 13:49:53 ram Exp ram $
  1241. X#
  1242. X#  Copyright (c) 1990-1993, Raphael Manfredi
  1243. X#  
  1244. X#  You may redistribute only under the terms of the Artistic License,
  1245. X#  as specified in the README file that comes with the distribution.
  1246. X#  You may reuse parts of this distribution only within the terms of
  1247. X#  that same Artistic License; a copy of which may be found at the root
  1248. X#  of the source tree for mailagent 3.0.
  1249. X#
  1250. X# $Log: unique.t,v $
  1251. X# Revision 3.0  1993/11/29  13:49:53  ram
  1252. X# Baseline for mailagent 3.0 netwide release.
  1253. X#
  1254. X
  1255. Xdo '../pl/cmd.pl';
  1256. Xunlink "$user.1", "$user.2", "$user.3";
  1257. X
  1258. X&add_header('X-Tag: unique #1');
  1259. X`rm -rf dbr` if -d 'dbr';
  1260. X`$cmd`;
  1261. X$? == 0 || print "1\n";
  1262. X-f "$user.1" || print "2\n";    # Was saved, first time.
  1263. Xunlink "$user.1";
  1264. X
  1265. X-d 'dbr' || print "3\n";        # Make sure history recording works
  1266. X-f 'dbr/i/e' || print "4\n";    # Hashing done on domain name
  1267. X
  1268. X`$cmd`;
  1269. X$? == 0 || print "5\n";
  1270. X-f "$user.1" && print "6\n";    # We rejected this time, NOT in SEEN mode
  1271. X-f "$user.2" || print "7\n";    # And saved it here
  1272. Xunlink "$user.2";
  1273. X
  1274. X&replace_header('X-Tag: unique #2');
  1275. X`$cmd`;
  1276. X$? == 0 || print "8\n";
  1277. X-f "$user.1" && print "9\n";    # We restarted this time
  1278. X-f "$user.3" || print "10\n";    # And caught that rule
  1279. X-f "$user" && print "11\n";        # Nothing here
  1280. Xunlink "$user.3";
  1281. X
  1282. X&replace_header('X-Tag: unique #3');
  1283. X`$cmd`;
  1284. X$? == 0 || print "12\n";
  1285. X-f "$user.1" && print "13\n";    # We aborted
  1286. X-f "$user" && print "14\n";        # Must not be there (tagged as saved)
  1287. Xunlink "$user.1", "$user";
  1288. X
  1289. X&replace_header('X-Tag: unique #4');
  1290. X`$cmd`;
  1291. X$? == 0 || print "15\n";
  1292. X-f "$user.1" && print "16\n";    # We rejected
  1293. X-f "$user.2" || print "17\n";    # Must be there (saved in mode UNIQUE)
  1294. X-f "$user" && print "18\n";
  1295. X
  1296. X`rm -rf dbr` if -d 'dbr';
  1297. Xunlink "$user", "$user.1", "$user.2", "$user.3", 'mail';
  1298. Xprint "0\n";
  1299. END_OF_FILE
  1300.   if test 1836 -ne `wc -c <'agent/test/cmd/unique.t'`; then
  1301.     echo shar: \"'agent/test/cmd/unique.t'\" unpacked with wrong size!
  1302.   fi
  1303.   # end of 'agent/test/cmd/unique.t'
  1304. fi
  1305. if test -f 'agent/test/cmd/write.t' -a "${1}" != "-c" ; then 
  1306.   echo shar: Will not clobber existing file \"'agent/test/cmd/write.t'\"
  1307. else
  1308.   echo shar: Extracting \"'agent/test/cmd/write.t'\" \(1840 characters\)
  1309.   sed "s/^X//" >'agent/test/cmd/write.t' <<'END_OF_FILE'
  1310. X# The WRITE command
  1311. X
  1312. X# $Id: write.t,v 3.0 1993/11/29 13:49:55 ram Exp ram $
  1313. X#
  1314. X#  Copyright (c) 1990-1993, Raphael Manfredi
  1315. X#  
  1316. X#  You may redistribute only under the terms of the Artistic License,
  1317. X#  as specified in the README file that comes with the distribution.
  1318. X#  You may reuse parts of this distribution only within the terms of
  1319. X#  that same Artistic License; a copy of which may be found at the root
  1320. X#  of the source tree for mailagent 3.0.
  1321. X#
  1322. X# $Log: write.t,v $
  1323. X# Revision 3.0  1993/11/29  13:49:55  ram
  1324. X# Baseline for mailagent 3.0 netwide release.
  1325. X#
  1326. X
  1327. Xdo '../pl/cmd.pl';
  1328. X$mbox = 'mbox';
  1329. X
  1330. X&add_header('X-Tag: write #1');
  1331. X`$cmd`;
  1332. X$? == 0 || print "1\n";
  1333. X-f "$mbox" || print "2\n";        # Mail saved here
  1334. X-f "$user" && print "3\n";        # Must not exist (yet)
  1335. X
  1336. X# When mailbox protected against writing...
  1337. Xunlink <emerg/*>;
  1338. X$size = -s "$mbox";
  1339. Xchmod 0444, "$mbox";
  1340. X`$cmd`;
  1341. X$? == 0 || print "4\n";
  1342. X-f "$mbox" || print "5\n";                # Must still be there
  1343. X$size == -s "$mbox" || print "6\n";        # And not altered
  1344. X@emerg = <emerg/*>;
  1345. X@emerg == 1 || print "7\n";                # Emeregency as SAVE failed
  1346. X-f "$user" || print "8\n";                # Not saved -> leave in mbox
  1347. X-s "$user" == -s "$mbox" || print "9\n";
  1348. X
  1349. X# There is no X-Filter mail in the emergency saving
  1350. X`grep -v X-Filter: $mbox > ok`;
  1351. X$? == 0 || print "10\n";
  1352. X-s $emerg[0] eq -s 'ok' || print "11\n";    # Full mail saved, of course
  1353. X
  1354. X# Now verify WRITE actually overwrites the contentes
  1355. Xunlink "$user";
  1356. Xchmod 0644, "$mbox";
  1357. X`$cmd`;
  1358. X$? == 0 || print "12\n";
  1359. X$size == -s "$mbox" || print "13\n";
  1360. X-f "$user" && print "14\n";
  1361. X
  1362. X# Make sure WRITE creates full path when needed
  1363. X&replace_header('X-Tag: write #2');
  1364. X`rm -rf path` if -d 'path';
  1365. X`$cmd`;
  1366. X$? == 0 || print "15\n";
  1367. X-f 'path/another/third/mbox' || print "16\n";
  1368. X`rm -rf path` if -d 'path';
  1369. X
  1370. Xunlink <emerg/*>;
  1371. Xunlink "$mbox", "$user", 'mail', 'ok';
  1372. Xprint "0\n";
  1373. END_OF_FILE
  1374.   if test 1840 -ne `wc -c <'agent/test/cmd/write.t'`; then
  1375.     echo shar: \"'agent/test/cmd/write.t'\" unpacked with wrong size!
  1376.   fi
  1377.   # end of 'agent/test/cmd/write.t'
  1378. fi
  1379. if test -f 'agent/test/misc/mh.t' -a "${1}" != "-c" ; then 
  1380.   echo shar: Will not clobber existing file \"'agent/test/misc/mh.t'\"
  1381. else
  1382.   echo shar: Extracting \"'agent/test/misc/mh.t'\" \(2486 characters\)
  1383.   sed "s/^X//" >'agent/test/misc/mh.t' <<'END_OF_FILE'
  1384. X# Test MH-style folders
  1385. X
  1386. X# $Id: mh.t,v 3.0 1993/11/29 13:50:09 ram Exp ram $
  1387. X#
  1388. X#  Copyright (c) 1990-1993, Raphael Manfredi
  1389. X#  
  1390. X#  You may redistribute only under the terms of the Artistic License,
  1391. X#  as specified in the README file that comes with the distribution.
  1392. X#  You may reuse parts of this distribution only within the terms of
  1393. X#  that same Artistic License; a copy of which may be found at the root
  1394. X#  of the source tree for mailagent 3.0.
  1395. X#
  1396. X# $Log: mh.t,v $
  1397. X# Revision 3.0  1993/11/29  13:50:09  ram
  1398. X# Baseline for mailagent 3.0 netwide release.
  1399. X#
  1400. X
  1401. Xdo '../pl/misc.pl';
  1402. Xunlink "$user", 'always';
  1403. X
  1404. X-d 'mh' || mkdir('mh', 0700) || print "1\n";
  1405. X-d 'mh/tmp' || mkdir('mh/tmp', 0700) || print "2\n";
  1406. Xunlink <mh/tmp/*>;
  1407. Xopen(MSG, '>mh/tmp/3') || print "3\n";
  1408. Xprint MSG <<'EOF';
  1409. XFrom: mailagent
  1410. XTo: ram
  1411. XSubject: message #3
  1412. X
  1413. XMessage #3
  1414. XEOF
  1415. Xclose MSG;
  1416. Xopen(MSG, '>mh/tmp/7') || print "4\n";
  1417. Xprint MSG <<'EOF';
  1418. XFrom: mailagent
  1419. XTo: ram
  1420. XSubject: message #7
  1421. X
  1422. XMessage #7
  1423. XEOF
  1424. Xclose MSG;
  1425. Xopen(MSG, '>mh/tmp/.mh_sequences') || print "5\n";
  1426. Xprint MSG <<'EOF';
  1427. Xcur: 1
  1428. Xpseq: 3 7
  1429. Xunseen: 1 3-4 12
  1430. Xanother: 1 3-7 12
  1431. Xhole: 1 3 5 7 9
  1432. Xfull: 1-9
  1433. Xlast: 3-6 9-12
  1434. XEOF
  1435. Xclose MSG;
  1436. Xopen(MSG, '>mh/tmp/.mh_seqnew') || print "6\n";
  1437. Xprint MSG <<'EOF';
  1438. Xcur: 1
  1439. Xpseq: 3 7
  1440. Xunseen: 1 3-4 8 12
  1441. Xanother: 1 3-8 12
  1442. Xhole: 1 3 5 7-8 9
  1443. Xfull: 1-9
  1444. Xlast: 3-6 8-12
  1445. Xnew: 8
  1446. XEOF
  1447. Xclose MSG;
  1448. Xopen(MSG, '>.mh_prof') || print "7\n";
  1449. Xprint MSG <<'EOF';
  1450. XPath: mh
  1451. XUnseen-Sequence: unseen, another, hole, full, last, new
  1452. XEOF
  1453. Xclose MSG;
  1454. X
  1455. X-d 'dir' || mkdir('dir', 0700) || print "8\n";
  1456. Xunlink <dir/*>;
  1457. Xopen(MSG, '>dir/.prefix') || print "9\n";
  1458. Xprint MSG "msg\nanother\n";
  1459. Xclose MSG;
  1460. Xopen(MSG, '>dir/msg4') || print "10\n";
  1461. Xclose MSG;
  1462. Xopen(MSG, '>dir/other5') || print "11\n";
  1463. Xclose MSG;
  1464. Xopen(MSG, '>dir/5') || print "12\n";
  1465. Xclose MSG;
  1466. X
  1467. X`rm -rf mh/new`;
  1468. X-d 'mh/new' && print "13\n";
  1469. X
  1470. X-d 'simple' || mkdir('simple', 0700) || print "14\n";
  1471. Xopen(MSG, '>simple/3') || print "15\n";
  1472. Xclose MSG;
  1473. X
  1474. Xunlink 'mh/tmp/8', 'dir/msg5', 'simple/4', $user;
  1475. X
  1476. X&add_option("-o 'mhprofile: ~/.mh_prof' -o 'msgprefix: .prefix'");
  1477. X&add_header('X-Tag: mh');
  1478. X`$cmd`;
  1479. X$? == 0 || print "16\n";
  1480. X-f "$user" && print "17\n";
  1481. X-s 'mh/tmp/8' || print "18\n";
  1482. Xsystem "cmp -s mh/tmp/.mh_sequences mh/tmp/.mh_seqnew >/dev/null 2>&1";
  1483. X$? == 0 || print "19\n";
  1484. X-f 'mh/new/1' || print "20\n";
  1485. X-s 'mh/new/.mh_sequences' || print "21\n";
  1486. X-s 'dir/msg5' || print "22\n";
  1487. X-s 'simple/4' || print "23\n";
  1488. X
  1489. Xsystem "rm -rf mh dir simple >/dev/null 2>&1";
  1490. Xunlink $user, 'mail';
  1491. Xprint "0\n";
  1492. END_OF_FILE
  1493.   if test 2486 -ne `wc -c <'agent/test/misc/mh.t'`; then
  1494.     echo shar: \"'agent/test/misc/mh.t'\" unpacked with wrong size!
  1495.   fi
  1496.   # end of 'agent/test/misc/mh.t'
  1497. fi
  1498. if test -f 'agent/test/misc/newcmd.t' -a "${1}" != "-c" ; then 
  1499.   echo shar: Will not clobber existing file \"'agent/test/misc/newcmd.t'\"
  1500. else
  1501.   echo shar: Extracting \"'agent/test/misc/newcmd.t'\" \(2232 characters\)
  1502.   sed "s/^X//" >'agent/test/misc/newcmd.t' <<'END_OF_FILE'
  1503. X# Test user-defined commands
  1504. X
  1505. X# $Id: newcmd.t,v 3.0 1993/11/29 13:50:10 ram Exp ram $
  1506. X#
  1507. X#  Copyright (c) 1990-1993, Raphael Manfredi
  1508. X#  
  1509. X#  You may redistribute only under the terms of the Artistic License,
  1510. X#  as specified in the README file that comes with the distribution.
  1511. X#  You may reuse parts of this distribution only within the terms of
  1512. X#  that same Artistic License; a copy of which may be found at the root
  1513. X#  of the source tree for mailagent 3.0.
  1514. X#
  1515. X# $Log: newcmd.t,v $
  1516. X# Revision 3.0  1993/11/29  13:50:10  ram
  1517. X# Baseline for mailagent 3.0 netwide release.
  1518. X#
  1519. X
  1520. Xdo '../pl/misc.pl';
  1521. Xunlink "$user", 'always', 'test';
  1522. X
  1523. X&add_option("-o 'newcmd: ~/.newcmd'");
  1524. Xopen(NEWCMD, '>.newcmd') || print "1\n";
  1525. Xprint NEWCMD <<EOF || print "2\n";
  1526. XFIRST_CMD ~/commands first
  1527. XSECOND_CMD ~/commands second
  1528. XTHIRD_CMD ~/commands third
  1529. XEOF
  1530. Xclose NEWCMD || print "3\n";
  1531. X
  1532. Xopen(COM, '>commands') || print "4\n";
  1533. Xprint COM <<'EOC' || print "5\n";
  1534. Xsub first {
  1535. X    &mailhook'third_cmd('test');    # Make sure interface function is there
  1536. X    open(OUT, '>output1');
  1537. X    print OUT join(' ', @ARGV), "\n";
  1538. X    print OUT "$to\n";
  1539. X    close OUT;
  1540. X    0;
  1541. X}
  1542. X
  1543. Xsub second {
  1544. X    &main'add_log('second user-defined command ran ok');
  1545. X    open(OUT, '>output2');
  1546. X    print OUT "$from\n";
  1547. X    print OUT "$header{'Date'}\n";
  1548. X    close OUT;
  1549. X    0;
  1550. X}
  1551. X
  1552. Xsub third {
  1553. X    local($cmd) = @_;
  1554. X    local(@cmd) = split(' ', $cmd);
  1555. X    open(TEST, ">$cmd[1]");
  1556. X    print TEST "$cmd\n";
  1557. X    close TEST;
  1558. X    0;
  1559. X}
  1560. XEOC
  1561. Xclose COM || print "6\n";
  1562. X
  1563. X&add_header('X-Tag: newcmd');
  1564. X`$cmd`;
  1565. X$? == 0 || print "7\n";
  1566. X-f "$user" && print "8\n";        # Has defaulted to LEAVE -> something's wrong
  1567. X-f 'output1' || print "9\n";
  1568. X-f 'output2' || print "10\n";
  1569. X-f 'test' || print "11\n";
  1570. X
  1571. Xchop($test = `cat test 2>/dev/null`);
  1572. X$test eq 'third_cmd test' || print "12\n";
  1573. X
  1574. Xchop(@test = `cat output1 2>/dev/null`);
  1575. X$test[0] eq 'FIRST_CMD arg1 arg2' || print "13\n";
  1576. X$test[1] eq 'ram@eiffel.com' || print "14\n";
  1577. X
  1578. Xchop(@test = `cat output2 2>/dev/null`);
  1579. X$test[0] eq 'compilers-request@iecc.cambridge.ma.us' || print "15\n";
  1580. X$test[1] eq '3 Jul 92 00:43:22 EDT (Fri)' || print "16\n";
  1581. X
  1582. X&get_log(17);
  1583. X&check_log('second user-defined command ran ok', 18) == 1 || print "19\n";
  1584. X
  1585. Xunlink "$user", 'mail', 'test', 'output1', 'output2', 'commands', '.newcmd';
  1586. Xprint "0\n";
  1587. END_OF_FILE
  1588.   if test 2232 -ne `wc -c <'agent/test/misc/newcmd.t'`; then
  1589.     echo shar: \"'agent/test/misc/newcmd.t'\" unpacked with wrong size!
  1590.   fi
  1591.   # end of 'agent/test/misc/newcmd.t'
  1592. fi
  1593. if test -f 'agent/test/option/s.t' -a "${1}" != "-c" ; then 
  1594.   echo shar: Will not clobber existing file \"'agent/test/option/s.t'\"
  1595. else
  1596.   echo shar: Extracting \"'agent/test/option/s.t'\" \(2336 characters\)
  1597.   sed "s/^X//" >'agent/test/option/s.t' <<'END_OF_FILE'
  1598. X# -s: report gathered statistics (special)
  1599. X
  1600. X# $Id: s.t,v 3.0 1993/11/29 13:50:20 ram Exp ram $
  1601. X#
  1602. X#  Copyright (c) 1990-1993, Raphael Manfredi
  1603. X#  
  1604. X#  You may redistribute only under the terms of the Artistic License,
  1605. X#  as specified in the README file that comes with the distribution.
  1606. X#  You may reuse parts of this distribution only within the terms of
  1607. X#  that same Artistic License; a copy of which may be found at the root
  1608. X#  of the source tree for mailagent 3.0.
  1609. X#
  1610. X# $Log: s.t,v $
  1611. X# Revision 3.0  1993/11/29  13:50:20  ram
  1612. X# Baseline for mailagent 3.0 netwide release.
  1613. X#
  1614. X
  1615. Xdo '../pl/init.pl';
  1616. Xdo '../pl/logfile.pl';
  1617. Xchdir '../out';
  1618. Xunlink 'mailagent.st';
  1619. X$out = `$mailagent -summary 2>/dev/null`;
  1620. X$? == 0 || print "1\n";
  1621. X`cp /dev/null mailagent.st`;
  1622. X$mail_test = <<'EOM';
  1623. XFrom ram Sat Jul 11 18:51:16 PDT 1992
  1624. XFrom: ram
  1625. XTo: ram
  1626. XSubject: test
  1627. X
  1628. XThis is a test.
  1629. XEOM
  1630. X# First time creates new statistics, second time updates them.
  1631. Xfor ($i = 0; $i < 2; $i++) {
  1632. X    open(MAILAGENT, "|$mailagent -e 'STRIP Nothing; LEAVE' 2>/dev/null") ||
  1633. X    print "2x$i\n";
  1634. X    print MAILAGENT $mail_test;
  1635. X    close MAILAGENT;
  1636. X    $? == 0 || print "3x$i\n";
  1637. X    sleep 1 while -f 'perl.lock';    # Wait for background process to finish
  1638. X}
  1639. X$user = $ENV{'USER'};
  1640. X-s "$user" || print "4\n";
  1641. X$out = `$mailagent -s 2>/dev/null`;
  1642. X$out ne '' || print "5\n";
  1643. X@out = split(/\n/, $out);
  1644. X@leave = grep(/LEAVE/, @out);
  1645. X@strip = grep(/STRIP/, @out);
  1646. X@leave == @strip || print "6\n";
  1647. X@leave == 1 || print "7\n";
  1648. X$out = `$mailagent -sm 2>/dev/null`;
  1649. X@out = split(/\n/, $out);
  1650. X@leave = grep(/LEAVE/, @out);
  1651. X@strip = grep(/STRIP/, @out);
  1652. X@leave == @strip || print "8\n";
  1653. X@leave == 2 || print "9\n";
  1654. X$out = `$mailagent -sr 2>/dev/null`;
  1655. X@out = split(/\n/, $out);
  1656. Xgrep(/STRIP.*LEAVE/, @out) || print "10\n";
  1657. X&get_log(11, 'mailagent.st');
  1658. X&check_log('^---', 12) == 1 || print "13\n";    # Rules did not changed
  1659. X&check_log('^\+\+\+', 14) == 1 || print "15\n";
  1660. X
  1661. X# Now change rules slightly
  1662. Xopen(MAILAGENT, "|$mailagent -e 'STRIP Other; LEAVE' 2>/dev/null") ||
  1663. Xprint "16\n";
  1664. Xprint MAILAGENT $mail_test;
  1665. Xclose MAILAGENT;
  1666. X$? == 0 || print "17\n";
  1667. Xsleep 1 while -f 'perl.lock';        # Wait for background process to finish
  1668. X&get_log(18, 'mailagent.st');
  1669. X&check_log('^---', 19) == 2 || print "20\n";    # Rules did changed
  1670. X&check_log('^\+\+\+', 21) == 2 || print "22\n";
  1671. X
  1672. Xunlink 'mailagent.st', "$user";
  1673. Xprint "0\n";
  1674. END_OF_FILE
  1675.   if test 2336 -ne `wc -c <'agent/test/option/s.t'`; then
  1676.     echo shar: \"'agent/test/option/s.t'\" unpacked with wrong size!
  1677.   fi
  1678.   # end of 'agent/test/option/s.t'
  1679. fi
  1680. if test -f 'misc/unkit/rules' -a "${1}" != "-c" ; then 
  1681.   echo shar: Will not clobber existing file \"'misc/unkit/rules'\"
  1682. else
  1683.   echo shar: Extracting \"'misc/unkit/rules'\" \(379 characters\)
  1684.   sed "s/^X//" >'misc/unkit/rules' <<'END_OF_FILE'
  1685. X# This rule will process any message containing the word 'kit #' in the subject
  1686. X# and that is not a reply. Indded, each kit message has a subject looking like:
  1687. X#   package - kit #1 / 5
  1688. X# The UNKIT command can be configured from the ~/.mailagent file, but defaults
  1689. X# values are hardwired and should be ok most of the time.
  1690. X
  1691. X!Subject: /^Re:/, !/kit #/        { UNKIT; ABORT -t; LEAVE };
  1692. END_OF_FILE
  1693.   if test 379 -ne `wc -c <'misc/unkit/rules'`; then
  1694.     echo shar: \"'misc/unkit/rules'\" unpacked with wrong size!
  1695.   fi
  1696.   # end of 'misc/unkit/rules'
  1697. fi
  1698. echo shar: End of archive 21 \(of 26\).
  1699. cp /dev/null ark21isdone
  1700. MISSING=""
  1701. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ; do
  1702.     if test ! -f ark${I}isdone ; then
  1703.     MISSING="${MISSING} ${I}"
  1704.     fi
  1705. done
  1706. if test "${MISSING}" = "" ; then
  1707.     echo You have unpacked all 26 archives.
  1708.     echo "Now run 'sh PACKNOTES', then read README and type Configure.'"
  1709.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1710. else
  1711.     echo You still must unpack the following archives:
  1712.     echo "        " ${MISSING}
  1713. fi
  1714. exit 0
  1715.  
  1716. exit 0 # Just in case...
  1717.