Line data Source code
1 : /* gpg-error.h or gpgrt.h - Common code for GnuPG and others. -*- c -*-
2 : * Copyright (C) 2001-2020 g10 Code GmbH
3 : *
4 : * This file is part of libgpg-error (aka libgpgrt).
5 : *
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.
10 : *
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.
15 : *
16 : * You should have received a copy of the GNU Lesser General Public
17 : * License along with this program; if not, see <https://www.gnu.org/licenses/>.
18 : * SPDX-License-Identifier: LGPL-2.1+
19 : *
20 : * Do not edit. Generated from gpg-error.h.in for:
21 : x86_64-unknown-linux-gnu (x86_64-pc-linux-gnu)
22 : */
23 :
24 : /* The GnuPG project consists of many components. Error codes are
25 : * exchanged between all components. The common error codes and their
26 : * user-presentable descriptions are kept into a shared library to
27 : * allow adding new error codes and components without recompiling any
28 : * of the other components. In addition to error codes this library
29 : * also features several other groups of functions which are common to
30 : * all GnuPG components. They may be used by independet project as
31 : * well. The interfaces will not change in a backward incompatible way.
32 : *
33 : * An error code together with an error source build up an error
34 : * value. As the error value is been passed from one component to
35 : * another, it preserves the information about the source and nature
36 : * of the error.
37 : *
38 : * A component of the GnuPG project can define the following macros to
39 : * tune the behaviour of the library:
40 : *
41 : * GPG_ERR_SOURCE_DEFAULT: Define to an error source of type
42 : * gpg_err_source_t to make that source the default for gpg_error().
43 : * Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default.
44 : *
45 : * GPG_ERR_ENABLE_GETTEXT_MACROS: Define to provide macros to map the
46 : * internal gettext API to standard names. This has only an effect on
47 : * Windows platforms.
48 : *
49 : * GPGRT_ENABLE_ES_MACROS: Define to provide "es_" macros for the
50 : * estream functions.
51 : *
52 : * GPGRT_ENABLE_LOG_MACROS: Define to provide short versions of the
53 : * log functions.
54 : *
55 : * GPGRT_ENABLE_ARGPARSE_MACROS: Needs to be defined to provide the
56 : * mandatory macros of the argparse interface.
57 : */
58 :
59 : #ifndef GPG_ERROR_H
60 : #define GPG_ERROR_H 1
61 : #ifndef GPGRT_H
62 : #define GPGRT_H 1
63 :
64 : #include <stddef.h>
65 : #include <stdio.h>
66 : #include <stdarg.h>
67 :
68 : /* The version string of this header. */
69 : #define GPG_ERROR_VERSION "1.43"
70 : #define GPGRT_VERSION "1.43"
71 :
72 : /* The version number of this header. */
73 : #define GPG_ERROR_VERSION_NUMBER 0x012b00
74 : #define GPGRT_VERSION_NUMBER 0x012b00
75 :
76 :
77 : #ifdef __GNUC__
78 : # define GPG_ERR_INLINE __inline__
79 : #elif defined(_MSC_VER) && _MSC_VER >= 1300
80 : # define GPG_ERR_INLINE __inline
81 : #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
82 : # define GPG_ERR_INLINE inline
83 : #else
84 : # ifndef GPG_ERR_INLINE
85 : # define GPG_ERR_INLINE
86 : # endif
87 : #endif
88 :
89 : #ifdef __cplusplus
90 : extern "C" {
91 : #if 0 /* just to make Emacs auto-indent happy */
92 : }
93 : #endif
94 : #endif /* __cplusplus */
95 :
96 :
97 :
98 : /* The error source type gpg_err_source_t.
99 : *
100 : * Where as the Poo out of a welle small
101 : * Taketh his firste springing and his sours.
102 : * --Chaucer.
103 : */
104 :
105 : /* Only use free slots, never change or reorder the existing
106 : * entries. */
107 : typedef enum
108 : {
109 : GPG_ERR_SOURCE_UNKNOWN = 0,
110 : GPG_ERR_SOURCE_GCRYPT = 1,
111 : GPG_ERR_SOURCE_GPG = 2,
112 : GPG_ERR_SOURCE_GPGSM = 3,
113 : GPG_ERR_SOURCE_GPGAGENT = 4,
114 : GPG_ERR_SOURCE_PINENTRY = 5,
115 : GPG_ERR_SOURCE_SCD = 6,
116 : GPG_ERR_SOURCE_GPGME = 7,
117 : GPG_ERR_SOURCE_KEYBOX = 8,
118 : GPG_ERR_SOURCE_KSBA = 9,
119 : GPG_ERR_SOURCE_DIRMNGR = 10,
120 : GPG_ERR_SOURCE_GSTI = 11,
121 : GPG_ERR_SOURCE_GPA = 12,
122 : GPG_ERR_SOURCE_KLEO = 13,
123 : GPG_ERR_SOURCE_G13 = 14,
124 : GPG_ERR_SOURCE_ASSUAN = 15,
125 : GPG_ERR_SOURCE_TPM2D = 16,
126 : GPG_ERR_SOURCE_TLS = 17,
127 : GPG_ERR_SOURCE_ANY = 31,
128 : GPG_ERR_SOURCE_USER_1 = 32,
129 : GPG_ERR_SOURCE_USER_2 = 33,
130 : GPG_ERR_SOURCE_USER_3 = 34,
131 : GPG_ERR_SOURCE_USER_4 = 35,
132 :
133 : /* This is one more than the largest allowed entry. */
134 : GPG_ERR_SOURCE_DIM = 128
135 : } gpg_err_source_t;
136 :
137 :
138 : /* The error code type gpg_err_code_t. */
139 :
140 : /* Only use free slots, never change or reorder the existing
141 : * entries. */
142 : typedef enum
143 : {
144 : GPG_ERR_NO_ERROR = 0,
145 : GPG_ERR_GENERAL = 1,
146 : GPG_ERR_UNKNOWN_PACKET = 2,
147 : GPG_ERR_UNKNOWN_VERSION = 3,
148 : GPG_ERR_PUBKEY_ALGO = 4,
149 : GPG_ERR_DIGEST_ALGO = 5,
150 : GPG_ERR_BAD_PUBKEY = 6,
151 : GPG_ERR_BAD_SECKEY = 7,
152 : GPG_ERR_BAD_SIGNATURE = 8,
153 : GPG_ERR_NO_PUBKEY = 9,
154 : GPG_ERR_CHECKSUM = 10,
155 : GPG_ERR_BAD_PASSPHRASE = 11,
156 : GPG_ERR_CIPHER_ALGO = 12,
157 : GPG_ERR_KEYRING_OPEN = 13,
158 : GPG_ERR_INV_PACKET = 14,
159 : GPG_ERR_INV_ARMOR = 15,
160 : GPG_ERR_NO_USER_ID = 16,
161 : GPG_ERR_NO_SECKEY = 17,
162 : GPG_ERR_WRONG_SECKEY = 18,
163 : GPG_ERR_BAD_KEY = 19,
164 : GPG_ERR_COMPR_ALGO = 20,
165 : GPG_ERR_NO_PRIME = 21,
166 : GPG_ERR_NO_ENCODING_METHOD = 22,
167 : GPG_ERR_NO_ENCRYPTION_SCHEME = 23,
168 : GPG_ERR_NO_SIGNATURE_SCHEME = 24,
169 : GPG_ERR_INV_ATTR = 25,
170 : GPG_ERR_NO_VALUE = 26,
171 : GPG_ERR_NOT_FOUND = 27,
172 : GPG_ERR_VALUE_NOT_FOUND = 28,
173 : GPG_ERR_SYNTAX = 29,
174 : GPG_ERR_BAD_MPI = 30,
175 : GPG_ERR_INV_PASSPHRASE = 31,
176 : GPG_ERR_SIG_CLASS = 32,
177 : GPG_ERR_RESOURCE_LIMIT = 33,
178 : GPG_ERR_INV_KEYRING = 34,
179 : GPG_ERR_TRUSTDB = 35,
180 : GPG_ERR_BAD_CERT = 36,
181 : GPG_ERR_INV_USER_ID = 37,
182 : GPG_ERR_UNEXPECTED = 38,
183 : GPG_ERR_TIME_CONFLICT = 39,
184 : GPG_ERR_KEYSERVER = 40,
185 : GPG_ERR_WRONG_PUBKEY_ALGO = 41,
186 : GPG_ERR_TRIBUTE_TO_D_A = 42,
187 : GPG_ERR_WEAK_KEY = 43,
188 : GPG_ERR_INV_KEYLEN = 44,
189 : GPG_ERR_INV_ARG = 45,
190 : GPG_ERR_BAD_URI = 46,
191 : GPG_ERR_INV_URI = 47,
192 : GPG_ERR_NETWORK = 48,
193 : GPG_ERR_UNKNOWN_HOST = 49,
194 : GPG_ERR_SELFTEST_FAILED = 50,
195 : GPG_ERR_NOT_ENCRYPTED = 51,
196 : GPG_ERR_NOT_PROCESSED = 52,
197 : GPG_ERR_UNUSABLE_PUBKEY = 53,
198 : GPG_ERR_UNUSABLE_SECKEY = 54,
199 : GPG_ERR_INV_VALUE = 55,
200 : GPG_ERR_BAD_CERT_CHAIN = 56,
201 : GPG_ERR_MISSING_CERT = 57,
202 : GPG_ERR_NO_DATA = 58,
203 : GPG_ERR_BUG = 59,
204 : GPG_ERR_NOT_SUPPORTED = 60,
205 : GPG_ERR_INV_OP = 61,
206 : GPG_ERR_TIMEOUT = 62,
207 : GPG_ERR_INTERNAL = 63,
208 : GPG_ERR_EOF_GCRYPT = 64,
209 : GPG_ERR_INV_OBJ = 65,
210 : GPG_ERR_TOO_SHORT = 66,
211 : GPG_ERR_TOO_LARGE = 67,
212 : GPG_ERR_NO_OBJ = 68,
213 : GPG_ERR_NOT_IMPLEMENTED = 69,
214 : GPG_ERR_CONFLICT = 70,
215 : GPG_ERR_INV_CIPHER_MODE = 71,
216 : GPG_ERR_INV_FLAG = 72,
217 : GPG_ERR_INV_HANDLE = 73,
218 : GPG_ERR_TRUNCATED = 74,
219 : GPG_ERR_INCOMPLETE_LINE = 75,
220 : GPG_ERR_INV_RESPONSE = 76,
221 : GPG_ERR_NO_AGENT = 77,
222 : GPG_ERR_AGENT = 78,
223 : GPG_ERR_INV_DATA = 79,
224 : GPG_ERR_ASSUAN_SERVER_FAULT = 80,
225 : GPG_ERR_ASSUAN = 81,
226 : GPG_ERR_INV_SESSION_KEY = 82,
227 : GPG_ERR_INV_SEXP = 83,
228 : GPG_ERR_UNSUPPORTED_ALGORITHM = 84,
229 : GPG_ERR_NO_PIN_ENTRY = 85,
230 : GPG_ERR_PIN_ENTRY = 86,
231 : GPG_ERR_BAD_PIN = 87,
232 : GPG_ERR_INV_NAME = 88,
233 : GPG_ERR_BAD_DATA = 89,
234 : GPG_ERR_INV_PARAMETER = 90,
235 : GPG_ERR_WRONG_CARD = 91,
236 : GPG_ERR_NO_DIRMNGR = 92,
237 : GPG_ERR_DIRMNGR = 93,
238 : GPG_ERR_CERT_REVOKED = 94,
239 : GPG_ERR_NO_CRL_KNOWN = 95,
240 : GPG_ERR_CRL_TOO_OLD = 96,
241 : GPG_ERR_LINE_TOO_LONG = 97,
242 : GPG_ERR_NOT_TRUSTED = 98,
243 : GPG_ERR_CANCELED = 99,
244 : GPG_ERR_BAD_CA_CERT = 100,
245 : GPG_ERR_CERT_EXPIRED = 101,
246 : GPG_ERR_CERT_TOO_YOUNG = 102,
247 : GPG_ERR_UNSUPPORTED_CERT = 103,
248 : GPG_ERR_UNKNOWN_SEXP = 104,
249 : GPG_ERR_UNSUPPORTED_PROTECTION = 105,
250 : GPG_ERR_CORRUPTED_PROTECTION = 106,
251 : GPG_ERR_AMBIGUOUS_NAME = 107,
252 : GPG_ERR_CARD = 108,
253 : GPG_ERR_CARD_RESET = 109,
254 : GPG_ERR_CARD_REMOVED = 110,
255 : GPG_ERR_INV_CARD = 111,
256 : GPG_ERR_CARD_NOT_PRESENT = 112,
257 : GPG_ERR_NO_PKCS15_APP = 113,
258 : GPG_ERR_NOT_CONFIRMED = 114,
259 : GPG_ERR_CONFIGURATION = 115,
260 : GPG_ERR_NO_POLICY_MATCH = 116,
261 : GPG_ERR_INV_INDEX = 117,
262 : GPG_ERR_INV_ID = 118,
263 : GPG_ERR_NO_SCDAEMON = 119,
264 : GPG_ERR_SCDAEMON = 120,
265 : GPG_ERR_UNSUPPORTED_PROTOCOL = 121,
266 : GPG_ERR_BAD_PIN_METHOD = 122,
267 : GPG_ERR_CARD_NOT_INITIALIZED = 123,
268 : GPG_ERR_UNSUPPORTED_OPERATION = 124,
269 : GPG_ERR_WRONG_KEY_USAGE = 125,
270 : GPG_ERR_NOTHING_FOUND = 126,
271 : GPG_ERR_WRONG_BLOB_TYPE = 127,
272 : GPG_ERR_MISSING_VALUE = 128,
273 : GPG_ERR_HARDWARE = 129,
274 : GPG_ERR_PIN_BLOCKED = 130,
275 : GPG_ERR_USE_CONDITIONS = 131,
276 : GPG_ERR_PIN_NOT_SYNCED = 132,
277 : GPG_ERR_INV_CRL = 133,
278 : GPG_ERR_BAD_BER = 134,
279 : GPG_ERR_INV_BER = 135,
280 : GPG_ERR_ELEMENT_NOT_FOUND = 136,
281 : GPG_ERR_IDENTIFIER_NOT_FOUND = 137,
282 : GPG_ERR_INV_TAG = 138,
283 : GPG_ERR_INV_LENGTH = 139,
284 : GPG_ERR_INV_KEYINFO = 140,
285 : GPG_ERR_UNEXPECTED_TAG = 141,
286 : GPG_ERR_NOT_DER_ENCODED = 142,
287 : GPG_ERR_NO_CMS_OBJ = 143,
288 : GPG_ERR_INV_CMS_OBJ = 144,
289 : GPG_ERR_UNKNOWN_CMS_OBJ = 145,
290 : GPG_ERR_UNSUPPORTED_CMS_OBJ = 146,
291 : GPG_ERR_UNSUPPORTED_ENCODING = 147,
292 : GPG_ERR_UNSUPPORTED_CMS_VERSION = 148,
293 : GPG_ERR_UNKNOWN_ALGORITHM = 149,
294 : GPG_ERR_INV_ENGINE = 150,
295 : GPG_ERR_PUBKEY_NOT_TRUSTED = 151,
296 : GPG_ERR_DECRYPT_FAILED = 152,
297 : GPG_ERR_KEY_EXPIRED = 153,
298 : GPG_ERR_SIG_EXPIRED = 154,
299 : GPG_ERR_ENCODING_PROBLEM = 155,
300 : GPG_ERR_INV_STATE = 156,
301 : GPG_ERR_DUP_VALUE = 157,
302 : GPG_ERR_MISSING_ACTION = 158,
303 : GPG_ERR_MODULE_NOT_FOUND = 159,
304 : GPG_ERR_INV_OID_STRING = 160,
305 : GPG_ERR_INV_TIME = 161,
306 : GPG_ERR_INV_CRL_OBJ = 162,
307 : GPG_ERR_UNSUPPORTED_CRL_VERSION = 163,
308 : GPG_ERR_INV_CERT_OBJ = 164,
309 : GPG_ERR_UNKNOWN_NAME = 165,
310 : GPG_ERR_LOCALE_PROBLEM = 166,
311 : GPG_ERR_NOT_LOCKED = 167,
312 : GPG_ERR_PROTOCOL_VIOLATION = 168,
313 : GPG_ERR_INV_MAC = 169,
314 : GPG_ERR_INV_REQUEST = 170,
315 : GPG_ERR_UNKNOWN_EXTN = 171,
316 : GPG_ERR_UNKNOWN_CRIT_EXTN = 172,
317 : GPG_ERR_LOCKED = 173,
318 : GPG_ERR_UNKNOWN_OPTION = 174,
319 : GPG_ERR_UNKNOWN_COMMAND = 175,
320 : GPG_ERR_NOT_OPERATIONAL = 176,
321 : GPG_ERR_NO_PASSPHRASE = 177,
322 : GPG_ERR_NO_PIN = 178,
323 : GPG_ERR_NOT_ENABLED = 179,
324 : GPG_ERR_NO_ENGINE = 180,
325 : GPG_ERR_MISSING_KEY = 181,
326 : GPG_ERR_TOO_MANY = 182,
327 : GPG_ERR_LIMIT_REACHED = 183,
328 : GPG_ERR_NOT_INITIALIZED = 184,
329 : GPG_ERR_MISSING_ISSUER_CERT = 185,
330 : GPG_ERR_NO_KEYSERVER = 186,
331 : GPG_ERR_INV_CURVE = 187,
332 : GPG_ERR_UNKNOWN_CURVE = 188,
333 : GPG_ERR_DUP_KEY = 189,
334 : GPG_ERR_AMBIGUOUS = 190,
335 : GPG_ERR_NO_CRYPT_CTX = 191,
336 : GPG_ERR_WRONG_CRYPT_CTX = 192,
337 : GPG_ERR_BAD_CRYPT_CTX = 193,
338 : GPG_ERR_CRYPT_CTX_CONFLICT = 194,
339 : GPG_ERR_BROKEN_PUBKEY = 195,
340 : GPG_ERR_BROKEN_SECKEY = 196,
341 : GPG_ERR_MAC_ALGO = 197,
342 : GPG_ERR_FULLY_CANCELED = 198,
343 : GPG_ERR_UNFINISHED = 199,
344 : GPG_ERR_BUFFER_TOO_SHORT = 200,
345 : GPG_ERR_SEXP_INV_LEN_SPEC = 201,
346 : GPG_ERR_SEXP_STRING_TOO_LONG = 202,
347 : GPG_ERR_SEXP_UNMATCHED_PAREN = 203,
348 : GPG_ERR_SEXP_NOT_CANONICAL = 204,
349 : GPG_ERR_SEXP_BAD_CHARACTER = 205,
350 : GPG_ERR_SEXP_BAD_QUOTATION = 206,
351 : GPG_ERR_SEXP_ZERO_PREFIX = 207,
352 : GPG_ERR_SEXP_NESTED_DH = 208,
353 : GPG_ERR_SEXP_UNMATCHED_DH = 209,
354 : GPG_ERR_SEXP_UNEXPECTED_PUNC = 210,
355 : GPG_ERR_SEXP_BAD_HEX_CHAR = 211,
356 : GPG_ERR_SEXP_ODD_HEX_NUMBERS = 212,
357 : GPG_ERR_SEXP_BAD_OCT_CHAR = 213,
358 : GPG_ERR_SUBKEYS_EXP_OR_REV = 217,
359 : GPG_ERR_DB_CORRUPTED = 218,
360 : GPG_ERR_SERVER_FAILED = 219,
361 : GPG_ERR_NO_NAME = 220,
362 : GPG_ERR_NO_KEY = 221,
363 : GPG_ERR_LEGACY_KEY = 222,
364 : GPG_ERR_REQUEST_TOO_SHORT = 223,
365 : GPG_ERR_REQUEST_TOO_LONG = 224,
366 : GPG_ERR_OBJ_TERM_STATE = 225,
367 : GPG_ERR_NO_CERT_CHAIN = 226,
368 : GPG_ERR_CERT_TOO_LARGE = 227,
369 : GPG_ERR_INV_RECORD = 228,
370 : GPG_ERR_BAD_MAC = 229,
371 : GPG_ERR_UNEXPECTED_MSG = 230,
372 : GPG_ERR_COMPR_FAILED = 231,
373 : GPG_ERR_WOULD_WRAP = 232,
374 : GPG_ERR_FATAL_ALERT = 233,
375 : GPG_ERR_NO_CIPHER = 234,
376 : GPG_ERR_MISSING_CLIENT_CERT = 235,
377 : GPG_ERR_CLOSE_NOTIFY = 236,
378 : GPG_ERR_TICKET_EXPIRED = 237,
379 : GPG_ERR_BAD_TICKET = 238,
380 : GPG_ERR_UNKNOWN_IDENTITY = 239,
381 : GPG_ERR_BAD_HS_CERT = 240,
382 : GPG_ERR_BAD_HS_CERT_REQ = 241,
383 : GPG_ERR_BAD_HS_CERT_VER = 242,
384 : GPG_ERR_BAD_HS_CHANGE_CIPHER = 243,
385 : GPG_ERR_BAD_HS_CLIENT_HELLO = 244,
386 : GPG_ERR_BAD_HS_SERVER_HELLO = 245,
387 : GPG_ERR_BAD_HS_SERVER_HELLO_DONE = 246,
388 : GPG_ERR_BAD_HS_FINISHED = 247,
389 : GPG_ERR_BAD_HS_SERVER_KEX = 248,
390 : GPG_ERR_BAD_HS_CLIENT_KEX = 249,
391 : GPG_ERR_BOGUS_STRING = 250,
392 : GPG_ERR_FORBIDDEN = 251,
393 : GPG_ERR_KEY_DISABLED = 252,
394 : GPG_ERR_KEY_ON_CARD = 253,
395 : GPG_ERR_INV_LOCK_OBJ = 254,
396 : GPG_ERR_TRUE = 255,
397 : GPG_ERR_FALSE = 256,
398 : GPG_ERR_ASS_GENERAL = 257,
399 : GPG_ERR_ASS_ACCEPT_FAILED = 258,
400 : GPG_ERR_ASS_CONNECT_FAILED = 259,
401 : GPG_ERR_ASS_INV_RESPONSE = 260,
402 : GPG_ERR_ASS_INV_VALUE = 261,
403 : GPG_ERR_ASS_INCOMPLETE_LINE = 262,
404 : GPG_ERR_ASS_LINE_TOO_LONG = 263,
405 : GPG_ERR_ASS_NESTED_COMMANDS = 264,
406 : GPG_ERR_ASS_NO_DATA_CB = 265,
407 : GPG_ERR_ASS_NO_INQUIRE_CB = 266,
408 : GPG_ERR_ASS_NOT_A_SERVER = 267,
409 : GPG_ERR_ASS_NOT_A_CLIENT = 268,
410 : GPG_ERR_ASS_SERVER_START = 269,
411 : GPG_ERR_ASS_READ_ERROR = 270,
412 : GPG_ERR_ASS_WRITE_ERROR = 271,
413 : GPG_ERR_ASS_TOO_MUCH_DATA = 273,
414 : GPG_ERR_ASS_UNEXPECTED_CMD = 274,
415 : GPG_ERR_ASS_UNKNOWN_CMD = 275,
416 : GPG_ERR_ASS_SYNTAX = 276,
417 : GPG_ERR_ASS_CANCELED = 277,
418 : GPG_ERR_ASS_NO_INPUT = 278,
419 : GPG_ERR_ASS_NO_OUTPUT = 279,
420 : GPG_ERR_ASS_PARAMETER = 280,
421 : GPG_ERR_ASS_UNKNOWN_INQUIRE = 281,
422 : GPG_ERR_ENGINE_TOO_OLD = 300,
423 : GPG_ERR_WINDOW_TOO_SMALL = 301,
424 : GPG_ERR_WINDOW_TOO_LARGE = 302,
425 : GPG_ERR_MISSING_ENVVAR = 303,
426 : GPG_ERR_USER_ID_EXISTS = 304,
427 : GPG_ERR_NAME_EXISTS = 305,
428 : GPG_ERR_DUP_NAME = 306,
429 : GPG_ERR_TOO_YOUNG = 307,
430 : GPG_ERR_TOO_OLD = 308,
431 : GPG_ERR_UNKNOWN_FLAG = 309,
432 : GPG_ERR_INV_ORDER = 310,
433 : GPG_ERR_ALREADY_FETCHED = 311,
434 : GPG_ERR_TRY_LATER = 312,
435 : GPG_ERR_WRONG_NAME = 313,
436 : GPG_ERR_NO_AUTH = 314,
437 : GPG_ERR_BAD_AUTH = 315,
438 : GPG_ERR_NO_KEYBOXD = 316,
439 : GPG_ERR_KEYBOXD = 317,
440 : GPG_ERR_NO_SERVICE = 318,
441 : GPG_ERR_SERVICE = 319,
442 : GPG_ERR_SYSTEM_BUG = 666,
443 : GPG_ERR_DNS_UNKNOWN = 711,
444 : GPG_ERR_DNS_SECTION = 712,
445 : GPG_ERR_DNS_ADDRESS = 713,
446 : GPG_ERR_DNS_NO_QUERY = 714,
447 : GPG_ERR_DNS_NO_ANSWER = 715,
448 : GPG_ERR_DNS_CLOSED = 716,
449 : GPG_ERR_DNS_VERIFY = 717,
450 : GPG_ERR_DNS_TIMEOUT = 718,
451 : GPG_ERR_LDAP_GENERAL = 721,
452 : GPG_ERR_LDAP_ATTR_GENERAL = 722,
453 : GPG_ERR_LDAP_NAME_GENERAL = 723,
454 : GPG_ERR_LDAP_SECURITY_GENERAL = 724,
455 : GPG_ERR_LDAP_SERVICE_GENERAL = 725,
456 : GPG_ERR_LDAP_UPDATE_GENERAL = 726,
457 : GPG_ERR_LDAP_E_GENERAL = 727,
458 : GPG_ERR_LDAP_X_GENERAL = 728,
459 : GPG_ERR_LDAP_OTHER_GENERAL = 729,
460 : GPG_ERR_LDAP_X_CONNECTING = 750,
461 : GPG_ERR_LDAP_REFERRAL_LIMIT = 751,
462 : GPG_ERR_LDAP_CLIENT_LOOP = 752,
463 : GPG_ERR_LDAP_NO_RESULTS = 754,
464 : GPG_ERR_LDAP_CONTROL_NOT_FOUND = 755,
465 : GPG_ERR_LDAP_NOT_SUPPORTED = 756,
466 : GPG_ERR_LDAP_CONNECT = 757,
467 : GPG_ERR_LDAP_NO_MEMORY = 758,
468 : GPG_ERR_LDAP_PARAM = 759,
469 : GPG_ERR_LDAP_USER_CANCELLED = 760,
470 : GPG_ERR_LDAP_FILTER = 761,
471 : GPG_ERR_LDAP_AUTH_UNKNOWN = 762,
472 : GPG_ERR_LDAP_TIMEOUT = 763,
473 : GPG_ERR_LDAP_DECODING = 764,
474 : GPG_ERR_LDAP_ENCODING = 765,
475 : GPG_ERR_LDAP_LOCAL = 766,
476 : GPG_ERR_LDAP_SERVER_DOWN = 767,
477 : GPG_ERR_LDAP_SUCCESS = 768,
478 : GPG_ERR_LDAP_OPERATIONS = 769,
479 : GPG_ERR_LDAP_PROTOCOL = 770,
480 : GPG_ERR_LDAP_TIMELIMIT = 771,
481 : GPG_ERR_LDAP_SIZELIMIT = 772,
482 : GPG_ERR_LDAP_COMPARE_FALSE = 773,
483 : GPG_ERR_LDAP_COMPARE_TRUE = 774,
484 : GPG_ERR_LDAP_UNSUPPORTED_AUTH = 775,
485 : GPG_ERR_LDAP_STRONG_AUTH_RQRD = 776,
486 : GPG_ERR_LDAP_PARTIAL_RESULTS = 777,
487 : GPG_ERR_LDAP_REFERRAL = 778,
488 : GPG_ERR_LDAP_ADMINLIMIT = 779,
489 : GPG_ERR_LDAP_UNAVAIL_CRIT_EXTN = 780,
490 : GPG_ERR_LDAP_CONFIDENT_RQRD = 781,
491 : GPG_ERR_LDAP_SASL_BIND_INPROG = 782,
492 : GPG_ERR_LDAP_NO_SUCH_ATTRIBUTE = 784,
493 : GPG_ERR_LDAP_UNDEFINED_TYPE = 785,
494 : GPG_ERR_LDAP_BAD_MATCHING = 786,
495 : GPG_ERR_LDAP_CONST_VIOLATION = 787,
496 : GPG_ERR_LDAP_TYPE_VALUE_EXISTS = 788,
497 : GPG_ERR_LDAP_INV_SYNTAX = 789,
498 : GPG_ERR_LDAP_NO_SUCH_OBJ = 800,
499 : GPG_ERR_LDAP_ALIAS_PROBLEM = 801,
500 : GPG_ERR_LDAP_INV_DN_SYNTAX = 802,
501 : GPG_ERR_LDAP_IS_LEAF = 803,
502 : GPG_ERR_LDAP_ALIAS_DEREF = 804,
503 : GPG_ERR_LDAP_X_PROXY_AUTH_FAIL = 815,
504 : GPG_ERR_LDAP_BAD_AUTH = 816,
505 : GPG_ERR_LDAP_INV_CREDENTIALS = 817,
506 : GPG_ERR_LDAP_INSUFFICIENT_ACC = 818,
507 : GPG_ERR_LDAP_BUSY = 819,
508 : GPG_ERR_LDAP_UNAVAILABLE = 820,
509 : GPG_ERR_LDAP_UNWILL_TO_PERFORM = 821,
510 : GPG_ERR_LDAP_LOOP_DETECT = 822,
511 : GPG_ERR_LDAP_NAMING_VIOLATION = 832,
512 : GPG_ERR_LDAP_OBJ_CLS_VIOLATION = 833,
513 : GPG_ERR_LDAP_NOT_ALLOW_NONLEAF = 834,
514 : GPG_ERR_LDAP_NOT_ALLOW_ON_RDN = 835,
515 : GPG_ERR_LDAP_ALREADY_EXISTS = 836,
516 : GPG_ERR_LDAP_NO_OBJ_CLASS_MODS = 837,
517 : GPG_ERR_LDAP_RESULTS_TOO_LARGE = 838,
518 : GPG_ERR_LDAP_AFFECTS_MULT_DSAS = 839,
519 : GPG_ERR_LDAP_VLV = 844,
520 : GPG_ERR_LDAP_OTHER = 848,
521 : GPG_ERR_LDAP_CUP_RESOURCE_LIMIT = 881,
522 : GPG_ERR_LDAP_CUP_SEC_VIOLATION = 882,
523 : GPG_ERR_LDAP_CUP_INV_DATA = 883,
524 : GPG_ERR_LDAP_CUP_UNSUP_SCHEME = 884,
525 : GPG_ERR_LDAP_CUP_RELOAD = 885,
526 : GPG_ERR_LDAP_CANCELLED = 886,
527 : GPG_ERR_LDAP_NO_SUCH_OPERATION = 887,
528 : GPG_ERR_LDAP_TOO_LATE = 888,
529 : GPG_ERR_LDAP_CANNOT_CANCEL = 889,
530 : GPG_ERR_LDAP_ASSERTION_FAILED = 890,
531 : GPG_ERR_LDAP_PROX_AUTH_DENIED = 891,
532 : GPG_ERR_USER_1 = 1024,
533 : GPG_ERR_USER_2 = 1025,
534 : GPG_ERR_USER_3 = 1026,
535 : GPG_ERR_USER_4 = 1027,
536 : GPG_ERR_USER_5 = 1028,
537 : GPG_ERR_USER_6 = 1029,
538 : GPG_ERR_USER_7 = 1030,
539 : GPG_ERR_USER_8 = 1031,
540 : GPG_ERR_USER_9 = 1032,
541 : GPG_ERR_USER_10 = 1033,
542 : GPG_ERR_USER_11 = 1034,
543 : GPG_ERR_USER_12 = 1035,
544 : GPG_ERR_USER_13 = 1036,
545 : GPG_ERR_USER_14 = 1037,
546 : GPG_ERR_USER_15 = 1038,
547 : GPG_ERR_USER_16 = 1039,
548 : GPG_ERR_SQL_OK = 1500,
549 : GPG_ERR_SQL_ERROR = 1501,
550 : GPG_ERR_SQL_INTERNAL = 1502,
551 : GPG_ERR_SQL_PERM = 1503,
552 : GPG_ERR_SQL_ABORT = 1504,
553 : GPG_ERR_SQL_BUSY = 1505,
554 : GPG_ERR_SQL_LOCKED = 1506,
555 : GPG_ERR_SQL_NOMEM = 1507,
556 : GPG_ERR_SQL_READONLY = 1508,
557 : GPG_ERR_SQL_INTERRUPT = 1509,
558 : GPG_ERR_SQL_IOERR = 1510,
559 : GPG_ERR_SQL_CORRUPT = 1511,
560 : GPG_ERR_SQL_NOTFOUND = 1512,
561 : GPG_ERR_SQL_FULL = 1513,
562 : GPG_ERR_SQL_CANTOPEN = 1514,
563 : GPG_ERR_SQL_PROTOCOL = 1515,
564 : GPG_ERR_SQL_EMPTY = 1516,
565 : GPG_ERR_SQL_SCHEMA = 1517,
566 : GPG_ERR_SQL_TOOBIG = 1518,
567 : GPG_ERR_SQL_CONSTRAINT = 1519,
568 : GPG_ERR_SQL_MISMATCH = 1520,
569 : GPG_ERR_SQL_MISUSE = 1521,
570 : GPG_ERR_SQL_NOLFS = 1522,
571 : GPG_ERR_SQL_AUTH = 1523,
572 : GPG_ERR_SQL_FORMAT = 1524,
573 : GPG_ERR_SQL_RANGE = 1525,
574 : GPG_ERR_SQL_NOTADB = 1526,
575 : GPG_ERR_SQL_NOTICE = 1527,
576 : GPG_ERR_SQL_WARNING = 1528,
577 : GPG_ERR_SQL_ROW = 1600,
578 : GPG_ERR_SQL_DONE = 1601,
579 : GPG_ERR_MISSING_ERRNO = 16381,
580 : GPG_ERR_UNKNOWN_ERRNO = 16382,
581 : GPG_ERR_EOF = 16383,
582 :
583 : /* The following error codes are used to map system errors. */
584 : #define GPG_ERR_SYSTEM_ERROR (1 << 15)
585 : GPG_ERR_E2BIG = GPG_ERR_SYSTEM_ERROR | 0,
586 : GPG_ERR_EACCES = GPG_ERR_SYSTEM_ERROR | 1,
587 : GPG_ERR_EADDRINUSE = GPG_ERR_SYSTEM_ERROR | 2,
588 : GPG_ERR_EADDRNOTAVAIL = GPG_ERR_SYSTEM_ERROR | 3,
589 : GPG_ERR_EADV = GPG_ERR_SYSTEM_ERROR | 4,
590 : GPG_ERR_EAFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 5,
591 : GPG_ERR_EAGAIN = GPG_ERR_SYSTEM_ERROR | 6,
592 : GPG_ERR_EALREADY = GPG_ERR_SYSTEM_ERROR | 7,
593 : GPG_ERR_EAUTH = GPG_ERR_SYSTEM_ERROR | 8,
594 : GPG_ERR_EBACKGROUND = GPG_ERR_SYSTEM_ERROR | 9,
595 : GPG_ERR_EBADE = GPG_ERR_SYSTEM_ERROR | 10,
596 : GPG_ERR_EBADF = GPG_ERR_SYSTEM_ERROR | 11,
597 : GPG_ERR_EBADFD = GPG_ERR_SYSTEM_ERROR | 12,
598 : GPG_ERR_EBADMSG = GPG_ERR_SYSTEM_ERROR | 13,
599 : GPG_ERR_EBADR = GPG_ERR_SYSTEM_ERROR | 14,
600 : GPG_ERR_EBADRPC = GPG_ERR_SYSTEM_ERROR | 15,
601 : GPG_ERR_EBADRQC = GPG_ERR_SYSTEM_ERROR | 16,
602 : GPG_ERR_EBADSLT = GPG_ERR_SYSTEM_ERROR | 17,
603 : GPG_ERR_EBFONT = GPG_ERR_SYSTEM_ERROR | 18,
604 : GPG_ERR_EBUSY = GPG_ERR_SYSTEM_ERROR | 19,
605 : GPG_ERR_ECANCELED = GPG_ERR_SYSTEM_ERROR | 20,
606 : GPG_ERR_ECHILD = GPG_ERR_SYSTEM_ERROR | 21,
607 : GPG_ERR_ECHRNG = GPG_ERR_SYSTEM_ERROR | 22,
608 : GPG_ERR_ECOMM = GPG_ERR_SYSTEM_ERROR | 23,
609 : GPG_ERR_ECONNABORTED = GPG_ERR_SYSTEM_ERROR | 24,
610 : GPG_ERR_ECONNREFUSED = GPG_ERR_SYSTEM_ERROR | 25,
611 : GPG_ERR_ECONNRESET = GPG_ERR_SYSTEM_ERROR | 26,
612 : GPG_ERR_ED = GPG_ERR_SYSTEM_ERROR | 27,
613 : GPG_ERR_EDEADLK = GPG_ERR_SYSTEM_ERROR | 28,
614 : GPG_ERR_EDEADLOCK = GPG_ERR_SYSTEM_ERROR | 29,
615 : GPG_ERR_EDESTADDRREQ = GPG_ERR_SYSTEM_ERROR | 30,
616 : GPG_ERR_EDIED = GPG_ERR_SYSTEM_ERROR | 31,
617 : GPG_ERR_EDOM = GPG_ERR_SYSTEM_ERROR | 32,
618 : GPG_ERR_EDOTDOT = GPG_ERR_SYSTEM_ERROR | 33,
619 : GPG_ERR_EDQUOT = GPG_ERR_SYSTEM_ERROR | 34,
620 : GPG_ERR_EEXIST = GPG_ERR_SYSTEM_ERROR | 35,
621 : GPG_ERR_EFAULT = GPG_ERR_SYSTEM_ERROR | 36,
622 : GPG_ERR_EFBIG = GPG_ERR_SYSTEM_ERROR | 37,
623 : GPG_ERR_EFTYPE = GPG_ERR_SYSTEM_ERROR | 38,
624 : GPG_ERR_EGRATUITOUS = GPG_ERR_SYSTEM_ERROR | 39,
625 : GPG_ERR_EGREGIOUS = GPG_ERR_SYSTEM_ERROR | 40,
626 : GPG_ERR_EHOSTDOWN = GPG_ERR_SYSTEM_ERROR | 41,
627 : GPG_ERR_EHOSTUNREACH = GPG_ERR_SYSTEM_ERROR | 42,
628 : GPG_ERR_EIDRM = GPG_ERR_SYSTEM_ERROR | 43,
629 : GPG_ERR_EIEIO = GPG_ERR_SYSTEM_ERROR | 44,
630 : GPG_ERR_EILSEQ = GPG_ERR_SYSTEM_ERROR | 45,
631 : GPG_ERR_EINPROGRESS = GPG_ERR_SYSTEM_ERROR | 46,
632 : GPG_ERR_EINTR = GPG_ERR_SYSTEM_ERROR | 47,
633 : GPG_ERR_EINVAL = GPG_ERR_SYSTEM_ERROR | 48,
634 : GPG_ERR_EIO = GPG_ERR_SYSTEM_ERROR | 49,
635 : GPG_ERR_EISCONN = GPG_ERR_SYSTEM_ERROR | 50,
636 : GPG_ERR_EISDIR = GPG_ERR_SYSTEM_ERROR | 51,
637 : GPG_ERR_EISNAM = GPG_ERR_SYSTEM_ERROR | 52,
638 : GPG_ERR_EL2HLT = GPG_ERR_SYSTEM_ERROR | 53,
639 : GPG_ERR_EL2NSYNC = GPG_ERR_SYSTEM_ERROR | 54,
640 : GPG_ERR_EL3HLT = GPG_ERR_SYSTEM_ERROR | 55,
641 : GPG_ERR_EL3RST = GPG_ERR_SYSTEM_ERROR | 56,
642 : GPG_ERR_ELIBACC = GPG_ERR_SYSTEM_ERROR | 57,
643 : GPG_ERR_ELIBBAD = GPG_ERR_SYSTEM_ERROR | 58,
644 : GPG_ERR_ELIBEXEC = GPG_ERR_SYSTEM_ERROR | 59,
645 : GPG_ERR_ELIBMAX = GPG_ERR_SYSTEM_ERROR | 60,
646 : GPG_ERR_ELIBSCN = GPG_ERR_SYSTEM_ERROR | 61,
647 : GPG_ERR_ELNRNG = GPG_ERR_SYSTEM_ERROR | 62,
648 : GPG_ERR_ELOOP = GPG_ERR_SYSTEM_ERROR | 63,
649 : GPG_ERR_EMEDIUMTYPE = GPG_ERR_SYSTEM_ERROR | 64,
650 : GPG_ERR_EMFILE = GPG_ERR_SYSTEM_ERROR | 65,
651 : GPG_ERR_EMLINK = GPG_ERR_SYSTEM_ERROR | 66,
652 : GPG_ERR_EMSGSIZE = GPG_ERR_SYSTEM_ERROR | 67,
653 : GPG_ERR_EMULTIHOP = GPG_ERR_SYSTEM_ERROR | 68,
654 : GPG_ERR_ENAMETOOLONG = GPG_ERR_SYSTEM_ERROR | 69,
655 : GPG_ERR_ENAVAIL = GPG_ERR_SYSTEM_ERROR | 70,
656 : GPG_ERR_ENEEDAUTH = GPG_ERR_SYSTEM_ERROR | 71,
657 : GPG_ERR_ENETDOWN = GPG_ERR_SYSTEM_ERROR | 72,
658 : GPG_ERR_ENETRESET = GPG_ERR_SYSTEM_ERROR | 73,
659 : GPG_ERR_ENETUNREACH = GPG_ERR_SYSTEM_ERROR | 74,
660 : GPG_ERR_ENFILE = GPG_ERR_SYSTEM_ERROR | 75,
661 : GPG_ERR_ENOANO = GPG_ERR_SYSTEM_ERROR | 76,
662 : GPG_ERR_ENOBUFS = GPG_ERR_SYSTEM_ERROR | 77,
663 : GPG_ERR_ENOCSI = GPG_ERR_SYSTEM_ERROR | 78,
664 : GPG_ERR_ENODATA = GPG_ERR_SYSTEM_ERROR | 79,
665 : GPG_ERR_ENODEV = GPG_ERR_SYSTEM_ERROR | 80,
666 : GPG_ERR_ENOENT = GPG_ERR_SYSTEM_ERROR | 81,
667 : GPG_ERR_ENOEXEC = GPG_ERR_SYSTEM_ERROR | 82,
668 : GPG_ERR_ENOLCK = GPG_ERR_SYSTEM_ERROR | 83,
669 : GPG_ERR_ENOLINK = GPG_ERR_SYSTEM_ERROR | 84,
670 : GPG_ERR_ENOMEDIUM = GPG_ERR_SYSTEM_ERROR | 85,
671 : GPG_ERR_ENOMEM = GPG_ERR_SYSTEM_ERROR | 86,
672 : GPG_ERR_ENOMSG = GPG_ERR_SYSTEM_ERROR | 87,
673 : GPG_ERR_ENONET = GPG_ERR_SYSTEM_ERROR | 88,
674 : GPG_ERR_ENOPKG = GPG_ERR_SYSTEM_ERROR | 89,
675 : GPG_ERR_ENOPROTOOPT = GPG_ERR_SYSTEM_ERROR | 90,
676 : GPG_ERR_ENOSPC = GPG_ERR_SYSTEM_ERROR | 91,
677 : GPG_ERR_ENOSR = GPG_ERR_SYSTEM_ERROR | 92,
678 : GPG_ERR_ENOSTR = GPG_ERR_SYSTEM_ERROR | 93,
679 : GPG_ERR_ENOSYS = GPG_ERR_SYSTEM_ERROR | 94,
680 : GPG_ERR_ENOTBLK = GPG_ERR_SYSTEM_ERROR | 95,
681 : GPG_ERR_ENOTCONN = GPG_ERR_SYSTEM_ERROR | 96,
682 : GPG_ERR_ENOTDIR = GPG_ERR_SYSTEM_ERROR | 97,
683 : GPG_ERR_ENOTEMPTY = GPG_ERR_SYSTEM_ERROR | 98,
684 : GPG_ERR_ENOTNAM = GPG_ERR_SYSTEM_ERROR | 99,
685 : GPG_ERR_ENOTSOCK = GPG_ERR_SYSTEM_ERROR | 100,
686 : GPG_ERR_ENOTSUP = GPG_ERR_SYSTEM_ERROR | 101,
687 : GPG_ERR_ENOTTY = GPG_ERR_SYSTEM_ERROR | 102,
688 : GPG_ERR_ENOTUNIQ = GPG_ERR_SYSTEM_ERROR | 103,
689 : GPG_ERR_ENXIO = GPG_ERR_SYSTEM_ERROR | 104,
690 : GPG_ERR_EOPNOTSUPP = GPG_ERR_SYSTEM_ERROR | 105,
691 : GPG_ERR_EOVERFLOW = GPG_ERR_SYSTEM_ERROR | 106,
692 : GPG_ERR_EPERM = GPG_ERR_SYSTEM_ERROR | 107,
693 : GPG_ERR_EPFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 108,
694 : GPG_ERR_EPIPE = GPG_ERR_SYSTEM_ERROR | 109,
695 : GPG_ERR_EPROCLIM = GPG_ERR_SYSTEM_ERROR | 110,
696 : GPG_ERR_EPROCUNAVAIL = GPG_ERR_SYSTEM_ERROR | 111,
697 : GPG_ERR_EPROGMISMATCH = GPG_ERR_SYSTEM_ERROR | 112,
698 : GPG_ERR_EPROGUNAVAIL = GPG_ERR_SYSTEM_ERROR | 113,
699 : GPG_ERR_EPROTO = GPG_ERR_SYSTEM_ERROR | 114,
700 : GPG_ERR_EPROTONOSUPPORT = GPG_ERR_SYSTEM_ERROR | 115,
701 : GPG_ERR_EPROTOTYPE = GPG_ERR_SYSTEM_ERROR | 116,
702 : GPG_ERR_ERANGE = GPG_ERR_SYSTEM_ERROR | 117,
703 : GPG_ERR_EREMCHG = GPG_ERR_SYSTEM_ERROR | 118,
704 : GPG_ERR_EREMOTE = GPG_ERR_SYSTEM_ERROR | 119,
705 : GPG_ERR_EREMOTEIO = GPG_ERR_SYSTEM_ERROR | 120,
706 : GPG_ERR_ERESTART = GPG_ERR_SYSTEM_ERROR | 121,
707 : GPG_ERR_EROFS = GPG_ERR_SYSTEM_ERROR | 122,
708 : GPG_ERR_ERPCMISMATCH = GPG_ERR_SYSTEM_ERROR | 123,
709 : GPG_ERR_ESHUTDOWN = GPG_ERR_SYSTEM_ERROR | 124,
710 : GPG_ERR_ESOCKTNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 125,
711 : GPG_ERR_ESPIPE = GPG_ERR_SYSTEM_ERROR | 126,
712 : GPG_ERR_ESRCH = GPG_ERR_SYSTEM_ERROR | 127,
713 : GPG_ERR_ESRMNT = GPG_ERR_SYSTEM_ERROR | 128,
714 : GPG_ERR_ESTALE = GPG_ERR_SYSTEM_ERROR | 129,
715 : GPG_ERR_ESTRPIPE = GPG_ERR_SYSTEM_ERROR | 130,
716 : GPG_ERR_ETIME = GPG_ERR_SYSTEM_ERROR | 131,
717 : GPG_ERR_ETIMEDOUT = GPG_ERR_SYSTEM_ERROR | 132,
718 : GPG_ERR_ETOOMANYREFS = GPG_ERR_SYSTEM_ERROR | 133,
719 : GPG_ERR_ETXTBSY = GPG_ERR_SYSTEM_ERROR | 134,
720 : GPG_ERR_EUCLEAN = GPG_ERR_SYSTEM_ERROR | 135,
721 : GPG_ERR_EUNATCH = GPG_ERR_SYSTEM_ERROR | 136,
722 : GPG_ERR_EUSERS = GPG_ERR_SYSTEM_ERROR | 137,
723 : GPG_ERR_EWOULDBLOCK = GPG_ERR_SYSTEM_ERROR | 138,
724 : GPG_ERR_EXDEV = GPG_ERR_SYSTEM_ERROR | 139,
725 : GPG_ERR_EXFULL = GPG_ERR_SYSTEM_ERROR | 140,
726 :
727 : /* This is one more than the largest allowed entry. */
728 : GPG_ERR_CODE_DIM = 65536
729 : } gpg_err_code_t;
730 :
731 :
732 : /* The error value type gpg_error_t. */
733 :
734 : /* We would really like to use bit-fields in a struct, but using
735 : * structs as return values can cause binary compatibility issues, in
736 : * particular if you want to do it efficiently (also see
737 : * -freg-struct-return option to GCC). */
738 : typedef unsigned int gpg_error_t;
739 :
740 : /* We use the lowest 16 bits of gpg_error_t for error codes. The 16th
741 : * bit indicates system errors. */
742 : #define GPG_ERR_CODE_MASK (GPG_ERR_CODE_DIM - 1)
743 :
744 : /* Bits 17 to 24 are reserved. */
745 :
746 : /* We use the upper 7 bits of gpg_error_t for error sources. */
747 : #define GPG_ERR_SOURCE_MASK (GPG_ERR_SOURCE_DIM - 1)
748 : #define GPG_ERR_SOURCE_SHIFT 24
749 :
750 : /* The highest bit is reserved. It shouldn't be used to prevent
751 : * potential negative numbers when transmitting error values as
752 : * text. */
753 :
754 :
755 : /*
756 : * GCC feature test.
757 : */
758 : #if __GNUC__
759 : # define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \
760 : + __GNUC_MINOR__ * 100 \
761 : + __GNUC_PATCHLEVEL__)
762 : #else
763 : # define _GPG_ERR_GCC_VERSION 0
764 : #endif
765 :
766 : #undef _GPG_ERR_HAVE_CONSTRUCTOR
767 : #if _GPG_ERR_GCC_VERSION > 30100
768 : # define _GPG_ERR_CONSTRUCTOR __attribute__ ((__constructor__))
769 : # define _GPG_ERR_HAVE_CONSTRUCTOR
770 : #else
771 : # define _GPG_ERR_CONSTRUCTOR
772 : #endif
773 :
774 : #define GPGRT_GCC_VERSION _GPG_ERR_GCC_VERSION
775 :
776 : #if _GPG_ERR_GCC_VERSION >= 29200
777 : # define _GPGRT__RESTRICT __restrict__
778 : #else
779 : # define _GPGRT__RESTRICT
780 : #endif
781 :
782 : /* The noreturn attribute. */
783 : #if _GPG_ERR_GCC_VERSION >= 20500
784 : # define GPGRT_ATTR_NORETURN __attribute__ ((__noreturn__))
785 : #else
786 : # define GPGRT_ATTR_NORETURN
787 : #endif
788 :
789 : /* The printf attributes. */
790 : #if _GPG_ERR_GCC_VERSION >= 40400
791 : # define GPGRT_ATTR_PRINTF(f, a) \
792 : __attribute__ ((format(__gnu_printf__,f,a)))
793 : # define GPGRT_ATTR_NR_PRINTF(f, a) \
794 : __attribute__ ((__noreturn__, format(__gnu_printf__,f,a)))
795 : #elif _GPG_ERR_GCC_VERSION >= 20500
796 : # define GPGRT_ATTR_PRINTF(f, a) \
797 : __attribute__ ((format(printf,f,a)))
798 : # define GPGRT_ATTR_NR_PRINTF(f, a) \
799 : __attribute__ ((__noreturn__, format(printf,f,a)))
800 : #else
801 : # define GPGRT_ATTR_PRINTF(f, a)
802 : # define GPGRT_ATTR_NR_PRINTF(f, a)
803 : #endif
804 : #if _GPG_ERR_GCC_VERSION >= 20800
805 : # define GPGRT_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a)))
806 : #else
807 : # define GPGRT_ATTR_FORMAT_ARG(a)
808 : #endif
809 :
810 : /* The sentinel attribute. */
811 : #if _GPG_ERR_GCC_VERSION >= 40000
812 : # define GPGRT_ATTR_SENTINEL(a) __attribute__ ((sentinel(a)))
813 : #else
814 : # define GPGRT_ATTR_SENTINEL(a)
815 : #endif
816 :
817 : /* The used and unused attributes.
818 : * I am not sure since when the unused attribute is really supported.
819 : * In any case it it only needed for gcc versions which print a
820 : * warning. Thus let us require gcc >= 3.5. */
821 : #if _GPG_ERR_GCC_VERSION >= 40000
822 : # define GPGRT_ATTR_USED __attribute__ ((used))
823 : #else
824 : # define GPGRT_ATTR_USED
825 : #endif
826 : #if _GPG_ERR_GCC_VERSION >= 30500
827 : # define GPGRT_ATTR_UNUSED __attribute__ ((unused))
828 : #else
829 : # define GPGRT_ATTR_UNUSED
830 : #endif
831 :
832 : /* The deprecated attribute. */
833 : #if _GPG_ERR_GCC_VERSION >= 30100
834 : # define GPGRT_ATTR_DEPRECATED __attribute__ ((__deprecated__))
835 : #else
836 : # define GPGRT_ATTR_DEPRECATED
837 : #endif
838 :
839 : /* The pure attribute. */
840 : #if _GPG_ERR_GCC_VERSION >= 29600
841 : # define GPGRT_ATTR_PURE __attribute__ ((__pure__))
842 : #else
843 : # define GPGRT_ATTR_PURE
844 : #endif
845 :
846 : /* The malloc attribute. */
847 : #if _GPG_ERR_GCC_VERSION >= 30200
848 : # define GPGRT_ATTR_MALLOC __attribute__ ((__malloc__))
849 : #else
850 : # define GPGRT_ATTR_MALLOC
851 : #endif
852 :
853 : /* A macro defined if a GCC style __FUNCTION__ macro is available. */
854 : #undef GPGRT_HAVE_MACRO_FUNCTION
855 : #if _GPG_ERR_GCC_VERSION >= 20500
856 : # define GPGRT_HAVE_MACRO_FUNCTION 1
857 : #endif
858 :
859 : /* A macro defined if the pragma GCC push_options is available. */
860 : #undef GPGRT_HAVE_PRAGMA_GCC_PUSH
861 : #if _GPG_ERR_GCC_VERSION >= 40400
862 : # define GPGRT_HAVE_PRAGMA_GCC_PUSH 1
863 : #endif
864 :
865 : /* Detect LeakSanitizer (LSan) support for GCC and Clang based on
866 : * whether AddressSanitizer (ASAN) is enabled via -fsanitize=address).
867 : * Note that -fsanitize=leak just affect the linker options which
868 : * cannot be detected here. In that case you have to define the
869 : * GPGRT_HAVE_LEAK_SANITIZER macro manually. */
870 : #ifdef __GNUC__
871 : # ifdef __SANITIZE_ADDRESS__
872 : # define GPGRT_HAVE_LEAK_SANITIZER
873 : # elif defined(__has_feature)
874 : # if __has_feature(address_sanitizer)
875 : # define GPGRT_HAVE_LEAK_SANITIZER
876 : # endif
877 : # endif
878 : #endif
879 :
880 :
881 : /* The new name for the inline macro. */
882 : #define GPGRT_INLINE GPG_ERR_INLINE
883 :
884 : #ifdef GPGRT_HAVE_LEAK_SANITIZER
885 : # include <sanitizer/lsan_interface.h>
886 : #endif
887 :
888 : /* Mark heap objects as non-leaked memory. */
889 : static GPGRT_INLINE void
890 : gpgrt_annotate_leaked_object (const void *p)
891 : {
892 : #ifdef GPGRT_HAVE_LEAK_SANITIZER
893 : __lsan_ignore_object(p);
894 : #else
895 : (void)p;
896 : #endif
897 : }
898 :
899 :
900 : /*
901 : * Initialization function.
902 : */
903 :
904 : /* Initialize the library. This function should be run early. */
905 : gpg_error_t gpg_err_init (void) _GPG_ERR_CONSTRUCTOR;
906 :
907 : /* If this is defined, the library is already initialized by the
908 : constructor and does not need to be initialized explicitely. */
909 : #undef GPG_ERR_INITIALIZED
910 : #ifdef _GPG_ERR_HAVE_CONSTRUCTOR
911 : # define GPG_ERR_INITIALIZED 1
912 : # define gpgrt_init() do { gpg_err_init (); } while (0)
913 : #else
914 : # define gpgrt_init() do { ; } while (0)
915 : #endif
916 :
917 : /* See the source on how to use the deinit function; it is usually not
918 : required. */
919 : void gpg_err_deinit (int mode);
920 :
921 : /* Register blocking system I/O clamping functions. */
922 : void gpgrt_set_syscall_clamp (void (*pre)(void), void (*post)(void));
923 :
924 : /* Get current I/O clamping functions. */
925 : void gpgrt_get_syscall_clamp (void (**r_pre)(void), void (**r_post)(void));
926 :
927 : /* Register a custom malloc/realloc/free function. */
928 : void gpgrt_set_alloc_func (void *(*f)(void *a, size_t n));
929 :
930 : /* Register an emergency cleanup handler. */
931 : void gpgrt_add_emergency_cleanup (void (*f)(void));
932 :
933 : /* Wrapper around abort to make sure emergency cleanups are run. */
934 : void gpgrt_abort (void) GPGRT_ATTR_NORETURN;
935 :
936 :
937 :
938 : /*
939 : * Constructor and accessor functions.
940 : */
941 :
942 : /* Construct an error value from an error code and source. Within a
943 : * subsystem, use gpg_error. */
944 : static GPG_ERR_INLINE gpg_error_t
945 : gpg_err_make (gpg_err_source_t source, gpg_err_code_t code)
946 : {
947 : return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
948 : : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
949 : | (code & GPG_ERR_CODE_MASK));
950 : }
951 :
952 :
953 : /* The user should define GPG_ERR_SOURCE_DEFAULT before including this
954 : * file to specify a default source for gpg_error. */
955 : #ifndef GPG_ERR_SOURCE_DEFAULT
956 : #define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_UNKNOWN
957 : #endif
958 :
959 : static GPG_ERR_INLINE gpg_error_t
960 : gpg_error (gpg_err_code_t code)
961 : {
962 : return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code);
963 : }
964 :
965 :
966 : /* Retrieve the error code from an error value. */
967 : static GPG_ERR_INLINE gpg_err_code_t
968 0 : gpg_err_code (gpg_error_t err)
969 : {
970 0 : return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
971 : }
972 :
973 :
974 : /* Retrieve the error source from an error value. */
975 : static GPG_ERR_INLINE gpg_err_source_t
976 0 : gpg_err_source (gpg_error_t err)
977 : {
978 0 : return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
979 : & GPG_ERR_SOURCE_MASK);
980 : }
981 :
982 :
983 : /* String functions. */
984 :
985 : /* Return a pointer to a string containing a description of the error
986 : * code in the error value ERR. This function is not thread-safe. */
987 : const char *gpg_strerror (gpg_error_t err);
988 :
989 : /* Return the error string for ERR in the user-supplied buffer BUF of
990 : * size BUFLEN. This function is, in contrast to gpg_strerror,
991 : * thread-safe if a thread-safe strerror_r() function is provided by
992 : * the system. If the function succeeds, 0 is returned and BUF
993 : * contains the string describing the error. If the buffer was not
994 : * large enough, ERANGE is returned and BUF contains as much of the
995 : * beginning of the error string as fits into the buffer. */
996 : int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
997 :
998 : /* Return a pointer to a string containing a description of the error
999 : * source in the error value ERR. */
1000 : const char *gpg_strsource (gpg_error_t err);
1001 :
1002 :
1003 : /*
1004 : * Mapping of system errors (errno).
1005 : */
1006 :
1007 : /* Retrieve the error code for the system error ERR. This returns
1008 : * GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
1009 : * this). */
1010 : gpg_err_code_t gpg_err_code_from_errno (int err);
1011 :
1012 : /* Retrieve the system error for the error code CODE. This returns 0
1013 : * if CODE is not a system error code. */
1014 : int gpg_err_code_to_errno (gpg_err_code_t code);
1015 :
1016 : /* Retrieve the error code directly from the ERRNO variable. This
1017 : * returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
1018 : * (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
1019 : gpg_err_code_t gpg_err_code_from_syserror (void);
1020 :
1021 : /* Mapper for SQLite primary error codes. */
1022 : static GPG_ERR_INLINE gpg_error_t
1023 : gpg_err_code_from_sqlite (int sqlres)
1024 : {
1025 : return sqlres? GPG_ERR_SQL_OK + (sqlres & 0xff) : 0;
1026 : }
1027 :
1028 :
1029 : /* Set the ERRNO variable. This function is the preferred way to set
1030 : * ERRNO due to peculiarities on WindowsCE. */
1031 : void gpg_err_set_errno (int err);
1032 :
1033 : /* Return or check the version. Both functions are identical. */
1034 : const char *gpgrt_check_version (const char *req_version);
1035 : const char *gpg_error_check_version (const char *req_version);
1036 :
1037 : /* System specific type definitions. */
1038 : #include <sys/types.h>
1039 :
1040 : typedef ssize_t gpgrt_ssize_t;
1041 :
1042 : typedef long gpgrt_off_t;
1043 :
1044 :
1045 :
1046 :
1047 : /* Self-documenting convenience functions. */
1048 :
1049 : static GPG_ERR_INLINE gpg_error_t
1050 : gpg_err_make_from_errno (gpg_err_source_t source, int err)
1051 : {
1052 : return gpg_err_make (source, gpg_err_code_from_errno (err));
1053 : }
1054 :
1055 :
1056 : static GPG_ERR_INLINE gpg_error_t
1057 : gpg_error_from_errno (int err)
1058 : {
1059 : return gpg_error (gpg_err_code_from_errno (err));
1060 : }
1061 :
1062 : static GPG_ERR_INLINE gpg_error_t
1063 : gpg_error_from_syserror (void)
1064 : {
1065 : return gpg_error (gpg_err_code_from_syserror ());
1066 : }
1067 :
1068 :
1069 :
1070 : /*
1071 : * Malloc and friends
1072 : */
1073 :
1074 : void *gpgrt_realloc (void *a, size_t n);
1075 : void *gpgrt_reallocarray (void *a, size_t oldnmemb, size_t nmemb, size_t size);
1076 : void *gpgrt_malloc (size_t n);
1077 : void *gpgrt_calloc (size_t n, size_t m);
1078 : char *gpgrt_strdup (const char *string);
1079 : char *gpgrt_strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
1080 : void gpgrt_free (void *a);
1081 :
1082 :
1083 : /*
1084 : * System specific function wrappers.
1085 : */
1086 :
1087 : /* A getenv replacement which mallocs the returned string. */
1088 : char *gpgrt_getenv (const char *name);
1089 :
1090 : /* A setenv and a unsetenv replacement.*/
1091 : gpg_err_code_t gpgrt_setenv (const char *name,
1092 : const char *value, int overwrite);
1093 : #define gpgrt_unsetenv(n) gpgrt_setenv ((n), NULL, 1)
1094 :
1095 : /* A wrapper around mkdir using a string for the mode. */
1096 : gpg_err_code_t gpgrt_mkdir (const char *name, const char *modestr);
1097 :
1098 : /* A simple wrapper around chdir. */
1099 : gpg_err_code_t gpgrt_chdir (const char *name);
1100 :
1101 : /* Return the current WD as a malloced string. */
1102 : char *gpgrt_getcwd (void);
1103 :
1104 : /* A wrapper around access to handle UTF-8 on Windows. */
1105 : gpg_err_code_t gpgrt_access (const char *fname, int mode);
1106 :
1107 :
1108 :
1109 :
1110 : /*
1111 : * Lock functions.
1112 : */
1113 :
1114 :
1115 : typedef struct
1116 : {
1117 : long _vers;
1118 : union {
1119 : volatile char _priv[40];
1120 : long _x_align;
1121 : long *_xp_align;
1122 : } u;
1123 : } gpgrt_lock_t;
1124 :
1125 : #define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \
1126 : 0,0,0,0,0,0,0,0, \
1127 : 0,0,0,0,0,0,0,0, \
1128 : 0,0,0,0,0,0,0,0, \
1129 : 0,0,0,0,0,0,0,0}}}
1130 :
1131 :
1132 : #define GPGRT_LOCK_DEFINE(name) \
1133 : static gpgrt_lock_t name = GPGRT_LOCK_INITIALIZER
1134 :
1135 : /* NB: If GPGRT_LOCK_DEFINE is not used, zero out the lock variable
1136 : before passing it to gpgrt_lock_init. */
1137 : gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd);
1138 : gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd);
1139 : gpg_err_code_t gpgrt_lock_trylock (gpgrt_lock_t *lockhd);
1140 : gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
1141 : gpg_err_code_t gpgrt_lock_destroy (gpgrt_lock_t *lockhd);
1142 :
1143 :
1144 :
1145 : /*
1146 : * Thread functions.
1147 : */
1148 :
1149 : gpg_err_code_t gpgrt_yield (void);
1150 :
1151 :
1152 :
1153 :
1154 : /*
1155 : * Estream
1156 : */
1157 :
1158 : /* The definition of this struct is entirely private. You must not
1159 : use it for anything. It is only here so some functions can be
1160 : implemented as macros. */
1161 : struct _gpgrt_stream_internal;
1162 : struct _gpgrt__stream
1163 : {
1164 : /* The layout of this struct must never change. It may be grown,
1165 : but only if all functions which access the new members are
1166 : versioned. */
1167 :
1168 : /* Various flags. */
1169 : struct {
1170 : unsigned int magic: 16;
1171 : unsigned int writing: 1;
1172 : unsigned int reserved: 15;
1173 : } flags;
1174 :
1175 : /* A pointer to the stream buffer. */
1176 : unsigned char *buffer;
1177 :
1178 : /* The size of the buffer in bytes. */
1179 : size_t buffer_size;
1180 :
1181 : /* The length of the usable data in the buffer, only valid when in
1182 : read mode (see flags). */
1183 : size_t data_len;
1184 :
1185 : /* The current position of the offset pointer, valid in read and
1186 : write mode. */
1187 : size_t data_offset;
1188 :
1189 : size_t data_flushed;
1190 : unsigned char *unread_buffer;
1191 : size_t unread_buffer_size;
1192 :
1193 : /* The number of unread bytes. */
1194 : size_t unread_data_len;
1195 :
1196 : /* A pointer to our internal data for this stream. */
1197 : struct _gpgrt_stream_internal *intern;
1198 : };
1199 :
1200 : /* The opaque type for an estream. */
1201 : typedef struct _gpgrt__stream *gpgrt_stream_t;
1202 : #ifdef GPGRT_ENABLE_ES_MACROS
1203 : typedef struct _gpgrt__stream *estream_t;
1204 : #endif
1205 :
1206 : typedef ssize_t (*gpgrt_cookie_read_function_t) (void *cookie,
1207 : void *buffer, size_t size);
1208 : typedef ssize_t (*gpgrt_cookie_write_function_t) (void *cookie,
1209 : const void *buffer,
1210 : size_t size);
1211 : typedef int (*gpgrt_cookie_seek_function_t) (void *cookie,
1212 : gpgrt_off_t *pos, int whence);
1213 : typedef int (*gpgrt_cookie_close_function_t) (void *cookie);
1214 :
1215 : struct _gpgrt_cookie_io_functions
1216 : {
1217 : gpgrt_cookie_read_function_t func_read;
1218 : gpgrt_cookie_write_function_t func_write;
1219 : gpgrt_cookie_seek_function_t func_seek;
1220 : gpgrt_cookie_close_function_t func_close;
1221 : };
1222 : typedef struct _gpgrt_cookie_io_functions gpgrt_cookie_io_functions_t;
1223 : #ifdef GPGRT_ENABLE_ES_MACROS
1224 : typedef struct _gpgrt_cookie_io_functions es_cookie_io_functions_t;
1225 : #define es_cookie_read_function_t gpgrt_cookie_read_function_t
1226 : #define es_cookie_write_function_t gpgrt_cookie_read_function_t
1227 : #define es_cookie_seek_function_t gpgrt_cookie_read_function_t
1228 : #define es_cookie_close_function_t gpgrt_cookie_read_function_t
1229 : #endif
1230 :
1231 : enum gpgrt_syshd_types
1232 : {
1233 : GPGRT_SYSHD_NONE = 0, /* No system handle available. */
1234 : GPGRT_SYSHD_FD = 1, /* A file descriptor as returned by open(). */
1235 : GPGRT_SYSHD_SOCK = 2, /* A socket as returned by socket(). */
1236 : GPGRT_SYSHD_RVID = 3, /* A rendezvous id (see libassuan's gpgcedev.c). */
1237 : GPGRT_SYSHD_HANDLE = 4 /* A HANDLE object (Windows). */
1238 : };
1239 :
1240 : struct _gpgrt_syshd
1241 : {
1242 : enum gpgrt_syshd_types type;
1243 : union {
1244 : int fd;
1245 : int sock;
1246 : int rvid;
1247 : void *handle;
1248 : } u;
1249 : };
1250 : typedef struct _gpgrt_syshd gpgrt_syshd_t;
1251 : #ifdef GPGRT_ENABLE_ES_MACROS
1252 : typedef struct _gpgrt_syshd es_syshd_t;
1253 : #define ES_SYSHD_NONE GPGRT_SYSHD_NONE
1254 : #define ES_SYSHD_FD GPGRT_SYSHD_FD
1255 : #define ES_SYSHD_SOCK GPGRT_SYSHD_SOCK
1256 : #define ES_SYSHD_RVID GPGRT_SYSHD_RVID
1257 : #define ES_SYSHD_HANDLE GPGRT_SYSHD_HANDLE
1258 : #endif
1259 :
1260 : /* The object used with gpgrt_poll. */
1261 : struct _gpgrt_poll_s
1262 : {
1263 : gpgrt_stream_t stream;
1264 : unsigned int want_read:1;
1265 : unsigned int want_write:1;
1266 : unsigned int want_oob:1;
1267 : unsigned int want_rdhup:1;
1268 : unsigned int _reserv1:4;
1269 : unsigned int got_read:1;
1270 : unsigned int got_write:1;
1271 : unsigned int got_oob:1;
1272 : unsigned int got_rdhup:1;
1273 : unsigned int _reserv2:4;
1274 : unsigned int got_err:1;
1275 : unsigned int got_hup:1;
1276 : unsigned int got_nval:1;
1277 : unsigned int _reserv3:4;
1278 : unsigned int ignore:1;
1279 : unsigned int user:8; /* For application use. */
1280 : };
1281 : typedef struct _gpgrt_poll_s gpgrt_poll_t;
1282 : #ifdef GPGRT_ENABLE_ES_MACROS
1283 : typedef struct _gpgrt_poll_s es_poll_t;
1284 : #endif
1285 :
1286 : /* The type of the string filter function as used by fprintf_sf et al. */
1287 : typedef char *(*gpgrt_string_filter_t) (const char *s, int n, void *opaque);
1288 :
1289 :
1290 :
1291 : gpgrt_stream_t gpgrt_fopen (const char *_GPGRT__RESTRICT path,
1292 : const char *_GPGRT__RESTRICT mode);
1293 : gpgrt_stream_t gpgrt_mopen (void *_GPGRT__RESTRICT data,
1294 : size_t data_n, size_t data_len,
1295 : unsigned int grow,
1296 : void *(*func_realloc) (void *mem, size_t size),
1297 : void (*func_free) (void *mem),
1298 : const char *_GPGRT__RESTRICT mode);
1299 : gpgrt_stream_t gpgrt_fopenmem (size_t memlimit,
1300 : const char *_GPGRT__RESTRICT mode);
1301 : gpgrt_stream_t gpgrt_fopenmem_init (size_t memlimit,
1302 : const char *_GPGRT__RESTRICT mode,
1303 : const void *data, size_t datalen);
1304 : gpgrt_stream_t gpgrt_fdopen (int filedes, const char *mode);
1305 : gpgrt_stream_t gpgrt_fdopen_nc (int filedes, const char *mode);
1306 : gpgrt_stream_t gpgrt_sysopen (gpgrt_syshd_t *syshd, const char *mode);
1307 : gpgrt_stream_t gpgrt_sysopen_nc (gpgrt_syshd_t *syshd, const char *mode);
1308 : gpgrt_stream_t gpgrt_fpopen (FILE *fp, const char *mode);
1309 : gpgrt_stream_t gpgrt_fpopen_nc (FILE *fp, const char *mode);
1310 : gpgrt_stream_t gpgrt_freopen (const char *_GPGRT__RESTRICT path,
1311 : const char *_GPGRT__RESTRICT mode,
1312 : gpgrt_stream_t _GPGRT__RESTRICT stream);
1313 : gpgrt_stream_t gpgrt_fopencookie (void *_GPGRT__RESTRICT cookie,
1314 : const char *_GPGRT__RESTRICT mode,
1315 : gpgrt_cookie_io_functions_t functions);
1316 : int gpgrt_fclose (gpgrt_stream_t stream);
1317 : int gpgrt_fcancel (gpgrt_stream_t stream);
1318 : int gpgrt_fclose_snatch (gpgrt_stream_t stream,
1319 : void **r_buffer, size_t *r_buflen);
1320 : int gpgrt_onclose (gpgrt_stream_t stream, int mode,
1321 : void (*fnc) (gpgrt_stream_t, void*), void *fnc_value);
1322 : int gpgrt_fileno (gpgrt_stream_t stream);
1323 : int gpgrt_fileno_unlocked (gpgrt_stream_t stream);
1324 : int gpgrt_syshd (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
1325 : int gpgrt_syshd_unlocked (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
1326 :
1327 : void _gpgrt_set_std_fd (int no, int fd);
1328 : gpgrt_stream_t _gpgrt_get_std_stream (int fd);
1329 :
1330 : #define gpgrt_stdin _gpgrt_get_std_stream (0)
1331 : #define gpgrt_stdout _gpgrt_get_std_stream (1)
1332 : #define gpgrt_stderr _gpgrt_get_std_stream (2)
1333 :
1334 :
1335 : void gpgrt_flockfile (gpgrt_stream_t stream);
1336 : int gpgrt_ftrylockfile (gpgrt_stream_t stream);
1337 : void gpgrt_funlockfile (gpgrt_stream_t stream);
1338 :
1339 : int gpgrt_feof (gpgrt_stream_t stream);
1340 : int gpgrt_feof_unlocked (gpgrt_stream_t stream);
1341 : int gpgrt_ferror (gpgrt_stream_t stream);
1342 : int gpgrt_ferror_unlocked (gpgrt_stream_t stream);
1343 : void gpgrt_clearerr (gpgrt_stream_t stream);
1344 : void gpgrt_clearerr_unlocked (gpgrt_stream_t stream);
1345 :
1346 : int _gpgrt_pending (gpgrt_stream_t stream); /* (private) */
1347 : int _gpgrt_pending_unlocked (gpgrt_stream_t stream); /* (private) */
1348 :
1349 : #define gpgrt_pending(stream) _gpgrt_pending (stream)
1350 :
1351 : #define gpgrt_pending_unlocked(stream) \
1352 : (((!(stream)->flags.writing) \
1353 : && (((stream)->data_offset < (stream)->data_len) \
1354 : || ((stream)->unread_data_len))) \
1355 : ? 1 : _gpgrt_pending_unlocked ((stream)))
1356 :
1357 : int gpgrt_fflush (gpgrt_stream_t stream);
1358 : int gpgrt_fseek (gpgrt_stream_t stream, long int offset, int whence);
1359 : int gpgrt_fseeko (gpgrt_stream_t stream, gpgrt_off_t offset, int whence);
1360 : int gpgrt_ftruncate (gpgrt_stream_t stream, gpgrt_off_t length);
1361 : long int gpgrt_ftell (gpgrt_stream_t stream);
1362 : gpgrt_off_t gpgrt_ftello (gpgrt_stream_t stream);
1363 : void gpgrt_rewind (gpgrt_stream_t stream);
1364 :
1365 : int gpgrt_fgetc (gpgrt_stream_t stream);
1366 : int gpgrt_fputc (int c, gpgrt_stream_t stream);
1367 :
1368 : int _gpgrt_getc_underflow (gpgrt_stream_t stream); /* (private) */
1369 : int _gpgrt_putc_overflow (int c, gpgrt_stream_t stream); /* (private) */
1370 :
1371 : #define gpgrt_getc_unlocked(stream) \
1372 : (((!(stream)->flags.writing) \
1373 : && ((stream)->data_offset < (stream)->data_len) \
1374 : && (! (stream)->unread_data_len)) \
1375 : ? ((int) (stream)->buffer[((stream)->data_offset)++]) \
1376 : : _gpgrt_getc_underflow ((stream)))
1377 :
1378 : #define gpgrt_putc_unlocked(c, stream) \
1379 : (((stream)->flags.writing \
1380 : && ((stream)->data_offset < (stream)->buffer_size) \
1381 : && (c != '\n')) \
1382 : ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c))) \
1383 : : _gpgrt_putc_overflow ((c), (stream)))
1384 :
1385 : #define gpgrt_getc(stream) gpgrt_fgetc (stream)
1386 : #define gpgrt_putc(c, stream) gpgrt_fputc (c, stream)
1387 :
1388 : int gpgrt_ungetc (int c, gpgrt_stream_t stream);
1389 :
1390 : int gpgrt_read (gpgrt_stream_t _GPGRT__RESTRICT stream,
1391 : void *_GPGRT__RESTRICT buffer, size_t bytes_to_read,
1392 : size_t *_GPGRT__RESTRICT bytes_read);
1393 : int gpgrt_write (gpgrt_stream_t _GPGRT__RESTRICT stream,
1394 : const void *_GPGRT__RESTRICT buffer, size_t bytes_to_write,
1395 : size_t *_GPGRT__RESTRICT bytes_written);
1396 : int gpgrt_write_sanitized (gpgrt_stream_t _GPGRT__RESTRICT stream,
1397 : const void *_GPGRT__RESTRICT buffer, size_t length,
1398 : const char *delimiters,
1399 : size_t *_GPGRT__RESTRICT bytes_written);
1400 : int gpgrt_write_hexstring (gpgrt_stream_t _GPGRT__RESTRICT stream,
1401 : const void *_GPGRT__RESTRICT buffer, size_t length,
1402 : int reserved,
1403 : size_t *_GPGRT__RESTRICT bytes_written);
1404 :
1405 : size_t gpgrt_fread (void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems,
1406 : gpgrt_stream_t _GPGRT__RESTRICT stream);
1407 : size_t gpgrt_fwrite (const void *_GPGRT__RESTRICT ptr, size_t size,
1408 : size_t nitems, gpgrt_stream_t _GPGRT__RESTRICT stream);
1409 :
1410 : char *gpgrt_fgets (char *_GPGRT__RESTRICT s, int n,
1411 : gpgrt_stream_t _GPGRT__RESTRICT stream);
1412 : int gpgrt_fputs (const char *_GPGRT__RESTRICT s,
1413 : gpgrt_stream_t _GPGRT__RESTRICT stream);
1414 : int gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s,
1415 : gpgrt_stream_t _GPGRT__RESTRICT stream);
1416 :
1417 : ssize_t gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr,
1418 : size_t *_GPGRT__RESTRICT n,
1419 : gpgrt_stream_t stream);
1420 : ssize_t gpgrt_read_line (gpgrt_stream_t stream,
1421 : char **addr_of_buffer, size_t *length_of_buffer,
1422 : size_t *max_length);
1423 :
1424 : int gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
1425 : const char *_GPGRT__RESTRICT format, ...)
1426 : GPGRT_ATTR_PRINTF(2,3);
1427 : int gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
1428 : const char *_GPGRT__RESTRICT format, ...)
1429 : GPGRT_ATTR_PRINTF(2,3);
1430 :
1431 : int gpgrt_fprintf_sf (gpgrt_stream_t _GPGRT__RESTRICT stream,
1432 : gpgrt_string_filter_t sf, void *sfvalue,
1433 : const char *_GPGRT__RESTRICT format,
1434 : ...) GPGRT_ATTR_PRINTF(4,5);
1435 : int gpgrt_fprintf_sf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
1436 : gpgrt_string_filter_t sf, void *sfvalue,
1437 : const char *_GPGRT__RESTRICT format,
1438 : ...) GPGRT_ATTR_PRINTF(4,5);
1439 :
1440 : int gpgrt_printf (const char *_GPGRT__RESTRICT format, ...)
1441 : GPGRT_ATTR_PRINTF(1,2);
1442 : int gpgrt_printf_unlocked (const char *_GPGRT__RESTRICT format, ...)
1443 : GPGRT_ATTR_PRINTF(1,2);
1444 :
1445 : int gpgrt_vfprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
1446 : const char *_GPGRT__RESTRICT format, va_list ap)
1447 : GPGRT_ATTR_PRINTF(2,0);
1448 : int gpgrt_vfprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
1449 : const char *_GPGRT__RESTRICT format, va_list ap)
1450 : GPGRT_ATTR_PRINTF(2,0);
1451 :
1452 : int gpgrt_setvbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
1453 : char *_GPGRT__RESTRICT buf, int mode, size_t size);
1454 : void gpgrt_setbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
1455 : char *_GPGRT__RESTRICT buf);
1456 :
1457 : void gpgrt_set_binary (gpgrt_stream_t stream);
1458 : int gpgrt_set_nonblock (gpgrt_stream_t stream, int onoff);
1459 : int gpgrt_get_nonblock (gpgrt_stream_t stream);
1460 :
1461 : int gpgrt_poll (gpgrt_poll_t *fdlist, unsigned int nfds, int timeout);
1462 :
1463 : gpgrt_stream_t gpgrt_tmpfile (void);
1464 :
1465 : void gpgrt_opaque_set (gpgrt_stream_t _GPGRT__RESTRICT stream,
1466 : void *_GPGRT__RESTRICT opaque);
1467 : void *gpgrt_opaque_get (gpgrt_stream_t stream);
1468 :
1469 : void gpgrt_fname_set (gpgrt_stream_t stream, const char *fname);
1470 : const char *gpgrt_fname_get (gpgrt_stream_t stream);
1471 :
1472 : int gpgrt_asprintf (char **r_buf, const char * _GPGRT__RESTRICT format, ...)
1473 : GPGRT_ATTR_PRINTF(2,3);
1474 : int gpgrt_vasprintf (char **r_buf, const char * _GPGRT__RESTRICT format,
1475 : va_list ap)
1476 : GPGRT_ATTR_PRINTF(2,0);
1477 : char *gpgrt_bsprintf (const char * _GPGRT__RESTRICT format, ...)
1478 : GPGRT_ATTR_PRINTF(1,2);
1479 : char *gpgrt_vbsprintf (const char * _GPGRT__RESTRICT format, va_list ap)
1480 : GPGRT_ATTR_PRINTF(1,0);
1481 : int gpgrt_snprintf (char *buf, size_t bufsize,
1482 : const char * _GPGRT__RESTRICT format, ...)
1483 : GPGRT_ATTR_PRINTF(3,4);
1484 : int gpgrt_vsnprintf (char *buf,size_t bufsize,
1485 : const char * _GPGRT__RESTRICT format, va_list arg_ptr)
1486 : GPGRT_ATTR_PRINTF(3,0);
1487 :
1488 :
1489 : #ifdef GPGRT_ENABLE_ES_MACROS
1490 : # define es_fopen gpgrt_fopen
1491 : # define es_mopen gpgrt_mopen
1492 : # define es_fopenmem gpgrt_fopenmem
1493 : # define es_fopenmem_init gpgrt_fopenmem_init
1494 : # define es_fdopen gpgrt_fdopen
1495 : # define es_fdopen_nc gpgrt_fdopen_nc
1496 : # define es_sysopen gpgrt_sysopen
1497 : # define es_sysopen_nc gpgrt_sysopen_nc
1498 : # define es_fpopen gpgrt_fpopen
1499 : # define es_fpopen_nc gpgrt_fpopen_nc
1500 : # define es_freopen gpgrt_freopen
1501 : # define es_fopencookie gpgrt_fopencookie
1502 : # define es_fclose gpgrt_fclose
1503 : # define es_fclose_snatch gpgrt_fclose_snatch
1504 : # define es_onclose gpgrt_onclose
1505 : # define es_fileno gpgrt_fileno
1506 : # define es_fileno_unlocked gpgrt_fileno_unlocked
1507 : # define es_syshd gpgrt_syshd
1508 : # define es_syshd_unlocked gpgrt_syshd_unlocked
1509 : # define es_stdin _gpgrt_get_std_stream (0)
1510 : # define es_stdout _gpgrt_get_std_stream (1)
1511 : # define es_stderr _gpgrt_get_std_stream (2)
1512 : # define es_flockfile gpgrt_flockfile
1513 : # define es_ftrylockfile gpgrt_ftrylockfile
1514 : # define es_funlockfile gpgrt_funlockfile
1515 : # define es_feof gpgrt_feof
1516 : # define es_feof_unlocked gpgrt_feof_unlocked
1517 : # define es_ferror gpgrt_ferror
1518 : # define es_ferror_unlocked gpgrt_ferror_unlocked
1519 : # define es_clearerr gpgrt_clearerr
1520 : # define es_clearerr_unlocked gpgrt_clearerr_unlocked
1521 : # define es_pending gpgrt_pending
1522 : # define es_pending_unlocked gpgrt_pending_unlocked
1523 : # define es_fflush gpgrt_fflush
1524 : # define es_fseek gpgrt_fseek
1525 : # define es_fseeko gpgrt_fseeko
1526 : # define es_ftruncate gpgrt_ftruncate
1527 : # define es_ftell gpgrt_ftell
1528 : # define es_ftello gpgrt_ftello
1529 : # define es_rewind gpgrt_rewind
1530 : # define es_fgetc gpgrt_fgetc
1531 : # define es_fputc gpgrt_fputc
1532 : # define es_getc_unlocked gpgrt_getc_unlocked
1533 : # define es_putc_unlocked gpgrt_putc_unlocked
1534 : # define es_getc gpgrt_getc
1535 : # define es_putc gpgrt_putc
1536 : # define es_ungetc gpgrt_ungetc
1537 : # define es_read gpgrt_read
1538 : # define es_write gpgrt_write
1539 : # define es_write_sanitized gpgrt_write_sanitized
1540 : # define es_write_hexstring gpgrt_write_hexstring
1541 : # define es_fread gpgrt_fread
1542 : # define es_fwrite gpgrt_fwrite
1543 : # define es_fgets gpgrt_fgets
1544 : # define es_fputs gpgrt_fputs
1545 : # define es_fputs_unlocked gpgrt_fputs_unlocked
1546 : # define es_getline gpgrt_getline
1547 : # define es_read_line gpgrt_read_line
1548 : # define es_free gpgrt_free
1549 : # define es_fprintf gpgrt_fprintf
1550 : # define es_fprintf_unlocked gpgrt_fprintf_unlocked
1551 : # define es_printf gpgrt_printf
1552 : # define es_printf_unlocked gpgrt_printf_unlocked
1553 : # define es_vfprintf gpgrt_vfprintf
1554 : # define es_vfprintf_unlocked gpgrt_vfprintf_unlocked
1555 : # define es_setvbuf gpgrt_setvbuf
1556 : # define es_setbuf gpgrt_setbuf
1557 : # define es_set_binary gpgrt_set_binary
1558 : # define es_set_nonblock gpgrt_set_nonblock
1559 : # define es_get_nonblock gpgrt_get_nonblock
1560 : # define es_poll gpgrt_poll
1561 : # define es_tmpfile gpgrt_tmpfile
1562 : # define es_opaque_set gpgrt_opaque_set
1563 : # define es_opaque_get gpgrt_opaque_get
1564 : # define es_fname_set gpgrt_fname_set
1565 : # define es_fname_get gpgrt_fname_get
1566 : # define es_asprintf gpgrt_asprintf
1567 : # define es_vasprintf gpgrt_vasprintf
1568 : # define es_bsprintf gpgrt_bsprintf
1569 : # define es_vbsprintf gpgrt_vbsprintf
1570 : #endif /*GPGRT_ENABLE_ES_MACROS*/
1571 :
1572 :
1573 :
1574 : /*
1575 : * Base64 encode and decode functions.
1576 : */
1577 :
1578 : struct _gpgrt_b64state;
1579 : typedef struct _gpgrt_b64state *gpgrt_b64state_t;
1580 :
1581 : gpgrt_b64state_t gpgrt_b64enc_start (gpgrt_stream_t stream, const char *title);
1582 : gpg_err_code_t gpgrt_b64enc_write (gpgrt_b64state_t state,
1583 : const void *buffer, size_t nbytes);
1584 : gpg_err_code_t gpgrt_b64enc_finish (gpgrt_b64state_t state);
1585 :
1586 : gpgrt_b64state_t gpgrt_b64dec_start (const char *title);
1587 : gpg_error_t gpgrt_b64dec_proc (gpgrt_b64state_t state,
1588 : void *buffer, size_t length,
1589 : size_t *r_nbytes);
1590 : gpg_error_t gpgrt_b64dec_finish (gpgrt_b64state_t state);
1591 :
1592 :
1593 :
1594 : /*
1595 : * Logging functions
1596 : */
1597 :
1598 : /* Flag values for gpgrt_log_set_prefix. */
1599 : #define GPGRT_LOG_WITH_PREFIX 1
1600 : #define GPGRT_LOG_WITH_TIME 2
1601 : #define GPGRT_LOG_WITH_PID 4
1602 : #define GPGRT_LOG_RUN_DETACHED 256
1603 : #define GPGRT_LOG_NO_REGISTRY 512
1604 :
1605 : /* Log levels as used by gpgrt_log. */
1606 : enum gpgrt_log_levels
1607 : {
1608 : GPGRT_LOGLVL_BEGIN,
1609 : GPGRT_LOGLVL_CONT,
1610 : GPGRT_LOGLVL_INFO,
1611 : GPGRT_LOGLVL_WARN,
1612 : GPGRT_LOGLVL_ERROR,
1613 : GPGRT_LOGLVL_FATAL,
1614 : GPGRT_LOGLVL_BUG,
1615 : GPGRT_LOGLVL_DEBUG
1616 : };
1617 :
1618 :
1619 : /* The next 4 functions are not thread-safe - call them early. */
1620 : void gpgrt_log_set_sink (const char *name, gpgrt_stream_t stream, int fd);
1621 : void gpgrt_log_set_socket_dir_cb (const char *(*fnc)(void));
1622 : void gpgrt_log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value));
1623 : void gpgrt_log_set_prefix (const char *text, unsigned int flags);
1624 :
1625 : int gpgrt_get_errorcount (int clear);
1626 : void gpgrt_inc_errorcount (void);
1627 : const char *gpgrt_log_get_prefix (unsigned int *flags);
1628 : int gpgrt_log_test_fd (int fd);
1629 : int gpgrt_log_get_fd (void);
1630 : gpgrt_stream_t gpgrt_log_get_stream (void);
1631 :
1632 : void gpgrt_log (int level, const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
1633 : void gpgrt_logv (int level, const char *fmt, va_list arg_ptr);
1634 : void gpgrt_logv_prefix (int level, const char *prefix,
1635 : const char *fmt, va_list arg_ptr);
1636 : void gpgrt_log_string (int level, const char *string);
1637 : void gpgrt_log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2);
1638 : void gpgrt_log_fatal (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2);
1639 : void gpgrt_log_error (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
1640 : void gpgrt_log_info (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
1641 : void gpgrt_log_debug (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
1642 : void gpgrt_log_debug_string (const char *string,
1643 : const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
1644 : void gpgrt_log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
1645 : void gpgrt_log_printhex (const void *buffer, size_t length,
1646 : const char *fmt, ...) GPGRT_ATTR_PRINTF(3,4);
1647 : void gpgrt_log_clock (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
1648 : void gpgrt_log_flush (void);
1649 : void _gpgrt_log_assert (const char *expr, const char *file, int line,
1650 : const char *func) GPGRT_ATTR_NORETURN;
1651 :
1652 : #ifdef GPGRT_HAVE_MACRO_FUNCTION
1653 : # define gpgrt_assert(expr) \
1654 : ((expr) \
1655 : ? (void) 0 \
1656 : : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
1657 : #else /*!GPGRT_HAVE_MACRO_FUNCTION*/
1658 : # define gpgrt_assert(expr) \
1659 : ((expr) \
1660 : ? (void) 0 \
1661 : : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL))
1662 : #endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
1663 :
1664 : #ifdef GPGRT_ENABLE_LOG_MACROS
1665 : # define log_get_errorcount gpgrt_get_errorcount
1666 : # define log_inc_errorcount gpgrt_inc_errorcount
1667 : # define log_set_file(a) gpgrt_log_set_sink ((a), NULL, -1)
1668 : # define log_set_fd(a) gpgrt_log_set_sink (NULL, NULL, (a))
1669 : # define log_set_stream(a) gpgrt_log_set_sink (NULL, (a), -1)
1670 : # define log_set_socket_dir_cb gpgrt_log_set_socket_dir_cb
1671 : # define log_set_pid_suffix_cb gpgrt_log_set_pid_suffix_cb
1672 : # define log_set_prefix gpgrt_log_set_prefix
1673 : # define log_get_prefix gpgrt_log_get_prefix
1674 : # define log_test_fd gpgrt_log_test_fd
1675 : # define log_get_fd gpgrt_log_get_fd
1676 : # define log_get_stream gpgrt_log_get_stream
1677 : # define log_log gpgrt_log
1678 : # define log_logv gpgrt_logv
1679 : # define log_logv_prefix gpgrt_logv_prefix
1680 : # define log_string gpgrt_log_string
1681 : # define log_bug gpgrt_log_bug
1682 : # define log_fatal gpgrt_log_fatal
1683 : # define log_error gpgrt_log_error
1684 : # define log_info gpgrt_log_info
1685 : # define log_debug gpgrt_log_debug
1686 : # define log_debug_string gpgrt_log_debug_string
1687 : # define log_printf gpgrt_log_printf
1688 : # define log_printhex gpgrt_log_printhex
1689 : # define log_clock gpgrt_log_clock
1690 : # define log_flush gpgrt_log_flush
1691 : # ifdef GPGRT_HAVE_MACRO_FUNCTION
1692 : # define log_assert(expr) \
1693 : ((expr) \
1694 : ? (void) 0 \
1695 : : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
1696 : # else /*!GPGRT_HAVE_MACRO_FUNCTION*/
1697 : # define log_assert(expr) \
1698 : ((expr) \
1699 : ? (void) 0 \
1700 : : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL))
1701 : # endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
1702 :
1703 : #endif /*GPGRT_ENABLE_LOG_MACROS*/
1704 :
1705 :
1706 : /*
1707 : * Spawn functions (Not yet available)
1708 : */
1709 : #define GPGRT_SPAWN_NONBLOCK 16 /* Set the streams to non-blocking. */
1710 : #define GPGRT_SPAWN_RUN_ASFW 64 /* Use AllowSetForegroundWindow on W32. */
1711 : #define GPGRT_SPAWN_DETACHED 128 /* Start the process in the background. */
1712 :
1713 : #if 0
1714 :
1715 : /* Function and convenience macros to create pipes. */
1716 : gpg_err_code_t gpgrt_make_pipe (int filedes[2], gpgrt_stream_t *r_fp,
1717 : int direction, int nonblock);
1718 : #define gpgrt_create_pipe(a) gpgrt_make_pipe ((a),NULL, 0, 0);
1719 : #define gpgrt_create_inbound_pipe(a,b,c) gpgrt_make_pipe ((a), (b), -1,(c));
1720 : #define gpgrt_create_outbound_pipe(a,b,c) gpgrt_make_pipe ((a), (b), 1,(c));
1721 :
1722 :
1723 : /* Fork and exec PGMNAME. */
1724 : gpg_err_code_t gpgrt_spawn_process (const char *pgmname, const char *argv[],
1725 : int *execpt, void (*preexec)(void),
1726 : unsigned int flags,
1727 : gpgrt_stream_t *r_infp,
1728 : gpgrt_stream_t *r_outfp,
1729 : gpgrt_stream_t *r_errfp,
1730 : pid_t *pid);
1731 :
1732 : /* Fork and exec PGNNAME and connect the process to the given FDs. */
1733 : gpg_err_code_t gpgrt_spawn_process_fd (const char *pgmname, const char *argv[],
1734 : int infd, int outfd, int errfd,
1735 : pid_t *pid);
1736 :
1737 : /* Fork and exec PGMNAME as a detached process. */
1738 : gpg_err_code_t gpgrt_spawn_process_detached (const char *pgmname,
1739 : const char *argv[],
1740 : const char *envp[] );
1741 :
1742 : /* Wait for a single process. */
1743 : gpg_err_code_t gpgrt_wait_process (const char *pgmname, pid_t pid, int hang,
1744 : int *r_exitcode);
1745 :
1746 : /* Wait for a multiple processes. */
1747 : gpg_err_code_t gpgrt_wait_processes (const char **pgmnames, pid_t *pids,
1748 : size_t count, int hang, int *r_exitcodes);
1749 :
1750 : /* Kill the process identified by PID. */
1751 : void gpgrt_kill_process (pid_t pid);
1752 :
1753 : /* Release process resources identified by PID. */
1754 : void gpgrt_release_process (pid_t pid);
1755 :
1756 : #endif /*0*/
1757 :
1758 :
1759 :
1760 : /*
1761 : * Option parsing.
1762 : */
1763 :
1764 : struct _gpgrt_argparse_internal_s;
1765 : typedef struct
1766 : {
1767 : int *argc; /* Pointer to ARGC (value subject to change). */
1768 : char ***argv; /* Pointer to ARGV (value subject to change). */
1769 : unsigned int flags; /* Global flags. May be set prior to calling the
1770 : parser. The parser may change the value. */
1771 : int err; /* Print error description for last option.
1772 : Either 0, ARGPARSE_PRINT_WARNING or
1773 : ARGPARSE_PRINT_ERROR. */
1774 : unsigned int lineno;/* The current line number. */
1775 : int r_opt; /* Returns option code. */
1776 : int r_type; /* Returns type of option value. */
1777 : union {
1778 : int ret_int;
1779 : long ret_long;
1780 : unsigned long ret_ulong;
1781 : char *ret_str;
1782 : } r; /* Return values */
1783 :
1784 : struct _gpgrt_argparse_internal_s *internal;
1785 : } gpgrt_argparse_t;
1786 :
1787 :
1788 : typedef struct
1789 : {
1790 : int short_opt;
1791 : const char *long_opt;
1792 : unsigned int flags;
1793 : const char *description; /* Optional description. */
1794 : } gpgrt_opt_t;
1795 :
1796 :
1797 : #ifdef GPGRT_ENABLE_ARGPARSE_MACROS
1798 :
1799 : /* Global flags for (gpgrt_argparse_t).flags. */
1800 : #define ARGPARSE_FLAG_KEEP 1 /* Do not remove options form argv. */
1801 : #define ARGPARSE_FLAG_ALL 2 /* Do not stop at last option but return
1802 : remaining args with R_OPT set to -1. */
1803 : #define ARGPARSE_FLAG_MIXED 4 /* Assume options and args are mixed. */
1804 : #define ARGPARSE_FLAG_NOSTOP 8 /* Do not stop processing at "--". */
1805 : #define ARGPARSE_FLAG_ARG0 16 /* Do not skip the first arg. */
1806 : #define ARGPARSE_FLAG_ONEDASH 32 /* Allow long options with one dash. */
1807 : #define ARGPARSE_FLAG_NOVERSION 64 /* No output for "--version". */
1808 : #define ARGPARSE_FLAG_RESET 128 /* Request to reset the internal state. */
1809 : #define ARGPARSE_FLAG_STOP_SEEN 256 /* Set to true if a "--" has been seen. */
1810 : #define ARGPARSE_FLAG_NOLINENO 512 /* Do not zero the lineno field. */
1811 : #define ARGPARSE_FLAG_SYS 1024 /* Use system config file. */
1812 : #define ARGPARSE_FLAG_USER 2048 /* Use user config file. */
1813 : #define ARGPARSE_FLAG_VERBOSE 4096 /* Print additional argparser info. */
1814 : #define ARGPARSE_FLAG_USERVERS 8192 /* Try version-ed user config files. */
1815 : #define ARGPARSE_FLAG_WITHATTR 16384 /* Return attribute bits. */
1816 :
1817 : /* Constants for (gpgrt_argparse_t).err. */
1818 : #define ARGPARSE_PRINT_WARNING 1 /* Print a diagnostic. */
1819 : #define ARGPARSE_PRINT_ERROR 2 /* Print a diagnostic and call exit. */
1820 :
1821 : /* Special return values of gpgrt_argparse. */
1822 : #define ARGPARSE_IS_ARG (-1)
1823 : #define ARGPARSE_INVALID_OPTION (-2)
1824 : #define ARGPARSE_MISSING_ARG (-3)
1825 : #define ARGPARSE_KEYWORD_TOO_LONG (-4)
1826 : #define ARGPARSE_READ_ERROR (-5)
1827 : #define ARGPARSE_UNEXPECTED_ARG (-6)
1828 : #define ARGPARSE_INVALID_COMMAND (-7)
1829 : #define ARGPARSE_AMBIGUOUS_OPTION (-8)
1830 : #define ARGPARSE_AMBIGUOUS_COMMAND (-9)
1831 : #define ARGPARSE_INVALID_ALIAS (-10)
1832 : #define ARGPARSE_OUT_OF_CORE (-11)
1833 : #define ARGPARSE_INVALID_ARG (-12)
1834 : #define ARGPARSE_PERMISSION_ERROR (-13)
1835 : #define ARGPARSE_NO_CONFFILE (-14)
1836 : #define ARGPARSE_CONFFILE (-15)
1837 : #define ARGPARSE_INVALID_META (-16)
1838 : #define ARGPARSE_UNKNOWN_META (-17)
1839 : #define ARGPARSE_UNEXPECTED_META (-18)
1840 :
1841 : /* Flags for the option descriptor (gpgrt_opt_t)->flags. Note that a
1842 : * TYPE constant may be or-ed with the OPT constants but when used as
1843 : * return value in r_type these OPT constants are normally not
1844 : * included. However with ARGPARSE_FLAG_WITHATTR used and an option
1845 : * would normally not be returned, it is returned but
1846 : * ARGPARSE_OPT_IGNORE is then set; further ARPARSE_ATTR_* are set.
1847 : */
1848 : #define ARGPARSE_TYPE_MASK 0x0007 /* Mask for the type bits. */
1849 : #define ARGPARSE_TYPE_NONE 0 /* Does not take an argument. */
1850 : #define ARGPARSE_TYPE_INT 1 /* Takes an int argument. */
1851 : #define ARGPARSE_TYPE_STRING 2 /* Takes a string argument. */
1852 : #define ARGPARSE_TYPE_LONG 3 /* Takes a long argument. */
1853 : #define ARGPARSE_TYPE_ULONG 4 /* Takes an unsigned long argument. */
1854 : #define ARGPARSE_OPT_OPTIONAL (1<<3) /* Argument is optional. */
1855 : #define ARGPARSE_OPT_PREFIX (1<<4) /* Allow 0x etc. prefixed values. */
1856 : #define ARGPARSE_OPT_IGNORE (1<<6) /* Ignore command or option. */
1857 : #define ARGPARSE_OPT_COMMAND (1<<7) /* The argument is a command. */
1858 : #define ARGPARSE_OPT_CONFFILE (1<<8) /* The value is a conffile. */
1859 : #define ARGPARSE_OPT_HEADER (1<<9) /* The value is printed as a header. */
1860 : #define ARGPARSE_OPT_VERBATIM (1<<10)/* The value is printed verbatim. */
1861 : #define ARGPARSE_ATTR_FORCE (1<<14)/* Attribute force is set. */
1862 : #define ARGPARSE_ATTR_IGNORE (1<<15)/* Attribute ignore is set. */
1863 :
1864 : /* A set of macros to make option definitions easier to read. */
1865 : #define ARGPARSE_x(s,l,t,f,d) \
1866 : { (s), (l), ARGPARSE_TYPE_ ## t | (f), (d) }
1867 :
1868 : #define ARGPARSE_s(s,l,t,d) \
1869 : { (s), (l), ARGPARSE_TYPE_ ## t, (d) }
1870 : #define ARGPARSE_s_n(s,l,d) \
1871 : { (s), (l), ARGPARSE_TYPE_NONE, (d) }
1872 : #define ARGPARSE_s_i(s,l,d) \
1873 : { (s), (l), ARGPARSE_TYPE_INT, (d) }
1874 : #define ARGPARSE_s_s(s,l,d) \
1875 : { (s), (l), ARGPARSE_TYPE_STRING, (d) }
1876 : #define ARGPARSE_s_l(s,l,d) \
1877 : { (s), (l), ARGPARSE_TYPE_LONG, (d) }
1878 : #define ARGPARSE_s_u(s,l,d) \
1879 : { (s), (l), ARGPARSE_TYPE_ULONG, (d) }
1880 :
1881 : #define ARGPARSE_o(s,l,t,d) \
1882 : { (s), (l), (ARGPARSE_TYPE_ ## t | ARGPARSE_OPT_OPTIONAL), (d) }
1883 : #define ARGPARSE_o_n(s,l,d) \
1884 : { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_OPTIONAL), (d) }
1885 : #define ARGPARSE_o_i(s,l,d) \
1886 : { (s), (l), (ARGPARSE_TYPE_INT | ARGPARSE_OPT_OPTIONAL), (d) }
1887 : #define ARGPARSE_o_s(s,l,d) \
1888 : { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_OPTIONAL), (d) }
1889 : #define ARGPARSE_o_l(s,l,d) \
1890 : { (s), (l), (ARGPARSE_TYPE_LONG | ARGPARSE_OPT_OPTIONAL), (d) }
1891 : #define ARGPARSE_o_u(s,l,d) \
1892 : { (s), (l), (ARGPARSE_TYPE_ULONG | ARGPARSE_OPT_OPTIONAL), (d) }
1893 :
1894 : #define ARGPARSE_p(s,l,t,d) \
1895 : { (s), (l), (ARGPARSE_TYPE_ ## t | ARGPARSE_OPT_PREFIX), (d) }
1896 : #define ARGPARSE_p_n(s,l,d) \
1897 : { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_PREFIX), (d) }
1898 : #define ARGPARSE_p_i(s,l,d) \
1899 : { (s), (l), (ARGPARSE_TYPE_INT | ARGPARSE_OPT_PREFIX), (d) }
1900 : #define ARGPARSE_p_s(s,l,d) \
1901 : { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_PREFIX), (d) }
1902 : #define ARGPARSE_p_l(s,l,d) \
1903 : { (s), (l), (ARGPARSE_TYPE_LONG | ARGPARSE_OPT_PREFIX), (d) }
1904 : #define ARGPARSE_p_u(s,l,d) \
1905 : { (s), (l), (ARGPARSE_TYPE_ULONG | ARGPARSE_OPT_PREFIX), (d) }
1906 :
1907 : #define ARGPARSE_op(s,l,t,d) \
1908 : { (s), (l), (ARGPARSE_TYPE_ ## t \
1909 : | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1910 : #define ARGPARSE_op_n(s,l,d) \
1911 : { (s), (l), (ARGPARSE_TYPE_NONE \
1912 : | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1913 : #define ARGPARSE_op_i(s,l,d) \
1914 : { (s), (l), (ARGPARSE_TYPE_INT \
1915 : | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1916 : #define ARGPARSE_op_s(s,l,d) \
1917 : { (s), (l), (ARGPARSE_TYPE_STRING \
1918 : | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1919 : #define ARGPARSE_op_l(s,l,d) \
1920 : { (s), (l), (ARGPARSE_TYPE_LONG \
1921 : | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1922 : #define ARGPARSE_op_u(s,l,d) \
1923 : { (s), (l), (ARGPARSE_TYPE_ULONG \
1924 : | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1925 :
1926 : #define ARGPARSE_c(s,l,d) \
1927 : { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_COMMAND), (d) }
1928 :
1929 : #define ARGPARSE_conffile(s,l,d) \
1930 : { (s), (l), (ARGPARSE_TYPE_STRING|ARGPARSE_OPT_CONFFILE), (d) }
1931 :
1932 : #define ARGPARSE_noconffile(s,l,d) \
1933 : { (s), (l), (ARGPARSE_TYPE_NONE|ARGPARSE_OPT_CONFFILE), (d) }
1934 :
1935 : /* This macro is for stub or obsolete options. */
1936 : #define ARGPARSE_ignore(s,l) \
1937 : { (s), (l), (ARGPARSE_OPT_IGNORE), "@" }
1938 :
1939 : /* This is a legacy version of ARGPARSE_verbatim which really does
1940 : * verbatim printing. */
1941 : #define ARGPARSE_group(s,d) \
1942 : { (s), NULL, 0, (d) }
1943 :
1944 : /* Verbatim print the string D in the help output. It does not make
1945 : * use of the "@" hack as ARGPARSE_group does. */
1946 : #define ARGPARSE_verbatim(d) \
1947 : { 1, NULL, (ARGPARSE_OPT_VERBATIM), (d) }
1948 :
1949 : /* Same as ARGPARSE_verbatim but also print a colon and a LF. N can
1950 : * be used give a symbolic name to the header. Nothing is printed if
1951 : * D is the empty string. */
1952 : #define ARGPARSE_header(n,d) \
1953 : { 1, (n), (ARGPARSE_OPT_HEADER), (d) }
1954 :
1955 : /* Mark the end of the list (mandatory). */
1956 : #define ARGPARSE_end() \
1957 : { 0, NULL, 0, NULL }
1958 :
1959 : #endif /* GPGRT_ENABLE_ARGPARSE_MACROS */
1960 :
1961 : /* Values used for gpgrt_set_confdir. */
1962 : #define GPGRT_CONFDIR_USER 1 /* The user's configuration dir. */
1963 : #define GPGRT_CONFDIR_SYS 2 /* The systems's configuration dir. */
1964 :
1965 : /* Take care: gpgrt_argparse keeps state in ARG and requires that
1966 : * either ARGPARSE_FLAG_RESET is used after OPTS has been changed or
1967 : * gpgrt_argparse (NULL, ARG, NULL) is called first. */
1968 : int gpgrt_argparse (gpgrt_stream_t fp,
1969 : gpgrt_argparse_t *arg, gpgrt_opt_t *opts);
1970 : int gpgrt_argparser (gpgrt_argparse_t *arg, gpgrt_opt_t *opts,
1971 : const char *confname);
1972 : void gpgrt_usage (int level);
1973 : const char *gpgrt_strusage (int level);
1974 : void gpgrt_set_strusage (const char *(*f)(int));
1975 : void gpgrt_set_usage_outfnc (int (*f)(int, const char *));
1976 : void gpgrt_set_fixed_string_mapper (const char *(*f)(const char*));
1977 : void gpgrt_set_confdir (int what, const char *name);
1978 :
1979 :
1980 : /*
1981 : * Various helper functions
1982 : */
1983 :
1984 : /* Compare arbitrary version strings. For the standard m.n.o version
1985 : * numbering scheme a LEVEL of 3 is suitable; see the manual. */
1986 : int gpgrt_cmp_version (const char *a, const char *b, int level);
1987 :
1988 : /* Construct a filename from the NULL terminated list of parts. Tilde
1989 : * expansion is done for the first argument. The caller must release
1990 : * the result using gpgrt_free; on error ERRNO is set and NULL
1991 : * returned. The second function returns an absolute filename. */
1992 : char *gpgrt_fnameconcat (const char *first, ...) GPGRT_ATTR_SENTINEL(0);
1993 : char *gpgrt_absfnameconcat (const char *first, ...) GPGRT_ATTR_SENTINEL(0);
1994 :
1995 :
1996 : #ifdef __cplusplus
1997 : }
1998 : #endif
1999 : #endif /* GPGRT_H */
2000 : #endif /* GPG_ERROR_H */
2001 : /*
2002 : Local Variables:
2003 : buffer-read-only: t
2004 : End:
2005 : */
|