Cleanup and bugfixes(...).
[doldaconnect.git] / lib / guile / dolcon / util.scm
CommitLineData
d3372da9 1(define-module (dolcon util))
2(use-modules (dolcon ui))
3
4(define fnetnodes '())
5
6(define-public dc-fn-update
7 (lambda ()
8 (set! fnetnodes
9 (let ((resp (dc-ecmd "lsnodes")) (er #f))
10 (if (and resp (begin (set! er (dc-extract resp)) er) (= (cdr (assq 'code er)) 200))
11 (map (lambda (o)
12 (apply (lambda (id net name users state)
13 (cons id
14 (list (cons 'id id)
15 (cons 'net net)
16 (cons 'name name)
17 (cons 'users users)
18 (cons 'state (list-ref '(syn hs est dead) state)))))
19 o))
20 (dc-intall resp))
21 '())))
22 fnetnodes))
23
24(define-public dc-fn-getattrib
25 (lambda (id attrib)
26 (if (not (assq id fnetnodes))
27 (dc-fn-update))
28 (let ((aform (assq id fnetnodes)))
29 (if aform
30 (cdr (assq attrib (cdr aform)))
31 #f))))
32
33(define-public dc-fn-getname
34 (lambda (id)
35 (dc-fn-getattrib id 'name)))
36
37(define-public dc-getfnetnodes
38 (lambda ()
39 (map (lambda (o) (car o))
40 fnetnodes)))