23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
(declare (uses commonmod))
(declare (uses processmod))
(declare (uses mtargs))
(use regex regex-case)
(module configfmod
*
(import scheme
chicken
extras
files
matchable
ports
|
<
>
>
>
>
>
>
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
(declare (uses commonmod))
(declare (uses processmod))
(declare (uses mtargs))
(use regex regex-case)
(module configfmod
(
lookup
configf:lookup
get-section
configf:get-section
)
(import scheme
chicken
extras
files
matchable
ports
|
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
#f
(let ((match (assoc var sectdat)))
(if match ;; (and match (list? match)(> (length match) 1))
(cadr match)
#f))
))
#f))
;; use to have definitive setting:
;; [foo]
;; var yes
;;
;; (configf:var-is? cfgdat "foo" "var" "yes") => #t
;;
|
>
>
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
#f
(let ((match (assoc var sectdat)))
(if match ;; (and match (list? match)(> (length match) 1))
(cadr match)
#f))
))
#f))
(define lookup configf:lookup)
;; use to have definitive setting:
;; [foo]
;; var yes
;;
;; (configf:var-is? cfgdat "foo" "var" "yes") => #t
;;
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
(let ((sectdat (hash-table-ref/default cfgdat section '())))
(if (null? sectdat)
'()
(map car sectdat))))
(define (configf:get-section cfgdat section)
(hash-table-ref/default cfgdat section '()))
(define (configf:set-section-var cfgdat section var val)
(let ((sectdat (configf:get-section cfgdat section)))
(hash-table-set! cfgdat section
(configf:assoc-safe-add sectdat var val))))
;;======================================================================
|
>
>
|
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
(let ((sectdat (hash-table-ref/default cfgdat section '())))
(if (null? sectdat)
'()
(map car sectdat))))
(define (configf:get-section cfgdat section)
(hash-table-ref/default cfgdat section '()))
(define get-section configf:get-section)
(define (configf:set-section-var cfgdat section var val)
(let ((sectdat (configf:get-section cfgdat section)))
(hash-table-set! cfgdat section
(configf:assoc-safe-add sectdat var val))))
;;======================================================================
|