summary refs log tree commit diff
path: root/gnu/services/cups.scm
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2017-03-13 23:08:49 +0200
committerEfraim Flashner <efraim@flashner.co.il>2017-03-13 23:08:49 +0200
commit3f9543aee1e49001d0f80542dd71ba73c44787c7 (patch)
tree50ee1bdd53b1e5ec69cb8655f23da79c332dde1e /gnu/services/cups.scm
parent864a9590ad948df09f2ad6e9e929608a7587a5f7 (diff)
parenta71c863834448e2645518b31b60a96ef488dd761 (diff)
downloadguix-3f9543aee1e49001d0f80542dd71ba73c44787c7.tar.gz
Merge remote-tracking branch 'origin/master' into core-updates
Diffstat (limited to 'gnu/services/cups.scm')
-rw-r--r--gnu/services/cups.scm32
1 files changed, 32 insertions, 0 deletions
diff --git a/gnu/services/cups.scm b/gnu/services/cups.scm
index 70b858479a..70a71eff0a 100644
--- a/gnu/services/cups.scm
+++ b/gnu/services/cups.scm
@@ -57,6 +57,21 @@
          (home-directory "/var/empty")
          (shell (file-append shadow "/sbin/nologin")))))
 
+(define (uglify-field-name field-name)
+  (let ((str (symbol->string field-name)))
+    (string-concatenate
+     (map string-titlecase
+          (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 (multiline-string-list? val)
   (and (list? val)
        (and-map (lambda (x)
@@ -65,11 +80,28 @@
 (define (serialize-multiline-string-list field-name val)
   (for-each (lambda (str) (serialize-field field-name str)) 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 (space-separated-symbol-list? val)
   (and (list? val) (and-map symbol? val)))
 (define (serialize-space-separated-symbol-list field-name val)
   (serialize-field field-name (string-join (map symbol->string val) " ")))
 
+(define (file-name? val)
+  (and (string? val)
+       (string-prefix? "/" val)))
+(define (serialize-file-name field-name val)
+  (serialize-string field-name 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)