Dovecot

Parses dovecot configuration files.

Author: Serge Smetana serge..nosp@m.smetana@gmai.nosp@m.l.com Acunote http://www.acunote.com Pluron, Inc.  http://pluron.com

Summary
DovecotParses dovecot configuration files.
LicenseThis file is licensed under the LGPL v2+.
Configuration filesThis lens applies to /etc/dovecot/dovecot.conf and files in /etc/dovecot/conf.d/.
ExamplesThe Test_Dovecot file contains various examples and tests.
TODOSupport for multiline values like queries in dict-sql.conf
USEFUL PRIMITIVES
indent
eol
emptyMap empty lines.
commentMap comments in “#comment” nodes.
eq
any
valueMatch any value after “ =”.
command_start
ENTRIES
commands
block_names
keysMatch any possible key except commands and block names.
entryMap simple “key = value” entries including “key =” entries with empty value.
commandMap commands started with “!”
dquote_spacesMake double quotes mandatory if value contains spaces, and optional if value doesn’t contain spaces.
blockMap block enclosed in brackets recursively.
LENS AND FILTER
lnsThe Dovecot lens
filter

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/.  See filter.

Examples

The Test_Dovecot file contains various examples and tests.

TODO

Support for multiline values like queries in dict-sql.conf

USEFUL PRIMITIVES

indent

let indent = Util.indent

eol

let eol = Util.eol

empty

let empty = Util.empty

Map empty lines.

comment

let comment = Util.comment

Map comments in “#comment” nodes.

eq

let eq = del /[ \t]*=/ " ="

any

let any = Rx.no_spaces

value

let value = any . (Rx.space . any)*

Match any value after “ =”.  Should not start and end with spaces.  May contain spaces inside

command_start

let command_start = Util.del_str "!"

ENTRIES

commands

let commands = /include|include_try/

block_names

let block_names = /dict|userdb|passdb|protocol|service|plugin|namespace|map|fields|unix_listener|fifo_listener|inet_listener/

keys

let keys = Rx.word - (commands | block_names)

Match any possible key except commands and block names.

entry

let entry = [ indent . key keys. eq . (Sep.opt_space . store value)? . eol ]

Map simple “key = value” entries including “key =” entries with empty value.

command

let command = [ command_start . key commands . Sep.space . store Rx.fspath . eol ]

Map commands started with “!”.

dquote_spaces

let dquote_spaces (lns1:lens) (lns2:lens) =

Make double quotes mandatory if value contains spaces, and optional if value doesn’t contain spaces.

Based off Quote.dquote_spaces

Parameters

lns1:lensthe lens before
lns2:lensthe lens after

block

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.

LENS AND FILTER

lns

let lns = (comment|empty|entry|command|block)*

The Dovecot lens

filter

Provides unit tests and examples for the Dovecot lens.
let indent = Util.indent
let eol = Util.eol
let empty = Util.empty
Map empty lines.
let comment = Util.comment
Map comments in “#comment” nodes.
let eq = del /[ \t]*=/ " ="
let any = Rx.no_spaces
let value = any . (Rx.space . any)*
Match any value after “ =”.
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/
let keys = Rx.word - (commands | block_names)
Match any possible key except commands and block names.
let entry = [ indent . key keys. eq . (Sep.opt_space . store value)? . eol ]
Map simple “key = value” entries including “key =” entries with empty value.
let command = [ command_start . key commands . Sep.space . store Rx.fspath . eol ]
Map commands started with “!”
let dquote_spaces (lns1:lens) (lns2:lens) =
Make double quotes mandatory if value contains spaces, and optional if value doesn’t contain spaces.
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.
let lns = (comment|empty|entry|command|block)*
The Dovecot lens
Close