From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 22-NOV-1988 09:30
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Aliased Mail (another one)


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue, 22 NOV 88 04:15:56 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Tue, 22 Nov 88 03:54:11 PST
Received: by ucbvax.Berkeley.EDU (5.59/1.31)
	id AA10911; Mon, 21 Nov 88 23:12:09 PST
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 22 Nov 88 00:35:03 GMT
From: unmvax!charon!sdowdy@ucbvax.Berkeley.EDU  (Stephen Dowdy)
Organization: University of New Mexico, Albuquerque, NM
Subject: Aliased Mail (another one)
Message-Id: <4002@charon.unm.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

Joel Snyder brought up an interesting point regarding LNM$FILE_DEV usage
for mail aliases.  So, i decided that i would write the program he is
afraid to show (because of it's DCL grossness) and here it is...

It uses a /usr/lib/aliases style configuration file referenced by
	MAIL_ALIASES (default SYS$LOGIN:.DAT)
and keeps track of the file to reload it if it changes (either by name
or revision)  The Logicals are stored in an alternate table that is
connected in /user mode in LNM$FILE_DEV prior to invoking the mail command.
This also supports the command line interface to MAIL ($ Mail [file] [to])

The format for MAIL_ALIASES.DAT is
	[alias : equivalence ] [! comments]
E.G.
	! Mail Aliases File
	
	People:		Manny,Moe,Jack	! 3 people
	Everyone:	People, @other_guys,	! all the people here
	Over_There:	REMNOD::Hey_You	! remote node person

Comments for Alias_Mail are at the bottom of the file.

Joel Snyder claims 10 lines, but to do this "well", it took me more like
65 or so.

Question: Anyone know a quick way to get a DCL symbol to contain the entire
Search List for a logical name (LNM$FILE_DEV in particular) If you notice,
i had to write a subroutine to do this.

--- Cut 'n' Snip ---
$! Title:	Alias_Mail.Com
$! see bottom for comments
$	Set NoOn
$	mailqual	= P1
$	mailfile	= P2
$	destination	= P3
$	a_tbl_exists	= (F$TRNLNM("MAIL_ALIASES", -
		"LNM$PROCESS_DIRECTORY",,,,"TABLE"))
$	If (.NOT. a_tbl_exists) Then -
		Create/Name/Parent=LNM$PROCESS_DIRECTORY MAIL_ALIASES
$	alias_file	= F$Parse("MAIL_ALIASES","SYS$LOGIN:.DAT")
$	If (F$Search(alias_file) .NES. "") Then Goto GET_ALIASES
$ NO_ALIAS_FILE:
$	Write SYS$OUTPUT "%ALM-E-NOALIAFIL, No Alias File ''alias_file'"
$	Deassign/All/Table=MAIL_ALIASES
$	Goto DO_MAIL
$ GET_ALIASES:
$	Gosub	GET_FILE_DEV
$	aliasfname	= F$TRNLNM("ALIAS_FILE_NAME","MAIL_ALIASES")
$	aliasfdate	= F$CVTime(F$File(alias_file,"RDT"))
$	old_date	= F$TRNLNM("ALIAS_FILE_DATE","MAIL_ALIASES")
$	If ((aliasfname .NES. alias_file) .OR. -
		(old_date .LTS. aliasfdate)) Then Gosub CONFIG_ALIASES
$	Define/NoLog/Table=MAIL_ALIASES ALIAS_FILE_DATE "''aliasfdate'"
$	Define/NoLog/Table=MAIL_ALIASES ALIAS_FILE_NAME "''alias_file'"
$ DO_MAIL:
$	Deassign SYS$INPUT
$	Define/NoLog/User/Table=LNM$PROCESS_DIRECTORY -
		LNM$FILE_DEV 'lnm$file_dev',MAIL_ALIASES
$	Mail$ 'mailqual' 'mailfile' 'destination'
$ EXIT:
$	Exit
$ CONFIG_ALIASES:
$	Write SYS$OUTPUT "%ALM-I-CFGALIAS, Configuring Aliases File..."
$	Deassign/All/Table=MAIL_ALIASES
$	Open/Read/Err=READ_ERR/Share=Read AFILE 'alias_file'
$ RD_LOOP:
$	Read/End=NO_MORE/NoLock AFILE rec
$	rec = F$Edit(rec,"TRIM,COMPRESS,UNCOMMENT")
$	If (rec .EQS. "") Then Goto RD_LOOP
$	aname	= F$Edit(F$Element(0,":",rec),"TRIM")
$	aequiv	= F$Edit(F$Element(1,":",rec),"TRIM")
$	If ((aname .EQS. ":") .OR. (aequiv .EQS. ":") -
		.OR. (aname .EQS. "") .OR. (aequiv .EQS. "")) Then -
		Goto BAD_ENTRY
$	Define/NoLog/Table=MAIL_ALIASES "''aname'" "''aequiv'"
$	Goto RD_LOOP
$ BAD_ENTRY:
$	Write SYS$OUTPUT "%ALM-E-BADENTRY, Bad Entry in Alias File"
$	Write SYS$OUTPUT " \''rec'\"
$	Goto RD_LOOP
$ NO_MORE:
$	If (F$TRNLNM("AFILE") .NES. "") Then -
		Close AFILE
$	Return
$ GET_FILE_DEV:
$	max_index = F$TRNLNM("LNM$FILE_DEV","LNM$DIRECTORIES",,,,"MAX_INDEX")
$	ind = 0
$	lnm$file_dev = ""
$ IND_LOOP:
$	lnm$file_dev = lnm$file_dev + "," + -
		F$TRNLNM("LNM$FILE_DEV","LNM$DIRECTORIES",ind)
$	ind = ind + 1
$	If (ind .LE. max_index) Then Goto IND_LOOP
$	lnm$file_dev = lnm$file_dev - ","
$	Return
$!##############################################################################
$! Title:	Alias_Mail.Com
$! Purpose:	To Provide user defined aliases to mail w/o overhead at all
$!		times in LogNam processing
$! Author:	Stephen Dowdy (University of New Mexico -- CIRT)
$! Date:	20-Nov-1988
$! Modification Log:
$!##############################################################################

Alias_Mail allows users to have Mail Aliases defined for them via use of
a configuration file and a logical name table that is connected only within
the scope of this program.  This scheme allows the logicals to be defined
at all times, but not to be processed all the time.

The Aliases Configuration file is known as MAIL_ALIASES.DAT.  It is normally
located in SYS$LOGIN:, but can be referenced by the logical name
MAIL_ALIASES as defined in a LNM$FILE_DEV table.

Format of MAIL_ALIASES.DAT:
[<alias_name> : <alias_equivalence>] [ ! Comment ]
E.G.
	! Mail_Aliases.Dat File

	manager:	System		! System Manager Alias
	Ken:		DECVAX::KOLSEN	! Ken Olsen

Whenever you edit your Mail_Aliases.Dat File, it is detected, and
all aliases are reconfigured.  If you redefine MAIL_ALIASES, this is
also detected, and your aliases are again reconfigured.  This means that
the MAIL_ALIASES table is wiped clean and reconfigured from scratch.

You can call this program with arguments
	P1 = qualifiers for the Mail command
	P2 = Input file spec
	P3 = TO: address destination
-- 
$!#######################################################################
$! stephen dowdy (UNM CIRT) Albuquerque, New Mexico, 87131 (505) 277-8044
$! Usenet:   {convex,ucbvax,gatech,csu-cs,anl-mcs}!unmvax!ariel!sdowdy
$! BITNET:   sdowdy@unmb
$! Internet: sdowdy@ariel.unm.edu
$!      Team SPAM in '88!            SPAAAAAAAAAAAAAAAAAAAAMMMMMMM!
$!#######################################################################

