Parses dovecot configuration files.
Author: Serge Smetana serge.@gmai l.com Acunote smetanahttp://www.acunote.com Pluron, Inc. http://pluron.com
Dovecot | Parses dovecot configuration files. |
License | This file is licensed under the LGPL v2+. |
Configuration files | This lens applies to /etc/dovecot/dovecot.conf and files in /etc/dovecot/conf.d/. |
Examples | The Test_Dovecot file contains various examples and tests. |
TODO | Support for multiline values like queries in dict-sql.conf |
USEFUL PRIMITIVES | |
indent | |
eol | |
empty | Map empty lines. |
comment | Map comments in “#comment” nodes. |
eq | |
any | |
value | Match any value after “ =”. |
command_start | |
ENTRIES | |
commands | |
block_names | |
keys | Match any possible key except commands and block names. |
entry | Map simple “key = value” entries including “key =” entries with empty value. |
command | Map commands started with “!” |
dquote_spaces | Make double quotes mandatory if value contains spaces, and optional if value doesn’t contain spaces. |
block | Map block enclosed in brackets recursively. |
LENS AND FILTER | |
lns | The Dovecot lens |
filter |
This lens applies to /etc/dovecot/dovecot.conf and files in /etc/dovecot/conf.d/. See filter.
The Test_Dovecot file contains various examples and tests.
let rec block = [ indent . key block_names . (Sep.space . Quote.do_dquote_opt (store /!?[\/A-Za-z0-9_-]+/))? . block_newlines (entry|block|mailbox) comment . eol ]
Map block enclosed in brackets recursively. Block may be indented and have optional argument. Block body may have entries, comments, empty lines, and nested blocks recursively.
let indent = Util.indent
let eol = Util.eol
Map empty lines.
let empty = Util.empty
Map comments in “#comment” nodes.
let comment = Util.comment
let eq = del /[ \t]*=/ " ="
let any = Rx.no_spaces
Match any value after “ =”.
let value = any . (Rx.space . any)*
let command_start = Util.del_str "!"
let commands = /include|include_try/
let block_names = /dict|userdb|passdb|protocol|service|plugin|namespace|map|fields|unix_listener|fifo_listener|inet_listener/
Match any possible key except commands and block names.
let keys = Rx.word - (commands | block_names)
Map simple “key = value” entries including “key =” entries with empty value.
let entry = [ indent . key keys. eq . (Sep.opt_space . store value)? . eol ]
Map commands started with “!”
let command = [ command_start . key commands . Sep.space . store Rx.fspath . eol ]
Make double quotes mandatory if value contains spaces, and optional if value doesn’t contain spaces.
let dquote_spaces (lns1:lens) (lns2:lens) =
Map block enclosed in brackets recursively.
let rec block = [ indent . key block_names . (Sep.space . Quote.do_dquote_opt (store /!?[\/A-Za-z0-9_-]+/))? . block_newlines (entry|block|mailbox) comment . eol ]
The Dovecot lens
let lns = (comment|empty|entry|command|block)*