Hello to everyone. I've been trying to write a small parser to parse Postfix lookup table calls for a piece of code I am developing.
I have taken a look at the source code and then resorted to postmap -q invocations to empirically test the descriptions at http://www.postfix.org/DATABASE_README.html . I am writing since testing out possible table values for the inline table has left me a bit stumped, since the results I get do no seem to match the description I read. Or, at least in a few cases, the description seems to mislead about what's actually accepted. Firstly, I haven't found around the Postfix documentation (and here I hope that somebody could point me in the right direction) how to use comma «,» characters in keys or values; I assume it's not allowed but I haven't located any document where that's stated clearly, except for a few peculiar places such as the definition for inline tables. The same goes for whitespace, for instance if one wanted to use a filename with ASCII spaces in it as a table name for, for example, pcre tables. But, as I mentioned at the beginning, the inline table is the one leaving me slightly confused. The definition for the inline table reads: « A non-shared, in-memory lookup table. Example: "inline:{ key=value, { key = text with whitespace or comma }}". Key-value pairs are separated by whitespace or comma; with a key-value pair inside "{}", whitespace is ignored after the opening "{", around the "=" between key and value, and before the closing "}". Inline tables eliminate the need to create a database file for just a few fixed elements. See also the static: map type » Below a few examples generated through postmap & tee & bash. -- # echo key | postmap -q - $'inline:{ key=value\, }' | tee >( cat --show-all ) key value\ key^Ivalue\$ So, commas and whitespace after the first «{» and before the last «}» are ignored, which wasn't specified in the description. -- # echo key\{ | postmap -q - $'inline:{ key{=value\, }' | tee >( cat --show-all ) postmap: fatal: bad syntax: "inline:{ key{=value\, }"; need "inline:{name=value...}" # echo key\} | postmap -q - $'inline:{ key}=value\, }' | tee >( cat --show-all ) postmap: fatal: bad syntax: "inline:{ key}=value\, }"; need "inline:{name=value...}" # echo key\} | postmap -q - $'inline:{ key}=value}\, }' | tee >( cat --show-all ) postmap: fatal: bad syntax: "inline:{ key}=value}\, }"; need "inline:{name=value...}" Ok, apparently no «{» or «}» characters in the key or value ? # echo a\{\{akey | postmap -q - $'inline:{ a{{akey ={}}} }' | tee >( cat --show-all ) a{{akey {}}} a{{akey^I{}}}$ No, apparently it's fine if the braces are balanced??? # echo a\{\{akey | postmap -q - $'inline:{ aakey ={}}}a }' | tee >( cat --show-all ) postmap: fatal: bad syntax: "inline:{ aakey ={}}}a }"; need "inline:{name=value...}" Ok that's consistent... # echo a\{\{akey | postmap -q - $'inline:{ a{{akey ={}}}a }' | tee >( cat --show-all ) a{{akey {}}}a a{{akey^I{}}}a$ But why is this working?? Just because there are balanced braces at some point in the key and/or value? I hope I haven't missed something obvious. A last question, somewhat unrelated, is about this line from postconf(5) «A logical line starts with non-whitespace text. A line that starts with whitespace continues a logical line.» Does that mean that two lines in main.cf such as 2bounce_notice_recipient = post master would be equivalent to 2bounce_notice_recipient = postmaster ignoring the whitespace after the soft line break? Thanks in advance for any answer or pointer. Regards, Fulvio Scapin