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