1 /*******************************************************************************
2 
3     D bindings to GPG error functions, used by libgcrypt.
4 
5     These are actually in the separate libgpg-error library, but libgcrypt is
6     linked with it.
7 
8     Requires linking with libgcrypt:
9 
10         -L-lgcrypt
11 
12     Copyright:
13         Copyright (c) 2009-2016 dunnhumby Germany GmbH.
14         All rights reserved.
15 
16     License:
17         Boost Software License Version 1.0. See LICENSE_BOOST.txt for details.
18         Alternatively, this file may be distributed under the terms of the Tango
19         3-Clause BSD License (see LICENSE_BSD.txt for details).
20 
21         Bear in mind this module provides bindings to an external library that
22         has its own license, which might be more restrictive. Please check the
23         external library license to see which conditions apply for linking.
24 
25 *******************************************************************************/
26 
27 module ocean.util.cipher.gcrypt.c.gpgerror;
28 
29 import ocean.core.Verify;
30 public import ocean.util.cipher.gcrypt.c.libversion;
31 import core.stdc.string;
32 
33 shared static this ( ) { gpg_err_init(); }
34 
35 extern (C):
36 
37 /// See original's library documentation for details.
38 static immutable GPG_ERROR_VERSION_NUMBER = 0x011500;
39 static immutable GPGRT_VERSION_NUMBER =     0x011500;
40 
41 /// See original's library documentation for details.
42 alias uint gpg_error_t;
43 
44 
45 /// See original's library documentation for details.
46 enum GPG_ERR_SOURCE
47 {
48     UNKNOWN = 0,
49     GCRYPT = 1,
50     GPG = 2,
51     GPGSM = 3,
52     GPGAGENT = 4,
53     PINENTRY = 5,
54     SCD = 6,
55     GPGME = 7,
56     KEYBOX = 8,
57     KSBA = 9,
58     DIRMNGR = 10,
59     GSTI = 11,
60     GPA = 12,
61     KLEO = 13,
62     G13 = 14,
63     ASSUAN = 15,
64     TLS = 17,
65     ANY = 31,
66     USER_1 = 32,
67     USER_2 = 33,
68     USER_3 = 34,
69     USER_4 = 35,
70 
71     MASK = (1 << 7) - 1
72 }
73 
74 /// See original's library documentation for details.
75 static immutable GPG_ERR_SOURCE_DIM = GPG_ERR_SOURCE.max + 1;
76 
77 
78 /// See original's library documentation for details.
79 enum GPG_ERR_CODE
80 {
81     NO_ERROR = 0,
82     GENERAL = 1,
83     UNKNOWN_PACKET = 2,
84     UNKNOWN_VERSION = 3,
85     PUBKEY_ALGO = 4,
86     DIGEST_ALGO = 5,
87     BAD_PUBKEY = 6,
88     BAD_SECKEY = 7,
89     BAD_SIGNATURE = 8,
90     NO_PUBKEY = 9,
91     CHECKSUM = 10,
92     BAD_PASSPHRASE = 11,
93     CIPHER_ALGO = 12,
94     KEYRING_OPEN = 13,
95     INV_PACKET = 14,
96     INV_ARMOR = 15,
97     NO_USER_ID = 16,
98     NO_SECKEY = 17,
99     WRONG_SECKEY = 18,
100     BAD_KEY = 19,
101     COMPR_ALGO = 20,
102     NO_PRIME = 21,
103     NO_ENCODING_METHOD = 22,
104     NO_ENCRYPTION_SCHEME = 23,
105     NO_SIGNATURE_SCHEME = 24,
106     INV_ATTR = 25,
107     NO_VALUE = 26,
108     NOT_FOUND = 27,
109     VALUE_NOT_FOUND = 28,
110     SYNTAX = 29,
111     BAD_MPI = 30,
112     INV_PASSPHRASE = 31,
113     SIG_CLASS = 32,
114     RESOURCE_LIMIT = 33,
115     INV_KEYRING = 34,
116     TRUSTDB = 35,
117     BAD_CERT = 36,
118     INV_USER_ID = 37,
119     UNEXPECTED = 38,
120     TIME_CONFLICT = 39,
121     KEYSERVER = 40,
122     WRONG_PUBKEY_ALGO = 41,
123     TRIBUTE_TO_D_A = 42,
124     WEAK_KEY = 43,
125     INV_KEYLEN = 44,
126     INV_ARG = 45,
127     BAD_URI = 46,
128     INV_URI = 47,
129     NETWORK = 48,
130     UNKNOWN_HOST = 49,
131     SELFTEST_FAILED = 50,
132     NOT_ENCRYPTED = 51,
133     NOT_PROCESSED = 52,
134     UNUSABLE_PUBKEY = 53,
135     UNUSABLE_SECKEY = 54,
136     INV_VALUE = 55,
137     BAD_CERT_CHAIN = 56,
138     MISSING_CERT = 57,
139     NO_DATA = 58,
140     BUG = 59,
141     NOT_SUPPORTED = 60,
142     INV_OP = 61,
143     TIMEOUT = 62,
144     INTERNAL = 63,
145     EOF_GCRYPT = 64,
146     INV_OBJ = 65,
147     TOO_SHORT = 66,
148     TOO_LARGE = 67,
149     NO_OBJ = 68,
150     NOT_IMPLEMENTED = 69,
151     CONFLICT = 70,
152     INV_CIPHER_MODE = 71,
153     INV_FLAG = 72,
154     INV_HANDLE = 73,
155     TRUNCATED = 74,
156     INCOMPLETE_LINE = 75,
157     INV_RESPONSE = 76,
158     NO_AGENT = 77,
159     AGENT = 78,
160     INV_DATA = 79,
161     ASSUAN_SERVER_FAULT = 80,
162     ASSUAN = 81,
163     INV_SESSION_KEY = 82,
164     INV_SEXP = 83,
165     UNSUPPORTED_ALGORITHM = 84,
166     NO_PIN_ENTRY = 85,
167     PIN_ENTRY = 86,
168     BAD_PIN = 87,
169     INV_NAME = 88,
170     BAD_DATA = 89,
171     INV_PARAMETER = 90,
172     WRONG_CARD = 91,
173     NO_DIRMNGR = 92,
174     DIRMNGR = 93,
175     CERT_REVOKED = 94,
176     NO_CRL_KNOWN = 95,
177     CRL_TOO_OLD = 96,
178     LINE_TOO_LONG = 97,
179     NOT_TRUSTED = 98,
180     CANCELED = 99,
181     BAD_CA_CERT = 100,
182     CERT_EXPIRED = 101,
183     CERT_TOO_YOUNG = 102,
184     UNSUPPORTED_CERT = 103,
185     UNKNOWN_SEXP = 104,
186     UNSUPPORTED_PROTECTION = 105,
187     CORRUPTED_PROTECTION = 106,
188     AMBIGUOUS_NAME = 107,
189     CARD = 108,
190     CARD_RESET = 109,
191     CARD_REMOVED = 110,
192     INV_CARD = 111,
193     CARD_NOT_PRESENT = 112,
194     NO_PKCS15_APP = 113,
195     NOT_CONFIRMED = 114,
196     CONFIGURATION = 115,
197     NO_POLICY_MATCH = 116,
198     INV_INDEX = 117,
199     INV_ID = 118,
200     NO_SCDAEMON = 119,
201     SCDAEMON = 120,
202     UNSUPPORTED_PROTOCOL = 121,
203     BAD_PIN_METHOD = 122,
204     CARD_NOT_INITIALIZED = 123,
205     UNSUPPORTED_OPERATION = 124,
206     WRONG_KEY_USAGE = 125,
207     NOTHING_FOUND = 126,
208     WRONG_BLOB_TYPE = 127,
209     MISSING_VALUE = 128,
210     HARDWARE = 129,
211     PIN_BLOCKED = 130,
212     USE_CONDITIONS = 131,
213     PIN_NOT_SYNCED = 132,
214     INV_CRL = 133,
215     BAD_BER = 134,
216     INV_BER = 135,
217     ELEMENT_NOT_FOUND = 136,
218     IDENTIFIER_NOT_FOUND = 137,
219     INV_TAG = 138,
220     INV_LENGTH = 139,
221     INV_KEYINFO = 140,
222     UNEXPECTED_TAG = 141,
223     NOT_DER_ENCODED = 142,
224     NO_CMS_OBJ = 143,
225     INV_CMS_OBJ = 144,
226     UNKNOWN_CMS_OBJ = 145,
227     UNSUPPORTED_CMS_OBJ = 146,
228     UNSUPPORTED_ENCODING = 147,
229     UNSUPPORTED_CMS_VERSION = 148,
230     UNKNOWN_ALGORITHM = 149,
231     INV_ENGINE = 150,
232     PUBKEY_NOT_TRUSTED = 151,
233     DECRYPT_FAILED = 152,
234     KEY_EXPIRED = 153,
235     SIG_EXPIRED = 154,
236     ENCODING_PROBLEM = 155,
237     INV_STATE = 156,
238     DUP_VALUE = 157,
239     MISSING_ACTION = 158,
240     MODULE_NOT_FOUND = 159,
241     INV_OID_STRING = 160,
242     INV_TIME = 161,
243     INV_CRL_OBJ = 162,
244     UNSUPPORTED_CRL_VERSION = 163,
245     INV_CERT_OBJ = 164,
246     UNKNOWN_NAME = 165,
247     LOCALE_PROBLEM = 166,
248     NOT_LOCKED = 167,
249     PROTOCOL_VIOLATION = 168,
250     INV_MAC = 169,
251     INV_REQUEST = 170,
252     UNKNOWN_EXTN = 171,
253     UNKNOWN_CRIT_EXTN = 172,
254     LOCKED = 173,
255     UNKNOWN_OPTION = 174,
256     UNKNOWN_COMMAND = 175,
257     NOT_OPERATIONAL = 176,
258     NO_PASSPHRASE = 177,
259     NO_PIN = 178,
260     NOT_ENABLED = 179,
261     NO_ENGINE = 180,
262     MISSING_KEY = 181,
263     TOO_MANY = 182,
264     LIMIT_REACHED = 183,
265     NOT_INITIALIZED = 184,
266     MISSING_ISSUER_CERT = 185,
267     NO_KEYSERVER = 186,
268     INV_CURVE = 187,
269     UNKNOWN_CURVE = 188,
270     DUP_KEY = 189,
271     AMBIGUOUS = 190,
272     NO_CRYPT_CTX = 191,
273     WRONG_CRYPT_CTX = 192,
274     BAD_CRYPT_CTX = 193,
275     CRYPT_CTX_CONFLICT = 194,
276     BROKEN_PUBKEY = 195,
277     BROKEN_SECKEY = 196,
278     MAC_ALGO = 197,
279     FULLY_CANCELED = 198,
280     UNFINISHED = 199,
281     BUFFER_TOO_SHORT = 200,
282     SEXP_INV_LEN_SPEC = 201,
283     SEXP_STRING_TOO_LONG = 202,
284     SEXP_UNMATCHED_PAREN = 203,
285     SEXP_NOT_CANONICAL = 204,
286     SEXP_BAD_CHARACTER = 205,
287     SEXP_BAD_QUOTATION = 206,
288     SEXP_ZERO_PREFIX = 207,
289     SEXP_NESTED_DH = 208,
290     SEXP_UNMATCHED_DH = 209,
291     SEXP_UNEXPECTED_PUNC = 210,
292     SEXP_BAD_HEX_CHAR = 211,
293     SEXP_ODD_HEX_NUMBERS = 212,
294     SEXP_BAD_OCT_CHAR = 213,
295     SERVER_FAILED = 219,
296     NO_NAME = 220,
297     NO_KEY = 221,
298     LEGACY_KEY = 222,
299     REQUEST_TOO_SHORT = 223,
300     REQUEST_TOO_LONG = 224,
301     OBJ_TERM_STATE = 225,
302     NO_CERT_CHAIN = 226,
303     CERT_TOO_LARGE = 227,
304     INV_RECORD = 228,
305     BAD_MAC = 229,
306     UNEXPECTED_MSG = 230,
307     COMPR_FAILED = 231,
308     WOULD_WRAP = 232,
309     FATAL_ALERT = 233,
310     NO_CIPHER = 234,
311     MISSING_CLIENT_CERT = 235,
312     CLOSE_NOTIFY = 236,
313     TICKET_EXPIRED = 237,
314     BAD_TICKET = 238,
315     UNKNOWN_IDENTITY = 239,
316     BAD_HS_CERT = 240,
317     BAD_HS_CERT_REQ = 241,
318     BAD_HS_CERT_VER = 242,
319     BAD_HS_CHANGE_CIPHER = 243,
320     BAD_HS_CLIENT_HELLO = 244,
321     BAD_HS_SERVER_HELLO = 245,
322     BAD_HS_SERVER_HELLO_DONE = 246,
323     BAD_HS_FINISHED = 247,
324     BAD_HS_SERVER_KEX = 248,
325     BAD_HS_CLIENT_KEX = 249,
326     BOGUS_STRING = 250,
327     FORBIDDEN = 251,
328     KEY_DISABLED = 252,
329     KEY_ON_CARD = 253,
330     INV_LOCK_OBJ = 254,
331     TRUE = 255,
332     FALSE = 256,
333     ASS_GENERAL = 257,
334     ASS_ACCEPT_FAILED = 258,
335     ASS_CONNECT_FAILED = 259,
336     ASS_INV_RESPONSE = 260,
337     ASS_INV_VALUE = 261,
338     ASS_INCOMPLETE_LINE = 262,
339     ASS_LINE_TOO_LONG = 263,
340     ASS_NESTED_COMMANDS = 264,
341     ASS_NO_DATA_CB = 265,
342     ASS_NO_INQUIRE_CB = 266,
343     ASS_NOT_A_SERVER = 267,
344     ASS_NOT_A_CLIENT = 268,
345     ASS_SERVER_START = 269,
346     ASS_READ_ERROR = 270,
347     ASS_WRITE_ERROR = 271,
348     ASS_TOO_MUCH_DATA = 273,
349     ASS_UNEXPECTED_CMD = 274,
350     ASS_UNKNOWN_CMD = 275,
351     ASS_SYNTAX = 276,
352     ASS_CANCELED = 277,
353     ASS_NO_INPUT = 278,
354     ASS_NO_OUTPUT = 279,
355     ASS_PARAMETER = 280,
356     ASS_UNKNOWN_INQUIRE = 281,
357     LDAP_GENERAL = 721,
358     LDAP_ATTR_GENERAL = 722,
359     LDAP_NAME_GENERAL = 723,
360     LDAP_SECURITY_GENERAL = 724,
361     LDAP_SERVICE_GENERAL = 725,
362     LDAP_UPDATE_GENERAL = 726,
363     LDAP_E_GENERAL = 727,
364     LDAP_X_GENERAL = 728,
365     LDAP_OTHER_GENERAL = 729,
366     LDAP_X_CONNECTING = 750,
367     LDAP_REFERRAL_LIMIT = 751,
368     LDAP_CLIENT_LOOP = 752,
369     LDAP_NO_RESULTS = 754,
370     LDAP_CONTROL_NOT_FOUND = 755,
371     LDAP_NOT_SUPPORTED = 756,
372     LDAP_CONNECT = 757,
373     LDAP_NO_MEMORY = 758,
374     LDAP_PARAM = 759,
375     LDAP_USER_CANCELLED = 760,
376     LDAP_FILTER = 761,
377     LDAP_AUTH_UNKNOWN = 762,
378     LDAP_TIMEOUT = 763,
379     LDAP_DECODING = 764,
380     LDAP_ENCODING = 765,
381     LDAP_LOCAL = 766,
382     LDAP_SERVER_DOWN = 767,
383     LDAP_SUCCESS = 768,
384     LDAP_OPERATIONS = 769,
385     LDAP_PROTOCOL = 770,
386     LDAP_TIMELIMIT = 771,
387     LDAP_SIZELIMIT = 772,
388     LDAP_COMPARE_FALSE = 773,
389     LDAP_COMPARE_TRUE = 774,
390     LDAP_UNSUPPORTED_AUTH = 775,
391     LDAP_STRONG_AUTH_RQRD = 776,
392     LDAP_PARTIAL_RESULTS = 777,
393     LDAP_REFERRAL = 778,
394     LDAP_ADMINLIMIT = 779,
395     LDAP_UNAVAIL_CRIT_EXTN = 780,
396     LDAP_CONFIDENT_RQRD = 781,
397     LDAP_SASL_BIND_INPROG = 782,
398     LDAP_NO_SUCH_ATTRIBUTE = 784,
399     LDAP_UNDEFINED_TYPE = 785,
400     LDAP_BAD_MATCHING = 786,
401     LDAP_CONST_VIOLATION = 787,
402     LDAP_TYPE_VALUE_EXISTS = 788,
403     LDAP_INV_SYNTAX = 789,
404     LDAP_NO_SUCH_OBJ = 800,
405     LDAP_ALIAS_PROBLEM = 801,
406     LDAP_INV_DN_SYNTAX = 802,
407     LDAP_IS_LEAF = 803,
408     LDAP_ALIAS_DEREF = 804,
409     LDAP_X_PROXY_AUTH_FAIL = 815,
410     LDAP_BAD_AUTH = 816,
411     LDAP_INV_CREDENTIALS = 817,
412     LDAP_INSUFFICIENT_ACC = 818,
413     LDAP_BUSY = 819,
414     LDAP_UNAVAILABLE = 820,
415     LDAP_UNWILL_TO_PERFORM = 821,
416     LDAP_LOOP_DETECT = 822,
417     LDAP_NAMING_VIOLATION = 832,
418     LDAP_OBJ_CLS_VIOLATION = 833,
419     LDAP_NOT_ALLOW_NONLEAF = 834,
420     LDAP_NOT_ALLOW_ON_RDN = 835,
421     LDAP_ALREADY_EXISTS = 836,
422     LDAP_NO_OBJ_CLASS_MODS = 837,
423     LDAP_RESULTS_TOO_LARGE = 838,
424     LDAP_AFFECTS_MULT_DSAS = 839,
425     LDAP_VLV = 844,
426     LDAP_OTHER = 848,
427     LDAP_CUP_RESOURCE_LIMIT = 881,
428     LDAP_CUP_SEC_VIOLATION = 882,
429     LDAP_CUP_INV_DATA = 883,
430     LDAP_CUP_UNSUP_SCHEME = 884,
431     LDAP_CUP_RELOAD = 885,
432     LDAP_CANCELLED = 886,
433     LDAP_NO_SUCH_OPERATION = 887,
434     LDAP_TOO_LATE = 888,
435     LDAP_CANNOT_CANCEL = 889,
436     LDAP_ASSERTION_FAILED = 890,
437     LDAP_PROX_AUTH_DENIED = 891,
438     USER_1 = (1 << 10),
439     USER_2,
440     USER_3,
441     USER_4,
442     USER_5,
443     USER_6,
444     USER_7,
445     USER_8,
446     USER_9,
447     USER_10,
448     USER_11,
449     USER_12,
450     USER_13,
451     USER_14,
452     USER_15,
453     USER_16,
454     MISSING_ERRNO = (1 << 14) - 3,
455     UNKNOWN_ERRNO = (1 << 14) - 2,
456     EOF = (1 << 14) - 1,
457 
458     SYSTEM_ERROR = (1 << 15),
459     E2BIG = SYSTEM_ERROR | 0,
460     EACCES = SYSTEM_ERROR | 1,
461     EADDRINUSE = SYSTEM_ERROR | 2,
462     EADDRNOTAVAIL = SYSTEM_ERROR | 3,
463     EADV = SYSTEM_ERROR | 4,
464     EAFNOSUPPORT = SYSTEM_ERROR | 5,
465     EAGAIN = SYSTEM_ERROR | 6,
466     EALREADY = SYSTEM_ERROR | 7,
467     EAUTH = SYSTEM_ERROR | 8,
468     EBACKGROUND = SYSTEM_ERROR | 9,
469     EBADE = SYSTEM_ERROR | 10,
470     EBADF = SYSTEM_ERROR | 11,
471     EBADFD = SYSTEM_ERROR | 12,
472     EBADMSG = SYSTEM_ERROR | 13,
473     EBADR = SYSTEM_ERROR | 14,
474     EBADRPC = SYSTEM_ERROR | 15,
475     EBADRQC = SYSTEM_ERROR | 16,
476     EBADSLT = SYSTEM_ERROR | 17,
477     EBFONT = SYSTEM_ERROR | 18,
478     EBUSY = SYSTEM_ERROR | 19,
479     ECANCELED = SYSTEM_ERROR | 20,
480     ECHILD = SYSTEM_ERROR | 21,
481     ECHRNG = SYSTEM_ERROR | 22,
482     ECOMM = SYSTEM_ERROR | 23,
483     ECONNABORTED = SYSTEM_ERROR | 24,
484     ECONNREFUSED = SYSTEM_ERROR | 25,
485     ECONNRESET = SYSTEM_ERROR | 26,
486     ED = SYSTEM_ERROR | 27,
487     EDEADLK = SYSTEM_ERROR | 28,
488     EDEADLOCK = SYSTEM_ERROR | 29,
489     EDESTADDRREQ = SYSTEM_ERROR | 30,
490     EDIED = SYSTEM_ERROR | 31,
491     EDOM = SYSTEM_ERROR | 32,
492     EDOTDOT = SYSTEM_ERROR | 33,
493     EDQUOT = SYSTEM_ERROR | 34,
494     EEXIST = SYSTEM_ERROR | 35,
495     EFAULT = SYSTEM_ERROR | 36,
496     EFBIG = SYSTEM_ERROR | 37,
497     EFTYPE = SYSTEM_ERROR | 38,
498     EGRATUITOUS = SYSTEM_ERROR | 39,
499     EGREGIOUS = SYSTEM_ERROR | 40,
500     EHOSTDOWN = SYSTEM_ERROR | 41,
501     EHOSTUNREACH = SYSTEM_ERROR | 42,
502     EIDRM = SYSTEM_ERROR | 43,
503     EIEIO = SYSTEM_ERROR | 44,
504     EILSEQ = SYSTEM_ERROR | 45,
505     EINPROGRESS = SYSTEM_ERROR | 46,
506     EINTR = SYSTEM_ERROR | 47,
507     EINVAL = SYSTEM_ERROR | 48,
508     EIO = SYSTEM_ERROR | 49,
509     EISCONN = SYSTEM_ERROR | 50,
510     EISDIR = SYSTEM_ERROR | 51,
511     EISNAM = SYSTEM_ERROR | 52,
512     EL2HLT = SYSTEM_ERROR | 53,
513     EL2NSYNC = SYSTEM_ERROR | 54,
514     EL3HLT = SYSTEM_ERROR | 55,
515     EL3RST = SYSTEM_ERROR | 56,
516     ELIBACC = SYSTEM_ERROR | 57,
517     ELIBBAD = SYSTEM_ERROR | 58,
518     ELIBEXEC = SYSTEM_ERROR | 59,
519     ELIBMAX = SYSTEM_ERROR | 60,
520     ELIBSCN = SYSTEM_ERROR | 61,
521     ELNRNG = SYSTEM_ERROR | 62,
522     ELOOP = SYSTEM_ERROR | 63,
523     EMEDIUMTYPE = SYSTEM_ERROR | 64,
524     EMFILE = SYSTEM_ERROR | 65,
525     EMLINK = SYSTEM_ERROR | 66,
526     EMSGSIZE = SYSTEM_ERROR | 67,
527     EMULTIHOP = SYSTEM_ERROR | 68,
528     ENAMETOOLONG = SYSTEM_ERROR | 69,
529     ENAVAIL = SYSTEM_ERROR | 70,
530     ENEEDAUTH = SYSTEM_ERROR | 71,
531     ENETDOWN = SYSTEM_ERROR | 72,
532     ENETRESET = SYSTEM_ERROR | 73,
533     ENETUNREACH = SYSTEM_ERROR | 74,
534     ENFILE = SYSTEM_ERROR | 75,
535     ENOANO = SYSTEM_ERROR | 76,
536     ENOBUFS = SYSTEM_ERROR | 77,
537     ENOCSI = SYSTEM_ERROR | 78,
538     ENODATA = SYSTEM_ERROR | 79,
539     ENODEV = SYSTEM_ERROR | 80,
540     ENOENT = SYSTEM_ERROR | 81,
541     ENOEXEC = SYSTEM_ERROR | 82,
542     ENOLCK = SYSTEM_ERROR | 83,
543     ENOLINK = SYSTEM_ERROR | 84,
544     ENOMEDIUM = SYSTEM_ERROR | 85,
545     ENOMEM = SYSTEM_ERROR | 86,
546     ENOMSG = SYSTEM_ERROR | 87,
547     ENONET = SYSTEM_ERROR | 88,
548     ENOPKG = SYSTEM_ERROR | 89,
549     ENOPROTOOPT = SYSTEM_ERROR | 90,
550     ENOSPC = SYSTEM_ERROR | 91,
551     ENOSR = SYSTEM_ERROR | 92,
552     ENOSTR = SYSTEM_ERROR | 93,
553     ENOSYS = SYSTEM_ERROR | 94,
554     ENOTBLK = SYSTEM_ERROR | 95,
555     ENOTCONN = SYSTEM_ERROR | 96,
556     ENOTDIR = SYSTEM_ERROR | 97,
557     ENOTEMPTY = SYSTEM_ERROR | 98,
558     ENOTNAM = SYSTEM_ERROR | 99,
559     ENOTSOCK = SYSTEM_ERROR | 100,
560     ENOTSUP = SYSTEM_ERROR | 101,
561     ENOTTY = SYSTEM_ERROR | 102,
562     ENOTUNIQ = SYSTEM_ERROR | 103,
563     ENXIO = SYSTEM_ERROR | 104,
564     EOPNOTSUPP = SYSTEM_ERROR | 105,
565     EOVERFLOW = SYSTEM_ERROR | 106,
566     EPERM = SYSTEM_ERROR | 107,
567     EPFNOSUPPORT = SYSTEM_ERROR | 108,
568     EPIPE = SYSTEM_ERROR | 109,
569     EPROCLIM = SYSTEM_ERROR | 110,
570     EPROCUNAVAIL = SYSTEM_ERROR | 111,
571     EPROGMISMATCH = SYSTEM_ERROR | 112,
572     EPROGUNAVAIL = SYSTEM_ERROR | 113,
573     EPROTO = SYSTEM_ERROR | 114,
574     EPROTONOSUPPORT = SYSTEM_ERROR | 115,
575     EPROTOTYPE = SYSTEM_ERROR | 116,
576     ERANGE = SYSTEM_ERROR | 117,
577     EREMCHG = SYSTEM_ERROR | 118,
578     EREMOTE = SYSTEM_ERROR | 119,
579     EREMOTEIO = SYSTEM_ERROR | 120,
580     ERESTART = SYSTEM_ERROR | 121,
581     EROFS = SYSTEM_ERROR | 122,
582     ERPCMISMATCH = SYSTEM_ERROR | 123,
583     ESHUTDOWN = SYSTEM_ERROR | 124,
584     ESOCKTNOSUPPORT = SYSTEM_ERROR | 125,
585     ESPIPE = SYSTEM_ERROR | 126,
586     ESRCH = SYSTEM_ERROR | 127,
587     ESRMNT = SYSTEM_ERROR | 128,
588     ESTALE = SYSTEM_ERROR | 129,
589     ESTRPIPE = SYSTEM_ERROR | 130,
590     ETIME = SYSTEM_ERROR | 131,
591     ETIMEDOUT = SYSTEM_ERROR | 132,
592     ETOOMANYREFS = SYSTEM_ERROR | 133,
593     ETXTBSY = SYSTEM_ERROR | 134,
594     EUCLEAN = SYSTEM_ERROR | 135,
595     EUNATCH = SYSTEM_ERROR | 136,
596     EUSERS = SYSTEM_ERROR | 137,
597     EWOULDBLOCK = SYSTEM_ERROR | 138,
598     EXDEV = SYSTEM_ERROR | 139,
599     EXFULL = SYSTEM_ERROR | 140,
600 
601     MASK = (1 << 16) - 1
602 }
603 
604 /// See original's library documentation for details.
605 static immutable GPG_ERR_CODE_DIM = GPG_ERR_CODE.max + 1;
606 
607 /// See original's library documentation for details.
608 static immutable GPG_ERR_SOURCE_SHIFT  = 24;
609 
610 /// See original's library documentation for details.
611 uint gpg_err_init();
612 
613 /// See original's library documentation for details.
614 void gpg_err_deinit (int mode);
615 
616 /// See original's library documentation for details.
617 void gpgrt_set_syscall_clamp (void function() pre, void function() post);
618 
619 /// See original's library documentation for details.
620 void gpgrt_set_alloc_func  (void* function(void *a, size_t n) f);
621 
622 
623 /// See original's library documentation for details.
624 uint gpg_err_make(GPG_ERR_SOURCE source, GPG_ERR_CODE code)
625 {
626     return code? (((source & source.MASK) << GPG_ERR_SOURCE_SHIFT) | (code & code.MASK))
627                : code;
628 }
629 
630 
631 /// See original's library documentation for details.
632 gpg_error_t gpg_error (GPG_ERR_CODE code)
633 {
634   return gpg_err_make(GPG_ERR_SOURCE.init, code);
635 }
636 
637 
638 /// See original's library documentation for details.
639 GPG_ERR_CODE gpg_err_code (gpg_error_t err)
640 {
641   return cast(GPG_ERR_CODE)(err & GPG_ERR_CODE.MASK);
642 }
643 
644 
645 /// See original's library documentation for details.
646 GPG_ERR_SOURCE gpg_err_source (gpg_error_t err)
647 {
648   return cast(GPG_ERR_SOURCE)((err >> GPG_ERR_SOURCE_SHIFT) & GPG_ERR_SOURCE.MASK);
649 }
650 
651 /// See original's library documentation for details.
652 const(char)* gpg_strerror(gpg_error_t err);
653 
654 /// See original's library documentation for details.
655 int gpg_strerror_r(gpg_error_t err, char* buf, size_t buflen);
656 
657 extern (D) int gpg_strerror_r(uint err, ref char[] msg)
658 {
659     verify(msg.length != 0);
660 
661     scope (exit)
662         msg = msg[0 .. strlen(msg.ptr)];
663 
664     return gpg_strerror_r(err, msg.ptr, msg.length);
665 }
666 
667 /// See original's library documentation for details.
668 const(char)* gpg_strsource (uint err);
669 
670 /// See original's library documentation for details.
671 GPG_ERR_CODE gpg_err_code_from_errno(int err);
672 
673 
674 /// See original's library documentation for details.
675 int gpg_err_code_to_errno(GPG_ERR_CODE code);
676 
677 
678 /// See original's library documentation for details.
679 GPG_ERR_CODE gpg_err_code_from_syserror();
680 
681 
682 /// See original's library documentation for details.
683 void gpg_err_set_errno(int err);
684 
685 /// See original's library documentation for details.
686 const(char)* gpgrt_check_version (const(char)* req_version);
687 const(char)* gpg_error_check_version(const(char)* req_version);