Customer-Supplied Routine Substitutions, $[...]

A substitution of the form $[image,routine,argument] is handled specially. The image,routine,argument part is used to find and call a customer-supplied routine. At runtime, IMTA uses dlopen and dlsym to dynamically load and call the routine routine from the shared library image. The routine routine is then called as a function, with the following argument list:

 
int routine
 

 
 
(char *argument
 
int *arglength
 

 
char *result
 
init *reslength);
 
 
/* input string */
 
/* pointer to length of input 
string
 
/* result of substitution */
 
/* length of result of 
substitution */
 

argument and result are 252 byte-long-character string buffers. The routine routine returns a 0 if the rewrite rule fails, and -1 if the rewrite rule succeeds.

This mechanism allows IMTA's rewriting process to be extended in complex ways. For example, a call to a name service could be performed, and the result used to alter the address. For example, directory service lookups for forward-pointing addresses (To: addresses) to the host alpha.com might be performed as follows, with the rewrite rule, $F, described in TABLE 3-5 causing this rule to be used only for forward-pointing addresses):

jdoe@acme.com $F$[libxyz.so,mylookup,$U]

A forward-pointing address, jdoe@acme.com, when it matches this rewrite rule, causes libxyz.so to be loaded into memory, then causes the routine mylookup called with jdoe as the argument parameter. The routine mylookup might then return a different string, say, John.Doe%alpha.com in the result parameter and the value -1 to indicate that the rewrite rule succeeded. The percent sign (%) in the result string causes the rewriting process to start over again, using John.Doe@alpha.com as the address to be rewritten. The site-supplied shared library image image should be world readable.


Note - This facility is not designed for use by casual users; it is intended to be used to extend IMTA's capabilities system-wide.



Copyright © 1999 Sun Microsystems, Inc. All Rights Reserved.