summaryrefslogtreecommitdiff
path: root/gemini.cl
blob: 9460439af817cbfef79376eafd7e4b93cbe2e34d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(defun reverse-alist (alist)
  (loop for (a . b) in alist collect `(,b . ,a)))

(defvar +status-codes+
  '((10 . :input)
    (11 . :sensitive-input)
    (20 . :success)
    (30 . :redirect)
    (40 . :temporary-failure)
    (41 . :server-unavailable)
    (42 . :gci-error)
    (43 . :proxy-error)
    (44 . :slow-down)
    (50 . :permanent-failure)
    (51 . :not-found)
    (52 . :gone)
    (59 . :bad-request)
    (60 . :client-certificate-required)
    (61 . :certificate-not-authorised)
    (62 . :certificate-not-valid)))

(defun number->status (num)
  (cdr (assoc num +status-codes+)))

(defun status->number (key)
  (cdr (assoc key (reverse-alist +status-codes+))))