Rewrite routine substitutions

Rewrite routine substitutions,
A substitution of the form      is handled specially. The   part is used to find and call an  Oracle-supplied or customer-supplied routine. At run-time on UNIX, the MTA uses   and   to dynamically load and call  the routine   from the shared library   . The routine   is then called as a function with the following argument list: status := routine (argument, arglength, result, reslength) where argument and result are 256 byte long (252 byte long in iMS 5.2 and earlier) character string  buffers. On Solaris,  argument and result are passed as a  pointer to a character string, (e.g., in C, as char&#x2a;). arglength and reslength are signed, long integers passed by reference. On input, argument contains the   string from the rewrite  rule template, and arglength the length of that  string. On return, the resultant string should be placed in result and its length in reslength. This resultant string will then replace the " " in the  rewrite rule template. The routine   should return 0 if the rewrite rule should fail and -1 if the rewrite rule  should succeed.

This mechanism allows the MTA&#x27;s rewriting process to be extended in all sorts of complex ways. For example, a call to some type of name service could be performed and the result used to alter the address in some  fashion. For instance, directory service lookups for forward pointing addresses (e.g., To: addresses) to the host domain.com might be  performed as follows with the following rewrite rule (the $F, described  in  Address direction and location-specific rewrites  causes this rule to only be used for forward pointing addresses): domain.com     $F$&#x5b;LOOKUP_IMAGE,LOOKUP,$U&#x5d; A forward pointing address jdoe@domain.com will, when it matches this rewrite rule, cause   (which is    a shared library on UNIX) to be loaded into  memory, and then cause the routine   called with  "jdoe" as the argument parameter. The routine   might then return a different address, say,  John.Doe%specialhost.domain.com in the result parameter and  the value -1 to indicate that the rewrite rule succeeded. The percent sign in the result string causes, as described in  Repeated rewriting template,  the  rewriting process to start over again using John.Doe@specialhost.domain.com  as the address to be rewritten.

The site-supplied shared library image   should be readable but not writable by the Messaging Server user.

Note: This facility is not designed for use by casual users; it is intended to be used to extend the MTA&#x27;s capabilities system-wide.

See also:
 * Callout routines
 * Address direction and location-specific rewrites
 * Repeated rewriting template
 * Rewrite rule template substitutions and control sequences