1 (define-module (dolcon ui))
3 (export dc-connect dc-disconnect dc-connected dc-select dc-getresp dc-extract dc-intresp dc-qcmd dc-loginasync dc-lexsexpr)
5 (load-extension "libdolcon-guile" "init_guiledc")
7 (define-public dc-login
8 (lambda (useauthless . username)
9 (let ((done #f) (errsym #f))
14 useauthless (if (pair? username) (car username) #f))
15 (while (not done) (dc-select))
18 (define-public dc-must-connect
20 (let* ((fd (apply dc-connect args)) (resp (dc-extract (do ((resp (dc-getresp) (dc-getresp)))
22 (equal? (cdr (assoc 'cmd (dc-extract resp))) ".connect"))
25 (if (= (cdr (assoc 'code resp)) 200)
27 (throw 'bad-return (cdr (assoc 'code resp)) (cadr (assoc 'resp resp)))
34 (lambda (verbose host useauthless)
35 (let ((fd -1) (print (lambda (obj) (if verbose (display obj (if (port? verbose) verbose (current-error-port)))))))
36 (print "connecting...\n")
37 (set! fd (dc-must-connect host))
38 (print "authenticating...\n")
39 (let ((ret (dc-login useauthless)))
40 (if (not (eq? ret 'success))
41 (throw 'login-failure ret)))
42 (print "authentication success\n")
47 (define-public dc-ecmd
49 (let ((tag (dc-qcmd args)))
51 (do ((resp (dc-getresp tag) (dc-getresp tag)))
58 (define-public dc-ecmd-assert
60 (let* ((resp (apply dc-ecmd args)) (eresp (dc-extract resp)))
61 (if (not (if (list? code)
62 (memq (cdr (assoc 'code eresp)) code)
63 (= (cdr (assoc 'code eresp)) code)))
64 (throw 'bad-return (cdr (assoc 'code eresp)) (cadr (assoc 'resp eresp)))
71 (define-public dc-intall
74 (do ((ires (dc-intresp resp) (dc-intresp resp))) ((not ires) retlist)
75 (set! retlist (append retlist (list ires)))))))