some updates
[iv.d.git] / gpgerror.d
blobc7cf446266c09fa79a8603a67b0a509adc8359b0
1 /* gpg-error.h - Public interface to libgpg-error. -*- c -*-
2 Copyright (C) 2003, 2004, 2010, 2013, 2014, 2015 g10 Code GmbH
4 This file is part of libgpg-error.
6 libgpg-error is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public License
8 as published by the Free Software Foundation; either version 2.1 of
9 the License, or (at your option) any later version.
11 libgpg-error is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this program; if not, see <http://www.gnu.org/licenses/>.
19 module iv.gpgerror /*is aliced*/;
20 pragma(lib, "gpg-error");
22 import core.stdc.stdarg : va_list;
23 import core.stdc.stdio : FILE;
24 import iv.alice;
27 extern(C) nothrow @nogc:
28 /* The GnuPG project consists of many components. Error codes are
29 exchanged between all components. The common error codes and their
30 user-presentable descriptions are kept into a shared library to
31 allow adding new error codes and components without recompiling any
32 of the other components. The interface will not change in a
33 backward incompatible way.
35 An error code together with an error source build up an error
36 value. As the error value is been passed from one component to
37 another, it preserver the information about the source and nature
38 of the error.
40 A component of the GnuPG project can define the following macros to
41 tune the behaviour of the library:
43 GPG_ERR_SOURCE_DEFAULT: Define to an error source of type
44 gpg_err_source_t to make that source the default for gpg_error().
45 Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default.
47 GPG_ERR_ENABLE_GETTEXT_MACROS: Define to provide macros to map the
48 internal gettext API to standard names. This has only an effect on
49 Windows platforms.
51 GPGRT_ENABLE_ES_MACROS: Define to provide "es_" macros for the
52 estream functions.
54 In addition to the error codes, Libgpg-error also provides a set of
55 functions used by most GnuPG components. */
58 /* The error source type gpg_err_source_t.
60 Where as the Poo out of a welle small
61 Taketh his firste springing and his sours.
62 --Chaucer. */
64 /* Only use free slots, never change or reorder the existing
65 entries. */
66 enum :uint {
67 GPG_ERR_SOURCE_UNKNOWN = 0,
68 GPG_ERR_SOURCE_GCRYPT = 1,
69 GPG_ERR_SOURCE_GPG = 2,
70 GPG_ERR_SOURCE_GPGSM = 3,
71 GPG_ERR_SOURCE_GPGAGENT = 4,
72 GPG_ERR_SOURCE_PINENTRY = 5,
73 GPG_ERR_SOURCE_SCD = 6,
74 GPG_ERR_SOURCE_GPGME = 7,
75 GPG_ERR_SOURCE_KEYBOX = 8,
76 GPG_ERR_SOURCE_KSBA = 9,
77 GPG_ERR_SOURCE_DIRMNGR = 10,
78 GPG_ERR_SOURCE_GSTI = 11,
79 GPG_ERR_SOURCE_GPA = 12,
80 GPG_ERR_SOURCE_KLEO = 13,
81 GPG_ERR_SOURCE_G13 = 14,
82 GPG_ERR_SOURCE_ASSUAN = 15,
83 GPG_ERR_SOURCE_TLS = 17,
84 GPG_ERR_SOURCE_ANY = 31,
85 GPG_ERR_SOURCE_USER_1 = 32,
86 GPG_ERR_SOURCE_USER_2 = 33,
87 GPG_ERR_SOURCE_USER_3 = 34,
88 GPG_ERR_SOURCE_USER_4 = 35,
90 /* This is one more than the largest allowed entry. */
91 GPG_ERR_SOURCE_DIM = 128
93 alias gpg_err_source_t = uint;
96 /* The error code type gpg_err_code_t. */
98 /* Only use free slots, never change or reorder the existing
99 entries. */
100 enum :uint {
101 GPG_ERR_NO_ERROR = 0,
102 GPG_ERR_GENERAL = 1,
103 GPG_ERR_UNKNOWN_PACKET = 2,
104 GPG_ERR_UNKNOWN_VERSION = 3,
105 GPG_ERR_PUBKEY_ALGO = 4,
106 GPG_ERR_DIGEST_ALGO = 5,
107 GPG_ERR_BAD_PUBKEY = 6,
108 GPG_ERR_BAD_SECKEY = 7,
109 GPG_ERR_BAD_SIGNATURE = 8,
110 GPG_ERR_NO_PUBKEY = 9,
111 GPG_ERR_CHECKSUM = 10,
112 GPG_ERR_BAD_PASSPHRASE = 11,
113 GPG_ERR_CIPHER_ALGO = 12,
114 GPG_ERR_KEYRING_OPEN = 13,
115 GPG_ERR_INV_PACKET = 14,
116 GPG_ERR_INV_ARMOR = 15,
117 GPG_ERR_NO_USER_ID = 16,
118 GPG_ERR_NO_SECKEY = 17,
119 GPG_ERR_WRONG_SECKEY = 18,
120 GPG_ERR_BAD_KEY = 19,
121 GPG_ERR_COMPR_ALGO = 20,
122 GPG_ERR_NO_PRIME = 21,
123 GPG_ERR_NO_ENCODING_METHOD = 22,
124 GPG_ERR_NO_ENCRYPTION_SCHEME = 23,
125 GPG_ERR_NO_SIGNATURE_SCHEME = 24,
126 GPG_ERR_INV_ATTR = 25,
127 GPG_ERR_NO_VALUE = 26,
128 GPG_ERR_NOT_FOUND = 27,
129 GPG_ERR_VALUE_NOT_FOUND = 28,
130 GPG_ERR_SYNTAX = 29,
131 GPG_ERR_BAD_MPI = 30,
132 GPG_ERR_INV_PASSPHRASE = 31,
133 GPG_ERR_SIG_CLASS = 32,
134 GPG_ERR_RESOURCE_LIMIT = 33,
135 GPG_ERR_INV_KEYRING = 34,
136 GPG_ERR_TRUSTDB = 35,
137 GPG_ERR_BAD_CERT = 36,
138 GPG_ERR_INV_USER_ID = 37,
139 GPG_ERR_UNEXPECTED = 38,
140 GPG_ERR_TIME_CONFLICT = 39,
141 GPG_ERR_KEYSERVER = 40,
142 GPG_ERR_WRONG_PUBKEY_ALGO = 41,
143 GPG_ERR_TRIBUTE_TO_D_A = 42,
144 GPG_ERR_WEAK_KEY = 43,
145 GPG_ERR_INV_KEYLEN = 44,
146 GPG_ERR_INV_ARG = 45,
147 GPG_ERR_BAD_URI = 46,
148 GPG_ERR_INV_URI = 47,
149 GPG_ERR_NETWORK = 48,
150 GPG_ERR_UNKNOWN_HOST = 49,
151 GPG_ERR_SELFTEST_FAILED = 50,
152 GPG_ERR_NOT_ENCRYPTED = 51,
153 GPG_ERR_NOT_PROCESSED = 52,
154 GPG_ERR_UNUSABLE_PUBKEY = 53,
155 GPG_ERR_UNUSABLE_SECKEY = 54,
156 GPG_ERR_INV_VALUE = 55,
157 GPG_ERR_BAD_CERT_CHAIN = 56,
158 GPG_ERR_MISSING_CERT = 57,
159 GPG_ERR_NO_DATA = 58,
160 GPG_ERR_BUG = 59,
161 GPG_ERR_NOT_SUPPORTED = 60,
162 GPG_ERR_INV_OP = 61,
163 GPG_ERR_TIMEOUT = 62,
164 GPG_ERR_INTERNAL = 63,
165 GPG_ERR_EOF_GCRYPT = 64,
166 GPG_ERR_INV_OBJ = 65,
167 GPG_ERR_TOO_SHORT = 66,
168 GPG_ERR_TOO_LARGE = 67,
169 GPG_ERR_NO_OBJ = 68,
170 GPG_ERR_NOT_IMPLEMENTED = 69,
171 GPG_ERR_CONFLICT = 70,
172 GPG_ERR_INV_CIPHER_MODE = 71,
173 GPG_ERR_INV_FLAG = 72,
174 GPG_ERR_INV_HANDLE = 73,
175 GPG_ERR_TRUNCATED = 74,
176 GPG_ERR_INCOMPLETE_LINE = 75,
177 GPG_ERR_INV_RESPONSE = 76,
178 GPG_ERR_NO_AGENT = 77,
179 GPG_ERR_AGENT = 78,
180 GPG_ERR_INV_DATA = 79,
181 GPG_ERR_ASSUAN_SERVER_FAULT = 80,
182 GPG_ERR_ASSUAN = 81,
183 GPG_ERR_INV_SESSION_KEY = 82,
184 GPG_ERR_INV_SEXP = 83,
185 GPG_ERR_UNSUPPORTED_ALGORITHM = 84,
186 GPG_ERR_NO_PIN_ENTRY = 85,
187 GPG_ERR_PIN_ENTRY = 86,
188 GPG_ERR_BAD_PIN = 87,
189 GPG_ERR_INV_NAME = 88,
190 GPG_ERR_BAD_DATA = 89,
191 GPG_ERR_INV_PARAMETER = 90,
192 GPG_ERR_WRONG_CARD = 91,
193 GPG_ERR_NO_DIRMNGR = 92,
194 GPG_ERR_DIRMNGR = 93,
195 GPG_ERR_CERT_REVOKED = 94,
196 GPG_ERR_NO_CRL_KNOWN = 95,
197 GPG_ERR_CRL_TOO_OLD = 96,
198 GPG_ERR_LINE_TOO_LONG = 97,
199 GPG_ERR_NOT_TRUSTED = 98,
200 GPG_ERR_CANCELED = 99,
201 GPG_ERR_BAD_CA_CERT = 100,
202 GPG_ERR_CERT_EXPIRED = 101,
203 GPG_ERR_CERT_TOO_YOUNG = 102,
204 GPG_ERR_UNSUPPORTED_CERT = 103,
205 GPG_ERR_UNKNOWN_SEXP = 104,
206 GPG_ERR_UNSUPPORTED_PROTECTION = 105,
207 GPG_ERR_CORRUPTED_PROTECTION = 106,
208 GPG_ERR_AMBIGUOUS_NAME = 107,
209 GPG_ERR_CARD = 108,
210 GPG_ERR_CARD_RESET = 109,
211 GPG_ERR_CARD_REMOVED = 110,
212 GPG_ERR_INV_CARD = 111,
213 GPG_ERR_CARD_NOT_PRESENT = 112,
214 GPG_ERR_NO_PKCS15_APP = 113,
215 GPG_ERR_NOT_CONFIRMED = 114,
216 GPG_ERR_CONFIGURATION = 115,
217 GPG_ERR_NO_POLICY_MATCH = 116,
218 GPG_ERR_INV_INDEX = 117,
219 GPG_ERR_INV_ID = 118,
220 GPG_ERR_NO_SCDAEMON = 119,
221 GPG_ERR_SCDAEMON = 120,
222 GPG_ERR_UNSUPPORTED_PROTOCOL = 121,
223 GPG_ERR_BAD_PIN_METHOD = 122,
224 GPG_ERR_CARD_NOT_INITIALIZED = 123,
225 GPG_ERR_UNSUPPORTED_OPERATION = 124,
226 GPG_ERR_WRONG_KEY_USAGE = 125,
227 GPG_ERR_NOTHING_FOUND = 126,
228 GPG_ERR_WRONG_BLOB_TYPE = 127,
229 GPG_ERR_MISSING_VALUE = 128,
230 GPG_ERR_HARDWARE = 129,
231 GPG_ERR_PIN_BLOCKED = 130,
232 GPG_ERR_USE_CONDITIONS = 131,
233 GPG_ERR_PIN_NOT_SYNCED = 132,
234 GPG_ERR_INV_CRL = 133,
235 GPG_ERR_BAD_BER = 134,
236 GPG_ERR_INV_BER = 135,
237 GPG_ERR_ELEMENT_NOT_FOUND = 136,
238 GPG_ERR_IDENTIFIER_NOT_FOUND = 137,
239 GPG_ERR_INV_TAG = 138,
240 GPG_ERR_INV_LENGTH = 139,
241 GPG_ERR_INV_KEYINFO = 140,
242 GPG_ERR_UNEXPECTED_TAG = 141,
243 GPG_ERR_NOT_DER_ENCODED = 142,
244 GPG_ERR_NO_CMS_OBJ = 143,
245 GPG_ERR_INV_CMS_OBJ = 144,
246 GPG_ERR_UNKNOWN_CMS_OBJ = 145,
247 GPG_ERR_UNSUPPORTED_CMS_OBJ = 146,
248 GPG_ERR_UNSUPPORTED_ENCODING = 147,
249 GPG_ERR_UNSUPPORTED_CMS_VERSION = 148,
250 GPG_ERR_UNKNOWN_ALGORITHM = 149,
251 GPG_ERR_INV_ENGINE = 150,
252 GPG_ERR_PUBKEY_NOT_TRUSTED = 151,
253 GPG_ERR_DECRYPT_FAILED = 152,
254 GPG_ERR_KEY_EXPIRED = 153,
255 GPG_ERR_SIG_EXPIRED = 154,
256 GPG_ERR_ENCODING_PROBLEM = 155,
257 GPG_ERR_INV_STATE = 156,
258 GPG_ERR_DUP_VALUE = 157,
259 GPG_ERR_MISSING_ACTION = 158,
260 GPG_ERR_MODULE_NOT_FOUND = 159,
261 GPG_ERR_INV_OID_STRING = 160,
262 GPG_ERR_INV_TIME = 161,
263 GPG_ERR_INV_CRL_OBJ = 162,
264 GPG_ERR_UNSUPPORTED_CRL_VERSION = 163,
265 GPG_ERR_INV_CERT_OBJ = 164,
266 GPG_ERR_UNKNOWN_NAME = 165,
267 GPG_ERR_LOCALE_PROBLEM = 166,
268 GPG_ERR_NOT_LOCKED = 167,
269 GPG_ERR_PROTOCOL_VIOLATION = 168,
270 GPG_ERR_INV_MAC = 169,
271 GPG_ERR_INV_REQUEST = 170,
272 GPG_ERR_UNKNOWN_EXTN = 171,
273 GPG_ERR_UNKNOWN_CRIT_EXTN = 172,
274 GPG_ERR_LOCKED = 173,
275 GPG_ERR_UNKNOWN_OPTION = 174,
276 GPG_ERR_UNKNOWN_COMMAND = 175,
277 GPG_ERR_NOT_OPERATIONAL = 176,
278 GPG_ERR_NO_PASSPHRASE = 177,
279 GPG_ERR_NO_PIN = 178,
280 GPG_ERR_NOT_ENABLED = 179,
281 GPG_ERR_NO_ENGINE = 180,
282 GPG_ERR_MISSING_KEY = 181,
283 GPG_ERR_TOO_MANY = 182,
284 GPG_ERR_LIMIT_REACHED = 183,
285 GPG_ERR_NOT_INITIALIZED = 184,
286 GPG_ERR_MISSING_ISSUER_CERT = 185,
287 GPG_ERR_NO_KEYSERVER = 186,
288 GPG_ERR_INV_CURVE = 187,
289 GPG_ERR_UNKNOWN_CURVE = 188,
290 GPG_ERR_DUP_KEY = 189,
291 GPG_ERR_AMBIGUOUS = 190,
292 GPG_ERR_NO_CRYPT_CTX = 191,
293 GPG_ERR_WRONG_CRYPT_CTX = 192,
294 GPG_ERR_BAD_CRYPT_CTX = 193,
295 GPG_ERR_CRYPT_CTX_CONFLICT = 194,
296 GPG_ERR_BROKEN_PUBKEY = 195,
297 GPG_ERR_BROKEN_SECKEY = 196,
298 GPG_ERR_MAC_ALGO = 197,
299 GPG_ERR_FULLY_CANCELED = 198,
300 GPG_ERR_UNFINISHED = 199,
301 GPG_ERR_BUFFER_TOO_SHORT = 200,
302 GPG_ERR_SEXP_INV_LEN_SPEC = 201,
303 GPG_ERR_SEXP_STRING_TOO_LONG = 202,
304 GPG_ERR_SEXP_UNMATCHED_PAREN = 203,
305 GPG_ERR_SEXP_NOT_CANONICAL = 204,
306 GPG_ERR_SEXP_BAD_CHARACTER = 205,
307 GPG_ERR_SEXP_BAD_QUOTATION = 206,
308 GPG_ERR_SEXP_ZERO_PREFIX = 207,
309 GPG_ERR_SEXP_NESTED_DH = 208,
310 GPG_ERR_SEXP_UNMATCHED_DH = 209,
311 GPG_ERR_SEXP_UNEXPECTED_PUNC = 210,
312 GPG_ERR_SEXP_BAD_HEX_CHAR = 211,
313 GPG_ERR_SEXP_ODD_HEX_NUMBERS = 212,
314 GPG_ERR_SEXP_BAD_OCT_CHAR = 213,
315 GPG_ERR_LEGACY_KEY = 222,
316 GPG_ERR_REQUEST_TOO_SHORT = 223,
317 GPG_ERR_REQUEST_TOO_LONG = 224,
318 GPG_ERR_OBJ_TERM_STATE = 225,
319 GPG_ERR_NO_CERT_CHAIN = 226,
320 GPG_ERR_CERT_TOO_LARGE = 227,
321 GPG_ERR_INV_RECORD = 228,
322 GPG_ERR_BAD_MAC = 229,
323 GPG_ERR_UNEXPECTED_MSG = 230,
324 GPG_ERR_COMPR_FAILED = 231,
325 GPG_ERR_WOULD_WRAP = 232,
326 GPG_ERR_FATAL_ALERT = 233,
327 GPG_ERR_NO_CIPHER = 234,
328 GPG_ERR_MISSING_CLIENT_CERT = 235,
329 GPG_ERR_CLOSE_NOTIFY = 236,
330 GPG_ERR_TICKET_EXPIRED = 237,
331 GPG_ERR_BAD_TICKET = 238,
332 GPG_ERR_UNKNOWN_IDENTITY = 239,
333 GPG_ERR_BAD_HS_CERT = 240,
334 GPG_ERR_BAD_HS_CERT_REQ = 241,
335 GPG_ERR_BAD_HS_CERT_VER = 242,
336 GPG_ERR_BAD_HS_CHANGE_CIPHER = 243,
337 GPG_ERR_BAD_HS_CLIENT_HELLO = 244,
338 GPG_ERR_BAD_HS_SERVER_HELLO = 245,
339 GPG_ERR_BAD_HS_SERVER_HELLO_DONE = 246,
340 GPG_ERR_BAD_HS_FINISHED = 247,
341 GPG_ERR_BAD_HS_SERVER_KEX = 248,
342 GPG_ERR_BAD_HS_CLIENT_KEX = 249,
343 GPG_ERR_BOGUS_STRING = 250,
344 GPG_ERR_FORBIDDEN = 251,
345 GPG_ERR_KEY_DISABLED = 252,
346 GPG_ERR_KEY_ON_CARD = 253,
347 GPG_ERR_INV_LOCK_OBJ = 254,
348 GPG_ERR_ASS_GENERAL = 257,
349 GPG_ERR_ASS_ACCEPT_FAILED = 258,
350 GPG_ERR_ASS_CONNECT_FAILED = 259,
351 GPG_ERR_ASS_INV_RESPONSE = 260,
352 GPG_ERR_ASS_INV_VALUE = 261,
353 GPG_ERR_ASS_INCOMPLETE_LINE = 262,
354 GPG_ERR_ASS_LINE_TOO_LONG = 263,
355 GPG_ERR_ASS_NESTED_COMMANDS = 264,
356 GPG_ERR_ASS_NO_DATA_CB = 265,
357 GPG_ERR_ASS_NO_INQUIRE_CB = 266,
358 GPG_ERR_ASS_NOT_A_SERVER = 267,
359 GPG_ERR_ASS_NOT_A_CLIENT = 268,
360 GPG_ERR_ASS_SERVER_START = 269,
361 GPG_ERR_ASS_READ_ERROR = 270,
362 GPG_ERR_ASS_WRITE_ERROR = 271,
363 GPG_ERR_ASS_TOO_MUCH_DATA = 273,
364 GPG_ERR_ASS_UNEXPECTED_CMD = 274,
365 GPG_ERR_ASS_UNKNOWN_CMD = 275,
366 GPG_ERR_ASS_SYNTAX = 276,
367 GPG_ERR_ASS_CANCELED = 277,
368 GPG_ERR_ASS_NO_INPUT = 278,
369 GPG_ERR_ASS_NO_OUTPUT = 279,
370 GPG_ERR_ASS_PARAMETER = 280,
371 GPG_ERR_ASS_UNKNOWN_INQUIRE = 281,
372 GPG_ERR_USER_1 = 1024,
373 GPG_ERR_USER_2 = 1025,
374 GPG_ERR_USER_3 = 1026,
375 GPG_ERR_USER_4 = 1027,
376 GPG_ERR_USER_5 = 1028,
377 GPG_ERR_USER_6 = 1029,
378 GPG_ERR_USER_7 = 1030,
379 GPG_ERR_USER_8 = 1031,
380 GPG_ERR_USER_9 = 1032,
381 GPG_ERR_USER_10 = 1033,
382 GPG_ERR_USER_11 = 1034,
383 GPG_ERR_USER_12 = 1035,
384 GPG_ERR_USER_13 = 1036,
385 GPG_ERR_USER_14 = 1037,
386 GPG_ERR_USER_15 = 1038,
387 GPG_ERR_USER_16 = 1039,
388 GPG_ERR_MISSING_ERRNO = 16381,
389 GPG_ERR_UNKNOWN_ERRNO = 16382,
390 GPG_ERR_EOF = 16383,
392 /* The following error codes are used to map system errors. */
393 GPG_ERR_SYSTEM_ERROR = (1 << 15),
394 GPG_ERR_E2BIG = GPG_ERR_SYSTEM_ERROR | 0,
395 GPG_ERR_EACCES = GPG_ERR_SYSTEM_ERROR | 1,
396 GPG_ERR_EADDRINUSE = GPG_ERR_SYSTEM_ERROR | 2,
397 GPG_ERR_EADDRNOTAVAIL = GPG_ERR_SYSTEM_ERROR | 3,
398 GPG_ERR_EADV = GPG_ERR_SYSTEM_ERROR | 4,
399 GPG_ERR_EAFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 5,
400 GPG_ERR_EAGAIN = GPG_ERR_SYSTEM_ERROR | 6,
401 GPG_ERR_EALREADY = GPG_ERR_SYSTEM_ERROR | 7,
402 GPG_ERR_EAUTH = GPG_ERR_SYSTEM_ERROR | 8,
403 GPG_ERR_EBACKGROUND = GPG_ERR_SYSTEM_ERROR | 9,
404 GPG_ERR_EBADE = GPG_ERR_SYSTEM_ERROR | 10,
405 GPG_ERR_EBADF = GPG_ERR_SYSTEM_ERROR | 11,
406 GPG_ERR_EBADFD = GPG_ERR_SYSTEM_ERROR | 12,
407 GPG_ERR_EBADMSG = GPG_ERR_SYSTEM_ERROR | 13,
408 GPG_ERR_EBADR = GPG_ERR_SYSTEM_ERROR | 14,
409 GPG_ERR_EBADRPC = GPG_ERR_SYSTEM_ERROR | 15,
410 GPG_ERR_EBADRQC = GPG_ERR_SYSTEM_ERROR | 16,
411 GPG_ERR_EBADSLT = GPG_ERR_SYSTEM_ERROR | 17,
412 GPG_ERR_EBFONT = GPG_ERR_SYSTEM_ERROR | 18,
413 GPG_ERR_EBUSY = GPG_ERR_SYSTEM_ERROR | 19,
414 GPG_ERR_ECANCELED = GPG_ERR_SYSTEM_ERROR | 20,
415 GPG_ERR_ECHILD = GPG_ERR_SYSTEM_ERROR | 21,
416 GPG_ERR_ECHRNG = GPG_ERR_SYSTEM_ERROR | 22,
417 GPG_ERR_ECOMM = GPG_ERR_SYSTEM_ERROR | 23,
418 GPG_ERR_ECONNABORTED = GPG_ERR_SYSTEM_ERROR | 24,
419 GPG_ERR_ECONNREFUSED = GPG_ERR_SYSTEM_ERROR | 25,
420 GPG_ERR_ECONNRESET = GPG_ERR_SYSTEM_ERROR | 26,
421 GPG_ERR_ED = GPG_ERR_SYSTEM_ERROR | 27,
422 GPG_ERR_EDEADLK = GPG_ERR_SYSTEM_ERROR | 28,
423 GPG_ERR_EDEADLOCK = GPG_ERR_SYSTEM_ERROR | 29,
424 GPG_ERR_EDESTADDRREQ = GPG_ERR_SYSTEM_ERROR | 30,
425 GPG_ERR_EDIED = GPG_ERR_SYSTEM_ERROR | 31,
426 GPG_ERR_EDOM = GPG_ERR_SYSTEM_ERROR | 32,
427 GPG_ERR_EDOTDOT = GPG_ERR_SYSTEM_ERROR | 33,
428 GPG_ERR_EDQUOT = GPG_ERR_SYSTEM_ERROR | 34,
429 GPG_ERR_EEXIST = GPG_ERR_SYSTEM_ERROR | 35,
430 GPG_ERR_EFAULT = GPG_ERR_SYSTEM_ERROR | 36,
431 GPG_ERR_EFBIG = GPG_ERR_SYSTEM_ERROR | 37,
432 GPG_ERR_EFTYPE = GPG_ERR_SYSTEM_ERROR | 38,
433 GPG_ERR_EGRATUITOUS = GPG_ERR_SYSTEM_ERROR | 39,
434 GPG_ERR_EGREGIOUS = GPG_ERR_SYSTEM_ERROR | 40,
435 GPG_ERR_EHOSTDOWN = GPG_ERR_SYSTEM_ERROR | 41,
436 GPG_ERR_EHOSTUNREACH = GPG_ERR_SYSTEM_ERROR | 42,
437 GPG_ERR_EIDRM = GPG_ERR_SYSTEM_ERROR | 43,
438 GPG_ERR_EIEIO = GPG_ERR_SYSTEM_ERROR | 44,
439 GPG_ERR_EILSEQ = GPG_ERR_SYSTEM_ERROR | 45,
440 GPG_ERR_EINPROGRESS = GPG_ERR_SYSTEM_ERROR | 46,
441 GPG_ERR_EINTR = GPG_ERR_SYSTEM_ERROR | 47,
442 GPG_ERR_EINVAL = GPG_ERR_SYSTEM_ERROR | 48,
443 GPG_ERR_EIO = GPG_ERR_SYSTEM_ERROR | 49,
444 GPG_ERR_EISCONN = GPG_ERR_SYSTEM_ERROR | 50,
445 GPG_ERR_EISDIR = GPG_ERR_SYSTEM_ERROR | 51,
446 GPG_ERR_EISNAM = GPG_ERR_SYSTEM_ERROR | 52,
447 GPG_ERR_EL2HLT = GPG_ERR_SYSTEM_ERROR | 53,
448 GPG_ERR_EL2NSYNC = GPG_ERR_SYSTEM_ERROR | 54,
449 GPG_ERR_EL3HLT = GPG_ERR_SYSTEM_ERROR | 55,
450 GPG_ERR_EL3RST = GPG_ERR_SYSTEM_ERROR | 56,
451 GPG_ERR_ELIBACC = GPG_ERR_SYSTEM_ERROR | 57,
452 GPG_ERR_ELIBBAD = GPG_ERR_SYSTEM_ERROR | 58,
453 GPG_ERR_ELIBEXEC = GPG_ERR_SYSTEM_ERROR | 59,
454 GPG_ERR_ELIBMAX = GPG_ERR_SYSTEM_ERROR | 60,
455 GPG_ERR_ELIBSCN = GPG_ERR_SYSTEM_ERROR | 61,
456 GPG_ERR_ELNRNG = GPG_ERR_SYSTEM_ERROR | 62,
457 GPG_ERR_ELOOP = GPG_ERR_SYSTEM_ERROR | 63,
458 GPG_ERR_EMEDIUMTYPE = GPG_ERR_SYSTEM_ERROR | 64,
459 GPG_ERR_EMFILE = GPG_ERR_SYSTEM_ERROR | 65,
460 GPG_ERR_EMLINK = GPG_ERR_SYSTEM_ERROR | 66,
461 GPG_ERR_EMSGSIZE = GPG_ERR_SYSTEM_ERROR | 67,
462 GPG_ERR_EMULTIHOP = GPG_ERR_SYSTEM_ERROR | 68,
463 GPG_ERR_ENAMETOOLONG = GPG_ERR_SYSTEM_ERROR | 69,
464 GPG_ERR_ENAVAIL = GPG_ERR_SYSTEM_ERROR | 70,
465 GPG_ERR_ENEEDAUTH = GPG_ERR_SYSTEM_ERROR | 71,
466 GPG_ERR_ENETDOWN = GPG_ERR_SYSTEM_ERROR | 72,
467 GPG_ERR_ENETRESET = GPG_ERR_SYSTEM_ERROR | 73,
468 GPG_ERR_ENETUNREACH = GPG_ERR_SYSTEM_ERROR | 74,
469 GPG_ERR_ENFILE = GPG_ERR_SYSTEM_ERROR | 75,
470 GPG_ERR_ENOANO = GPG_ERR_SYSTEM_ERROR | 76,
471 GPG_ERR_ENOBUFS = GPG_ERR_SYSTEM_ERROR | 77,
472 GPG_ERR_ENOCSI = GPG_ERR_SYSTEM_ERROR | 78,
473 GPG_ERR_ENODATA = GPG_ERR_SYSTEM_ERROR | 79,
474 GPG_ERR_ENODEV = GPG_ERR_SYSTEM_ERROR | 80,
475 GPG_ERR_ENOENT = GPG_ERR_SYSTEM_ERROR | 81,
476 GPG_ERR_ENOEXEC = GPG_ERR_SYSTEM_ERROR | 82,
477 GPG_ERR_ENOLCK = GPG_ERR_SYSTEM_ERROR | 83,
478 GPG_ERR_ENOLINK = GPG_ERR_SYSTEM_ERROR | 84,
479 GPG_ERR_ENOMEDIUM = GPG_ERR_SYSTEM_ERROR | 85,
480 GPG_ERR_ENOMEM = GPG_ERR_SYSTEM_ERROR | 86,
481 GPG_ERR_ENOMSG = GPG_ERR_SYSTEM_ERROR | 87,
482 GPG_ERR_ENONET = GPG_ERR_SYSTEM_ERROR | 88,
483 GPG_ERR_ENOPKG = GPG_ERR_SYSTEM_ERROR | 89,
484 GPG_ERR_ENOPROTOOPT = GPG_ERR_SYSTEM_ERROR | 90,
485 GPG_ERR_ENOSPC = GPG_ERR_SYSTEM_ERROR | 91,
486 GPG_ERR_ENOSR = GPG_ERR_SYSTEM_ERROR | 92,
487 GPG_ERR_ENOSTR = GPG_ERR_SYSTEM_ERROR | 93,
488 GPG_ERR_ENOSYS = GPG_ERR_SYSTEM_ERROR | 94,
489 GPG_ERR_ENOTBLK = GPG_ERR_SYSTEM_ERROR | 95,
490 GPG_ERR_ENOTCONN = GPG_ERR_SYSTEM_ERROR | 96,
491 GPG_ERR_ENOTDIR = GPG_ERR_SYSTEM_ERROR | 97,
492 GPG_ERR_ENOTEMPTY = GPG_ERR_SYSTEM_ERROR | 98,
493 GPG_ERR_ENOTNAM = GPG_ERR_SYSTEM_ERROR | 99,
494 GPG_ERR_ENOTSOCK = GPG_ERR_SYSTEM_ERROR | 100,
495 GPG_ERR_ENOTSUP = GPG_ERR_SYSTEM_ERROR | 101,
496 GPG_ERR_ENOTTY = GPG_ERR_SYSTEM_ERROR | 102,
497 GPG_ERR_ENOTUNIQ = GPG_ERR_SYSTEM_ERROR | 103,
498 GPG_ERR_ENXIO = GPG_ERR_SYSTEM_ERROR | 104,
499 GPG_ERR_EOPNOTSUPP = GPG_ERR_SYSTEM_ERROR | 105,
500 GPG_ERR_EOVERFLOW = GPG_ERR_SYSTEM_ERROR | 106,
501 GPG_ERR_EPERM = GPG_ERR_SYSTEM_ERROR | 107,
502 GPG_ERR_EPFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 108,
503 GPG_ERR_EPIPE = GPG_ERR_SYSTEM_ERROR | 109,
504 GPG_ERR_EPROCLIM = GPG_ERR_SYSTEM_ERROR | 110,
505 GPG_ERR_EPROCUNAVAIL = GPG_ERR_SYSTEM_ERROR | 111,
506 GPG_ERR_EPROGMISMATCH = GPG_ERR_SYSTEM_ERROR | 112,
507 GPG_ERR_EPROGUNAVAIL = GPG_ERR_SYSTEM_ERROR | 113,
508 GPG_ERR_EPROTO = GPG_ERR_SYSTEM_ERROR | 114,
509 GPG_ERR_EPROTONOSUPPORT = GPG_ERR_SYSTEM_ERROR | 115,
510 GPG_ERR_EPROTOTYPE = GPG_ERR_SYSTEM_ERROR | 116,
511 GPG_ERR_ERANGE = GPG_ERR_SYSTEM_ERROR | 117,
512 GPG_ERR_EREMCHG = GPG_ERR_SYSTEM_ERROR | 118,
513 GPG_ERR_EREMOTE = GPG_ERR_SYSTEM_ERROR | 119,
514 GPG_ERR_EREMOTEIO = GPG_ERR_SYSTEM_ERROR | 120,
515 GPG_ERR_ERESTART = GPG_ERR_SYSTEM_ERROR | 121,
516 GPG_ERR_EROFS = GPG_ERR_SYSTEM_ERROR | 122,
517 GPG_ERR_ERPCMISMATCH = GPG_ERR_SYSTEM_ERROR | 123,
518 GPG_ERR_ESHUTDOWN = GPG_ERR_SYSTEM_ERROR | 124,
519 GPG_ERR_ESOCKTNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 125,
520 GPG_ERR_ESPIPE = GPG_ERR_SYSTEM_ERROR | 126,
521 GPG_ERR_ESRCH = GPG_ERR_SYSTEM_ERROR | 127,
522 GPG_ERR_ESRMNT = GPG_ERR_SYSTEM_ERROR | 128,
523 GPG_ERR_ESTALE = GPG_ERR_SYSTEM_ERROR | 129,
524 GPG_ERR_ESTRPIPE = GPG_ERR_SYSTEM_ERROR | 130,
525 GPG_ERR_ETIME = GPG_ERR_SYSTEM_ERROR | 131,
526 GPG_ERR_ETIMEDOUT = GPG_ERR_SYSTEM_ERROR | 132,
527 GPG_ERR_ETOOMANYREFS = GPG_ERR_SYSTEM_ERROR | 133,
528 GPG_ERR_ETXTBSY = GPG_ERR_SYSTEM_ERROR | 134,
529 GPG_ERR_EUCLEAN = GPG_ERR_SYSTEM_ERROR | 135,
530 GPG_ERR_EUNATCH = GPG_ERR_SYSTEM_ERROR | 136,
531 GPG_ERR_EUSERS = GPG_ERR_SYSTEM_ERROR | 137,
532 GPG_ERR_EWOULDBLOCK = GPG_ERR_SYSTEM_ERROR | 138,
533 GPG_ERR_EXDEV = GPG_ERR_SYSTEM_ERROR | 139,
534 GPG_ERR_EXFULL = GPG_ERR_SYSTEM_ERROR | 140,
536 /* This is one more than the largest allowed entry. */
537 GPG_ERR_CODE_DIM = 65536
539 alias gpg_err_code_t = uint;
542 /* The error value type gpg_error_t. */
544 /* We would really like to use bit-fields in a struct, but using
545 structs as return values can cause binary compatibility issues, in
546 particular if you want to do it effeciently (also see
547 -freg-struct-return option to GCC). */
548 alias gpg_error_t = uint;
550 /* We use the lowest 16 bits of gpg_error_t for error codes. The 16th
551 bit indicates system errors. */
552 enum GPG_ERR_CODE_MASK = (GPG_ERR_CODE_DIM-1);
554 /* Bits 17 to 24 are reserved. */
556 /* We use the upper 7 bits of gpg_error_t for error sources. */
557 enum GPG_ERR_SOURCE_MASK = (GPG_ERR_SOURCE_DIM-1);
558 enum GPG_ERR_SOURCE_SHIFT = 24;
560 /* The highest bit is reserved. It shouldn't be used to prevent
561 potential negative numbers when transmitting error values as
562 text. */
565 /* Initialization function. */
567 /* Initialize the library. This function should be run early. */
568 gpg_error_t gpg_err_init () /*_GPG_ERR_CONSTRUCTOR*/;
569 shared static this () { gpg_err_init(); }
572 /* See the source on how to use the deinit function; it is usually not
573 required. */
574 void gpg_err_deinit (int mode);
576 /* Register blocking system I/O clamping functions. */
577 void gpgrt_set_syscall_clamp (void function () pre, void function () post);
579 /* Register a custom malloc/realloc/free function. */
580 void gpgrt_set_alloc_func (void* function (void *a, usize n) f);
584 /* Constructor and accessor functions. */
586 /* Construct an error value from an error code and source. Within a
587 subsystem, use gpg_error. */
588 /*GPG_ERR_INLINE*/ gpg_error_t gpg_err_make (gpg_err_source_t source, gpg_err_code_t code) {
589 return (code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
590 : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
591 | (code & GPG_ERR_CODE_MASK)));
595 /* The user should define GPG_ERR_SOURCE_DEFAULT before including this
596 file to specify a default source for gpg_error. */
597 enum GPG_ERR_SOURCE_DEFAULT = GPG_ERR_SOURCE_UNKNOWN;
599 /*GPG_ERR_INLINE*/ gpg_error_t gpg_error (gpg_err_code_t code) {
600 return gpg_err_make(GPG_ERR_SOURCE_DEFAULT, code);
604 /* Retrieve the error code from an error value. */
605 /*GPG_ERR_INLINE*/ gpg_err_code_t gpg_err_code (gpg_error_t err) {
606 return cast(gpg_err_code_t)(err&GPG_ERR_CODE_MASK);
610 /* Retrieve the error source from an error value. */
611 /*GPG_ERR_INLINE*/ gpg_err_source_t gpg_err_source (gpg_error_t err) {
612 return cast(gpg_err_source_t)((err>>GPG_ERR_SOURCE_SHIFT)&GPG_ERR_SOURCE_MASK);
616 /* String functions. */
618 /* Return a pointer to a string containing a description of the error
619 code in the error value ERR. This function is not thread-safe. */
620 const(char)* gpg_strerror (gpg_error_t err);
622 /* Return the error string for ERR in the user-supplied buffer BUF of
623 size BUFLEN. This function is, in contrast to gpg_strerror,
624 thread-safe if a thread-safe strerror_r() function is provided by
625 the system. If the function succeeds, 0 is returned and BUF
626 contains the string describing the error. If the buffer was not
627 large enough, ERANGE is returned and BUF contains as much of the
628 beginning of the error string as fits into the buffer. */
629 int gpg_strerror_r (gpg_error_t err, char* buf, usize buflen);
631 /* Return a pointer to a string containing a description of the error
632 source in the error value ERR. */
633 const(char)* gpg_strsource (gpg_error_t err);
636 /* Mapping of system errors (errno). */
638 /* Retrieve the error code for the system error ERR. This returns
639 GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
640 this). */
641 gpg_err_code_t gpg_err_code_from_errno (int err);
644 /* Retrieve the system error for the error code CODE. This returns 0
645 if CODE is not a system error code. */
646 int gpg_err_code_to_errno (gpg_err_code_t code);
649 /* Retrieve the error code directly from the ERRNO variable. This
650 returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
651 (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
652 gpg_err_code_t gpg_err_code_from_syserror ();
655 /* Set the ERRNO variable. This function is the preferred way to set
656 ERRNO due to peculiarities on WindowsCE. */
657 void gpg_err_set_errno (int err);
659 /* Return or check the version. Both functions are identical. */
660 const(char)* gpgrt_check_version (const(char)* req_version);
661 const(char)* gpg_error_check_version (const(char)* req_version);
663 /* The version string of this header. */
664 enum GPG_ERROR_VERSION = "1.18";
666 /* The version number of this header. */
667 enum GPG_ERROR_VERSION_NUMBER = 0x011200;
669 /* System specific type definitions. */
670 alias gpgrt_ssize_t = ssize;
671 alias gpgrt_off_t = ulong;
674 /* Self-documenting convenience functions. */
676 /*GPG_ERR_INLINE*/ gpg_error_t gpg_err_make_from_errno (gpg_err_source_t source, int err) {
677 return gpg_err_make(source, gpg_err_code_from_errno (err));
681 /*GPG_ERR_INLINE*/ gpg_error_t gpg_error_from_errno (int err) {
682 return gpg_error(gpg_err_code_from_errno (err));
685 /*GPG_ERR_INLINE*/ gpg_error_t gpg_error_from_syserror () {
686 return gpg_error(gpg_err_code_from_syserror ());
690 /* Lock functions. */
691 struct gpgrt_lock_t {
692 long _vers;
693 union {
694 /*TODO:volatile*/ char[24] _priv;
695 long _x_align;
696 long *_xp_align;
700 /+TODO
701 #define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \
702 0,0,0,0,0,0,0,0, \
703 0,0,0,0,0,0,0,0}}}
706 #define GPGRT_LOCK_DEFINE(name) \
707 static gpgrt_lock_t name = GPGRT_LOCK_INITIALIZER
709 /* NB: If GPGRT_LOCK_DEFINE is not used, zero out the lock variable
710 before passing it to gpgrt_lock_init. */
711 gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd);
712 gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd);
713 gpg_err_code_t gpgrt_lock_trylock (gpgrt_lock_t *lockhd);
714 gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
715 gpg_err_code_t gpgrt_lock_destroy (gpgrt_lock_t *lockhd);
719 /* Thread functions. */
721 gpg_err_code_t gpgrt_yield ();
726 /* Estream */
728 /* The definition of this struct is entirely private. You must not
729 use it for anything. It is only here so some functions can be
730 implemented as macros. */
731 alias _gpgrt_stream_internal_ptr = void*; //struct
732 struct _gpgrt__stream {
733 /* The layout of this struct must never change. It may be grown,
734 but only if all functions which access the new members are
735 versioned. */
737 /* Various flags. */
738 /+TODO
739 struct {
740 uint magic: 16;
741 uint writing: 1;
742 uint reserved: 15;
743 } flags;
745 uint flags;
747 /* A pointer to the stream buffer. */
748 ubyte* buffer;
750 /* The size of the buffer in bytes. */
751 usize buffer_size;
753 /* The length of the usable data in the buffer, only valid when in
754 read mode (see flags). */
755 usize data_len;
757 /* The current position of the offset pointer, valid in read and
758 write mode. */
759 usize data_offset;
761 usize data_flushed;
762 ubyte* unread_buffer;
763 usize unread_buffer_size;
765 /* The number of unread bytes. */
766 usize unread_data_len;
768 /* A pointer to our internal data for this stream. */
769 _gpgrt_stream_internal_ptr intern;
772 /* The opaque type for an estream. */
773 alias gpgrt_stream_t = _gpgrt__stream*;
775 #ifdef GPGRT_ENABLE_ES_MACROS
776 typedef struct _gpgrt__stream *estream_t;
777 #endif
780 alias gpgrt_cookie_read_function_t = ssize function (void *cookie, void *buffer, usize size);
781 alias gpgrt_cookie_write_function_t = ssize function (void *cookie, const void *buffer, usize size);
782 alias gpgrt_cookie_seek_function_t = int function (void *cookie, gpgrt_off_t *pos, int whence);
783 alias gpgrt_cookie_close_function_t = int function (void *cookie);
785 struct _gpgrt_cookie_io_functions {
786 gpgrt_cookie_read_function_t func_read;
787 gpgrt_cookie_write_function_t func_write;
788 gpgrt_cookie_seek_function_t func_seek;
789 gpgrt_cookie_close_function_t func_close;
791 alias gpgrt_cookie_io_functions_t = _gpgrt_cookie_io_functions;
793 #ifdef GPGRT_ENABLE_ES_MACROS
794 typedef struct _gpgrt_cookie_io_functions es_cookie_io_functions_t;
795 #define es_cookie_read_function_t gpgrt_cookie_read_function_t
796 #define es_cookie_write_function_t gpgrt_cookie_read_function_t
797 #define es_cookie_seek_function_t gpgrt_cookie_read_function_t
798 #define es_cookie_close_function_t gpgrt_cookie_read_function_t
799 #endif
802 enum {
803 GPGRT_SYSHD_NONE = 0, /* No system handle available. */
804 GPGRT_SYSHD_FD = 1, /* A file descriptor as returned by open(). */
805 GPGRT_SYSHD_SOCK = 2, /* A socket as returned by socket(). */
806 GPGRT_SYSHD_RVID = 3, /* A rendevous id (see libassuan's gpgcedev.c). */
807 GPGRT_SYSHD_HANDLE = 4 /* A HANDLE object (Windows). */
809 alias gpgrt_syshd_types = int;
811 struct _gpgrt_syshd {
812 gpgrt_syshd_types type;
813 union {
814 int fd;
815 int sock;
816 int rvid;
817 void *handle;
820 alias gpgrt_syshd_t = _gpgrt_syshd;
822 #ifdef GPGRT_ENABLE_ES_MACROS
823 typedef struct _gpgrt_syshd es_syshd_t;
824 #define ES_SYSHD_NONE GPGRT_SYSHD_NONE
825 #define ES_SYSHD_FD GPGRT_SYSHD_FD
826 #define ES_SYSHD_SOCK GPGRT_SYSHD_SOCK
827 #define ES_SYSHD_RVID GPGRT_SYSHD_RVID
828 #define ES_SYSHD_HANDLE GPGRT_SYSHD_HANDLE
829 #endif
832 gpgrt_stream_t gpgrt_fopen (scope const(char)* path, scope const(char)* mode);
833 gpgrt_stream_t gpgrt_mopen (scope void *data,
834 usize data_n, usize data_len,
835 uint grow,
836 void* function (void *mem, usize size) func_realloc,
837 void function (void *mem) func_free,
838 scope const(char)* mode);
839 gpgrt_stream_t gpgrt_fopenmem (usize memlimit,
840 scope const(char)* mode);
841 gpgrt_stream_t gpgrt_fopenmem_init (usize memlimit,
842 scope const(char)* mode,
843 const void *data, usize datalen);
844 gpgrt_stream_t gpgrt_fdopen (int filedes, const(char)* mode);
845 gpgrt_stream_t gpgrt_fdopen_nc (int filedes, const(char)* mode);
847 gpgrt_stream_t gpgrt_sysopen (gpgrt_syshd_t *syshd, const(char)* mode);
848 gpgrt_stream_t gpgrt_sysopen_nc (gpgrt_syshd_t *syshd, const(char)* mode);
849 gpgrt_stream_t gpgrt_fpopen (FILE *fp, const(char)* mode);
850 gpgrt_stream_t gpgrt_fpopen_nc (FILE *fp, const(char)* mode);
851 gpgrt_stream_t gpgrt_freopen (scope const(char)* path,
852 scope const(char)* mode,
853 scope gpgrt_stream_t stream);
854 gpgrt_stream_t gpgrt_fopencookie (scope void *cookie,
855 scope const(char)* mode,
856 gpgrt_cookie_io_functions_t functions);
857 int gpgrt_fclose (gpgrt_stream_t stream);
858 int gpgrt_fclose_snatch (gpgrt_stream_t stream,
859 void **r_buffer, usize *r_buflen);
860 int gpgrt_onclose (gpgrt_stream_t stream, int mode,
861 void function (gpgrt_stream_t, void*) fnc, void *fnc_value);
862 int gpgrt_fileno (gpgrt_stream_t stream);
863 int gpgrt_fileno_unlocked (gpgrt_stream_t stream);
864 int gpgrt_syshd (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
865 int gpgrt_syshd_unlocked (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
867 void _gpgrt_set_std_fd (int no, int fd);
868 gpgrt_stream_t _gpgrt_get_std_stream (int fd);
870 auto gpgrt_stdin () { return _gpgrt_get_std_stream(0); }
871 auto gpgrt_stdout () { return _gpgrt_get_std_stream(1); }
872 auto gpgrt_stderr () { return _gpgrt_get_std_stream(2); }
875 void gpgrt_flockfile (gpgrt_stream_t stream);
876 int gpgrt_ftrylockfile (gpgrt_stream_t stream);
877 void gpgrt_funlockfile (gpgrt_stream_t stream);
879 int gpgrt_feof (gpgrt_stream_t stream);
880 int gpgrt_feof_unlocked (gpgrt_stream_t stream);
881 int gpgrt_ferror (gpgrt_stream_t stream);
882 int gpgrt_ferror_unlocked (gpgrt_stream_t stream);
883 void gpgrt_clearerr (gpgrt_stream_t stream);
884 void gpgrt_clearerr_unlocked (gpgrt_stream_t stream);
886 int _gpgrt_pending (gpgrt_stream_t stream); /* (private) */
887 int _gpgrt_pending_unlocked (gpgrt_stream_t stream); /* (private) */
889 auto gpgrt_pending (gpgrt_stream_t stream) { return _gpgrt_pending(stream); }
891 /+TODO
892 #define gpgrt_pending_unlocked(stream) \
893 (((!(stream)->flags.writing) \
894 && (((stream)->data_offset < (stream)->data_len) \
895 || ((stream)->unread_data_len))) \
896 ? 1 : _gpgrt_pending_unlocked ((stream)))
899 int gpgrt_fflush (gpgrt_stream_t stream);
900 int gpgrt_fseek (gpgrt_stream_t stream, int/*long int*/ offset, int whence);
901 int gpgrt_fseeko (gpgrt_stream_t stream, gpgrt_off_t offset, int whence);
902 int/*long int*/ gpgrt_ftell (gpgrt_stream_t stream);
903 gpgrt_off_t gpgrt_ftello (gpgrt_stream_t stream);
904 void gpgrt_rewind (gpgrt_stream_t stream);
906 int gpgrt_fgetc (gpgrt_stream_t stream);
907 int gpgrt_fputc (int c, gpgrt_stream_t stream);
909 int _gpgrt_getc_underflow (gpgrt_stream_t stream); /* (private) */
910 int _gpgrt_putc_overflow (int c, gpgrt_stream_t stream); /* (private) */
912 /+TODO
913 #define gpgrt_getc_unlocked(stream) \
914 (((!(stream)->flags.writing) \
915 && ((stream)->data_offset < (stream)->data_len) \
916 && (! (stream)->unread_data_len)) \
917 ? ((int) (stream)->buffer[((stream)->data_offset)++]) \
918 : _gpgrt_getc_underflow ((stream)))
920 #define gpgrt_putc_unlocked(c, stream) \
921 (((stream)->flags.writing \
922 && ((stream)->data_offset < (stream)->buffer_size) \
923 && (c != '\n')) \
924 ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c))) \
925 : _gpgrt_putc_overflow ((c), (stream)))
927 #define gpgrt_getc(stream) gpgrt_fgetc (stream)
928 #define gpgrt_putc(c, stream) gpgrt_fputc (c, stream)
931 int gpgrt_ungetc (int c, gpgrt_stream_t stream);
933 int gpgrt_read (scope gpgrt_stream_t stream,
934 scope void *buffer, usize bytes_to_read,
935 scope usize *bytes_read);
936 int gpgrt_write (scope gpgrt_stream_t stream,
937 scope const void *buffer, usize bytes_to_write,
938 scope usize *bytes_written);
939 int gpgrt_write_sanitized (scope gpgrt_stream_t stream,
940 scope const void *buffer, usize length,
941 const(char)* delimiters,
942 scope usize *bytes_written);
943 int gpgrt_write_hexstring (scope gpgrt_stream_t stream,
944 scope const void *buffer, usize length,
945 int reserved,
946 scope usize *bytes_written);
948 usize gpgrt_fread (scope void *ptr, usize size, usize nitems,
949 scope gpgrt_stream_t stream);
950 usize gpgrt_fwrite (scope const void *ptr, usize size, usize memb,
951 scope gpgrt_stream_t stream);
953 char *gpgrt_fgets (scope char *s, int n, scope gpgrt_stream_t stream);
954 int gpgrt_fputs (scope const(char)* s, scope gpgrt_stream_t stream);
955 int gpgrt_fputs_unlocked (scope const(char)* s, scope gpgrt_stream_t stream);
957 ssize gpgrt_getline (scope char **lineptr,
958 scope usize *n,
959 gpgrt_stream_t stream);
960 ssize gpgrt_read_line (gpgrt_stream_t stream,
961 char **addr_of_buffer, usize *length_of_buffer,
962 usize *max_length);
963 void gpgrt_free (void *a);
965 int gpgrt_fprintf (scope gpgrt_stream_t stream, scope const(char)* format, ...) /*_GPGRT_GCC_A_PRINTF(2,3)*/;
966 int gpgrt_fprintf_unlocked (scope gpgrt_stream_t stream, scope const(char)* format, ...) /*_GPGRT_GCC_A_PRINTF(2,3)*/;
968 int gpgrt_printf (scope const(char)* format, ...) /*_GPGRT_GCC_A_PRINTF(1,2)*/;
969 int gpgrt_printf_unlocked (scope const(char)* format, ...) /*_GPGRT_GCC_A_PRINTF(1,2)*/;
971 int gpgrt_vfprintf (scope gpgrt_stream_t stream, scope const(char)* format, va_list ap) /*_GPGRT_GCC_A_PRINTF(2,0)*/;
972 int gpgrt_vfprintf_unlocked (scope gpgrt_stream_t stream, scope const(char)* format, va_list ap) /*_GPGRT_GCC_A_PRINTF(2,0)*/;
974 int gpgrt_setvbuf (scope gpgrt_stream_t stream, scope char *buf, int mode, usize size);
975 void gpgrt_setbuf (scope gpgrt_stream_t stream, scope char *buf);
977 void gpgrt_set_binary (gpgrt_stream_t stream);
979 gpgrt_stream_t gpgrt_tmpfile ();
981 void gpgrt_opaque_set (scope gpgrt_stream_t stream, scope void *opaque);
982 void *gpgrt_opaque_get (gpgrt_stream_t stream);
984 void gpgrt_fname_set (gpgrt_stream_t stream, const(char)* fname);
985 const(char)* gpgrt_fname_get (gpgrt_stream_t stream);
987 int gpgrt_asprintf (char **r_buf, scope const(char)* format, ...) /*_GPGRT_GCC_A_PRINTF(2,3)*/;
988 int gpgrt_vasprintf (char **r_buf, scope const(char)* format, va_list ap) /*_GPGRT_GCC_A_PRINTF(2,0)*/;
989 char *gpgrt_bsprintf (scope const(char)* format, ...) /*_GPGRT_GCC_A_PRINTF(1,2)*/;
990 char *gpgrt_vbsprintf (scope const(char)* format, va_list ap) /*_GPGRT_GCC_A_PRINTF(1,0)*/;
991 int gpgrt_snprintf (char *buf, usize bufsize, scope const(char)* format, ...) /*_GPGRT_GCC_A_PRINTF(3,4)*/;
992 int gpgrt_vsnprintf (char *buf,usize bufsize, scope const(char)* format, va_list arg_ptr) /*_GPGRT_GCC_A_PRINTF(3,0)*/;
996 #ifdef GPGRT_ENABLE_ES_MACROS
997 # define es_fopen gpgrt_fopen
998 # define es_mopen gpgrt_mopen
999 # define es_fopenmem gpgrt_fopenmem
1000 # define es_fopenmem_init gpgrt_fopenmem_init
1001 # define es_fdopen gpgrt_fdopen
1002 # define es_fdopen_nc gpgrt_fdopen_nc
1003 # define es_sysopen gpgrt_sysopen
1004 # define es_sysopen_nc gpgrt_sysopen_nc
1005 # define es_fpopen gpgrt_fpopen
1006 # define es_fpopen_nc gpgrt_fpopen_nc
1007 # define es_freopen gpgrt_freopen
1008 # define es_fopencookie gpgrt_fopencookie
1009 # define es_fclose gpgrt_fclose
1010 # define es_fclose_snatch gpgrt_fclose_snatch
1011 # define es_onclose gpgrt_onclose
1012 # define es_fileno gpgrt_fileno
1013 # define es_fileno_unlocked gpgrt_fileno_unlocked
1014 # define es_syshd gpgrt_syshd
1015 # define es_syshd_unlocked gpgrt_syshd_unlocked
1016 # define es_stdin _gpgrt_get_std_stream (0)
1017 # define es_stdout _gpgrt_get_std_stream (1)
1018 # define es_stderr _gpgrt_get_std_stream (2)
1019 # define es_flockfile gpgrt_flockfile
1020 # define es_ftrylockfile gpgrt_ftrylockfile
1021 # define es_funlockfile gpgrt_funlockfile
1022 # define es_feof gpgrt_feof
1023 # define es_feof_unlocked gpgrt_feof_unlocked
1024 # define es_ferror gpgrt_ferror
1025 # define es_ferror_unlocked gpgrt_ferror_unlocked
1026 # define es_clearerr gpgrt_clearerr
1027 # define es_clearerr_unlocked gpgrt_clearerr_unlocked
1028 # define es_pending gpgrt_pending
1029 # define es_pending_unlocked gpgrt_pending_unlocked
1030 # define es_fflush gpgrt_fflush
1031 # define es_fseek gpgrt_fseek
1032 # define es_fseeko gpgrt_fseeko
1033 # define es_ftell gpgrt_ftell
1034 # define es_ftello gpgrt_ftello
1035 # define es_rewind gpgrt_rewind
1036 # define es_fgetc gpgrt_fgetc
1037 # define es_fputc gpgrt_fputc
1038 # define es_getc_unlocked gpgrt_getc_unlocked
1039 # define es_putc_unlocked gpgrt_putc_unlocked
1040 # define es_getc gpgrt_getc
1041 # define es_putc gpgrt_putc
1042 # define es_ungetc gpgrt_ungetc
1043 # define es_read gpgrt_read
1044 # define es_write gpgrt_write
1045 # define es_write_sanitized gpgrt_write_sanitized
1046 # define es_write_hexstring gpgrt_write_hexstring
1047 # define es_fread gpgrt_fread
1048 # define es_fwrite gpgrt_fwrite
1049 # define es_fgets gpgrt_fgets
1050 # define es_fputs gpgrt_fputs
1051 # define es_fputs_unlocked gpgrt_fputs_unlocked
1052 # define es_getline gpgrt_getline
1053 # define es_read_line gpgrt_read_line
1054 # define es_free gpgrt_free
1055 # define es_fprintf gpgrt_fprintf
1056 # define es_fprintf_unlocked gpgrt_fprintf_unlocked
1057 # define es_printf gpgrt_printf
1058 # define es_printf_unlocked gpgrt_printf_unlocked
1059 # define es_vfprintf gpgrt_vfprintf
1060 # define es_vfprintf_unlocked gpgrt_vfprintf_unlocked
1061 # define es_setvbuf gpgrt_setvbuf
1062 # define es_setbuf gpgrt_setbuf
1063 # define es_set_binary gpgrt_set_binary
1064 # define es_tmpfile gpgrt_tmpfile
1065 # define es_opaque_set gpgrt_opaque_set
1066 # define es_opaque_get gpgrt_opaque_get
1067 # define es_fname_set gpgrt_fname_set
1068 # define es_fname_get gpgrt_fname_get
1069 # define es_asprintf gpgrt_asprintf
1070 # define es_vasprintf gpgrt_vasprintf
1071 # define es_bsprintf gpgrt_bsprintf
1072 # define es_vbsprintf gpgrt_vbsprintf
1073 #endif