| Previous | Contents | Index | 
If the comparison of the pattern in a given entry fails, no action is taken; the scan proceeds to the next entry. If the comparison succeeds, the right hand side of the entry is used as a template to produce an output string. The template effectively causes the replacement of the input string with the output string that is constructed from the instructions given by the template.
Almost all characters in the template simply produce themselves in the output. The one exception is a dollar sign.
A dollar sign followed by a dollar sign, space, or tab produces a dollar sign, space, or tab in the output string. Note that all these characters must be quoted in order to be inserted into the output string.
A dollar sign followed by a digit N calls for a substitution; a dollar sign followed by an alphabetic character is referred to as a "metacharacter". Metacharacters themselves will not appear in the output string produced by a template. See Table 5-2 for a list of the special substitution and standard processing metacharacters. Any other metacharacters are reserved for mapping-specific applications.
Note that any of the metacharacters $C, $E, 
$L, or $R, when present in the template of a 
matching pattern, will influence the mapping process, controlling 
whether it terminates or continues. That is, it is possible to set up 
iterative mapping table entries, where the output of one entry becomes 
the input of another entry. If the template of a matching pattern does 
not contain any of the metacharacters $C, $E, 
$L, or $R, then $E (immediate 
termination of the mapping process) is assumed.
The number of iterative passes through a mapping table is limited to prevent infinite loops. A counter is incremented each time a pass is restarted with a pattern that is the same length or longer than the previous pass. If the string has a shorter length than previously, the counter is reset to zero. A request to again iterate a mapping is not honored after the counter has exceeded 10.
| Substitution sequence | Section | Substitutes | 
|---|---|---|
| $ n | 5.3.2.1 | nth wildcarded field as counted from left to right starting from 0 | 
| $#...# | 5.3.2.6 | Sequence number substitution. | 
| $]...[ | 5.3.2.7 | LDAP search URL lookup; substitute in result. | 
| ${...} | 5.3.2.8 | General database substitution. | 
| $|...| | 5.3.2.9 | Apply specified mapping table to supplied string. | 
| $[...] | 5.3.2.10 | Invoke site-supplied routine; substitute in result. | 
| Metacharacter | Section | Description | 
| $C | 5.3.2.3 | Continue the mapping process starting with the next table entry; use the output string of this entry as the new input string for the mapping process. | 
| $E | 5.3.2.3 | End the mapping process now; use the output string from this entry as the final result of the mapping process. | 
| $L | 5.3.2.3 | Continue the mapping process starting with the next table entry; use the output string of this entry as the new input string; after all entries in the table are exhausted make one additional pass starting with the first table entry. A subsequent match can override this condition with a $C, $E, or $R metacharacter. | 
| $R | 5.3.2.3 | Continue the mapping process starting with the first entry of the the mapping table; use the output string of this entry as the new input string for the mapping process. | 
| $? x? | 5.3.2.5 | Mapping entry succeeds x percent of the time. | 
| $\ | 5.3.2.2 | Force subsequent text to lowercase. | 
| $^ | 5.3.2.2 | Force subsequent text to uppercase. | 
| $_ | 5.3.2.2 | Leave subsequent text in its original case. | 
| $: x | 5.3.2.4 | Match only if the specified flag is set. | 
| $; x | 5.3.2.4 | Match only if the specified flag is clear. | 
5.3.2.1 Wildcard Field Substitutions, $n
A dollar sign followed by a digit n is replaced with the 
material that matched the nth wildcard in the pattern. The 
wildcards are numbered starting with 0. For example, the entry
      PSI$%*::* $1@$0.psi.example.com  | 
PSI%A::B and produce the 
resultant output string b@a.psi.example.com. The input 
string PSI%1234::USER would also match producing 
USER@1234.psi.example.com as the output string. The input 
string PSIABC::DEF would not match the pattern in this 
entry and no action would be taken; i.e., no output string 
would result from this entry.
5.3.2.2 Controlling Text Case, $\, $^, $_
$\ forces subsequent text to lowercase, $^ 
forces subsequent text to uppercase, and $_ causes 
subsequent text to retain its original case. For instance, these 
metacharacters can be useful when using mappings to transform addresses 
for which case is significant.
5.3.2.3 Processing Control, $C, $L, $R, $E
The $C, $L, $R, and 
$E metacharacters influence the mapping process, 
controlling whether and when the mapping process terminates. 
$C causes the mapping process to continue with the next 
entry, using the output string of the current entry as the new input 
string for the mapping process. $L causes the mapping 
process to continue with the next entry, using the output string of the 
current entry as the new input string for the mapping process, and, if 
no matching entry is found, making one additional pass through the 
table starting with the first table entry; a subsequent matching entry 
with a $C, $E, or $R 
metacharacter overrides this condition. $R causes the 
mapping process to continue from the first entry of the table, using 
the output string of the current entry as the new input string for the 
mapping process. $E causes the mapping process to 
terminate; the output string of this entry is the final output. 
$E is the default.
Mapping table templates are scanned left to right. So to set a 
$C, $L, or $R flag for entries 
that can "succeed" or "fail", e.g., 
general database substitutions, or random value controlled entries, put 
the $C, $L, or $R metacharacter 
to the left of the part of the entry that can succeed or fail; 
otherwise, if the remainder of the entry fails, the flag will not be 
seen.
5.3.2.4 Check for Special Flags
Some mapping probes have special flags set. $:x causes an 
entry to match only if the flag x is set. $;x 
causes an entry to match only if the flag x is clear. See 
specific mapping table descriptions for any special flags that can 
apply for that table.
When the intention is that an entry should succeed and terminate if the 
flag check succeeds, but that the mapping process should continue if 
the flag check fails, then the entry should use the $C 
metacharacter to the left of the flag check and use the $E 
flag to the right of the flag check.
5.3.2.5 Entry Randomly Succeeds or Fails, $?x?
$?x? in a mapping table entry causes the entry to 
"succeed" x percent of the time; the rest of the 
time, the entry "fails" and the output of the mapping entry's 
input is taken unchanged as the output. (Note that, depending upon the 
mapping, the effect of the entry "failing" is not necessarily 
the same as the entry not matching in the first place.) The argument 
between the ?'s, x, should consist of a real 
number specifying the success percentage.
For instance, suppose that a system with IP address 123.45.6.78 is 
sending your site just a little too much e-mail and you'd like to slow 
it down; if you're using the multithreaded TCP SMTP channel, you can 
use a PORT_ACCESS mapping table in the following way. 
Suppose you'd like to allow through only 25 percent of its connection 
attempts and temporarily reject the other 75 percent of its connection 
attempts. The following PORT_ACCESS mapping table uses 
$?25? to cause the entry with the $Y (accept 
the connection) to succeed only 25 percent of the time; the other 75 
percent of the time, when this entry fails, the initial $C 
on that entry causes PMDF to continue the mapping from the next entry, 
which causes the connection attempt to be rejected with a temporary 
SMTP error (in this example, 452 4.4.0) and the text message "Try 
again later".
      PORT_ACCESS TCP|*|25|123.45.6.78|* $C$?25?$Y TCP|*|25|123.45.6.78|* $N452$ 4.4.0$ Try$ again$ later  | 
      PORT_ACCESS ! POP3 connections TCP|*|110|123.45.6.78|* $C$?25?$Y TCP|*|110|123.45.6.78|* $N-ERR$ Try$ again$ later ! IMAP connections TCP|*|143|123.45.6.78|* $C$?25?$Y TCP|*|143|123.45.6.78|* $N*$ BYE$ Try$ again$ later  | 
PORT_ACCESS mapping 
table.
Another example would be to randomly issue a temporary failure message 
for a certain percentage of SMTP messages from a particular envelope 
From: address; for instance, suppose the goal is to issue 
a temporary failure message with extended SMTP code 4.5.9 to 80 percent 
of the messages that busybee@some.where attempts to send 
to your local channel users. Then a SEND_ACCESS mapping 
table could be used, e.g.,
      SEND_ACCESS tcp_*|busybee@some.where|l|* $C$?20?$Y tcp_*|busybee@some.where|l|* $N$X4.5.9|Try$ again$ later  | 
5.3.2.6 Sequence Number Substitutions, $#...#
A $#...# substitution increments the value stored in a 
PMDF sequence file and substitutes that value into the template. This 
can be used to generate unique, increasing strings in cases where it is 
desirable to have a uniquifier in the mapping table output; for 
instance, when using a mapping table to generate file names.
Permitted syntax is any one of:
      $#seq-file-spec|radix|width#  | 
      $#seq-file-spec|radix#  | 
      $#seq-file-spec#  | 
seq-file-spec argument is a 
full file specification for an (already existing) PMDF sequence file, 
and where the optional radix and 
width arguments specify the radix (base) in which 
to output the sequence value, and the number of digits to output, 
respectively. The seq-file-spec argument can be 
omitted, in which case PMDF will use its own temporary sequence file 
(that will be created and used for the duration of this image). The 
default radix is 10. Radices in the range -36 to 36 are also allowed; 
for instance, base 36 gives values expressed with digits 
0,...,9,A,...,Z. By default, the sequence value is printed in its 
natural width, but if the specified width calls for a greater number of 
digits, then the output will be padded with 0's on the left to obtain 
the desired number of digits. Note that if a width is explicitly 
specified, then the radix must be explicitly specified also.
As noted above, when specifying an explicit PMDF sequence file in a mapping, that file must already exist. To create a PMDF sequence file, on OpenVMS use the command
      $ CREATE/FDL=PMDF_COM:sequence_number.fdl seq-file-spec  | 
      % touch seq-file-spec  | 
      % cat >seq-file-spec  | 
      C:\> copy nul seq-file-spec  | 
PMDF_USER during your PMDF installation, you should use 
the PMDF_COM:create_pmdf_user_account.com procedure to 
create it.
5.3.2.7 LDAP Query URL Substitutions, $]...[
A substitution of the form $]ldap-url[ is handled 
specially. ldap-url is interpreted as an LDAP 
query URL and the result of the LDAP query is substituted. Standard 
LDAP URLs are used, with the host and port omitted; the host and port 
are instead specified with the LDAP_HOST and 
LDAP_PORT PMDF options (see Section 7.3.2 for further 
discussion of this option). That is, the LDAP URL should be specified as
      ldap:///dn[?attributes[?scope?filter]]  | 
[ and 
] shown above indicate optional portions of the 
URL. The dn is required and is a distinguished 
name specifying the search base. The optional 
attributes, scope, and 
filter portions of the URL further refine what 
information to return. That is, attributes 
specifies the attribute or attributes to be returned from LDAP 
directory entries matching this LDAP query. The 
scope can be any of base (the 
default), one, or sub. 
filter describes the characteristics of matching 
entries.
Certain LDAP URL substitution sequences are available for use within the LDAP query URL; see Table 3-1 for a full list.
5.3.2.8 General Database Substitutions, ${...}
A substitution of the form ${text} is handled specially. The 
text part is used as a key to access the PMDF general 
database.2 This database is generated with the PMDF 
CRDB (OpenVMS) or pmdf crdb (UNIX and NT) utility. 
If text is found in the database, the corresponding template 
from the database is substituted. If text does not match an 
entry in the database, the input string is used unchanged as the output 
string.
If a general database exists, it should be world readable to ensure that it operates properly.
Note that when wanting to use processing control metacharacters such as 
$C, $R, or $L in a mapping table 
entry that does a general database substitution, the processing control 
metacharacter should be placed to the left of the general database 
substitution in the mapping table template; otherwise the 
"failure" of a general database substitution will mean that 
the processing control metacharacter will not be seen.
5.3.2.9 Mapping Table Substitutions, $|...|
A substitution of the form $|mapping;argument| is 
handled specially. PMDF looks for an auxiliary mapping table named 
mapping in the PMDF mapping file, and uses argument 
as the input to that named auxiliary mapping table. The named auxiliary 
mapping table must exist and must set the $Y flag in its 
output if it is successful; if the named auxiliary mapping table does 
not exist or doesn't set the $Y flag, then that auxiliary 
mapping table substitution fails and the original mapping entry is 
considered to fail: the original input string will be used as the 
output string.
Note that when wanting to use processing control metacharacters such as 
$C, $R, or $L in a mapping table 
entry that does a mapping table substitution, the processing control 
metacharacter should be placed to the left of the mapping table 
substitution in the mapping table template; otherwise the 
"failure" of a mapping table substitution will mean that the 
processing control metacharacter will not be seen.
5.3.2.10 Site-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 run-time on OpenVMS, PMDF uses 
LIB$FIND_IMAGE_SYMBOL to dynamically load and link to the 
routine routine from the shareable image 
image; at run-time on UNIX, PMDF uses 
dlopen and dlsym to dynamically load and call 
the routine routine from the shared library 
image; at run-time on NT, PMDF calls the routine 
routine from the dynamic link library 
image. The routine routine 
is then called as a function with the following argument list:
status := routine 
(argument, arglength, 
result, reslength) 
argument and result are 252 byte long 
character string buffers. On OpenVMS argument and 
result are passed by descriptor (a class S descriptor 
is used to ensure maximum compatibility); on UNIX and NT, 
argument and result are passed as a 
pointer to a character string, (e.g., in C, as char*.) 
arglength and reslength are signed, 
long integers passed by reference. On input, argument 
contains the argument string from the mapping 
table 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 
"$[image,routine,argument]" in the 
mapping table template. The routine routine 
should return 0 if the mapping table substitution should fail and -1 if 
the mapping table substitution should succeed. If the substitution 
fails, then normally the original input string will be used unchanged 
as the output string.
Note that when wanting to use processing control metacharacters such as 
$C, $R, or $L in a mapping table 
entry that does a site-supplied routine substitution, the processing 
control metacharacter should be placed to the left of the site-supplied 
routine substitution in the mapping table template; otherwise the 
"failure" of a mapping table substitution will mean that the 
processing control metacharacter will not be seen.
The site-supplied routine callout mechanism allows PMDF's mapping 
process to be extended in all sorts of complex ways. For example, in a 
PORT_ACCESS or SEND_ACCESS mapping table, a 
call to some type of load monitoring service could be performed and the 
result used to decide whether or not to accept a connection or message.
On OpenVMS systems, since LIB$FIND_IMAGE_SYMBOL is used to 
dynamically load the site-supplied image image, 
then image must be a logical name pointing to the 
actual shareable image. Moreover, as this mechanism will be invoked by 
PMDF in a variety of contexts, the logical must be an executive mode 
logical, any logicals it references must also be executive mode 
logicals, and the image itself must be world readable and installed as 
a known image.
On UNIX systems, the site-supplied shared library image 
image should be world readable.
This facility is not designed for use by casual users; it is intended to be used to extend PMDF's capabilities system-wide.  | 
  
      2  The PMDF general database is 
        referenced via the 
    
     | 
  
| Previous | Next | Contents | Index |