diff options
author | Clément Lassieur <clement@lassieur.org> | 2017-02-28 23:02:14 +0100 |
---|---|---|
committer | Clément Lassieur <clement@lassieur.org> | 2017-03-12 19:08:50 +0100 |
commit | 56aef188a2a014e254d3c93c8a79cd1fb5a1ece6 (patch) | |
tree | 9b77d331929910dca65d54adc5cbf5da23ab0e27 | |
parent | 334c95306a298803096a0077c892d69473ad0824 (diff) | |
download | guix-56aef188a2a014e254d3c93c8a79cd1fb5a1ece6.tar.gz guix-56aef188a2a014e254d3c93c8a79cd1fb5a1ece6.zip |
services: dovecot: Reimplement proper configuration functions.
* gnu/services/mail.scm (uglify-field-name, serialize-field, serialize-string)
(space-separated-string-list?, serialize-space-separated-string-list)
(file-name?, serialize-file-name, serialize-boolean): Add them.
These functions were inadvertently changed while being factorized in
gnu/service/configuration.scm.
Signed-off-by: Clément Lassieur <clement@lassieur.org>
-rw-r--r-- | gnu/services/mail.scm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm index dbc5de9e62..05978e0068 100644 --- a/gnu/services/mail.scm +++ b/gnu/services/mail.scm @@ -69,6 +69,27 @@ ;;; ;;; Code: +(define (uglify-field-name field-name) + (let ((str (symbol->string field-name))) + (string-join (string-split (if (string-suffix? "?" str) + (substring str 0 (1- (string-length str))) + str) + #\-) + "_"))) + +(define (serialize-field field-name val) + (format #t "~a=~a\n" (uglify-field-name field-name) val)) + +(define (serialize-string field-name val) + (serialize-field field-name val)) + +(define (space-separated-string-list? val) + (and (list? val) + (and-map (lambda (x) + (and (string? x) (not (string-index x #\space)))) + val))) +(define (serialize-space-separated-string-list field-name val) + (serialize-field field-name (string-join val " "))) (define (comma-separated-string-list? val) (and (list? val) @@ -78,6 +99,12 @@ (define (serialize-comma-separated-string-list field-name val) (serialize-field field-name (string-join val ","))) +(define (file-name? val) + (and (string? val) + (string-prefix? "/" val))) +(define (serialize-file-name field-name val) + (serialize-string field-name val)) + (define (colon-separated-file-name-list? val) (and (list? val) ;; Trailing slashes not needed and not @@ -85,6 +112,9 @@ (define (serialize-colon-separated-file-name-list field-name val) (serialize-field field-name (string-join val ":"))) +(define (serialize-boolean field-name val) + (serialize-string field-name (if val "yes" "no"))) + (define (non-negative-integer? val) (and (exact-integer? val) (not (negative? val)))) (define (serialize-non-negative-integer field-name val) |