From:	CRDGW2::CRDGW2::MRGATE::"SMTP::KSUVAX1.CIS.KSU.EDU::MCCALL!NEWSMGR" 31-AUG-1990 01:58:10.08
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	RE: feature request in UUCP_MAILSHR, LIB$FIND_IMAGE_SYMBOL

Received:  by crdgw1.ge.com (5.57/GE 1.70)
	 id AA11767; Fri, 31 Aug 90 01:48:28 EDT
Resent-From: mccall!newsmgr@ksuvax1.cis.ksu.edu
Return-Path: mccall!newsmgr@ksuvax1.cis.ksu.edu
Received: from harris.cis.ksu.edu by DRYCAS.CLUB.CC.CMU.EDU; Fri, 31 Aug 90
 01:41 EST
Received: from ksuvax1.cis.ksu.edu by harris.cis.ksu.edu (5.58/SWH-2.03); id
 AA23240; Fri, 31 Aug 90 00:41:38 CDT
Received: by ksuvax1.cis.ksu.edu (5.59++/CIS1.1) id AA28140; Fri, 31 Aug 90
 00:41:36 CDT
Resent-Date: Fri, 31 Aug 90 01:42 EST
Date: 30 Aug 90 14:18:24 GMT
From: gjc@mitech.com
Subject: RE: feature request in UUCP_MAILSHR, LIB$FIND_IMAGE_SYMBOL
Resent-To: VMSNET-LIST@DRYCAS.CLUB.CC.CMU.EDU
To: vmsnet@DRYCAS.CLUB.CC.CMU.EDU
Resent-Message-Id: <4014F7D9748F0002B2@DRYCAS.CLUB.CC.CMU.EDU>
Message-Id: <4744@mitech.com>
Organization: Mitech Corporation, Concord MA
X-Envelope-To: everhart%arisia.decnet@CRDGW1.GE.COM
X-Vms-To: vmsnet@DRYCAS.CLUB.CC.CMU.EDU

In article <49.26db79f2@inland.com>, allebrandi@inland.com (Tom Allebrandi) writes:
> Interesting idea. I've stashed a copy of your article and will
> consider adding this for the next release of the mail handler.

Great. When it comes out I can release my ADDRESS_REWRITE module,
which is scheme/lisp based (but still extremely small).
(Actually I guess I can release it before then. If there are people
who would like to try it they can make the modifications to GLUE.C
etc and then have me send them my other code).

I never fooled with CHECKADDR before, so I've just realized that
my putting all the changes into GLUE.C was not the correct thing to do.
Instead, here are the minor diffs to glue.c and an entirely new
file DYN_TRANSFORM.C:

File USER$DISK:[GJC.UUCP.MAILSHR]GLUE.C;2
  291   	dyn_init_transform();
  298   newaddressP = dyn_add_transform(address,class);
File USER$DISK:[GJC.UUCP.MAILSHR]GLUE.C;1
  291   	init_transform();
  298   newaddressP = add_transform(address,class);

Here is the file DYN_TRANSFORM:C

/* Defines dyn_init_transform and dyn_add_transform,
   to dynamically load a uucp mail transform module if available
   or to call init_transform and add_transform by default.
 */

/* Author: George Carrette, GJC@MITECH.COM 30-AUG-90 */

#include stdio
#include descrip
#include ssdef
#include lnmdef

void init_transform();
char *add_transform();

static void (*ptr_init_transform)() = NULL;
static char * (*ptr_add_transform)() = NULL;

void dyn_init_transform()
{if (load_dyn_transform() == 0)
   {ptr_init_transform = NULL;
    ptr_add_transform = NULL;}
 if (ptr_init_transform != NULL)
   (*ptr_init_transform)();
 else
   init_transform();}

char *dyn_add_transform(addr,kind)
     char *addr;
     long kind;
{if (ptr_add_transform != NULL)
   return((*ptr_add_transform)(addr,kind));
 else
   return(add_transform(addr,kind));}

static $DESCRIPTOR(dyn_rewrite_module,"UUCP_ADDRESS_REWRITE_HANDLER");
static $DESCRIPTOR(dyn_rewrite_lnm,"LNM$FILE_DEV");
static $DESCRIPTOR(dyn_init_transform_name,"init_transform");
static $DESCRIPTOR(dyn_add_transform_name,"add_transform");

load_dyn_transform()
{struct trnlnm_item
   {short buflen;
    short code;
    char *buffer;
    short *retlen;} items[2];
 char buff[256];
 short retsize;
 int retval;
 items[1].buflen = 0;
 items[1].code = 0;
 items[0].buflen = sizeof(buff);
 items[0].code = LNM$_STRING;
 items[0].buffer = buff;
 items[0].retlen = &retsize;
 retval = sys$trnlnm(0,&dyn_rewrite_lnm,&dyn_rewrite_module,0,items);
 if (retval == SS$_NOLOGNAM) return(0);
 if (retval != SS$_NORMAL) {lib$signal(retval); return(0);}
 if (retsize == 0) return(0);
 retval = lib$find_image_symbol(&dyn_rewrite_module,
				&dyn_init_transform_name,
				&ptr_init_transform,
				0);
 if (retval != SS$_NORMAL) return(0);
 retval = lib$find_image_symbol(&dyn_rewrite_module,
				&dyn_add_transform_name,
				&ptr_add_transform,
				0);
 if (retval != SS$_NORMAL) return(0);
 return(1);}
 
