Lines Matching +defs:gpg +defs:err +defs:source +defs:as +defs:key
9 ;;; as published by the Free Software Foundation; either version 2.1 of
24 (in-package :gpg-error)
38 (defcenum gpg-err-source-t
39 "The GPG error source type."
40 (:gpg-err-source-unknown 0)
41 (:gpg-err-source-gcrypt 1)
42 (:gpg-err-source-gpg 2)
43 (:gpg-err-source-gpgsm 3)
44 (:gpg-err-source-gpgagent 4)
45 (:gpg-err-source-pinentry 5)
46 (:gpg-err-source-scd 6)
47 (:gpg-err-source-gpgme 7)
48 (:gpg-err-source-keybox 8)
49 (:gpg-err-source-ksba 9)
50 (:gpg-err-source-dirmngr 10)
51 (:gpg-err-source-gsti 11)
52 (:gpg-err-source-any 31)
53 (:gpg-err-source-user-1 32)
54 (:gpg-err-source-user-2 33)
55 (:gpg-err-source-user-3 34)
56 (:gpg-err-source-user-4 35))
58 (defconstant +gpg-err-source-dim+ 256)
60 ;;; The error code type gpg-err-code-t.
64 (defctype gpg-error-t :unsigned-int "The GPG error code type.")
68 (defconstant +gpg-err-code-mask+ (- +gpg-err-code-dim+ 1))
70 (defconstant +gpg-err-source-mask+ (- +gpg-err-source-dim+ 1))
71 (defconstant +gpg-err-source-shift+ 24)
78 (defun c-gpg-err-make (source code)
79 "Construct an error value from an error code and source.
80 Within a subsystem, use gpg-error instead."
82 (ash (logand source +gpg-err-source-mask+)
83 +gpg-err-source-shift+)
84 (logand code +gpg-err-code-mask+)))
86 (defun c-gpg-err-code (err)
88 (logand err +gpg-err-code-mask+))
90 (defun c-gpg-err-source (err)
91 "retrieve the error source from an error value."
92 (logand (ash err (- +gpg-err-source-shift+))
93 +gpg-err-source-mask+))
97 (defcfun ("gpg_strerror" c-gpg-strerror) :string
98 (err gpg-error-t))
100 (defcfun ("gpg_strsource" c-gpg-strsource) :string
101 (err gpg-error-t))
105 (defcfun ("gpg_err_code_from_errno" c-gpg-err-code-from-errno) gpg-err-code-t
106 (err :int))
108 (defcfun ("gpg_err_code_to_errno" c-gpg-err-code-to-errno) :int
109 (code gpg-err-code-t))
112 c-gpg-err-code-from-syserror) gpg-err-code-t)
126 (defun gpg-err-code-as-value (code-key)
127 (foreign-enum-value 'gpg-err-code-t code-key))
129 (defun gpg-err-code-as-key (code)
130 (foreign-enum-keyword 'gpg-err-code-t code))
132 (defun gpg-err-source-as-value (source-key)
133 (foreign-enum-value 'gpg-err-source-t source-key))
135 (defun gpg-err-source-as-key (source)
136 (foreign-enum-keyword 'gpg-err-source-t source))
138 (defun gpg-err-canonicalize (err)
139 "Canonicalize the error value err."
140 (gpg-err-make (gpg-err-source err) (gpg-err-code err)))
142 (defun gpg-err-as-value (err)
144 (let ((error (gpg-err-canonicalize err)))
145 (c-gpg-err-make (gpg-err-source-as-value (gpg-err-source error))
146 (gpg-err-code-as-value (gpg-err-code error)))))
150 (defun gpg-err-make (source code)
151 "Construct an error value from an error code and source.
152 Within a subsystem, use gpg-error instead."
153 ;; As an exception to the rule, the function gpg-err-make will use
154 ;; the error source value as is when provided as integer, instead of
155 ;; parsing it as an error value.
156 (list (if (integerp source)
157 (gpg-err-source-as-key source)
158 (gpg-err-source source))
159 (gpg-err-code code)))
161 (defvar *gpg-err-source-default* :gpg-err-source-unknown
162 "define this to specify a default source for gpg-error.")
164 (defun gpg-error (code)
165 "Construct an error value from an error code, using the default source."
166 (gpg-err-make *gpg-err-source-default* code))
168 (defun gpg-err-code (err)
170 (cond ((listp err) (second err))
171 ((keywordp err) err) ; FIXME
172 (t (gpg-err-code-as-key (c-gpg-err-code err)))))
174 (defun gpg-err-source (err)
175 "Retrieve an error source from the error value ERR."
176 (cond ((listp err) (first err))
177 ((keywordp err) err) ; FIXME
178 (t (gpg-err-source-as-key (c-gpg-err-source err)))))
182 (defun gpg-strerror (err)
184 (c-gpg-strerror (gpg-err-as-value err)))
186 ;;; FIXME: maybe we should use this as the actual implementation for
187 ;;; gpg-strerror.
189 ;; (defcfun ("gpg_strerror_r" c-gpg-strerror-r) :int
190 ;; (err gpg-error-t)
194 ;; (defun gpg-strerror-r (err)
196 ;; (with-foreign-pointer-as-string (errmsg 256 errmsg-size)
197 ;; (c-gpg-strerror-r (gpg-err-code-as-value (gpg-err-code err))
200 (defun gpg-strsource (err)
201 "Return a string containig a description of the error source."
202 (c-gpg-strsource (gpg-err-as-value err)))
206 (defun gpg-err-code-from-errno (err)
208 is not mapped, :gpg-err-unknown-errno is returned."
209 (gpg-err-code-as-key (c-gpg-err-code-from-errno err)))
211 (defun gpg-err-code-to-errno (code)
214 (c-gpg-err-code-to-errno (gpg-err-code code)))
216 (defun gpg-err-code-from-syserror ()
218 is not mapped, :gpg-err-unknown-errno is returned and
219 :gpg-err-missing-errno if ERRNO has the value 0."
220 (gpg-err-code-as-key (c-gpg-err-code-from-syserror)))
225 (defun gpg-err-make-from-errno (source err)
226 (gpg-err-make source (gpg-err-code-from-errno err)))
228 (defun gpg-error-from-errno (err)
229 (gpg-error (gpg-err-code-from-errno err)))
231 (defun gpg-error-from-syserror ()
232 (gpg-error (gpg-err-code-from-syserror)))