LCOV - code coverage report
Current view: top level - opt/gnupg/include - gpg-error.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 15 73.3 %
Date: 2018-11-14 16:53:58 Functions: 4 6 66.7 %

          Line data    Source code
       1             : /* gpg-error.h or gpgrt.h - Common code for GnuPG and others.    -*- c -*-
       2             :  * Copyright (C) 2001-2018 g10 Code GmbH
       3             :  *
       4             :  * This file is part of libgpg-error (aka libgpgrt).
       5             :  *
       6             :  * libgpg-error is free software; you can redistribute it and/or
       7             :  * modify it under the terms of the GNU Lesser General Public License
       8             :  * as published by the Free Software Foundation; either version 2.1 of
       9             :  * the License, or (at your option) any later version.
      10             :  *
      11             :  * libgpg-error is distributed in the hope that it will be useful, but
      12             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             :  * Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public
      17             :  * License along with this program; if not, see <https://www.gnu.org/licenses/>.
      18             :  * SPDX-License-Identifier: LGPL-2.1+
      19             :  *
      20             :  * Do not edit.  Generated from gpg-error.h.in for:
      21             :                  x86_64-unknown-linux-gnu (x86_64-pc-linux-gnu)
      22             :  */
      23             : 
      24             : /* The GnuPG project consists of many components.  Error codes are
      25             :  * exchanged between all components.  The common error codes and their
      26             :  * user-presentable descriptions are kept into a shared library to
      27             :  * allow adding new error codes and components without recompiling any
      28             :  * of the other components.  In addition to error codes this library
      29             :  * also features several other groups of functions which are common to
      30             :  * all GnuPG components.  They may be used by independet project as
      31             :  * well.  The interfaces will not change in a backward incompatible way.
      32             :  *
      33             :  * An error code together with an error source build up an error
      34             :  * value.  As the error value is been passed from one component to
      35             :  * another, it preserves the information about the source and nature
      36             :  * of the error.
      37             :  *
      38             :  * A component of the GnuPG project can define the following macros to
      39             :  * tune the behaviour of the library:
      40             :  *
      41             :  * GPG_ERR_SOURCE_DEFAULT: Define to an error source of type
      42             :  * gpg_err_source_t to make that source the default for gpg_error().
      43             :  * Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default.
      44             :  *
      45             :  * GPG_ERR_ENABLE_GETTEXT_MACROS: Define to provide macros to map the
      46             :  * internal gettext API to standard names.  This has only an effect on
      47             :  * Windows platforms.
      48             :  *
      49             :  * GPGRT_ENABLE_ES_MACROS: Define to provide "es_" macros for the
      50             :  * estream functions.
      51             :  *
      52             :  * GPGRT_ENABLE_LOG_MACROS: Define to provide short versions of the
      53             :  * log functions.
      54             :  *
      55             :  * GPGRT_ENABLE_ARGPARSE_MACROS: Needs to be defined to provide the
      56             :  * mandatory macros of the argparse interface.
      57             :  */
      58             : 
      59             : #ifndef GPG_ERROR_H
      60             : #define GPG_ERROR_H 1
      61             : #ifndef GPGRT_H
      62             : #define GPGRT_H 1
      63             : 
      64             : #include <stddef.h>
      65             : #include <stdio.h>
      66             : #include <stdarg.h>
      67             : 
      68             : /* The version string of this header. */
      69             : #define GPG_ERROR_VERSION "1.33-beta43"
      70             : #define GPGRT_VERSION     "1.33-beta43"
      71             : 
      72             : /* The version number of this header. */
      73             : #define GPG_ERROR_VERSION_NUMBER 0x012100
      74             : #define GPGRT_VERSION_NUMBER     0x012100
      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_SYSTEM_BUG = 666,
     436             :     GPG_ERR_DNS_UNKNOWN = 711,
     437             :     GPG_ERR_DNS_SECTION = 712,
     438             :     GPG_ERR_DNS_ADDRESS = 713,
     439             :     GPG_ERR_DNS_NO_QUERY = 714,
     440             :     GPG_ERR_DNS_NO_ANSWER = 715,
     441             :     GPG_ERR_DNS_CLOSED = 716,
     442             :     GPG_ERR_DNS_VERIFY = 717,
     443             :     GPG_ERR_DNS_TIMEOUT = 718,
     444             :     GPG_ERR_LDAP_GENERAL = 721,
     445             :     GPG_ERR_LDAP_ATTR_GENERAL = 722,
     446             :     GPG_ERR_LDAP_NAME_GENERAL = 723,
     447             :     GPG_ERR_LDAP_SECURITY_GENERAL = 724,
     448             :     GPG_ERR_LDAP_SERVICE_GENERAL = 725,
     449             :     GPG_ERR_LDAP_UPDATE_GENERAL = 726,
     450             :     GPG_ERR_LDAP_E_GENERAL = 727,
     451             :     GPG_ERR_LDAP_X_GENERAL = 728,
     452             :     GPG_ERR_LDAP_OTHER_GENERAL = 729,
     453             :     GPG_ERR_LDAP_X_CONNECTING = 750,
     454             :     GPG_ERR_LDAP_REFERRAL_LIMIT = 751,
     455             :     GPG_ERR_LDAP_CLIENT_LOOP = 752,
     456             :     GPG_ERR_LDAP_NO_RESULTS = 754,
     457             :     GPG_ERR_LDAP_CONTROL_NOT_FOUND = 755,
     458             :     GPG_ERR_LDAP_NOT_SUPPORTED = 756,
     459             :     GPG_ERR_LDAP_CONNECT = 757,
     460             :     GPG_ERR_LDAP_NO_MEMORY = 758,
     461             :     GPG_ERR_LDAP_PARAM = 759,
     462             :     GPG_ERR_LDAP_USER_CANCELLED = 760,
     463             :     GPG_ERR_LDAP_FILTER = 761,
     464             :     GPG_ERR_LDAP_AUTH_UNKNOWN = 762,
     465             :     GPG_ERR_LDAP_TIMEOUT = 763,
     466             :     GPG_ERR_LDAP_DECODING = 764,
     467             :     GPG_ERR_LDAP_ENCODING = 765,
     468             :     GPG_ERR_LDAP_LOCAL = 766,
     469             :     GPG_ERR_LDAP_SERVER_DOWN = 767,
     470             :     GPG_ERR_LDAP_SUCCESS = 768,
     471             :     GPG_ERR_LDAP_OPERATIONS = 769,
     472             :     GPG_ERR_LDAP_PROTOCOL = 770,
     473             :     GPG_ERR_LDAP_TIMELIMIT = 771,
     474             :     GPG_ERR_LDAP_SIZELIMIT = 772,
     475             :     GPG_ERR_LDAP_COMPARE_FALSE = 773,
     476             :     GPG_ERR_LDAP_COMPARE_TRUE = 774,
     477             :     GPG_ERR_LDAP_UNSUPPORTED_AUTH = 775,
     478             :     GPG_ERR_LDAP_STRONG_AUTH_RQRD = 776,
     479             :     GPG_ERR_LDAP_PARTIAL_RESULTS = 777,
     480             :     GPG_ERR_LDAP_REFERRAL = 778,
     481             :     GPG_ERR_LDAP_ADMINLIMIT = 779,
     482             :     GPG_ERR_LDAP_UNAVAIL_CRIT_EXTN = 780,
     483             :     GPG_ERR_LDAP_CONFIDENT_RQRD = 781,
     484             :     GPG_ERR_LDAP_SASL_BIND_INPROG = 782,
     485             :     GPG_ERR_LDAP_NO_SUCH_ATTRIBUTE = 784,
     486             :     GPG_ERR_LDAP_UNDEFINED_TYPE = 785,
     487             :     GPG_ERR_LDAP_BAD_MATCHING = 786,
     488             :     GPG_ERR_LDAP_CONST_VIOLATION = 787,
     489             :     GPG_ERR_LDAP_TYPE_VALUE_EXISTS = 788,
     490             :     GPG_ERR_LDAP_INV_SYNTAX = 789,
     491             :     GPG_ERR_LDAP_NO_SUCH_OBJ = 800,
     492             :     GPG_ERR_LDAP_ALIAS_PROBLEM = 801,
     493             :     GPG_ERR_LDAP_INV_DN_SYNTAX = 802,
     494             :     GPG_ERR_LDAP_IS_LEAF = 803,
     495             :     GPG_ERR_LDAP_ALIAS_DEREF = 804,
     496             :     GPG_ERR_LDAP_X_PROXY_AUTH_FAIL = 815,
     497             :     GPG_ERR_LDAP_BAD_AUTH = 816,
     498             :     GPG_ERR_LDAP_INV_CREDENTIALS = 817,
     499             :     GPG_ERR_LDAP_INSUFFICIENT_ACC = 818,
     500             :     GPG_ERR_LDAP_BUSY = 819,
     501             :     GPG_ERR_LDAP_UNAVAILABLE = 820,
     502             :     GPG_ERR_LDAP_UNWILL_TO_PERFORM = 821,
     503             :     GPG_ERR_LDAP_LOOP_DETECT = 822,
     504             :     GPG_ERR_LDAP_NAMING_VIOLATION = 832,
     505             :     GPG_ERR_LDAP_OBJ_CLS_VIOLATION = 833,
     506             :     GPG_ERR_LDAP_NOT_ALLOW_NONLEAF = 834,
     507             :     GPG_ERR_LDAP_NOT_ALLOW_ON_RDN = 835,
     508             :     GPG_ERR_LDAP_ALREADY_EXISTS = 836,
     509             :     GPG_ERR_LDAP_NO_OBJ_CLASS_MODS = 837,
     510             :     GPG_ERR_LDAP_RESULTS_TOO_LARGE = 838,
     511             :     GPG_ERR_LDAP_AFFECTS_MULT_DSAS = 839,
     512             :     GPG_ERR_LDAP_VLV = 844,
     513             :     GPG_ERR_LDAP_OTHER = 848,
     514             :     GPG_ERR_LDAP_CUP_RESOURCE_LIMIT = 881,
     515             :     GPG_ERR_LDAP_CUP_SEC_VIOLATION = 882,
     516             :     GPG_ERR_LDAP_CUP_INV_DATA = 883,
     517             :     GPG_ERR_LDAP_CUP_UNSUP_SCHEME = 884,
     518             :     GPG_ERR_LDAP_CUP_RELOAD = 885,
     519             :     GPG_ERR_LDAP_CANCELLED = 886,
     520             :     GPG_ERR_LDAP_NO_SUCH_OPERATION = 887,
     521             :     GPG_ERR_LDAP_TOO_LATE = 888,
     522             :     GPG_ERR_LDAP_CANNOT_CANCEL = 889,
     523             :     GPG_ERR_LDAP_ASSERTION_FAILED = 890,
     524             :     GPG_ERR_LDAP_PROX_AUTH_DENIED = 891,
     525             :     GPG_ERR_USER_1 = 1024,
     526             :     GPG_ERR_USER_2 = 1025,
     527             :     GPG_ERR_USER_3 = 1026,
     528             :     GPG_ERR_USER_4 = 1027,
     529             :     GPG_ERR_USER_5 = 1028,
     530             :     GPG_ERR_USER_6 = 1029,
     531             :     GPG_ERR_USER_7 = 1030,
     532             :     GPG_ERR_USER_8 = 1031,
     533             :     GPG_ERR_USER_9 = 1032,
     534             :     GPG_ERR_USER_10 = 1033,
     535             :     GPG_ERR_USER_11 = 1034,
     536             :     GPG_ERR_USER_12 = 1035,
     537             :     GPG_ERR_USER_13 = 1036,
     538             :     GPG_ERR_USER_14 = 1037,
     539             :     GPG_ERR_USER_15 = 1038,
     540             :     GPG_ERR_USER_16 = 1039,
     541             :     GPG_ERR_MISSING_ERRNO = 16381,
     542             :     GPG_ERR_UNKNOWN_ERRNO = 16382,
     543             :     GPG_ERR_EOF = 16383,
     544             : 
     545             :     /* The following error codes are used to map system errors.  */
     546             : #define GPG_ERR_SYSTEM_ERROR    (1 << 15)
     547             :     GPG_ERR_E2BIG = GPG_ERR_SYSTEM_ERROR | 0,
     548             :     GPG_ERR_EACCES = GPG_ERR_SYSTEM_ERROR | 1,
     549             :     GPG_ERR_EADDRINUSE = GPG_ERR_SYSTEM_ERROR | 2,
     550             :     GPG_ERR_EADDRNOTAVAIL = GPG_ERR_SYSTEM_ERROR | 3,
     551             :     GPG_ERR_EADV = GPG_ERR_SYSTEM_ERROR | 4,
     552             :     GPG_ERR_EAFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 5,
     553             :     GPG_ERR_EAGAIN = GPG_ERR_SYSTEM_ERROR | 6,
     554             :     GPG_ERR_EALREADY = GPG_ERR_SYSTEM_ERROR | 7,
     555             :     GPG_ERR_EAUTH = GPG_ERR_SYSTEM_ERROR | 8,
     556             :     GPG_ERR_EBACKGROUND = GPG_ERR_SYSTEM_ERROR | 9,
     557             :     GPG_ERR_EBADE = GPG_ERR_SYSTEM_ERROR | 10,
     558             :     GPG_ERR_EBADF = GPG_ERR_SYSTEM_ERROR | 11,
     559             :     GPG_ERR_EBADFD = GPG_ERR_SYSTEM_ERROR | 12,
     560             :     GPG_ERR_EBADMSG = GPG_ERR_SYSTEM_ERROR | 13,
     561             :     GPG_ERR_EBADR = GPG_ERR_SYSTEM_ERROR | 14,
     562             :     GPG_ERR_EBADRPC = GPG_ERR_SYSTEM_ERROR | 15,
     563             :     GPG_ERR_EBADRQC = GPG_ERR_SYSTEM_ERROR | 16,
     564             :     GPG_ERR_EBADSLT = GPG_ERR_SYSTEM_ERROR | 17,
     565             :     GPG_ERR_EBFONT = GPG_ERR_SYSTEM_ERROR | 18,
     566             :     GPG_ERR_EBUSY = GPG_ERR_SYSTEM_ERROR | 19,
     567             :     GPG_ERR_ECANCELED = GPG_ERR_SYSTEM_ERROR | 20,
     568             :     GPG_ERR_ECHILD = GPG_ERR_SYSTEM_ERROR | 21,
     569             :     GPG_ERR_ECHRNG = GPG_ERR_SYSTEM_ERROR | 22,
     570             :     GPG_ERR_ECOMM = GPG_ERR_SYSTEM_ERROR | 23,
     571             :     GPG_ERR_ECONNABORTED = GPG_ERR_SYSTEM_ERROR | 24,
     572             :     GPG_ERR_ECONNREFUSED = GPG_ERR_SYSTEM_ERROR | 25,
     573             :     GPG_ERR_ECONNRESET = GPG_ERR_SYSTEM_ERROR | 26,
     574             :     GPG_ERR_ED = GPG_ERR_SYSTEM_ERROR | 27,
     575             :     GPG_ERR_EDEADLK = GPG_ERR_SYSTEM_ERROR | 28,
     576             :     GPG_ERR_EDEADLOCK = GPG_ERR_SYSTEM_ERROR | 29,
     577             :     GPG_ERR_EDESTADDRREQ = GPG_ERR_SYSTEM_ERROR | 30,
     578             :     GPG_ERR_EDIED = GPG_ERR_SYSTEM_ERROR | 31,
     579             :     GPG_ERR_EDOM = GPG_ERR_SYSTEM_ERROR | 32,
     580             :     GPG_ERR_EDOTDOT = GPG_ERR_SYSTEM_ERROR | 33,
     581             :     GPG_ERR_EDQUOT = GPG_ERR_SYSTEM_ERROR | 34,
     582             :     GPG_ERR_EEXIST = GPG_ERR_SYSTEM_ERROR | 35,
     583             :     GPG_ERR_EFAULT = GPG_ERR_SYSTEM_ERROR | 36,
     584             :     GPG_ERR_EFBIG = GPG_ERR_SYSTEM_ERROR | 37,
     585             :     GPG_ERR_EFTYPE = GPG_ERR_SYSTEM_ERROR | 38,
     586             :     GPG_ERR_EGRATUITOUS = GPG_ERR_SYSTEM_ERROR | 39,
     587             :     GPG_ERR_EGREGIOUS = GPG_ERR_SYSTEM_ERROR | 40,
     588             :     GPG_ERR_EHOSTDOWN = GPG_ERR_SYSTEM_ERROR | 41,
     589             :     GPG_ERR_EHOSTUNREACH = GPG_ERR_SYSTEM_ERROR | 42,
     590             :     GPG_ERR_EIDRM = GPG_ERR_SYSTEM_ERROR | 43,
     591             :     GPG_ERR_EIEIO = GPG_ERR_SYSTEM_ERROR | 44,
     592             :     GPG_ERR_EILSEQ = GPG_ERR_SYSTEM_ERROR | 45,
     593             :     GPG_ERR_EINPROGRESS = GPG_ERR_SYSTEM_ERROR | 46,
     594             :     GPG_ERR_EINTR = GPG_ERR_SYSTEM_ERROR | 47,
     595             :     GPG_ERR_EINVAL = GPG_ERR_SYSTEM_ERROR | 48,
     596             :     GPG_ERR_EIO = GPG_ERR_SYSTEM_ERROR | 49,
     597             :     GPG_ERR_EISCONN = GPG_ERR_SYSTEM_ERROR | 50,
     598             :     GPG_ERR_EISDIR = GPG_ERR_SYSTEM_ERROR | 51,
     599             :     GPG_ERR_EISNAM = GPG_ERR_SYSTEM_ERROR | 52,
     600             :     GPG_ERR_EL2HLT = GPG_ERR_SYSTEM_ERROR | 53,
     601             :     GPG_ERR_EL2NSYNC = GPG_ERR_SYSTEM_ERROR | 54,
     602             :     GPG_ERR_EL3HLT = GPG_ERR_SYSTEM_ERROR | 55,
     603             :     GPG_ERR_EL3RST = GPG_ERR_SYSTEM_ERROR | 56,
     604             :     GPG_ERR_ELIBACC = GPG_ERR_SYSTEM_ERROR | 57,
     605             :     GPG_ERR_ELIBBAD = GPG_ERR_SYSTEM_ERROR | 58,
     606             :     GPG_ERR_ELIBEXEC = GPG_ERR_SYSTEM_ERROR | 59,
     607             :     GPG_ERR_ELIBMAX = GPG_ERR_SYSTEM_ERROR | 60,
     608             :     GPG_ERR_ELIBSCN = GPG_ERR_SYSTEM_ERROR | 61,
     609             :     GPG_ERR_ELNRNG = GPG_ERR_SYSTEM_ERROR | 62,
     610             :     GPG_ERR_ELOOP = GPG_ERR_SYSTEM_ERROR | 63,
     611             :     GPG_ERR_EMEDIUMTYPE = GPG_ERR_SYSTEM_ERROR | 64,
     612             :     GPG_ERR_EMFILE = GPG_ERR_SYSTEM_ERROR | 65,
     613             :     GPG_ERR_EMLINK = GPG_ERR_SYSTEM_ERROR | 66,
     614             :     GPG_ERR_EMSGSIZE = GPG_ERR_SYSTEM_ERROR | 67,
     615             :     GPG_ERR_EMULTIHOP = GPG_ERR_SYSTEM_ERROR | 68,
     616             :     GPG_ERR_ENAMETOOLONG = GPG_ERR_SYSTEM_ERROR | 69,
     617             :     GPG_ERR_ENAVAIL = GPG_ERR_SYSTEM_ERROR | 70,
     618             :     GPG_ERR_ENEEDAUTH = GPG_ERR_SYSTEM_ERROR | 71,
     619             :     GPG_ERR_ENETDOWN = GPG_ERR_SYSTEM_ERROR | 72,
     620             :     GPG_ERR_ENETRESET = GPG_ERR_SYSTEM_ERROR | 73,
     621             :     GPG_ERR_ENETUNREACH = GPG_ERR_SYSTEM_ERROR | 74,
     622             :     GPG_ERR_ENFILE = GPG_ERR_SYSTEM_ERROR | 75,
     623             :     GPG_ERR_ENOANO = GPG_ERR_SYSTEM_ERROR | 76,
     624             :     GPG_ERR_ENOBUFS = GPG_ERR_SYSTEM_ERROR | 77,
     625             :     GPG_ERR_ENOCSI = GPG_ERR_SYSTEM_ERROR | 78,
     626             :     GPG_ERR_ENODATA = GPG_ERR_SYSTEM_ERROR | 79,
     627             :     GPG_ERR_ENODEV = GPG_ERR_SYSTEM_ERROR | 80,
     628             :     GPG_ERR_ENOENT = GPG_ERR_SYSTEM_ERROR | 81,
     629             :     GPG_ERR_ENOEXEC = GPG_ERR_SYSTEM_ERROR | 82,
     630             :     GPG_ERR_ENOLCK = GPG_ERR_SYSTEM_ERROR | 83,
     631             :     GPG_ERR_ENOLINK = GPG_ERR_SYSTEM_ERROR | 84,
     632             :     GPG_ERR_ENOMEDIUM = GPG_ERR_SYSTEM_ERROR | 85,
     633             :     GPG_ERR_ENOMEM = GPG_ERR_SYSTEM_ERROR | 86,
     634             :     GPG_ERR_ENOMSG = GPG_ERR_SYSTEM_ERROR | 87,
     635             :     GPG_ERR_ENONET = GPG_ERR_SYSTEM_ERROR | 88,
     636             :     GPG_ERR_ENOPKG = GPG_ERR_SYSTEM_ERROR | 89,
     637             :     GPG_ERR_ENOPROTOOPT = GPG_ERR_SYSTEM_ERROR | 90,
     638             :     GPG_ERR_ENOSPC = GPG_ERR_SYSTEM_ERROR | 91,
     639             :     GPG_ERR_ENOSR = GPG_ERR_SYSTEM_ERROR | 92,
     640             :     GPG_ERR_ENOSTR = GPG_ERR_SYSTEM_ERROR | 93,
     641             :     GPG_ERR_ENOSYS = GPG_ERR_SYSTEM_ERROR | 94,
     642             :     GPG_ERR_ENOTBLK = GPG_ERR_SYSTEM_ERROR | 95,
     643             :     GPG_ERR_ENOTCONN = GPG_ERR_SYSTEM_ERROR | 96,
     644             :     GPG_ERR_ENOTDIR = GPG_ERR_SYSTEM_ERROR | 97,
     645             :     GPG_ERR_ENOTEMPTY = GPG_ERR_SYSTEM_ERROR | 98,
     646             :     GPG_ERR_ENOTNAM = GPG_ERR_SYSTEM_ERROR | 99,
     647             :     GPG_ERR_ENOTSOCK = GPG_ERR_SYSTEM_ERROR | 100,
     648             :     GPG_ERR_ENOTSUP = GPG_ERR_SYSTEM_ERROR | 101,
     649             :     GPG_ERR_ENOTTY = GPG_ERR_SYSTEM_ERROR | 102,
     650             :     GPG_ERR_ENOTUNIQ = GPG_ERR_SYSTEM_ERROR | 103,
     651             :     GPG_ERR_ENXIO = GPG_ERR_SYSTEM_ERROR | 104,
     652             :     GPG_ERR_EOPNOTSUPP = GPG_ERR_SYSTEM_ERROR | 105,
     653             :     GPG_ERR_EOVERFLOW = GPG_ERR_SYSTEM_ERROR | 106,
     654             :     GPG_ERR_EPERM = GPG_ERR_SYSTEM_ERROR | 107,
     655             :     GPG_ERR_EPFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 108,
     656             :     GPG_ERR_EPIPE = GPG_ERR_SYSTEM_ERROR | 109,
     657             :     GPG_ERR_EPROCLIM = GPG_ERR_SYSTEM_ERROR | 110,
     658             :     GPG_ERR_EPROCUNAVAIL = GPG_ERR_SYSTEM_ERROR | 111,
     659             :     GPG_ERR_EPROGMISMATCH = GPG_ERR_SYSTEM_ERROR | 112,
     660             :     GPG_ERR_EPROGUNAVAIL = GPG_ERR_SYSTEM_ERROR | 113,
     661             :     GPG_ERR_EPROTO = GPG_ERR_SYSTEM_ERROR | 114,
     662             :     GPG_ERR_EPROTONOSUPPORT = GPG_ERR_SYSTEM_ERROR | 115,
     663             :     GPG_ERR_EPROTOTYPE = GPG_ERR_SYSTEM_ERROR | 116,
     664             :     GPG_ERR_ERANGE = GPG_ERR_SYSTEM_ERROR | 117,
     665             :     GPG_ERR_EREMCHG = GPG_ERR_SYSTEM_ERROR | 118,
     666             :     GPG_ERR_EREMOTE = GPG_ERR_SYSTEM_ERROR | 119,
     667             :     GPG_ERR_EREMOTEIO = GPG_ERR_SYSTEM_ERROR | 120,
     668             :     GPG_ERR_ERESTART = GPG_ERR_SYSTEM_ERROR | 121,
     669             :     GPG_ERR_EROFS = GPG_ERR_SYSTEM_ERROR | 122,
     670             :     GPG_ERR_ERPCMISMATCH = GPG_ERR_SYSTEM_ERROR | 123,
     671             :     GPG_ERR_ESHUTDOWN = GPG_ERR_SYSTEM_ERROR | 124,
     672             :     GPG_ERR_ESOCKTNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 125,
     673             :     GPG_ERR_ESPIPE = GPG_ERR_SYSTEM_ERROR | 126,
     674             :     GPG_ERR_ESRCH = GPG_ERR_SYSTEM_ERROR | 127,
     675             :     GPG_ERR_ESRMNT = GPG_ERR_SYSTEM_ERROR | 128,
     676             :     GPG_ERR_ESTALE = GPG_ERR_SYSTEM_ERROR | 129,
     677             :     GPG_ERR_ESTRPIPE = GPG_ERR_SYSTEM_ERROR | 130,
     678             :     GPG_ERR_ETIME = GPG_ERR_SYSTEM_ERROR | 131,
     679             :     GPG_ERR_ETIMEDOUT = GPG_ERR_SYSTEM_ERROR | 132,
     680             :     GPG_ERR_ETOOMANYREFS = GPG_ERR_SYSTEM_ERROR | 133,
     681             :     GPG_ERR_ETXTBSY = GPG_ERR_SYSTEM_ERROR | 134,
     682             :     GPG_ERR_EUCLEAN = GPG_ERR_SYSTEM_ERROR | 135,
     683             :     GPG_ERR_EUNATCH = GPG_ERR_SYSTEM_ERROR | 136,
     684             :     GPG_ERR_EUSERS = GPG_ERR_SYSTEM_ERROR | 137,
     685             :     GPG_ERR_EWOULDBLOCK = GPG_ERR_SYSTEM_ERROR | 138,
     686             :     GPG_ERR_EXDEV = GPG_ERR_SYSTEM_ERROR | 139,
     687             :     GPG_ERR_EXFULL = GPG_ERR_SYSTEM_ERROR | 140,
     688             : 
     689             :     /* This is one more than the largest allowed entry.  */
     690             :     GPG_ERR_CODE_DIM = 65536
     691             :   } gpg_err_code_t;
     692             : 
     693             : 
     694             : /* The error value type gpg_error_t.  */
     695             : 
     696             : /* We would really like to use bit-fields in a struct, but using
     697             :  * structs as return values can cause binary compatibility issues, in
     698             :  * particular if you want to do it efficiently (also see
     699             :  * -freg-struct-return option to GCC).  */
     700             : typedef unsigned int gpg_error_t;
     701             : 
     702             : /* We use the lowest 16 bits of gpg_error_t for error codes.  The 16th
     703             :  * bit indicates system errors.  */
     704             : #define GPG_ERR_CODE_MASK       (GPG_ERR_CODE_DIM - 1)
     705             : 
     706             : /* Bits 17 to 24 are reserved.  */
     707             : 
     708             : /* We use the upper 7 bits of gpg_error_t for error sources.  */
     709             : #define GPG_ERR_SOURCE_MASK     (GPG_ERR_SOURCE_DIM - 1)
     710             : #define GPG_ERR_SOURCE_SHIFT    24
     711             : 
     712             : /* The highest bit is reserved.  It shouldn't be used to prevent
     713             :  * potential negative numbers when transmitting error values as
     714             :  * text.  */
     715             : 
     716             : 
     717             : /*
     718             :  * GCC feature test.
     719             :  */
     720             : #if __GNUC__
     721             : # define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \
     722             :                                + __GNUC_MINOR__ * 100 \
     723             :                                + __GNUC_PATCHLEVEL__)
     724             : #else
     725             : # define _GPG_ERR_GCC_VERSION 0
     726             : #endif
     727             : 
     728             : #undef _GPG_ERR_HAVE_CONSTRUCTOR
     729             : #if _GPG_ERR_GCC_VERSION > 30100
     730             : # define _GPG_ERR_CONSTRUCTOR   __attribute__ ((__constructor__))
     731             : # define _GPG_ERR_HAVE_CONSTRUCTOR
     732             : #else
     733             : # define _GPG_ERR_CONSTRUCTOR
     734             : #endif
     735             : 
     736             : #define GPGRT_GCC_VERSION  _GPG_ERR_GCC_VERSION
     737             : 
     738             : #if _GPG_ERR_GCC_VERSION >= 29200
     739             : # define _GPGRT__RESTRICT __restrict__
     740             : #else
     741             : # define _GPGRT__RESTRICT
     742             : #endif
     743             : 
     744             : /* The noreturn attribute.  */
     745             : #if _GPG_ERR_GCC_VERSION >= 20500
     746             : # define GPGRT_ATTR_NORETURN   __attribute__ ((__noreturn__))
     747             : #else
     748             : # define GPGRT_ATTR_NORETURN
     749             : #endif
     750             : 
     751             : /* The printf attributes.  */
     752             : #if _GPG_ERR_GCC_VERSION >= 40400
     753             : # define GPGRT_ATTR_PRINTF(f, a) \
     754             :                     __attribute__ ((format(__gnu_printf__,f,a)))
     755             : # define GPGRT_ATTR_NR_PRINTF(f, a) \
     756             :                     __attribute__ ((__noreturn__, format(__gnu_printf__,f,a)))
     757             : #elif _GPG_ERR_GCC_VERSION >= 20500
     758             : # define GPGRT_ATTR_PRINTF(f, a) \
     759             :                     __attribute__ ((format(printf,f,a)))
     760             : # define GPGRT_ATTR_NR_PRINTF(f, a) \
     761             :                     __attribute__ ((__noreturn__, format(printf,f,a)))
     762             : #else
     763             : # define GPGRT_ATTR_PRINTF(f, a)
     764             : # define GPGRT_ATTR_NR_PRINTF(f, a)
     765             : #endif
     766             : #if _GPG_ERR_GCC_VERSION >= 20800
     767             : # define GPGRT_ATTR_FORMAT_ARG(a)  __attribute__ ((__format_arg__ (a)))
     768             : #else
     769             : # define GPGRT_ATTR_FORMAT_ARG(a)
     770             : #endif
     771             : 
     772             : /* The sentinel attribute.  */
     773             : #if _GPG_ERR_GCC_VERSION >= 40000
     774             : # define GPGRT_ATTR_SENTINEL(a)  __attribute__ ((sentinel(a)))
     775             : #else
     776             : # define GPGRT_ATTR_SENTINEL(a)
     777             : #endif
     778             : 
     779             : /* The used and unused attributes.
     780             :  * I am not sure since when the unused attribute is really supported.
     781             :  * In any case it it only needed for gcc versions which print a
     782             :  * warning.  Thus let us require gcc >= 3.5.  */
     783             : #if _GPG_ERR_GCC_VERSION >= 40000
     784             : # define GPGRT_ATTR_USED  __attribute__ ((used))
     785             : #else
     786             : # define GPGRT_ATTR_USED
     787             : #endif
     788             : #if _GPG_ERR_GCC_VERSION >= 30500
     789             : # define GPGRT_ATTR_UNUSED  __attribute__ ((unused))
     790             : #else
     791             : # define GPGRT_ATTR_UNUSED
     792             : #endif
     793             : 
     794             : /* The deprecated attribute.  */
     795             : #if _GPG_ERR_GCC_VERSION >= 30100
     796             : # define GPGRT_ATTR_DEPRECATED  __attribute__ ((__deprecated__))
     797             : #else
     798             : # define GPGRT_ATTR_DEPRECATED
     799             : #endif
     800             : 
     801             : /* The pure attribute.  */
     802             : #if _GPG_ERR_GCC_VERSION >= 29600
     803             : # define GPGRT_ATTR_PURE  __attribute__ ((__pure__))
     804             : #else
     805             : # define GPGRT_ATTR_PURE
     806             : #endif
     807             : 
     808             : /* The malloc attribute.  */
     809             : #if _GPG_ERR_GCC_VERSION >= 30200
     810             : # define GPGRT_ATTR_MALLOC  __attribute__ ((__malloc__))
     811             : #else
     812             : # define GPGRT_ATTR_MALLOC
     813             : #endif
     814             : 
     815             : /* A macro defined if a GCC style __FUNCTION__ macro is available.  */
     816             : #undef GPGRT_HAVE_MACRO_FUNCTION
     817             : #if _GPG_ERR_GCC_VERSION >= 20500
     818             : # define GPGRT_HAVE_MACRO_FUNCTION 1
     819             : #endif
     820             : 
     821             : /* A macro defined if the pragma GCC push_options is available.  */
     822             : #undef GPGRT_HAVE_PRAGMA_GCC_PUSH
     823             : #if _GPG_ERR_GCC_VERSION >= 40400
     824             : # define GPGRT_HAVE_PRAGMA_GCC_PUSH 1
     825             : #endif
     826             : 
     827             : /* Detect LeakSanitizer (LSan) support for GCC and Clang based on
     828             :  * whether AddressSanitizer (ASAN) is enabled via -fsanitize=address).
     829             :  * Note that -fsanitize=leak just affect the linker options which
     830             :  * cannot be detected here.  In that case you have to define the
     831             :  * GPGRT_HAVE_LEAK_SANITIZER macro manually.  */
     832             : #ifdef __GNUC__
     833             : # ifdef __SANITIZE_ADDRESS__
     834             : #  define GPGRT_HAVE_LEAK_SANITIZER
     835             : # elif defined(__has_feature)
     836             : #  if __has_feature(address_sanitizer)
     837             : #   define GPGRT_HAVE_LEAK_SANITIZER
     838             : #  endif
     839             : # endif
     840             : #endif
     841             : 
     842             : 
     843             : /* The new name for the inline macro.  */
     844             : #define GPGRT_INLINE GPG_ERR_INLINE
     845             : 
     846             : #ifdef GPGRT_HAVE_LEAK_SANITIZER
     847             : # include <sanitizer/lsan_interface.h>
     848             : #endif
     849             : 
     850             : /* Mark heap objects as non-leaked memory. */
     851             : static GPGRT_INLINE void
     852             : gpgrt_annotate_leaked_object (const void *p)
     853             : {
     854             : #ifdef GPGRT_HAVE_LEAK_SANITIZER
     855             :   __lsan_ignore_object(p);
     856             : #else
     857             :   (void)p;
     858             : #endif
     859             : }
     860             : 
     861             : 
     862             : /*
     863             :  * Initialization function.
     864             :  */
     865             : 
     866             : /* Initialize the library.  This function should be run early.  */
     867             : gpg_error_t gpg_err_init (void) _GPG_ERR_CONSTRUCTOR;
     868             : 
     869             : /* If this is defined, the library is already initialized by the
     870             :    constructor and does not need to be initialized explicitely.  */
     871             : #undef GPG_ERR_INITIALIZED
     872             : #ifdef _GPG_ERR_HAVE_CONSTRUCTOR
     873             : # define GPG_ERR_INITIALIZED    1
     874             : # define gpgrt_init() do { gpg_err_init (); } while (0)
     875             : #else
     876             : # define gpgrt_init() do { ; } while (0)
     877             : #endif
     878             : 
     879             : /* See the source on how to use the deinit function; it is usually not
     880             :    required.  */
     881             : void gpg_err_deinit (int mode);
     882             : 
     883             : /* Register blocking system I/O clamping functions.  */
     884             : void gpgrt_set_syscall_clamp (void (*pre)(void), void (*post)(void));
     885             : 
     886             : /* Get current I/O clamping functions.  */
     887             : void gpgrt_get_syscall_clamp (void (**r_pre)(void), void (**r_post)(void));
     888             : 
     889             : /* Register a custom malloc/realloc/free function.  */
     890             : void gpgrt_set_alloc_func  (void *(*f)(void *a, size_t n));
     891             : 
     892             : 
     893             : 
     894             : /*
     895             :  * Constructor and accessor functions.
     896             :  */
     897             : 
     898             : /* Construct an error value from an error code and source.  Within a
     899             :  * subsystem, use gpg_error.  */
     900             : static GPG_ERR_INLINE gpg_error_t
     901        2978 : gpg_err_make (gpg_err_source_t source, gpg_err_code_t code)
     902             : {
     903           2 :   return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
     904        5762 :     : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
     905        2786 :        | (code & GPG_ERR_CODE_MASK));
     906             : }
     907             : 
     908             : 
     909             : /* The user should define GPG_ERR_SOURCE_DEFAULT before including this
     910             :  * file to specify a default source for gpg_error.  */
     911             : #ifndef GPG_ERR_SOURCE_DEFAULT
     912             : #define GPG_ERR_SOURCE_DEFAULT  GPG_ERR_SOURCE_UNKNOWN
     913             : #endif
     914             : 
     915             : static GPG_ERR_INLINE gpg_error_t
     916        2977 : gpg_error (gpg_err_code_t code)
     917             : {
     918        2987 :   return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code);
     919             : }
     920             : 
     921             : 
     922             : /* Retrieve the error code from an error value.  */
     923             : static GPG_ERR_INLINE gpg_err_code_t
     924        8527 : gpg_err_code (gpg_error_t err)
     925             : {
     926        8634 :   return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
     927             : }
     928             : 
     929             : 
     930             : /* Retrieve the error source from an error value.  */
     931             : static GPG_ERR_INLINE gpg_err_source_t
     932           0 : gpg_err_source (gpg_error_t err)
     933             : {
     934           2 :   return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
     935           0 :                              & GPG_ERR_SOURCE_MASK);
     936             : }
     937             : 
     938             : 
     939             : /* String functions.  */
     940             : 
     941             : /* Return a pointer to a string containing a description of the error
     942             :  * code in the error value ERR.  This function is not thread-safe.  */
     943             : const char *gpg_strerror (gpg_error_t err);
     944             : 
     945             : /* Return the error string for ERR in the user-supplied buffer BUF of
     946             :  * size BUFLEN.  This function is, in contrast to gpg_strerror,
     947             :  * thread-safe if a thread-safe strerror_r() function is provided by
     948             :  * the system.  If the function succeeds, 0 is returned and BUF
     949             :  * contains the string describing the error.  If the buffer was not
     950             :  * large enough, ERANGE is returned and BUF contains as much of the
     951             :  * beginning of the error string as fits into the buffer.  */
     952             : int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
     953             : 
     954             : /* Return a pointer to a string containing a description of the error
     955             :  * source in the error value ERR.  */
     956             : const char *gpg_strsource (gpg_error_t err);
     957             : 
     958             : 
     959             : /*
     960             :  * Mapping of system errors (errno).
     961             :  */
     962             : 
     963             : /* Retrieve the error code for the system error ERR.  This returns
     964             :  * GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
     965             :  * this). */
     966             : gpg_err_code_t gpg_err_code_from_errno (int err);
     967             : 
     968             : /* Retrieve the system error for the error code CODE.  This returns 0
     969             :  * if CODE is not a system error code.  */
     970             : int gpg_err_code_to_errno (gpg_err_code_t code);
     971             : 
     972             : /* Retrieve the error code directly from the ERRNO variable.  This
     973             :  * returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
     974             :  * (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
     975             : gpg_err_code_t gpg_err_code_from_syserror (void);
     976             : 
     977             : 
     978             : /* Set the ERRNO variable.  This function is the preferred way to set
     979             :  * ERRNO due to peculiarities on WindowsCE.  */
     980             : void gpg_err_set_errno (int err);
     981             : 
     982             : /* Return or check the version.  Both functions are identical.  */
     983             : const char *gpgrt_check_version (const char *req_version);
     984             : const char *gpg_error_check_version (const char *req_version);
     985             : 
     986             : /* System specific type definitions.  */
     987             : #include <sys/types.h>
     988             : 
     989             : typedef ssize_t gpgrt_ssize_t;
     990             : 
     991             : typedef long gpgrt_off_t;
     992             : 
     993             : 
     994             : 
     995             : 
     996             : /* Self-documenting convenience functions.  */
     997             : 
     998             : static GPG_ERR_INLINE gpg_error_t
     999           0 : gpg_err_make_from_errno (gpg_err_source_t source, int err)
    1000             : {
    1001           0 :   return gpg_err_make (source, gpg_err_code_from_errno (err));
    1002             : }
    1003             : 
    1004             : 
    1005             : static GPG_ERR_INLINE gpg_error_t
    1006             : gpg_error_from_errno (int err)
    1007             : {
    1008             :   return gpg_error (gpg_err_code_from_errno (err));
    1009             : }
    1010             : 
    1011             : static GPG_ERR_INLINE gpg_error_t
    1012         729 : gpg_error_from_syserror (void)
    1013             : {
    1014         729 :   return gpg_error (gpg_err_code_from_syserror ());
    1015             : }
    1016             : 
    1017             : 
    1018             : 
    1019             : /*
    1020             :  * Malloc and friends
    1021             :  */
    1022             : 
    1023             : void *gpgrt_realloc (void *a, size_t n);
    1024             : void *gpgrt_malloc (size_t n);
    1025             : void *gpgrt_calloc (size_t n, size_t m);
    1026             : char *gpgrt_strdup (const char *string);
    1027             : char *gpgrt_strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
    1028             : void gpgrt_free (void *a);
    1029             : 
    1030             : 
    1031             : /*
    1032             :  * System specific function wrappers.
    1033             :  */
    1034             : 
    1035             : /* A getenv replacement which mallocs the returned string.  */
    1036             : char *gpgrt_getenv (const char *name);
    1037             : 
    1038             : /* A setenv and a unsetenv replacement.*/
    1039             : gpg_err_code_t gpgrt_setenv (const char *name,
    1040             :                              const char *value, int overwrite);
    1041             : #define gpgrt_unsetenv(n) gpgrt_setenv ((n), NULL, 1)
    1042             : 
    1043             : /* A wrapper around mkdir using a string for the mode.  */
    1044             : gpg_err_code_t gpgrt_mkdir (const char *name, const char *modestr);
    1045             : 
    1046             : /* A simple wrapper around chdir.  */
    1047             : gpg_err_code_t gpgrt_chdir (const char *name);
    1048             : 
    1049             : /* Return the current WD as a malloced string.  */
    1050             : char *gpgrt_getcwd (void);
    1051             : 
    1052             : 
    1053             : 
    1054             : 
    1055             : /*
    1056             :  * Lock functions.
    1057             :  */
    1058             : 
    1059             : 
    1060             : typedef struct
    1061             : {
    1062             :   long _vers;
    1063             :   union {
    1064             :     volatile char _priv[40];
    1065             :     long _x_align;
    1066             :     long *_xp_align;
    1067             :   } u;
    1068             : } gpgrt_lock_t;
    1069             : 
    1070             : #define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \
    1071             :                                     0,0,0,0,0,0,0,0, \
    1072             :                                     0,0,0,0,0,0,0,0, \
    1073             :                                     0,0,0,0,0,0,0,0, \
    1074             :                                     0,0,0,0,0,0,0,0}}}
    1075             : 
    1076             : 
    1077             : #define GPGRT_LOCK_DEFINE(name) \
    1078             :   static gpgrt_lock_t name  = GPGRT_LOCK_INITIALIZER
    1079             : 
    1080             : /* NB: If GPGRT_LOCK_DEFINE is not used, zero out the lock variable
    1081             :    before passing it to gpgrt_lock_init.  */
    1082             : gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd);
    1083             : gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd);
    1084             : gpg_err_code_t gpgrt_lock_trylock (gpgrt_lock_t *lockhd);
    1085             : gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
    1086             : gpg_err_code_t gpgrt_lock_destroy (gpgrt_lock_t *lockhd);
    1087             : 
    1088             : 
    1089             : 
    1090             : /*
    1091             :  * Thread functions.
    1092             :  */
    1093             : 
    1094             : gpg_err_code_t gpgrt_yield (void);
    1095             : 
    1096             : 
    1097             : 
    1098             : 
    1099             : /*
    1100             :  * Estream
    1101             :  */
    1102             : 
    1103             : /* The definition of this struct is entirely private.  You must not
    1104             :    use it for anything.  It is only here so some functions can be
    1105             :    implemented as macros.  */
    1106             : struct _gpgrt_stream_internal;
    1107             : struct _gpgrt__stream
    1108             : {
    1109             :   /* The layout of this struct must never change.  It may be grown,
    1110             :      but only if all functions which access the new members are
    1111             :      versioned.  */
    1112             : 
    1113             :   /* Various flags.  */
    1114             :   struct {
    1115             :     unsigned int magic: 16;
    1116             :     unsigned int writing: 1;
    1117             :     unsigned int reserved: 15;
    1118             :   } flags;
    1119             : 
    1120             :   /* A pointer to the stream buffer.  */
    1121             :   unsigned char *buffer;
    1122             : 
    1123             :   /* The size of the buffer in bytes.  */
    1124             :   size_t buffer_size;
    1125             : 
    1126             :   /* The length of the usable data in the buffer, only valid when in
    1127             :      read mode (see flags).  */
    1128             :   size_t data_len;
    1129             : 
    1130             :   /* The current position of the offset pointer, valid in read and
    1131             :      write mode.  */
    1132             :   size_t data_offset;
    1133             : 
    1134             :   size_t data_flushed;
    1135             :   unsigned char *unread_buffer;
    1136             :   size_t unread_buffer_size;
    1137             : 
    1138             :   /* The number of unread bytes.  */
    1139             :   size_t unread_data_len;
    1140             : 
    1141             :   /* A pointer to our internal data for this stream.  */
    1142             :   struct _gpgrt_stream_internal *intern;
    1143             : };
    1144             : 
    1145             : /* The opaque type for an estream.  */
    1146             : typedef struct _gpgrt__stream *gpgrt_stream_t;
    1147             : #ifdef GPGRT_ENABLE_ES_MACROS
    1148             : typedef struct _gpgrt__stream *estream_t;
    1149             : #endif
    1150             : 
    1151             : typedef ssize_t (*gpgrt_cookie_read_function_t) (void *cookie,
    1152             :                                                  void *buffer, size_t size);
    1153             : typedef ssize_t (*gpgrt_cookie_write_function_t) (void *cookie,
    1154             :                                                   const void *buffer,
    1155             :                                                   size_t size);
    1156             : typedef int (*gpgrt_cookie_seek_function_t) (void *cookie,
    1157             :                                              gpgrt_off_t *pos, int whence);
    1158             : typedef int (*gpgrt_cookie_close_function_t) (void *cookie);
    1159             : 
    1160             : struct _gpgrt_cookie_io_functions
    1161             : {
    1162             :   gpgrt_cookie_read_function_t func_read;
    1163             :   gpgrt_cookie_write_function_t func_write;
    1164             :   gpgrt_cookie_seek_function_t func_seek;
    1165             :   gpgrt_cookie_close_function_t func_close;
    1166             : };
    1167             : typedef struct _gpgrt_cookie_io_functions gpgrt_cookie_io_functions_t;
    1168             : #ifdef GPGRT_ENABLE_ES_MACROS
    1169             : typedef struct _gpgrt_cookie_io_functions  es_cookie_io_functions_t;
    1170             : #define es_cookie_read_function_t  gpgrt_cookie_read_function_t
    1171             : #define es_cookie_write_function_t gpgrt_cookie_read_function_t
    1172             : #define es_cookie_seek_function_t  gpgrt_cookie_read_function_t
    1173             : #define es_cookie_close_function_t gpgrt_cookie_read_function_t
    1174             : #endif
    1175             : 
    1176             : enum gpgrt_syshd_types
    1177             :   {
    1178             :     GPGRT_SYSHD_NONE = 0,  /* No system handle available.                   */
    1179             :     GPGRT_SYSHD_FD = 1,    /* A file descriptor as returned by open().      */
    1180             :     GPGRT_SYSHD_SOCK = 2,  /* A socket as returned by socket().             */
    1181             :     GPGRT_SYSHD_RVID = 3,  /* A rendezvous id (see libassuan's gpgcedev.c).  */
    1182             :     GPGRT_SYSHD_HANDLE = 4 /* A HANDLE object (Windows).                    */
    1183             :   };
    1184             : 
    1185             : struct _gpgrt_syshd
    1186             : {
    1187             :   enum gpgrt_syshd_types type;
    1188             :   union {
    1189             :     int fd;
    1190             :     int sock;
    1191             :     int rvid;
    1192             :     void *handle;
    1193             :   } u;
    1194             : };
    1195             : typedef struct _gpgrt_syshd gpgrt_syshd_t;
    1196             : #ifdef GPGRT_ENABLE_ES_MACROS
    1197             : typedef struct _gpgrt_syshd es_syshd_t;
    1198             : #define ES_SYSHD_NONE   GPGRT_SYSHD_NONE
    1199             : #define ES_SYSHD_FD     GPGRT_SYSHD_FD
    1200             : #define ES_SYSHD_SOCK   GPGRT_SYSHD_SOCK
    1201             : #define ES_SYSHD_RVID   GPGRT_SYSHD_RVID
    1202             : #define ES_SYSHD_HANDLE GPGRT_SYSHD_HANDLE
    1203             : #endif
    1204             : 
    1205             : /* The object used with gpgrt_poll.  */
    1206             : struct _gpgrt_poll_s
    1207             : {
    1208             :   gpgrt_stream_t stream;
    1209             :   unsigned int want_read:1;
    1210             :   unsigned int want_write:1;
    1211             :   unsigned int want_oob:1;
    1212             :   unsigned int want_rdhup:1;
    1213             :   unsigned int _reserv1:4;
    1214             :   unsigned int got_read:1;
    1215             :   unsigned int got_write:1;
    1216             :   unsigned int got_oob:1;
    1217             :   unsigned int got_rdhup:1;
    1218             :   unsigned int _reserv2:4;
    1219             :   unsigned int got_err:1;
    1220             :   unsigned int got_hup:1;
    1221             :   unsigned int got_nval:1;
    1222             :   unsigned int _reserv3:4;
    1223             :   unsigned int ignore:1;
    1224             :   unsigned int user:8;       /* For application use.  */
    1225             : };
    1226             : typedef struct _gpgrt_poll_s gpgrt_poll_t;
    1227             : #ifdef GPGRT_ENABLE_ES_MACROS
    1228             : typedef struct _gpgrt_poll_s es_poll_t;
    1229             : #endif
    1230             : 
    1231             : gpgrt_stream_t gpgrt_fopen (const char *_GPGRT__RESTRICT path,
    1232             :                             const char *_GPGRT__RESTRICT mode);
    1233             : gpgrt_stream_t gpgrt_mopen (void *_GPGRT__RESTRICT data,
    1234             :                             size_t data_n, size_t data_len,
    1235             :                             unsigned int grow,
    1236             :                             void *(*func_realloc) (void *mem, size_t size),
    1237             :                             void (*func_free) (void *mem),
    1238             :                             const char *_GPGRT__RESTRICT mode);
    1239             : gpgrt_stream_t gpgrt_fopenmem (size_t memlimit,
    1240             :                                const char *_GPGRT__RESTRICT mode);
    1241             : gpgrt_stream_t gpgrt_fopenmem_init (size_t memlimit,
    1242             :                                     const char *_GPGRT__RESTRICT mode,
    1243             :                                     const void *data, size_t datalen);
    1244             : gpgrt_stream_t gpgrt_fdopen    (int filedes, const char *mode);
    1245             : gpgrt_stream_t gpgrt_fdopen_nc (int filedes, const char *mode);
    1246             : gpgrt_stream_t gpgrt_sysopen    (gpgrt_syshd_t *syshd, const char *mode);
    1247             : gpgrt_stream_t gpgrt_sysopen_nc (gpgrt_syshd_t *syshd, const char *mode);
    1248             : gpgrt_stream_t gpgrt_fpopen    (FILE *fp, const char *mode);
    1249             : gpgrt_stream_t gpgrt_fpopen_nc (FILE *fp, const char *mode);
    1250             : gpgrt_stream_t gpgrt_freopen (const char *_GPGRT__RESTRICT path,
    1251             :                               const char *_GPGRT__RESTRICT mode,
    1252             :                               gpgrt_stream_t _GPGRT__RESTRICT stream);
    1253             : gpgrt_stream_t gpgrt_fopencookie (void *_GPGRT__RESTRICT cookie,
    1254             :                                   const char *_GPGRT__RESTRICT mode,
    1255             :                                   gpgrt_cookie_io_functions_t functions);
    1256             : int gpgrt_fclose (gpgrt_stream_t stream);
    1257             : int gpgrt_fclose_snatch (gpgrt_stream_t stream,
    1258             :                          void **r_buffer, size_t *r_buflen);
    1259             : int gpgrt_onclose (gpgrt_stream_t stream, int mode,
    1260             :                    void (*fnc) (gpgrt_stream_t, void*), void *fnc_value);
    1261             : int gpgrt_fileno (gpgrt_stream_t stream);
    1262             : int gpgrt_fileno_unlocked (gpgrt_stream_t stream);
    1263             : int gpgrt_syshd (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
    1264             : int gpgrt_syshd_unlocked (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
    1265             : 
    1266             : void _gpgrt_set_std_fd (int no, int fd);
    1267             : gpgrt_stream_t _gpgrt_get_std_stream (int fd);
    1268             : 
    1269             : #define gpgrt_stdin  _gpgrt_get_std_stream (0)
    1270             : #define gpgrt_stdout _gpgrt_get_std_stream (1)
    1271             : #define gpgrt_stderr _gpgrt_get_std_stream (2)
    1272             : 
    1273             : 
    1274             : void gpgrt_flockfile (gpgrt_stream_t stream);
    1275             : int  gpgrt_ftrylockfile (gpgrt_stream_t stream);
    1276             : void gpgrt_funlockfile (gpgrt_stream_t stream);
    1277             : 
    1278             : int gpgrt_feof (gpgrt_stream_t stream);
    1279             : int gpgrt_feof_unlocked (gpgrt_stream_t stream);
    1280             : int gpgrt_ferror (gpgrt_stream_t stream);
    1281             : int gpgrt_ferror_unlocked (gpgrt_stream_t stream);
    1282             : void gpgrt_clearerr (gpgrt_stream_t stream);
    1283             : void gpgrt_clearerr_unlocked (gpgrt_stream_t stream);
    1284             : 
    1285             : int _gpgrt_pending (gpgrt_stream_t stream);          /* (private) */
    1286             : int _gpgrt_pending_unlocked (gpgrt_stream_t stream); /* (private) */
    1287             : 
    1288             : #define gpgrt_pending(stream) _gpgrt_pending (stream)
    1289             : 
    1290             : #define gpgrt_pending_unlocked(stream)                          \
    1291             :   (((!(stream)->flags.writing)                                       \
    1292             :     && (((stream)->data_offset < (stream)->data_len)           \
    1293             :         || ((stream)->unread_data_len)))                        \
    1294             :    ? 1 : _gpgrt_pending_unlocked ((stream)))
    1295             : 
    1296             : int gpgrt_fflush (gpgrt_stream_t stream);
    1297             : int gpgrt_fseek (gpgrt_stream_t stream, long int offset, int whence);
    1298             : int gpgrt_fseeko (gpgrt_stream_t stream, gpgrt_off_t offset, int whence);
    1299             : long int gpgrt_ftell (gpgrt_stream_t stream);
    1300             : gpgrt_off_t gpgrt_ftello (gpgrt_stream_t stream);
    1301             : void gpgrt_rewind (gpgrt_stream_t stream);
    1302             : 
    1303             : int gpgrt_fgetc (gpgrt_stream_t stream);
    1304             : int gpgrt_fputc (int c, gpgrt_stream_t stream);
    1305             : 
    1306             : int _gpgrt_getc_underflow (gpgrt_stream_t stream);       /* (private) */
    1307             : int _gpgrt_putc_overflow (int c, gpgrt_stream_t stream); /* (private) */
    1308             : 
    1309             : #define gpgrt_getc_unlocked(stream)                             \
    1310             :   (((!(stream)->flags.writing)                                       \
    1311             :     && ((stream)->data_offset < (stream)->data_len)            \
    1312             :     && (! (stream)->unread_data_len))                                \
    1313             :   ? ((int) (stream)->buffer[((stream)->data_offset)++])           \
    1314             :   : _gpgrt_getc_underflow ((stream)))
    1315             : 
    1316             : #define gpgrt_putc_unlocked(c, stream)                          \
    1317             :   (((stream)->flags.writing                                  \
    1318             :     && ((stream)->data_offset < (stream)->buffer_size)         \
    1319             :     && (c != '\n'))                                             \
    1320             :   ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))   \
    1321             :   : _gpgrt_putc_overflow ((c), (stream)))
    1322             : 
    1323             : #define gpgrt_getc(stream)    gpgrt_fgetc (stream)
    1324             : #define gpgrt_putc(c, stream) gpgrt_fputc (c, stream)
    1325             : 
    1326             : int gpgrt_ungetc (int c, gpgrt_stream_t stream);
    1327             : 
    1328             : int gpgrt_read (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1329             :                 void *_GPGRT__RESTRICT buffer, size_t bytes_to_read,
    1330             :                 size_t *_GPGRT__RESTRICT bytes_read);
    1331             : int gpgrt_write (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1332             :                  const void *_GPGRT__RESTRICT buffer, size_t bytes_to_write,
    1333             :                  size_t *_GPGRT__RESTRICT bytes_written);
    1334             : int gpgrt_write_sanitized (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1335             :                            const void *_GPGRT__RESTRICT buffer, size_t length,
    1336             :                            const char *delimiters,
    1337             :                            size_t *_GPGRT__RESTRICT bytes_written);
    1338             : int gpgrt_write_hexstring (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1339             :                            const void *_GPGRT__RESTRICT buffer, size_t length,
    1340             :                            int reserved,
    1341             :                            size_t *_GPGRT__RESTRICT bytes_written);
    1342             : 
    1343             : size_t gpgrt_fread (void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems,
    1344             :                     gpgrt_stream_t _GPGRT__RESTRICT stream);
    1345             : size_t gpgrt_fwrite (const void *_GPGRT__RESTRICT ptr, size_t size,
    1346             :                      size_t nitems, gpgrt_stream_t _GPGRT__RESTRICT stream);
    1347             : 
    1348             : char *gpgrt_fgets (char *_GPGRT__RESTRICT s, int n,
    1349             :                    gpgrt_stream_t _GPGRT__RESTRICT stream);
    1350             : int gpgrt_fputs (const char *_GPGRT__RESTRICT s,
    1351             :                  gpgrt_stream_t _GPGRT__RESTRICT stream);
    1352             : int gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s,
    1353             :                           gpgrt_stream_t _GPGRT__RESTRICT stream);
    1354             : 
    1355             : ssize_t gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr,
    1356             :                        size_t *_GPGRT__RESTRICT n,
    1357             :                        gpgrt_stream_t stream);
    1358             : ssize_t gpgrt_read_line (gpgrt_stream_t stream,
    1359             :                          char **addr_of_buffer, size_t *length_of_buffer,
    1360             :                          size_t *max_length);
    1361             : 
    1362             : int gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1363             :                    const char *_GPGRT__RESTRICT format, ...)
    1364             :                    GPGRT_ATTR_PRINTF(2,3);
    1365             : int gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1366             :                             const char *_GPGRT__RESTRICT format, ...)
    1367             :                             GPGRT_ATTR_PRINTF(2,3);
    1368             : 
    1369             : int gpgrt_printf (const char *_GPGRT__RESTRICT format, ...)
    1370             :                   GPGRT_ATTR_PRINTF(1,2);
    1371             : int gpgrt_printf_unlocked (const char *_GPGRT__RESTRICT format, ...)
    1372             :                            GPGRT_ATTR_PRINTF(1,2);
    1373             : 
    1374             : int gpgrt_vfprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1375             :                     const char *_GPGRT__RESTRICT format, va_list ap)
    1376             :                     GPGRT_ATTR_PRINTF(2,0);
    1377             : int gpgrt_vfprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1378             :                              const char *_GPGRT__RESTRICT format, va_list ap)
    1379             :                              GPGRT_ATTR_PRINTF(2,0);
    1380             : 
    1381             : int gpgrt_setvbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1382             :                    char *_GPGRT__RESTRICT buf, int mode, size_t size);
    1383             : void gpgrt_setbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1384             :                    char *_GPGRT__RESTRICT buf);
    1385             : 
    1386             : void gpgrt_set_binary (gpgrt_stream_t stream);
    1387             : int  gpgrt_set_nonblock (gpgrt_stream_t stream, int onoff);
    1388             : int  gpgrt_get_nonblock (gpgrt_stream_t stream);
    1389             : 
    1390             : int gpgrt_poll (gpgrt_poll_t *fdlist, unsigned int nfds, int timeout);
    1391             : 
    1392             : gpgrt_stream_t gpgrt_tmpfile (void);
    1393             : 
    1394             : void gpgrt_opaque_set (gpgrt_stream_t _GPGRT__RESTRICT stream,
    1395             :                        void *_GPGRT__RESTRICT opaque);
    1396             : void *gpgrt_opaque_get (gpgrt_stream_t stream);
    1397             : 
    1398             : void gpgrt_fname_set (gpgrt_stream_t stream, const char *fname);
    1399             : const char *gpgrt_fname_get (gpgrt_stream_t stream);
    1400             : 
    1401             : int gpgrt_asprintf (char **r_buf, const char * _GPGRT__RESTRICT format, ...)
    1402             :                     GPGRT_ATTR_PRINTF(2,3);
    1403             : int gpgrt_vasprintf (char **r_buf, const char * _GPGRT__RESTRICT format,
    1404             :                      va_list ap)
    1405             :                      GPGRT_ATTR_PRINTF(2,0);
    1406             : char *gpgrt_bsprintf (const char * _GPGRT__RESTRICT format, ...)
    1407             :                       GPGRT_ATTR_PRINTF(1,2);
    1408             : char *gpgrt_vbsprintf (const char * _GPGRT__RESTRICT format, va_list ap)
    1409             :                        GPGRT_ATTR_PRINTF(1,0);
    1410             : int gpgrt_snprintf (char *buf, size_t bufsize,
    1411             :                     const char * _GPGRT__RESTRICT format, ...)
    1412             :                     GPGRT_ATTR_PRINTF(3,4);
    1413             : int gpgrt_vsnprintf (char *buf,size_t bufsize,
    1414             :                      const char * _GPGRT__RESTRICT format, va_list arg_ptr)
    1415             :                      GPGRT_ATTR_PRINTF(3,0);
    1416             : 
    1417             : 
    1418             : #ifdef GPGRT_ENABLE_ES_MACROS
    1419             : # define es_fopen             gpgrt_fopen
    1420             : # define es_mopen             gpgrt_mopen
    1421             : # define es_fopenmem          gpgrt_fopenmem
    1422             : # define es_fopenmem_init     gpgrt_fopenmem_init
    1423             : # define es_fdopen            gpgrt_fdopen
    1424             : # define es_fdopen_nc         gpgrt_fdopen_nc
    1425             : # define es_sysopen           gpgrt_sysopen
    1426             : # define es_sysopen_nc        gpgrt_sysopen_nc
    1427             : # define es_fpopen            gpgrt_fpopen
    1428             : # define es_fpopen_nc         gpgrt_fpopen_nc
    1429             : # define es_freopen           gpgrt_freopen
    1430             : # define es_fopencookie       gpgrt_fopencookie
    1431             : # define es_fclose            gpgrt_fclose
    1432             : # define es_fclose_snatch     gpgrt_fclose_snatch
    1433             : # define es_onclose           gpgrt_onclose
    1434             : # define es_fileno            gpgrt_fileno
    1435             : # define es_fileno_unlocked   gpgrt_fileno_unlocked
    1436             : # define es_syshd             gpgrt_syshd
    1437             : # define es_syshd_unlocked    gpgrt_syshd_unlocked
    1438             : # define es_stdin             _gpgrt_get_std_stream (0)
    1439             : # define es_stdout            _gpgrt_get_std_stream (1)
    1440             : # define es_stderr            _gpgrt_get_std_stream (2)
    1441             : # define es_flockfile         gpgrt_flockfile
    1442             : # define es_ftrylockfile      gpgrt_ftrylockfile
    1443             : # define es_funlockfile       gpgrt_funlockfile
    1444             : # define es_feof              gpgrt_feof
    1445             : # define es_feof_unlocked     gpgrt_feof_unlocked
    1446             : # define es_ferror            gpgrt_ferror
    1447             : # define es_ferror_unlocked   gpgrt_ferror_unlocked
    1448             : # define es_clearerr          gpgrt_clearerr
    1449             : # define es_clearerr_unlocked gpgrt_clearerr_unlocked
    1450             : # define es_pending           gpgrt_pending
    1451             : # define es_pending_unlocked  gpgrt_pending_unlocked
    1452             : # define es_fflush            gpgrt_fflush
    1453             : # define es_fseek             gpgrt_fseek
    1454             : # define es_fseeko            gpgrt_fseeko
    1455             : # define es_ftell             gpgrt_ftell
    1456             : # define es_ftello            gpgrt_ftello
    1457             : # define es_rewind            gpgrt_rewind
    1458             : # define es_fgetc             gpgrt_fgetc
    1459             : # define es_fputc             gpgrt_fputc
    1460             : # define es_getc_unlocked     gpgrt_getc_unlocked
    1461             : # define es_putc_unlocked     gpgrt_putc_unlocked
    1462             : # define es_getc              gpgrt_getc
    1463             : # define es_putc              gpgrt_putc
    1464             : # define es_ungetc            gpgrt_ungetc
    1465             : # define es_read              gpgrt_read
    1466             : # define es_write             gpgrt_write
    1467             : # define es_write_sanitized   gpgrt_write_sanitized
    1468             : # define es_write_hexstring   gpgrt_write_hexstring
    1469             : # define es_fread             gpgrt_fread
    1470             : # define es_fwrite            gpgrt_fwrite
    1471             : # define es_fgets             gpgrt_fgets
    1472             : # define es_fputs             gpgrt_fputs
    1473             : # define es_fputs_unlocked    gpgrt_fputs_unlocked
    1474             : # define es_getline           gpgrt_getline
    1475             : # define es_read_line         gpgrt_read_line
    1476             : # define es_free              gpgrt_free
    1477             : # define es_fprintf           gpgrt_fprintf
    1478             : # define es_fprintf_unlocked  gpgrt_fprintf_unlocked
    1479             : # define es_printf            gpgrt_printf
    1480             : # define es_printf_unlocked   gpgrt_printf_unlocked
    1481             : # define es_vfprintf          gpgrt_vfprintf
    1482             : # define es_vfprintf_unlocked gpgrt_vfprintf_unlocked
    1483             : # define es_setvbuf           gpgrt_setvbuf
    1484             : # define es_setbuf            gpgrt_setbuf
    1485             : # define es_set_binary        gpgrt_set_binary
    1486             : # define es_set_nonblock      gpgrt_set_nonblock
    1487             : # define es_get_nonblock      gpgrt_get_nonblock
    1488             : # define es_poll              gpgrt_poll
    1489             : # define es_tmpfile           gpgrt_tmpfile
    1490             : # define es_opaque_set        gpgrt_opaque_set
    1491             : # define es_opaque_get        gpgrt_opaque_get
    1492             : # define es_fname_set         gpgrt_fname_set
    1493             : # define es_fname_get         gpgrt_fname_get
    1494             : # define es_asprintf          gpgrt_asprintf
    1495             : # define es_vasprintf         gpgrt_vasprintf
    1496             : # define es_bsprintf          gpgrt_bsprintf
    1497             : # define es_vbsprintf         gpgrt_vbsprintf
    1498             : #endif /*GPGRT_ENABLE_ES_MACROS*/
    1499             : 
    1500             : 
    1501             : 
    1502             : /*
    1503             :  * Base64 encode and decode functions.
    1504             :  */
    1505             : 
    1506             : struct _gpgrt_b64state;
    1507             : typedef struct _gpgrt_b64state *gpgrt_b64state_t;
    1508             : 
    1509             : gpgrt_b64state_t gpgrt_b64enc_start (gpgrt_stream_t stream, const char *title);
    1510             : gpg_err_code_t   gpgrt_b64enc_write (gpgrt_b64state_t state,
    1511             :                                      const void *buffer, size_t nbytes);
    1512             : gpg_err_code_t   gpgrt_b64enc_finish (gpgrt_b64state_t state);
    1513             : 
    1514             : gpgrt_b64state_t gpgrt_b64dec_start (const char *title);
    1515             : gpg_error_t      gpgrt_b64dec_proc (gpgrt_b64state_t state,
    1516             :                                     void *buffer, size_t length,
    1517             :                                     size_t *r_nbytes);
    1518             : gpg_error_t      gpgrt_b64dec_finish (gpgrt_b64state_t state);
    1519             : 
    1520             : 
    1521             : 
    1522             : /*
    1523             :  * Logging functions
    1524             :  */
    1525             : 
    1526             : /* Flag values for gpgrt_log_set_prefix. */
    1527             : #define GPGRT_LOG_WITH_PREFIX  1
    1528             : #define GPGRT_LOG_WITH_TIME    2
    1529             : #define GPGRT_LOG_WITH_PID     4
    1530             : #define GPGRT_LOG_RUN_DETACHED 256
    1531             : #define GPGRT_LOG_NO_REGISTRY  512
    1532             : 
    1533             : /* Log levels as used by gpgrt_log.  */
    1534             : enum gpgrt_log_levels
    1535             :   {
    1536             :     GPGRT_LOGLVL_BEGIN,
    1537             :     GPGRT_LOGLVL_CONT,
    1538             :     GPGRT_LOGLVL_INFO,
    1539             :     GPGRT_LOGLVL_WARN,
    1540             :     GPGRT_LOGLVL_ERROR,
    1541             :     GPGRT_LOGLVL_FATAL,
    1542             :     GPGRT_LOGLVL_BUG,
    1543             :     GPGRT_LOGLVL_DEBUG
    1544             :   };
    1545             : 
    1546             : 
    1547             : /* The next 4 functions are not thread-safe - call them early.  */
    1548             : void gpgrt_log_set_sink (const char *name, gpgrt_stream_t stream, int fd);
    1549             : void gpgrt_log_set_socket_dir_cb (const char *(*fnc)(void));
    1550             : void gpgrt_log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value));
    1551             : void gpgrt_log_set_prefix (const char *text, unsigned int flags);
    1552             : 
    1553             : int  gpgrt_get_errorcount (int clear);
    1554             : void gpgrt_inc_errorcount (void);
    1555             : const char *gpgrt_log_get_prefix (unsigned int *flags);
    1556             : int  gpgrt_log_test_fd (int fd);
    1557             : int  gpgrt_log_get_fd (void);
    1558             : gpgrt_stream_t gpgrt_log_get_stream (void);
    1559             : 
    1560             : void gpgrt_log (int level, const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
    1561             : void gpgrt_logv (int level, const char *fmt, va_list arg_ptr);
    1562             : void gpgrt_logv_prefix (int level, const char *prefix,
    1563             :                               const char *fmt, va_list arg_ptr);
    1564             : void gpgrt_log_string (int level, const char *string);
    1565             : void gpgrt_log_bug (const char *fmt, ...)    GPGRT_ATTR_NR_PRINTF(1,2);
    1566             : void gpgrt_log_fatal (const char *fmt, ...)  GPGRT_ATTR_NR_PRINTF(1,2);
    1567             : void gpgrt_log_error (const char *fmt, ...)  GPGRT_ATTR_PRINTF(1,2);
    1568             : void gpgrt_log_info (const char *fmt, ...)   GPGRT_ATTR_PRINTF(1,2);
    1569             : void gpgrt_log_debug (const char *fmt, ...)  GPGRT_ATTR_PRINTF(1,2);
    1570             : void gpgrt_log_debug_string (const char *string,
    1571             :                              const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
    1572             : void gpgrt_log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
    1573             : void gpgrt_log_printhex (const void *buffer, size_t length,
    1574             :                          const char *fmt, ...) GPGRT_ATTR_PRINTF(3,4);
    1575             : void gpgrt_log_clock (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
    1576             : void gpgrt_log_flush (void);
    1577             : void _gpgrt_log_assert (const char *expr, const char *file, int line,
    1578             :                         const char *func) GPGRT_ATTR_NORETURN;
    1579             : 
    1580             : #ifdef GPGRT_HAVE_MACRO_FUNCTION
    1581             : # define gpgrt_assert(expr)                                     \
    1582             :   ((expr)                                                       \
    1583             :    ? (void) 0                                                   \
    1584             :    : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
    1585             : #else /*!GPGRT_HAVE_MACRO_FUNCTION*/
    1586             : # define gpgrt_assert(expr)                                     \
    1587             :   ((expr)                                                       \
    1588             :    ? (void) 0                                                   \
    1589             :    : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL))
    1590             : #endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
    1591             : 
    1592             : #ifdef GPGRT_ENABLE_LOG_MACROS
    1593             : # define log_get_errorcount      gpgrt_get_errorcount
    1594             : # define log_inc_errorcount      gpgrt_inc_errorcount
    1595             : # define log_set_file(a)         gpgrt_log_set_sink ((a), NULL, -1)
    1596             : # define log_set_fd(a)           gpgrt_log_set_sink (NULL, NULL, (a))
    1597             : # define log_set_stream(a)       gpgrt_log_set_sink (NULL, (a), -1)
    1598             : # define log_set_socket_dir_cb   gpgrt_log_set_socket_dir_cb
    1599             : # define log_set_pid_suffix_cb   gpgrt_log_set_pid_suffix_cb
    1600             : # define log_set_prefix          gpgrt_log_set_prefix
    1601             : # define log_get_prefix          gpgrt_log_get_prefix
    1602             : # define log_test_fd             gpgrt_log_test_fd
    1603             : # define log_get_fd              gpgrt_log_get_fd
    1604             : # define log_get_stream          gpgrt_log_get_stream
    1605             : # define log_log                 gpgrt_log
    1606             : # define log_logv                gpgrt_logv
    1607             : # define log_logv_prefix         gpgrt_logv_prefix
    1608             : # define log_string              gpgrt_log_string
    1609             : # define log_bug                 gpgrt_log_bug
    1610             : # define log_fatal               gpgrt_log_fatal
    1611             : # define log_error               gpgrt_log_error
    1612             : # define log_info                gpgrt_log_info
    1613             : # define log_debug               gpgrt_log_debug
    1614             : # define log_debug_string        gpgrt_log_debug_string
    1615             : # define log_printf              gpgrt_log_printf
    1616             : # define log_printhex            gpgrt_log_printhex
    1617             : # define log_clock               gpgrt_log_clock
    1618             : # define log_flush               gpgrt_log_flush
    1619             : # ifdef GPGRT_HAVE_MACRO_FUNCTION
    1620             : #  define log_assert(expr)                                      \
    1621             :   ((expr)                                                       \
    1622             :    ? (void) 0                                                   \
    1623             :    : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
    1624             : # else /*!GPGRT_HAVE_MACRO_FUNCTION*/
    1625             : #  define log_assert(expr)                                      \
    1626             :   ((expr)                                                       \
    1627             :    ? (void) 0                                                   \
    1628             :    : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL))
    1629             : # endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
    1630             : 
    1631             : #endif /*GPGRT_ENABLE_LOG_MACROS*/
    1632             : 
    1633             : 
    1634             : /*
    1635             :  * Spawn functions  (Not yet available)
    1636             :  */
    1637             : #define GPGRT_SPAWN_NONBLOCK   16 /* Set the streams to non-blocking.      */
    1638             : #define GPGRT_SPAWN_RUN_ASFW   64 /* Use AllowSetForegroundWindow on W32.  */
    1639             : #define GPGRT_SPAWN_DETACHED  128 /* Start the process in the background.  */
    1640             : 
    1641             : #if 0
    1642             : 
    1643             : /* Function and convenience macros to create pipes.  */
    1644             : gpg_err_code_t gpgrt_make_pipe (int filedes[2], gpgrt_stream_t *r_fp,
    1645             :                                 int direction, int nonblock);
    1646             : #define gpgrt_create_pipe(a)              gpgrt_make_pipe ((a),NULL,  0,  0);
    1647             : #define gpgrt_create_inbound_pipe(a,b,c)  gpgrt_make_pipe ((a), (b), -1,(c));
    1648             : #define gpgrt_create_outbound_pipe(a,b,c) gpgrt_make_pipe ((a), (b),  1,(c));
    1649             : 
    1650             : 
    1651             : /* Fork and exec PGMNAME.  */
    1652             : gpg_err_code_t gpgrt_spawn_process (const char *pgmname, const char *argv[],
    1653             :                                     int *execpt, void (*preexec)(void),
    1654             :                                     unsigned int flags,
    1655             :                                     gpgrt_stream_t *r_infp,
    1656             :                                     gpgrt_stream_t *r_outfp,
    1657             :                                     gpgrt_stream_t *r_errfp,
    1658             :                                     pid_t *pid);
    1659             : 
    1660             : /* Fork and exec PGNNAME and connect the process to the given FDs.  */
    1661             : gpg_err_code_t gpgrt_spawn_process_fd (const char *pgmname, const char *argv[],
    1662             :                                        int infd, int outfd, int errfd,
    1663             :                                        pid_t *pid);
    1664             : 
    1665             : /* Fork and exec PGMNAME as a detached process.  */
    1666             : gpg_err_code_t gpgrt_spawn_process_detached (const char *pgmname,
    1667             :                                              const char *argv[],
    1668             :                                              const char *envp[] );
    1669             : 
    1670             : /* Wait for a single process.  */
    1671             : gpg_err_code_t gpgrt_wait_process (const char *pgmname, pid_t pid, int hang,
    1672             :                                 int *r_exitcode);
    1673             : 
    1674             : /* Wait for a multiple processes.  */
    1675             : gpg_err_code_t gpgrt_wait_processes (const char **pgmnames, pid_t *pids,
    1676             :                                      size_t count, int hang, int *r_exitcodes);
    1677             : 
    1678             : /* Kill the process identified by PID.  */
    1679             : void gpgrt_kill_process (pid_t pid);
    1680             : 
    1681             : /* Release process resources identified by PID.  */
    1682             : void gpgrt_release_process (pid_t pid);
    1683             : 
    1684             : #endif /*0*/
    1685             : 
    1686             : 
    1687             : 
    1688             : /*
    1689             :  * Option parsing.
    1690             :  */
    1691             : 
    1692             : struct _gpgrt_argparse_internal_s;
    1693             : typedef struct
    1694             : {
    1695             :   int  *argc;         /* Pointer to ARGC (value subject to change). */
    1696             :   char ***argv;       /* Pointer to ARGV (value subject to change). */
    1697             :   unsigned int flags; /* Global flags.  May be set prior to calling the
    1698             :                          parser.  The parser may change the value.  */
    1699             :   int err;            /* Print error description for last option.
    1700             :                          Either 0,  ARGPARSE_PRINT_WARNING or
    1701             :                          ARGPARSE_PRINT_ERROR.  */
    1702             :   unsigned int lineno;/* The current line number.  */
    1703             :   int r_opt;          /* Returns option code. */
    1704             :   int r_type;         /* Returns type of option value.  */
    1705             :   union {
    1706             :     int   ret_int;
    1707             :     long  ret_long;
    1708             :     unsigned long ret_ulong;
    1709             :     char *ret_str;
    1710             :   } r;                /* Return values */
    1711             : 
    1712             :   struct _gpgrt_argparse_internal_s *internal;
    1713             : } gpgrt_argparse_t;
    1714             : 
    1715             : 
    1716             : typedef struct
    1717             : {
    1718             :   int          short_opt;
    1719             :   const char  *long_opt;
    1720             :   unsigned int flags;
    1721             :   const char  *description; /* Optional description. */
    1722             : } gpgrt_opt_t;
    1723             : 
    1724             : 
    1725             : #ifdef GPGRT_ENABLE_ARGPARSE_MACROS
    1726             : 
    1727             : /* Global flags for (gpgrt_argparse_t).flags.  */
    1728             : #define ARGPARSE_FLAG_KEEP        1  /* Do not remove options form argv.     */
    1729             : #define ARGPARSE_FLAG_ALL         2  /* Do not stop at last option but return
    1730             :                                         remaining args with R_OPT set to -1. */
    1731             : #define ARGPARSE_FLAG_MIXED       4  /* Assume options and args are mixed.   */
    1732             : #define ARGPARSE_FLAG_NOSTOP      8  /* Do not stop processing at "--".      */
    1733             : #define ARGPARSE_FLAG_ARG0       16  /* Do not skip the first arg.           */
    1734             : #define ARGPARSE_FLAG_ONEDASH    32  /* Allow long options with one dash.    */
    1735             : #define ARGPARSE_FLAG_NOVERSION  64  /* No output for "--version".           */
    1736             : #define ARGPARSE_FLAG_RESET     128  /* Request to reset the internal state. */
    1737             : #define ARGPARSE_FLAG_STOP_SEEN 256  /* Set to true if a "--" has been seen. */
    1738             : #define ARGPARSE_FLAG_NOLINENO  512  /* Do not zero the lineno field.         */
    1739             : 
    1740             : /* Constants for (gpgrt_argparse_t).err.  */
    1741             : #define ARGPARSE_PRINT_WARNING  1    /* Print a diagnostic.                  */
    1742             : #define ARGPARSE_PRINT_ERROR    2    /* Print a diagnostic and call exit.    */
    1743             : 
    1744             : /* Special return values of gpgrt_argparse.  */
    1745             : #define ARGPARSE_IS_ARG            (-1)
    1746             : #define ARGPARSE_INVALID_OPTION    (-2)
    1747             : #define ARGPARSE_MISSING_ARG       (-3)
    1748             : #define ARGPARSE_KEYWORD_TOO_LONG  (-4)
    1749             : #define ARGPARSE_READ_ERROR        (-5)
    1750             : #define ARGPARSE_UNEXPECTED_ARG    (-6)
    1751             : #define ARGPARSE_INVALID_COMMAND   (-7)
    1752             : #define ARGPARSE_AMBIGUOUS_OPTION  (-8)
    1753             : #define ARGPARSE_AMBIGUOUS_COMMAND (-9)
    1754             : #define ARGPARSE_INVALID_ALIAS     (-10)
    1755             : #define ARGPARSE_OUT_OF_CORE       (-11)
    1756             : #define ARGPARSE_INVALID_ARG       (-12)
    1757             : 
    1758             : /* Flags for the option descriptor (gpgrt_opt_t)->flags.  Note that
    1759             :  * a TYPE constant may be or-ed with the OPT constants.  */
    1760             : #define ARGPARSE_TYPE_NONE        0  /* Does not take an argument.        */
    1761             : #define ARGPARSE_TYPE_INT         1  /* Takes an int argument.            */
    1762             : #define ARGPARSE_TYPE_STRING      2  /* Takes a string argument.          */
    1763             : #define ARGPARSE_TYPE_LONG        3  /* Takes a long argument.            */
    1764             : #define ARGPARSE_TYPE_ULONG       4  /* Takes an unsigned long argument.  */
    1765             : #define ARGPARSE_OPT_OPTIONAL (1<<3) /* Argument is optional.             */
    1766             : #define ARGPARSE_OPT_PREFIX   (1<<4) /* Allow 0x etc. prefixed values.    */
    1767             : #define ARGPARSE_OPT_IGNORE   (1<<6) /* Ignore command or option.         */
    1768             : #define ARGPARSE_OPT_COMMAND  (1<<7) /* The argument is a command.        */
    1769             : 
    1770             : /* A set of macros to make option definitions easier to read.  */
    1771             : #define ARGPARSE_x(s,l,t,f,d) \
    1772             :      { (s), (l), ARGPARSE_TYPE_ ## t | (f), (d) }
    1773             : 
    1774             : #define ARGPARSE_s(s,l,t,d) \
    1775             :      { (s), (l), ARGPARSE_TYPE_ ## t, (d) }
    1776             : #define ARGPARSE_s_n(s,l,d) \
    1777             :      { (s), (l), ARGPARSE_TYPE_NONE, (d) }
    1778             : #define ARGPARSE_s_i(s,l,d) \
    1779             :      { (s), (l), ARGPARSE_TYPE_INT, (d) }
    1780             : #define ARGPARSE_s_s(s,l,d) \
    1781             :      { (s), (l), ARGPARSE_TYPE_STRING, (d) }
    1782             : #define ARGPARSE_s_l(s,l,d) \
    1783             :      { (s), (l), ARGPARSE_TYPE_LONG, (d) }
    1784             : #define ARGPARSE_s_u(s,l,d) \
    1785             :      { (s), (l), ARGPARSE_TYPE_ULONG, (d) }
    1786             : 
    1787             : #define ARGPARSE_o(s,l,t,d) \
    1788             :      { (s), (l), (ARGPARSE_TYPE_ ## t  | ARGPARSE_OPT_OPTIONAL), (d) }
    1789             : #define ARGPARSE_o_n(s,l,d) \
    1790             :      { (s), (l), (ARGPARSE_TYPE_NONE   | ARGPARSE_OPT_OPTIONAL), (d) }
    1791             : #define ARGPARSE_o_i(s,l,d) \
    1792             :      { (s), (l), (ARGPARSE_TYPE_INT    | ARGPARSE_OPT_OPTIONAL), (d) }
    1793             : #define ARGPARSE_o_s(s,l,d) \
    1794             :      { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_OPTIONAL), (d) }
    1795             : #define ARGPARSE_o_l(s,l,d) \
    1796             :      { (s), (l), (ARGPARSE_TYPE_LONG   | ARGPARSE_OPT_OPTIONAL), (d) }
    1797             : #define ARGPARSE_o_u(s,l,d) \
    1798             :      { (s), (l), (ARGPARSE_TYPE_ULONG  | ARGPARSE_OPT_OPTIONAL), (d) }
    1799             : 
    1800             : #define ARGPARSE_p(s,l,t,d) \
    1801             :      { (s), (l), (ARGPARSE_TYPE_ ## t  | ARGPARSE_OPT_PREFIX), (d) }
    1802             : #define ARGPARSE_p_n(s,l,d) \
    1803             :      { (s), (l), (ARGPARSE_TYPE_NONE   | ARGPARSE_OPT_PREFIX), (d) }
    1804             : #define ARGPARSE_p_i(s,l,d) \
    1805             :      { (s), (l), (ARGPARSE_TYPE_INT    | ARGPARSE_OPT_PREFIX), (d) }
    1806             : #define ARGPARSE_p_s(s,l,d) \
    1807             :      { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_PREFIX), (d) }
    1808             : #define ARGPARSE_p_l(s,l,d) \
    1809             :      { (s), (l), (ARGPARSE_TYPE_LONG   | ARGPARSE_OPT_PREFIX), (d) }
    1810             : #define ARGPARSE_p_u(s,l,d) \
    1811             :      { (s), (l), (ARGPARSE_TYPE_ULONG  | ARGPARSE_OPT_PREFIX), (d) }
    1812             : 
    1813             : #define ARGPARSE_op(s,l,t,d) \
    1814             :      { (s), (l), (ARGPARSE_TYPE_ ## t \
    1815             :                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
    1816             : #define ARGPARSE_op_n(s,l,d) \
    1817             :      { (s), (l), (ARGPARSE_TYPE_NONE \
    1818             :                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
    1819             : #define ARGPARSE_op_i(s,l,d) \
    1820             :      { (s), (l), (ARGPARSE_TYPE_INT \
    1821             :                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
    1822             : #define ARGPARSE_op_s(s,l,d) \
    1823             :      { (s), (l), (ARGPARSE_TYPE_STRING \
    1824             :                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
    1825             : #define ARGPARSE_op_l(s,l,d) \
    1826             :      { (s), (l), (ARGPARSE_TYPE_LONG \
    1827             :                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
    1828             : #define ARGPARSE_op_u(s,l,d) \
    1829             :      { (s), (l), (ARGPARSE_TYPE_ULONG \
    1830             :                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
    1831             : 
    1832             : #define ARGPARSE_c(s,l,d) \
    1833             :      { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_COMMAND), (d) }
    1834             : 
    1835             : #define ARGPARSE_ignore(s,l) \
    1836             :      { (s), (l), (ARGPARSE_OPT_IGNORE), "@" }
    1837             : 
    1838             : #define ARGPARSE_group(s,d) \
    1839             :      { (s), NULL, 0, (d) }
    1840             : 
    1841             : /* Mark the end of the list (mandatory).  */
    1842             : #define ARGPARSE_end() \
    1843             :      { 0, NULL, 0, NULL }
    1844             : 
    1845             : #endif /* GPGRT_ENABLE_ARGPARSE_MACROS */
    1846             : 
    1847             : /* Take care: gpgrt_argparse keeps state in ARG and requires that
    1848             :  * either ARGPARSE_FLAG_RESET is used after OPTS has been changed or
    1849             :  * gpgrt_argparse (NULL, ARG, NULL) is called first.  */
    1850             : int gpgrt_argparse (gpgrt_stream_t fp,
    1851             :                     gpgrt_argparse_t *arg, gpgrt_opt_t *opts);
    1852             : void gpgrt_usage (int level);
    1853             : const char *gpgrt_strusage (int level);
    1854             : void gpgrt_set_strusage (const char *(*f)(int));
    1855             : void gpgrt_set_usage_outfnc (int (*f)(int, const char *));
    1856             : void gpgrt_set_fixed_string_mapper (const char *(*f)(const char*));
    1857             : 
    1858             : 
    1859             : 
    1860             : #ifdef __cplusplus
    1861             : }
    1862             : #endif
    1863             : #endif  /* GPGRT_H */
    1864             : #endif  /* GPG_ERROR_H */
    1865             : /*
    1866             : Local Variables:
    1867             : buffer-read-only: t
    1868             : End:
    1869             : */

Generated by: LCOV version 1.13