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>
This commit is contained in:
parent
334c95306a
commit
56aef188a2
|
@ -69,6 +69,27 @@
|
||||||
;;;
|
;;;
|
||||||
;;; Code:
|
;;; 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)
|
(define (comma-separated-string-list? val)
|
||||||
(and (list? val)
|
(and (list? val)
|
||||||
|
@ -78,6 +99,12 @@
|
||||||
(define (serialize-comma-separated-string-list field-name val)
|
(define (serialize-comma-separated-string-list field-name val)
|
||||||
(serialize-field field-name (string-join 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)
|
(define (colon-separated-file-name-list? val)
|
||||||
(and (list? val)
|
(and (list? val)
|
||||||
;; Trailing slashes not needed and not
|
;; Trailing slashes not needed and not
|
||||||
|
@ -85,6 +112,9 @@
|
||||||
(define (serialize-colon-separated-file-name-list field-name val)
|
(define (serialize-colon-separated-file-name-list field-name val)
|
||||||
(serialize-field field-name (string-join 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)
|
(define (non-negative-integer? val)
|
||||||
(and (exact-integer? val) (not (negative? val))))
|
(and (exact-integer? val) (not (negative? val))))
|
||||||
(define (serialize-non-negative-integer field-name val)
|
(define (serialize-non-negative-integer field-name val)
|
||||||
|
|
Loading…
Reference in New Issue