Next: exit codes, Previous: dispatch rules, Up: smapd [Contents][Index]
Transformations are special rules that modify the key or map value. Syntax of transformation rules is:
dispatch cond-list transform key-or-map dbname
where cond-list is a condition list, as described in the previous section, key-or-map is ‘key’ if the transformation is applied to the key value and ‘map’ if it is applied to the map name, and dbname is the name of a database that handles the transformation. For example:
dispatch key like <*> transform key dequote
This rule applies the ‘dequote’ database to any key that is enclosed in angle brackets. It is supposed that the ‘dequote’ database removes the brackets. It may be implemented using the the ‘sed’ module (see sed module), as follows.
module sed sed database dequote sed extended 's/<(.*)>/\1/g'
The transform rules can be chained, as in the example below:
# This database removes domain part from its argument. database localpart sed 's/@.*$//' # Dispatch rules: dispatch key like <*> transform key dequote dispatch key like *@* transform key localpart dispatch default database getpwnam
As a result, the ‘getpwnam’ database will get the local part of the original key (which may be supplied in the form of an email address).