The text database-map type allows you to look up keys in flat text files. This technique is vastly less efficient than looking up keys in real databases, but it can serve as a way to test rules before implementing them in database form. For the text database map, columns for the key and value are measured as an index. That is, the first column is number 0. To illustrate , consider the following mini-configuration file that can be used to check spelling: Kspell text /usr/dict/words Spell R$- $: $(spell $: not in dictionary $) The /usr/dict/words file contains only a single column of words. This rule shows that the key is (by default) the first column (index 0). And the value is (by default) also the first column (index 0). For more sophisticated applications you can specify the key's column (with the -k switch), the value's column (with the -v switch), and the column delimiter (with the -z switch). To illustrate, consider the need to look up a user -id in the /etc/passwd file and to return the login name of the user to whom it belongs: Kgetuid text -k2 -v0 -z: /etc/passwd R$- $: $(getuid $) The lines of a password file look like this: ftp:*:1092:255:File Transfer Protocol Program:/u/ftp:/bin/sh The third column (where the columns are separated by colons) is the uid field. The first is the login name. Note that the -k and -v switches show these fields as indexes, where the first is 0 and the third is 2. Note that if a file cannot be opened because it is unsafe (DontBlameSendmail), the following warning will be logged and printed: text map " name ": unsafe map file filename This message will not be printed if the -o switch is specified with the database-map declaration. Only a handful of database switches are available with this text type. The are listed in Table 23-26. Table 23-26. The text database-map type K command switches
The -d38.20 debugging command-line switch (-d38.20) is available to watch this text type. |