File indexing completed on 2025-01-17 09:55:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 #ifndef GPG_ERROR_H
0060 #define GPG_ERROR_H 1
0061 #ifndef GPGRT_H
0062 #define GPGRT_H 1
0063
0064 #include <stddef.h>
0065 #include <stdio.h>
0066 #include <stdarg.h>
0067
0068
0069 #define GPG_ERROR_VERSION "1.50"
0070 #define GPGRT_VERSION "1.50"
0071
0072
0073 #define GPG_ERROR_VERSION_NUMBER 0x013200
0074 #define GPGRT_VERSION_NUMBER 0x013200
0075
0076
0077 #ifdef __GNUC__
0078 # define GPG_ERR_INLINE __inline__
0079 #elif defined(_MSC_VER) && _MSC_VER >= 1300
0080 # define GPG_ERR_INLINE __inline
0081 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
0082 # define GPG_ERR_INLINE inline
0083 #else
0084 # ifndef GPG_ERR_INLINE
0085 # define GPG_ERR_INLINE
0086 # endif
0087 #endif
0088
0089 #ifdef __cplusplus
0090 extern "C" {
0091 #if 0
0092 }
0093 #endif
0094 #endif
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107 typedef enum
0108 {
0109 GPG_ERR_SOURCE_UNKNOWN = 0,
0110 GPG_ERR_SOURCE_GCRYPT = 1,
0111 GPG_ERR_SOURCE_GPG = 2,
0112 GPG_ERR_SOURCE_GPGSM = 3,
0113 GPG_ERR_SOURCE_GPGAGENT = 4,
0114 GPG_ERR_SOURCE_PINENTRY = 5,
0115 GPG_ERR_SOURCE_SCD = 6,
0116 GPG_ERR_SOURCE_GPGME = 7,
0117 GPG_ERR_SOURCE_KEYBOX = 8,
0118 GPG_ERR_SOURCE_KSBA = 9,
0119 GPG_ERR_SOURCE_DIRMNGR = 10,
0120 GPG_ERR_SOURCE_GSTI = 11,
0121 GPG_ERR_SOURCE_GPA = 12,
0122 GPG_ERR_SOURCE_KLEO = 13,
0123 GPG_ERR_SOURCE_G13 = 14,
0124 GPG_ERR_SOURCE_ASSUAN = 15,
0125 GPG_ERR_SOURCE_TPM2D = 16,
0126 GPG_ERR_SOURCE_TLS = 17,
0127 GPG_ERR_SOURCE_TKD = 18,
0128 GPG_ERR_SOURCE_ANY = 31,
0129 GPG_ERR_SOURCE_USER_1 = 32,
0130 GPG_ERR_SOURCE_USER_2 = 33,
0131 GPG_ERR_SOURCE_USER_3 = 34,
0132 GPG_ERR_SOURCE_USER_4 = 35,
0133
0134
0135 GPG_ERR_SOURCE_DIM = 128
0136 } gpg_err_source_t;
0137
0138
0139
0140
0141
0142
0143 typedef enum
0144 {
0145 GPG_ERR_NO_ERROR = 0,
0146 GPG_ERR_GENERAL = 1,
0147 GPG_ERR_UNKNOWN_PACKET = 2,
0148 GPG_ERR_UNKNOWN_VERSION = 3,
0149 GPG_ERR_PUBKEY_ALGO = 4,
0150 GPG_ERR_DIGEST_ALGO = 5,
0151 GPG_ERR_BAD_PUBKEY = 6,
0152 GPG_ERR_BAD_SECKEY = 7,
0153 GPG_ERR_BAD_SIGNATURE = 8,
0154 GPG_ERR_NO_PUBKEY = 9,
0155 GPG_ERR_CHECKSUM = 10,
0156 GPG_ERR_BAD_PASSPHRASE = 11,
0157 GPG_ERR_CIPHER_ALGO = 12,
0158 GPG_ERR_KEYRING_OPEN = 13,
0159 GPG_ERR_INV_PACKET = 14,
0160 GPG_ERR_INV_ARMOR = 15,
0161 GPG_ERR_NO_USER_ID = 16,
0162 GPG_ERR_NO_SECKEY = 17,
0163 GPG_ERR_WRONG_SECKEY = 18,
0164 GPG_ERR_BAD_KEY = 19,
0165 GPG_ERR_COMPR_ALGO = 20,
0166 GPG_ERR_NO_PRIME = 21,
0167 GPG_ERR_NO_ENCODING_METHOD = 22,
0168 GPG_ERR_NO_ENCRYPTION_SCHEME = 23,
0169 GPG_ERR_NO_SIGNATURE_SCHEME = 24,
0170 GPG_ERR_INV_ATTR = 25,
0171 GPG_ERR_NO_VALUE = 26,
0172 GPG_ERR_NOT_FOUND = 27,
0173 GPG_ERR_VALUE_NOT_FOUND = 28,
0174 GPG_ERR_SYNTAX = 29,
0175 GPG_ERR_BAD_MPI = 30,
0176 GPG_ERR_INV_PASSPHRASE = 31,
0177 GPG_ERR_SIG_CLASS = 32,
0178 GPG_ERR_RESOURCE_LIMIT = 33,
0179 GPG_ERR_INV_KEYRING = 34,
0180 GPG_ERR_TRUSTDB = 35,
0181 GPG_ERR_BAD_CERT = 36,
0182 GPG_ERR_INV_USER_ID = 37,
0183 GPG_ERR_UNEXPECTED = 38,
0184 GPG_ERR_TIME_CONFLICT = 39,
0185 GPG_ERR_KEYSERVER = 40,
0186 GPG_ERR_WRONG_PUBKEY_ALGO = 41,
0187 GPG_ERR_TRIBUTE_TO_D_A = 42,
0188 GPG_ERR_WEAK_KEY = 43,
0189 GPG_ERR_INV_KEYLEN = 44,
0190 GPG_ERR_INV_ARG = 45,
0191 GPG_ERR_BAD_URI = 46,
0192 GPG_ERR_INV_URI = 47,
0193 GPG_ERR_NETWORK = 48,
0194 GPG_ERR_UNKNOWN_HOST = 49,
0195 GPG_ERR_SELFTEST_FAILED = 50,
0196 GPG_ERR_NOT_ENCRYPTED = 51,
0197 GPG_ERR_NOT_PROCESSED = 52,
0198 GPG_ERR_UNUSABLE_PUBKEY = 53,
0199 GPG_ERR_UNUSABLE_SECKEY = 54,
0200 GPG_ERR_INV_VALUE = 55,
0201 GPG_ERR_BAD_CERT_CHAIN = 56,
0202 GPG_ERR_MISSING_CERT = 57,
0203 GPG_ERR_NO_DATA = 58,
0204 GPG_ERR_BUG = 59,
0205 GPG_ERR_NOT_SUPPORTED = 60,
0206 GPG_ERR_INV_OP = 61,
0207 GPG_ERR_TIMEOUT = 62,
0208 GPG_ERR_INTERNAL = 63,
0209 GPG_ERR_EOF_GCRYPT = 64,
0210 GPG_ERR_INV_OBJ = 65,
0211 GPG_ERR_TOO_SHORT = 66,
0212 GPG_ERR_TOO_LARGE = 67,
0213 GPG_ERR_NO_OBJ = 68,
0214 GPG_ERR_NOT_IMPLEMENTED = 69,
0215 GPG_ERR_CONFLICT = 70,
0216 GPG_ERR_INV_CIPHER_MODE = 71,
0217 GPG_ERR_INV_FLAG = 72,
0218 GPG_ERR_INV_HANDLE = 73,
0219 GPG_ERR_TRUNCATED = 74,
0220 GPG_ERR_INCOMPLETE_LINE = 75,
0221 GPG_ERR_INV_RESPONSE = 76,
0222 GPG_ERR_NO_AGENT = 77,
0223 GPG_ERR_AGENT = 78,
0224 GPG_ERR_INV_DATA = 79,
0225 GPG_ERR_ASSUAN_SERVER_FAULT = 80,
0226 GPG_ERR_ASSUAN = 81,
0227 GPG_ERR_INV_SESSION_KEY = 82,
0228 GPG_ERR_INV_SEXP = 83,
0229 GPG_ERR_UNSUPPORTED_ALGORITHM = 84,
0230 GPG_ERR_NO_PIN_ENTRY = 85,
0231 GPG_ERR_PIN_ENTRY = 86,
0232 GPG_ERR_BAD_PIN = 87,
0233 GPG_ERR_INV_NAME = 88,
0234 GPG_ERR_BAD_DATA = 89,
0235 GPG_ERR_INV_PARAMETER = 90,
0236 GPG_ERR_WRONG_CARD = 91,
0237 GPG_ERR_NO_DIRMNGR = 92,
0238 GPG_ERR_DIRMNGR = 93,
0239 GPG_ERR_CERT_REVOKED = 94,
0240 GPG_ERR_NO_CRL_KNOWN = 95,
0241 GPG_ERR_CRL_TOO_OLD = 96,
0242 GPG_ERR_LINE_TOO_LONG = 97,
0243 GPG_ERR_NOT_TRUSTED = 98,
0244 GPG_ERR_CANCELED = 99,
0245 GPG_ERR_BAD_CA_CERT = 100,
0246 GPG_ERR_CERT_EXPIRED = 101,
0247 GPG_ERR_CERT_TOO_YOUNG = 102,
0248 GPG_ERR_UNSUPPORTED_CERT = 103,
0249 GPG_ERR_UNKNOWN_SEXP = 104,
0250 GPG_ERR_UNSUPPORTED_PROTECTION = 105,
0251 GPG_ERR_CORRUPTED_PROTECTION = 106,
0252 GPG_ERR_AMBIGUOUS_NAME = 107,
0253 GPG_ERR_CARD = 108,
0254 GPG_ERR_CARD_RESET = 109,
0255 GPG_ERR_CARD_REMOVED = 110,
0256 GPG_ERR_INV_CARD = 111,
0257 GPG_ERR_CARD_NOT_PRESENT = 112,
0258 GPG_ERR_NO_PKCS15_APP = 113,
0259 GPG_ERR_NOT_CONFIRMED = 114,
0260 GPG_ERR_CONFIGURATION = 115,
0261 GPG_ERR_NO_POLICY_MATCH = 116,
0262 GPG_ERR_INV_INDEX = 117,
0263 GPG_ERR_INV_ID = 118,
0264 GPG_ERR_NO_SCDAEMON = 119,
0265 GPG_ERR_SCDAEMON = 120,
0266 GPG_ERR_UNSUPPORTED_PROTOCOL = 121,
0267 GPG_ERR_BAD_PIN_METHOD = 122,
0268 GPG_ERR_CARD_NOT_INITIALIZED = 123,
0269 GPG_ERR_UNSUPPORTED_OPERATION = 124,
0270 GPG_ERR_WRONG_KEY_USAGE = 125,
0271 GPG_ERR_NOTHING_FOUND = 126,
0272 GPG_ERR_WRONG_BLOB_TYPE = 127,
0273 GPG_ERR_MISSING_VALUE = 128,
0274 GPG_ERR_HARDWARE = 129,
0275 GPG_ERR_PIN_BLOCKED = 130,
0276 GPG_ERR_USE_CONDITIONS = 131,
0277 GPG_ERR_PIN_NOT_SYNCED = 132,
0278 GPG_ERR_INV_CRL = 133,
0279 GPG_ERR_BAD_BER = 134,
0280 GPG_ERR_INV_BER = 135,
0281 GPG_ERR_ELEMENT_NOT_FOUND = 136,
0282 GPG_ERR_IDENTIFIER_NOT_FOUND = 137,
0283 GPG_ERR_INV_TAG = 138,
0284 GPG_ERR_INV_LENGTH = 139,
0285 GPG_ERR_INV_KEYINFO = 140,
0286 GPG_ERR_UNEXPECTED_TAG = 141,
0287 GPG_ERR_NOT_DER_ENCODED = 142,
0288 GPG_ERR_NO_CMS_OBJ = 143,
0289 GPG_ERR_INV_CMS_OBJ = 144,
0290 GPG_ERR_UNKNOWN_CMS_OBJ = 145,
0291 GPG_ERR_UNSUPPORTED_CMS_OBJ = 146,
0292 GPG_ERR_UNSUPPORTED_ENCODING = 147,
0293 GPG_ERR_UNSUPPORTED_CMS_VERSION = 148,
0294 GPG_ERR_UNKNOWN_ALGORITHM = 149,
0295 GPG_ERR_INV_ENGINE = 150,
0296 GPG_ERR_PUBKEY_NOT_TRUSTED = 151,
0297 GPG_ERR_DECRYPT_FAILED = 152,
0298 GPG_ERR_KEY_EXPIRED = 153,
0299 GPG_ERR_SIG_EXPIRED = 154,
0300 GPG_ERR_ENCODING_PROBLEM = 155,
0301 GPG_ERR_INV_STATE = 156,
0302 GPG_ERR_DUP_VALUE = 157,
0303 GPG_ERR_MISSING_ACTION = 158,
0304 GPG_ERR_MODULE_NOT_FOUND = 159,
0305 GPG_ERR_INV_OID_STRING = 160,
0306 GPG_ERR_INV_TIME = 161,
0307 GPG_ERR_INV_CRL_OBJ = 162,
0308 GPG_ERR_UNSUPPORTED_CRL_VERSION = 163,
0309 GPG_ERR_INV_CERT_OBJ = 164,
0310 GPG_ERR_UNKNOWN_NAME = 165,
0311 GPG_ERR_LOCALE_PROBLEM = 166,
0312 GPG_ERR_NOT_LOCKED = 167,
0313 GPG_ERR_PROTOCOL_VIOLATION = 168,
0314 GPG_ERR_INV_MAC = 169,
0315 GPG_ERR_INV_REQUEST = 170,
0316 GPG_ERR_UNKNOWN_EXTN = 171,
0317 GPG_ERR_UNKNOWN_CRIT_EXTN = 172,
0318 GPG_ERR_LOCKED = 173,
0319 GPG_ERR_UNKNOWN_OPTION = 174,
0320 GPG_ERR_UNKNOWN_COMMAND = 175,
0321 GPG_ERR_NOT_OPERATIONAL = 176,
0322 GPG_ERR_NO_PASSPHRASE = 177,
0323 GPG_ERR_NO_PIN = 178,
0324 GPG_ERR_NOT_ENABLED = 179,
0325 GPG_ERR_NO_ENGINE = 180,
0326 GPG_ERR_MISSING_KEY = 181,
0327 GPG_ERR_TOO_MANY = 182,
0328 GPG_ERR_LIMIT_REACHED = 183,
0329 GPG_ERR_NOT_INITIALIZED = 184,
0330 GPG_ERR_MISSING_ISSUER_CERT = 185,
0331 GPG_ERR_NO_KEYSERVER = 186,
0332 GPG_ERR_INV_CURVE = 187,
0333 GPG_ERR_UNKNOWN_CURVE = 188,
0334 GPG_ERR_DUP_KEY = 189,
0335 GPG_ERR_AMBIGUOUS = 190,
0336 GPG_ERR_NO_CRYPT_CTX = 191,
0337 GPG_ERR_WRONG_CRYPT_CTX = 192,
0338 GPG_ERR_BAD_CRYPT_CTX = 193,
0339 GPG_ERR_CRYPT_CTX_CONFLICT = 194,
0340 GPG_ERR_BROKEN_PUBKEY = 195,
0341 GPG_ERR_BROKEN_SECKEY = 196,
0342 GPG_ERR_MAC_ALGO = 197,
0343 GPG_ERR_FULLY_CANCELED = 198,
0344 GPG_ERR_UNFINISHED = 199,
0345 GPG_ERR_BUFFER_TOO_SHORT = 200,
0346 GPG_ERR_SEXP_INV_LEN_SPEC = 201,
0347 GPG_ERR_SEXP_STRING_TOO_LONG = 202,
0348 GPG_ERR_SEXP_UNMATCHED_PAREN = 203,
0349 GPG_ERR_SEXP_NOT_CANONICAL = 204,
0350 GPG_ERR_SEXP_BAD_CHARACTER = 205,
0351 GPG_ERR_SEXP_BAD_QUOTATION = 206,
0352 GPG_ERR_SEXP_ZERO_PREFIX = 207,
0353 GPG_ERR_SEXP_NESTED_DH = 208,
0354 GPG_ERR_SEXP_UNMATCHED_DH = 209,
0355 GPG_ERR_SEXP_UNEXPECTED_PUNC = 210,
0356 GPG_ERR_SEXP_BAD_HEX_CHAR = 211,
0357 GPG_ERR_SEXP_ODD_HEX_NUMBERS = 212,
0358 GPG_ERR_SEXP_BAD_OCT_CHAR = 213,
0359 GPG_ERR_SUBKEYS_EXP_OR_REV = 217,
0360 GPG_ERR_DB_CORRUPTED = 218,
0361 GPG_ERR_SERVER_FAILED = 219,
0362 GPG_ERR_NO_NAME = 220,
0363 GPG_ERR_NO_KEY = 221,
0364 GPG_ERR_LEGACY_KEY = 222,
0365 GPG_ERR_REQUEST_TOO_SHORT = 223,
0366 GPG_ERR_REQUEST_TOO_LONG = 224,
0367 GPG_ERR_OBJ_TERM_STATE = 225,
0368 GPG_ERR_NO_CERT_CHAIN = 226,
0369 GPG_ERR_CERT_TOO_LARGE = 227,
0370 GPG_ERR_INV_RECORD = 228,
0371 GPG_ERR_BAD_MAC = 229,
0372 GPG_ERR_UNEXPECTED_MSG = 230,
0373 GPG_ERR_COMPR_FAILED = 231,
0374 GPG_ERR_WOULD_WRAP = 232,
0375 GPG_ERR_FATAL_ALERT = 233,
0376 GPG_ERR_NO_CIPHER = 234,
0377 GPG_ERR_MISSING_CLIENT_CERT = 235,
0378 GPG_ERR_CLOSE_NOTIFY = 236,
0379 GPG_ERR_TICKET_EXPIRED = 237,
0380 GPG_ERR_BAD_TICKET = 238,
0381 GPG_ERR_UNKNOWN_IDENTITY = 239,
0382 GPG_ERR_BAD_HS_CERT = 240,
0383 GPG_ERR_BAD_HS_CERT_REQ = 241,
0384 GPG_ERR_BAD_HS_CERT_VER = 242,
0385 GPG_ERR_BAD_HS_CHANGE_CIPHER = 243,
0386 GPG_ERR_BAD_HS_CLIENT_HELLO = 244,
0387 GPG_ERR_BAD_HS_SERVER_HELLO = 245,
0388 GPG_ERR_BAD_HS_SERVER_HELLO_DONE = 246,
0389 GPG_ERR_BAD_HS_FINISHED = 247,
0390 GPG_ERR_BAD_HS_SERVER_KEX = 248,
0391 GPG_ERR_BAD_HS_CLIENT_KEX = 249,
0392 GPG_ERR_BOGUS_STRING = 250,
0393 GPG_ERR_FORBIDDEN = 251,
0394 GPG_ERR_KEY_DISABLED = 252,
0395 GPG_ERR_KEY_ON_CARD = 253,
0396 GPG_ERR_INV_LOCK_OBJ = 254,
0397 GPG_ERR_TRUE = 255,
0398 GPG_ERR_FALSE = 256,
0399 GPG_ERR_ASS_GENERAL = 257,
0400 GPG_ERR_ASS_ACCEPT_FAILED = 258,
0401 GPG_ERR_ASS_CONNECT_FAILED = 259,
0402 GPG_ERR_ASS_INV_RESPONSE = 260,
0403 GPG_ERR_ASS_INV_VALUE = 261,
0404 GPG_ERR_ASS_INCOMPLETE_LINE = 262,
0405 GPG_ERR_ASS_LINE_TOO_LONG = 263,
0406 GPG_ERR_ASS_NESTED_COMMANDS = 264,
0407 GPG_ERR_ASS_NO_DATA_CB = 265,
0408 GPG_ERR_ASS_NO_INQUIRE_CB = 266,
0409 GPG_ERR_ASS_NOT_A_SERVER = 267,
0410 GPG_ERR_ASS_NOT_A_CLIENT = 268,
0411 GPG_ERR_ASS_SERVER_START = 269,
0412 GPG_ERR_ASS_READ_ERROR = 270,
0413 GPG_ERR_ASS_WRITE_ERROR = 271,
0414 GPG_ERR_ASS_TOO_MUCH_DATA = 273,
0415 GPG_ERR_ASS_UNEXPECTED_CMD = 274,
0416 GPG_ERR_ASS_UNKNOWN_CMD = 275,
0417 GPG_ERR_ASS_SYNTAX = 276,
0418 GPG_ERR_ASS_CANCELED = 277,
0419 GPG_ERR_ASS_NO_INPUT = 278,
0420 GPG_ERR_ASS_NO_OUTPUT = 279,
0421 GPG_ERR_ASS_PARAMETER = 280,
0422 GPG_ERR_ASS_UNKNOWN_INQUIRE = 281,
0423 GPG_ERR_ENGINE_TOO_OLD = 300,
0424 GPG_ERR_WINDOW_TOO_SMALL = 301,
0425 GPG_ERR_WINDOW_TOO_LARGE = 302,
0426 GPG_ERR_MISSING_ENVVAR = 303,
0427 GPG_ERR_USER_ID_EXISTS = 304,
0428 GPG_ERR_NAME_EXISTS = 305,
0429 GPG_ERR_DUP_NAME = 306,
0430 GPG_ERR_TOO_YOUNG = 307,
0431 GPG_ERR_TOO_OLD = 308,
0432 GPG_ERR_UNKNOWN_FLAG = 309,
0433 GPG_ERR_INV_ORDER = 310,
0434 GPG_ERR_ALREADY_FETCHED = 311,
0435 GPG_ERR_TRY_LATER = 312,
0436 GPG_ERR_WRONG_NAME = 313,
0437 GPG_ERR_NO_AUTH = 314,
0438 GPG_ERR_BAD_AUTH = 315,
0439 GPG_ERR_NO_KEYBOXD = 316,
0440 GPG_ERR_KEYBOXD = 317,
0441 GPG_ERR_NO_SERVICE = 318,
0442 GPG_ERR_SERVICE = 319,
0443 GPG_ERR_BAD_PUK = 320,
0444 GPG_ERR_NO_RESET_CODE = 321,
0445 GPG_ERR_BAD_RESET_CODE = 322,
0446 GPG_ERR_SYSTEM_BUG = 666,
0447 GPG_ERR_DNS_UNKNOWN = 711,
0448 GPG_ERR_DNS_SECTION = 712,
0449 GPG_ERR_DNS_ADDRESS = 713,
0450 GPG_ERR_DNS_NO_QUERY = 714,
0451 GPG_ERR_DNS_NO_ANSWER = 715,
0452 GPG_ERR_DNS_CLOSED = 716,
0453 GPG_ERR_DNS_VERIFY = 717,
0454 GPG_ERR_DNS_TIMEOUT = 718,
0455 GPG_ERR_LDAP_GENERAL = 721,
0456 GPG_ERR_LDAP_ATTR_GENERAL = 722,
0457 GPG_ERR_LDAP_NAME_GENERAL = 723,
0458 GPG_ERR_LDAP_SECURITY_GENERAL = 724,
0459 GPG_ERR_LDAP_SERVICE_GENERAL = 725,
0460 GPG_ERR_LDAP_UPDATE_GENERAL = 726,
0461 GPG_ERR_LDAP_E_GENERAL = 727,
0462 GPG_ERR_LDAP_X_GENERAL = 728,
0463 GPG_ERR_LDAP_OTHER_GENERAL = 729,
0464 GPG_ERR_LDAP_X_CONNECTING = 750,
0465 GPG_ERR_LDAP_REFERRAL_LIMIT = 751,
0466 GPG_ERR_LDAP_CLIENT_LOOP = 752,
0467 GPG_ERR_LDAP_NO_RESULTS = 754,
0468 GPG_ERR_LDAP_CONTROL_NOT_FOUND = 755,
0469 GPG_ERR_LDAP_NOT_SUPPORTED = 756,
0470 GPG_ERR_LDAP_CONNECT = 757,
0471 GPG_ERR_LDAP_NO_MEMORY = 758,
0472 GPG_ERR_LDAP_PARAM = 759,
0473 GPG_ERR_LDAP_USER_CANCELLED = 760,
0474 GPG_ERR_LDAP_FILTER = 761,
0475 GPG_ERR_LDAP_AUTH_UNKNOWN = 762,
0476 GPG_ERR_LDAP_TIMEOUT = 763,
0477 GPG_ERR_LDAP_DECODING = 764,
0478 GPG_ERR_LDAP_ENCODING = 765,
0479 GPG_ERR_LDAP_LOCAL = 766,
0480 GPG_ERR_LDAP_SERVER_DOWN = 767,
0481 GPG_ERR_LDAP_SUCCESS = 768,
0482 GPG_ERR_LDAP_OPERATIONS = 769,
0483 GPG_ERR_LDAP_PROTOCOL = 770,
0484 GPG_ERR_LDAP_TIMELIMIT = 771,
0485 GPG_ERR_LDAP_SIZELIMIT = 772,
0486 GPG_ERR_LDAP_COMPARE_FALSE = 773,
0487 GPG_ERR_LDAP_COMPARE_TRUE = 774,
0488 GPG_ERR_LDAP_UNSUPPORTED_AUTH = 775,
0489 GPG_ERR_LDAP_STRONG_AUTH_RQRD = 776,
0490 GPG_ERR_LDAP_PARTIAL_RESULTS = 777,
0491 GPG_ERR_LDAP_REFERRAL = 778,
0492 GPG_ERR_LDAP_ADMINLIMIT = 779,
0493 GPG_ERR_LDAP_UNAVAIL_CRIT_EXTN = 780,
0494 GPG_ERR_LDAP_CONFIDENT_RQRD = 781,
0495 GPG_ERR_LDAP_SASL_BIND_INPROG = 782,
0496 GPG_ERR_LDAP_NO_SUCH_ATTRIBUTE = 784,
0497 GPG_ERR_LDAP_UNDEFINED_TYPE = 785,
0498 GPG_ERR_LDAP_BAD_MATCHING = 786,
0499 GPG_ERR_LDAP_CONST_VIOLATION = 787,
0500 GPG_ERR_LDAP_TYPE_VALUE_EXISTS = 788,
0501 GPG_ERR_LDAP_INV_SYNTAX = 789,
0502 GPG_ERR_LDAP_NO_SUCH_OBJ = 800,
0503 GPG_ERR_LDAP_ALIAS_PROBLEM = 801,
0504 GPG_ERR_LDAP_INV_DN_SYNTAX = 802,
0505 GPG_ERR_LDAP_IS_LEAF = 803,
0506 GPG_ERR_LDAP_ALIAS_DEREF = 804,
0507 GPG_ERR_LDAP_X_PROXY_AUTH_FAIL = 815,
0508 GPG_ERR_LDAP_BAD_AUTH = 816,
0509 GPG_ERR_LDAP_INV_CREDENTIALS = 817,
0510 GPG_ERR_LDAP_INSUFFICIENT_ACC = 818,
0511 GPG_ERR_LDAP_BUSY = 819,
0512 GPG_ERR_LDAP_UNAVAILABLE = 820,
0513 GPG_ERR_LDAP_UNWILL_TO_PERFORM = 821,
0514 GPG_ERR_LDAP_LOOP_DETECT = 822,
0515 GPG_ERR_LDAP_NAMING_VIOLATION = 832,
0516 GPG_ERR_LDAP_OBJ_CLS_VIOLATION = 833,
0517 GPG_ERR_LDAP_NOT_ALLOW_NONLEAF = 834,
0518 GPG_ERR_LDAP_NOT_ALLOW_ON_RDN = 835,
0519 GPG_ERR_LDAP_ALREADY_EXISTS = 836,
0520 GPG_ERR_LDAP_NO_OBJ_CLASS_MODS = 837,
0521 GPG_ERR_LDAP_RESULTS_TOO_LARGE = 838,
0522 GPG_ERR_LDAP_AFFECTS_MULT_DSAS = 839,
0523 GPG_ERR_LDAP_VLV = 844,
0524 GPG_ERR_LDAP_OTHER = 848,
0525 GPG_ERR_LDAP_CUP_RESOURCE_LIMIT = 881,
0526 GPG_ERR_LDAP_CUP_SEC_VIOLATION = 882,
0527 GPG_ERR_LDAP_CUP_INV_DATA = 883,
0528 GPG_ERR_LDAP_CUP_UNSUP_SCHEME = 884,
0529 GPG_ERR_LDAP_CUP_RELOAD = 885,
0530 GPG_ERR_LDAP_CANCELLED = 886,
0531 GPG_ERR_LDAP_NO_SUCH_OPERATION = 887,
0532 GPG_ERR_LDAP_TOO_LATE = 888,
0533 GPG_ERR_LDAP_CANNOT_CANCEL = 889,
0534 GPG_ERR_LDAP_ASSERTION_FAILED = 890,
0535 GPG_ERR_LDAP_PROX_AUTH_DENIED = 891,
0536 GPG_ERR_USER_1 = 1024,
0537 GPG_ERR_USER_2 = 1025,
0538 GPG_ERR_USER_3 = 1026,
0539 GPG_ERR_USER_4 = 1027,
0540 GPG_ERR_USER_5 = 1028,
0541 GPG_ERR_USER_6 = 1029,
0542 GPG_ERR_USER_7 = 1030,
0543 GPG_ERR_USER_8 = 1031,
0544 GPG_ERR_USER_9 = 1032,
0545 GPG_ERR_USER_10 = 1033,
0546 GPG_ERR_USER_11 = 1034,
0547 GPG_ERR_USER_12 = 1035,
0548 GPG_ERR_USER_13 = 1036,
0549 GPG_ERR_USER_14 = 1037,
0550 GPG_ERR_USER_15 = 1038,
0551 GPG_ERR_USER_16 = 1039,
0552 GPG_ERR_SQL_OK = 1500,
0553 GPG_ERR_SQL_ERROR = 1501,
0554 GPG_ERR_SQL_INTERNAL = 1502,
0555 GPG_ERR_SQL_PERM = 1503,
0556 GPG_ERR_SQL_ABORT = 1504,
0557 GPG_ERR_SQL_BUSY = 1505,
0558 GPG_ERR_SQL_LOCKED = 1506,
0559 GPG_ERR_SQL_NOMEM = 1507,
0560 GPG_ERR_SQL_READONLY = 1508,
0561 GPG_ERR_SQL_INTERRUPT = 1509,
0562 GPG_ERR_SQL_IOERR = 1510,
0563 GPG_ERR_SQL_CORRUPT = 1511,
0564 GPG_ERR_SQL_NOTFOUND = 1512,
0565 GPG_ERR_SQL_FULL = 1513,
0566 GPG_ERR_SQL_CANTOPEN = 1514,
0567 GPG_ERR_SQL_PROTOCOL = 1515,
0568 GPG_ERR_SQL_EMPTY = 1516,
0569 GPG_ERR_SQL_SCHEMA = 1517,
0570 GPG_ERR_SQL_TOOBIG = 1518,
0571 GPG_ERR_SQL_CONSTRAINT = 1519,
0572 GPG_ERR_SQL_MISMATCH = 1520,
0573 GPG_ERR_SQL_MISUSE = 1521,
0574 GPG_ERR_SQL_NOLFS = 1522,
0575 GPG_ERR_SQL_AUTH = 1523,
0576 GPG_ERR_SQL_FORMAT = 1524,
0577 GPG_ERR_SQL_RANGE = 1525,
0578 GPG_ERR_SQL_NOTADB = 1526,
0579 GPG_ERR_SQL_NOTICE = 1527,
0580 GPG_ERR_SQL_WARNING = 1528,
0581 GPG_ERR_SQL_ROW = 1600,
0582 GPG_ERR_SQL_DONE = 1601,
0583 GPG_ERR_MISSING_ERRNO = 16381,
0584 GPG_ERR_UNKNOWN_ERRNO = 16382,
0585 GPG_ERR_EOF = 16383,
0586
0587
0588 #define GPG_ERR_SYSTEM_ERROR (1 << 15)
0589 GPG_ERR_E2BIG = GPG_ERR_SYSTEM_ERROR | 0,
0590 GPG_ERR_EACCES = GPG_ERR_SYSTEM_ERROR | 1,
0591 GPG_ERR_EADDRINUSE = GPG_ERR_SYSTEM_ERROR | 2,
0592 GPG_ERR_EADDRNOTAVAIL = GPG_ERR_SYSTEM_ERROR | 3,
0593 GPG_ERR_EADV = GPG_ERR_SYSTEM_ERROR | 4,
0594 GPG_ERR_EAFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 5,
0595 GPG_ERR_EAGAIN = GPG_ERR_SYSTEM_ERROR | 6,
0596 GPG_ERR_EALREADY = GPG_ERR_SYSTEM_ERROR | 7,
0597 GPG_ERR_EAUTH = GPG_ERR_SYSTEM_ERROR | 8,
0598 GPG_ERR_EBACKGROUND = GPG_ERR_SYSTEM_ERROR | 9,
0599 GPG_ERR_EBADE = GPG_ERR_SYSTEM_ERROR | 10,
0600 GPG_ERR_EBADF = GPG_ERR_SYSTEM_ERROR | 11,
0601 GPG_ERR_EBADFD = GPG_ERR_SYSTEM_ERROR | 12,
0602 GPG_ERR_EBADMSG = GPG_ERR_SYSTEM_ERROR | 13,
0603 GPG_ERR_EBADR = GPG_ERR_SYSTEM_ERROR | 14,
0604 GPG_ERR_EBADRPC = GPG_ERR_SYSTEM_ERROR | 15,
0605 GPG_ERR_EBADRQC = GPG_ERR_SYSTEM_ERROR | 16,
0606 GPG_ERR_EBADSLT = GPG_ERR_SYSTEM_ERROR | 17,
0607 GPG_ERR_EBFONT = GPG_ERR_SYSTEM_ERROR | 18,
0608 GPG_ERR_EBUSY = GPG_ERR_SYSTEM_ERROR | 19,
0609 GPG_ERR_ECANCELED = GPG_ERR_SYSTEM_ERROR | 20,
0610 GPG_ERR_ECHILD = GPG_ERR_SYSTEM_ERROR | 21,
0611 GPG_ERR_ECHRNG = GPG_ERR_SYSTEM_ERROR | 22,
0612 GPG_ERR_ECOMM = GPG_ERR_SYSTEM_ERROR | 23,
0613 GPG_ERR_ECONNABORTED = GPG_ERR_SYSTEM_ERROR | 24,
0614 GPG_ERR_ECONNREFUSED = GPG_ERR_SYSTEM_ERROR | 25,
0615 GPG_ERR_ECONNRESET = GPG_ERR_SYSTEM_ERROR | 26,
0616 GPG_ERR_ED = GPG_ERR_SYSTEM_ERROR | 27,
0617 GPG_ERR_EDEADLK = GPG_ERR_SYSTEM_ERROR | 28,
0618 GPG_ERR_EDEADLOCK = GPG_ERR_SYSTEM_ERROR | 29,
0619 GPG_ERR_EDESTADDRREQ = GPG_ERR_SYSTEM_ERROR | 30,
0620 GPG_ERR_EDIED = GPG_ERR_SYSTEM_ERROR | 31,
0621 GPG_ERR_EDOM = GPG_ERR_SYSTEM_ERROR | 32,
0622 GPG_ERR_EDOTDOT = GPG_ERR_SYSTEM_ERROR | 33,
0623 GPG_ERR_EDQUOT = GPG_ERR_SYSTEM_ERROR | 34,
0624 GPG_ERR_EEXIST = GPG_ERR_SYSTEM_ERROR | 35,
0625 GPG_ERR_EFAULT = GPG_ERR_SYSTEM_ERROR | 36,
0626 GPG_ERR_EFBIG = GPG_ERR_SYSTEM_ERROR | 37,
0627 GPG_ERR_EFTYPE = GPG_ERR_SYSTEM_ERROR | 38,
0628 GPG_ERR_EGRATUITOUS = GPG_ERR_SYSTEM_ERROR | 39,
0629 GPG_ERR_EGREGIOUS = GPG_ERR_SYSTEM_ERROR | 40,
0630 GPG_ERR_EHOSTDOWN = GPG_ERR_SYSTEM_ERROR | 41,
0631 GPG_ERR_EHOSTUNREACH = GPG_ERR_SYSTEM_ERROR | 42,
0632 GPG_ERR_EIDRM = GPG_ERR_SYSTEM_ERROR | 43,
0633 GPG_ERR_EIEIO = GPG_ERR_SYSTEM_ERROR | 44,
0634 GPG_ERR_EILSEQ = GPG_ERR_SYSTEM_ERROR | 45,
0635 GPG_ERR_EINPROGRESS = GPG_ERR_SYSTEM_ERROR | 46,
0636 GPG_ERR_EINTR = GPG_ERR_SYSTEM_ERROR | 47,
0637 GPG_ERR_EINVAL = GPG_ERR_SYSTEM_ERROR | 48,
0638 GPG_ERR_EIO = GPG_ERR_SYSTEM_ERROR | 49,
0639 GPG_ERR_EISCONN = GPG_ERR_SYSTEM_ERROR | 50,
0640 GPG_ERR_EISDIR = GPG_ERR_SYSTEM_ERROR | 51,
0641 GPG_ERR_EISNAM = GPG_ERR_SYSTEM_ERROR | 52,
0642 GPG_ERR_EL2HLT = GPG_ERR_SYSTEM_ERROR | 53,
0643 GPG_ERR_EL2NSYNC = GPG_ERR_SYSTEM_ERROR | 54,
0644 GPG_ERR_EL3HLT = GPG_ERR_SYSTEM_ERROR | 55,
0645 GPG_ERR_EL3RST = GPG_ERR_SYSTEM_ERROR | 56,
0646 GPG_ERR_ELIBACC = GPG_ERR_SYSTEM_ERROR | 57,
0647 GPG_ERR_ELIBBAD = GPG_ERR_SYSTEM_ERROR | 58,
0648 GPG_ERR_ELIBEXEC = GPG_ERR_SYSTEM_ERROR | 59,
0649 GPG_ERR_ELIBMAX = GPG_ERR_SYSTEM_ERROR | 60,
0650 GPG_ERR_ELIBSCN = GPG_ERR_SYSTEM_ERROR | 61,
0651 GPG_ERR_ELNRNG = GPG_ERR_SYSTEM_ERROR | 62,
0652 GPG_ERR_ELOOP = GPG_ERR_SYSTEM_ERROR | 63,
0653 GPG_ERR_EMEDIUMTYPE = GPG_ERR_SYSTEM_ERROR | 64,
0654 GPG_ERR_EMFILE = GPG_ERR_SYSTEM_ERROR | 65,
0655 GPG_ERR_EMLINK = GPG_ERR_SYSTEM_ERROR | 66,
0656 GPG_ERR_EMSGSIZE = GPG_ERR_SYSTEM_ERROR | 67,
0657 GPG_ERR_EMULTIHOP = GPG_ERR_SYSTEM_ERROR | 68,
0658 GPG_ERR_ENAMETOOLONG = GPG_ERR_SYSTEM_ERROR | 69,
0659 GPG_ERR_ENAVAIL = GPG_ERR_SYSTEM_ERROR | 70,
0660 GPG_ERR_ENEEDAUTH = GPG_ERR_SYSTEM_ERROR | 71,
0661 GPG_ERR_ENETDOWN = GPG_ERR_SYSTEM_ERROR | 72,
0662 GPG_ERR_ENETRESET = GPG_ERR_SYSTEM_ERROR | 73,
0663 GPG_ERR_ENETUNREACH = GPG_ERR_SYSTEM_ERROR | 74,
0664 GPG_ERR_ENFILE = GPG_ERR_SYSTEM_ERROR | 75,
0665 GPG_ERR_ENOANO = GPG_ERR_SYSTEM_ERROR | 76,
0666 GPG_ERR_ENOBUFS = GPG_ERR_SYSTEM_ERROR | 77,
0667 GPG_ERR_ENOCSI = GPG_ERR_SYSTEM_ERROR | 78,
0668 GPG_ERR_ENODATA = GPG_ERR_SYSTEM_ERROR | 79,
0669 GPG_ERR_ENODEV = GPG_ERR_SYSTEM_ERROR | 80,
0670 GPG_ERR_ENOENT = GPG_ERR_SYSTEM_ERROR | 81,
0671 GPG_ERR_ENOEXEC = GPG_ERR_SYSTEM_ERROR | 82,
0672 GPG_ERR_ENOLCK = GPG_ERR_SYSTEM_ERROR | 83,
0673 GPG_ERR_ENOLINK = GPG_ERR_SYSTEM_ERROR | 84,
0674 GPG_ERR_ENOMEDIUM = GPG_ERR_SYSTEM_ERROR | 85,
0675 GPG_ERR_ENOMEM = GPG_ERR_SYSTEM_ERROR | 86,
0676 GPG_ERR_ENOMSG = GPG_ERR_SYSTEM_ERROR | 87,
0677 GPG_ERR_ENONET = GPG_ERR_SYSTEM_ERROR | 88,
0678 GPG_ERR_ENOPKG = GPG_ERR_SYSTEM_ERROR | 89,
0679 GPG_ERR_ENOPROTOOPT = GPG_ERR_SYSTEM_ERROR | 90,
0680 GPG_ERR_ENOSPC = GPG_ERR_SYSTEM_ERROR | 91,
0681 GPG_ERR_ENOSR = GPG_ERR_SYSTEM_ERROR | 92,
0682 GPG_ERR_ENOSTR = GPG_ERR_SYSTEM_ERROR | 93,
0683 GPG_ERR_ENOSYS = GPG_ERR_SYSTEM_ERROR | 94,
0684 GPG_ERR_ENOTBLK = GPG_ERR_SYSTEM_ERROR | 95,
0685 GPG_ERR_ENOTCONN = GPG_ERR_SYSTEM_ERROR | 96,
0686 GPG_ERR_ENOTDIR = GPG_ERR_SYSTEM_ERROR | 97,
0687 GPG_ERR_ENOTEMPTY = GPG_ERR_SYSTEM_ERROR | 98,
0688 GPG_ERR_ENOTNAM = GPG_ERR_SYSTEM_ERROR | 99,
0689 GPG_ERR_ENOTSOCK = GPG_ERR_SYSTEM_ERROR | 100,
0690 GPG_ERR_ENOTSUP = GPG_ERR_SYSTEM_ERROR | 101,
0691 GPG_ERR_ENOTTY = GPG_ERR_SYSTEM_ERROR | 102,
0692 GPG_ERR_ENOTUNIQ = GPG_ERR_SYSTEM_ERROR | 103,
0693 GPG_ERR_ENXIO = GPG_ERR_SYSTEM_ERROR | 104,
0694 GPG_ERR_EOPNOTSUPP = GPG_ERR_SYSTEM_ERROR | 105,
0695 GPG_ERR_EOVERFLOW = GPG_ERR_SYSTEM_ERROR | 106,
0696 GPG_ERR_EPERM = GPG_ERR_SYSTEM_ERROR | 107,
0697 GPG_ERR_EPFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 108,
0698 GPG_ERR_EPIPE = GPG_ERR_SYSTEM_ERROR | 109,
0699 GPG_ERR_EPROCLIM = GPG_ERR_SYSTEM_ERROR | 110,
0700 GPG_ERR_EPROCUNAVAIL = GPG_ERR_SYSTEM_ERROR | 111,
0701 GPG_ERR_EPROGMISMATCH = GPG_ERR_SYSTEM_ERROR | 112,
0702 GPG_ERR_EPROGUNAVAIL = GPG_ERR_SYSTEM_ERROR | 113,
0703 GPG_ERR_EPROTO = GPG_ERR_SYSTEM_ERROR | 114,
0704 GPG_ERR_EPROTONOSUPPORT = GPG_ERR_SYSTEM_ERROR | 115,
0705 GPG_ERR_EPROTOTYPE = GPG_ERR_SYSTEM_ERROR | 116,
0706 GPG_ERR_ERANGE = GPG_ERR_SYSTEM_ERROR | 117,
0707 GPG_ERR_EREMCHG = GPG_ERR_SYSTEM_ERROR | 118,
0708 GPG_ERR_EREMOTE = GPG_ERR_SYSTEM_ERROR | 119,
0709 GPG_ERR_EREMOTEIO = GPG_ERR_SYSTEM_ERROR | 120,
0710 GPG_ERR_ERESTART = GPG_ERR_SYSTEM_ERROR | 121,
0711 GPG_ERR_EROFS = GPG_ERR_SYSTEM_ERROR | 122,
0712 GPG_ERR_ERPCMISMATCH = GPG_ERR_SYSTEM_ERROR | 123,
0713 GPG_ERR_ESHUTDOWN = GPG_ERR_SYSTEM_ERROR | 124,
0714 GPG_ERR_ESOCKTNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 125,
0715 GPG_ERR_ESPIPE = GPG_ERR_SYSTEM_ERROR | 126,
0716 GPG_ERR_ESRCH = GPG_ERR_SYSTEM_ERROR | 127,
0717 GPG_ERR_ESRMNT = GPG_ERR_SYSTEM_ERROR | 128,
0718 GPG_ERR_ESTALE = GPG_ERR_SYSTEM_ERROR | 129,
0719 GPG_ERR_ESTRPIPE = GPG_ERR_SYSTEM_ERROR | 130,
0720 GPG_ERR_ETIME = GPG_ERR_SYSTEM_ERROR | 131,
0721 GPG_ERR_ETIMEDOUT = GPG_ERR_SYSTEM_ERROR | 132,
0722 GPG_ERR_ETOOMANYREFS = GPG_ERR_SYSTEM_ERROR | 133,
0723 GPG_ERR_ETXTBSY = GPG_ERR_SYSTEM_ERROR | 134,
0724 GPG_ERR_EUCLEAN = GPG_ERR_SYSTEM_ERROR | 135,
0725 GPG_ERR_EUNATCH = GPG_ERR_SYSTEM_ERROR | 136,
0726 GPG_ERR_EUSERS = GPG_ERR_SYSTEM_ERROR | 137,
0727 GPG_ERR_EWOULDBLOCK = GPG_ERR_SYSTEM_ERROR | 138,
0728 GPG_ERR_EXDEV = GPG_ERR_SYSTEM_ERROR | 139,
0729 GPG_ERR_EXFULL = GPG_ERR_SYSTEM_ERROR | 140,
0730
0731
0732 GPG_ERR_CODE_DIM = 65536
0733 } gpg_err_code_t;
0734
0735
0736
0737
0738
0739
0740
0741
0742 typedef unsigned int gpg_error_t;
0743
0744
0745
0746 #define GPG_ERR_CODE_MASK (GPG_ERR_CODE_DIM - 1)
0747
0748
0749
0750
0751 #define GPG_ERR_SOURCE_MASK (GPG_ERR_SOURCE_DIM - 1)
0752 #define GPG_ERR_SOURCE_SHIFT 24
0753
0754
0755
0756
0757
0758
0759
0760
0761
0762 #if __GNUC__
0763 # define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \
0764 + __GNUC_MINOR__ * 100 \
0765 + __GNUC_PATCHLEVEL__)
0766 #else
0767 # define _GPG_ERR_GCC_VERSION 0
0768 #endif
0769
0770 #undef _GPG_ERR_HAVE_CONSTRUCTOR
0771 #if _GPG_ERR_GCC_VERSION > 30100
0772 # define _GPG_ERR_CONSTRUCTOR __attribute__ ((__constructor__))
0773 # define _GPG_ERR_HAVE_CONSTRUCTOR
0774 #else
0775 # define _GPG_ERR_CONSTRUCTOR
0776 #endif
0777
0778 #define GPGRT_GCC_VERSION _GPG_ERR_GCC_VERSION
0779
0780 #if _GPG_ERR_GCC_VERSION >= 29200
0781 # define _GPGRT__RESTRICT __restrict__
0782 #else
0783 # define _GPGRT__RESTRICT
0784 #endif
0785
0786
0787 #if _GPG_ERR_GCC_VERSION >= 20500
0788 # define GPGRT_ATTR_NORETURN __attribute__ ((__noreturn__))
0789 #else
0790 # define GPGRT_ATTR_NORETURN
0791 #endif
0792
0793
0794 #if _GPG_ERR_GCC_VERSION >= 40400
0795 # define GPGRT_ATTR_PRINTF(f, a) \
0796 __attribute__ ((format(__gnu_printf__,f,a)))
0797 # define GPGRT_ATTR_NR_PRINTF(f, a) \
0798 __attribute__ ((__noreturn__, format(__gnu_printf__,f,a)))
0799 #elif _GPG_ERR_GCC_VERSION >= 20500
0800 # define GPGRT_ATTR_PRINTF(f, a) \
0801 __attribute__ ((format(printf,f,a)))
0802 # define GPGRT_ATTR_NR_PRINTF(f, a) \
0803 __attribute__ ((__noreturn__, format(printf,f,a)))
0804 #else
0805 # define GPGRT_ATTR_PRINTF(f, a)
0806 # define GPGRT_ATTR_NR_PRINTF(f, a)
0807 #endif
0808 #if _GPG_ERR_GCC_VERSION >= 20800
0809 # define GPGRT_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a)))
0810 #else
0811 # define GPGRT_ATTR_FORMAT_ARG(a)
0812 #endif
0813
0814
0815 #if _GPG_ERR_GCC_VERSION >= 40000
0816 # define GPGRT_ATTR_SENTINEL(a) __attribute__ ((sentinel(a)))
0817 #else
0818 # define GPGRT_ATTR_SENTINEL(a)
0819 #endif
0820
0821
0822
0823
0824
0825 #if _GPG_ERR_GCC_VERSION >= 40000
0826 # define GPGRT_ATTR_USED __attribute__ ((used))
0827 #else
0828 # define GPGRT_ATTR_USED
0829 #endif
0830 #if _GPG_ERR_GCC_VERSION >= 30500
0831 # define GPGRT_ATTR_UNUSED __attribute__ ((unused))
0832 #else
0833 # define GPGRT_ATTR_UNUSED
0834 #endif
0835
0836
0837 #if _GPG_ERR_GCC_VERSION >= 30100
0838 # define GPGRT_ATTR_DEPRECATED __attribute__ ((__deprecated__))
0839 #else
0840 # define GPGRT_ATTR_DEPRECATED
0841 #endif
0842
0843
0844 #if _GPG_ERR_GCC_VERSION >= 29600
0845 # define GPGRT_ATTR_PURE __attribute__ ((__pure__))
0846 #else
0847 # define GPGRT_ATTR_PURE
0848 #endif
0849
0850
0851 #if _GPG_ERR_GCC_VERSION >= 30200
0852 # define GPGRT_ATTR_MALLOC __attribute__ ((__malloc__))
0853 #else
0854 # define GPGRT_ATTR_MALLOC
0855 #endif
0856
0857
0858 #undef GPGRT_HAVE_MACRO_FUNCTION
0859 #if _GPG_ERR_GCC_VERSION >= 20500
0860 # define GPGRT_HAVE_MACRO_FUNCTION 1
0861 #endif
0862
0863
0864 #undef GPGRT_HAVE_PRAGMA_GCC_PUSH
0865 #if _GPG_ERR_GCC_VERSION >= 40400
0866 # define GPGRT_HAVE_PRAGMA_GCC_PUSH 1
0867 #endif
0868
0869
0870
0871
0872
0873
0874 #ifdef __GNUC__
0875 # ifdef __SANITIZE_ADDRESS__
0876 # define GPGRT_HAVE_LEAK_SANITIZER
0877 # elif defined(__has_feature)
0878 # if __has_feature(address_sanitizer)
0879 # define GPGRT_HAVE_LEAK_SANITIZER
0880 # endif
0881 # endif
0882 #endif
0883
0884
0885
0886 #define GPGRT_INLINE GPG_ERR_INLINE
0887
0888 #ifdef GPGRT_HAVE_LEAK_SANITIZER
0889 # include <sanitizer/lsan_interface.h>
0890 #endif
0891
0892
0893 static GPGRT_INLINE void
0894 gpgrt_annotate_leaked_object (const void *p)
0895 {
0896 #ifdef GPGRT_HAVE_LEAK_SANITIZER
0897 __lsan_ignore_object(p);
0898 #else
0899 (void)p;
0900 #endif
0901 }
0902
0903
0904
0905
0906
0907
0908
0909 gpg_error_t gpg_err_init (void) _GPG_ERR_CONSTRUCTOR;
0910
0911
0912
0913 #undef GPG_ERR_INITIALIZED
0914 #ifdef _GPG_ERR_HAVE_CONSTRUCTOR
0915 # define GPG_ERR_INITIALIZED 1
0916 # define gpgrt_init() do { gpg_err_init (); } while (0)
0917 #else
0918 # define gpgrt_init() do { ; } while (0)
0919 #endif
0920
0921
0922
0923 void gpg_err_deinit (int mode);
0924
0925
0926 void gpgrt_set_syscall_clamp (void (*pre)(void), void (*post)(void));
0927
0928
0929 void gpgrt_get_syscall_clamp (void (**r_pre)(void), void (**r_post)(void));
0930
0931
0932 void gpgrt_set_alloc_func (void *(*f)(void *a, size_t n));
0933
0934
0935 void gpgrt_add_emergency_cleanup (void (*f)(void));
0936
0937
0938 void gpgrt_abort (void) GPGRT_ATTR_NORETURN;
0939
0940
0941
0942
0943
0944
0945
0946
0947
0948 static GPG_ERR_INLINE gpg_error_t
0949 gpg_err_make (gpg_err_source_t source, gpg_err_code_t code)
0950 {
0951 return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
0952 : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
0953 | (code & GPG_ERR_CODE_MASK));
0954 }
0955
0956
0957
0958
0959 #ifndef GPG_ERR_SOURCE_DEFAULT
0960 #define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_UNKNOWN
0961 #endif
0962
0963 static GPG_ERR_INLINE gpg_error_t
0964 gpg_error (gpg_err_code_t code)
0965 {
0966 return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code);
0967 }
0968
0969
0970
0971 static GPG_ERR_INLINE gpg_err_code_t
0972 gpg_err_code (gpg_error_t err)
0973 {
0974 return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
0975 }
0976
0977
0978
0979 static GPG_ERR_INLINE gpg_err_source_t
0980 gpg_err_source (gpg_error_t err)
0981 {
0982 return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
0983 & GPG_ERR_SOURCE_MASK);
0984 }
0985
0986
0987
0988
0989
0990
0991 const char *gpg_strerror (gpg_error_t err);
0992
0993
0994
0995
0996
0997
0998
0999
1000 int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
1001
1002
1003
1004 const char *gpg_strsource (gpg_error_t err);
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014 gpg_err_code_t gpg_err_code_from_errno (int err);
1015
1016
1017
1018 int gpg_err_code_to_errno (gpg_err_code_t code);
1019
1020
1021
1022
1023 gpg_err_code_t gpg_err_code_from_syserror (void);
1024
1025
1026 static GPG_ERR_INLINE gpg_error_t
1027 gpg_err_code_from_sqlite (int sqlres)
1028 {
1029 return sqlres? GPG_ERR_SQL_OK + (sqlres & 0xff) : 0;
1030 }
1031
1032
1033
1034
1035 void gpg_err_set_errno (int err);
1036
1037
1038 const char *gpgrt_check_version (const char *req_version);
1039 const char *gpg_error_check_version (const char *req_version);
1040
1041
1042 #include <sys/types.h>
1043 typedef ssize_t gpgrt_ssize_t;
1044
1045 typedef long gpgrt_off_t;
1046
1047
1048
1049
1050
1051
1052 static GPG_ERR_INLINE gpg_error_t
1053 gpg_err_make_from_errno (gpg_err_source_t source, int err)
1054 {
1055 return gpg_err_make (source, gpg_err_code_from_errno (err));
1056 }
1057
1058
1059 static GPG_ERR_INLINE gpg_error_t
1060 gpg_error_from_errno (int err)
1061 {
1062 return gpg_error (gpg_err_code_from_errno (err));
1063 }
1064
1065 static GPG_ERR_INLINE gpg_error_t
1066 gpg_error_from_syserror (void)
1067 {
1068 return gpg_error (gpg_err_code_from_syserror ());
1069 }
1070
1071
1072
1073
1074
1075
1076
1077 void *gpgrt_realloc (void *a, size_t n);
1078 void *gpgrt_reallocarray (void *a, size_t oldnmemb, size_t nmemb, size_t size);
1079 void *gpgrt_malloc (size_t n);
1080 void *gpgrt_calloc (size_t n, size_t m);
1081 char *gpgrt_strdup (const char *string);
1082 char *gpgrt_strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
1083 void gpgrt_free (void *a);
1084 void gpgrt_wipememory (void *ptr, size_t len);
1085
1086
1087
1088
1089
1090
1091
1092 char *gpgrt_getenv (const char *name);
1093
1094
1095 gpg_err_code_t gpgrt_setenv (const char *name,
1096 const char *value, int overwrite);
1097 #define gpgrt_unsetenv(n) gpgrt_setenv ((n), NULL, 1)
1098
1099
1100 gpg_err_code_t gpgrt_mkdir (const char *name, const char *modestr);
1101
1102
1103 gpg_err_code_t gpgrt_chdir (const char *name);
1104
1105
1106 char *gpgrt_getcwd (void);
1107
1108
1109 gpg_err_code_t gpgrt_access (const char *fname, int mode);
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119 typedef struct
1120 {
1121 long _vers;
1122 union {
1123 volatile char _priv[40];
1124 long _x_align;
1125 long *_xp_align;
1126 } u;
1127 } gpgrt_lock_t;
1128
1129 #define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \
1130 0,0,0,0,0,0,0,0, \
1131 0,0,0,0,0,0,0,0, \
1132 0,0,0,0,0,0,0,0, \
1133 0,0,0,0,0,0,0,0}}}
1134
1135
1136 #define GPGRT_LOCK_DEFINE(name) \
1137 static gpgrt_lock_t name = GPGRT_LOCK_INITIALIZER
1138
1139
1140
1141 gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd);
1142 gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd);
1143 gpg_err_code_t gpgrt_lock_trylock (gpgrt_lock_t *lockhd);
1144 gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
1145 gpg_err_code_t gpgrt_lock_destroy (gpgrt_lock_t *lockhd);
1146
1147
1148
1149
1150
1151
1152
1153 gpg_err_code_t gpgrt_yield (void);
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165 struct _gpgrt_stream_internal;
1166 struct _gpgrt__stream
1167 {
1168
1169
1170
1171
1172
1173 struct {
1174 unsigned int magic: 16;
1175 unsigned int writing: 1;
1176 unsigned int reserved: 15;
1177 } flags;
1178
1179
1180 unsigned char *buffer;
1181
1182
1183 size_t buffer_size;
1184
1185
1186
1187 size_t data_len;
1188
1189
1190
1191 size_t data_offset;
1192
1193 size_t data_flushed;
1194 unsigned char *unread_buffer;
1195 size_t unread_buffer_size;
1196
1197
1198 size_t unread_data_len;
1199
1200
1201 struct _gpgrt_stream_internal *intern;
1202 };
1203
1204
1205 typedef struct _gpgrt__stream *gpgrt_stream_t;
1206 #ifdef GPGRT_ENABLE_ES_MACROS
1207 typedef struct _gpgrt__stream *estream_t;
1208 #endif
1209
1210 typedef ssize_t (*gpgrt_cookie_read_function_t) (void *cookie,
1211 void *buffer, size_t size);
1212 typedef ssize_t (*gpgrt_cookie_write_function_t) (void *cookie,
1213 const void *buffer,
1214 size_t size);
1215 typedef int (*gpgrt_cookie_seek_function_t) (void *cookie,
1216 gpgrt_off_t *pos, int whence);
1217 typedef int (*gpgrt_cookie_close_function_t) (void *cookie);
1218
1219 struct _gpgrt_cookie_io_functions
1220 {
1221 gpgrt_cookie_read_function_t func_read;
1222 gpgrt_cookie_write_function_t func_write;
1223 gpgrt_cookie_seek_function_t func_seek;
1224 gpgrt_cookie_close_function_t func_close;
1225 };
1226 typedef struct _gpgrt_cookie_io_functions gpgrt_cookie_io_functions_t;
1227 #ifdef GPGRT_ENABLE_ES_MACROS
1228 typedef struct _gpgrt_cookie_io_functions es_cookie_io_functions_t;
1229 #define es_cookie_read_function_t gpgrt_cookie_read_function_t
1230 #define es_cookie_write_function_t gpgrt_cookie_read_function_t
1231 #define es_cookie_seek_function_t gpgrt_cookie_read_function_t
1232 #define es_cookie_close_function_t gpgrt_cookie_read_function_t
1233 #endif
1234
1235 enum gpgrt_syshd_types
1236 {
1237 GPGRT_SYSHD_NONE = 0,
1238 GPGRT_SYSHD_FD = 1,
1239 GPGRT_SYSHD_SOCK = 2,
1240 GPGRT_SYSHD_RVID = 3,
1241 GPGRT_SYSHD_HANDLE = 4
1242 };
1243
1244 struct _gpgrt_syshd
1245 {
1246 enum gpgrt_syshd_types type;
1247 union {
1248 int fd;
1249 int sock;
1250 int rvid;
1251 void *handle;
1252 } u;
1253 };
1254 typedef struct _gpgrt_syshd gpgrt_syshd_t;
1255 #ifdef GPGRT_ENABLE_ES_MACROS
1256 typedef struct _gpgrt_syshd es_syshd_t;
1257 #define ES_SYSHD_NONE GPGRT_SYSHD_NONE
1258 #define ES_SYSHD_FD GPGRT_SYSHD_FD
1259 #define ES_SYSHD_SOCK GPGRT_SYSHD_SOCK
1260 #define ES_SYSHD_RVID GPGRT_SYSHD_RVID
1261 #define ES_SYSHD_HANDLE GPGRT_SYSHD_HANDLE
1262 #endif
1263
1264
1265 struct _gpgrt_poll_s
1266 {
1267 gpgrt_stream_t stream;
1268 unsigned int want_read:1;
1269 unsigned int want_write:1;
1270 unsigned int want_oob:1;
1271 unsigned int want_rdhup:1;
1272 unsigned int _reserv1:4;
1273 unsigned int got_read:1;
1274 unsigned int got_write:1;
1275 unsigned int got_oob:1;
1276 unsigned int got_rdhup:1;
1277 unsigned int _reserv2:4;
1278 unsigned int got_err:1;
1279 unsigned int got_hup:1;
1280 unsigned int got_nval:1;
1281 unsigned int _reserv3:4;
1282 unsigned int ignore:1;
1283 unsigned int user:8;
1284 };
1285 typedef struct _gpgrt_poll_s gpgrt_poll_t;
1286 #ifdef GPGRT_ENABLE_ES_MACROS
1287 typedef struct _gpgrt_poll_s es_poll_t;
1288 #endif
1289
1290
1291 typedef char *(*gpgrt_string_filter_t) (const char *s, int n, void *opaque);
1292
1293
1294
1295 gpgrt_stream_t gpgrt_fopen (const char *_GPGRT__RESTRICT path,
1296 const char *_GPGRT__RESTRICT mode);
1297 gpgrt_stream_t gpgrt_mopen (void *_GPGRT__RESTRICT data,
1298 size_t data_n, size_t data_len,
1299 unsigned int grow,
1300 void *(*func_realloc) (void *mem, size_t size),
1301 void (*func_free) (void *mem),
1302 const char *_GPGRT__RESTRICT mode);
1303 gpgrt_stream_t gpgrt_fopenmem (size_t memlimit,
1304 const char *_GPGRT__RESTRICT mode);
1305 gpgrt_stream_t gpgrt_fopenmem_init (size_t memlimit,
1306 const char *_GPGRT__RESTRICT mode,
1307 const void *data, size_t datalen);
1308 gpgrt_stream_t gpgrt_fdopen (int filedes, const char *mode);
1309 gpgrt_stream_t gpgrt_fdopen_nc (int filedes, const char *mode);
1310 gpgrt_stream_t gpgrt_sysopen (gpgrt_syshd_t *syshd, const char *mode);
1311 gpgrt_stream_t gpgrt_sysopen_nc (gpgrt_syshd_t *syshd, const char *mode);
1312 gpgrt_stream_t gpgrt_fpopen (FILE *fp, const char *mode);
1313 gpgrt_stream_t gpgrt_fpopen_nc (FILE *fp, const char *mode);
1314 gpgrt_stream_t gpgrt_freopen (const char *_GPGRT__RESTRICT path,
1315 const char *_GPGRT__RESTRICT mode,
1316 gpgrt_stream_t _GPGRT__RESTRICT stream);
1317 gpgrt_stream_t gpgrt_fopencookie (void *_GPGRT__RESTRICT cookie,
1318 const char *_GPGRT__RESTRICT mode,
1319 gpgrt_cookie_io_functions_t functions);
1320 int gpgrt_fclose (gpgrt_stream_t stream);
1321 int gpgrt_fcancel (gpgrt_stream_t stream);
1322 int gpgrt_fclose_snatch (gpgrt_stream_t stream,
1323 void **r_buffer, size_t *r_buflen);
1324 int gpgrt_onclose (gpgrt_stream_t stream, int mode,
1325 void (*fnc) (gpgrt_stream_t, void*), void *fnc_value);
1326 int gpgrt_fileno (gpgrt_stream_t stream);
1327 int gpgrt_fileno_unlocked (gpgrt_stream_t stream);
1328 int gpgrt_syshd (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
1329 int gpgrt_syshd_unlocked (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
1330
1331 void _gpgrt_set_std_fd (int no, int fd);
1332 gpgrt_stream_t _gpgrt_get_std_stream (int fd);
1333
1334 #define gpgrt_stdin _gpgrt_get_std_stream (0)
1335 #define gpgrt_stdout _gpgrt_get_std_stream (1)
1336 #define gpgrt_stderr _gpgrt_get_std_stream (2)
1337
1338
1339 void gpgrt_flockfile (gpgrt_stream_t stream);
1340 int gpgrt_ftrylockfile (gpgrt_stream_t stream);
1341 void gpgrt_funlockfile (gpgrt_stream_t stream);
1342
1343 int gpgrt_feof (gpgrt_stream_t stream);
1344 int gpgrt_feof_unlocked (gpgrt_stream_t stream);
1345 int gpgrt_ferror (gpgrt_stream_t stream);
1346 int gpgrt_ferror_unlocked (gpgrt_stream_t stream);
1347 void gpgrt_clearerr (gpgrt_stream_t stream);
1348 void gpgrt_clearerr_unlocked (gpgrt_stream_t stream);
1349
1350 int _gpgrt_pending (gpgrt_stream_t stream);
1351 int _gpgrt_pending_unlocked (gpgrt_stream_t stream);
1352
1353 #define gpgrt_pending(stream) _gpgrt_pending (stream)
1354
1355 #define gpgrt_pending_unlocked(stream) \
1356 (((!(stream)->flags.writing) \
1357 && (((stream)->data_offset < (stream)->data_len) \
1358 || ((stream)->unread_data_len))) \
1359 ? 1 : _gpgrt_pending_unlocked ((stream)))
1360
1361 int gpgrt_fflush (gpgrt_stream_t stream);
1362 int gpgrt_fseek (gpgrt_stream_t stream, long int offset, int whence);
1363 int gpgrt_fseeko (gpgrt_stream_t stream, gpgrt_off_t offset, int whence);
1364 int gpgrt_ftruncate (gpgrt_stream_t stream, gpgrt_off_t length);
1365 long int gpgrt_ftell (gpgrt_stream_t stream);
1366 gpgrt_off_t gpgrt_ftello (gpgrt_stream_t stream);
1367 void gpgrt_rewind (gpgrt_stream_t stream);
1368
1369 int gpgrt_fgetc (gpgrt_stream_t stream);
1370 int gpgrt_fputc (int c, gpgrt_stream_t stream);
1371
1372 int _gpgrt_getc_underflow (gpgrt_stream_t stream);
1373 int _gpgrt_putc_overflow (int c, gpgrt_stream_t stream);
1374
1375 #define gpgrt_getc_unlocked(stream) \
1376 (((!(stream)->flags.writing) \
1377 && ((stream)->data_offset < (stream)->data_len) \
1378 && (! (stream)->unread_data_len)) \
1379 ? ((int) (stream)->buffer[((stream)->data_offset)++]) \
1380 : _gpgrt_getc_underflow ((stream)))
1381
1382 #define gpgrt_putc_unlocked(c, stream) \
1383 (((stream)->flags.writing \
1384 && ((stream)->data_offset < (stream)->buffer_size) \
1385 && (c != '\n')) \
1386 ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c))) \
1387 : _gpgrt_putc_overflow ((c), (stream)))
1388
1389 #define gpgrt_getc(stream) gpgrt_fgetc (stream)
1390 #define gpgrt_putc(c, stream) gpgrt_fputc (c, stream)
1391
1392 int gpgrt_ungetc (int c, gpgrt_stream_t stream);
1393
1394 int gpgrt_read (gpgrt_stream_t _GPGRT__RESTRICT stream,
1395 void *_GPGRT__RESTRICT buffer, size_t bytes_to_read,
1396 size_t *_GPGRT__RESTRICT bytes_read);
1397 int gpgrt_write (gpgrt_stream_t _GPGRT__RESTRICT stream,
1398 const void *_GPGRT__RESTRICT buffer, size_t bytes_to_write,
1399 size_t *_GPGRT__RESTRICT bytes_written);
1400 int gpgrt_write_sanitized (gpgrt_stream_t _GPGRT__RESTRICT stream,
1401 const void *_GPGRT__RESTRICT buffer, size_t length,
1402 const char *delimiters,
1403 size_t *_GPGRT__RESTRICT bytes_written);
1404 int gpgrt_write_hexstring (gpgrt_stream_t _GPGRT__RESTRICT stream,
1405 const void *_GPGRT__RESTRICT buffer, size_t length,
1406 int reserved,
1407 size_t *_GPGRT__RESTRICT bytes_written);
1408
1409 size_t gpgrt_fread (void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems,
1410 gpgrt_stream_t _GPGRT__RESTRICT stream);
1411 size_t gpgrt_fwrite (const void *_GPGRT__RESTRICT ptr, size_t size,
1412 size_t nitems, gpgrt_stream_t _GPGRT__RESTRICT stream);
1413
1414 char *gpgrt_fgets (char *_GPGRT__RESTRICT s, int n,
1415 gpgrt_stream_t _GPGRT__RESTRICT stream);
1416 int gpgrt_fputs (const char *_GPGRT__RESTRICT s,
1417 gpgrt_stream_t _GPGRT__RESTRICT stream);
1418 int gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s,
1419 gpgrt_stream_t _GPGRT__RESTRICT stream);
1420
1421 ssize_t gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr,
1422 size_t *_GPGRT__RESTRICT n,
1423 gpgrt_stream_t stream);
1424 ssize_t gpgrt_read_line (gpgrt_stream_t stream,
1425 char **addr_of_buffer, size_t *length_of_buffer,
1426 size_t *max_length);
1427
1428 int gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
1429 const char *_GPGRT__RESTRICT format, ...)
1430 GPGRT_ATTR_PRINTF(2,3);
1431 int gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
1432 const char *_GPGRT__RESTRICT format, ...)
1433 GPGRT_ATTR_PRINTF(2,3);
1434
1435 int gpgrt_fprintf_sf (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 int gpgrt_fprintf_sf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
1440 gpgrt_string_filter_t sf, void *sfvalue,
1441 const char *_GPGRT__RESTRICT format,
1442 ...) GPGRT_ATTR_PRINTF(4,5);
1443
1444 int gpgrt_printf (const char *_GPGRT__RESTRICT format, ...)
1445 GPGRT_ATTR_PRINTF(1,2);
1446 int gpgrt_printf_unlocked (const char *_GPGRT__RESTRICT format, ...)
1447 GPGRT_ATTR_PRINTF(1,2);
1448
1449 int gpgrt_vfprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
1450 const char *_GPGRT__RESTRICT format, va_list ap)
1451 GPGRT_ATTR_PRINTF(2,0);
1452 int gpgrt_vfprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
1453 const char *_GPGRT__RESTRICT format, va_list ap)
1454 GPGRT_ATTR_PRINTF(2,0);
1455
1456 int gpgrt_setvbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
1457 char *_GPGRT__RESTRICT buf, int mode, size_t size);
1458 void gpgrt_setbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
1459 char *_GPGRT__RESTRICT buf);
1460
1461 void gpgrt_set_binary (gpgrt_stream_t stream);
1462 int gpgrt_set_nonblock (gpgrt_stream_t stream, int onoff);
1463 int gpgrt_get_nonblock (gpgrt_stream_t stream);
1464
1465 int gpgrt_poll (gpgrt_poll_t *fdlist, unsigned int nfds, int timeout);
1466
1467 gpgrt_stream_t gpgrt_tmpfile (void);
1468
1469 void gpgrt_opaque_set (gpgrt_stream_t _GPGRT__RESTRICT stream,
1470 void *_GPGRT__RESTRICT opaque);
1471 void *gpgrt_opaque_get (gpgrt_stream_t stream);
1472
1473 void gpgrt_fname_set (gpgrt_stream_t stream, const char *fname);
1474 const char *gpgrt_fname_get (gpgrt_stream_t stream);
1475
1476 int gpgrt_asprintf (char **r_buf, const char * _GPGRT__RESTRICT format, ...)
1477 GPGRT_ATTR_PRINTF(2,3);
1478 int gpgrt_vasprintf (char **r_buf, const char * _GPGRT__RESTRICT format,
1479 va_list ap)
1480 GPGRT_ATTR_PRINTF(2,0);
1481 char *gpgrt_bsprintf (const char * _GPGRT__RESTRICT format, ...)
1482 GPGRT_ATTR_PRINTF(1,2);
1483 char *gpgrt_vbsprintf (const char * _GPGRT__RESTRICT format, va_list ap)
1484 GPGRT_ATTR_PRINTF(1,0);
1485 int gpgrt_snprintf (char *buf, size_t bufsize,
1486 const char * _GPGRT__RESTRICT format, ...)
1487 GPGRT_ATTR_PRINTF(3,4);
1488 int gpgrt_vsnprintf (char *buf,size_t bufsize,
1489 const char * _GPGRT__RESTRICT format, va_list arg_ptr)
1490 GPGRT_ATTR_PRINTF(3,0);
1491
1492
1493 #ifdef GPGRT_ENABLE_ES_MACROS
1494 # define es_fopen gpgrt_fopen
1495 # define es_mopen gpgrt_mopen
1496 # define es_fopenmem gpgrt_fopenmem
1497 # define es_fopenmem_init gpgrt_fopenmem_init
1498 # define es_fdopen gpgrt_fdopen
1499 # define es_fdopen_nc gpgrt_fdopen_nc
1500 # define es_sysopen gpgrt_sysopen
1501 # define es_sysopen_nc gpgrt_sysopen_nc
1502 # define es_fpopen gpgrt_fpopen
1503 # define es_fpopen_nc gpgrt_fpopen_nc
1504 # define es_freopen gpgrt_freopen
1505 # define es_fopencookie gpgrt_fopencookie
1506 # define es_fclose gpgrt_fclose
1507 # define es_fclose_snatch gpgrt_fclose_snatch
1508 # define es_onclose gpgrt_onclose
1509 # define es_fileno gpgrt_fileno
1510 # define es_fileno_unlocked gpgrt_fileno_unlocked
1511 # define es_syshd gpgrt_syshd
1512 # define es_syshd_unlocked gpgrt_syshd_unlocked
1513 # define es_stdin _gpgrt_get_std_stream (0)
1514 # define es_stdout _gpgrt_get_std_stream (1)
1515 # define es_stderr _gpgrt_get_std_stream (2)
1516 # define es_flockfile gpgrt_flockfile
1517 # define es_ftrylockfile gpgrt_ftrylockfile
1518 # define es_funlockfile gpgrt_funlockfile
1519 # define es_feof gpgrt_feof
1520 # define es_feof_unlocked gpgrt_feof_unlocked
1521 # define es_ferror gpgrt_ferror
1522 # define es_ferror_unlocked gpgrt_ferror_unlocked
1523 # define es_clearerr gpgrt_clearerr
1524 # define es_clearerr_unlocked gpgrt_clearerr_unlocked
1525 # define es_pending gpgrt_pending
1526 # define es_pending_unlocked gpgrt_pending_unlocked
1527 # define es_fflush gpgrt_fflush
1528 # define es_fseek gpgrt_fseek
1529 # define es_fseeko gpgrt_fseeko
1530 # define es_ftruncate gpgrt_ftruncate
1531 # define es_ftell gpgrt_ftell
1532 # define es_ftello gpgrt_ftello
1533 # define es_rewind gpgrt_rewind
1534 # define es_fgetc gpgrt_fgetc
1535 # define es_fputc gpgrt_fputc
1536 # define es_getc_unlocked gpgrt_getc_unlocked
1537 # define es_putc_unlocked gpgrt_putc_unlocked
1538 # define es_getc gpgrt_getc
1539 # define es_putc gpgrt_putc
1540 # define es_ungetc gpgrt_ungetc
1541 # define es_read gpgrt_read
1542 # define es_write gpgrt_write
1543 # define es_write_sanitized gpgrt_write_sanitized
1544 # define es_write_hexstring gpgrt_write_hexstring
1545 # define es_fread gpgrt_fread
1546 # define es_fwrite gpgrt_fwrite
1547 # define es_fgets gpgrt_fgets
1548 # define es_fputs gpgrt_fputs
1549 # define es_fputs_unlocked gpgrt_fputs_unlocked
1550 # define es_getline gpgrt_getline
1551 # define es_read_line gpgrt_read_line
1552 # define es_free gpgrt_free
1553 # define es_fprintf gpgrt_fprintf
1554 # define es_fprintf_unlocked gpgrt_fprintf_unlocked
1555 # define es_printf gpgrt_printf
1556 # define es_printf_unlocked gpgrt_printf_unlocked
1557 # define es_vfprintf gpgrt_vfprintf
1558 # define es_vfprintf_unlocked gpgrt_vfprintf_unlocked
1559 # define es_setvbuf gpgrt_setvbuf
1560 # define es_setbuf gpgrt_setbuf
1561 # define es_set_binary gpgrt_set_binary
1562 # define es_set_nonblock gpgrt_set_nonblock
1563 # define es_get_nonblock gpgrt_get_nonblock
1564 # define es_poll gpgrt_poll
1565 # define es_tmpfile gpgrt_tmpfile
1566 # define es_opaque_set gpgrt_opaque_set
1567 # define es_opaque_get gpgrt_opaque_get
1568 # define es_fname_set gpgrt_fname_set
1569 # define es_fname_get gpgrt_fname_get
1570 # define es_asprintf gpgrt_asprintf
1571 # define es_vasprintf gpgrt_vasprintf
1572 # define es_bsprintf gpgrt_bsprintf
1573 # define es_vbsprintf gpgrt_vbsprintf
1574 #endif
1575
1576
1577
1578
1579
1580
1581
1582 struct _gpgrt_b64state;
1583 typedef struct _gpgrt_b64state *gpgrt_b64state_t;
1584
1585 gpgrt_b64state_t gpgrt_b64enc_start (gpgrt_stream_t stream, const char *title);
1586 gpg_err_code_t gpgrt_b64enc_write (gpgrt_b64state_t state,
1587 const void *buffer, size_t nbytes);
1588 gpg_err_code_t gpgrt_b64enc_finish (gpgrt_b64state_t state);
1589
1590 gpgrt_b64state_t gpgrt_b64dec_start (const char *title);
1591 gpg_err_code_t gpgrt_b64dec_proc (gpgrt_b64state_t state,
1592 void *buffer, size_t length,
1593 size_t *r_nbytes);
1594 gpg_err_code_t gpgrt_b64dec_finish (gpgrt_b64state_t state);
1595
1596
1597
1598
1599
1600
1601
1602
1603 #define GPGRT_LOG_WITH_PREFIX 1
1604 #define GPGRT_LOG_WITH_TIME 2
1605 #define GPGRT_LOG_WITH_PID 4
1606 #define GPGRT_LOG_RUN_DETACHED 256
1607 #define GPGRT_LOG_NO_REGISTRY 512
1608
1609
1610 enum gpgrt_log_levels
1611 {
1612 GPGRT_LOGLVL_BEGIN,
1613 GPGRT_LOGLVL_CONT,
1614 GPGRT_LOGLVL_INFO,
1615 GPGRT_LOGLVL_WARN,
1616 GPGRT_LOGLVL_ERROR,
1617 GPGRT_LOGLVL_FATAL,
1618 GPGRT_LOGLVL_BUG,
1619 GPGRT_LOGLVL_DEBUG
1620 };
1621
1622
1623
1624 void gpgrt_log_set_sink (const char *name, gpgrt_stream_t stream, int fd);
1625 void gpgrt_log_set_socket_dir_cb (const char *(*fnc)(void));
1626 void gpgrt_log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value));
1627 void gpgrt_log_set_prefix (const char *text, unsigned int flags);
1628 void gpgrt_add_post_log_func (void (*f)(int));
1629
1630 int gpgrt_get_errorcount (int clear);
1631 void gpgrt_inc_errorcount (void);
1632 const char *gpgrt_log_get_prefix (unsigned int *flags);
1633 int gpgrt_log_test_fd (int fd);
1634 int gpgrt_log_get_fd (void);
1635 gpgrt_stream_t gpgrt_log_get_stream (void);
1636
1637 void gpgrt_log (int level, const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
1638 void gpgrt_logv (int level, const char *fmt,
1639 va_list arg_ptr) GPGRT_ATTR_PRINTF(2,0);
1640 void gpgrt_logv_prefix (int level, const char *prefix, const char *fmt,
1641 va_list arg_ptr) GPGRT_ATTR_PRINTF(3,0);
1642 void gpgrt_logv_domain (const char *domain, int level, const char *prefix,
1643 const void *buffer, size_t length, const char *fmt,
1644 va_list arg_ptr) GPGRT_ATTR_PRINTF(6,0);
1645 void gpgrt_log_string (int level, const char *string);
1646 void gpgrt_log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2);
1647 void gpgrt_log_fatal (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2);
1648 void gpgrt_log_error (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
1649 void gpgrt_log_info (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
1650 void gpgrt_log_debug (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
1651 void gpgrt_log_debug_string (const char *string,
1652 const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
1653 void gpgrt_log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
1654 void gpgrt_log_printhex (const void *buffer, size_t length,
1655 const char *fmt, ...) GPGRT_ATTR_PRINTF(3,4);
1656 void gpgrt_log_clock (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
1657 void gpgrt_log_flush (void);
1658 void _gpgrt_log_assert (const char *expr, const char *file, int line,
1659 const char *func) GPGRT_ATTR_NORETURN;
1660
1661 #ifdef GPGRT_HAVE_MACRO_FUNCTION
1662 # define gpgrt_assert(expr) \
1663 ((expr) \
1664 ? (void) 0 \
1665 : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
1666 #else
1667 # define gpgrt_assert(expr) \
1668 ((expr) \
1669 ? (void) 0 \
1670 : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL))
1671 #endif
1672
1673 #ifdef GPGRT_ENABLE_LOG_MACROS
1674 # define log_get_errorcount gpgrt_get_errorcount
1675 # define log_inc_errorcount gpgrt_inc_errorcount
1676 # define log_set_file(a) gpgrt_log_set_sink ((a), NULL, -1)
1677 # define log_set_fd(a) gpgrt_log_set_sink (NULL, NULL, (a))
1678 # define log_set_stream(a) gpgrt_log_set_sink (NULL, (a), -1)
1679 # define log_set_socket_dir_cb gpgrt_log_set_socket_dir_cb
1680 # define log_set_pid_suffix_cb gpgrt_log_set_pid_suffix_cb
1681 # define log_set_prefix gpgrt_log_set_prefix
1682 # define log_get_prefix gpgrt_log_get_prefix
1683 # define log_test_fd gpgrt_log_test_fd
1684 # define log_get_fd gpgrt_log_get_fd
1685 # define log_get_stream gpgrt_log_get_stream
1686 # define log_log gpgrt_log
1687 # define log_logv gpgrt_logv
1688 # define log_logv_prefix gpgrt_logv_prefix
1689 # define log_string gpgrt_log_string
1690 # define log_bug gpgrt_log_bug
1691 # define log_fatal gpgrt_log_fatal
1692 # define log_error gpgrt_log_error
1693 # define log_info gpgrt_log_info
1694 # define log_debug gpgrt_log_debug
1695 # define log_debug_string gpgrt_log_debug_string
1696 # define log_printf gpgrt_log_printf
1697 # define log_printhex gpgrt_log_printhex
1698 # define log_clock gpgrt_log_clock
1699 # define log_flush gpgrt_log_flush
1700 # ifdef GPGRT_HAVE_MACRO_FUNCTION
1701 # define log_assert(expr) \
1702 ((expr) \
1703 ? (void) 0 \
1704 : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
1705 # else
1706 # define log_assert(expr) \
1707 ((expr) \
1708 ? (void) 0 \
1709 : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL))
1710 # endif
1711
1712 #endif
1713
1714
1715
1716
1717
1718
1719 #define GPGRT_PROCESS_DETACHED (1 << 1)
1720
1721
1722 #define GPGRT_PROCESS_NO_CONSOLE (1 << 2)
1723
1724
1725 #define GPGRT_PROCESS_NO_EUID_CHECK (1 << 3)
1726
1727
1728 #define GPGRT_PROCESS_STDIN_PIPE (1 << 8)
1729 #define GPGRT_PROCESS_STDOUT_PIPE (1 << 9)
1730 #define GPGRT_PROCESS_STDERR_PIPE (1 << 10)
1731 #define GPGRT_PROCESS_STDINOUT_SOCKETPAIR (1 << 11)
1732 #define GPGRT_PROCESS_STDIN_KEEP (1 << 12)
1733 #define GPGRT_PROCESS_STDOUT_KEEP (1 << 13)
1734 #define GPGRT_PROCESS_STDERR_KEEP (1 << 14)
1735 #define GPGRT_PROCESS_STDFDS_SETTING ( GPGRT_PROCESS_STDIN_PIPE \
1736 | GPGRT_PROCESS_STDOUT_PIPE | GPGRT_PROCESS_STDERR_PIPE \
1737 | GPGRT_PROCESS_STDINOUT_SOCKETPAIR | GPGRT_PROCESS_STDIN_KEEP \
1738 | GPGRT_PROCESS_STDOUT_KEEP | GPGRT_PROCESS_STDERR_KEEP)
1739
1740 #define GPGRT_PROCESS_STREAM_NONBLOCK (1 << 16)
1741
1742 typedef struct gpgrt_process *gpgrt_process_t;
1743 typedef struct gpgrt_spawn_actions *gpgrt_spawn_actions_t;
1744 gpg_err_code_t gpgrt_spawn_actions_new (gpgrt_spawn_actions_t *r_act);
1745 void gpgrt_spawn_actions_release (gpgrt_spawn_actions_t act);
1746 void gpgrt_spawn_actions_set_environ (gpgrt_spawn_actions_t, char **);
1747 void gpgrt_spawn_actions_set_redirect (gpgrt_spawn_actions_t, int, int, int);
1748 void gpgrt_spawn_actions_set_inherit_fds (gpgrt_spawn_actions_t, const int *);
1749 void gpgrt_spawn_actions_set_atfork (gpgrt_spawn_actions_t, void (*)(void *), void *);
1750
1751 enum gpgrt_process_requests
1752 {
1753
1754 GPGRT_PROCESS_NOP = 0,
1755 GPGRT_PROCESS_GET_PROC_ID = 1,
1756 GPGRT_PROCESS_GET_EXIT_ID = 2,
1757
1758
1759 GPGRT_PROCESS_GET_PID = 16,
1760 GPGRT_PROCESS_GET_WSTATUS = 17,
1761 GPGRT_PROCESS_KILL = 18,
1762
1763
1764 GPGRT_PROCESS_GET_P_HANDLE = 32,
1765 GPGRT_PROCESS_GET_HANDLES = 33,
1766 GPGRT_PROCESS_GET_EXIT_CODE = 34,
1767 GPGRT_PROCESS_KILL_WITH_EC = 35
1768 };
1769
1770 #if 0
1771
1772 gpg_err_code_t gpgrt_make_pipe (int filedes[2], gpgrt_stream_t *r_fp,
1773 int direction, int nonblock);
1774 #define gpgrt_create_pipe(a) gpgrt_make_pipe ((a),NULL, 0, 0);
1775 #define gpgrt_create_inbound_pipe(a,b,c) gpgrt_make_pipe ((a), (b), -1,(c));
1776 #define gpgrt_create_outbound_pipe(a,b,c) gpgrt_make_pipe ((a), (b), 1,(c));
1777
1778
1779 void gpgrt_close_all_fds (int from, int *keep_fds);
1780 #endif
1781
1782 gpg_err_code_t gpgrt_process_spawn (const char *pgmname, const char *argv1[],
1783 unsigned int flags,
1784 gpgrt_spawn_actions_t act,
1785 gpgrt_process_t *r_process);
1786
1787 gpg_err_code_t gpgrt_process_terminate (gpgrt_process_t process);
1788
1789 gpg_err_code_t gpgrt_process_get_fds (gpgrt_process_t process,
1790 unsigned int flags,
1791 int *r_fd_in, int *r_fd_out,
1792 int *r_fd_err);
1793
1794 gpg_err_code_t gpgrt_process_get_streams (gpgrt_process_t process,
1795 unsigned int flags,
1796 gpgrt_stream_t *r_fp_in,
1797 gpgrt_stream_t *r_fp_out,
1798 gpgrt_stream_t *r_fp_err);
1799
1800 gpg_err_code_t gpgrt_process_ctl (gpgrt_process_t process,
1801 unsigned int request, ...);
1802
1803 gpg_err_code_t gpgrt_process_wait (gpgrt_process_t process, int hang);
1804
1805 void gpgrt_process_release (gpgrt_process_t process);
1806
1807
1808
1809
1810
1811 struct _gpgrt_argparse_internal_s;
1812 typedef struct
1813 {
1814 int *argc;
1815 char ***argv;
1816 unsigned int flags;
1817
1818 int err;
1819
1820
1821 unsigned int lineno;
1822 int r_opt;
1823 int r_type;
1824 union {
1825 int ret_int;
1826 long ret_long;
1827 unsigned long ret_ulong;
1828 char *ret_str;
1829 } r;
1830
1831 struct _gpgrt_argparse_internal_s *internal;
1832 } gpgrt_argparse_t;
1833
1834
1835 typedef struct
1836 {
1837 int short_opt;
1838 const char *long_opt;
1839 unsigned int flags;
1840 const char *description;
1841 } gpgrt_opt_t;
1842
1843
1844 #ifdef GPGRT_ENABLE_ARGPARSE_MACROS
1845
1846
1847 #define ARGPARSE_FLAG_KEEP 1
1848 #define ARGPARSE_FLAG_ALL 2
1849
1850 #define ARGPARSE_FLAG_MIXED 4
1851 #define ARGPARSE_FLAG_NOSTOP 8
1852 #define ARGPARSE_FLAG_ARG0 16
1853 #define ARGPARSE_FLAG_ONEDASH 32
1854 #define ARGPARSE_FLAG_NOVERSION 64
1855 #define ARGPARSE_FLAG_RESET 128
1856 #define ARGPARSE_FLAG_STOP_SEEN 256
1857 #define ARGPARSE_FLAG_NOLINENO 512
1858 #define ARGPARSE_FLAG_SYS 1024
1859 #define ARGPARSE_FLAG_USER 2048
1860 #define ARGPARSE_FLAG_VERBOSE 4096
1861 #define ARGPARSE_FLAG_USERVERS 8192
1862 #define ARGPARSE_FLAG_WITHATTR 16384
1863
1864 #define ARGPARSE_FLAG_COMMAND 32768
1865
1866
1867
1868 #define ARGPARSE_PRINT_WARNING 1
1869 #define ARGPARSE_PRINT_ERROR 2
1870
1871
1872 #define ARGPARSE_IS_ARG (-1)
1873 #define ARGPARSE_INVALID_OPTION (-2)
1874 #define ARGPARSE_MISSING_ARG (-3)
1875 #define ARGPARSE_KEYWORD_TOO_LONG (-4)
1876 #define ARGPARSE_READ_ERROR (-5)
1877 #define ARGPARSE_UNEXPECTED_ARG (-6)
1878 #define ARGPARSE_INVALID_COMMAND (-7)
1879 #define ARGPARSE_AMBIGUOUS_OPTION (-8)
1880 #define ARGPARSE_AMBIGUOUS_COMMAND (-9)
1881 #define ARGPARSE_INVALID_ALIAS (-10)
1882 #define ARGPARSE_OUT_OF_CORE (-11)
1883 #define ARGPARSE_INVALID_ARG (-12)
1884 #define ARGPARSE_PERMISSION_ERROR (-13)
1885 #define ARGPARSE_NO_CONFFILE (-14)
1886 #define ARGPARSE_CONFFILE (-15)
1887 #define ARGPARSE_INVALID_META (-16)
1888 #define ARGPARSE_UNKNOWN_META (-17)
1889 #define ARGPARSE_UNEXPECTED_META (-18)
1890
1891
1892
1893
1894
1895
1896
1897
1898 #define ARGPARSE_TYPE_MASK 0x0007
1899 #define ARGPARSE_TYPE_NONE 0
1900 #define ARGPARSE_TYPE_INT 1
1901 #define ARGPARSE_TYPE_STRING 2
1902 #define ARGPARSE_TYPE_LONG 3
1903 #define ARGPARSE_TYPE_ULONG 4
1904 #define ARGPARSE_OPT_OPTIONAL (1<<3)
1905 #define ARGPARSE_OPT_PREFIX (1<<4)
1906 #define ARGPARSE_OPT_IGNORE (1<<6)
1907 #define ARGPARSE_OPT_COMMAND (1<<7)
1908 #define ARGPARSE_OPT_CONFFILE (1<<8)
1909 #define ARGPARSE_OPT_HEADER (1<<9)
1910 #define ARGPARSE_OPT_VERBATIM (1<<10)
1911 #define ARGPARSE_ATTR_FORCE (1<<14)
1912 #define ARGPARSE_ATTR_IGNORE (1<<15)
1913
1914
1915 #define ARGPARSE_x(s,l,t,f,d) \
1916 { (s), (l), ARGPARSE_TYPE_ ## t | (f), (d) }
1917
1918 #define ARGPARSE_s(s,l,t,d) \
1919 { (s), (l), ARGPARSE_TYPE_ ## t, (d) }
1920 #define ARGPARSE_s_n(s,l,d) \
1921 { (s), (l), ARGPARSE_TYPE_NONE, (d) }
1922 #define ARGPARSE_s_i(s,l,d) \
1923 { (s), (l), ARGPARSE_TYPE_INT, (d) }
1924 #define ARGPARSE_s_s(s,l,d) \
1925 { (s), (l), ARGPARSE_TYPE_STRING, (d) }
1926 #define ARGPARSE_s_l(s,l,d) \
1927 { (s), (l), ARGPARSE_TYPE_LONG, (d) }
1928 #define ARGPARSE_s_u(s,l,d) \
1929 { (s), (l), ARGPARSE_TYPE_ULONG, (d) }
1930
1931 #define ARGPARSE_o(s,l,t,d) \
1932 { (s), (l), (ARGPARSE_TYPE_ ## t | ARGPARSE_OPT_OPTIONAL), (d) }
1933 #define ARGPARSE_o_n(s,l,d) \
1934 { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_OPTIONAL), (d) }
1935 #define ARGPARSE_o_i(s,l,d) \
1936 { (s), (l), (ARGPARSE_TYPE_INT | ARGPARSE_OPT_OPTIONAL), (d) }
1937 #define ARGPARSE_o_s(s,l,d) \
1938 { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_OPTIONAL), (d) }
1939 #define ARGPARSE_o_l(s,l,d) \
1940 { (s), (l), (ARGPARSE_TYPE_LONG | ARGPARSE_OPT_OPTIONAL), (d) }
1941 #define ARGPARSE_o_u(s,l,d) \
1942 { (s), (l), (ARGPARSE_TYPE_ULONG | ARGPARSE_OPT_OPTIONAL), (d) }
1943
1944 #define ARGPARSE_p(s,l,t,d) \
1945 { (s), (l), (ARGPARSE_TYPE_ ## t | ARGPARSE_OPT_PREFIX), (d) }
1946 #define ARGPARSE_p_n(s,l,d) \
1947 { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_PREFIX), (d) }
1948 #define ARGPARSE_p_i(s,l,d) \
1949 { (s), (l), (ARGPARSE_TYPE_INT | ARGPARSE_OPT_PREFIX), (d) }
1950 #define ARGPARSE_p_s(s,l,d) \
1951 { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_PREFIX), (d) }
1952 #define ARGPARSE_p_l(s,l,d) \
1953 { (s), (l), (ARGPARSE_TYPE_LONG | ARGPARSE_OPT_PREFIX), (d) }
1954 #define ARGPARSE_p_u(s,l,d) \
1955 { (s), (l), (ARGPARSE_TYPE_ULONG | ARGPARSE_OPT_PREFIX), (d) }
1956
1957 #define ARGPARSE_op(s,l,t,d) \
1958 { (s), (l), (ARGPARSE_TYPE_ ## t \
1959 | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1960 #define ARGPARSE_op_n(s,l,d) \
1961 { (s), (l), (ARGPARSE_TYPE_NONE \
1962 | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1963 #define ARGPARSE_op_i(s,l,d) \
1964 { (s), (l), (ARGPARSE_TYPE_INT \
1965 | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1966 #define ARGPARSE_op_s(s,l,d) \
1967 { (s), (l), (ARGPARSE_TYPE_STRING \
1968 | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1969 #define ARGPARSE_op_l(s,l,d) \
1970 { (s), (l), (ARGPARSE_TYPE_LONG \
1971 | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1972 #define ARGPARSE_op_u(s,l,d) \
1973 { (s), (l), (ARGPARSE_TYPE_ULONG \
1974 | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
1975
1976 #define ARGPARSE_c(s,l,d) \
1977 { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_COMMAND), (d) }
1978
1979 #define ARGPARSE_conffile(s,l,d) \
1980 { (s), (l), (ARGPARSE_TYPE_STRING|ARGPARSE_OPT_CONFFILE), (d) }
1981
1982 #define ARGPARSE_noconffile(s,l,d) \
1983 { (s), (l), (ARGPARSE_TYPE_NONE|ARGPARSE_OPT_CONFFILE), (d) }
1984
1985
1986 #define ARGPARSE_ignore(s,l) \
1987 { (s), (l), (ARGPARSE_OPT_IGNORE), "@" }
1988
1989
1990
1991 #define ARGPARSE_group(s,d) \
1992 { (s), NULL, 0, (d) }
1993
1994
1995
1996 #define ARGPARSE_verbatim(d) \
1997 { 1, NULL, (ARGPARSE_OPT_VERBATIM), (d) }
1998
1999
2000
2001
2002 #define ARGPARSE_header(n,d) \
2003 { 1, (n), (ARGPARSE_OPT_HEADER), (d) }
2004
2005
2006 #define ARGPARSE_end() \
2007 { 0, NULL, 0, NULL }
2008
2009 #endif
2010
2011
2012 #define GPGRT_CONFDIR_USER 1
2013 #define GPGRT_CONFDIR_SYS 2
2014
2015
2016
2017
2018 int gpgrt_argparse (gpgrt_stream_t fp,
2019 gpgrt_argparse_t *arg, gpgrt_opt_t *opts);
2020 int gpgrt_argparser (gpgrt_argparse_t *arg, gpgrt_opt_t *opts,
2021 const char *confname);
2022 void gpgrt_usage (int level);
2023 const char *gpgrt_strusage (int level);
2024 void gpgrt_set_strusage (const char *(*f)(int));
2025 void gpgrt_set_usage_outfnc (int (*f)(int, const char *));
2026 void gpgrt_set_fixed_string_mapper (const char *(*f)(const char*));
2027 void gpgrt_set_confdir (int what, const char *name);
2028
2029
2030
2031
2032
2033
2034
2035
2036 int gpgrt_cmp_version (const char *a, const char *b, int level);
2037
2038
2039
2040
2041
2042 char *gpgrt_fnameconcat (const char *first, ...) GPGRT_ATTR_SENTINEL(0);
2043 char *gpgrt_absfnameconcat (const char *first, ...) GPGRT_ATTR_SENTINEL(0);
2044
2045
2046 #ifdef __cplusplus
2047 }
2048 #endif
2049 #endif
2050 #endif
2051
2052
2053
2054
2055