5 (use-modules (dolcon ui))
6 (use-modules (ice-9 popen))
7 (use-modules (ice-9 pretty-print))
14 (define (filtered tag filter)
16 (or (equal? (car filter) (substring tag 0 (min (string-length (car filter)) (string-length tag))))
17 (filtered tag (cdr filter)))))
20 (let ((port (open-input-file (string-append (getenv "HOME") "/.dctrmon-defines"))) (form #f))
21 (while (begin (set! form (read port)) (not (eof-object? form)))
22 (primitive-eval form))))
27 (define krbcc (string-append "/tmp/krb5cc_dcmon_" (number->string (getuid)) "_XXXXXX"))
28 (close-port (mkstemp! krbcc))
29 (setenv "KRB5CCNAME" (string-append "FILE:" krbcc))
30 (sigaction SIGCHLD SIG_DFL)
31 (define pid (primitive-fork))
33 (begin (execlp "kinit" "kinit" "-f" "-r" "10d" "-k" "-t" (string-append (getenv "HOME") "/.myprinc.keytab") (string-append (passwd:name (getpwuid (getuid))) "/dcview"))
35 (if (not (= (cdr (waitpid pid)) 0))
37 (dc-c&l #f (getenv "DCSERVER") #t)
40 (dc-ecmd-assert 200 "notify" "all" "on")
44 (let ((resp (dc-ecmd-assert '(200 201) "lstrans")))
45 (if (and resp (= (cdr (assoc 'code (dc-extract resp))) 200))
51 (if (and (equal? (car a) "tag") (filtered (cadr a) filter))
53 (display (string-append "N\t" (cadr a) "\t" (number->string (list-ref o 6)) "\t" (number->string (list-ref o 7)) "\n"))
54 (set! idlist (append idlist (list (cons (car o) (cadr a))))))))
55 (dc-intall (dc-ecmd-assert 200 "lstrarg" (car o)))))
59 (flush (current-output-port))
63 (while (let ((resp (dc-getresp)))
66 (let* ((er (dc-extract resp)) (code (cdr (assoc 'code er))) (cmd (cdr (assoc 'cmd er))) (ir (dc-intresp resp)))
67 (if (equal? cmd ".notify")
70 (let* ((id (car ir)) (ir2 (dc-intall (dc-ecmd-assert '(200 201) "lstrarg" id))) (tag (if (eq? (car ir2) '()) #f (assoc "tag" ir2))))
71 (if (and tag (filtered (cadr tag) filter))
72 (begin (display (string-append "N\t" (cadr tag) "\t-1\t-1\n"))
73 (flush (current-output-port))
74 (set! idlist (append idlist (list (cons (car ir) (cadr tag)))))))))
78 (begin (display (string-append "S\t" (cdr (assoc id idlist)) "\t" (number->string (cadr ir)) "\n"))
79 (flush (current-output-port))))))
83 (begin (display (string-append "P\t" (cdr (assoc id idlist)) "\t" (number->string (cadr ir)) "\n"))
84 (flush (current-output-port))))))
88 (begin (display (string-append "D\t" (cdr (assoc id idlist)) "\n"))
89 (flush (current-output-port)))))))))