# 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

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 |

### 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:lens | the lens before
lns2:lens | the 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