diff --git a/AUTHORS b/AUTHORS
index 6c73617..71dd5d3 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,71 +1,71 @@
 Package: libgpg-error
 Maintainer: Werner Koch <wk@gnupg.org>
 Bug reports: bug-gnupg@gnupg.org
 Mailing list: gnupg-devel@gnupg.org
 Security related bug reports: security@gnupg.org
 License (library): LGPLv2.1+
 License (manual tools): GPLv2+ with exception
 
 Libgpg-error is free software.  See the files COPYING.LIB and COPYING
 for copying conditions.  License copyright years may be listed using
 range notation, e.g., 2000-2013, indicating that every year in the
 range, inclusive, is a copyrightable year that would otherwise be
 listed individually.
 
 
 List of Copyright holders
 =========================
 
-  Copyright (C) 2001-2019 g10 Code GmbH
+  Copyright (C) 2001-2020 g10 Code GmbH
   Copyright (C) 1995-2017 Free Software Foundation, Inc.
   Copyright (C) 1998-2006, 2008-2017  Werner Koch
   Copyright (C) 2014 Jedi Lin
 
 
 Authors with a DCO
 ==================
 
 We do not collect DCOs for libgpg-error.  As a supporting library for
 GnuPG, Libgcrypt, and GPGME a DCO for any of these projects is
 sufficient.
 
 
 Translators
 ===========
 
 cs    - Petr Pisar <petr.pisar at atlas.cz>
 da    - Joe Hansen <joedalton2 at yahoo.dk>
 de    - Werner Koch <wk at gnupg.org>
 eo    - Felipe Castro <fefcas at gmail.com>
 fr    - David Prévot <david at tilapin.org>
         Stephane Roy <sroy at j2n.net>
 it    - Francesco Groccia <fgr at anche.no>
 jp    - Takeshi Hamasaki <hmatrjp at users.sourceforge.jp>
         Yasuaki Taniguchi <yasuakit at gmail.com>
 nl    - Freek de Kruijf <f.de.kruijf at gmail.com>
 pl    - Jakub Bogusz <qboosh at pld-linux.org>
 ro    - Laurentiu Buzdugan <lbuz at rolix.org>
 sv    - Daniel Nylander <po at danielnylander.se>
 uk    - Yuri Chornoivan <yurchor at ukr.net>
 vi    - Clytie Siddall <clytie at riverland.net.au>
 zh_CN - Aron Xu <happyaron.xu at gmail.com>
 
 
 More credits
 ============
 
 Robert Schiele <rschiele at uni-mannheim.de> wrote libgpg-error.spec.
 
 Thanks to Yukihiro Nakadaira for his public domain iconv
 implementation for Windows.
 
 
  Copyright 2003-2007, 2013-2017 g10 Code GmbH
 
  This file is free software; as a special exception the author gives
  unlimited permission to copy and/or distribute it, with or without
  modifications, as long as this notice is preserved.
 
  This file is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/NEWS b/NEWS
index a60af93..fc91b90 100644
--- a/NEWS
+++ b/NEWS
@@ -1,1014 +1,1026 @@
 Noteworthy changes in version 1.38 (unreleased) [C28/A28/R_]
 -----------------------------------------------
 
  * Interface changes relative to the 1.37 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gpgrt_fnameconcat                NEW.
  gpgrt_absfnameconcat             NEW.
+ gpgrt_set_confdir                NEW.
+ gpgrt_argparser                  NEW.
+ ARGPARSE_FLAG_SYS                NEW.
+ ARGPARSE_FLAG_USER               NEW.
+ ARGPARSE_FLAG_VERBOSE            NEW.
+ ARGPARSE_NO_CONFFILE             NEW.
+ ARGPARSE_CONFFILE                NEW.
+ ARGPARSE_OPT_CONFFILE            NEW.
+ ARGPARSE_conffile                NEW.
+ ARGPARSE_noconffile              NEW.
+ GPGRT_CONFDIR_USER               NEW.
+ GPGRT_CONFDIR_SYS                NEW.
 
  Release-info: https://dev.gnupg.org/T
 
 
 Noteworthy changes in version 1.37 (2020-02-07) [C28/A28/R0]
 -----------------------------------------------
 
  * Fixes a build problems when using Gawk 5.0  [#4459]
 
  * Fixes Bourne shell incompatibilities on Solaris.  [#4574]
 
  * Improves cross-comiling support.  [#4643]
 
  * On Windows strerror_s is now used to emulate strerror_r.  [#4539]
 
  * New error codes to map SQLite primary error codes.
 
  * Now uses poll(2) instead of select(2) in gpgrt_poll if possible.
 
  * Fixes a bug in gpgrt_close.  [#4698]
 
  * Fixes build problem under Cygwin.  [#4474]
 
  * Fixes a few minor portability bugs.
 
  * Interface changes relative to the 1.36 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_NO_KEYBOXD               NEW.
  GPG_ERR_KEYBOXD                  NEW.
  GPG_ERR_NO_SERVICE               NEW.
  GPG_ERR_SERVICE.                 NEW.
  GPG_ERR_SQL_OK		          NEW.
  GPG_ERR_SQL_ERROR	          NEW.
  GPG_ERR_SQL_INTERNAL	          NEW.
  GPG_ERR_SQL_PERM	          NEW.
  GPG_ERR_SQL_ABORT	          NEW.
  GPG_ERR_SQL_BUSY	          NEW.
  GPG_ERR_SQL_LOCKED	          NEW.
  GPG_ERR_SQL_NOMEM	          NEW.
  GPG_ERR_SQL_READONLY	          NEW.
  GPG_ERR_SQL_INTERRUPT	          NEW.
  GPG_ERR_SQL_IOERR	          NEW.
  GPG_ERR_SQL_CORRUPT	          NEW.
  GPG_ERR_SQL_NOTFOUND	          NEW.
  GPG_ERR_SQL_FULL	          NEW.
  GPG_ERR_SQL_CANTOPEN	          NEW.
  GPG_ERR_SQL_PROTOCOL	          NEW.
  GPG_ERR_SQL_EMPTY	          NEW.
  GPG_ERR_SQL_SCHEMA	          NEW.
  GPG_ERR_SQL_TOOBIG	          NEW.
  GPG_ERR_SQL_CONSTRAINT	          NEW.
  GPG_ERR_SQL_MISMATCH	          NEW.
  GPG_ERR_SQL_MISUSE	          NEW.
  GPG_ERR_SQL_NOLFS	          NEW.
  GPG_ERR_SQL_AUTH	          NEW.
  GPG_ERR_SQL_FORMAT	          NEW.
  GPG_ERR_SQL_RANGE	          NEW.
  GPG_ERR_SQL_NOTADB	          NEW.
  GPG_ERR_SQL_NOTICE	          NEW.
  GPG_ERR_SQL_WARNING	          NEW.
  GPG_ERR_SQL_ROW	          NEW.
  GPG_ERR_SQL_DONE	          NEW.
 
  Release-info: https://dev.gnupg.org/T4772
 
 
 Noteworthy changes in version 1.36 (2019-03-19) [C27/A27/R0]
 -----------------------------------------------
 
  * Two new error codes to better support PIV cards.
 
  * Support armv7a-unknown-linux-gnueabihf.
 
  * Increased estream buffer sizes for Windows.
 
  * Interface changes relative to the 1.34 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_NO_AUTH                  NEW.
  GPG_ERR_BAD_AUTH                 NEW.
 
  Release-info: https://dev.gnupg.org/T4413
 
 
 Noteworthy changes in version 1.35 (2019-01-28) [C26/A26/R1]
 -----------------------------------------------
 
  * Distribute the correct gpgrt-config.
 
 
 Noteworthy changes in version 1.34 (2019-01-16) [C26/A26/R0]
 -----------------------------------------------
 
  * Support for riscv32.
 
  * New API to allow emergency cleanup after internal fatal errors.
 
  * Minor bug and portability fixes. [#4286,#4298
 
  * Interface changes relative to the 1.33 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gpgrt_abort                     NEW.
  gpgrt_add_emergency_cleanup     NEW.
 
  Release-info: https://dev.gnupg.org/T4296
 
 
 Noteworthy changes in version 1.33 (2018-12-07) [C25/A25/R0]
 -----------------------------------------------
 
  * New unified config script gpgrt-config which can now be used by all
    GnuPG related packages.
 
  * Support for ARC and arm64ilp32.
 
  * The log functions now sanitize strings printed with the "%s" format
    specifier.  All control characters are C-escaped in the output.
    Users of that function may want to remove their own escaping to
    avoid doubling of backslashes.
 
  * New fprintf style function to apply a custom filter for string
    arguments.
 
  * New function to compare version strings.
 
  * Interface changes relative to the 1.28 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gpgrt_cmp_version               New.
  gpgrt_string_filter_t           New.
  gpgrt_fprintf_sf                New.
  gpgrt_fprintf_sf_unlocked       New.
  gpgrt_ftruncate                 New but limited functionality.
  gpgrt_w32_override_locale       New.
 
  Release-info: https://dev.gnupg.org/T4205
 
 
 Noteworthy changes in version 1.32 (2018-07-12) [C24/A24/R3]
 -----------------------------------------------
 
  * Fixes a problem with gpgrt_fflush and gpgrt_fopencookie.  [#4069]
 
  * Fixes a problem with the C11 header stdnoreturn.h.  [#4002]
 
  * The yat2m tool can now also be build on Windows.
 
  * Updates translations for Spanish, Russian and Ukrainian.
 
 
 Noteworthy changes in version 1.31 (2018-05-02) [C24/A24/R2]
 -----------------------------------------------
 
  * Fixes another problem with gpgrt_poll under Windows.  [#3937]
 
  * New translation for Spanish.
 
 
 Noteworthy changes in version 1.30 (2018-04-30) [C24/A24/R1]
 -----------------------------------------------
 
  * Fixes a hang on Windows when using gpgrt_poll under nPth.
 
  * Build fix for Solaris.  [#3869]
 
 
 Noteworthy changes in version 1.29 (2018-04-11) [C24/A24/R0]
 -----------------------------------------------
 
  * The yat2m tool is during cross-compile now also installed on the
    host platform.
 
  * New option parser and associated functions similar to the one used
    by GnuPG.
 
  * New Base-64 encoder.
 
  * Fixes regression in 1.28 for arm64 and w64 builds.
 
  * Interface changes relative to the 1.28 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gpgrt_argparse                  New.
  gpgrt_usage                     New.
  gpgrt_strusage                  New.
  gpgrt_set_strusage              New.
  gpgrt_set_usage_outfnc          New.
  gpgrt_set_fixed_string_mapper   New.
  GPGRT_ENABLE_ARGPARSE_MACROS    New macro.
  gpgrt_b64enc_start              New.
  gpgrt_b64enc_write              New.
  gpgrt_b64enc_finish             New.
 
 
 Noteworthy changes in version 1.28 (2018-03-13) [C23/A23/R0]
 -----------------------------------------------
 
  * The formerly internal yat2m tool is now installed for a native
    build.
 
  * The new files gpgrt.m4 and gpgrt-config are now installed.  They
    can be used instead of gpg-error.m4 and gpg-error-config.
 
  * New logging functions similar to those used by GnuPG.
 
  * New helper functions for platform abstraction.
 
  * Interface changes relative to the 1.27 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gpgrt_get_errorcount            New API.
  gpgrt_inc_errorcount            New API.
  gpgrt_log_set_sink              New API.
  gpgrt_log_set_socket_dir_cb     New API.
  gpgrt_log_set_pid_suffix_cb     New API.
  gpgrt_log_set_prefix            New API.
  gpgrt_log_get_prefix            New API.
  gpgrt_log_test_fd               New API.
  gpgrt_log_get_fd                New API.
  gpgrt_log_get_stream            New API.
  gpgrt_log                       New API.
  gpgrt_logv                      New API.
  gpgrt_logv_prefix               New API.
  gpgrt_log_string                New API.
  gpgrt_log_info                  New API.
  gpgrt_log_error                 New API.
  gpgrt_log_fatal                 New API.
  gpgrt_log_bug                   New API.
  gpgrt_log_debug                 New API.
  gpgrt_log_debug_string          New API.
  gpgrt_log_printf                New API.
  gpgrt_log_flush                 New API.
  gpgrt_log_printhex              New API.
  gpgrt_log_clock                 New API.
  gpgrt_assert                    New macro.
  _gpgrt_log_assert               New internal API.
  GPGRT_LOGLVL_BEGIN              New const.
  GPGRT_LOGLVL_CONT               New const.
  GPGRT_LOGLVL_INFO               New const.
  GPGRT_LOGLVL_WARN               New const.
  GPGRT_LOGLVL_ERROR              New const.
  GPGRT_LOGLVL_FATAL              New const.
  GPGRT_LOGLVL_BUG                New const.
  GPGRT_LOGLVL_DEBUG              New const.
  gpgrt_realloc                   New API.
  gpgrt_malloc                    New API.
  gpgrt_calloc                    New API.
  gpgrt_strdup                    New API.
  gpgrt_strconcat                 New API.
  gpgrt_w32_reg_query_string      New API.
  gpgrt_getenv                    New API.
  gpgrt_setenv                    New API.
  gpgrt_mkdir                     New API.
  gpgrt_chdir                     New API.
  gpgrt_getcwd                    New API.
 
 
 Noteworthy changes in version 1.27 (2017-02-28) [C22/A22/R0]
 -----------------------------------------------
 
  * Added a Base64 decoder.
 
  * Added support for the sh3 architecture.
 
  * Added header gpgrt.h as an alias for gpg-error.h.
 
  * Fixed macro GPGRT_GCC_VERSION.
 
  * Fixed a race in non-blocking I/O on Windows.
 
  * Interface changes relative to the 1.26 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gpgrt_b64state_t                 NEW type.
  gpgrt_b64dec_start               NEW.
  gpgrt_b64dec_proc                NEW.
  gpgrt_b64dec_finish              NEW.
  GPG_ERR_WRONG_NAME               NEW.
  gpgrt.h                          NEW header.
 
 
 Noteworthy changes in version 1.26 (2016-12-21) [C21/A21/R0]
 -----------------------------------------------
 
  * New option --desc for gpg-error.
 
  * Interface changes relative to the 1.25 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_UNKNOWN_FLAG             NEW.
  GPG_ERR_INV_ORDER                NEW.
  GPG_ERR_ALREADY_FETCHED          NEW.
  GPG_ERR_TRY_LATER                NEW.
  GPG_ERR_SYSTEM_BUG               NEW.
  GPG_ERR_DNS_UNKNOWN	          NEW.
  GPG_ERR_DNS_SECTION	          NEW.
  GPG_ERR_DNS_ADDRESS	          NEW.
  GPG_ERR_DNS_NO_QUERY	          NEW.
  GPG_ERR_DNS_NO_ANSWER	          NEW.
  GPG_ERR_DNS_CLOSED	          NEW.
  GPG_ERR_DNS_VERIFY	          NEW.
  GPG_ERR_DNS_TIMEOUT	          NEW.
 
 
 Noteworthy changes in version 1.25 (2016-11-14) [C20/A20/R0]
 -----------------------------------------------
 
  * New interface gpgrt_get_syscall_clamp to allow libaries to make use
    of Libgpg-error's system call wrapper functions.
 
  * gpgrt_poll does now work under Windows.
 
  * Fixed bug in the locking code when used with the nPth threading
    library.
 
  * Added support for {i686,x86_64}-apple-darwin.
 
  * Added new error codes.
 
  * Interface changes relative to the 1.23 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gpgrt_get_syscall_clamp          NEW.
  GPG_ERR_ENGINE_TOO_OLD	          NEW.
  GPG_ERR_WINDOW_TOO_SMALL         NEW.
  GPG_ERR_WINDOW_TOO_LARGE         NEW.
  GPG_ERR_MISSING_ENVVAR	          NEW.
  GPG_ERR_USER_ID_EXISTS           NEW.
  GPG_ERR_NAME_EXISTS              NEW.
  GPG_ERR_DUP_NAME                 NEW.
  GPG_ERR_TOO_OLD                  NEW.
  GPG_ERR_TOO_YOUNG                NEW.
 
 
 Noteworthy changes in version 1.24 (2016-07-14) [C19/A19/R1]
 -----------------------------------------------
 
  * Fixes a bug in es_fclose_snatch when used used after es_fseek.
 
  * Fixes building without thread support.
 
  * New configure option --disable-tests.
 
 
 Noteworthy changes in version 1.23 (2016-06-15) [C19/A19/R0]
 -----------------------------------------------
 
  * Fixes an assertion failure due to es_flush on read/write streams.
 
  * Fixes a bug with a too short memory limit is es_fopenmen.
 
  * Cross-build support for powerpc-unknown-linux-gnuspe and
    tilegx-unknown-linux-gnu architectures.
 
  * Interface changes relative to the 1.22 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_SUBKEYS_EXP_OR_REV       NEW.
 
 
 Noteworthy changes in version 1.22 (2016-04-25) [C18/A18/R0]
 -----------------------------------------------
 
  * New functions and macros to to provide iconv(3) on Windows.
 
  * Support for LeakSanitizer with the gpgrt_annotate_leaked_object
    inline function.
 
  * Interface changes relative to the 1.21 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_DB_CORRUPTED             NEW.
  gpgrt_annotate_leaked_object     NEW inline func.
  GPGRT_ENABLE_W32_ICONV_MACROS    NEW.
  gpgrt_w32_iconv_open             NEW.
  gpgrt_w32_iconv_close            NEW.
  gpgrt_w32_iconv                  NEW.
 
 
 Noteworthy changes in version 1.21 (2015-12-12) [C17/A17/R0]
 -----------------------------------------------
 
  * New functions gpgrt_poll and gpgrt_set_nonblock.  For now only
    pipes and sockets on Unix are supported.
 
  * Fixes gettext output encoding problems on Windows.
 
  * Interface changes relative to the 1.20 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gpgrt_set_nonblock               NEW.
  gpgrt_get_nonblock               NEW.
  gpgrt_poll                       NEW.
  gpgrt_poll_t                     NEW type.
  es_poll_t                        NEW type.
  es_set_nonblock                  NEW macro.
  es_get_nonblock                  NEW macro.
  es_poll                          NEW macro.
  GPG_ERR_TRUE                     NEW.
  GPG_ERR_FALSE                    NEW.
  GPG_ERR_NO_NAME                  NEW.
  GPG_ERR_NO_KEY                   NEW.
  GPG_ERR_SERVER_FAILED            NEW.
 
 
 Noteworthy changes in version 1.20 (2015-08-26) [C16/A16/R0]
 -----------------------------------------------
 
  * New macros for GCC attributes.
 
  * Make es_set_binary actually work for Windows.
 
  * Allow building without thread support.
 
  * Build without a build timestamp by default.
 
  * Interface changes relative to the 1.19 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPGRT_VERSION                    NEW macro.
  GPGRT_VERSION_NUMBER             NEW macro.
  GPGRT_INLINE                     NEW macro.
  GPGRT_GCC_VERSION                NEW macro.
  GPGRT_ATTR_NORETURN              NEW macro.
  GPGRT_ATTR_PRINTF                NEW macro.
  GPGRT_ATTR_NR_PRINTF             NEW macro.
  GPGRT_ATTR_FORMAT_ARG            NEW macro.
  GPGRT_ATTR_SENTINEL              NEW macro.
  GPGRT_ATTR_USED                  NEW macro.
  GPGRT_ATTR_UNUSED                NEW macro.
  GPGRT_ATTR_DEPRECATED            NEW macro.
  GPGRT_ATTR_PURE                  NEW macro.
  GPGRT_ATTR_MALLOC                NEW macro.
  GPGRT_HAVE_MACRO_FUNCTION        NEW macro.
  GPGRT_HAVE_PRAGMA_GCC_PUSH       NEW macro.
 
 
 Noteworthy changes in version 1.19 (2015-04-10) [C15/A15/R0]
 -----------------------------------------------
 
  * New set of error codes for use with LDAP.
 
  * New options --help and --defines for gpg-error.
 
  * Allow building with gcc 5.
 
  * Interface changes relative to the 1.18 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_LDAP_*                   NEW.
 
 
 Noteworthy changes in version 1.18 (2015-01-26) [C14/A14/R0]
 -----------------------------------------------
 
  * New translations for Hungarian, Portuguese, Russian, and
    traditional Chinese.  Updated other translations.
 
  * New error codes.
 
  * Interface changes relative to the 1.17 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_FORBIDDEN                NEW.
  GPG_ERR_OBJ_TERM_STATE           NEW.
  GPG_ERR_REQUEST_TOO_SHORT        NEW.
  GPG_ERR_REQUEST_TOO_LONG         NEW.
  GPG_ERR_LEGACY_KEY               NEW.
 
 
 Noteworthy changes in version 1.17 (2014-10-15) [C13/A13/R0]
 -----------------------------------------------
 
  * New error codes for TLS protocol libraries.
 
  * New configure option --enable-build-timestamp.
 
  * New man page for gpg-error-config.
 
  * Interface changes relative to the 1.16 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_SOURCE_TLS               NEW.
  GPG_ERR_NO_CERT_CHAIN            NEW.
  GPG_ERR_CERT_TOO_LARGE	          NEW.
  GPG_ERR_INV_RECORD               NEW.
  GPG_ERR_BAD_MAC	          NEW.
  GPG_ERR_UNEXPECTED_MSG           NEW.
  GPG_ERR_COMPR_FAILED             NEW.
  GPG_ERR_WOULD_WRAP               NEW.
  GPG_ERR_FATAL_ALERT              NEW.
  GPG_ERR_NO_CIPHER                NEW.
  GPG_ERR_MISSING_CLIENT_CERT      NEW.
  GPG_ERR_CLOSE_NOTIFY             NEW.
  GPG_ERR_TICKET_EXPIRED           NEW.
  GPG_ERR_BAD_TICKET               NEW.
  GPG_ERR_UNKNOWN_IDENTITY         NEW.
  GPG_ERR_BAD_HS_CERT              NEW.
  GPG_ERR_BAD_HS_CERT_REQ          NEW.
  GPG_ERR_BAD_HS_CERT_VER          NEW.
  GPG_ERR_BAD_HS_CHANGE_CIPHER     NEW.
  GPG_ERR_BAD_HS_CLIENT_HELLO      NEW.
  GPG_ERR_BAD_HS_SERVER_HELLO      NEW.
  GPG_ERR_BAD_HS_SERVER_HELLO_DONE NEW.
  GPG_ERR_BAD_HS_FINISHED          NEW.
  GPG_ERR_BAD_HS_SERVER_KEX        NEW.
  GPG_ERR_BAD_HS_CLIENT_KEX        NEW.
  GPG_ERR_BOGUS_STRING             NEW.
  gpgrt_pending                    NEW.
  gpgrt_pending_unlocked           NEW.
 
 
 Noteworthy changes in version 1.16 (2014-09-18) [C12/A12/R2]
 -----------------------------------------------
 
  * Support building for iOS.
 
  * Fixed a prototype mismatch.
 
  * Fix es_fclose for streams opened with "samethread".
 
 
 Noteworthy changes in version 1.15 (2014-09-11) [C12/A12/R1]
 -----------------------------------------------
 
  * This releases fixes problems with the use of off_t and ssize_t by
    the estream functions introduced with 1.14.  Although this is
    technically an ABI break on some platforms, we take this as a
    simple bug fix for 1.14.  The new functions are very unlikely in
    use by any code and thus no breakage should happen.  The 1.14
    tarball will be removed from the archive.
 
  * Add type gpgrt_off_t which is guaranteed to be 64 bit.
 
  * Add type gpgrt_ssize_t to make use on Windows easier.  On Unix
    platforms this is an alias for ssize_t.
 
 
 Noteworthy changes in version 1.14 (2014-09-08) [C12/A12/R0]
 -----------------------------------------------
 
  * Added gpgrt_lock_trylock.
 
  * Added the estream library under the name gpgrt and a set of macros
    to use them with their "es_" names.
 
  * Interface changes relative to the 1.13 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_KEY_DISABLED         NEW.
  gpgrt_init                   NEW macro.
  gpgrt_check_version          NEW.
  gpgrt_lock_trylock           NEW.
  gpgrt_set_syscall_clamp      NEW.
  gpgrt_set_alloc_func         NEW.
  gpgrt_stream_t               NEW.
  gpgrt_cookie_io_functions_t  NEW.
  gpgrt_syshd_t                NEW.
  GPGRT_SYSHD_NONE             NEW.
  GPGRT_SYSHD_FD               NEW.
  GPGRT_SYSHD_SOCK             NEW.
  GPGRT_SYSHD_RVID             NEW.
  GPGRT_SYSHD_HANDLE           NEW.
  gpgrt_stdin                  NEW macro.
  gpgrt_stdout                 NEW macro.
  gpgrt_stderr                 NEW macro.
  gpgrt_fopen                  NEW.
  gpgrt_mopen                  NEW.
  gpgrt_fopenmem               NEW.
  gpgrt_fopenmem_init          NEW.
  gpgrt_fdopen                 NEW.
  gpgrt_fdopen_nc              NEW.
  gpgrt_sysopen                NEW.
  gpgrt_sysopen_nc             NEW.
  gpgrt_fpopen                 NEW.
  gpgrt_fpopen_nc              NEW.
  gpgrt_freopen                NEW.
  gpgrt_fopencookie            NEW.
  gpgrt_fclose                 NEW.
  gpgrt_fclose_snatch          NEW.
  gpgrt_onclose                NEW.
  gpgrt_fileno                 NEW.
  gpgrt_fileno_unlocked        NEW.
  gpgrt_syshd                  NEW.
  gpgrt_syshd_unlocked         NEW.
  gpgrt_flockfile              NEW.
  gpgrt_ftrylockfile           NEW.
  gpgrt_funlockfile            NEW.
  gpgrt_feof                   NEW.
  gpgrt_feof_unlocked          NEW.
  gpgrt_ferror                 NEW.
  gpgrt_ferror_unlocked        NEW.
  gpgrt_clearerr               NEW.
  gpgrt_clearerr_unlocked      NEW.
  gpgrt_fflush                 NEW.
  gpgrt_fseek                  NEW.
  gpgrt_fseeko                 NEW.
  gpgrt_ftell                  NEW.
  gpgrt_ftello                 NEW.
  gpgrt_rewind                 NEW.
  gpgrt_getc                   NEW macro.
  gpgrt_getc_unlocked          NEW macro.
  gpgrt_fgetc                  NEW.
  gpgrt_fputc                  NEW.
  gpgrt_ungetc                 NEW.
  gpgrt_read                   NEW.
  gpgrt_write                  NEW.
  gpgrt_write_sanitized        NEW.
  gpgrt_write_hexstring        NEW.
  gpgrt_fread                  NEW.
  gpgrt_fwrite                 NEW.
  gpgrt_fgets                  NEW.
  gpgrt_putc                   NEW macro.
  gpgrt_putc_unlocked          NEW macro.
  gpgrt_fputs                  NEW.
  gpgrt_fputs_unlocked         NEW.
  gpgrt_getline                NEW.
  gpgrt_read_line              NEW.
  gpgrt_free                   NEW.
  gpgrt_fprintf                NEW.
  gpgrt_fprintf_unlocked       NEW.
  gpgrt_printf                 NEW.
  gpgrt_printf_unlocked        NEW.
  gpgrt_vfprintf               NEW.
  gpgrt_vfprintf_unlocked      NEW.
  gpgrt_setvbuf                NEW.
  gpgrt_setbuf                 NEW.
  gpgrt_set_binary             NEW.
  gpgrt_tmpfile                NEW.
  gpgrt_opaque_set             NEW.
  gpgrt_opaque_get             NEW.
  gpgrt_fname_set              NEW.
  gpgrt_fname_get              NEW.
  gpgrt_asprintf               NEW.
  gpgrt_vasprintf              NEW.
  gpgrt_bsprintf               NEW.
  gpgrt_vbsprintf              NEW.
  gpgrt_snprintf               NEW.
  gpgrt_vsnprintf              NEW.
 
 
 Noteworthy changes in version 1.13 (2014-04-15) [C11/A11/R0]
 -----------------------------------------------
 
  * Added a portable mutex API.
 
  * The AM_PATH_GPG_ERROR macro now defines GPG_ERROR_MT_CFLAGS and
    GPG_ERROR_MT_LIBS autoconf output variables for use by programs
    which need gpgrt based thread support.  gpg-error-config has a new
    option --mt.
 
  * Interface changes relative to the 1.12 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_KEY_ON_CARD          NEW.
  GPG_ERR_MAC_ALGO             NEW.
  GPG_ERR_INV_LOCK_OBJ         NEW.
  gpgrt_lock_t                 NEW.
  GPGRT_LOCK_INITIALIZER       NEW.
  GPGRT_LOCK_DEFINE            NEW.
  gpgrt_lock_init              NEW.
  gpgrt_lock_lock              NEW.
  gpgrt_lock_unlock            NEW.
  gpgrt_lock_destroy           NEW.
  gpgrt_yield                  NEW.
 
 
 Noteworthy changes in version 1.12 (2013-06-24)
 -----------------------------------------------
 
  * Add support for 64 bit Windows (use ./autogen.sh --build-w64).
 
  * Fixed parsing and installing of the Windows .def file.
 
  * Interface changes relative to the 1.11 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_NO_CRYPT_CTX         NEW.
  GPG_ERR_WRONG_CRYPT_CTX      NEW.
  GPG_ERR_BAD_CRYPT_CTX        NEW.
  GPG_ERR_CRYPT_CTX_CONFLICT   NEW.
  GPG_ERR_BROKEN_PUBKEY        NEW.
  GPG_ERR_BROKEN_SECKEY        NEW.
 
 
 Noteworthy changes in version 1.11 (2013-02-25)
 -----------------------------------------------
 
  * New error source GPG_ERR_SOURCE_ASSUAN for Libassuan related
    errors.
 
  * New macros GPG_ERROR_VERSION and GPG_ERROR_VERSION_NUMBER.  New
    function gpg_error_check_version.
 
  * Interface changes relative to the 1.10 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_NO_KEYSERVER          NEW.
  GPG_ERR_INV_CURVE             NEW.
  GPG_ERR_UNKNOWN_CURVE         NEW.
  GPG_ERR_DUP_KEY               NEW.
  GPG_ERR_AMBIGUOUS             NEW.
  GPG_ERR_SOURCE_ASSUAN         NEW.
  gpg_error_check_version       NEW.
  GPG_ERROR_VERSION             NEW.
  GPG_ERROR_VERSION_NUMBER      NEW.
 
 
 Noteworthy changes in version 1.10 (2010-10-26)
 -----------------------------------------------
 
  * Using a static library on W32 does now work.
 
  * Interface changes relative to the 1.9 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_NOT_INITIALIZED       NEW.
  GPG_ERR_MISSING_ISSUER_CERT   NEW.
  GPG_ERR_FULLY_CANCELED        NEW.
 
 
 Noteworthy changes in version 1.9 (2010-07-21)
 ----------------------------------------------
 
  * New function gpg_err_deinit.
 
  * Fix building of static lib under W32.
 
  * Interface changes relative to the 1.8 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_MISSING_KEY           NEW.
  GPG_ERR_TOO_MANY              NEW.
  GPG_ERR_LIMIT_REACHED         NEW.
  gpg_err_deinit                NEW.
 
 
 Noteworthy changes in version 1.8 (2010-05-06)
 ----------------------------------------------
 
  * Support for WindowsCE.
 
  * New option --list for gpg-error.
 
  * Interface changes relative to the 1.7 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_NOT_ENABLED           NEW.
  GPG_ERR_SOURCE_G13            NEW.
  GPG_ERR_NO_ENGINE             NEW.
  gpg_err_set_errno             NEW.
 
 
 Noteworthy changes in version 1.7 (2008-11-26)
 ----------------------------------------------
 
  * Minor fixes and a few new error codes.
 
  * Interface changes relative to the 1.6 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_NOT_OPERATIONAL       NEW
  GPG_ERR_NO_PASSPHRASE         NEW
  GPG_ERR_NO_PIN                NEW
 
 
 Noteworthy changes in version 1.6 (2007-10-29)
 ----------------------------------------------
 
  * Fixed a build problem under Windows.
 
  * Interface changes relative to the 1.4 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_UNFINISHED            NEW
  GPG_ERR_SOURCE_GPA            NEW
  GPG_ERR_SOURCE_KLEO           NEW
 
 
 Noteworthy changes in version 1.5 (2006-11-30)
 ----------------------------------------------
 
  * Minor build system fixes.
 
  * Updated gettext.  Removed included gettext copy.
 
  * gpg-error has a new option --version.
 
 
 Noteworthy changes in version 1.4 (2006-09-14)
 ----------------------------------------------
 
  * Support for Common Lisp is included.
 
  * New error codes for the Assuan IPC library.
 
  * New error code GPG_ERR_MISSING_ERRNO to be used in cases when a
    system accidentally does not set errno but a system error
    definitely occurred.
 
  * New error source GPG_ERR_SOURCE_ANY to allow proper use of
    libgpg-error even if a specific source is not available.
 
  * New convenience functions gpg_err_code_from_syserror and
    gpg_error_from_syserror which make sure never to return 0.
 
  * Interface changes relative to the 1.2 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gpg_err_code_from_syserror    NEW
  gpg_error_from_syserror       NEW
  GPG_ERR_SOURCE_ANY            NEW
  GPG_ERR_MISSING_ERRNO         NEW
  GPG_ERR_UNKNOWN_OPTION        NEW
  GPG_ERR_UNKNOWN_COMMAND       NEW
  GPG_ERR_ASS_GENERAL           NEW
  GPG_ERR_ASS_ACCEPT_FAILED     NEW
  GPG_ERR_ASS_CONNECT_FAILED    NEW
  GPG_ERR_ASS_INV_RESPONSE      NEW
  GPG_ERR_ASS_INV_VALUE         NEW
  GPG_ERR_ASS_INCOMPLETE_LINE   NEW
  GPG_ERR_ASS_LINE_TOO_LONG     NEW
  GPG_ERR_ASS_NESTED_COMMANDS   NEW
  GPG_ERR_ASS_NO_DATA_CB        NEW
  GPG_ERR_ASS_NO_INQUIRE_CB     NEW
  GPG_ERR_ASS_NOT_A_SERVER      NEW
  GPG_ERR_ASS_NOT_A_CLIENT      NEW
  GPG_ERR_ASS_SERVER_START      NEW
  GPG_ERR_ASS_READ_ERROR        NEW
  GPG_ERR_ASS_WRITE_ERROR       NEW
  GPG_ERR_ASS_TOO_MUCH_DATA     NEW
  GPG_ERR_ASS_UNEXPECTED_CMD    NEW
  GPG_ERR_ASS_UNKNOWN_CMD       NEW
  GPG_ERR_ASS_SYNTAX            NEW
  GPG_ERR_ASS_CANCELED          NEW
  GPG_ERR_ASS_NO_INPUT          NEW
  GPG_ERR_ASS_NO_OUTPUT         NEW
  GPG_ERR_ASS_PARAMETER         NEW
  GPG_ERR_ASS_UNKNOWN_INQUIRE   NEW
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
 Noteworthy changes in version 1.3 (2006-03-14)
 ----------------------------------------------
 
  * GNU gettext is included for systems that do not provide it.
 
 
 Noteworthy changes in version 1.2 (2006-03-03)
 ----------------------------------------------
 
  * New function gpg_err_init, which binds the locale directory to
    the text domain.  This function is a constructor on GCC targets,
    so it does not need to be called explicitely.  The header file
    defines GPG_ERR_INITIALIZED in this case.  This is experimental for
    now.
 
  * "./autogen.sh --build-w32" does now also build a DLL for W32.
    Translations are not yet provided for this platform.
 
  * New error codes GPG_ERR_UNKNOWN_EXTN and GPG_ERR_UNKNOWN_CRIT_EXTN.
 
  * New error code GPG_ERR_LOCKED.
 
  * New translations included for France, Romania, and Vietnamese.
 
  * Interface changes relative to the 1.1 release:
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 GPG_ERR_UNKNOWN_EXTN		NEW
 GPG_ERR_UNKNOWN_CRIT_EXTN	NEW
 GPG_ERR_LOCKED			NEW
 gpg_err_init			NEW
 GPG_ERR_INITIALIZED		NEW
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
 Noteworthy changes in version 1.1 (2005-06-20)
 ----------------------------------------------
 
  * Bug fixes.
 
 
 Noteworthy changes in version 1.0 (2004-07-30)
 ----------------------------------------------
 
  * Ported to Solaris 2.8.
 
  * Added a new error source GPG_ERR_SOURCE_GSTI, and new error
    codes GPG_ERR_PROTOCOL_VIOLATION and GPG_ERR_INV_MAC for this
    source.
 
  * Interface changes relative to the 0.7 release:
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 GPG_ERR_SOURCE_GSTI		NEW
 GPG_ERR_PROTOCOL_VIOLATION	NEW
 GPG_ERR_INV_MAC			NEW
 GPG_ERR_INV_REQUEST             NEW
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Noteworthy changes in version 0.7 (2004-03-07)
 ----------------------------------------------
 
  * libgpg-error can be built on systems where the errno macros do not
    evaluate to plain numbers, but expressions.  If you want to
    cross-compile, you might have to set CC_FOR_BUILD, though.
 
  * A new tool gpg-error to convert error numbers into symbols into
    strings is provided.
 
  * Interface changes relative to the 0.6 release:
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 GPG_ERR_LOCALE_PROBLEM          NEW
 GPG_ERR_NOT_LOCKED              NEW
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Noteworthy changes in version 0.6 (2003-11-14)
 ----------------------------------------------
 
  * German translation included.
 
  * It is now possible to use the inline functions even for non C99
    compliant compilers by given e.g. -DGPG_ERR_INLINE=inline when
    compiling an application using this library.  Note, that gcc will
    use inline anyway.
 
  * Interface changes relative to the 0.5 release:
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 GPG_ERR_SOURCE_KSBA             NEW
 GPG_ERR_SOURCE_DIRMNGR          NEW
 GPG_ERR_TRUNCATED		NEW
 GPG_ERR_NO_ENCODING_METHOD      NEW
 GPG_ERR_NO_ENCRYPTION_SCHEME    NEW
 GPG_ERR_NO_SIGNATURE_SCHEME     NEW
 GPG_ERR_INV_ATTR                NEW
 GPG_ERR_NO_VALUE                NEW
 GPG_ERR_NOT_FOUND               NEW
 GPG_ERR_VALUE_NOT_FOUND         NEW
 GPG_ERR_SYNTAX                  NEW
 GPG_ERR_INV_CRL                 NEW
 GPG_ERR_BAD_BER                 NEW
 GPG_ERR_INV_BER                 NEW
 GPG_ERR_ELEMENT_NOT_FOUND       NEW
 GPG_ERR_IDENTIFIER_NOT_FOUND    NEW
 GPG_ERR_INV_TAG                 NEW
 GPG_ERR_INV_LENGTH              NEW
 GPG_ERR_INV_KEYINFO             NEW
 GPG_ERR_UNEXPECTED_TAG          NEW
 GPG_ERR_NOT_DER_ENCODED,        NEW
 GPG_ERR_NO_CMS_OBJ              NEW
 GPG_ERR_INV_CMS_OBJ             NEW
 GPG_ERR_UNKNOWN_CMS_OBJ,        NEW
 GPG_ERR_UNSUPPORTED_CMS_OBJ     NEW
 GPG_ERR_UNSUPPORTED_ENCODING,   NEW
 GPG_ERR_UNSUPPORTED_CMS_VERSION NEW
 GPG_ERR_UNKNOWN_ALGORITHM       NEW
 GPG_ERR_ENCODING_PROBLEM        NEW
 GPG_ERR_INV_STATE               NEW
 GPG_ERR_DUP_VALUE,              NEW
 GPG_ERR_MISSING_ACTION          NEW
 GPG_ERR_MODULE_NOT_FOUND        NEW
 GPG_ERR_INV_OID_STRING          NEW
 GPG_ERR_INV_TIME                NEW
 GPG_ERR_INV_CRL_OBJ             NEW
 GPG_ERR_UNSUPPORTED_CRL_VERSION NEW
 GPG_ERR_INV_CERT_OBJ            NEW
 GPG_ERR_UNKNOWN_NAME            NEW
 GPG_ERR_BUFFER_TOO_SHORT.       NEW
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Noteworthy changes in version 0.5 (2003-10-06)
 ----------------------------------------------
 
  * New thread safe interface gpg_strerror_r.
 
  * New error code GPG_ERR_PIN_NOT_SYNCED has been added.
 
  * Interface changes relative to the 0.4 release:
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 gpg_strerror_r			NEW
 GPG_ERR_PIN_NOT_SYNCED		NEW
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
 Noteworthy changes in version 0.4 (2003-09-03)
 ----------------------------------------------
 
  * Fixed another bug that prevented that system errors were created
    correctly in the first place.
 
  * Use inline in public header file only on C99 compilers.
 
 
 Noteworthy changes in version 0.3 (2003-07-31)
 ----------------------------------------------
 
  * Fixed bug that prevented that system errors were mapped to error
    strings correctly.
 
 
 Noteworthy changes in version 0.2 (2003-07-30)
 ----------------------------------------------
 
  * Value of the error code GPG_ERR_CANCELED was fixed.
 
  * New error codes GPG_ERR_WRONG_CARD, GPG_ERR_HARDWARE,
    GPG_ERR_PIN_BLOCKED and GPG_ERR_USE_CONDITIONS have been added.
 
  * The header file has been made C++ clean.
 
  * AM_PATH_GPG_ERR has been fixed to work without explicit version
    number.
 
  * The header file now uses inline instead __inline__ for non-GNU
    compilers.
 
 
 Noteworthy changes in version 0.1 (2003-06-06)
 ----------------------------------------------
 
  * Initial release.
 
 
  Copyright 2003, 2004, 2005, 2010 g10 Code GmbH
 
  This file is free software; as a special exception the author gives
  unlimited permission to copy and/or distribute it, with or without
  modifications, as long as this notice is preserved.
 
  This file is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/configure.ac b/configure.ac
index ceace2d..bfebf37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,733 +1,733 @@
 # configure.ac for libgpg-error
-# Copyright (C) 2003, 2004, 2006, 2010, 2013-2017 g10 Code GmbH
+# Copyright (C) 2003, 2004, 2006, 2010, 2013-2020 g10 Code GmbH
 #
 # This file is part of libgpg-error.
 #
 # libgpg-error is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as
 # published by the Free Software Foundation; either version 2.1 of the
 # License, or (at your option) any later version.
 #
 # libgpg-error is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <https://www.gnu.org/licenses/>.
 # SPDX-License-Identifier: LGPL-2.1+
 
 # (Process this file with autoconf to produce a configure script.)
 # The following lines are used by ./autogen.sh.
 AC_PREREQ(2.59)
 min_automake_version="1.14"
 
 # To build a release you need to create a tag with the version number
 # (git tag -s libgpg-error-n.m) and run "./autogen.sh --force".
 # Please bump the version number immediately after the release, do
 # another commit, and a push so that the git magic is able to work.
 # See below for the LT versions.
 m4_define([mym4_package],[libgpg-error])
 m4_define([mym4_major], [1])
 m4_define([mym4_minor], [38])
 
 # Below is m4 magic to extract and compute the revision number, the
 # decimalized short revision number, a beta version string, and a flag
 # indicating a development version (mym4_isgit). Note that the m4
 # processing is done by autoconf and not during the configure run.
 m4_define([mym4_verslist], m4_split(m4_esyscmd([./autogen.sh --find-version] \
                            mym4_package mym4_major mym4_minor),[:]))
 m4_define([mym4_isbeta],       m4_argn(2, mym4_verslist))
 m4_define([mym4_version],      m4_argn(4, mym4_verslist))
 m4_define([mym4_revision],     m4_argn(7, mym4_verslist))
 m4_define([mym4_revision_dec], m4_argn(8, mym4_verslist))
 m4_esyscmd([echo ]mym4_version[>VERSION])
 AC_INIT([mym4_package],[mym4_version], [https://bugs.gnupg.org])
 # LT Version numbers, remember to change them just *before* a release.
 #   (Code changed:			REVISION++)
 #   (Interfaces added/removed/changed:	CURRENT++, REVISION=0)
 #   (Interfaces added:			AGE++)
 #   (Interfaces removed:		AGE=0)
 # Note that added error codes don't constitute an interface change.
 LIBGPG_ERROR_LT_CURRENT=28
 LIBGPG_ERROR_LT_AGE=28
 LIBGPG_ERROR_LT_REVISION=0
 ################################################
 
 AC_SUBST(LIBGPG_ERROR_LT_CURRENT)
 AC_SUBST(LIBGPG_ERROR_LT_AGE)
 AC_SUBST(LIBGPG_ERROR_LT_REVISION)
 
 VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x00" mym4_major mym4_minor)
 AC_SUBST(VERSION_NUMBER)
 
 AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE([serial-tests dist-bzip2])
 AM_MAINTAINER_MODE
 AC_CONFIG_SRCDIR([src/err-sources.h.in])
 AC_CONFIG_HEADER([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 AM_SILENT_RULES
 
 # We need to know about the host architecture to avoid spurious
 # warnings.
 AC_CANONICAL_HOST
 AB_INIT
 
 # Checks for programs.
 AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_CPP
 AC_PROG_AWK
 AC_CHECK_TOOL(AR, ar, :)
 AC_GNU_SOURCE
 
 # Taken from mpfr-4.0.1, then modified for LDADD_FOR_TESTS_KLUDGE
 dnl Under Linux, make sure that the old dtags are used if LD_LIBRARY_PATH
 dnl is defined. The issue is that with the new dtags, LD_LIBRARY_PATH has
 dnl the precedence over the run path, so that if a compatible MPFR library
 dnl is installed in some directory from $LD_LIBRARY_PATH, then the tested
 dnl MPFR library will be this library instead of the MPFR library from the
 dnl build tree. Other OS with the same issue might be added later.
 dnl
 dnl References:
 dnl   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859732
 dnl   http://lists.gnu.org/archive/html/libtool/2017-05/msg00000.html
 dnl
 dnl We need to check whether --disable-new-dtags is supported as alternate
 dnl linkers may be used (e.g., with tcc: CC=tcc LD=tcc).
 dnl
 case $host in
   *-*-linux*)
     if test -n "$LD_LIBRARY_PATH"; then
       saved_LDFLAGS="$LDFLAGS"
       LDADD_FOR_TESTS_KLUDGE="-Wl,--disable-new-dtags"
       LDFLAGS="$LDFLAGS $LDADD_FOR_TESTS_KLUDGE"
       AC_MSG_CHECKING(whether --disable-new-dtags is supported by the linker)
       AC_LINK_IFELSE([AC_LANG_SOURCE([[
 int main (void) { return 0; }
       ]])],
       [AC_MSG_RESULT(yes (use it since LD_LIBRARY_PATH is set))],
       [AC_MSG_RESULT(no)
        LDADD_FOR_TESTS_KLUDGE=""
       ])
       LDFLAGS="$saved_LDFLAGS"
     fi
     ;;
 esac
 AC_SUBST([LDADD_FOR_TESTS_KLUDGE])
 
 # Set some variables depending on the platform for later use.
 have_w32_system=no
 have_w64_system=no
 have_w32ce_system=no
 case "${host}" in
     x86_64-*mingw32*)
         have_w32_system=yes
         have_w64_system=yes
         ;;
     *-mingw32ce*)
         have_w32_system=yes
         have_w32ce_system=yes
         ;;
     *-mingw32*)
         have_w32_system=yes
         ;;
     *-apple-darwin*)
         # This is the equivalent of the _GNU_SOURCE feature-test-macro
         # on GNU libc systems.
         AC_DEFINE(_DARWIN_C_SOURCE, 900000L,
                   Expose all libc features (__DARWIN_C_FULL).)
         ;;
     *)
        ;;
 esac
 
 
 if test "$have_w32_system" != yes; then
   gl_THREADLIB_EARLY
 fi
 
 # We build libgpg-error with large file support so that we have a 64
 # bit off_t.  Our external interface uses the gpgrt_off_t which is
 # anyway specified as 64 bit.  Thus the same libgpg-error can be used
 # by software which is not build with large file support.
 AC_SYS_LARGEFILE
 
 
 LT_PREREQ([2.2.6])
 LT_INIT([win32-dll disable-static])
 LT_LANG([Windows Resource])
 
 
 # We need to compile and run a program on the build machine.
 AX_CC_FOR_BUILD
 
 AH_BOTTOM([
 /* Force using of NLS for W32 even if no libintl has been found.  This is
    okay because we have our own gettext implementation for W32.  */
 #if defined(HAVE_W32_SYSTEM) && !defined(ENABLE_NLS)
 #define ENABLE_NLS 1
 #endif
 
 /* Connect the generic estream-printf.c to our framework.  */
 #define _ESTREAM_PRINTF_REALLOC _gpgrt_realloc
 #define _ESTREAM_PRINTF_EXTRA_INCLUDE "gpgrt-int.h"
 
 /* For building we need to define these macro.  */
 #define GPG_ERR_ENABLE_GETTEXT_MACROS 1
 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
 #define GPGRT_ENABLE_ES_MACROS 1
 #define GPGRT_ENABLE_LOG_MACROS 1
 #define GPGRT_ENABLE_ARGPARSE_MACROS 1
 ])
 
 
 # Note, that autogen.sh greps for the next line.
 AM_GNU_GETTEXT_VERSION([0.19.3])
 AM_GNU_GETTEXT([external])
 
 # Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS([stdlib.h locale.h stdint.h sys/select.h sys/time.h \
                   signal.h poll.h pwd.h])
 
 AC_FUNC_STRERROR_R
 case "${host_os}" in
      mingw32*)
      INSTALLSHELLPATH=/bin/sh
      AC_CHECK_FUNC([strerror_s])
      ;;
      solaris*)
      INSTALLSHELLPATH=/usr/xpg4/bin/sh
      # All versions of Solaris from 2.4 have a thread-safe strerror().
      # Since Solaris 10, in addition strerror_r() exists.
      ;;
      *)
      INSTALLSHELLPATH=/bin/sh
      AC_CHECK_FUNC([strerror_r], [],
 AC_MSG_WARN([[Without strerror_r, gpg_strerror_r might not be thread-safe]]))
      ;;
 esac
 AC_SUBST(INSTALLSHELLPATH)
 
 AC_FUNC_FORK
 AC_CHECK_FUNCS([flockfile vasprintf mmap rand strlwr stpcpy setenv stat \
                 getrlimit getpwnam getpwuid getpwnam_r getpwuid_r ])
 
 
 #
 # Checks for typedefs, structures, and compiler characteristics.
 #
 AC_C_CONST
 
 AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(long long)
 AC_HEADER_TIME
 AC_CHECK_SIZEOF(time_t,,[[
 #include <stdio.h>
 #if TIME_WITH_SYS_TIME
 # include <sys/time.h>
 # include <time.h>
 #else
 # if HAVE_SYS_TIME_H
 #  include <sys/time.h>
 # else
 #  include <time.h>
 # endif
 #endif
 ]])
 
 GNUPG_FUNC_MKDIR_TAKES_ONE_ARG
 
 
 # Find a 64 bit integer type to be used instead of off_t.  We prefer
 # the standard integer types over int64_t and finally try long long.
 if test "$ac_cv_sizeof_int" = "8"; then
    replacement_for_off_t="int"
 elif test "$ac_cv_sizeof_long" = "8"; then
    replacement_for_off_t="long"
 elif test "$ac_cv_header_stdint_h" = yes; then
    replacement_for_off_t="int64_t"
 elif test "$ac_cv_sizeof_long_long" = "8"; then
    replacement_for_off_t="long long"
 else
    AC_MSG_ERROR([[
 ***
 *** No 64 bit signed integer type found.  Can't build this library.
 ***]])
 fi
 AC_DEFINE_UNQUOTED(REPLACEMENT_FOR_OFF_T, "$replacement_for_off_t",
                    [Used by mkheader to insert the replacement type.])
 
 
 #
 # Setup gcc specific options
 #
 AC_MSG_NOTICE([checking for cc features])
 if test "$GCC" = yes; then
     # Check whether gcc does not emit a diagnostic for unknown -Wno-*
     # options.  This is the case for gcc >= 4.6
     AC_MSG_CHECKING([if gcc ignores unknown -Wno-* options])
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6 )
 #kickerror
 #endif]],[])],[_gcc_silent_wno=yes],[_gcc_silent_wno=no])
     AC_MSG_RESULT($_gcc_silent_wno)
 
     # Note that it is okay to use CFLAGS here because these are just
     # warning options and the user should have a chance of overriding
     # them.
     if test "$USE_MAINTAINER_MODE" = "yes"; then
         M_CFLAGS="-O3 -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
         M_CFLAGS="$M_CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
         if test x"$_gcc_silent_wno" = xyes ; then
           _gcc_wopt=yes
         else
           AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
           _gcc_cflags_save=$CFLAGS
           CFLAGS="-Wno-missing-field-initializers"
           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
                             [_gcc_wopt=yes],[_gcc_wopt=no])
           AC_MSG_RESULT($_gcc_wopt)
           CFLAGS=$_gcc_cflags_save;
         fi
         if test x"$_gcc_wopt" = xyes ; then
           M_CFLAGS="$M_CFLAGS -W -Wno-sign-compare -Wno-missing-field-initializers"
         fi
 
         AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement])
         _gcc_cflags_save=$CFLAGS
         CFLAGS="-Wdeclaration-after-statement"
         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
         AC_MSG_RESULT($_gcc_wopt)
         CFLAGS=$_gcc_cflags_save;
         if test x"$_gcc_wopt" = xyes ; then
           M_CFLAGS="$M_CFLAGS -Wdeclaration-after-statement"
         fi
 
 	# Prepend the maintainer-cflags so that the user can override
 	# them, e.g. to override the optimization flags for debugging.
 	CFLAGS="$M_CFLAGS $CFLAGS"
     else
         CFLAGS="$CFLAGS -Wall"
     fi
 
     AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
     _gcc_cflags_save=$CFLAGS
     CFLAGS="-Wpointer-arith"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_psign=yes,_gcc_psign=no)
     AC_MSG_RESULT($_gcc_psign)
     CFLAGS=$_gcc_cflags_save;
     if test x"$_gcc_psign" = xyes ; then
        CFLAGS="$CFLAGS -Wpointer-arith"
     fi
 
     # The undocumented option -Wno-psabi suppresses the annoying
     #   "the ABI of passing union with long double has changed in GCC 4.4"
     # which is emitted in estream-printf.c but entirely irrelvant
     # because that union is local to the file.
     if test x"$_gcc_silent_wno" = xyes ; then
        CFLAGS="$CFLAGS -Wno-psabi"
     fi
 fi
 
 #
 # Check whether the compiler supports the GCC style aligned attribute
 #
 AC_CACHE_CHECK([whether the GCC style aligned attribute is supported],
        [gcry_cv_gcc_attribute_aligned],
        [gcry_cv_gcc_attribute_aligned=no
         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
           [[struct { int a; } foo __attribute__ ((aligned (16)));]])],
           [gcry_cv_gcc_attribute_aligned=yes])])
 if test "$gcry_cv_gcc_attribute_aligned" = "yes" ; then
    AC_DEFINE(HAVE_GCC_ATTRIBUTE_ALIGNED,1,
      [Defined if a GCC style "__attribute__ ((aligned (n))" is supported])
 fi
 
 #
 # Check for ELF visibility support.
 #
 AC_CACHE_CHECK(whether the visibility attribute is supported,
        gcry_cv_visibility_attribute,
        [gcry_cv_visibility_attribute=no
         AC_LANG_CONFTEST([AC_LANG_SOURCE(
           [[int foo __attribute__ ((visibility ("hidden"))) = 1;
             int bar __attribute__ ((visibility ("protected"))) = 1;
           ]])])
 
         if ${CC-cc} -Werror -S conftest.c -o conftest.s \
                   1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
             if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
                 if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
                     gcry_cv_visibility_attribute=yes
                 fi
             fi
         fi
        ])
 if test "$gcry_cv_visibility_attribute" = "yes"; then
     AC_CACHE_CHECK(for broken visibility attribute,
        gcry_cv_broken_visibility_attribute,
        [gcry_cv_broken_visibility_attribute=yes
         AC_LANG_CONFTEST([AC_LANG_SOURCE(
           [[int foo (int x);
             int bar (int x) __asm__ ("foo")
                             __attribute__ ((visibility ("hidden")));
             int bar (int x) { return x; }
           ]])])
 
         if ${CC-cc} -Werror -S conftest.c -o conftest.s \
                   1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
            if grep '\.hidden@<:@ 	_@:>@foo' conftest.s >/dev/null 2>&1;
             then
                gcry_cv_broken_visibility_attribute=no
            fi
         fi
        ])
 fi
 if test "$gcry_cv_visibility_attribute" = "yes"; then
     AC_CACHE_CHECK(for broken alias attribute,
        gcry_cv_broken_alias_attribute,
        [gcry_cv_broken_alias_attribute=yes
         AC_LANG_CONFTEST([AC_LANG_SOURCE(
           [[extern int foo (int x) __asm ("xyzzy");
             int bar (int x) { return x; }
             extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
             extern int dfoo;
             extern __typeof (dfoo) dfoo __asm ("abccb");
             int dfoo = 1;
           ]])])
 
         if ${CC-cc} -Werror -S conftest.c -o conftest.s \
                   1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
            if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
               grep 'abccb' conftest.s >/dev/null 2>&1; then
               gcry_cv_broken_alias_attribute=no
            fi
         fi
         ])
 fi
 if test "$gcry_cv_visibility_attribute" = "yes"; then
     AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
        gcry_cv_gcc_has_f_visibility,
        [gcry_cv_gcc_has_f_visibility=no
         _gcc_cflags_save=$CFLAGS
         CFLAGS="-fvisibility=hidden"
         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
                           gcry_cv_gcc_has_f_visibility=yes)
         CFLAGS=$_gcc_cflags_save;
        ])
 fi
 if test "$gcry_cv_visibility_attribute" = "yes" \
    && test "$gcry_cv_broken_visibility_attribute" != "yes" \
    && test "$gcry_cv_broken_alias_attribute" != "yes" \
    && test "$gcry_cv_gcc_has_f_visibility" = "yes"
  then
    AC_DEFINE(GPGRT_USE_VISIBILITY, 1,
              [Define to use the GNU C visibility attribute.])
    CFLAGS="$CFLAGS -fvisibility=hidden"
 fi
 
 #
 # Check whether ld supports a version script.
 # (Actually not a check but a list of systems which are known to support it.)
 #
 have_ld_version_script=no
 case "${host}" in
     *-*-linux*)
 	have_ld_version_script=yes
         ;;
     *-*-gnu*)
 	have_ld_version_script=yes
         ;;
 esac
 AC_ARG_ENABLE([ld-version-script],
               AC_HELP_STRING([--enable-ld-version-script],
                              [enable/disable use of linker version script.
                               (default is system dependent)]),
               [have_ld_version_script=$enableval],
               [ : ] )
 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
 
 
 #
 # Check for thread library.
 #
 # Windows has always thread support; thus we don't bother to test for
 # it as it may lead to false results when cross building.
 if test "$have_w32_system" = yes; then
   GPG_ERROR_CONFIG_LIBS_PRIVATE=-lws2_32
   AC_DEFINE([USE_WINDOWS_THREADS], [1])
   LIBTHREAD=
   LTLIBTHREAD=
   LIBMULTITHREAD=
   LTLIBMULTITHREAD=
   THREADLIB_CPPFLAGS=""
   AC_SUBST([LIBTHREAD])
   AC_SUBST([LTLIBTHREAD])
   AC_SUBST([LIBMULTITHREAD])
   AC_SUBST([LTLIBMULTITHREAD])
 else
   GPG_ERROR_CONFIG_LIBS_PRIVATE=""
   gl_LOCK
   if test "$gl_threads_api" = posix; then
     AC_CHECK_SIZEOF(pthread_mutex_t,,[AC_INCLUDES_DEFAULT
                                       #include <pthread.h>])
   fi
 fi
 
 # Default value for GPG_ERROR_CONFIG_LIBS
 config_libs="-lgpg-error"
 
 #
 # Check for other libraries
 #
 LIB_SCHED_YIELD=
 AC_SUBST([LIB_SCHED_YIELD])
 AC_SEARCH_LIBS([sched_yield], [rt posix4],
                [if test "$ac_cv_search_sched_yield" != "none required"; then
                   LIB_SCHED_YIELD=$ac_cv_search_sched_yield
                   config_libs="$config_libs $LIB_SCHED_YIELD"
                 fi])
 
 LIB_NETWORK=
 AC_SUBST([LIB_NETWORK])
 AC_SEARCH_LIBS([inet_addr], [nsl],
                [if test "$ac_cv_search_inet_addr" != "none required"; then
                   LIB_NETWORK=$ac_cv_search_inet_addr
                 fi])
 AC_SEARCH_LIBS([socket], [socket],
                [if test "$ac_cv_search_socket" != "none required"; then
                   LIB_NETWORK="$ac_cv_search_socket $LIB_NETWORK"
                 fi], [], [$LIB_NETWORK])
 if test "x$LIB_NETWORK" != x; then
   config_libs="$config_libs $LIB_NETWORK"
 fi
 
 # Check for optional readline support
 GNUPG_CHECK_READLINE
 
 
 #
 # Prepare building of estream
 #
 estream_INIT
 
 #
 # Substitution used for gpg-error-config
 #
 GPG_ERROR_CONFIG_LIBS="$config_libs"
 if test "x$LIBTHREAD" != x; then
   GPG_ERROR_CONFIG_LIBS="${GPG_ERROR_CONFIG_LIBS} ${LIBTHREAD}"
 fi
 if test "x$LIBMULTITHREAD" != x; then
   GPG_ERROR_CONFIG_MT_LIBS="${LIBMULTITHREAD}"
 else
   GPG_ERROR_CONFIG_MT_LIBS=""
 fi
 if test "$have_w32ce_system" = yes; then
   GPG_ERROR_CONFIG_CFLAGS="-idirafter \${includedir}/gpg-extra"
 else
   GPG_ERROR_CONFIG_CFLAGS=""
 fi
 if test "x$THREADLIB_CPPFLAGS" != x; then
   GPG_ERROR_CONFIG_MT_CFLAGS="${THREADLIB_CPPFLAGS}"
 else
   GPG_ERROR_CONFIG_MT_CFLAGS=""
 fi
 GPG_ERROR_CONFIG_HOST="$host"
 
 case "$includedir" in
   /usr/include|/include) ;;
   '${prefix}/include')
     if test "$prefix" != / -a "$prefix" != /usr; then
       if test -z "$GPG_ERROR_CONFIG_CFLAGS"; then
         GPG_ERROR_CONFIG_CFLAGS="-I$includedir"
       else
         GPG_ERROR_CONFIG_CFLAGS="-I$includedir $GPG_ERROR_CONFIG_CFLAGS"
       fi
     fi
     ;;
   *)
     if test -z "$GPG_ERROR_CONFIG_CFLAGS"; then
       GPG_ERROR_CONFIG_CFLAGS="-I$includedir"
     else
       GPG_ERROR_CONFIG_CFLAGS="-I$includedir $GPG_ERROR_CONFIG_CFLAGS"
     fi
     ;;
 esac
 case "$libdir" in
   /usr/lib|/usr/lib64|/lib|/lib64) ;;
   '${exec_prefix}/lib')
     if test "$exec_prefix" = "NONE"; then
       if test "$prefix" != / -a "$prefix" != /usr; then
         GPG_ERROR_CONFIG_LIBS="-L$libdir $GPG_ERROR_CONFIG_LIBS"
       fi
     elif test "$exec_prefix" != / -a "$exec_prefix" != /usr; then
       GPG_ERROR_CONFIG_LIBS="-L$libdir $GPG_ERROR_CONFIG_LIBS"
     fi
     ;;
   *) GPG_ERROR_CONFIG_LIBS="-L$libdir $GPG_ERROR_CONFIG_LIBS" ;;
 esac
 
 AC_SUBST(GPG_ERROR_CONFIG_LIBS)
 AC_SUBST(GPG_ERROR_CONFIG_CFLAGS)
 AC_SUBST(GPG_ERROR_CONFIG_MT_LIBS)
 AC_SUBST(GPG_ERROR_CONFIG_MT_CFLAGS)
 AC_SUBST(GPG_ERROR_CONFIG_LIBS_PRIVATE)
 AC_SUBST(GPG_ERROR_CONFIG_HOST)
 
 
 #
 # Special defines for certain platforms
 #
 force_use_syscfg=no
 if test "$have_w32_system" = yes; then
     AC_DEFINE(HAVE_W32_SYSTEM,1,[Defined if we run on a W32 API based system])
     if test "$have_w64_system" = yes; then
       AC_DEFINE(HAVE_W64_SYSTEM,1,[Defined if we run on 64 bit W32 API system])
     fi
     if test "$have_w32ce_system" = yes; then
       AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
     fi
     force_use_syscfg=yes
 fi
 if test x$cross_compiling = xyes; then
     force_use_syscfg=yes
 fi
 
 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
 AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes)
 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
 AM_CONDITIONAL(FORCE_USE_SYSCFG, test x$force_use_syscfg = xyes)
 
 AC_DEFINE_UNQUOTED(HOST_TRIPLET_STRING, "$host", [The host triplet])
 
 
 #
 # gpgrt_log_clock may require linking with extra libaries.  As long as
 # we don't have a good test for this we require the use of this
 # configure option to enabling printing of a timestamp.
 #
 AC_MSG_CHECKING([whether to enable log_clock])
 AC_ARG_ENABLE(log_clock,
               AC_HELP_STRING([--enable-log-clock],
                              [enable log_clock timestamps]),
               enable_log_clock=$enableval, enable_log_clock=no)
 AC_MSG_RESULT($enable_log_clock)
 if test "$enable_log_clock" = yes ; then
   AC_DEFINE(ENABLE_LOG_CLOCK,1,[Defined to use log_clock timestamps])
 fi
 
 #
 # For now we do not build gpgscm by default.
 # Eventually we will reverse the meaning of that option.
 #
 build_gpgscm=no
 #AC_MSG_CHECKING([whether to build gpgscm])
 #AC_ARG_ENABLE(gpgscm,
 #              AC_HELP_STRING([--enable-gpgscm],
 #                             [build the gpgscm tool]),
 #              build_gpgscm=$enableval, build_gpgscm=no)
 #AC_MSG_RESULT($build_gpgscm)
 AM_CONDITIONAL([BUILD_GPGSCM], [test "x$build_gpgscm" != xno])
 
 
 #
 # Add -Werror to CFLAGS.  This hack can be used to avoid problems with
 # misbehaving autoconf tests in case the user supplied -Werror.
 #
 AC_ARG_ENABLE(werror,
    AC_HELP_STRING([--enable-werror],
                   [append -Werror to CFLAGS]),
                   [if test $enableval = yes ; then
                       CFLAGS="$CFLAGS -Werror"
                    fi])
 
 
 #
 # Provide information about the build.
 #
 BUILD_REVISION="mym4_revision"
 AC_SUBST(BUILD_REVISION)
 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
                    [GIT commit id revision used to build this package])
 
 changequote(,)dnl
 BUILD_VERSION=`echo "$PACKAGE_VERSION"|sed 's/\([0-9.]*\).*/\1./'`
 changequote([,])dnl
 BUILD_VERSION="${BUILD_VERSION}0.mym4_revision_dec"
 BUILD_FILEVERSION=`echo "${BUILD_VERSION}" | tr . ,`
 AC_SUBST(BUILD_VERSION)
 AC_SUBST(BUILD_FILEVERSION)
 
 AC_ARG_ENABLE([build-timestamp],
   AC_HELP_STRING([--enable-build-timestamp],
                  [set an explicit build timestamp for reproducibility.
                   (default is the current time in ISO-8601 format)]),
      [if test "$enableval" = "yes"; then
         BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
       else
         BUILD_TIMESTAMP="$enableval"
       fi],
      [BUILD_TIMESTAMP="<none>"])
 AC_SUBST(BUILD_TIMESTAMP)
 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
                    [The time this package was configured for a build])
 
 
 
 AC_ARG_ENABLE(languages, AC_HELP_STRING([--disable-languages],
                         [do not build support for other languages than C]))
 AM_CONDITIONAL([LANGUAGES_SOME], [test "x$enable_languages" != xno])
 
 build_doc=yes
 AC_ARG_ENABLE([doc], AC_HELP_STRING([--disable-doc],
                                     [do not build the documentation]),
                      build_doc=$enableval, build_doc=yes)
 AM_CONDITIONAL([BUILD_DOC], [test "x$build_doc" != xno])
 
 build_tests=yes
 AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
                                     [do not build the tests]),
                      build_tests=$enableval, build_tests=yes)
 AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != xno])
 
 #
 # Substitution
 #
 AC_CONFIG_FILES([Makefile])
 AC_CONFIG_FILES([doc/Makefile po/Makefile.in m4/Makefile])
 AC_CONFIG_FILES([src/Makefile tests/Makefile])
 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpg-error.asd])
 AC_CONFIG_FILES([src/versioninfo.rc src/gpg-error.w32-manifest])
 AC_CONFIG_FILES([src/gpg-error.pc])
 AC_CONFIG_FILES([src/gpg-error-config-old:src/gpg-error-config.in], [chmod +x src/gpg-error-config-old])
 AC_CONFIG_FILES([src/gpgrt-config], [chmod +x src/gpgrt-config])
 AC_CONFIG_FILES([src/gpg-error-config-test.sh], [chmod +x src/gpg-error-config-test.sh])
 
 AC_OUTPUT
 
 tmp=
 if test "$have_w32_system" != yes; then
    if test x"$gl_use_threads" = xno; then
      tmp=" NO-THREADS"
    fi
 fi
 echo "
         $PACKAGE_NAME v$PACKAGE_VERSION has been configured as follows:
 
         Revision: mym4_revision  (mym4_revision_dec)
         Platform: $host$tmp
 "
 if test "$gcry_cv_gcc_attribute_aligned" != "yes" ; then
 cat <<G10EOF
 ***
 ***  Please note that your compiler does not support the GCC style
 ***  aligned attribute.  Using this software may evoke bus errors.
 ***
 G10EOF
 fi
diff --git a/src/argparse.c b/src/argparse.c
index fecd3b5..10e18c0 100644
--- a/src/argparse.c
+++ b/src/argparse.c
@@ -1,1593 +1,1965 @@
 /* argparse.c - Argument Parser for option handling
  * Copyright (C) 1997-2001, 2006-2008, 2013-2017 Werner Koch
  * Copyright (C) 1998-2001, 2006-2008, 2012 Free Software Foundation, Inc.
- * Copyright (C) 2015-2018 g10 Code GmbH
+ * Copyright (C) 2015-2020 g10 Code GmbH
  *
  * This file is part of Libgpg-error.
  *
  * This file is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This file is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public License
  * along with this program; if not, see <https://www.gnu.org/licenses/>.
  * SPDX-License-Identifier: LGPL-2.1-or-later
  *
  * This file was originally a part of GnuPG.
  */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
 #include <stdarg.h>
 #include <limits.h>
 #include <errno.h>
 
 #include "gpgrt-int.h"
 
+
+/* The malloced configuration directories or NULL.  */
+static struct
+{
+  char *user;
+  char *sys;
+} confdir;
+
+
 /* Special short options which are auto-inserterd.  */
 #define ARGPARSE_SHORTOPT_HELP 32768
 #define ARGPARSE_SHORTOPT_VERSION 32769
 #define ARGPARSE_SHORTOPT_WARRANTY 32770
 #define ARGPARSE_SHORTOPT_DUMP_OPTIONS 32771
 
 /* A mask for the types.  */
 #define ARGPARSE_TYPE_MASK  7  /* Mask for the type values.  */
 
+/* The states for the gpgrt_argparser machinery.  */
+enum argparser_states
+  {
+   STATE_init = 0,
+   STATE_open_sys,
+   STATE_open_user,
+   STATE_open_cmdline,
+   STATE_read_sys,
+   STATE_read_user,
+   STATE_read_cmdline,
+   STATE_finished
+  };
+
+
 /* Internal object of the public gpgrt_argparse_t object.  */
 struct _gpgrt_argparse_internal_s
 {
-  int idx;
+  int idx;   /* Note that this is saved and restored in _gpgrt_argparser. */
   int inarg;
   int stopped;
+  int explicit_confopt;        /* A conffile option has been given. */
+  char *explicit_conffile;     /* Malloced name of an explicit conffile.  */
+  unsigned int opt_flags;      /* Current option flags.  */
+  enum argparser_states state; /* of gpgrt_argparser.  */
   const char *last;
   void *aliases;
   const void *cur_alias;
   void *iio_list;
+  estream_t conffp;
+  char *confname;
   gpgrt_opt_t **opts;  /* Malloced array of pointer to user provided opts.  */
 };
 
 
 typedef struct alias_def_s *ALIAS_DEF;
 struct alias_def_s {
     ALIAS_DEF next;
     char *name;   /* malloced buffer with name, \0, value */
     const char *value; /* ptr into name */
 };
 
 
 /* Object to store the names for the --ignore-invalid-option option.
    This is a simple linked list.  */
 typedef struct iio_item_def_s *IIO_ITEM_DEF;
 struct iio_item_def_s
 {
   IIO_ITEM_DEF next;
   char name[1];      /* String with the long option name.  */
 };
 
 
 /* The almost always needed user handler for strusage.  */
 static const char *(*strusage_handler)( int ) = NULL;
 /* Optional handler to write strings.  See _gpgrt_set_usage_outfnc.  */
 static int (*custom_outfnc) (int, const char *);
 /* Optional handler to map strings.  See _gpgrt_set_fixed_string_mapper.  */
 static const char *(*fixed_string_mapper)(const char*);
 
 static int  set_opt_arg (gpgrt_argparse_t *arg, unsigned int flags, char *s);
 static void show_help (gpgrt_opt_t **opts, unsigned int flags);
 static void show_version (void);
 static int writestrings (int is_error, const char *string,
                          ...) GPGRT_ATTR_SENTINEL(0);
 static int arg_parse (gpgrt_argparse_t *arg, gpgrt_opt_t *opts);
 
 
 
 
 
 /* Return true if the native charset is utf-8.  */
 static int
 is_native_utf8 (void)
 {
   static char result;
 
   if (!result)
     {
       const char *p = _gpgrt_strusage (8);
       if (!p || !*p || !strcmp (p, "utf-8"))
         result = 1;
       result |= 128;
     }
 
   return (result & 1);
 }
 
 
 static char *
 trim_spaces (char *str)
 {
   char *string, *p, *mark;
 
   string = str;
   /* Find first non space character. */
   for (p=string; *p && isspace (*(unsigned char*)p) ; p++)
     ;
   /* Move characters. */
   for ((mark = NULL); (*string = *p); string++, p++)
     if (isspace (*(unsigned char*)p))
       {
         if (!mark)
           mark = string;
       }
     else
       mark = NULL;
   if (mark)
     *mark = '\0' ;  /* Remove trailing spaces. */
 
   return str ;
 }
 
 
 static const char *
 map_fixed_string (const char *string)
 {
   return fixed_string_mapper? fixed_string_mapper (string) : string;
 }
 
 
 /* Write STRING and all following const char * arguments either to
    stdout or, if IS_ERROR is set, to stderr.  The list of strings must
    be terminated by a NULL.  */
 static int
 writestrings (int is_error, const char *string, ...)
 {
   va_list arg_ptr;
   const char *s;
   int count = 0;
 
   if (string)
     {
       s = string;
       va_start (arg_ptr, string);
       do
         {
           if (custom_outfnc)
             custom_outfnc (is_error? 2:1, s);
           else
             fputs (s, is_error? stderr : stdout);
           count += strlen (s);
         }
       while ((s = va_arg (arg_ptr, const char *)));
       va_end (arg_ptr);
     }
   return count;
 }
 
 
 static void
 flushstrings (int is_error)
 {
   if (custom_outfnc)
     custom_outfnc (is_error? 2:1, NULL);
   else
     _gpgrt_fflush (is_error? es_stderr : es_stdout);
 }
 
 
 static void
 deinitialize (gpgrt_argparse_t *arg)
 {
   if (arg->internal)
     {
+      xfree (arg->internal->explicit_conffile);
       xfree (arg->internal->opts);
       xfree (arg->internal);
       arg->internal = NULL;
     }
 
   arg->lineno = 0;
   arg->err = 0;
 }
 
 /* Our own exit handler to clean up used memory.  */
 static void
 my_exit (gpgrt_argparse_t *arg, int code)
 {
   deinitialize (arg);
   exit (code);
 }
 
 
 static gpg_err_code_t
 initialize (gpgrt_argparse_t *arg, gpgrt_opt_t *opts, estream_t fp)
 {
   if (!arg->internal || (arg->flags & ARGPARSE_FLAG_RESET))
     {
       /* Allocate internal data.  */
       if (!arg->internal)
         {
           arg->internal = xtrymalloc (sizeof *arg->internal);
           if (!arg->internal)
             return _gpg_err_code_from_syserror ();
         }
       else if (arg->internal->opts)
         xfree (arg->internal->opts);
       arg->internal->opts = NULL;
 
       /* Initialize this instance. */
       arg->internal->idx = 0;
       arg->internal->last = NULL;
       arg->internal->inarg = 0;
       arg->internal->stopped = 0;
+      arg->internal->explicit_confopt = 0;
+      arg->internal->explicit_conffile = NULL;
+      arg->internal->opt_flags = 0;
+      arg->internal->state = STATE_init;
       arg->internal->aliases = NULL;
       arg->internal->cur_alias = NULL;
       arg->internal->iio_list = NULL;
+      arg->internal->conffp = NULL;
+      arg->internal->confname = NULL;
 
       /* Clear the copy of the option list.  */
       /* Clear the error indicator.  */
       arg->err = 0;
 
       /* Usually an option file will be parsed from the start.
        * However, we do not open the stream and thus we have no way to
        * know the current lineno.  Using this flag we can allow the
        * user to provide a lineno which we don't reset.  */
-      if (fp || !(arg->flags & ARGPARSE_FLAG_NOLINENO))
+      if (fp || arg->internal->conffp || !(arg->flags & ARGPARSE_FLAG_NOLINENO))
         arg->lineno = 0;
 
       /* Need to clear the reset request.  */
       arg->flags &= ~ARGPARSE_FLAG_RESET;
 
       /* Check initial args.  */
       if ( *arg->argc < 0 )
         _gpgrt_log_bug ("invalid argument passed to gpgrt_argparse\n");
 
     }
 
   /* Create an array with pointers to the provided list of options.
    * Keeping a copy is useful to sort that array and thus do a binary
    * search and to allow for extra space at the end to insert the
    * hidden options.  An ARGPARSE_FLAG_RESET can be used to reinit
    * this array.  */
   if (!arg->internal->opts)
     {
       static gpgrt_opt_t help_opt
         = ARGPARSE_s_n (ARGPARSE_SHORTOPT_HELP, "help", "@");
       static gpgrt_opt_t version_opt
         = ARGPARSE_s_n (ARGPARSE_SHORTOPT_VERSION, "version", "@");
       static gpgrt_opt_t warranty_opt
         = ARGPARSE_s_n (ARGPARSE_SHORTOPT_WARRANTY, "warranty", "@");
       static gpgrt_opt_t dump_options_opt
         = ARGPARSE_s_n(ARGPARSE_SHORTOPT_DUMP_OPTIONS, "dump-options", "@");
       static gpgrt_opt_t end_marker
         = ARGPARSE_end ();
       int seen_help = 0;
       int seen_version = 0;
       int seen_warranty = 0;
       int seen_dump_options = 0;
       int i;
 
       for (i=0; opts[i].short_opt; i++)
         {
           if (opts[i].long_opt)
             {
               if (!strcmp(opts[i].long_opt, help_opt.long_opt))
                 seen_help = 1;
               else if (!strcmp(opts[i].long_opt, version_opt.long_opt))
                 seen_version = 1;
               else if (!strcmp(opts[i].long_opt, warranty_opt.long_opt))
                 seen_warranty = 1;
               else if (!strcmp(opts[i].long_opt, dump_options_opt.long_opt))
                 seen_dump_options = 1;
             }
         }
       i += 4; /* The number of the above internal options.  */
       i++;    /* End of list marker.  */
       arg->internal->opts = xtrycalloc (i, sizeof *arg->internal->opts);
       if (!arg->internal->opts)
         return _gpg_err_code_from_syserror ();
       for(i=0; opts[i].short_opt; i++)
         arg->internal->opts[i] = opts + i;
       if (!seen_help)
         arg->internal->opts[i++] = &help_opt;
       if (!seen_version)
         arg->internal->opts[i++] = &version_opt;
       if (!seen_warranty)
         arg->internal->opts[i++] = &warranty_opt;
       if (!seen_dump_options)
         arg->internal->opts[i++] = &dump_options_opt;
       arg->internal->opts[i] = &end_marker;
     }
 
   if (arg->err)
     {
       /* Last option was erroneous.  */
       const char *s;
 
+      if (!fp && arg->internal->conffp)
+        fp = arg->internal->conffp;
+
       if (fp)
         {
           if ( arg->r_opt == ARGPARSE_UNEXPECTED_ARG )
             s = _("argument not expected");
           else if ( arg->r_opt == ARGPARSE_READ_ERROR )
             s = _("read error");
           else if ( arg->r_opt == ARGPARSE_KEYWORD_TOO_LONG )
             s = _("keyword too long");
           else if ( arg->r_opt == ARGPARSE_MISSING_ARG )
             s = _("missing argument");
           else if ( arg->r_opt == ARGPARSE_INVALID_ARG )
             s = _("invalid argument");
           else if ( arg->r_opt == ARGPARSE_INVALID_COMMAND )
             s = _("invalid command");
           else if ( arg->r_opt == ARGPARSE_INVALID_ALIAS )
             s = _("invalid alias definition");
           else if ( arg->r_opt == ARGPARSE_OUT_OF_CORE )
             s = _("out of core");
+          else if ( arg->r_opt == ARGPARSE_NO_CONFFILE )
+            s = NULL;  /* Error has already been printed.  */
           else
             s = _("invalid option");
-          _gpgrt_log_error ("%s:%u: %s\n",
-                            _gpgrt_fname_get (fp), arg->lineno, s);
+          if (s)
+            _gpgrt_log_error ("%s:%u: %s\n",
+                              _gpgrt_fname_get (fp), arg->lineno, s);
 	}
       else
         {
           s = arg->internal->last? arg->internal->last:"[??]";
 
           if ( arg->r_opt == ARGPARSE_MISSING_ARG )
             _gpgrt_log_error (_("missing argument for option \"%.50s\"\n"), s);
           else if ( arg->r_opt == ARGPARSE_INVALID_ARG )
             _gpgrt_log_error (_("invalid argument for option \"%.50s\"\n"), s);
           else if ( arg->r_opt == ARGPARSE_UNEXPECTED_ARG )
             _gpgrt_log_error (_("option \"%.50s\" does not expect "
                                 "an argument\n"), s);
           else if ( arg->r_opt == ARGPARSE_INVALID_COMMAND )
             _gpgrt_log_error (_("invalid command \"%.50s\"\n"), s);
           else if ( arg->r_opt == ARGPARSE_AMBIGUOUS_OPTION )
             _gpgrt_log_error (_("option \"%.50s\" is ambiguous\n"), s);
           else if ( arg->r_opt == ARGPARSE_AMBIGUOUS_COMMAND )
             _gpgrt_log_error (_("command \"%.50s\" is ambiguous\n"),s );
           else if ( arg->r_opt == ARGPARSE_OUT_OF_CORE )
-            _gpgrt_log_error ("%s\n", _("out of core\n"));
+            _gpgrt_log_error ("%s\n", _("out of core"));
+          else if ( arg->r_opt == ARGPARSE_NO_CONFFILE)
+            ;  /* Error has already been printed.  */
           else
             _gpgrt_log_error (_("invalid option \"%.50s\"\n"), s);
 	}
       if (arg->err != ARGPARSE_PRINT_WARNING)
         my_exit (arg, 2);
       arg->err = 0;
     }
 
   /* Zero out the return value union.  */
   arg->r.ret_str = NULL;
   arg->r.ret_long = 0;
 
   return 0;
 }
 
 
 static void
 store_alias( gpgrt_argparse_t *arg, char *name, char *value )
 {
     /* TODO: replace this dummy function with a rea one
      * and fix the probelms IRIX has with (ALIAS_DEV)arg..
      * used as lvalue
      */
   (void)arg;
   (void)name;
   (void)value;
 #if 0
     ALIAS_DEF a = xmalloc( sizeof *a );
     a->name = name;
     a->value = value;
     a->next = (ALIAS_DEF)arg->internal->aliases;
     (ALIAS_DEF)arg->internal->aliases = a;
 #endif
 }
 
 
 /* Return true if KEYWORD is in the ignore-invalid-option list.  */
 static int
 ignore_invalid_option_p (gpgrt_argparse_t *arg, const char *keyword)
 {
   IIO_ITEM_DEF item = arg->internal->iio_list;
 
   for (; item; item = item->next)
     if (!strcmp (item->name, keyword))
       return 1;
   return 0;
 }
 
 
 /* Add the keywords up to the next LF to the list of to be ignored
    options.  After returning FP will either be at EOF or the next
    character read wll be the first of a new line.  The function
    returns 0 on success or true on malloc failure.  */
 static int
 ignore_invalid_option_add (gpgrt_argparse_t *arg, estream_t fp)
 {
   IIO_ITEM_DEF item;
   int c;
   char name[100];
   int namelen = 0;
   int ready = 0;
   enum { skipWS, collectNAME, skipNAME, addNAME} state = skipWS;
 
   while (!ready)
     {
       c = _gpgrt_fgetc (fp);
       if (c == '\n')
         ready = 1;
       else if (c == EOF)
         {
           c = '\n';
           ready = 1;
         }
     again:
       switch (state)
         {
         case skipWS:
           if (!isascii (c) || !isspace(c))
             {
               namelen = 0;
               state = collectNAME;
               goto again;
             }
           break;
 
         case collectNAME:
           if (isspace (c))
             {
               state = addNAME;
               goto again;
             }
           else if (namelen < DIM(name)-1)
             name[namelen++] = c;
           else /* Too long.  */
             state = skipNAME;
           break;
 
         case skipNAME:
           if (isspace (c))
             {
               state = skipWS;
               goto again;
             }
           break;
 
         case addNAME:
           name[namelen] = 0;
           if (!ignore_invalid_option_p (arg, name))
             {
               item = xtrymalloc (sizeof *item + namelen);
               if (!item)
                 return 1;
               strcpy (item->name, name);
               item->next = (IIO_ITEM_DEF)arg->internal->iio_list;
               arg->internal->iio_list = item;
             }
           state = skipWS;
           goto again;
         }
     }
   return 0;
 }
 
 
 /* Clear the entire ignore-invalid-option list.  */
 static void
 ignore_invalid_option_clear (gpgrt_argparse_t *arg)
 {
   IIO_ITEM_DEF item, tmpitem;
 
   for (item = arg->internal->iio_list; item; item = tmpitem)
     {
       tmpitem = item->next;
       xfree (item);
     }
   arg->internal->iio_list = NULL;
 }
 
 
 
 /****************
  * Get options from a file.
  * Lines starting with '#' are comment lines.
  * Syntax is simply a keyword and the argument.
  * Valid keywords are all keywords from the long_opt list without
  * the leading dashes. The special keywords "help", "warranty" and "version"
  * are not valid here.
  * The special keyword "alias" may be used to store alias definitions,
  * which are later expanded like long options.
  * The option
  *   ignore-invalid-option OPTIONNAMEs
  * is recognized and updates a list of option which should be ignored if they
  * are not defined.
  * Caller must free returned strings.
  * If called with FP set to NULL command line args are parse instead.
  *
  * Q: Should we allow the syntax
  *     keyword = value
  *    and accept for boolean options a value of 1/0, yes/no or true/false?
  * Note: Abbreviation of options is here not allowed.
  */
 int
 _gpgrt_argparse (estream_t fp, gpgrt_argparse_t *arg, gpgrt_opt_t *opts_orig)
 {
   gpgrt_opt_t **opts;
   int state, i, c;
   int idx = 0;
   char keyword[100];
   char *buffer = NULL;
   size_t buflen = 0;
   int in_alias=0;
   int unread_buf[3];  /* We use an int so that we can store EOF.  */
   int unread_buf_count = 0;
 
   if (arg && !opts_orig)
     {
       deinitialize (arg);
       return 0;
     }
 
   if (!fp) /* Divert to arg_parse() in this case.  */
     return arg_parse (arg, opts_orig);
 
   if (initialize (arg, opts_orig, fp))
     return (arg->r_opt = ARGPARSE_OUT_OF_CORE);
 
   opts = arg->internal->opts;
 
   /* If the LINENO is zero we assume that we are at the start of a
    * file and we skip over a possible Byte Order Mark.  */
   if (!arg->lineno)
     {
       unread_buf[0] = _gpgrt_fgetc (fp);
       unread_buf[1] = _gpgrt_fgetc (fp);
       unread_buf[2] = _gpgrt_fgetc (fp);
       if (unread_buf[0] != 0xef
           || unread_buf[1] != 0xbb
           || unread_buf[2] != 0xbf)
         unread_buf_count = 3;
     }
 
   /* Find the next keyword.  */
   state = i = 0;
   for (;;)
     {
       if (unread_buf_count)
         c = unread_buf[3 - unread_buf_count--];
       else
         c = _gpgrt_fgetc (fp);
       if (c == '\n' || c== EOF )
         {
           if ( c != EOF )
             arg->lineno++;
           if (state == -1)
             break;
           else if (state == 2)
             {
               keyword[i] = 0;
               for (i=0; opts[i]->short_opt; i++ )
                 {
                   if (opts[i]->long_opt && !strcmp (opts[i]->long_opt, keyword))
                     break;
                 }
               idx = i;
               arg->r_opt = opts[idx]->short_opt;
               if ((opts[idx]->flags & ARGPARSE_OPT_IGNORE))
                 {
                   state = i = 0;
                   continue;
                 }
               else if (!opts[idx]->short_opt )
                 {
                   if (!strcmp (keyword, "ignore-invalid-option"))
                     {
                       /* No argument - ignore this meta option.  */
                       state = i = 0;
                       continue;
                     }
                   else if (ignore_invalid_option_p (arg, keyword))
                     {
                       /* This invalid option is in the iio list.  */
                       state = i = 0;
                       continue;
                     }
                   arg->r_opt = ((opts[idx]->flags & ARGPARSE_OPT_COMMAND)
                                 ? ARGPARSE_INVALID_COMMAND
                                 : ARGPARSE_INVALID_OPTION);
                 }
               else if (!(opts[idx]->flags & ARGPARSE_TYPE_MASK))
                 arg->r_type = 0; /* Does not take an arg. */
               else if ((opts[idx]->flags & ARGPARSE_OPT_OPTIONAL) )
                 arg->r_type = 0; /* Arg is optional.  */
               else
                 arg->r_opt = ARGPARSE_MISSING_ARG;
 
               break;
 	    }
           else if (state == 3)
             {
               /* No argument found.  */
               if (in_alias)
                 arg->r_opt = ARGPARSE_MISSING_ARG;
               else if (!(opts[idx]->flags & ARGPARSE_TYPE_MASK))
                 arg->r_type = 0; /* Does not take an arg. */
               else if ((opts[idx]->flags & ARGPARSE_OPT_OPTIONAL))
                 arg->r_type = 0; /* No optional argument. */
               else
                 arg->r_opt = ARGPARSE_MISSING_ARG;
 
               break;
 	    }
           else if (state == 4)
             {
               /* Has an argument. */
               if (in_alias)
                 {
                   if (!buffer)
                     arg->r_opt = ARGPARSE_UNEXPECTED_ARG;
                   else
                     {
                       char *p;
 
                       buffer[i] = 0;
                       p = strpbrk (buffer, " \t");
                       if (p)
                         {
                           *p++ = 0;
                           trim_spaces (p);
 			}
                       if (!p || !*p)
                         {
                           xfree (buffer);
                           arg->r_opt = ARGPARSE_INVALID_ALIAS;
                         }
                       else
                         {
                           store_alias (arg, buffer, p);
                         }
 		    }
 		}
               else if (!(opts[idx]->flags & ARGPARSE_TYPE_MASK))
                 arg->r_opt = ARGPARSE_UNEXPECTED_ARG;
               else
                 {
                   char *p;
 
                   if (!buffer)
                     {
                       keyword[i] = 0;
                       buffer = xtrystrdup (keyword);
                       if (!buffer)
                         arg->r_opt = ARGPARSE_OUT_OF_CORE;
 		    }
                   else
                     buffer[i] = 0;
 
                   if (buffer)
                     {
                       trim_spaces (buffer);
                       p = buffer;
                       if (*p == '"')
                         {
                           /* Remove quotes. */
                           p++;
                           if (*p && p[strlen(p)-1] == '\"' )
                             p[strlen(p)-1] = 0;
                         }
                       if (!set_opt_arg (arg, opts[idx]->flags, p))
                         xfree (buffer);
                       else
                         gpgrt_annotate_leaked_object (buffer);
                     }
                 }
               break;
             }
           else if (c == EOF)
             {
               ignore_invalid_option_clear (arg);
               if (_gpgrt_ferror (fp))
                 arg->r_opt = ARGPARSE_READ_ERROR;
               else
                 arg->r_opt = 0; /* EOF. */
               break;
             }
           state = 0;
           i = 0;
         }
       else if (state == -1)
         ; /* Skip. */
       else if (state == 0 && isascii (c) && isspace(c))
         ; /* Skip leading white space.  */
       else if (state == 0 && c == '#' )
         state = 1;	/* Start of a comment.  */
       else if (state == 1)
         ; /* Skip comments. */
       else if (state == 2 && isascii (c) && isspace(c))
         {
           /* Check keyword.  */
           keyword[i] = 0;
           for (i=0; opts[i]->short_opt; i++ )
             if (opts[i]->long_opt && !strcmp (opts[i]->long_opt, keyword))
               break;
           idx = i;
           arg->r_opt = opts[idx]->short_opt;
           if ((opts[idx]->flags & ARGPARSE_OPT_IGNORE))
             {
               state = 1; /* Process like a comment.  */
             }
           else if (!opts[idx]->short_opt)
             {
               if (!strcmp (keyword, "alias"))
                 {
                   in_alias = 1;
                   state = 3;
                 }
               else if (!strcmp (keyword, "ignore-invalid-option"))
                 {
                   if (ignore_invalid_option_add (arg, fp))
                     {
                       arg->r_opt = ARGPARSE_OUT_OF_CORE;
                       break;
                     }
                   state = i = 0;
                   arg->lineno++;
                 }
               else if (ignore_invalid_option_p (arg, keyword))
                 state = 1; /* Process like a comment.  */
               else
                 {
                   arg->r_opt = ((opts[idx]->flags & ARGPARSE_OPT_COMMAND)
                                 ? ARGPARSE_INVALID_COMMAND
                                 : ARGPARSE_INVALID_OPTION);
                   state = -1; /* Skip rest of line and leave.  */
                 }
             }
           else
             state = 3;
         }
       else if (state == 3)
         {
           /* Skip leading spaces of the argument.  */
           if (!isascii (c) || !isspace(c))
             {
               i = 0;
               keyword[i++] = c;
               state = 4;
             }
         }
       else if (state == 4)
         {
           /* Collect the argument. */
           if (buffer)
             {
               if (i < buflen-1)
                 buffer[i++] = c;
               else
                 {
                   char *tmp;
                   size_t tmplen = buflen + 50;
 
                   tmp = xtryrealloc (buffer, tmplen);
                   if (tmp)
                     {
                       buflen = tmplen;
                       buffer = tmp;
                       buffer[i++] = c;
                     }
                   else
                     {
                       xfree (buffer);
                       arg->r_opt = ARGPARSE_OUT_OF_CORE;
                       break;
                     }
                 }
             }
           else if (i < DIM(keyword)-1)
             keyword[i++] = c;
           else
             {
               size_t tmplen = DIM(keyword) + 50;
               buffer = xtrymalloc (tmplen);
               if (buffer)
                 {
                   buflen = tmplen;
                   memcpy(buffer, keyword, i);
                   buffer[i++] = c;
                 }
               else
                 {
                   arg->r_opt = ARGPARSE_OUT_OF_CORE;
                   break;
                 }
             }
         }
       else if (i >= DIM(keyword)-1)
         {
           arg->r_opt = ARGPARSE_KEYWORD_TOO_LONG;
           state = -1; /* Skip rest of line and leave.  */
         }
       else
         {
           keyword[i++] = c;
           state = 2;
         }
     }
 
   return arg->r_opt;
 }
 
 
+/* Return true if the list of options OPTS has any option marked with
+ * ARGPARSE_OPT_CONFFILE.  */
+static int
+any_opt_conffile (gpgrt_opt_t *opts)
+{
+  int i;
+
+  for (i=0; opts[i].short_opt; i++ )
+    if ((opts[i].flags & ARGPARSE_OPT_CONFFILE))
+      return 1;
+  return 0;
+}
+
+
+/* The full arg parser which handles option files and command line
+ * arguments.  The behaviour depends on the combinations of CONFNAME
+ * and the ARGPARSE_FLAG_xxx values:
+ *
+ * | CONFNAME | SYS | USER | Action             |
+ * |----------+-----+------+--------------------|
+ * | NULL     |   - |    - | cmdline            |
+ * | string   |   0 |    1 | user, cmdline      |
+ * | string   |   1 |    0 | sys, cmdline       |
+ * | string   |   1 |    1 | sys, user, cmdline |
+ *
+ * Note that if an option has been flagged with ARGPARSE_OPT_CONFFILE
+ * and a type of ARGPARSE_TYPE_STRING that option is not returned but
+ * the specified configuration file is processed directly; if
+ * ARGPARSE_TYPE_NONE is used no user configuration files are
+ * processed and from the system configuration files only those which
+ * are immutable are processed.  The string values for CONFNAME shall
+ * not include a directory part, because that is taken from the values
+ * set by gpgrt_set_confdir.
+ */
+int
+_gpgrt_argparser (gpgrt_argparse_t *arg, gpgrt_opt_t *opts,
+                  const char *confname)
+{
+  /* First check whether releasing the resources has been requested.  */
+  if (arg && !opts)
+    {
+      deinitialize (arg);
+      return 0;
+    }
+
+  /* Make sure that the internal data object is ready and also print
+   * warnings or errors from the last iteration.  */
+  if (initialize (arg, opts, NULL))
+    return (arg->r_opt = ARGPARSE_OUT_OF_CORE);
+
+ next_state:
+  switch (arg->internal->state)
+    {
+    case STATE_init:
+      if (any_opt_conffile (opts))
+        {
+          /* The list of option allow for conf files
+           * (e.g. gpg's "--option FILE" and "--no-options")
+           * Now check whether one was really given on the
+           * command line.  */
+          int  *save_argc = arg->argc;
+          char ***save_argv = arg->argv;
+          unsigned int save_flags = arg->flags;
+          int save_idx = arg->internal->idx;
+          int any_no_conffile = 0;
+
+          arg->flags = (ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION);
+          while (arg_parse (arg, opts))
+            {
+              if ((arg->internal->opt_flags & ARGPARSE_OPT_CONFFILE))
+                {
+                  arg->internal->explicit_confopt = 1;
+                  if (arg->r_type == ARGPARSE_TYPE_STRING
+                      && !arg->internal->explicit_conffile)
+                    {
+                      /* Store the first conffile name.  All further
+                       * conf file options are not handled.  */
+                      arg->internal->explicit_conffile
+                        = xtrystrdup (arg->r.ret_str);
+                      if (!arg->internal->explicit_conffile)
+                        return (arg->r_opt = ARGPARSE_OUT_OF_CORE);
+
+                    }
+                  else if (arg->r_type == ARGPARSE_TYPE_NONE)
+                    any_no_conffile = 1;
+                }
+            }
+          if (any_no_conffile)
+            {
+              /* A NoConffile option overrides any other conf file option.  */
+              xfree (arg->internal->explicit_conffile);
+              arg->internal->explicit_conffile = NULL;
+            }
+          /* Restore parser.  */
+          arg->argc = save_argc;
+          arg->argv = save_argv;
+          arg->flags = save_flags;
+          arg->internal->idx = save_idx;
+
+        }
+
+      if (confname && *confname)
+        {
+          if ((arg->flags & ARGPARSE_FLAG_SYS))
+            arg->internal->state = STATE_open_sys;
+          else if ((arg->flags & ARGPARSE_FLAG_USER))
+            arg->internal->state = STATE_open_user;
+          else
+            return (arg->r_opt = ARGPARSE_INVALID_ARG);
+        }
+      else
+        arg->internal->state = STATE_open_cmdline;
+      goto next_state;
+
+    case STATE_open_sys:
+      xfree (arg->internal->confname);
+      arg->internal->confname = _gpgrt_fnameconcat
+        (confdir.sys? confdir.sys : "/etc", confname, NULL);
+      arg->lineno = 0;
+      _gpgrt_fclose (arg->internal->conffp);
+      arg->internal->conffp = _gpgrt_fopen (arg->internal->confname, "r");
+      /* FIXME: Add a callback.  */
+      /* if (arg->internal->conffp && is_secured_file (fileno (configfp)))*/
+      /*   { */
+      /*     es_fclose (arg->internal->conffp); */
+      /*     arg->internal->conffp = NULL; */
+      /*     gpg_err_set_errno (EPERM); */
+      /*   } */
+      if (!arg->internal->conffp)
+        {
+          if ((arg->flags & ARGPARSE_FLAG_VERBOSE))
+            _gpgrt_log_info (_("Note: no default option file '%s'\n"),
+                             arg->internal->confname);
+          if ((arg->flags & ARGPARSE_FLAG_USER))
+            arg->internal->state = STATE_open_user;
+          else
+            arg->internal->state = STATE_open_cmdline;
+          goto next_state;
+        }
+
+      if ((arg->flags & ARGPARSE_FLAG_VERBOSE))
+        _gpgrt_log_info (_("reading options from '%s'\n"),
+                         arg->internal->confname);
+      arg->internal->state = STATE_read_sys;
+      arg->r.ret_str = xtrystrdup (arg->internal->confname);
+      if (!arg->r.ret_str)
+        arg->r_opt = ARGPARSE_OUT_OF_CORE;
+      else
+        {
+          gpgrt_annotate_leaked_object (arg->r.ret_str);
+          arg->r_opt = ARGPARSE_CONFFILE;
+          arg->r_type = ARGPARSE_TYPE_STRING;
+        }
+      break;
+
+    case STATE_open_user:
+      if (arg->internal->explicit_confopt
+          && arg->internal->explicit_conffile)
+        {
+          /* An explict option to use a specific configuration file
+           * has been given - use that one.  */
+          xfree (arg->internal->confname);
+          arg->internal->confname
+            = xtrystrdup (arg->internal->explicit_conffile);
+          if (!arg->internal->confname)
+            return (arg->r_opt = ARGPARSE_OUT_OF_CORE);
+        }
+      else if (arg->internal->explicit_confopt)
+        {
+          /* An explict option not to use a configuration file has
+           * been given - leap direct to command line reading.  */
+          arg->internal->state = STATE_open_cmdline;
+          goto next_state;
+        }
+      else
+        {
+          /* Use the standard configure file.  */
+          xfree (arg->internal->confname);
+          arg->internal->confname = _gpgrt_fnameconcat
+            (confdir.user? confdir.user : "/FIXME", confname, NULL);
+        }
+      arg->lineno = 0;
+      _gpgrt_fclose (arg->internal->conffp);
+      arg->internal->conffp = _gpgrt_fopen (arg->internal->confname, "r");
+      /* FIXME: Add a callback.  */
+      /* if (arg->internal->conffp && is_secured_file (fileno (configfp)))*/
+      /*   { */
+      /*     es_fclose (arg->internal->conffp); */
+      /*     arg->internal->conffp = NULL; */
+      /*     gpg_err_set_errno (EPERM); */
+      /*   } */
+      if (!arg->internal->conffp)
+        {
+          arg->internal->state = STATE_open_cmdline;
+          if (arg->internal->explicit_confopt)
+            {
+              _gpgrt_log_error (_("option file '%s': %s\n"),
+                                arg->internal->confname, strerror (errno));
+              return (arg->r_opt = ARGPARSE_NO_CONFFILE);
+            }
+          else
+            {
+              if ((arg->flags & ARGPARSE_FLAG_VERBOSE))
+                _gpgrt_log_info (_("Note: no default option file '%s'\n"),
+                                 arg->internal->confname);
+              goto next_state;
+            }
+        }
+
+      if ((arg->flags & ARGPARSE_FLAG_VERBOSE))
+        _gpgrt_log_info (_("reading options from '%s'\n"),
+                         arg->internal->confname);
+      arg->internal->state = STATE_read_user;
+      arg->r.ret_str = xtrystrdup (arg->internal->confname);
+      if (!arg->r.ret_str)
+        arg->r_opt = ARGPARSE_OUT_OF_CORE;
+      else
+        {
+          gpgrt_annotate_leaked_object (arg->r.ret_str);
+          arg->r_opt = ARGPARSE_CONFFILE;
+          arg->r_type = ARGPARSE_TYPE_STRING;
+        }
+      break;
+
+    case STATE_open_cmdline:
+      xfree (arg->internal->confname);
+      arg->internal->confname = NULL;
+      arg->r_opt = ARGPARSE_CONFFILE;
+      arg->r_type = ARGPARSE_TYPE_NONE;
+      arg->r.ret_str = NULL;
+      arg->internal->state = STATE_read_cmdline;
+      break;
+
+    case STATE_read_sys:
+     arg->r_opt = _gpgrt_argparse (arg->internal->conffp, arg, opts);
+      if (!arg->r_opt)
+        {
+          arg->internal->state = STATE_open_user;
+          goto next_state;
+        }
+      if ((arg->internal->opt_flags & ARGPARSE_OPT_CONFFILE))
+        goto next_state;  /* Already handled - again.  */
+      break;
+
+    case STATE_read_user:
+      arg->r_opt = _gpgrt_argparse (arg->internal->conffp, arg, opts);
+      if (!arg->r_opt)
+        {
+          arg->internal->state = STATE_open_cmdline;
+          goto next_state;
+        }
+      if ((arg->internal->opt_flags & ARGPARSE_OPT_CONFFILE))
+        goto next_state;  /* Already handled - again.  */
+      break;
+
+    case STATE_read_cmdline:
+      arg->r_opt = _gpgrt_argparse (arg->internal->conffp, arg, opts);
+      if (!arg->r_opt)
+        {
+          arg->internal->state = STATE_finished;
+          goto next_state;
+        }
+      if ((arg->internal->opt_flags & ARGPARSE_OPT_CONFFILE))
+        goto next_state;  /* Already handled - again.  */
+      break;
+
+    case STATE_finished:
+      arg->r_opt = 0;
+      break;
+    }
+
+  return arg->r_opt;
+}
+
+
 /* Given the list of options OPTS and a keyword, return the index of
  * the long option macthing KEYWORD.  On error -1 is retruned for not
  * found or -2 for ambigious keyword.  */
 static int
 find_long_option (gpgrt_argparse_t *arg, gpgrt_opt_t **opts,
                   const char *keyword)
 {
   int i;
   size_t n;
 
   (void)arg;  /* Not yet required.  */
 
   /* Would be better if we can do a binary search, but it is not
    * possible to reorder our option table because we would mess up our
    * help strings.  What we can do is: Build an option lookup table
    * when this function is first invoked.  */
   if (!*keyword)
     return -1;
   for (i=0; opts[i]->short_opt; i++ )
     if (opts[i]->long_opt && !strcmp (opts[i]->long_opt, keyword))
       return i;
 #if 0
   {
     ALIAS_DEF a;
     /* see whether it is an alias */
     for (a = args->internal->aliases; a; a = a->next)
       {
         if (!strcmp( a->name, keyword))
           {
             /* todo: must parse the alias here */
             args->internal->cur_alias = a;
             return -3; /* alias available */
           }
       }
   }
 #endif
   /* Not found.  See whether it is an abbreviation.  Aliases may not
    * be abbreviated, though. */
   n = strlen (keyword);
   for (i=0; opts[i]->short_opt; i++)
     {
       if (opts[i]->long_opt && !strncmp (opts[i]->long_opt, keyword, n))
         {
           int j;
           for (j=i+1; opts[j]->short_opt; j++)
             {
               if (opts[j]->long_opt
                   && !strncmp (opts[j]->long_opt, keyword, n)
                   && !(opts[j]->short_opt == opts[i]->short_opt
                        && opts[j]->flags == opts[i]->flags ) )
                 return -2;  /* Abbreviation is ambiguous.  */
 	    }
           return i;
 	}
     }
   return -1;  /* Not found.  */
 }
 
 
 /* The option parser for command line options.  */
 static int
 arg_parse (gpgrt_argparse_t *arg, gpgrt_opt_t *opts_orig)
 {
   int idx;
   gpgrt_opt_t **opts;
   int argc;
   char **argv;
   char *s, *s2;
   int i;
 
   if (initialize (arg, opts_orig, NULL))
     return (arg->r_opt = ARGPARSE_OUT_OF_CORE);
 
   opts = arg->internal->opts;
   argc = *arg->argc;
   argv = *arg->argv;
   idx = arg->internal->idx;
 
   if (!idx && argc && !(arg->flags & ARGPARSE_FLAG_ARG0))
     {
       /* Skip the first argument.  */
       argc--; argv++; idx++;
     }
 
  next_one:
   if (!argc)
     {
       /* No more args.  */
       arg->r_opt = 0;
       goto leave; /* Ready. */
     }
 
   s = *argv;
   arg->internal->last = s;
 
   if (arg->internal->stopped && (arg->flags & ARGPARSE_FLAG_ALL))
     {
       arg->r_opt = ARGPARSE_IS_ARG;  /* Not an option but an argument.  */
       arg->r_type = 2;
       arg->r.ret_str = s;
       argc--; argv++; idx++; /* set to next one */
     }
   else if( arg->internal->stopped )
     {
       arg->r_opt = 0;
       goto leave; /* Ready.  */
     }
   else if ( *s == '-' && s[1] == '-' )
     {
       /* Long option.  */
       char *argpos;
 
       arg->internal->inarg = 0;
       if (!s[2] && !(arg->flags & ARGPARSE_FLAG_NOSTOP))
         {
           /* Stop option processing.  */
           arg->internal->stopped = 1;
           arg->flags |= ARGPARSE_FLAG_STOP_SEEN;
           argc--; argv++; idx++;
           goto next_one;
 	}
 
       argpos = strchr( s+2, '=' );
       if ( argpos )
         *argpos = 0;
       i = find_long_option ( arg, opts, s+2 );
       if ( argpos )
         *argpos = '=';
 
       if (i > 0 && opts[i]->short_opt == ARGPARSE_SHORTOPT_HELP)
         show_help (opts, arg->flags);
       else if (i > 0 && opts[i]->short_opt == ARGPARSE_SHORTOPT_VERSION)
         {
           if (!(arg->flags & ARGPARSE_FLAG_NOVERSION))
             {
               show_version ();
               my_exit (arg, 0);
             }
 	}
       else if (i > 0 && opts[i]->short_opt == ARGPARSE_SHORTOPT_WARRANTY)
         {
           writestrings (0, _gpgrt_strusage (16), "\n", NULL);
           my_exit (arg, 0);
 	}
       else if (i > 0 && opts[i]->short_opt == ARGPARSE_SHORTOPT_DUMP_OPTIONS)
         {
           for (i=0; opts[i]->short_opt; i++ )
             {
               if (opts[i]->long_opt && !(opts[i]->flags & ARGPARSE_OPT_IGNORE))
                 writestrings (0, "--", opts[i]->long_opt, "\n", NULL);
 	    }
           my_exit (arg, 0);
 	}
 
       if ( i == -2 )
         arg->r_opt = ARGPARSE_AMBIGUOUS_OPTION;
       else if ( i == -1 )
         {
           arg->r_opt = ARGPARSE_INVALID_OPTION;
           arg->r.ret_str = s+2;
 	}
       else
         arg->r_opt = opts[i]->short_opt;
       if ( i < 0 )
         ;
       else if ( (opts[i]->flags & ARGPARSE_TYPE_MASK) )
         {
           if ( argpos )
             {
               s2 = argpos+1;
               if ( !*s2 )
                 s2 = NULL;
 	    }
           else
             s2 = argv[1];
           if ( !s2 && (opts[i]->flags & ARGPARSE_OPT_OPTIONAL) )
             {
               arg->r_type = ARGPARSE_TYPE_NONE; /* Argument is optional.  */
 	    }
           else if ( !s2 )
             {
               arg->r_opt = ARGPARSE_MISSING_ARG;
 	    }
           else if ( !argpos && *s2 == '-'
                     && (opts[i]->flags & ARGPARSE_OPT_OPTIONAL) )
             {
               /* The argument is optional and the next seems to be an
                  option.  We do not check this possible option but
                  assume no argument */
               arg->r_type = ARGPARSE_TYPE_NONE;
 	    }
           else
             {
               set_opt_arg (arg, opts[i]->flags, s2);
               if ( !argpos )
                 {
                   argc--; argv++; idx++; /* Skip one.  */
 		}
 	    }
 	}
       else
         {
           /* Does not take an argument. */
           if ( argpos )
             arg->r_type = ARGPARSE_UNEXPECTED_ARG;
           else
             arg->r_type = 0;
 	}
       argc--; argv++; idx++; /* Set to next one.  */
     }
     else if ( (*s == '-' && s[1]) || arg->internal->inarg )
       {
         /* Short option.  */
 	int dash_kludge = 0;
 
 	i = 0;
 	if ( !arg->internal->inarg )
           {
 	    arg->internal->inarg++;
 	    if ( (arg->flags & ARGPARSE_FLAG_ONEDASH) )
               {
                 for (i=0; opts[i]->short_opt; i++ )
                   if ( opts[i]->long_opt && !strcmp (opts[i]->long_opt, s+1))
                     {
                       dash_kludge = 1;
                       break;
 		    }
               }
           }
 	s += arg->internal->inarg;
 
 	if (!dash_kludge )
           {
 	    for (i=0; opts[i]->short_opt; i++ )
               if ( opts[i]->short_opt == *s )
                 break;
           }
 
 	if ( !opts[i]->short_opt && ( *s == 'h' || *s == '?' ) )
           show_help (opts, arg->flags);
 
 	arg->r_opt = opts[i]->short_opt;
 	if (!opts[i]->short_opt )
           {
 	    arg->r_opt = (opts[i]->flags & ARGPARSE_OPT_COMMAND)?
               ARGPARSE_INVALID_COMMAND:ARGPARSE_INVALID_OPTION;
 	    arg->internal->inarg++; /* Point to the next arg.  */
 	    arg->r.ret_str = s;
           }
 	else if ( (opts[i]->flags & ARGPARSE_TYPE_MASK) )
           {
 	    if ( s[1] && !dash_kludge )
               {
 		s2 = s+1;
 		set_opt_arg (arg, opts[i]->flags, s2);
               }
 	    else
               {
 		s2 = argv[1];
 		if ( !s2 && (opts[i]->flags & ARGPARSE_OPT_OPTIONAL) )
                   {
 		    arg->r_type = ARGPARSE_TYPE_NONE;
                   }
 		else if ( !s2 )
                   {
 		    arg->r_opt = ARGPARSE_MISSING_ARG;
                   }
 		else if ( *s2 == '-' && s2[1]
                           && (opts[i]->flags & ARGPARSE_OPT_OPTIONAL) )
                   {
 		    /* The argument is optional and the next seems to
 	               be an option.  We do not check this possible
 	               option but assume no argument.  */
 		    arg->r_type = ARGPARSE_TYPE_NONE;
                   }
 		else
                   {
 		    set_opt_arg (arg, opts[i]->flags, s2);
 		    argc--; argv++; idx++; /* Skip one.  */
                   }
               }
 	    s = "x"; /* This is so that !s[1] yields false.  */
           }
 	else
           {
             /* Does not take an argument.  */
 	    arg->r_type = ARGPARSE_TYPE_NONE;
 	    arg->internal->inarg++; /* Point to the next arg.  */
           }
 	if ( !s[1] || dash_kludge )
           {
             /* No more concatenated short options.  */
 	    arg->internal->inarg = 0;
 	    argc--; argv++; idx++;
           }
       }
   else if ( arg->flags & ARGPARSE_FLAG_MIXED )
     {
       arg->r_opt = ARGPARSE_IS_ARG;
       arg->r_type = 2;
       arg->r.ret_str = s;
       argc--; argv++; idx++; /* Set to next one.  */
     }
   else
     {
       arg->internal->stopped = 1; /* Stop option processing.  */
       goto next_one;
     }
 
  leave:
   *arg->argc = argc;
   *arg->argv = argv;
   arg->internal->idx = idx;
   return arg->r_opt;
 }
 
 
 /* Returns: -1 on error, 0 for an integer type and 1 for a non integer
    type argument.  */
 static int
 set_opt_arg (gpgrt_argparse_t *arg, unsigned flags, char *s)
 {
   int base = (flags & ARGPARSE_OPT_PREFIX)? 0 : 10;
   long l;
 
+  arg->internal->opt_flags = flags;
   switch ( (arg->r_type = (flags & ARGPARSE_TYPE_MASK)) )
     {
     case ARGPARSE_TYPE_LONG:
     case ARGPARSE_TYPE_INT:
       errno = 0;
       l = strtol (s, NULL, base);
       if ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE)
         {
           arg->r_opt = ARGPARSE_INVALID_ARG;
           return -1;
         }
       if (arg->r_type == ARGPARSE_TYPE_LONG)
         arg->r.ret_long = l;
       else if ( (l < 0 && l < INT_MIN) || l > INT_MAX )
         {
           arg->r_opt = ARGPARSE_INVALID_ARG;
           return -1;
         }
       else
         arg->r.ret_int = (int)l;
       return 0;
 
     case ARGPARSE_TYPE_ULONG:
       while (isascii (*s) && isspace(*s))
         s++;
       if (*s == '-')
         {
           arg->r.ret_ulong = 0;
           arg->r_opt = ARGPARSE_INVALID_ARG;
           return -1;
         }
       errno = 0;
       arg->r.ret_ulong = strtoul (s, NULL, base);
       if (arg->r.ret_ulong == ULONG_MAX && errno == ERANGE)
         {
           arg->r_opt = ARGPARSE_INVALID_ARG;
           return -1;
         }
       return 0;
 
     case ARGPARSE_TYPE_STRING:
     default:
       arg->r.ret_str = s;
       return 1;
     }
 }
 
 
 /* Return the length of the option O.  This needs to consider the
  * description as weel as the option name.  */
 static size_t
 long_opt_strlen (gpgrt_opt_t *o)
 {
   size_t n = strlen (o->long_opt);
 
   if ( o->description && *o->description == '|' )
     {
       const char *s;
       int is_utf8 = is_native_utf8 ();
 
       s=o->description+1;
       if ( *s != '=' )
         n++;
       /* For a (mostly) correct length calculation we exclude
        * continuation bytes (10xxxxxx) if we are on a native utf8
        * terminal. */
       for (; *s && *s != '|'; s++ )
         if ( is_utf8 && (*s&0xc0) != 0x80 )
           n++;
     }
   return n;
 }
 
 
 /****************
  * Print formatted help. The description string has some special
  * meanings:
  *  - A description string which is "@" suppresses help output for
  *    this option
  *  - a description,ine which starts with a '@' and is followed by
  *    any other characters is printed as is; this may be used for examples
  *    ans such.
  *  - A description which starts with a '|' outputs the string between this
  *    bar and the next one as arguments of the long option.
  */
 static void
 show_help (gpgrt_opt_t **opts, unsigned int flags)
 {
   const char *s;
   char tmp[2];
 
   show_version ();
   writestrings (0, "\n", NULL);
   s = _gpgrt_strusage (42);
   if (s && *s == '1')
     {
       s = _gpgrt_strusage (40);
       writestrings (1, s, NULL);
       if (*s && s[strlen(s)] != '\n')
         writestrings (1, "\n", NULL);
     }
   s = _gpgrt_strusage(41);
   writestrings (0, s, "\n", NULL);
   if ( opts[0]->description )
     {
       /* Auto format the option description.  */
       int i,j, indent;
 
       /* Get max. length of long options.  */
       for (i=indent=0; opts[i]->short_opt; i++ )
         {
           if ( opts[i]->long_opt )
             if ( !opts[i]->description || *opts[i]->description != '@' )
               if ( (j=long_opt_strlen(opts[i])) > indent && j < 35 )
                 indent = j;
 	}
 
       /* Example: " -v, --verbose   Viele Sachen ausgeben" */
       indent += 10;
       if ( *opts[0]->description != '@' )
         writestrings (0, "Options:", "\n", NULL);
       for (i=0; opts[i]->short_opt; i++ )
         {
           s = map_fixed_string (_( opts[i]->description ));
           if ( s && *s== '@' && !s[1] ) /* Hide this line.  */
             continue;
           if ( s && *s == '@' )  /* Unindented comment only line.  */
             {
               for (s++; *s; s++ )
                 {
                   if ( *s == '\n' )
                     {
                       if( s[1] )
                         writestrings (0, "\n", NULL);
 		    }
                   else
                     {
                       tmp[0] = *s;
                       tmp[1] = 0;
                       writestrings (0, tmp, NULL);
                     }
                 }
               writestrings (0, "\n", NULL);
               continue;
 	    }
 
           j = 3;
           if ( opts[i]->short_opt < 256 )
             {
               tmp[0] = opts[i]->short_opt;
               tmp[1] = 0;
               writestrings (0, " -", tmp, NULL );
               if ( !opts[i]->long_opt )
                 {
                   if (s && *s == '|' )
                     {
                       writestrings (0, " ", NULL); j++;
                       for (s++ ; *s && *s != '|'; s++, j++ )
                         {
                           tmp[0] = *s;
                           tmp[1] = 0;
                           writestrings (0, tmp, NULL);
                         }
                       if ( *s )
                         s++;
 		    }
 		}
 	    }
           else
             writestrings (0, "   ", NULL);
           if ( opts[i]->long_opt )
             {
               tmp[0] = opts[i]->short_opt < 256?',':' ';
               tmp[1] = 0;
               j += writestrings (0, tmp, " --", opts[i]->long_opt, NULL);
               if (s && *s == '|' )
                 {
                   if ( *++s != '=' )
                     {
                       writestrings (0, " ", NULL);
                       j++;
 		    }
                   for ( ; *s && *s != '|'; s++, j++ )
                     {
                       tmp[0] = *s;
                       tmp[1] = 0;
                       writestrings (0, tmp, NULL);
                     }
                   if ( *s )
                     s++;
 		}
               writestrings (0, "   ", NULL);
               j += 3;
 	    }
           for (;j < indent; j++ )
             writestrings (0, " ", NULL);
           if ( s )
             {
               if ( *s && j > indent )
                 {
                   writestrings (0, "\n", NULL);
                   for (j=0;j < indent; j++ )
                     writestrings (0, " ", NULL);
 		}
               for (; *s; s++ )
                 {
                   if ( *s == '\n' )
                     {
                       if ( s[1] )
                         {
                           writestrings (0, "\n", NULL);
                           for (j=0; j < indent; j++ )
                             writestrings (0, " ", NULL);
 			}
 		    }
                   else
                     {
                       tmp[0] = *s;
                       tmp[1] = 0;
                       writestrings (0, tmp, NULL);
                     }
 		}
 	    }
           writestrings (0, "\n", NULL);
 	}
 	if ( (flags & ARGPARSE_FLAG_ONEDASH) )
           writestrings (0, "\n(A single dash may be used "
                         "instead of the double ones)\n", NULL);
     }
   if ( (s=_gpgrt_strusage(19)) )
     {
       writestrings (0, "\n", NULL);
       writestrings (0, s, NULL);
     }
   flushstrings (0);
   exit (0);
 }
 
 
 static void
 show_version ()
 {
   const char *s;
   int i;
 
   /* Version line.  */
   writestrings (0, _gpgrt_strusage (11), NULL);
   if ((s=_gpgrt_strusage (12)))
     writestrings (0, " (", s, ")", NULL);
   writestrings (0, " ", _gpgrt_strusage (13), "\n", NULL);
   /* Additional version lines. */
   for (i=20; i < 30; i++)
     if ((s=_gpgrt_strusage (i)))
       writestrings (0, s, "\n", NULL);
   /* Copyright string.  */
   if ((s=_gpgrt_strusage (14)))
     writestrings (0, s, "\n", NULL);
   /* Licence string.  */
   if( (s=_gpgrt_strusage (10)) )
     writestrings (0, s, "\n", NULL);
   /* Copying conditions. */
   if ( (s=_gpgrt_strusage(15)) )
     writestrings (0, s, NULL);
   /* Thanks. */
   if ((s=_gpgrt_strusage(18)))
     writestrings (0, s, NULL);
   /* Additional program info. */
   for (i=30; i < 40; i++ )
     if ( (s=_gpgrt_strusage (i)) )
       writestrings (0, s, NULL);
   flushstrings (0);
 }
 
 
 void
 _gpgrt_usage (int level)
 {
   const char *p;
 
   if (!level)
     {
       writestrings (1, _gpgrt_strusage(11), " ", _gpgrt_strusage(13), "; ",
                     _gpgrt_strusage (14), "\n", NULL);
       flushstrings (1);
     }
   else if (level == 1)
     {
       p = _gpgrt_strusage (40);
       writestrings (1, p, NULL);
       if (*p && p[strlen(p)] != '\n')
         writestrings (1, "\n", NULL);
       exit (2);
     }
   else if (level == 2)
     {
       p = _gpgrt_strusage (42);
       if (p && *p == '1')
         {
           p = _gpgrt_strusage (40);
           writestrings (1, p, NULL);
           if (*p && p[strlen(p)] != '\n')
             writestrings (1, "\n", NULL);
         }
       writestrings (0, _gpgrt_strusage(41), "\n", NULL);
       exit (0);
     }
 }
 
 /* Level
  *     0: Print copyright string to stderr
  *     1: Print a short usage hint to stderr and terminate
  *     2: Print a long usage hint to stdout and terminate
  *     8: Return NULL for UTF-8 or string with the native charset.
  *     9: Return the SPDX License tag.
  *    10: Return license info string
  *    11: Return the name of the program
  *    12: Return optional name of package which includes this program.
  *    13: version  string
  *    14: copyright string
  *    15: Short copying conditions (with LFs)
  *    16: Long copying conditions (with LFs)
  *    17: Optional printable OS name
  *    18: Optional thanks list (with LFs)
  *    19: Bug report info
  *20..29: Additional lib version strings.
  *30..39: Additional program info (with LFs)
  *    40: short usage note (with LF)
  *    41: long usage note (with LF)
  *    42: Flag string:
  *          First char is '1':
  *             The short usage notes needs to be printed
  *             before the long usage note.
  */
 const char *
 _gpgrt_strusage (int level)
 {
   const char *p = strusage_handler? strusage_handler(level) : NULL;
   const char *tmp;
 
   if ( p )
     return map_fixed_string (p);
 
   switch ( level )
     {
 
     case 8: break; /* Default to utf-8.  */
     case 9:
       p = "GPL-3.0-or-later"; /* Suggested license.  */
       break;
 
     case 10:
       tmp = _gpgrt_strusage (9);
       if (tmp && !strcmp (tmp, "GPL-2.0-or-later"))
         p = ("License GPL-2.0-or-later <https://gnu.org/licenses/>");
       else if (tmp && !strcmp (tmp, "LGPL-2.1-or-later"))
         p = ("License LGPL-2.1-or-later <https://gnu.org/licenses/>");
       else /* Default to GPLv3+.  */
         p = ("License GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>");
       break;
     case 11: p = "foo"; break;
     case 13: p = "0.0"; break;
     case 14: p = "Copyright (C) YEAR NAME"; break;
     case 15: p =
 "This is free software: you are free to change and redistribute it.\n"
 "There is NO WARRANTY, to the extent permitted by law.\n";
       break;
     case 16:
       tmp = _gpgrt_strusage (9);
       if (tmp && !strcmp (tmp, "GPL-2.0-or-later"))
         p =
 "This is free software; you can redistribute it and/or modify\n"
 "it under the terms of the GNU General Public License as published by\n"
 "the Free Software Foundation; either version 2 of the License, or\n"
 "(at your option) any later version.\n\n"
 "It is distributed in the hope that it will be useful,\n"
 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
 "GNU General Public License for more details.\n\n"
 "You should have received a copy of the GNU General Public License\n"
 "along with this software.  If not, see <https://gnu.org/licenses/>.\n";
       else if (tmp && !strcmp (tmp, "LGPL-2.1-or-later"))
         p =
 "This is free software; you can redistribute it and/or modify\n"
 "it under the terms of the GNU Lesser General Public License as\n"
 "published by the Free Software Foundation; either version 2.1 of\n"
 "the License, or (at your option) any later version.\n\n"
 "It is distributed in the hope that it will be useful,\n"
 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
 "GNU Lesser General Public License for more details.\n\n"
 "You should have received a copy of the GNU General Public License\n"
 "along with this software.  If not, see <https://gnu.org/licenses/>.\n";
       else /* Default */
         p =
 "This is free software; you can redistribute it and/or modify\n"
 "it under the terms of the GNU General Public License as published by\n"
 "the Free Software Foundation; either version 3 of the License, or\n"
 "(at your option) any later version.\n\n"
 "It is distributed in the hope that it will be useful,\n"
 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
 "GNU General Public License for more details.\n\n"
 "You should have received a copy of the GNU General Public License\n"
 "along with this software.  If not, see <https://gnu.org/licenses/>.\n";
       break;
     case 40: /* short and long usage */
     case 41: p = ""; break;
     }
 
   return p;
 }
 
 
 /* Set the usage handler.  This function is basically a constructor.  */
 void
 _gpgrt_set_strusage (const char *(*f)(int) )
 {
   strusage_handler = f;
 }
 
 
 /* Set a function to write strings which is then used instead of
  * estream.  The first arg of that function is MODE and the second the
  * STRING to write.  A mode of 1 is used for writing to stdout and a
  * mode of 2 to write to stderr.  Other modes are reserved and should
  * not output anything.  A NULL for STRING requests a flush.  */
 void
 _gpgrt_set_usage_outfnc (int (*f)(int, const char *))
 {
   custom_outfnc = f;
 }
 
 
 /* Register function F as a string mapper which takes a string as
  * argument, replaces known "@FOO@" style macros and returns a new
  * fixed string.  Warning: The input STRING must have been allocated
  * statically.  */
 void
 _gpgrt_set_fixed_string_mapper (const char *(*f)(const char*))
 {
   fixed_string_mapper = f;
 }
+
+
+/* Register a configuration directory for use by the argparse
+ * functions.  The defined values for WHAT are:
+ *
+ *   GPGRT_CONFDIR_SYS   The systems's configuration dir.
+ *                       The default is /etc
+ *
+ *   GPGRT_CONFDIR_USER  The user's configuration directory.
+ *                       The default is $HOME.
+ *
+ * A trailing slash is ignored; to have the function lookup
+ * configuration files in the current directory, use ".".  There is no
+ * error return; more configuraion values may be added in future
+ * revisions of this library.
+ */
+void
+_gpgrt_set_confdir (int what, const char *name)
+{
+  char *buf, *p;
+
+  if (what == GPGRT_CONFDIR_SYS)
+    {
+      _gpgrt_free (confdir.sys);
+      buf = confdir.sys = _gpgrt_strdup (name);
+    }
+  else if (what == GPGRT_CONFDIR_USER)
+    {
+      _gpgrt_free (confdir.user);
+      buf = confdir.user = _gpgrt_strdup (name);
+    }
+  else
+    return;
+
+  if (!buf)
+    _gpgrt_log_fatal ("out of core in %s\n", __func__);
+#ifdef HAVE_W32_SYSTEM
+  for (p=buf; *p; p++)
+    if (*p == '\\')
+      *p = '/';
+#endif
+  /* Strip trailing slashes unless buf is "/" or any other single char
+   * string.  */
+  if (*buf)
+    {
+      for (p=buf + strlen (buf)-1; p > buf; p--)
+        if (*p == '/')
+          *p = 0;
+        else
+          break;
+    }
+}
diff --git a/src/gpg-error.def.in b/src/gpg-error.def.in
index 4e3b5d7..537d3cf 100644
--- a/src/gpg-error.def.in
+++ b/src/gpg-error.def.in
@@ -1,235 +1,238 @@
 /* libgpg-error.def - Exported symbols for W32
  * Copyright (C) 2014 g10 Code GmbH
  *
  * This file is part of libgpg-error.
  *
  * libgpg-error is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * libgpg-error is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, see <https://www.gnu.org/licenses/>.
  * SPDX-License-Identifier: LGPL-2.1+
  *
  * Note: This file should be updated manually and the ordinals shall
  * never be changed.  Also check gpg-error.vers and visibility.h.
  *
  * This file needs to be pre-processed.
  */
 
 #include <config.h>
 
 EXPORTS
  gpg_strerror                 @1
  gpg_strerror_r               @2
  gpg_strsource                @3
  gpg_err_code_from_errno      @4
  gpg_err_code_to_errno        @5
  /* @6 - Not anymore used.  */
  gpg_err_code_from_syserror   @7
  gpg_err_set_errno            @8
 #ifdef HAVE_W32CE_SYSTEM
    _gpg_w32ce_get_errno       @9
    _gpg_w32ce_strerror        @10
 #endif
 #ifdef HAVE_W32_SYSTEM
    _gpg_w32_bindtextdomain     @11
    _gpg_w32_textdomain         @12
    _gpg_w32_gettext            @13
    _gpg_w32_dgettext           @14
    _gpg_w32_dngettext          @15
    _gpg_w32_gettext_localename @16
    _gpg_w32_gettext_use_utf8   @17
 #endif
  /* @18 - Not anymore used. */
  gpg_error_check_version      @19
 
  gpgrt_lock_init              @20
  gpgrt_lock_lock              @21
  gpgrt_lock_unlock            @22
  gpgrt_lock_destroy           @23
  gpgrt_yield                  @24
  gpgrt_lock_trylock           @25
 
  gpgrt_set_syscall_clamp      @26
 
  gpgrt_fopen                  @27
  gpgrt_mopen                  @28
  gpgrt_fopenmem               @29
  gpgrt_fopenmem_init          @30
  gpgrt_fdopen                 @31
  gpgrt_fdopen_nc              @32
  gpgrt_sysopen                @33
  gpgrt_sysopen_nc             @34
  gpgrt_fpopen                 @35
  gpgrt_fpopen_nc              @36
  gpgrt_freopen                @37
  gpgrt_fopencookie            @38
  gpgrt_fclose                 @39
  gpgrt_fclose_snatch          @40
  gpgrt_onclose                @41
  gpgrt_fileno                 @42
  gpgrt_fileno_unlocked        @43
  gpgrt_syshd                  @44
  gpgrt_syshd_unlocked         @45
  _gpgrt_set_std_fd            @46
  _gpgrt_get_std_stream        @47
  gpgrt_flockfile              @48
  gpgrt_ftrylockfile           @49
  gpgrt_funlockfile            @50
  gpgrt_feof                   @51
  gpgrt_feof_unlocked          @52
  gpgrt_ferror                 @53
  gpgrt_ferror_unlocked        @54
  gpgrt_clearerr               @55
  gpgrt_clearerr_unlocked      @56
  gpgrt_fflush                 @57
  gpgrt_fseek                  @58
  gpgrt_fseeko                 @59
  gpgrt_ftell                  @60
  gpgrt_ftello                 @61
  gpgrt_rewind                 @62
  gpgrt_fgetc                  @63
  _gpgrt_getc_underflow        @64
  gpgrt_fputc                  @65
  _gpgrt_putc_overflow         @66
  gpgrt_ungetc                 @67
  gpgrt_read                   @68
  gpgrt_write                  @69
  gpgrt_write_sanitized        @70
  gpgrt_write_hexstring        @71
  gpgrt_fread                  @72
  gpgrt_fwrite                 @73
  gpgrt_fgets                  @74
  gpgrt_fputs                  @75
  gpgrt_fputs_unlocked         @76
  gpgrt_getline                @77
  gpgrt_read_line              @78
  gpgrt_free                   @79
  gpgrt_fprintf                @80
  gpgrt_fprintf_unlocked       @81
  gpgrt_printf                 @82
  gpgrt_printf_unlocked        @83
  gpgrt_vfprintf               @84
  gpgrt_vfprintf_unlocked      @85
  gpgrt_setvbuf                @86
  gpgrt_setbuf                 @87
  gpgrt_set_binary             @88
  gpgrt_tmpfile                @89
  gpgrt_opaque_set             @90
  gpgrt_opaque_get             @91
  gpgrt_fname_set              @92
  gpgrt_fname_get              @93
  gpgrt_asprintf               @94
  gpgrt_vasprintf              @95
  gpgrt_bsprintf               @96
  gpgrt_vbsprintf              @97
  gpgrt_snprintf               @98
  gpgrt_vsnprintf              @99
 
  gpgrt_check_version          @100
  gpg_err_init                 @101
  gpg_err_deinit               @102
  gpgrt_set_alloc_func         @103
 
  _gpgrt_pending               @104
  _gpgrt_pending_unlocked      @105
 
  gpgrt_set_nonblock           @106
  gpgrt_get_nonblock           @107
  gpgrt_poll                   @108
 
 #ifdef HAVE_W32_SYSTEM
  gpgrt_w32_iconv_open         @109
  gpgrt_w32_iconv_close        @110
  gpgrt_w32_iconv              @111
 #endif
 
  gpgrt_get_syscall_clamp      @112
 
  gpgrt_b64dec_start           @113
  gpgrt_b64dec_proc            @114
  gpgrt_b64dec_finish          @115
 
  gpgrt_get_errorcount         @116
  gpgrt_inc_errorcount         @117
  gpgrt_log_set_sink           @118
  gpgrt_log_set_socket_dir_cb  @119
  gpgrt_log_set_pid_suffix_cb  @120
  gpgrt_log_set_prefix         @121
  gpgrt_log_get_prefix         @122
  gpgrt_log_test_fd            @123
  gpgrt_log_get_fd             @124
  gpgrt_log_get_stream         @125
  gpgrt_log                    @126
  gpgrt_logv                   @127
  gpgrt_logv_prefix            @128
  gpgrt_log_string             @129
  gpgrt_log_bug                @130
  gpgrt_log_fatal              @131
  gpgrt_log_error              @132
  gpgrt_log_info               @133
  gpgrt_log_debug              @134
  gpgrt_log_debug_string       @135
  gpgrt_log_printf             @136
  gpgrt_log_printhex           @137
  gpgrt_log_clock              @138
  gpgrt_log_flush              @139
  _gpgrt_log_assert            @140
 
  gpgrt_realloc                @141
  gpgrt_malloc                 @142
  gpgrt_calloc                 @143
  gpgrt_strdup                 @144
  gpgrt_strconcat              @145
 
  gpgrt_w32_reg_query_string   @146
 
  gpgrt_getenv                 @147
  gpgrt_setenv                 @148
  gpgrt_mkdir                  @149
  gpgrt_chdir                  @150
  gpgrt_getcwd                 @151
 
 ;; API not yet finished for:
 ;; gpgrt_make_pipe              @152
 ;; gpgrt_spawn_process          @153
 ;; gpgrt_spawn_process_fd       @154
 ;; gpgrt_spawn_process_detached @155
 ;; gpgrt_wait_process           @156
 ;; gpgrt_wait_processes         @157
 ;; gpgrt_kill_process           @158
 ;; gpgrt_release_process        @159
 
  gpgrt_argparse               @160
  gpgrt_usage                  @161
  gpgrt_strusage               @162
  gpgrt_set_strusage           @163
  gpgrt_set_usage_outfnc       @164
  gpgrt_set_fixed_string_mapper  @165
 
  gpgrt_b64enc_start           @166
  gpgrt_b64enc_write           @167
  gpgrt_b64enc_finish          @168
 
  gpgrt_cmp_version            @169
 
  gpgrt_ftruncate              @170
  gpgrt_fprintf_sf             @171
  gpgrt_fprintf_sf_unlocked    @172
 
  gpgrt_w32_override_locale    @173
 
  gpgrt_add_emergency_cleanup  @174
  gpgrt_abort                  @175
 
+ gpgrt_set_confdir            @176
+ gpgrt_argparse               @177
+
  gpgrt_fnameconcat            @178
  gpgrt_absfnameconcat         @179
 
 ;; end of file with public symbols for Windows.
diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in
index 470021d..d812326 100644
--- a/src/gpg-error.h.in
+++ b/src/gpg-error.h.in
@@ -1,1324 +1,1343 @@
 /* gpg-error.h or gpgrt.h - Common code for GnuPG and others.    -*- c -*-
- * Copyright (C) 2001-2019 g10 Code GmbH
+ * Copyright (C) 2001-2020 g10 Code GmbH
  *
  * This file is part of libgpg-error (aka libgpgrt).
  *
  * libgpg-error is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * libgpg-error is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, see <https://www.gnu.org/licenses/>.
  * SPDX-License-Identifier: LGPL-2.1+
  *
  * @configure_input@
  */
 
 /* The GnuPG project consists of many components.  Error codes are
  * exchanged between all components.  The common error codes and their
  * user-presentable descriptions are kept into a shared library to
  * allow adding new error codes and components without recompiling any
  * of the other components.  In addition to error codes this library
  * also features several other groups of functions which are common to
  * all GnuPG components.  They may be used by independet project as
  * well.  The interfaces will not change in a backward incompatible way.
  *
  * An error code together with an error source build up an error
  * value.  As the error value is been passed from one component to
  * another, it preserves the information about the source and nature
  * of the error.
  *
  * A component of the GnuPG project can define the following macros to
  * tune the behaviour of the library:
  *
  * GPG_ERR_SOURCE_DEFAULT: Define to an error source of type
  * gpg_err_source_t to make that source the default for gpg_error().
  * Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default.
  *
  * GPG_ERR_ENABLE_GETTEXT_MACROS: Define to provide macros to map the
  * internal gettext API to standard names.  This has only an effect on
  * Windows platforms.
  *
  * GPGRT_ENABLE_ES_MACROS: Define to provide "es_" macros for the
  * estream functions.
  *
  * GPGRT_ENABLE_LOG_MACROS: Define to provide short versions of the
  * log functions.
  *
  * GPGRT_ENABLE_ARGPARSE_MACROS: Needs to be defined to provide the
  * mandatory macros of the argparse interface.
  */
 
 #ifndef GPG_ERROR_H
 #define GPG_ERROR_H 1
 #ifndef GPGRT_H
 #define GPGRT_H 1
 
 #include <stddef.h>
 #include <stdio.h>
 #include <stdarg.h>
 
 /* The version string of this header. */
 #define GPG_ERROR_VERSION @version@
 #define GPGRT_VERSION     @version@
 
 /* The version number of this header. */
 #define GPG_ERROR_VERSION_NUMBER @version-number@
 #define GPGRT_VERSION_NUMBER     @version-number@
 
 
 #ifdef __GNUC__
 # define GPG_ERR_INLINE __inline__
 #elif defined(_MSC_VER) && _MSC_VER >= 1300
 # define GPG_ERR_INLINE __inline
 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
 # define GPG_ERR_INLINE inline
 #else
 # ifndef GPG_ERR_INLINE
 #  define GPG_ERR_INLINE
 # endif
 #endif
 
 #ifdef __cplusplus
 extern "C" {
 #if 0 /* just to make Emacs auto-indent happy */
 }
 #endif
 #endif /* __cplusplus */
 
 
 
 /* The error source type gpg_err_source_t.
  *
  * Where as the Poo out of a welle small
  * Taketh his firste springing and his sours.
  *					--Chaucer.
  */
 
 /* Only use free slots, never change or reorder the existing
  * entries.  */
 typedef enum
   {
 @include:err-sources@
     /* This is one more than the largest allowed entry.  */
     GPG_ERR_SOURCE_DIM = 128
   } gpg_err_source_t;
 
 
 /* The error code type gpg_err_code_t.  */
 
 /* Only use free slots, never change or reorder the existing
  * entries.  */
 typedef enum
   {
 @include:err-codes@
     /* The following error codes are used to map system errors.  */
 #define GPG_ERR_SYSTEM_ERROR	(1 << 15)
 @include:errnos@
     /* This is one more than the largest allowed entry.  */
     GPG_ERR_CODE_DIM = 65536
   } gpg_err_code_t;
 
 
 /* The error value type gpg_error_t.  */
 
 /* We would really like to use bit-fields in a struct, but using
  * structs as return values can cause binary compatibility issues, in
  * particular if you want to do it efficiently (also see
  * -freg-struct-return option to GCC).  */
 typedef unsigned int gpg_error_t;
 
 /* We use the lowest 16 bits of gpg_error_t for error codes.  The 16th
  * bit indicates system errors.  */
 #define GPG_ERR_CODE_MASK	(GPG_ERR_CODE_DIM - 1)
 
 /* Bits 17 to 24 are reserved.  */
 
 /* We use the upper 7 bits of gpg_error_t for error sources.  */
 #define GPG_ERR_SOURCE_MASK	(GPG_ERR_SOURCE_DIM - 1)
 #define GPG_ERR_SOURCE_SHIFT	24
 
 /* The highest bit is reserved.  It shouldn't be used to prevent
  * potential negative numbers when transmitting error values as
  * text.  */
 
 
 /*
  * GCC feature test.
  */
 #if __GNUC__
 # define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \
                                + __GNUC_MINOR__ * 100 \
                                + __GNUC_PATCHLEVEL__)
 #else
 # define _GPG_ERR_GCC_VERSION 0
 #endif
 
 #undef _GPG_ERR_HAVE_CONSTRUCTOR
 #if _GPG_ERR_GCC_VERSION > 30100
 # define _GPG_ERR_CONSTRUCTOR	__attribute__ ((__constructor__))
 # define _GPG_ERR_HAVE_CONSTRUCTOR
 #else
 # define _GPG_ERR_CONSTRUCTOR
 #endif
 
 #define GPGRT_GCC_VERSION  _GPG_ERR_GCC_VERSION
 
 #if _GPG_ERR_GCC_VERSION >= 29200
 # define _GPGRT__RESTRICT __restrict__
 #else
 # define _GPGRT__RESTRICT
 #endif
 
 /* The noreturn attribute.  */
 #if _GPG_ERR_GCC_VERSION >= 20500
 # define GPGRT_ATTR_NORETURN   __attribute__ ((__noreturn__))
 #else
 # define GPGRT_ATTR_NORETURN
 #endif
 
 /* The printf attributes.  */
 #if _GPG_ERR_GCC_VERSION >= 40400
 # define GPGRT_ATTR_PRINTF(f, a) \
                     __attribute__ ((format(__gnu_printf__,f,a)))
 # define GPGRT_ATTR_NR_PRINTF(f, a) \
                     __attribute__ ((__noreturn__, format(__gnu_printf__,f,a)))
 #elif _GPG_ERR_GCC_VERSION >= 20500
 # define GPGRT_ATTR_PRINTF(f, a) \
                     __attribute__ ((format(printf,f,a)))
 # define GPGRT_ATTR_NR_PRINTF(f, a) \
                     __attribute__ ((__noreturn__, format(printf,f,a)))
 #else
 # define GPGRT_ATTR_PRINTF(f, a)
 # define GPGRT_ATTR_NR_PRINTF(f, a)
 #endif
 #if _GPG_ERR_GCC_VERSION >= 20800
 # define GPGRT_ATTR_FORMAT_ARG(a)  __attribute__ ((__format_arg__ (a)))
 #else
 # define GPGRT_ATTR_FORMAT_ARG(a)
 #endif
 
 /* The sentinel attribute.  */
 #if _GPG_ERR_GCC_VERSION >= 40000
 # define GPGRT_ATTR_SENTINEL(a)  __attribute__ ((sentinel(a)))
 #else
 # define GPGRT_ATTR_SENTINEL(a)
 #endif
 
 /* The used and unused attributes.
  * I am not sure since when the unused attribute is really supported.
  * In any case it it only needed for gcc versions which print a
  * warning.  Thus let us require gcc >= 3.5.  */
 #if _GPG_ERR_GCC_VERSION >= 40000
 # define GPGRT_ATTR_USED  __attribute__ ((used))
 #else
 # define GPGRT_ATTR_USED
 #endif
 #if _GPG_ERR_GCC_VERSION >= 30500
 # define GPGRT_ATTR_UNUSED  __attribute__ ((unused))
 #else
 # define GPGRT_ATTR_UNUSED
 #endif
 
 /* The deprecated attribute.  */
 #if _GPG_ERR_GCC_VERSION >= 30100
 # define GPGRT_ATTR_DEPRECATED  __attribute__ ((__deprecated__))
 #else
 # define GPGRT_ATTR_DEPRECATED
 #endif
 
 /* The pure attribute.  */
 #if _GPG_ERR_GCC_VERSION >= 29600
 # define GPGRT_ATTR_PURE  __attribute__ ((__pure__))
 #else
 # define GPGRT_ATTR_PURE
 #endif
 
 /* The malloc attribute.  */
 #if _GPG_ERR_GCC_VERSION >= 30200
 # define GPGRT_ATTR_MALLOC  __attribute__ ((__malloc__))
 #else
 # define GPGRT_ATTR_MALLOC
 #endif
 
 /* A macro defined if a GCC style __FUNCTION__ macro is available.  */
 #undef GPGRT_HAVE_MACRO_FUNCTION
 #if _GPG_ERR_GCC_VERSION >= 20500
 # define GPGRT_HAVE_MACRO_FUNCTION 1
 #endif
 
 /* A macro defined if the pragma GCC push_options is available.  */
 #undef GPGRT_HAVE_PRAGMA_GCC_PUSH
 #if _GPG_ERR_GCC_VERSION >= 40400
 # define GPGRT_HAVE_PRAGMA_GCC_PUSH 1
 #endif
 
 /* Detect LeakSanitizer (LSan) support for GCC and Clang based on
  * whether AddressSanitizer (ASAN) is enabled via -fsanitize=address).
  * Note that -fsanitize=leak just affect the linker options which
  * cannot be detected here.  In that case you have to define the
  * GPGRT_HAVE_LEAK_SANITIZER macro manually.  */
 #ifdef __GNUC__
 # ifdef __SANITIZE_ADDRESS__
 #  define GPGRT_HAVE_LEAK_SANITIZER
 # elif defined(__has_feature)
 #  if __has_feature(address_sanitizer)
 #   define GPGRT_HAVE_LEAK_SANITIZER
 #  endif
 # endif
 #endif
 
 
 /* The new name for the inline macro.  */
 #define GPGRT_INLINE GPG_ERR_INLINE
 
 #ifdef GPGRT_HAVE_LEAK_SANITIZER
 # include <sanitizer/lsan_interface.h>
 #endif
 
 /* Mark heap objects as non-leaked memory. */
 static GPGRT_INLINE void
 gpgrt_annotate_leaked_object (const void *p)
 {
 #ifdef GPGRT_HAVE_LEAK_SANITIZER
   __lsan_ignore_object(p);
 #else
   (void)p;
 #endif
 }
 
 
 /*
  * Initialization function.
  */
 
 /* Initialize the library.  This function should be run early.  */
 gpg_error_t gpg_err_init (void) _GPG_ERR_CONSTRUCTOR;
 
 /* If this is defined, the library is already initialized by the
    constructor and does not need to be initialized explicitely.  */
 #undef GPG_ERR_INITIALIZED
 #ifdef _GPG_ERR_HAVE_CONSTRUCTOR
 # define GPG_ERR_INITIALIZED	1
 # define gpgrt_init() do { gpg_err_init (); } while (0)
 #else
 # define gpgrt_init() do { ; } while (0)
 #endif
 
 /* See the source on how to use the deinit function; it is usually not
    required.  */
 void gpg_err_deinit (int mode);
 
 /* Register blocking system I/O clamping functions.  */
 void gpgrt_set_syscall_clamp (void (*pre)(void), void (*post)(void));
 
 /* Get current I/O clamping functions.  */
 void gpgrt_get_syscall_clamp (void (**r_pre)(void), void (**r_post)(void));
 
 /* Register a custom malloc/realloc/free function.  */
 void gpgrt_set_alloc_func  (void *(*f)(void *a, size_t n));
 
 /* Register an emergency cleanup handler.  */
 void gpgrt_add_emergency_cleanup (void (*f)(void));
 
 /* Wrapper around abort to make sure emergency cleanups are run.  */
 void gpgrt_abort (void) GPGRT_ATTR_NORETURN;
 
 
 
 /*
  * Constructor and accessor functions.
  */
 
 /* Construct an error value from an error code and source.  Within a
  * subsystem, use gpg_error.  */
 static GPG_ERR_INLINE gpg_error_t
 gpg_err_make (gpg_err_source_t source, gpg_err_code_t code)
 {
   return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
     : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
        | (code & GPG_ERR_CODE_MASK));
 }
 
 
 /* The user should define GPG_ERR_SOURCE_DEFAULT before including this
  * file to specify a default source for gpg_error.  */
 #ifndef GPG_ERR_SOURCE_DEFAULT
 #define GPG_ERR_SOURCE_DEFAULT	GPG_ERR_SOURCE_UNKNOWN
 #endif
 
 static GPG_ERR_INLINE gpg_error_t
 gpg_error (gpg_err_code_t code)
 {
   return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code);
 }
 
 
 /* Retrieve the error code from an error value.  */
 static GPG_ERR_INLINE gpg_err_code_t
 gpg_err_code (gpg_error_t err)
 {
   return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
 }
 
 
 /* Retrieve the error source from an error value.  */
 static GPG_ERR_INLINE gpg_err_source_t
 gpg_err_source (gpg_error_t err)
 {
   return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
 			     & GPG_ERR_SOURCE_MASK);
 }
 
 
 /* String functions.  */
 
 /* Return a pointer to a string containing a description of the error
  * code in the error value ERR.  This function is not thread-safe.  */
 const char *gpg_strerror (gpg_error_t err);
 
 /* Return the error string for ERR in the user-supplied buffer BUF of
  * size BUFLEN.  This function is, in contrast to gpg_strerror,
  * thread-safe if a thread-safe strerror_r() function is provided by
  * the system.  If the function succeeds, 0 is returned and BUF
  * contains the string describing the error.  If the buffer was not
  * large enough, ERANGE is returned and BUF contains as much of the
  * beginning of the error string as fits into the buffer.  */
 int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
 
 /* Return a pointer to a string containing a description of the error
  * source in the error value ERR.  */
 const char *gpg_strsource (gpg_error_t err);
 
 
 /*
  * Mapping of system errors (errno).
  */
 
 /* Retrieve the error code for the system error ERR.  This returns
  * GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
  * this). */
 gpg_err_code_t gpg_err_code_from_errno (int err);
 
 /* Retrieve the system error for the error code CODE.  This returns 0
  * if CODE is not a system error code.  */
 int gpg_err_code_to_errno (gpg_err_code_t code);
 
 /* Retrieve the error code directly from the ERRNO variable.  This
  * returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
  * (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
 gpg_err_code_t gpg_err_code_from_syserror (void);
 
 /* Mapper for SQLite primary error codes.  */
 static GPG_ERR_INLINE gpg_error_t
 gpg_err_code_from_sqlite (int sqlres)
 {
   return sqlres? GPG_ERR_SQL_OK + (sqlres & 0xff) : 0;
 }
 
 
 /* Set the ERRNO variable.  This function is the preferred way to set
  * ERRNO due to peculiarities on WindowsCE.  */
 void gpg_err_set_errno (int err);
 
 /* Return or check the version.  Both functions are identical.  */
 const char *gpgrt_check_version (const char *req_version);
 const char *gpg_error_check_version (const char *req_version);
 
 /* System specific type definitions.  */
 @define:pid_t@
 @define:gpgrt_ssize_t@
 @define:gpgrt_off_t@
 
 @include:os-add@
 
 /* Self-documenting convenience functions.  */
 
 static GPG_ERR_INLINE gpg_error_t
 gpg_err_make_from_errno (gpg_err_source_t source, int err)
 {
   return gpg_err_make (source, gpg_err_code_from_errno (err));
 }
 
 
 static GPG_ERR_INLINE gpg_error_t
 gpg_error_from_errno (int err)
 {
   return gpg_error (gpg_err_code_from_errno (err));
 }
 
 static GPG_ERR_INLINE gpg_error_t
 gpg_error_from_syserror (void)
 {
   return gpg_error (gpg_err_code_from_syserror ());
 }
 
 
 
 /*
  * Malloc and friends
  */
 
 void *gpgrt_realloc (void *a, size_t n);
 void *gpgrt_malloc (size_t n);
 void *gpgrt_calloc (size_t n, size_t m);
 char *gpgrt_strdup (const char *string);
 char *gpgrt_strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
 void gpgrt_free (void *a);
 
 
 /*
  * System specific function wrappers.
  */
 
 /* A getenv replacement which mallocs the returned string.  */
 char *gpgrt_getenv (const char *name);
 
 /* A setenv and a unsetenv replacement.*/
 gpg_err_code_t gpgrt_setenv (const char *name,
                              const char *value, int overwrite);
 #define gpgrt_unsetenv(n) gpgrt_setenv ((n), NULL, 1)
 
 /* A wrapper around mkdir using a string for the mode.  */
 gpg_err_code_t gpgrt_mkdir (const char *name, const char *modestr);
 
 /* A simple wrapper around chdir.  */
 gpg_err_code_t gpgrt_chdir (const char *name);
 
 /* Return the current WD as a malloced string.  */
 char *gpgrt_getcwd (void);
 
 
 
 
 /*
  * Lock functions.
  */
 
 @include:lock-obj@
 
 #define GPGRT_LOCK_DEFINE(name) \
   static gpgrt_lock_t name  = GPGRT_LOCK_INITIALIZER
 
 /* NB: If GPGRT_LOCK_DEFINE is not used, zero out the lock variable
    before passing it to gpgrt_lock_init.  */
 gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd);
 gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd);
 gpg_err_code_t gpgrt_lock_trylock (gpgrt_lock_t *lockhd);
 gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
 gpg_err_code_t gpgrt_lock_destroy (gpgrt_lock_t *lockhd);
 
 
 
 /*
  * Thread functions.
  */
 
 gpg_err_code_t gpgrt_yield (void);
 
 
 
 
 /*
  * Estream
  */
 
 /* The definition of this struct is entirely private.  You must not
    use it for anything.  It is only here so some functions can be
    implemented as macros.  */
 struct _gpgrt_stream_internal;
 struct _gpgrt__stream
 {
   /* The layout of this struct must never change.  It may be grown,
      but only if all functions which access the new members are
      versioned.  */
 
   /* Various flags.  */
   struct {
     unsigned int magic: 16;
     unsigned int writing: 1;
     unsigned int reserved: 15;
   } flags;
 
   /* A pointer to the stream buffer.  */
   unsigned char *buffer;
 
   /* The size of the buffer in bytes.  */
   size_t buffer_size;
 
   /* The length of the usable data in the buffer, only valid when in
      read mode (see flags).  */
   size_t data_len;
 
   /* The current position of the offset pointer, valid in read and
      write mode.  */
   size_t data_offset;
 
   size_t data_flushed;
   unsigned char *unread_buffer;
   size_t unread_buffer_size;
 
   /* The number of unread bytes.  */
   size_t unread_data_len;
 
   /* A pointer to our internal data for this stream.  */
   struct _gpgrt_stream_internal *intern;
 };
 
 /* The opaque type for an estream.  */
 typedef struct _gpgrt__stream *gpgrt_stream_t;
 #ifdef GPGRT_ENABLE_ES_MACROS
 typedef struct _gpgrt__stream *estream_t;
 #endif
 
 typedef @api_ssize_t@ (*gpgrt_cookie_read_function_t) (void *cookie,
                                                  void *buffer, size_t size);
 typedef @api_ssize_t@ (*gpgrt_cookie_write_function_t) (void *cookie,
                                                   const void *buffer,
                                                   size_t size);
 typedef int (*gpgrt_cookie_seek_function_t) (void *cookie,
                                              gpgrt_off_t *pos, int whence);
 typedef int (*gpgrt_cookie_close_function_t) (void *cookie);
 
 struct _gpgrt_cookie_io_functions
 {
   gpgrt_cookie_read_function_t func_read;
   gpgrt_cookie_write_function_t func_write;
   gpgrt_cookie_seek_function_t func_seek;
   gpgrt_cookie_close_function_t func_close;
 };
 typedef struct _gpgrt_cookie_io_functions gpgrt_cookie_io_functions_t;
 #ifdef GPGRT_ENABLE_ES_MACROS
 typedef struct _gpgrt_cookie_io_functions  es_cookie_io_functions_t;
 #define es_cookie_read_function_t  gpgrt_cookie_read_function_t
 #define es_cookie_write_function_t gpgrt_cookie_read_function_t
 #define es_cookie_seek_function_t  gpgrt_cookie_read_function_t
 #define es_cookie_close_function_t gpgrt_cookie_read_function_t
 #endif
 
 enum gpgrt_syshd_types
   {
     GPGRT_SYSHD_NONE = 0,  /* No system handle available.                   */
     GPGRT_SYSHD_FD = 1,    /* A file descriptor as returned by open().      */
     GPGRT_SYSHD_SOCK = 2,  /* A socket as returned by socket().             */
     GPGRT_SYSHD_RVID = 3,  /* A rendezvous id (see libassuan's gpgcedev.c).  */
     GPGRT_SYSHD_HANDLE = 4 /* A HANDLE object (Windows).                    */
   };
 
 struct _gpgrt_syshd
 {
   enum gpgrt_syshd_types type;
   union {
     int fd;
     int sock;
     int rvid;
     void *handle;
   } u;
 };
 typedef struct _gpgrt_syshd gpgrt_syshd_t;
 #ifdef GPGRT_ENABLE_ES_MACROS
 typedef struct _gpgrt_syshd es_syshd_t;
 #define ES_SYSHD_NONE   GPGRT_SYSHD_NONE
 #define ES_SYSHD_FD     GPGRT_SYSHD_FD
 #define ES_SYSHD_SOCK   GPGRT_SYSHD_SOCK
 #define ES_SYSHD_RVID   GPGRT_SYSHD_RVID
 #define ES_SYSHD_HANDLE GPGRT_SYSHD_HANDLE
 #endif
 
 /* The object used with gpgrt_poll.  */
 struct _gpgrt_poll_s
 {
   gpgrt_stream_t stream;
   unsigned int want_read:1;
   unsigned int want_write:1;
   unsigned int want_oob:1;
   unsigned int want_rdhup:1;
   unsigned int _reserv1:4;
   unsigned int got_read:1;
   unsigned int got_write:1;
   unsigned int got_oob:1;
   unsigned int got_rdhup:1;
   unsigned int _reserv2:4;
   unsigned int got_err:1;
   unsigned int got_hup:1;
   unsigned int got_nval:1;
   unsigned int _reserv3:4;
   unsigned int ignore:1;
   unsigned int user:8;       /* For application use.  */
 };
 typedef struct _gpgrt_poll_s gpgrt_poll_t;
 #ifdef GPGRT_ENABLE_ES_MACROS
 typedef struct _gpgrt_poll_s es_poll_t;
 #endif
 
 /* The type of the string filter function as used by fprintf_sf et al.  */
 typedef char *(*gpgrt_string_filter_t) (const char *s, int n, void *opaque);
 
 
 
 gpgrt_stream_t gpgrt_fopen (const char *_GPGRT__RESTRICT path,
                             const char *_GPGRT__RESTRICT mode);
 gpgrt_stream_t gpgrt_mopen (void *_GPGRT__RESTRICT data,
                             size_t data_n, size_t data_len,
                             unsigned int grow,
                             void *(*func_realloc) (void *mem, size_t size),
                             void (*func_free) (void *mem),
                             const char *_GPGRT__RESTRICT mode);
 gpgrt_stream_t gpgrt_fopenmem (size_t memlimit,
                                const char *_GPGRT__RESTRICT mode);
 gpgrt_stream_t gpgrt_fopenmem_init (size_t memlimit,
                                     const char *_GPGRT__RESTRICT mode,
                                     const void *data, size_t datalen);
 gpgrt_stream_t gpgrt_fdopen    (int filedes, const char *mode);
 gpgrt_stream_t gpgrt_fdopen_nc (int filedes, const char *mode);
 gpgrt_stream_t gpgrt_sysopen    (gpgrt_syshd_t *syshd, const char *mode);
 gpgrt_stream_t gpgrt_sysopen_nc (gpgrt_syshd_t *syshd, const char *mode);
 gpgrt_stream_t gpgrt_fpopen    (FILE *fp, const char *mode);
 gpgrt_stream_t gpgrt_fpopen_nc (FILE *fp, const char *mode);
 gpgrt_stream_t gpgrt_freopen (const char *_GPGRT__RESTRICT path,
                               const char *_GPGRT__RESTRICT mode,
                               gpgrt_stream_t _GPGRT__RESTRICT stream);
 gpgrt_stream_t gpgrt_fopencookie (void *_GPGRT__RESTRICT cookie,
                                   const char *_GPGRT__RESTRICT mode,
                                   gpgrt_cookie_io_functions_t functions);
 int gpgrt_fclose (gpgrt_stream_t stream);
 int gpgrt_fclose_snatch (gpgrt_stream_t stream,
                          void **r_buffer, size_t *r_buflen);
 int gpgrt_onclose (gpgrt_stream_t stream, int mode,
                    void (*fnc) (gpgrt_stream_t, void*), void *fnc_value);
 int gpgrt_fileno (gpgrt_stream_t stream);
 int gpgrt_fileno_unlocked (gpgrt_stream_t stream);
 int gpgrt_syshd (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
 int gpgrt_syshd_unlocked (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
 
 void _gpgrt_set_std_fd (int no, int fd);
 gpgrt_stream_t _gpgrt_get_std_stream (int fd);
 
 #define gpgrt_stdin  _gpgrt_get_std_stream (0)
 #define gpgrt_stdout _gpgrt_get_std_stream (1)
 #define gpgrt_stderr _gpgrt_get_std_stream (2)
 
 
 void gpgrt_flockfile (gpgrt_stream_t stream);
 int  gpgrt_ftrylockfile (gpgrt_stream_t stream);
 void gpgrt_funlockfile (gpgrt_stream_t stream);
 
 int gpgrt_feof (gpgrt_stream_t stream);
 int gpgrt_feof_unlocked (gpgrt_stream_t stream);
 int gpgrt_ferror (gpgrt_stream_t stream);
 int gpgrt_ferror_unlocked (gpgrt_stream_t stream);
 void gpgrt_clearerr (gpgrt_stream_t stream);
 void gpgrt_clearerr_unlocked (gpgrt_stream_t stream);
 
 int _gpgrt_pending (gpgrt_stream_t stream);          /* (private) */
 int _gpgrt_pending_unlocked (gpgrt_stream_t stream); /* (private) */
 
 #define gpgrt_pending(stream) _gpgrt_pending (stream)
 
 #define gpgrt_pending_unlocked(stream)				\
   (((!(stream)->flags.writing)					\
     && (((stream)->data_offset < (stream)->data_len)		\
         || ((stream)->unread_data_len)))                        \
    ? 1 : _gpgrt_pending_unlocked ((stream)))
 
 int gpgrt_fflush (gpgrt_stream_t stream);
 int gpgrt_fseek (gpgrt_stream_t stream, long int offset, int whence);
 int gpgrt_fseeko (gpgrt_stream_t stream, gpgrt_off_t offset, int whence);
 int gpgrt_ftruncate (gpgrt_stream_t stream, gpgrt_off_t length);
 long int gpgrt_ftell (gpgrt_stream_t stream);
 gpgrt_off_t gpgrt_ftello (gpgrt_stream_t stream);
 void gpgrt_rewind (gpgrt_stream_t stream);
 
 int gpgrt_fgetc (gpgrt_stream_t stream);
 int gpgrt_fputc (int c, gpgrt_stream_t stream);
 
 int _gpgrt_getc_underflow (gpgrt_stream_t stream);       /* (private) */
 int _gpgrt_putc_overflow (int c, gpgrt_stream_t stream); /* (private) */
 
 #define gpgrt_getc_unlocked(stream)				\
   (((!(stream)->flags.writing)					\
     && ((stream)->data_offset < (stream)->data_len)		\
     && (! (stream)->unread_data_len))				\
   ? ((int) (stream)->buffer[((stream)->data_offset)++])		\
   : _gpgrt_getc_underflow ((stream)))
 
 #define gpgrt_putc_unlocked(c, stream)				\
   (((stream)->flags.writing					\
     && ((stream)->data_offset < (stream)->buffer_size)		\
     && (c != '\n'))						\
   ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
   : _gpgrt_putc_overflow ((c), (stream)))
 
 #define gpgrt_getc(stream)    gpgrt_fgetc (stream)
 #define gpgrt_putc(c, stream) gpgrt_fputc (c, stream)
 
 int gpgrt_ungetc (int c, gpgrt_stream_t stream);
 
 int gpgrt_read (gpgrt_stream_t _GPGRT__RESTRICT stream,
                 void *_GPGRT__RESTRICT buffer, size_t bytes_to_read,
                 size_t *_GPGRT__RESTRICT bytes_read);
 int gpgrt_write (gpgrt_stream_t _GPGRT__RESTRICT stream,
                  const void *_GPGRT__RESTRICT buffer, size_t bytes_to_write,
                  size_t *_GPGRT__RESTRICT bytes_written);
 int gpgrt_write_sanitized (gpgrt_stream_t _GPGRT__RESTRICT stream,
                            const void *_GPGRT__RESTRICT buffer, size_t length,
                            const char *delimiters,
                            size_t *_GPGRT__RESTRICT bytes_written);
 int gpgrt_write_hexstring (gpgrt_stream_t _GPGRT__RESTRICT stream,
                            const void *_GPGRT__RESTRICT buffer, size_t length,
                            int reserved,
                            size_t *_GPGRT__RESTRICT bytes_written);
 
 size_t gpgrt_fread (void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems,
                     gpgrt_stream_t _GPGRT__RESTRICT stream);
 size_t gpgrt_fwrite (const void *_GPGRT__RESTRICT ptr, size_t size,
                      size_t nitems, gpgrt_stream_t _GPGRT__RESTRICT stream);
 
 char *gpgrt_fgets (char *_GPGRT__RESTRICT s, int n,
                    gpgrt_stream_t _GPGRT__RESTRICT stream);
 int gpgrt_fputs (const char *_GPGRT__RESTRICT s,
                  gpgrt_stream_t _GPGRT__RESTRICT stream);
 int gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s,
                           gpgrt_stream_t _GPGRT__RESTRICT stream);
 
 @api_ssize_t@ gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr,
                        size_t *_GPGRT__RESTRICT n,
                        gpgrt_stream_t stream);
 @api_ssize_t@ gpgrt_read_line (gpgrt_stream_t stream,
                          char **addr_of_buffer, size_t *length_of_buffer,
                          size_t *max_length);
 
 int gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
                    const char *_GPGRT__RESTRICT format, ...)
                    GPGRT_ATTR_PRINTF(2,3);
 int gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
                             const char *_GPGRT__RESTRICT format, ...)
                             GPGRT_ATTR_PRINTF(2,3);
 
 int gpgrt_fprintf_sf (gpgrt_stream_t _GPGRT__RESTRICT stream,
                       gpgrt_string_filter_t sf, void *sfvalue,
                       const char *_GPGRT__RESTRICT format,
                       ...) GPGRT_ATTR_PRINTF(4,5);
 int gpgrt_fprintf_sf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
                                gpgrt_string_filter_t sf, void *sfvalue,
                                const char *_GPGRT__RESTRICT format,
                                ...) GPGRT_ATTR_PRINTF(4,5);
 
 int gpgrt_printf (const char *_GPGRT__RESTRICT format, ...)
                   GPGRT_ATTR_PRINTF(1,2);
 int gpgrt_printf_unlocked (const char *_GPGRT__RESTRICT format, ...)
                            GPGRT_ATTR_PRINTF(1,2);
 
 int gpgrt_vfprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
                     const char *_GPGRT__RESTRICT format, va_list ap)
                     GPGRT_ATTR_PRINTF(2,0);
 int gpgrt_vfprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
                              const char *_GPGRT__RESTRICT format, va_list ap)
                              GPGRT_ATTR_PRINTF(2,0);
 
 int gpgrt_setvbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
                    char *_GPGRT__RESTRICT buf, int mode, size_t size);
 void gpgrt_setbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
                    char *_GPGRT__RESTRICT buf);
 
 void gpgrt_set_binary (gpgrt_stream_t stream);
 int  gpgrt_set_nonblock (gpgrt_stream_t stream, int onoff);
 int  gpgrt_get_nonblock (gpgrt_stream_t stream);
 
 int gpgrt_poll (gpgrt_poll_t *fdlist, unsigned int nfds, int timeout);
 
 gpgrt_stream_t gpgrt_tmpfile (void);
 
 void gpgrt_opaque_set (gpgrt_stream_t _GPGRT__RESTRICT stream,
                        void *_GPGRT__RESTRICT opaque);
 void *gpgrt_opaque_get (gpgrt_stream_t stream);
 
 void gpgrt_fname_set (gpgrt_stream_t stream, const char *fname);
 const char *gpgrt_fname_get (gpgrt_stream_t stream);
 
 int gpgrt_asprintf (char **r_buf, const char * _GPGRT__RESTRICT format, ...)
                     GPGRT_ATTR_PRINTF(2,3);
 int gpgrt_vasprintf (char **r_buf, const char * _GPGRT__RESTRICT format,
                      va_list ap)
                      GPGRT_ATTR_PRINTF(2,0);
 char *gpgrt_bsprintf (const char * _GPGRT__RESTRICT format, ...)
                       GPGRT_ATTR_PRINTF(1,2);
 char *gpgrt_vbsprintf (const char * _GPGRT__RESTRICT format, va_list ap)
                        GPGRT_ATTR_PRINTF(1,0);
 int gpgrt_snprintf (char *buf, size_t bufsize,
                     const char * _GPGRT__RESTRICT format, ...)
                     GPGRT_ATTR_PRINTF(3,4);
 int gpgrt_vsnprintf (char *buf,size_t bufsize,
                      const char * _GPGRT__RESTRICT format, va_list arg_ptr)
                      GPGRT_ATTR_PRINTF(3,0);
 
 
 #ifdef GPGRT_ENABLE_ES_MACROS
 # define es_fopen             gpgrt_fopen
 # define es_mopen             gpgrt_mopen
 # define es_fopenmem          gpgrt_fopenmem
 # define es_fopenmem_init     gpgrt_fopenmem_init
 # define es_fdopen            gpgrt_fdopen
 # define es_fdopen_nc         gpgrt_fdopen_nc
 # define es_sysopen           gpgrt_sysopen
 # define es_sysopen_nc        gpgrt_sysopen_nc
 # define es_fpopen            gpgrt_fpopen
 # define es_fpopen_nc         gpgrt_fpopen_nc
 # define es_freopen           gpgrt_freopen
 # define es_fopencookie       gpgrt_fopencookie
 # define es_fclose            gpgrt_fclose
 # define es_fclose_snatch     gpgrt_fclose_snatch
 # define es_onclose           gpgrt_onclose
 # define es_fileno            gpgrt_fileno
 # define es_fileno_unlocked   gpgrt_fileno_unlocked
 # define es_syshd             gpgrt_syshd
 # define es_syshd_unlocked    gpgrt_syshd_unlocked
 # define es_stdin             _gpgrt_get_std_stream (0)
 # define es_stdout            _gpgrt_get_std_stream (1)
 # define es_stderr            _gpgrt_get_std_stream (2)
 # define es_flockfile         gpgrt_flockfile
 # define es_ftrylockfile      gpgrt_ftrylockfile
 # define es_funlockfile       gpgrt_funlockfile
 # define es_feof              gpgrt_feof
 # define es_feof_unlocked     gpgrt_feof_unlocked
 # define es_ferror            gpgrt_ferror
 # define es_ferror_unlocked   gpgrt_ferror_unlocked
 # define es_clearerr          gpgrt_clearerr
 # define es_clearerr_unlocked gpgrt_clearerr_unlocked
 # define es_pending           gpgrt_pending
 # define es_pending_unlocked  gpgrt_pending_unlocked
 # define es_fflush            gpgrt_fflush
 # define es_fseek             gpgrt_fseek
 # define es_fseeko            gpgrt_fseeko
 # define es_ftruncate         gpgrt_ftruncate
 # define es_ftell             gpgrt_ftell
 # define es_ftello            gpgrt_ftello
 # define es_rewind            gpgrt_rewind
 # define es_fgetc             gpgrt_fgetc
 # define es_fputc             gpgrt_fputc
 # define es_getc_unlocked     gpgrt_getc_unlocked
 # define es_putc_unlocked     gpgrt_putc_unlocked
 # define es_getc              gpgrt_getc
 # define es_putc              gpgrt_putc
 # define es_ungetc            gpgrt_ungetc
 # define es_read              gpgrt_read
 # define es_write             gpgrt_write
 # define es_write_sanitized   gpgrt_write_sanitized
 # define es_write_hexstring   gpgrt_write_hexstring
 # define es_fread             gpgrt_fread
 # define es_fwrite            gpgrt_fwrite
 # define es_fgets             gpgrt_fgets
 # define es_fputs             gpgrt_fputs
 # define es_fputs_unlocked    gpgrt_fputs_unlocked
 # define es_getline           gpgrt_getline
 # define es_read_line         gpgrt_read_line
 # define es_free              gpgrt_free
 # define es_fprintf           gpgrt_fprintf
 # define es_fprintf_unlocked  gpgrt_fprintf_unlocked
 # define es_printf            gpgrt_printf
 # define es_printf_unlocked   gpgrt_printf_unlocked
 # define es_vfprintf          gpgrt_vfprintf
 # define es_vfprintf_unlocked gpgrt_vfprintf_unlocked
 # define es_setvbuf           gpgrt_setvbuf
 # define es_setbuf            gpgrt_setbuf
 # define es_set_binary        gpgrt_set_binary
 # define es_set_nonblock      gpgrt_set_nonblock
 # define es_get_nonblock      gpgrt_get_nonblock
 # define es_poll              gpgrt_poll
 # define es_tmpfile           gpgrt_tmpfile
 # define es_opaque_set        gpgrt_opaque_set
 # define es_opaque_get        gpgrt_opaque_get
 # define es_fname_set         gpgrt_fname_set
 # define es_fname_get         gpgrt_fname_get
 # define es_asprintf          gpgrt_asprintf
 # define es_vasprintf         gpgrt_vasprintf
 # define es_bsprintf          gpgrt_bsprintf
 # define es_vbsprintf         gpgrt_vbsprintf
 #endif /*GPGRT_ENABLE_ES_MACROS*/
 
 
 
 /*
  * Base64 encode and decode functions.
  */
 
 struct _gpgrt_b64state;
 typedef struct _gpgrt_b64state *gpgrt_b64state_t;
 
 gpgrt_b64state_t gpgrt_b64enc_start (gpgrt_stream_t stream, const char *title);
 gpg_err_code_t   gpgrt_b64enc_write (gpgrt_b64state_t state,
                                      const void *buffer, size_t nbytes);
 gpg_err_code_t   gpgrt_b64enc_finish (gpgrt_b64state_t state);
 
 gpgrt_b64state_t gpgrt_b64dec_start (const char *title);
 gpg_error_t      gpgrt_b64dec_proc (gpgrt_b64state_t state,
                                     void *buffer, size_t length,
                                     size_t *r_nbytes);
 gpg_error_t      gpgrt_b64dec_finish (gpgrt_b64state_t state);
 
 
 
 /*
  * Logging functions
  */
 
 /* Flag values for gpgrt_log_set_prefix. */
 #define GPGRT_LOG_WITH_PREFIX  1
 #define GPGRT_LOG_WITH_TIME    2
 #define GPGRT_LOG_WITH_PID     4
 #define GPGRT_LOG_RUN_DETACHED 256
 #define GPGRT_LOG_NO_REGISTRY  512
 
 /* Log levels as used by gpgrt_log.  */
 enum gpgrt_log_levels
   {
     GPGRT_LOGLVL_BEGIN,
     GPGRT_LOGLVL_CONT,
     GPGRT_LOGLVL_INFO,
     GPGRT_LOGLVL_WARN,
     GPGRT_LOGLVL_ERROR,
     GPGRT_LOGLVL_FATAL,
     GPGRT_LOGLVL_BUG,
     GPGRT_LOGLVL_DEBUG
   };
 
 
 /* The next 4 functions are not thread-safe - call them early.  */
 void gpgrt_log_set_sink (const char *name, gpgrt_stream_t stream, int fd);
 void gpgrt_log_set_socket_dir_cb (const char *(*fnc)(void));
 void gpgrt_log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value));
 void gpgrt_log_set_prefix (const char *text, unsigned int flags);
 
 int  gpgrt_get_errorcount (int clear);
 void gpgrt_inc_errorcount (void);
 const char *gpgrt_log_get_prefix (unsigned int *flags);
 int  gpgrt_log_test_fd (int fd);
 int  gpgrt_log_get_fd (void);
 gpgrt_stream_t gpgrt_log_get_stream (void);
 
 void gpgrt_log (int level, const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
 void gpgrt_logv (int level, const char *fmt, va_list arg_ptr);
 void gpgrt_logv_prefix (int level, const char *prefix,
                               const char *fmt, va_list arg_ptr);
 void gpgrt_log_string (int level, const char *string);
 void gpgrt_log_bug (const char *fmt, ...)    GPGRT_ATTR_NR_PRINTF(1,2);
 void gpgrt_log_fatal (const char *fmt, ...)  GPGRT_ATTR_NR_PRINTF(1,2);
 void gpgrt_log_error (const char *fmt, ...)  GPGRT_ATTR_PRINTF(1,2);
 void gpgrt_log_info (const char *fmt, ...)   GPGRT_ATTR_PRINTF(1,2);
 void gpgrt_log_debug (const char *fmt, ...)  GPGRT_ATTR_PRINTF(1,2);
 void gpgrt_log_debug_string (const char *string,
                              const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
 void gpgrt_log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
 void gpgrt_log_printhex (const void *buffer, size_t length,
                          const char *fmt, ...) GPGRT_ATTR_PRINTF(3,4);
 void gpgrt_log_clock (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
 void gpgrt_log_flush (void);
 void _gpgrt_log_assert (const char *expr, const char *file, int line,
                         const char *func) GPGRT_ATTR_NORETURN;
 
 #ifdef GPGRT_HAVE_MACRO_FUNCTION
 # define gpgrt_assert(expr)                                     \
   ((expr)                                                       \
    ? (void) 0                                                   \
    : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
 #else /*!GPGRT_HAVE_MACRO_FUNCTION*/
 # define gpgrt_assert(expr)                                     \
   ((expr)                                                       \
    ? (void) 0                                                   \
    : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL))
 #endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
 
 #ifdef GPGRT_ENABLE_LOG_MACROS
 # define log_get_errorcount      gpgrt_get_errorcount
 # define log_inc_errorcount      gpgrt_inc_errorcount
 # define log_set_file(a)         gpgrt_log_set_sink ((a), NULL, -1)
 # define log_set_fd(a)           gpgrt_log_set_sink (NULL, NULL, (a))
 # define log_set_stream(a)       gpgrt_log_set_sink (NULL, (a), -1)
 # define log_set_socket_dir_cb   gpgrt_log_set_socket_dir_cb
 # define log_set_pid_suffix_cb   gpgrt_log_set_pid_suffix_cb
 # define log_set_prefix          gpgrt_log_set_prefix
 # define log_get_prefix          gpgrt_log_get_prefix
 # define log_test_fd             gpgrt_log_test_fd
 # define log_get_fd              gpgrt_log_get_fd
 # define log_get_stream          gpgrt_log_get_stream
 # define log_log                 gpgrt_log
 # define log_logv                gpgrt_logv
 # define log_logv_prefix         gpgrt_logv_prefix
 # define log_string              gpgrt_log_string
 # define log_bug                 gpgrt_log_bug
 # define log_fatal               gpgrt_log_fatal
 # define log_error               gpgrt_log_error
 # define log_info                gpgrt_log_info
 # define log_debug               gpgrt_log_debug
 # define log_debug_string        gpgrt_log_debug_string
 # define log_printf              gpgrt_log_printf
 # define log_printhex            gpgrt_log_printhex
 # define log_clock               gpgrt_log_clock
 # define log_flush               gpgrt_log_flush
 # ifdef GPGRT_HAVE_MACRO_FUNCTION
 #  define log_assert(expr)                                      \
   ((expr)                                                       \
    ? (void) 0                                                   \
    : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
 # else /*!GPGRT_HAVE_MACRO_FUNCTION*/
 #  define log_assert(expr)                                      \
   ((expr)                                                       \
    ? (void) 0                                                   \
    : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL))
 # endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
 
 #endif /*GPGRT_ENABLE_LOG_MACROS*/
 
 
 /*
  * Spawn functions  (Not yet available)
  */
 #define GPGRT_SPAWN_NONBLOCK   16 /* Set the streams to non-blocking.      */
 #define GPGRT_SPAWN_RUN_ASFW   64 /* Use AllowSetForegroundWindow on W32.  */
 #define GPGRT_SPAWN_DETACHED  128 /* Start the process in the background.  */
 
 #if 0
 
 /* Function and convenience macros to create pipes.  */
 gpg_err_code_t gpgrt_make_pipe (int filedes[2], gpgrt_stream_t *r_fp,
                                 int direction, int nonblock);
 #define gpgrt_create_pipe(a)              gpgrt_make_pipe ((a),NULL,  0,  0);
 #define gpgrt_create_inbound_pipe(a,b,c)  gpgrt_make_pipe ((a), (b), -1,(c));
 #define gpgrt_create_outbound_pipe(a,b,c) gpgrt_make_pipe ((a), (b),  1,(c));
 
 
 /* Fork and exec PGMNAME.  */
 gpg_err_code_t gpgrt_spawn_process (const char *pgmname, const char *argv[],
                                     int *execpt, void (*preexec)(void),
                                     unsigned int flags,
                                     gpgrt_stream_t *r_infp,
                                     gpgrt_stream_t *r_outfp,
                                     gpgrt_stream_t *r_errfp,
                                     pid_t *pid);
 
 /* Fork and exec PGNNAME and connect the process to the given FDs.  */
 gpg_err_code_t gpgrt_spawn_process_fd (const char *pgmname, const char *argv[],
                                        int infd, int outfd, int errfd,
                                        pid_t *pid);
 
 /* Fork and exec PGMNAME as a detached process.  */
 gpg_err_code_t gpgrt_spawn_process_detached (const char *pgmname,
                                              const char *argv[],
                                              const char *envp[] );
 
 /* Wait for a single process.  */
 gpg_err_code_t gpgrt_wait_process (const char *pgmname, pid_t pid, int hang,
                                 int *r_exitcode);
 
 /* Wait for a multiple processes.  */
 gpg_err_code_t gpgrt_wait_processes (const char **pgmnames, pid_t *pids,
                                      size_t count, int hang, int *r_exitcodes);
 
 /* Kill the process identified by PID.  */
 void gpgrt_kill_process (pid_t pid);
 
 /* Release process resources identified by PID.  */
 void gpgrt_release_process (pid_t pid);
 
 #endif /*0*/
 
 
 
 /*
  * Option parsing.
  */
 
 struct _gpgrt_argparse_internal_s;
 typedef struct
 {
   int  *argc;	      /* Pointer to ARGC (value subject to change). */
   char ***argv;	      /* Pointer to ARGV (value subject to change). */
   unsigned int flags; /* Global flags.  May be set prior to calling the
                          parser.  The parser may change the value.  */
   int err;            /* Print error description for last option.
                          Either 0,  ARGPARSE_PRINT_WARNING or
                          ARGPARSE_PRINT_ERROR.  */
   unsigned int lineno;/* The current line number.  */
   int r_opt; 	      /* Returns option code. */
   int r_type;	      /* Returns type of option value.  */
   union {
     int   ret_int;
     long  ret_long;
     unsigned long ret_ulong;
     char *ret_str;
   } r;		      /* Return values */
 
   struct _gpgrt_argparse_internal_s *internal;
 } gpgrt_argparse_t;
 
 
 typedef struct
 {
   int          short_opt;
   const char  *long_opt;
   unsigned int flags;
   const char  *description; /* Optional description. */
 } gpgrt_opt_t;
 
 
 #ifdef GPGRT_ENABLE_ARGPARSE_MACROS
 
 /* Global flags for (gpgrt_argparse_t).flags.  */
 #define ARGPARSE_FLAG_KEEP        1  /* Do not remove options form argv.     */
 #define ARGPARSE_FLAG_ALL         2  /* Do not stop at last option but return
                                         remaining args with R_OPT set to -1. */
 #define ARGPARSE_FLAG_MIXED       4  /* Assume options and args are mixed.   */
 #define ARGPARSE_FLAG_NOSTOP      8  /* Do not stop processing at "--".      */
 #define ARGPARSE_FLAG_ARG0       16  /* Do not skip the first arg.           */
 #define ARGPARSE_FLAG_ONEDASH    32  /* Allow long options with one dash.    */
 #define ARGPARSE_FLAG_NOVERSION  64  /* No output for "--version".           */
 #define ARGPARSE_FLAG_RESET     128  /* Request to reset the internal state. */
 #define ARGPARSE_FLAG_STOP_SEEN 256  /* Set to true if a "--" has been seen. */
-#define ARGPARSE_FLAG_NOLINENO  512  /* Do not zero the lineno field.         */
+#define ARGPARSE_FLAG_NOLINENO  512  /* Do not zero the lineno field.        */
+#define ARGPARSE_FLAG_SYS      1024  /* Use system config file.              */
+#define ARGPARSE_FLAG_USER     2048  /* Use user config file.                */
+#define ARGPARSE_FLAG_VERBOSE  4096  /* Print additional argparser info.     */
 
 /* Constants for (gpgrt_argparse_t).err.  */
 #define ARGPARSE_PRINT_WARNING  1    /* Print a diagnostic.                  */
 #define ARGPARSE_PRINT_ERROR    2    /* Print a diagnostic and call exit.    */
 
 /* Special return values of gpgrt_argparse.  */
 #define ARGPARSE_IS_ARG            (-1)
 #define ARGPARSE_INVALID_OPTION    (-2)
 #define ARGPARSE_MISSING_ARG       (-3)
 #define ARGPARSE_KEYWORD_TOO_LONG  (-4)
 #define ARGPARSE_READ_ERROR        (-5)
 #define ARGPARSE_UNEXPECTED_ARG    (-6)
 #define ARGPARSE_INVALID_COMMAND   (-7)
 #define ARGPARSE_AMBIGUOUS_OPTION  (-8)
 #define ARGPARSE_AMBIGUOUS_COMMAND (-9)
 #define ARGPARSE_INVALID_ALIAS     (-10)
 #define ARGPARSE_OUT_OF_CORE       (-11)
 #define ARGPARSE_INVALID_ARG       (-12)
+#define ARGPARSE_NO_CONFFILE       (-14)
+#define ARGPARSE_CONFFILE          (-15)
 
 /* Flags for the option descriptor (gpgrt_opt_t)->flags.  Note that
  * a TYPE constant may be or-ed with the OPT constants.  */
 #define ARGPARSE_TYPE_NONE        0  /* Does not take an argument.        */
 #define ARGPARSE_TYPE_INT         1  /* Takes an int argument.            */
 #define ARGPARSE_TYPE_STRING      2  /* Takes a string argument.          */
 #define ARGPARSE_TYPE_LONG        3  /* Takes a long argument.            */
 #define ARGPARSE_TYPE_ULONG       4  /* Takes an unsigned long argument.  */
 #define ARGPARSE_OPT_OPTIONAL (1<<3) /* Argument is optional.             */
 #define ARGPARSE_OPT_PREFIX   (1<<4) /* Allow 0x etc. prefixed values.    */
 #define ARGPARSE_OPT_IGNORE   (1<<6) /* Ignore command or option.         */
 #define ARGPARSE_OPT_COMMAND  (1<<7) /* The argument is a command.        */
+#define ARGPARSE_OPT_CONFFILE (1<<8) /* The value is a conffile.          */
 
 /* A set of macros to make option definitions easier to read.  */
 #define ARGPARSE_x(s,l,t,f,d) \
      { (s), (l), ARGPARSE_TYPE_ ## t | (f), (d) }
 
 #define ARGPARSE_s(s,l,t,d) \
      { (s), (l), ARGPARSE_TYPE_ ## t, (d) }
 #define ARGPARSE_s_n(s,l,d) \
      { (s), (l), ARGPARSE_TYPE_NONE, (d) }
 #define ARGPARSE_s_i(s,l,d) \
      { (s), (l), ARGPARSE_TYPE_INT, (d) }
 #define ARGPARSE_s_s(s,l,d) \
      { (s), (l), ARGPARSE_TYPE_STRING, (d) }
 #define ARGPARSE_s_l(s,l,d) \
      { (s), (l), ARGPARSE_TYPE_LONG, (d) }
 #define ARGPARSE_s_u(s,l,d) \
      { (s), (l), ARGPARSE_TYPE_ULONG, (d) }
 
 #define ARGPARSE_o(s,l,t,d) \
      { (s), (l), (ARGPARSE_TYPE_ ## t  | ARGPARSE_OPT_OPTIONAL), (d) }
 #define ARGPARSE_o_n(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_NONE   | ARGPARSE_OPT_OPTIONAL), (d) }
 #define ARGPARSE_o_i(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_INT    | ARGPARSE_OPT_OPTIONAL), (d) }
 #define ARGPARSE_o_s(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_OPTIONAL), (d) }
 #define ARGPARSE_o_l(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_LONG   | ARGPARSE_OPT_OPTIONAL), (d) }
 #define ARGPARSE_o_u(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_ULONG  | ARGPARSE_OPT_OPTIONAL), (d) }
 
 #define ARGPARSE_p(s,l,t,d) \
      { (s), (l), (ARGPARSE_TYPE_ ## t  | ARGPARSE_OPT_PREFIX), (d) }
 #define ARGPARSE_p_n(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_NONE   | ARGPARSE_OPT_PREFIX), (d) }
 #define ARGPARSE_p_i(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_INT    | ARGPARSE_OPT_PREFIX), (d) }
 #define ARGPARSE_p_s(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_PREFIX), (d) }
 #define ARGPARSE_p_l(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_LONG   | ARGPARSE_OPT_PREFIX), (d) }
 #define ARGPARSE_p_u(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_ULONG  | ARGPARSE_OPT_PREFIX), (d) }
 
 #define ARGPARSE_op(s,l,t,d) \
      { (s), (l), (ARGPARSE_TYPE_ ## t \
                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
 #define ARGPARSE_op_n(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_NONE \
                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
 #define ARGPARSE_op_i(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_INT \
                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
 #define ARGPARSE_op_s(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_STRING \
                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
 #define ARGPARSE_op_l(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_LONG \
                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
 #define ARGPARSE_op_u(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_ULONG \
                   | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
 
 #define ARGPARSE_c(s,l,d) \
      { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_COMMAND), (d) }
 
-#define ARGPARSE_ignore(s,l) \
+#define ARGPARSE_conffile(s,l,d) \
+  { (s), (l), (ARGPARSE_TYPE_STRING|ARGPARSE_OPT_CONFFILE), (d) }
+
+#define ARGPARSE_noconffile(s,l,d) \
+  { (s), (l), (ARGPARSE_TYPE_NONE|ARGPARSE_OPT_CONFFILE), (d) }
+
+#define ARGPARSE_ignore(s,l)                    \
      { (s), (l), (ARGPARSE_OPT_IGNORE), "@" }
 
 #define ARGPARSE_group(s,d) \
      { (s), NULL, 0, (d) }
 
 /* Mark the end of the list (mandatory).  */
 #define ARGPARSE_end() \
      { 0, NULL, 0, NULL }
 
 #endif /* GPGRT_ENABLE_ARGPARSE_MACROS */
 
+/* Values used for gpgrt_set_confdir.  */
+#define GPGRT_CONFDIR_USER 1   /* The user's configuration dir.    */
+#define GPGRT_CONFDIR_SYS  2   /* The systems's configuration dir. */
+
 /* Take care: gpgrt_argparse keeps state in ARG and requires that
  * either ARGPARSE_FLAG_RESET is used after OPTS has been changed or
  * gpgrt_argparse (NULL, ARG, NULL) is called first.  */
 int gpgrt_argparse (gpgrt_stream_t fp,
                     gpgrt_argparse_t *arg, gpgrt_opt_t *opts);
+int gpgrt_argparser (gpgrt_argparse_t *arg, gpgrt_opt_t *opts,
+                     const char *confname);
 void gpgrt_usage (int level);
 const char *gpgrt_strusage (int level);
 void gpgrt_set_strusage (const char *(*f)(int));
 void gpgrt_set_usage_outfnc (int (*f)(int, const char *));
 void gpgrt_set_fixed_string_mapper (const char *(*f)(const char*));
+void gpgrt_set_confdir (int what, const char *name);
 
 
 /*
  * Various helper functions
  */
 
 /* Compare arbitrary version strings.  For the standard m.n.o version
  * numbering scheme a LEVEL of 3 is suitable; see the manual.  */
 int gpgrt_cmp_version (const char *a, const char *b, int level);
 
 /* Construct a filename from the NULL terminated list of parts.  Tilde
  * expansion is done for the first argument.  The caller must release
  * the result using gpgrt_free; on error ERRNO is set and NULL
  * returned.  The second function returns an absolute filename.  */
 char *gpgrt_fnameconcat (const char *first, ...) GPGRT_ATTR_SENTINEL(0);
 char *gpgrt_absfnameconcat (const char *first, ...) GPGRT_ATTR_SENTINEL(0);
 
 
 #ifdef __cplusplus
 }
 #endif
 #endif	/* GPGRT_H */
 #endif	/* GPG_ERROR_H */
diff --git a/src/gpg-error.vers b/src/gpg-error.vers
index 594342b..347235f 100644
--- a/src/gpg-error.vers
+++ b/src/gpg-error.vers
@@ -1,207 +1,209 @@
 # libgpg-error.vers - What symbols to export           -*- std -*-
 # Copyright (C) 2014 g10 Code GmbH
 #
 # This file is part of libgpg-error.
 #
 # libgpg-error is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as
 # published by the Free Software Foundation; either version 2.1 of the
 # License, or (at your option) any later version.
 #
 # libgpg-error is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with this program; if not, see <https://www.gnu.org/licenses/>.
 # SPDX-License-Identifier: LGPL-2.1+
 #
 # NOTE: When adding new functions, please make sure to add them to
 #       visibility.h and gpg-error.def.in as well.
 
 
 GPG_ERROR_1.0 {
   global:
     gpg_strerror;
     gpg_strerror_r;
     gpg_strsource;
     gpg_err_code_from_errno;
     gpg_err_code_to_errno;
     gpg_err_code_from_syserror;
     gpg_err_set_errno;
     gpg_error_check_version;
 
     gpgrt_lock_init;
     gpgrt_lock_lock;
     gpgrt_lock_unlock;
     gpgrt_lock_destroy;
     gpgrt_yield;
     gpgrt_lock_trylock;
 
     gpgrt_set_syscall_clamp;
     gpgrt_get_syscall_clamp;
 
     gpgrt_fopen;
     gpgrt_mopen;
     gpgrt_fopenmem;
     gpgrt_fopenmem_init;
     gpgrt_fdopen;
     gpgrt_fdopen_nc;
     gpgrt_sysopen;
     gpgrt_sysopen_nc;
     gpgrt_fpopen;
     gpgrt_fpopen_nc;
     gpgrt_freopen;
     gpgrt_fopencookie;
     gpgrt_fclose;
     gpgrt_fclose_snatch;
     gpgrt_onclose;
     gpgrt_fileno;
     gpgrt_fileno_unlocked;
     gpgrt_syshd;
     gpgrt_syshd_unlocked;
     _gpgrt_set_std_fd;
     _gpgrt_get_std_stream;
     gpgrt_flockfile;
     gpgrt_ftrylockfile;
     gpgrt_funlockfile;
     _gpgrt_pending;
     _gpgrt_pending_unlocked;
     gpgrt_feof;
     gpgrt_feof_unlocked;
     gpgrt_ferror;
     gpgrt_ferror_unlocked;
     gpgrt_clearerr;
     gpgrt_clearerr_unlocked;
     gpgrt_fflush;
     gpgrt_fseek;
     gpgrt_fseeko;
     gpgrt_ftell;
     gpgrt_ftello;
     gpgrt_rewind;
     gpgrt_fgetc;
     _gpgrt_getc_underflow;
     gpgrt_fputc;
     _gpgrt_putc_overflow;
     gpgrt_ungetc;
     gpgrt_read;
     gpgrt_write;
     gpgrt_write_sanitized;
     gpgrt_write_hexstring;
     gpgrt_fread;
     gpgrt_fwrite;
     gpgrt_fgets;
     gpgrt_fputs;
     gpgrt_fputs_unlocked;
     gpgrt_getline;
     gpgrt_read_line;
     gpgrt_free;
     gpgrt_fprintf;
     gpgrt_fprintf_unlocked;
     gpgrt_printf;
     gpgrt_printf_unlocked;
     gpgrt_vfprintf;
     gpgrt_vfprintf_unlocked;
     gpgrt_setvbuf;
     gpgrt_setbuf;
     gpgrt_set_binary;
     gpgrt_set_nonblock;
     gpgrt_get_nonblock;
     gpgrt_poll;
     gpgrt_tmpfile;
     gpgrt_opaque_set;
     gpgrt_opaque_get;
     gpgrt_fname_set;
     gpgrt_fname_get;
 
     gpgrt_asprintf;
     gpgrt_vasprintf;
     gpgrt_bsprintf;
     gpgrt_vbsprintf;
     gpgrt_snprintf;
     gpgrt_vsnprintf;
 
     gpgrt_check_version;
     gpg_err_init;
     gpg_err_deinit;
     gpgrt_set_alloc_func;
 
     gpgrt_b64dec_start;
     gpgrt_b64dec_proc;
     gpgrt_b64dec_finish;
 
     gpgrt_get_errorcount;
     gpgrt_inc_errorcount;
     gpgrt_log_set_sink;
     gpgrt_log_set_socket_dir_cb;
     gpgrt_log_set_pid_suffix_cb;
     gpgrt_log_set_prefix;
     gpgrt_log_get_prefix;
     gpgrt_log_test_fd;
     gpgrt_log_get_fd;
     gpgrt_log_get_stream;
     gpgrt_log;
     gpgrt_logv;
     gpgrt_logv_prefix;
     gpgrt_log_string;
     gpgrt_log_bug;
     gpgrt_log_fatal;
     gpgrt_log_error;
     gpgrt_log_info;
     gpgrt_log_debug;
     gpgrt_log_debug_string;
     gpgrt_log_printf;
     gpgrt_log_printhex;
     gpgrt_log_clock;
     gpgrt_log_flush;
     _gpgrt_log_assert;
 
     gpgrt_realloc;
     gpgrt_malloc;
     gpgrt_calloc;
     gpgrt_strdup;
     gpgrt_strconcat;
 
     gpgrt_getenv;
     gpgrt_setenv;
     gpgrt_mkdir;
     gpgrt_chdir;
     gpgrt_getcwd;
 
 ## API not yet finished for:
 #    gpgrt_make_pipe;
 #    gpgrt_spawn_process;
 #    gpgrt_spawn_process_fd;
 #    gpgrt_spawn_process_detached;
 #    gpgrt_wait_process;
 #    gpgrt_wait_processes;
 #    gpgrt_kill_process;
 #    gpgrt_release_process;
 
     gpgrt_argparse;
+    gpgrt_argparser;
     gpgrt_usage;
     gpgrt_strusage;
     gpgrt_set_strusage;
     gpgrt_set_usage_outfnc;
     gpgrt_set_fixed_string_mapper;
+    gpgrt_set_confdir;
 
     gpgrt_b64enc_start;
     gpgrt_b64enc_write;
     gpgrt_b64enc_finish;
 
     gpgrt_cmp_version;
 
     gpgrt_ftruncate;
     gpgrt_fprintf_sf;
     gpgrt_fprintf_sf_unlocked;
 
     gpgrt_add_emergency_cleanup;
     gpgrt_abort;
 
     gpgrt_fnameconcat;
     gpgrt_absfnameconcat;
 
   local:
     *;
 };
diff --git a/src/gpgrt-int.h b/src/gpgrt-int.h
index 97f0533..beb55ac 100644
--- a/src/gpgrt-int.h
+++ b/src/gpgrt-int.h
@@ -1,831 +1,834 @@
 /* gpgrt-int.h - Internal definitions
  * Copyright (C) 2014, 2017 g10 Code GmbH
  *
  * This file is part of libgpg-error.
  *
  * libgpg-error is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * libgpg-error is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, see <https://www.gnu.org/licenses/>.
  * SPDX-License-Identifier: LGPL-2.1+
  */
 
 #ifndef _GPGRT_GPGRT_INT_H
 #define _GPGRT_GPGRT_INT_H
 
 #include "gpg-error.h"
 #include "visibility.h"
 
 /*
  * Internal i18n macros.
  */
 #ifdef ENABLE_NLS
 # ifdef HAVE_W32_SYSTEM
 #  include "gettext.h"
 # else
 #  include <libintl.h>
 # endif
 # define _(a) gettext (a)
 # ifdef gettext_noop
 #  define N_(a) gettext_noop (a)
 # else
 #  define N_(a) (a)
 # endif
 #else  /*!ENABLE_NLS*/
 # define _(a) (a)
 # define N_(a) (a)
 #endif /*!ENABLE_NLS */
 
 
 /*
  * Hacks mainly required for Slowaris.
  */
 #ifdef _GPGRT_NEED_AFLOCAL
 # ifndef HAVE_W32_SYSTEM
 #  include <sys/socket.h>
 #  include <sys/un.h>
 # else
 #  ifdef HAVE_WINSOCK2_H
 #   include <winsock2.h>
 #  endif
 # include <windows.h>
 # endif
 
 # ifndef PF_LOCAL
 #  ifdef PF_UNIX
 #   define PF_LOCAL PF_UNIX
 #  else
 #   define PF_LOCAL AF_UNIX
 #  endif
 # endif /*PF_LOCAL*/
 # ifndef AF_LOCAL
 #  define AF_LOCAL AF_UNIX
 # endif /*AF_UNIX*/
 
 /* We used to avoid this macro in GnuPG and inlined the AF_LOCAL name
  * length computation directly with the little twist of adding 1 extra
  * byte.  It seems that this was needed once on an old HP/UX box and
  * there are also rumours that 4.3 Reno and DEC systems need it.  This
  * one-off buglet did not harm any current system until it came to Mac
  * OS X where the kernel (as of May 2009) exhibited a strange bug: The
  * systems basically froze in the connect call if the passed name
  * contained an invalid directory part.  Ignore the old Unices.  */
 # ifndef SUN_LEN
 #  define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
                         + strlen ((ptr)->sun_path))
 # endif /*SUN_LEN*/
 #endif /*_GPGRT_NEED_AFLOCAL*/
 
 
 /*
  * Common helper macros.
  */
 #ifndef DIM
 # define DIM(array) (sizeof (array) / sizeof (*array))
 #endif
 
 
 
 /*
  * Local error function prototypes.
  */
 const char *_gpg_strerror (gpg_error_t err);
 int _gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
 const char *_gpg_strsource (gpg_error_t err);
 gpg_err_code_t _gpg_err_code_from_errno (int err);
 int _gpg_err_code_to_errno (gpg_err_code_t code);
 gpg_err_code_t _gpg_err_code_from_syserror (void);
 void _gpg_err_set_errno (int err);
 
 gpg_error_t _gpg_err_init (void);
 void _gpg_err_deinit (int mode);
 
 void _gpgrt_add_emergency_cleanup (void (*f)(void));
 void _gpgrt_abort (void) GPGRT_ATTR_NORETURN;
 
 void _gpgrt_set_alloc_func (void *(*f)(void *a, size_t n));
 
 void *_gpgrt_realloc (void *a, size_t n);
 void *_gpgrt_malloc (size_t n);
 void *_gpgrt_calloc (size_t n, size_t m);
 char *_gpgrt_strdup (const char *string);
 char *_gpgrt_strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
 void _gpgrt_free (void *a);
 /* The next is only to be used by visibility.c.  */
 char *_gpgrt_strconcat_core (const char *s1, va_list arg_ptr);
 
 #define xfree(a)         _gpgrt_free ((a))
 #define xtrymalloc(a)    _gpgrt_malloc ((a))
 #define xtrycalloc(a,b)  _gpgrt_calloc ((a),(b))
 #define xtryrealloc(a,b) _gpgrt_realloc ((a),(b))
 #define xtrystrdup(a)    _gpgrt_strdup ((a))
 
 void _gpgrt_pre_syscall (void);
 void _gpgrt_post_syscall (void);
 
 const char *_gpg_error_check_version (const char *req_version);
 
 gpg_err_code_t _gpgrt_lock_init (gpgrt_lock_t *lockhd);
 gpg_err_code_t _gpgrt_lock_lock (gpgrt_lock_t *lockhd);
 gpg_err_code_t _gpgrt_lock_trylock (gpgrt_lock_t *lockhd);
 gpg_err_code_t _gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
 gpg_err_code_t _gpgrt_lock_destroy (gpgrt_lock_t *lockhd);
 gpg_err_code_t _gpgrt_yield (void);
 
 
 
 /*
  * Tracing
  */
 
 /* The trace macro is used this way:
  *   trace (("enter - foo=%d bar=%s", foo, bar));
  * Note the double parenthesis, they are important.
  * To append the current errno to the output, use
  *   trace_errno (EXTPR,("leave - baz=%d", faz));
  * If EXPR evaluates to true the output of strerror (errno)
  * is appended to the output.  Note that the trace function does
  * not modify ERRNO.  To enable tracing you need to have this
  *  #define ENABLE_TRACING "modulename"
  * before you include gpgrt-int.h.
  */
 #ifdef ENABLE_TRACING
 # define trace(X) do { \
                        _gpgrt_internal_trace_begin \
                          (ENABLE_TRACING, __func__, __LINE__, 0); \
                        _gpgrt_internal_trace X; \
                        _gpgrt_internal_trace_end (); \
                      } while (0)
 # define trace_errno(C,X) do {                     \
                        _gpgrt_internal_trace_begin \
                          (ENABLE_TRACING, __func__, __LINE__, (C)); \
                        _gpgrt_internal_trace X;      \
                        _gpgrt_internal_trace_end (); \
                      } while (0)
 # define trace_start(X) do { \
                        _gpgrt_internal_trace_begin \
                          (ENABLE_TRACING, __func__, __LINE__, 0); \
                        _gpgrt_internal_trace_printf X; \
                      } while (0)
 # define trace_append(X) do { \
                        _gpgrt_internal_trace_printf X; \
                      } while (0)
 # define trace_finish(X) do { \
                        _gpgrt_internal_trace_printf X; \
                        _gpgrt_internal_trace_end (); \
                      } while (0)
 #else
 # define trace(X) do { } while (0)
 # define trace_errno(C,X) do { } while (0)
 # define trace_start(X) do { } while (0)
 # define trace_append(X) do { } while (0)
 # define trace_finish(X) do { } while (0)
 #endif /*!ENABLE_TRACING*/
 
 void _gpgrt_internal_trace_begin (const char *mod, const char *file, int line,
                                   int with_errno);
 void _gpgrt_internal_trace (const char *format,
                             ...) GPGRT_ATTR_PRINTF(1,2);
 void _gpgrt_internal_trace_printf (const char *format,
                                    ...) GPGRT_ATTR_PRINTF(1,2);
 void _gpgrt_internal_trace_end (void);
 
 
 
 /*
  * Local definitions for estream.
  */
 
 #if HAVE_W32_SYSTEM
 # ifndef  O_NONBLOCK
 #  define O_NONBLOCK  0x40000000	/* FIXME: Is that safe?  */
 # endif
 #endif
 
 /*
  * A private cookie function to implement an internal IOCTL service.
  */
 typedef int (*cookie_ioctl_function_t) (void *cookie, int cmd,
 					void *ptr, size_t *len);
 #define COOKIE_IOCTL_SNATCH_BUFFER 1
 #define COOKIE_IOCTL_NONBLOCK      2
 #define COOKIE_IOCTL_TRUNCATE      3
 
 /* An internal variant of gpgrt_cookie_close_function_t with a slot
  * for the ioctl function.  */
 struct cookie_io_functions_s
 {
   struct _gpgrt_cookie_io_functions public;
   cookie_ioctl_function_t func_ioctl;
 };
 
 typedef enum
   {
     BACKEND_MEM,
     BACKEND_FD,
     BACKEND_W32,
     BACKEND_FP,
     BACKEND_USER,
     BACKEND_W32_POLLABLE
   } gpgrt_stream_backend_kind_t;
 
 
 /*
  * A type to hold notification functions.
  */
 struct notify_list_s
 {
   struct notify_list_s *next;
   void (*fnc) (estream_t, void*); /* The notification function.  */
   void *fnc_value;                /* The value to be passed to FNC.  */
 };
 typedef struct notify_list_s *notify_list_t;
 
 
 /*
  * Buffer management layer.
  */
 
 /* BUFSIZ on Windows is 512 but on current Linux it is 8k.  We better
  * use the 8k for Windows as well.  */
 #ifdef HAVE_W32_SYSTEM
 # define BUFFER_BLOCK_SIZE  8192
 #else
 # define BUFFER_BLOCK_SIZE  BUFSIZ
 #endif
 #define BUFFER_UNREAD_SIZE 16
 
 
 /*
  * The private object describing a stream.
  */
 struct _gpgrt_stream_internal
 {
   unsigned char buffer[BUFFER_BLOCK_SIZE];
   unsigned char unread_buffer[BUFFER_UNREAD_SIZE];
 
   gpgrt_lock_t lock;		 /* Lock.  Used by *_stream_lock(). */
 
   gpgrt_stream_backend_kind_t kind;
   void *cookie;			 /* Cookie.                */
   void *opaque;			 /* Opaque data.           */
   unsigned int modeflags;	 /* Flags for the backend. */
   char *printable_fname;         /* Malloced filename for es_fname_get.  */
   gpgrt_off_t offset;
   gpgrt_cookie_read_function_t  func_read;
   gpgrt_cookie_write_function_t func_write;
   gpgrt_cookie_seek_function_t  func_seek;
   gpgrt_cookie_close_function_t func_close;
   cookie_ioctl_function_t func_ioctl;
   int strategy;
   es_syshd_t syshd;              /* A copy of the system handle.  */
   struct
   {
     unsigned int err: 1;
     unsigned int eof: 1;
     unsigned int hup: 1;
   } indicators;
   unsigned int deallocate_buffer: 1;
   unsigned int is_stdstream:1;   /* This is a standard stream.  */
   unsigned int stdstream_fd:2;   /* 0, 1 or 2 for a standard stream.  */
   unsigned int printable_fname_inuse: 1;  /* es_fname_get has been used.  */
   unsigned int samethread: 1;    /* The "samethread" mode keyword.  */
   size_t print_ntotal;           /* Bytes written from in print_writer. */
   notify_list_t onclose;         /* On close notify function list.  */
 };
 typedef struct _gpgrt_stream_internal *estream_internal_t;
 
 
 /*
  * Local prototypes for estream.
  */
 int _gpgrt_estream_init (void);
 void _gpgrt_set_syscall_clamp (void (*pre)(void), void (*post)(void));
 void _gpgrt_get_syscall_clamp (void (**r_pre)(void), void (**r_post)(void));
 
 gpgrt_stream_t _gpgrt_fopen (const char *_GPGRT__RESTRICT path,
                              const char *_GPGRT__RESTRICT mode);
 gpgrt_stream_t _gpgrt_mopen (void *_GPGRT__RESTRICT data,
                              size_t data_n, size_t data_len,
                              unsigned int grow,
                              void *(*func_realloc) (void *mem, size_t size),
                              void (*func_free) (void *mem),
                              const char *_GPGRT__RESTRICT mode);
 gpgrt_stream_t _gpgrt_fopenmem (size_t memlimit,
                                 const char *_GPGRT__RESTRICT mode);
 gpgrt_stream_t _gpgrt_fopenmem_init (size_t memlimit,
                                      const char *_GPGRT__RESTRICT mode,
                                      const void *data, size_t datalen);
 gpgrt_stream_t _gpgrt_fdopen    (int filedes, const char *mode);
 gpgrt_stream_t _gpgrt_fdopen_nc (int filedes, const char *mode);
 gpgrt_stream_t _gpgrt_sysopen    (gpgrt_syshd_t *syshd, const char *mode);
 gpgrt_stream_t _gpgrt_sysopen_nc (gpgrt_syshd_t *syshd, const char *mode);
 gpgrt_stream_t _gpgrt_fpopen    (FILE *fp, const char *mode);
 gpgrt_stream_t _gpgrt_fpopen_nc (FILE *fp, const char *mode);
 gpgrt_stream_t _gpgrt_freopen (const char *_GPGRT__RESTRICT path,
                                const char *_GPGRT__RESTRICT mode,
                                gpgrt_stream_t _GPGRT__RESTRICT stream);
 gpgrt_stream_t _gpgrt_fopencookie (void *_GPGRT__RESTRICT cookie,
                                    const char *_GPGRT__RESTRICT mode,
                                    gpgrt_cookie_io_functions_t functions);
 int _gpgrt_fclose (gpgrt_stream_t stream);
 int _gpgrt_fclose_snatch (gpgrt_stream_t stream,
                           void **r_buffer, size_t *r_buflen);
 int _gpgrt_onclose (gpgrt_stream_t stream, int mode,
                     void (*fnc) (gpgrt_stream_t, void*), void *fnc_value);
 int _gpgrt_fileno (gpgrt_stream_t stream);
 int _gpgrt_fileno_unlocked (gpgrt_stream_t stream);
 int _gpgrt_syshd (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
 int _gpgrt_syshd_unlocked (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
 
 void _gpgrt__set_std_fd (int no, int fd);
 gpgrt_stream_t _gpgrt__get_std_stream (int fd);
 /* The es_stderr et al macros are pretty common so that we want to use
  * them too.  This requires that we redefine them.  */
 #undef es_stdin
 #define es_stdin  _gpgrt__get_std_stream (0)
 #undef es_stdout
 #define es_stdout _gpgrt__get_std_stream (1)
 #undef es_stderr
 #define es_stderr _gpgrt__get_std_stream (2)
 
 void _gpgrt_flockfile (gpgrt_stream_t stream);
 int  _gpgrt_ftrylockfile (gpgrt_stream_t stream);
 void _gpgrt_funlockfile (gpgrt_stream_t stream);
 
 int _gpgrt_feof (gpgrt_stream_t stream);
 int _gpgrt_feof_unlocked (gpgrt_stream_t stream);
 int _gpgrt_ferror (gpgrt_stream_t stream);
 int _gpgrt_ferror_unlocked (gpgrt_stream_t stream);
 void _gpgrt_clearerr (gpgrt_stream_t stream);
 void _gpgrt_clearerr_unlocked (gpgrt_stream_t stream);
 int _gpgrt__pending (gpgrt_stream_t stream);
 int _gpgrt__pending_unlocked (gpgrt_stream_t stream);
 
 int _gpgrt_fflush (gpgrt_stream_t stream);
 int _gpgrt_fseek (gpgrt_stream_t stream, long int offset, int whence);
 int _gpgrt_fseeko (gpgrt_stream_t stream, gpgrt_off_t offset, int whence);
 long int _gpgrt_ftell (gpgrt_stream_t stream);
 gpgrt_off_t _gpgrt_ftello (gpgrt_stream_t stream);
 void _gpgrt_rewind (gpgrt_stream_t stream);
 int  _gpgrt_ftruncate (estream_t stream, gpgrt_off_t length);
 
 int _gpgrt_fgetc (gpgrt_stream_t stream);
 int _gpgrt_fputc (int c, gpgrt_stream_t stream);
 
 int _gpgrt__getc_underflow (gpgrt_stream_t stream);
 int _gpgrt__putc_overflow (int c, gpgrt_stream_t stream);
 
 /* Note: Keeps the next two macros in sync
          with their counterparts in gpg-error.h. */
 #define _gpgrt_getc_unlocked(stream)				\
   (((!(stream)->flags.writing)					\
     && ((stream)->data_offset < (stream)->data_len)		\
     && (! (stream)->unread_data_len))				\
   ? ((int) (stream)->buffer[((stream)->data_offset)++])		\
   : _gpgrt__getc_underflow ((stream)))
 
 #define _gpgrt_putc_unlocked(c, stream)				\
   (((stream)->flags.writing					\
     && ((stream)->data_offset < (stream)->buffer_size)		\
     && (c != '\n'))						\
   ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
   : _gpgrt__putc_overflow ((c), (stream)))
 
 int _gpgrt_ungetc (int c, gpgrt_stream_t stream);
 
 int _gpgrt_read (gpgrt_stream_t _GPGRT__RESTRICT stream,
                  void *_GPGRT__RESTRICT buffer, size_t bytes_to_read,
                  size_t *_GPGRT__RESTRICT bytes_read);
 int _gpgrt_write (gpgrt_stream_t _GPGRT__RESTRICT stream,
                   const void *_GPGRT__RESTRICT buffer, size_t bytes_to_write,
                   size_t *_GPGRT__RESTRICT bytes_written);
 int _gpgrt_write_sanitized (gpgrt_stream_t _GPGRT__RESTRICT stream,
                             const void *_GPGRT__RESTRICT buffer, size_t length,
                             const char *delimiters,
                             size_t *_GPGRT__RESTRICT bytes_written);
 int _gpgrt_write_hexstring (gpgrt_stream_t _GPGRT__RESTRICT stream,
                             const void *_GPGRT__RESTRICT buffer, size_t length,
                             int reserved,
                             size_t *_GPGRT__RESTRICT bytes_written);
 
 size_t _gpgrt_fread (void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems,
                      gpgrt_stream_t _GPGRT__RESTRICT stream);
 size_t _gpgrt_fwrite (const void *_GPGRT__RESTRICT ptr,
                       size_t size, size_t memb,
                       gpgrt_stream_t _GPGRT__RESTRICT stream);
 
 char *_gpgrt_fgets (char *_GPGRT__RESTRICT s, int n,
                     gpgrt_stream_t _GPGRT__RESTRICT stream);
 int _gpgrt_fputs (const char *_GPGRT__RESTRICT s,
                   gpgrt_stream_t _GPGRT__RESTRICT stream);
 int _gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s,
                            gpgrt_stream_t _GPGRT__RESTRICT stream);
 
 gpgrt_ssize_t _gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr,
                               size_t *_GPGRT__RESTRICT n,
                               gpgrt_stream_t stream);
 gpgrt_ssize_t _gpgrt_read_line (gpgrt_stream_t stream,
                                 char **addr_of_buffer, size_t *length_of_buffer,
                                 size_t *max_length);
 
 int _gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
                     const char *_GPGRT__RESTRICT format, ...)
                     GPGRT_ATTR_PRINTF(2,3);
 int _gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
                              const char *_GPGRT__RESTRICT format, ...)
                              GPGRT_ATTR_PRINTF(2,3);
 
 int _gpgrt_vfprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
                      gpgrt_string_filter_t sf, void *sfvalue,
                      const char *_GPGRT__RESTRICT format, va_list ap)
                      GPGRT_ATTR_PRINTF(4,0);
 int _gpgrt_vfprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
                               gpgrt_string_filter_t sf, void *sfvalue,
                               const char *_GPGRT__RESTRICT format, va_list ap)
                               GPGRT_ATTR_PRINTF(4,0);
 
 int _gpgrt_setvbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
                     char *_GPGRT__RESTRICT buf, int mode, size_t size);
 
 void _gpgrt_set_binary (gpgrt_stream_t stream);
 int  _gpgrt_set_nonblock (gpgrt_stream_t stream, int onoff);
 int  _gpgrt_get_nonblock (gpgrt_stream_t stream);
 
 int _gpgrt_poll (gpgrt_poll_t *fds, unsigned int nfds, int timeout);
 
 gpgrt_stream_t _gpgrt_tmpfile (void);
 
 void _gpgrt_opaque_set (gpgrt_stream_t _GPGRT__RESTRICT stream,
                         void *_GPGRT__RESTRICT opaque);
 void *_gpgrt_opaque_get (gpgrt_stream_t stream);
 
 void _gpgrt_fname_set (gpgrt_stream_t stream, const char *fname);
 const char *_gpgrt_fname_get (gpgrt_stream_t stream);
 
 #include "estream-printf.h"
 
 /* Make sure we always use our snprintf */
 #undef snprintf
 #define snprintf _gpgrt_estream_snprintf
 
 
 #if HAVE_W32_SYSTEM
 /* Prototypes for w32-estream.c. */
 extern struct cookie_io_functions_s _gpgrt_functions_w32_pollable;
 int _gpgrt_w32_pollable_create (void *_GPGRT__RESTRICT *_GPGRT__RESTRICT cookie,
                                 unsigned int modeflags,
                                 struct cookie_io_functions_s next_functions,
                                 void *next_cookie);
 int _gpgrt_w32_poll (gpgrt_poll_t *fds, size_t nfds, int timeout);
 #endif /*HAVE_W32_SYSTEM*/
 
 
 
 /*
  * Local prototypes for the encoders.
  */
 
 struct _gpgrt_b64state
 {
   int idx;
   int quad_count;
   estream_t stream;
   char *title;
   unsigned char radbuf[4];
   unsigned int crc;
   gpg_err_code_t lasterr;
   unsigned int flags;
   unsigned int stop_seen:1;
   unsigned int invalid_encoding:1;
   unsigned int using_decoder:1;
 };
 
 gpgrt_b64state_t _gpgrt_b64enc_start (estream_t stream, const char *title);
 gpg_err_code_t   _gpgrt_b64enc_write (gpgrt_b64state_t state,
                                       const void *buffer, size_t nbytes);
 gpg_err_code_t   _gpgrt_b64enc_finish (gpgrt_b64state_t state);
 
 gpgrt_b64state_t _gpgrt_b64dec_start (const char *title);
 gpg_err_code_t _gpgrt_b64dec_proc (gpgrt_b64state_t state, void *buffer,
                                    size_t length, size_t *r_nbytes);
 gpg_err_code_t _gpgrt_b64dec_finish (gpgrt_b64state_t state);
 
 
 
 /*
  * Local prototypes for logging
  */
 int  _gpgrt_get_errorcount (int clear);
 void _gpgrt_inc_errorcount (void);
 void _gpgrt_log_set_sink (const char *name, estream_t stream, int fd);
 void _gpgrt_log_set_socket_dir_cb (const char *(*fnc)(void));
 void _gpgrt_log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value));
 void _gpgrt_log_set_prefix (const char *text, unsigned int flags);
 const char *_gpgrt_log_get_prefix (unsigned int *flags);
 int  _gpgrt_log_test_fd (int fd);
 int  _gpgrt_log_get_fd (void);
 estream_t _gpgrt_log_get_stream (void);
 
 void _gpgrt_log (int level, const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
 void _gpgrt_logv (int level, const char *fmt, va_list arg_ptr);
 void _gpgrt_logv_prefix (int level, const char *prefix,
                          const char *fmt, va_list arg_ptr);
 
 void _gpgrt_log_string (int level, const char *string);
 
 void _gpgrt_log_bug (const char *fmt, ...)    GPGRT_ATTR_NR_PRINTF(1,2);
 void _gpgrt_log_fatal (const char *fmt, ...)  GPGRT_ATTR_NR_PRINTF(1,2);
 void _gpgrt_log_error (const char *fmt, ...)  GPGRT_ATTR_PRINTF(1,2);
 void _gpgrt_log_info (const char *fmt, ...)   GPGRT_ATTR_PRINTF(1,2);
 void _gpgrt_log_debug (const char *fmt, ...)  GPGRT_ATTR_PRINTF(1,2);
 void _gpgrt_log_debug_string (const char *string, const char *fmt,
                               ...) GPGRT_ATTR_PRINTF(2,3);
 
 void _gpgrt_log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
 
 void _gpgrt_log_flush (void);
 
 void _gpgrt_logv_printhex (const void *buffer, size_t length,
                            const char *fmt, va_list arg_ptr);
 void _gpgrt_log_printhex (const void *buffer, size_t length,
                           const char *fmt, ...) GPGRT_ATTR_PRINTF(3,4);;
 
 void _gpgrt_logv_clock (const char *fmt, va_list arg_ptr);
 void _gpgrt_log_clock (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
 
 void _gpgrt__log_assert (const char *expr, const char *file, int line,
                          const char *func) GPGRT_ATTR_NORETURN;
 
 /* Redefine the assert macro to use our internal function.  */
 #undef gpgrt_assert
 #ifdef GPGRT_HAVE_MACRO_FUNCTION
 #define gpgrt_assert(expr)                                      \
   ((expr)                                                       \
    ? (void) 0                                                   \
    : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
 #else /*!GPGRT_HAVE_MACRO_FUNCTION*/
 /* # define BUG() bug_at( __FILE__ , __LINE__ ) */
 #define gpgrt_assert(expr)                                      \
   ((expr)                                                       \
    ? (void) 0                                                   \
    : _gpgrt__log_assert (#expr, __FILE__, __LINE__, NULL))
 #endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
 
 /* Note: The next function is only to be used by visibility.c.  */
 int _gpgrt_logv_internal (int level, int ignore_arg_ptr,
                           const char *extrastring,
                           const char *prefmt, const char *fmt,
                           va_list arg_ptr);
 
 
 /*
  * Local prototypes for the spawn functions.
  *
  * We put the docs here because we have separate implementations in
  * the files spawn-posix.c and spawn-w32.c
  */
 
 /* Return the maximum number of currently allowed file descriptors.
  * Only useful on POSIX systems.  */
 /* int get_max_fds (void); */
 
 
 /* Close all file descriptors starting with descriptor FIRST.  If
  * EXCEPT is not NULL, it is expected to be a list of file descriptors
  * which are not to close.  This list shall be sorted in ascending
  * order with its end marked by -1.  */
 /* void close_all_fds (int first, int *except); */
 
 
 /* Returns an array with all currently open file descriptors.  The end
  * of the array is marked by -1.  The caller needs to release this
  * array using the *standard free* and not with xfree.  This allow the
  * use of this function right at startup even before libgcrypt has
  * been initialized.  Returns NULL on error and sets ERRNO accordingly.  */
 /* int *get_all_open_fds (void); */
 
 /* Create a pipe.  The DIRECTION parameter gives the type of the created pipe:
  *   DIRECTION < 0 := Inbound pipe: On Windows the write end is inheritable.
  *   DIRECTION > 0 := Outbound pipe: On Windows the read end is inheritable.
  * If R_FP is NULL a standard pipe and no stream is created, DIRECTION
  * should then be 0.   */
 gpg_err_code_t _gpgrt_make_pipe (int filedes[2], estream_t *r_fp,
                                  int direction, int nonblock);
 
 /* Convenience macros to create a pipe.  */
 #define _gpgrt_create_pipe(a)              _gpgrt_make_pipe ((a),NULL, 0,    0);
 #define _gpgrt_create_inbound_pipe(a,b,c)  _gpgrt_make_pipe ((a), (b), -1, (c));
 #define _gpgrt_create_outbound_pipe(a,b,c) _gpgrt_make_pipe ((a), (b),  1, (c));
 
 
 /* Fork and exec the program PGMNAME.
  *
  * If R_INFP is NULL connect stdin of the new process to /dev/null; if
  * it is not NULL store the address of a pointer to a new estream
  * there. If R_OUTFP is NULL connect stdout of the new process to
  * /dev/null; if it is not NULL store the address of a pointer to a
  * new estream there.  If R_ERRFP is NULL connect stderr of the new
  * process to /dev/null; if it is not NULL store the address of a
  * pointer to a new estream there.  On success the pid of the new
  * process is stored at PID.  On error -1 is stored at PID and if
  * R_OUTFP or R_ERRFP are not NULL, NULL is stored there.
  *
  * The arguments for the process are expected in the NULL terminated
  * array ARGV.  The program name itself should not be included there.
  * If PREEXEC is not NULL, the given function will be called right
  * before the exec.
  *
  * IF EXCEPT is not NULL, it is expected to be an ordered list of file
  * descriptors, terminated by an entry with the value (-1).  These
  * file descriptors won't be closed before spawning a new program.
  *
  * Returns 0 on success or an error code.  Calling gpgrt_wait_process
  * and gpgrt_release_process is required if the function succeeded.
  *
  * FLAGS is a bit vector:
  *
  * GPGRT_SPAWN_NONBLOCK
  *        If set the two output streams are created in non-blocking
  *        mode and the input stream is switched to non-blocking mode.
  *        This is merely a convenience feature because the caller
  *        could do the same with gpgrt_set_nonblock.  Does not yet
  *        work for Windows.
  *
  * GPGRT_SPAWN_DETACHED
  *        If set the process will be started as a background process.
  *        This flag is only useful under W32 (but not W32CE) systems,
  *        so that no new console is created and pops up a console
  *        window when starting the server.  Does not work on W32CE.
  *
  * GPGRT_SPAWN_RUN_ASFW
  *        On W32 (but not on W32CE) run AllowSetForegroundWindow for
  *        the child.  Note that due to unknown problems this actually
  *        allows SetForegroundWindow for all children of this process.
  */
 gpg_err_code_t
 _gpgrt_spawn_process (const char *pgmname, const char *argv[],
                       int *execpt, void (*preexec)(void), unsigned int flags,
                       estream_t *r_infp,
                       estream_t *r_outfp,
                       estream_t *r_errfp,
                       pid_t *pid);
 
 
 /* Simplified version of gpgrt_spawn_process.  This function forks and
  * then execs PGMNAME, while connecting INFD to stdin, OUTFD to stdout
  * and ERRFD to stderr (any of them may be -1 to connect them to
  * /dev/null).  The arguments for the process are expected in the NULL
  * terminated array ARGV.  The program name itself should not be
  * included there.  Calling gpgrt_wait_process and
  * gpgrt_release_process is required.  Returns 0 on success or an
  * error code. */
 gpg_err_code_t _gpgrt_spawn_process_fd (const char *pgmname,
                                         const char *argv[],
                                         int infd, int outfd, int errfd,
                                         pid_t *pid);
 
 /* Spawn a new process and immediately detach from it.  The name of
  * the program to exec is PGMNAME and its arguments are in ARGV (the
  * programname is automatically passed as first argument).
  * Environment strings in ENVP are set.  An error is returned if
  * pgmname is not executable; to make this work it is necessary to
  * provide an absolute file name.  */
 gpg_err_code_t _gpgrt_spawn_process_detached (const char *pgmname,
                                               const char *argv[],
                                               const char *envp[] );
 
 /* If HANG is true, waits for the process identified by PID to exit;
  * if HANG is false, checks whether the process has terminated.
  * PGMNAME should be the same as supplied to the spawn function and is
  * only used for diagnostics.  Return values:
  *
  * 0
  *     The process exited successful.  0 is stored at R_EXITCODE.
  *
  * GPG_ERR_GENERAL
  *     The process exited without success.  The exit code of process
  *     is then stored at R_EXITCODE.  An exit code of -1 indicates
  *     that the process terminated abnormally (e.g. due to a signal).
  *
  * GPG_ERR_TIMEOUT
  *     The process is still running (returned only if HANG is false).
  *
  * GPG_ERR_INV_VALUE
  *     An invalid PID has been specified.
  *
  * Other error codes may be returned as well.  Unless otherwise noted,
  * -1 will be stored at R_EXITCODE.  R_EXITCODE may be passed as NULL
  * if the exit code is not required (in that case an error message will
  * be printed).  Note that under Windows PID is not the process id but
  * the handle of the process.  */
 gpg_err_code_t _gpgrt_wait_process (const char *pgmname, pid_t pid, int hang,
                                     int *r_exitcode);
 
 /* Like _gpgrt_wait_process, but for COUNT processes.  */
 gpg_err_code_t _gpgrt_wait_processes (const char **pgmnames, pid_t *pids,
                                       size_t count, int hang, int *r_exitcodes);
 
 /* Kill a process; that is send an appropriate signal to the process.
  * gpgrt_wait_process must be called to actually remove the process
  * from the system.  An invalid PID is ignored.  */
 void _gpgrt_kill_process (pid_t pid);
 
 /* Release the process identified by PID.  This function is actually
  * only required for Windows but it does not harm to always call it.
  * It is a nop if PID is invalid.  */
 void _gpgrt_release_process (pid_t pid);
 
 
 /*
  * Local prototypes for argparse.
  */
 int _gpgrt_argparse (estream_t fp, gpgrt_argparse_t *arg, gpgrt_opt_t *opts);
+int _gpgrt_argparser (gpgrt_argparse_t *arg, gpgrt_opt_t *opts,
+                      const char *confname);
 void _gpgrt_usage (int level);
 const char *_gpgrt_strusage (int level);
 void _gpgrt_set_strusage (const char *(*f)(int));
 void _gpgrt_set_usage_outfnc (int (*fnc)(int, const char *));
 void _gpgrt_set_fixed_string_mapper (const char *(*f)(const char*));
+void _gpgrt_set_confdir (int what, const char *name);
 
 
 /*
  * Various helper functions
  */
 int _gpgrt_cmp_version (const char *a, const char *b, int level);
 
 
 
 /*
  * Internal platform abstraction functions (sysutils.c)
  */
 
 /* Return true if FD is valid.  */
 int _gpgrt_fd_valid_p (int fd);
 
 /* A getenv variant which returns a malloced copy.  */
 char *_gpgrt_getenv (const char *name);
 
 /* A setenv variant which can be used for unsetenv by setting VALUE to
  * NULL and OVERRIDE to true.  */
 gpg_err_code_t _gpgrt_setenv (const char *name,
                               const char *value, int overwrite);
 
 /* A wrapper around mkdir using a string for the mode (permissions).  */
 gpg_err_code_t _gpgrt_mkdir (const char *name, const char *modestr);
 
 /* A simple wrapper around chdir.  */
 gpg_err_code_t _gpgrt_chdir (const char *name);
 
 /* Return the current WD as a malloced string.  */
 char *_gpgrt_getcwd (void);
 
 /* Return the home directory of user NAME.  */
 char *_gpgrt_getpwdir (const char *name);
 
 /* Expand and concat file name parts.  */
 char *_gpgrt_vfnameconcat (int want_abs, const char *first_part,
                            va_list arg_ptr);
 char *_gpgrt_fnameconcat (const char *first_part,
                           ... ) GPGRT_ATTR_SENTINEL(0);
 char *_gpgrt_absfnameconcat (const char *first_part,
                              ... ) GPGRT_ATTR_SENTINEL(0);
 
 
 /*
  * Platform specific functions (Windows)
  */
 #ifdef HAVE_W32_SYSTEM
 
 char *_gpgrt_w32_reg_query_string (const char *root,
                                    const char *dir,
                                    const char *name);
 
 
 #endif /*HAVE_W32_SYSTEM*/
 
 /*
  * Missing functions implemented inline.
  */
 
 #ifndef HAVE_STPCPY
 static GPG_ERR_INLINE char *
 _gpgrt_stpcpy (char *a, const char *b)
 {
   while (*b)
     *a++ = *b++;
   *a = 0;
   return a;
 }
 #define stpcpy(a,b) _gpgrt_stpcpy ((a), (b))
 #endif /*!HAVE_STPCPY*/
 
 
 #endif /*_GPGRT_GPGRT_INT_H*/
diff --git a/src/version.c b/src/version.c
index c65f5e9..276ee04 100644
--- a/src/version.c
+++ b/src/version.c
@@ -1,246 +1,246 @@
 /* version.c - Version checking
  * Copyright (C) 2001, 2002, 2012, 2013, 2014 g10 Code GmbH
  *
  * This file is part of libgpg-error.
  *
  * libgpg-error is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * libgpg-error is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
 #if HAVE_CONFIG_H
 #include <config.h>
 #endif
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
 #include <gpg-error.h>
 
 
 #define digitp(a) ((a) >= '0' && (a) <= '9')
 
 
 /* This is actually a dummy function to make sure that is module is
    not empty.  Some compilers barf on empty modules.  */
 static const char *
 cright_blurb (void)
 {
   static const char blurb[] =
     "\n\n"
     "This is Libgpg-error " PACKAGE_VERSION " - A runtime library\n"
-    "Copyright 2001-2019 g10 Code GmbH\n"
+    "Copyright 2001-2020 g10 Code GmbH\n"
     "\n"
     "(" BUILD_REVISION " " BUILD_TIMESTAMP ")\n"
     "\n\n";
   return blurb;
 }
 
 
 /* This function parses the first portion of the version number S and
  * stores it at NUMBER.  On success, this function returns a pointer
  * into S starting with the first character, which is not part of the
  * initial number portion; on failure, NULL is returned.  */
 static const char*
 parse_version_number (const char *s, int *number)
 {
   int val = 0;
 
   if (*s == '0' && digitp (s[1]))
     return NULL;  /* Leading zeros are not allowed.  */
   for (; digitp (*s); s++)
     {
       val *= 10;
       val += *s - '0';
     }
   *number = val;
   return val < 0 ? NULL : s;
 }
 
 
 /* This function breaks up the complete string-representation of the
  * version number S, which is of the following struture: <major
  * number>.<minor number>.<micro number><patch level>.  The major,
  * minor and micro number components will be stored in *MAJOR, *MINOR
  * and *MICRO.  If MINOR or MICRO is NULL the version number is
  * assumed to have just 1 respective 2 parts.
  *
  * On success, the last component, the patch level, will be returned;
  * in failure, NULL will be returned.  */
 static const char *
 parse_version_string (const char *s, int *major, int *minor, int *micro)
 {
   s = parse_version_number (s, major);
   if (!s)
     return NULL;
   if (!minor)
     {
       if (*s == '.')
         s++;
     }
   else
     {
       if (*s != '.')
         return NULL;
       s++;
       s = parse_version_number (s, minor);
       if (!s)
         return NULL;
       if (!micro)
         {
           if (*s == '.')
             s++;
         }
       else
         {
           if (*s != '.')
             return NULL;
           s++;
           s = parse_version_number (s, micro);
           if (!s)
             return NULL;
         }
     }
   return s; /* patchlevel */
 }
 
 
 /* Helper for _gpgrt_cmp_version.  */
 static int
 do_cmp_version (const char *a, const char *b, int level)
 {
   int a_major, a_minor, a_micro;
   int b_major, b_minor, b_micro;
   const char *a_plvl, *b_plvl;
   int r;
   int ignore_plvl;
   int positive, negative;
 
   if (level < 0)
     {
       positive = -1;
       negative = 1;
       level = 0 - level;
     }
   else
     {
       positive = 1;
       negative = -1;
     }
   if ((ignore_plvl = (level > 9)))
     level %= 10;
 
   a_major = a_minor = a_micro = 0;
   a_plvl = parse_version_string (a, &a_major,
                                  level > 1? &a_minor : NULL,
                                  level > 2? &a_micro : NULL);
   if (!a_plvl)
     a_major = a_minor = a_micro = 0; /* Error.  */
 
   b_major = b_minor = b_micro = 0;
   b_plvl = parse_version_string (b, &b_major,
                                  level > 1? &b_minor : NULL,
                                  level > 2? &b_micro : NULL);
   if (!b_plvl)
     b_major = b_minor = b_micro = 0;
 
   if (!ignore_plvl)
     {
       if (!a_plvl && !b_plvl)
         return negative;  /* Put invalid strings at the end.  */
       if (a_plvl && !b_plvl)
         return positive;
       if (!a_plvl && b_plvl)
         return negative;
     }
 
   if (a_major > b_major)
     return positive;
   if (a_major < b_major)
     return negative;
 
   if (a_minor > b_minor)
     return positive;
   if (a_minor < b_minor)
     return negative;
 
   if (a_micro > b_micro)
     return positive;
   if (a_micro < b_micro)
     return negative;
 
   if (ignore_plvl)
     return 0;
 
   for (; *a_plvl && *b_plvl; a_plvl++, b_plvl++)
     {
       if (*a_plvl == '.' && *b_plvl == '.')
         {
           r = strcmp (a_plvl, b_plvl);
           if (!r)
             return 0;
           else if ( r > 0 )
             return positive;
           else
             return negative;
         }
       else if (*a_plvl == '.')
         return negative; /* B is larger. */
       else if (*b_plvl == '.')
         return positive; /* A is larger. */
       else if (*a_plvl != *b_plvl)
         break;
         }
   if (*a_plvl == *b_plvl)
     return 0;
   else if ((*(signed char *)a_plvl - *(signed char *)b_plvl) > 0)
     return positive;
   else
     return negative;
 }
 
 
 /* Compare function for version strings.  The return value is
  * like strcmp().  LEVEL may be
  *   0 - reserved
  *   1 - format is "<major><patchlevel>".
  *   2 - format is "<major>.<minor><patchlevel>".
  *   3 - format is "<major>.<minor>.<micro><patchlevel>".
  * To ignore the patchlevel in the comparison add 10 to LEVEL.  To get
  * a reverse sorting order use a negative number.
  */
 int
 _gpgrt_cmp_version (const char *a, const char *b, int level)
 {
   return do_cmp_version (a, b, level);
 }
 
 
 /*
  * Check that the the version of the library is at minimum REQ_VERSION
  * and return the actual version string; return NULL if the condition
  * is not met.  If NULL is passed to this function, no check is done
  * and the version string is simply returned.
  */
 const char *
 _gpg_error_check_version (const char *req_version)
 {
   const char *my_version = PACKAGE_VERSION;
 
   if (req_version && req_version[0] == 1 && req_version[1] == 1)
     return cright_blurb ();
   if (!req_version)
     return my_version;
   return _gpgrt_cmp_version
     (my_version, req_version, 12) >= 0 ? my_version : NULL;
 }
diff --git a/src/versioninfo.rc.in b/src/versioninfo.rc.in
index 30aab66..d42d8fe 100644
--- a/src/versioninfo.rc.in
+++ b/src/versioninfo.rc.in
@@ -1,54 +1,54 @@
 /* versioninfo.rc.in - for libgpg-error
  *    Copyright (C) 2005 g10 Code GmbH
  *
  * This file is free software; as a special exception the author gives
  * unlimited permission to copy and/or distribute it, with or without
  * modifications, as long as this notice is preserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  * SPDX-License-Identifier: FSFULLR
  */
 
 /* This file is processed by configure to create versioninfo.rc */
 
 #line __LINE__ "versioninfo.rc.in"
 
 #include <afxres.h>
 
 
 VS_VERSION_INFO VERSIONINFO
  FILEVERSION @BUILD_FILEVERSION@
  PRODUCTVERSION @BUILD_FILEVERSION@
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x21L
 #else
  FILEFLAGS 0x20L
 #endif
  FILEOS 0x40004L
  FILETYPE 0x1L
  FILESUBTYPE 0x0L
 BEGIN
     BLOCK "StringFileInfo"
     BEGIN
         BLOCK "040904b0"
         BEGIN
             VALUE "Comments", "Provided under the terms of the GNU Lesser General Public License.\0"
             VALUE "CompanyName", "g10 Code GmbH\0"
             VALUE "FileDescription", "libgpg-error - Common error codes\0"
             VALUE "FileVersion", "@LIBGPG_ERROR_LT_CURRENT@.@LIBGPG_ERROR_LT_AGE@.@LIBGPG_ERROR_LT_REVISION@.@BUILD_REVISION@\0"
             VALUE "InternalName", "libgpg-error\0"
-            VALUE "LegalCopyright", "Copyright � 2019 g10 Code GmbH\0"
+            VALUE "LegalCopyright", "Copyright � 2020 g10 Code GmbH\0"
             VALUE "LegalTrademarks", "\0"
             VALUE "OriginalFilename", "libgpg-error.dll\0"
             VALUE "PrivateBuild", "\0"
             VALUE "ProductName", "libgpg-error\0"
             VALUE "ProductVersion", "@PACKAGE_VERSION@\0"
             VALUE "SpecialBuild", "@BUILD_TIMESTAMP@\0"
         END
     END
 END
 
 1 RT_MANIFEST "gpg-error.w32-manifest"
diff --git a/src/visibility.c b/src/visibility.c
index 5f88aad..ea55d54 100644
--- a/src/visibility.c
+++ b/src/visibility.c
@@ -1,1220 +1,1232 @@
 /* visibility.c - Wrapper for all public functions.
  * Copyright (C) 2014  g10 Code GmbH
  *
  * This file is part of libgpg-error.
  *
  * libgpg-error is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * libgpg-error is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, see <https://www.gnu.org/licenses/>.
  * SPDX-License-Identifier: LGPL-2.1+
  */
 
 #include <config.h>
 #include <stdarg.h>
 #include <stdlib.h> /* For abort().  */
 
 #define _GPGRT_INCL_BY_VISIBILITY_C 1
 #include "gpgrt-int.h"
 
 const char *
 gpg_strerror (gpg_error_t err)
 {
   return _gpg_strerror (err);
 }
 
 int
 gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen)
 {
   return _gpg_strerror_r (err, buf, buflen);
 }
 
 const char *
 gpg_strsource (gpg_error_t err)
 {
   return _gpg_strsource (err);
 }
 
 gpg_err_code_t
 gpg_err_code_from_errno (int err)
 {
   return _gpg_err_code_from_errno (err);
 }
 
 int
 gpg_err_code_to_errno (gpg_err_code_t code)
 {
   return _gpg_err_code_to_errno (code);
 }
 
 gpg_err_code_t
 gpg_err_code_from_syserror (void)
 {
   return _gpg_err_code_from_syserror ();
 }
 
 void
 gpg_err_set_errno (int err)
 {
   _gpg_err_set_errno (err);
 }
 
 
 gpg_error_t
 gpg_err_init (void)
 {
   return _gpg_err_init ();
 }
 
 void
 gpg_err_deinit (int mode)
 {
   _gpg_err_deinit (mode);
 }
 
 void
 gpgrt_add_emergency_cleanup (void (*f)(void))
 {
   _gpgrt_add_emergency_cleanup (f);
 }
 
 void
 gpgrt_abort (void)
 {
   _gpgrt_abort ();
 }
 
 const char *
 gpg_error_check_version (const char *req_version)
 {
   return _gpg_error_check_version (req_version);
 }
 
 const char *
 gpgrt_check_version (const char *req_version)
 {
   return _gpg_error_check_version (req_version);
 }
 
 void
 gpgrt_set_syscall_clamp (void (*pre)(void), void (*post)(void))
 {
   _gpgrt_set_syscall_clamp (pre, post);
 }
 
 void
 gpgrt_get_syscall_clamp (void (**r_pre)(void), void (**r_post)(void))
 {
   _gpgrt_get_syscall_clamp (r_pre, r_post);
 }
 
 void
 gpgrt_set_alloc_func (void *(*f)(void *a, size_t n))
 {
   _gpgrt_set_alloc_func (f);
 }
 
 
 gpg_err_code_t
 gpgrt_lock_init (gpgrt_lock_t *lockhd)
 {
   return _gpgrt_lock_init (lockhd);
 }
 
 gpg_err_code_t
 gpgrt_lock_lock (gpgrt_lock_t *lockhd)
 {
   return _gpgrt_lock_lock (lockhd);
 }
 
 gpg_err_code_t
 gpgrt_lock_trylock (gpgrt_lock_t *lockhd)
 {
   return _gpgrt_lock_trylock (lockhd);
 }
 
 gpg_err_code_t
 gpgrt_lock_unlock (gpgrt_lock_t *lockhd)
 {
   return _gpgrt_lock_unlock (lockhd);
 }
 
 gpg_err_code_t
 gpgrt_lock_destroy (gpgrt_lock_t *lockhd)
 {
   return _gpgrt_lock_destroy (lockhd);
 }
 
 gpg_err_code_t
 gpgrt_yield (void)
 {
   return _gpgrt_yield ();
 }
 
 
 
 estream_t
 gpgrt_fopen (const char *_GPGRT__RESTRICT path,
              const char *_GPGRT__RESTRICT mode)
 {
   return _gpgrt_fopen (path, mode);
 }
 
 estream_t
 gpgrt_mopen (void *_GPGRT__RESTRICT data, size_t data_n, size_t data_len,
              unsigned int grow,
              void *(*func_realloc) (void *mem, size_t size),
              void (*func_free) (void *mem),
              const char *_GPGRT__RESTRICT mode)
 {
   return _gpgrt_mopen (data, data_n, data_len, grow, func_realloc, func_free,
                        mode);
 }
 
 estream_t
 gpgrt_fopenmem (size_t memlimit, const char *_GPGRT__RESTRICT mode)
 {
   return _gpgrt_fopenmem (memlimit, mode);
 }
 
 estream_t
 gpgrt_fopenmem_init (size_t memlimit, const char *_GPGRT__RESTRICT mode,
                      const void *data, size_t datalen)
 {
   return _gpgrt_fopenmem_init (memlimit, mode, data, datalen);
 }
 
 estream_t
 gpgrt_fdopen (int filedes, const char *mode)
 {
   return _gpgrt_fdopen (filedes, mode);
 }
 
 estream_t
 gpgrt_fdopen_nc (int filedes, const char *mode)
 {
   return _gpgrt_fdopen_nc (filedes, mode);
 }
 
 estream_t
 gpgrt_sysopen (es_syshd_t *syshd, const char *mode)
 {
   return _gpgrt_sysopen (syshd, mode);
 }
 
 estream_t
 gpgrt_sysopen_nc (es_syshd_t *syshd, const char *mode)
 {
   return _gpgrt_sysopen_nc (syshd, mode);
 }
 
 estream_t
 gpgrt_fpopen (FILE *fp, const char *mode)
 {
   return _gpgrt_fpopen (fp, mode);
 }
 
 estream_t
 gpgrt_fpopen_nc (FILE *fp, const char *mode)
 {
   return _gpgrt_fpopen_nc (fp, mode);
 }
 
 estream_t
 gpgrt_freopen (const char *_GPGRT__RESTRICT path,
                const char *_GPGRT__RESTRICT mode,
                estream_t _GPGRT__RESTRICT stream)
 {
   return _gpgrt_freopen (path, mode, stream);
 }
 
 estream_t
 gpgrt_fopencookie (void *_GPGRT__RESTRICT cookie,
                    const char *_GPGRT__RESTRICT mode,
                    gpgrt_cookie_io_functions_t functions)
 {
   return _gpgrt_fopencookie (cookie, mode, functions);
 }
 
 int
 gpgrt_fclose (estream_t stream)
 {
   return _gpgrt_fclose (stream);
 }
 
 int
 gpgrt_fclose_snatch (estream_t stream, void **r_buffer, size_t *r_buflen)
 {
   return _gpgrt_fclose_snatch (stream, r_buffer, r_buflen);
 }
 
 int
 gpgrt_onclose (estream_t stream, int mode,
                void (*fnc) (estream_t, void*), void *fnc_value)
 {
   return _gpgrt_onclose (stream, mode, fnc, fnc_value);
 }
 
 int
 gpgrt_fileno (estream_t stream)
 {
   return _gpgrt_fileno (stream);
 }
 
 int
 gpgrt_fileno_unlocked (estream_t stream)
 {
   return _gpgrt_fileno_unlocked (stream);
 }
 
 int
 gpgrt_syshd (estream_t stream, es_syshd_t *syshd)
 {
   return _gpgrt_syshd (stream, syshd);
 }
 
 int
 gpgrt_syshd_unlocked (estream_t stream, es_syshd_t *syshd)
 {
   return _gpgrt_syshd_unlocked (stream, syshd);
 }
 
 void
 _gpgrt_set_std_fd (int no, int fd)
 {
   _gpgrt__set_std_fd (no, fd);  /* (double dash in name) */
 }
 
 estream_t
 _gpgrt_get_std_stream (int fd)
 {
   return _gpgrt__get_std_stream (fd);  /* (double dash in name) */
 }
 
 void
 gpgrt_flockfile (estream_t stream)
 {
   _gpgrt_flockfile (stream);
 }
 
 int
 gpgrt_ftrylockfile (estream_t stream)
 {
   return _gpgrt_ftrylockfile (stream);
 }
 
 void
 gpgrt_funlockfile (estream_t stream)
 {
   _gpgrt_funlockfile (stream);
 }
 
 int
 _gpgrt_pending (estream_t stream)
 {
   return _gpgrt__pending (stream);
 }
 
 int
 _gpgrt_pending_unlocked (estream_t stream)
 {
   return _gpgrt__pending_unlocked (stream);
 }
 
 int
 gpgrt_feof (estream_t stream)
 {
   return _gpgrt_feof (stream);
 }
 
 int
 gpgrt_feof_unlocked (estream_t stream)
 {
   return _gpgrt_feof_unlocked (stream);
 }
 
 int
 gpgrt_ferror (estream_t stream)
 {
   return _gpgrt_ferror (stream);
 }
 
 int
 gpgrt_ferror_unlocked (estream_t stream)
 {
   return _gpgrt_ferror_unlocked (stream);
 }
 
 void
 gpgrt_clearerr (estream_t stream)
 {
   _gpgrt_clearerr (stream);
 }
 
 void
 gpgrt_clearerr_unlocked (estream_t stream)
 {
   _gpgrt_clearerr_unlocked (stream);
 }
 
 int
 gpgrt_fflush (estream_t stream)
 {
   return _gpgrt_fflush (stream);
 }
 
 int
 gpgrt_fseek (estream_t stream, long int offset, int whence)
 {
   return _gpgrt_fseek (stream, offset, whence);
 }
 
 int
 gpgrt_fseeko (estream_t stream, gpgrt_off_t offset, int whence)
 {
   return _gpgrt_fseeko (stream, offset, whence);
 }
 
 long int
 gpgrt_ftell (estream_t stream)
 {
   return _gpgrt_ftell (stream);
 }
 
 gpgrt_off_t
 gpgrt_ftello (estream_t stream)
 {
   return _gpgrt_ftello (stream);
 }
 
 void
 gpgrt_rewind (estream_t stream)
 {
   _gpgrt_rewind (stream);
 }
 
 int
 gpgrt_ftruncate (estream_t stream, gpgrt_off_t length)
 {
   return _gpgrt_ftruncate (stream, length);
 }
 
 int
 gpgrt_fgetc (estream_t stream)
 {
   return _gpgrt_fgetc (stream);
 }
 
 int
 _gpgrt_getc_underflow (estream_t stream)
 {
   return _gpgrt__getc_underflow (stream);
 }
 
 int
 gpgrt_fputc (int c, estream_t stream)
 {
   return _gpgrt_fputc (c, stream);
 }
 
 int
 _gpgrt_putc_overflow (int c, estream_t stream)
 {
   return _gpgrt__putc_overflow (c, stream);
 }
 
 int
 gpgrt_ungetc (int c, estream_t stream)
 {
   return _gpgrt_ungetc (c, stream);
 }
 
 int
 gpgrt_read (estream_t _GPGRT__RESTRICT stream,
             void *_GPGRT__RESTRICT buffer, size_t bytes_to_read,
             size_t *_GPGRT__RESTRICT bytes_read)
 {
   return _gpgrt_read (stream, buffer, bytes_to_read, bytes_read);
 }
 
 int
 gpgrt_write (estream_t _GPGRT__RESTRICT stream,
              const void *_GPGRT__RESTRICT buffer, size_t bytes_to_write,
              size_t *_GPGRT__RESTRICT bytes_written)
 {
   return _gpgrt_write (stream, buffer, bytes_to_write, bytes_written);
 }
 
 int
 gpgrt_write_sanitized (estream_t _GPGRT__RESTRICT stream,
                        const void * _GPGRT__RESTRICT buffer, size_t length,
                        const char * delimiters,
                        size_t * _GPGRT__RESTRICT bytes_written)
 {
   return _gpgrt_write_sanitized (stream, buffer, length, delimiters,
                                  bytes_written);
 }
 
 int
 gpgrt_write_hexstring (estream_t _GPGRT__RESTRICT stream,
                        const void *_GPGRT__RESTRICT buffer, size_t length,
                        int reserved, size_t *_GPGRT__RESTRICT bytes_written )
 {
   return _gpgrt_write_hexstring (stream, buffer, length, reserved,
                                  bytes_written);
 }
 
 size_t
 gpgrt_fread (void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems,
              estream_t _GPGRT__RESTRICT stream)
 {
   return _gpgrt_fread (ptr, size, nitems, stream);
 }
 
 size_t
 gpgrt_fwrite (const void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems,
               estream_t _GPGRT__RESTRICT stream)
 {
   return _gpgrt_fwrite (ptr, size, nitems, stream);
 }
 
 char *
 gpgrt_fgets (char *_GPGRT__RESTRICT buffer, int length,
              estream_t _GPGRT__RESTRICT stream)
 {
   return _gpgrt_fgets (buffer, length, stream);
 }
 
 int
 gpgrt_fputs (const char *_GPGRT__RESTRICT s, estream_t _GPGRT__RESTRICT stream)
 {
   return _gpgrt_fputs (s, stream);
 }
 
 int
 gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s,
                       estream_t _GPGRT__RESTRICT stream)
 {
   return _gpgrt_fputs_unlocked (s, stream);
 }
 
 gpgrt_ssize_t
 gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr,
                size_t *_GPGRT__RESTRICT n, estream_t _GPGRT__RESTRICT stream)
 {
   return _gpgrt_getline (lineptr, n, stream);
 }
 
 gpgrt_ssize_t
 gpgrt_read_line (estream_t stream,
                  char **addr_of_buffer, size_t *length_of_buffer,
                  size_t *max_length)
 {
   return _gpgrt_read_line (stream, addr_of_buffer, length_of_buffer,
                            max_length);
 }
 
 int
 gpgrt_vfprintf (estream_t _GPGRT__RESTRICT stream,
                 const char *_GPGRT__RESTRICT format,
                 va_list ap)
 {
   return _gpgrt_vfprintf (stream, NULL, NULL, format, ap);
 }
 
 int
 gpgrt_vfprintf_unlocked (estream_t _GPGRT__RESTRICT stream,
                           const char *_GPGRT__RESTRICT format,
                           va_list ap)
 {
   return _gpgrt_vfprintf_unlocked (stream, NULL, NULL, format, ap);
 }
 
 int
 gpgrt_printf (const char *_GPGRT__RESTRICT format, ...)
 {
   va_list ap;
   int rc;
 
   va_start (ap, format);
   rc = _gpgrt_vfprintf (es_stdout, NULL, NULL, format, ap);
   va_end (ap);
 
   return rc;
 }
 
 int
 gpgrt_printf_unlocked (const char *_GPGRT__RESTRICT format, ...)
 {
   va_list ap;
   int rc;
 
   va_start (ap, format);
   rc = _gpgrt_vfprintf_unlocked (es_stdout, NULL, NULL, format, ap);
   va_end (ap);
 
   return rc;
 }
 
 int
 gpgrt_fprintf (estream_t _GPGRT__RESTRICT stream,
                const char *_GPGRT__RESTRICT format, ...)
 {
   va_list ap;
   int rc;
 
   va_start (ap, format);
   rc = _gpgrt_vfprintf (stream, NULL, NULL, format, ap);
   va_end (ap);
 
   return rc;
 }
 
 int
 gpgrt_fprintf_unlocked (estream_t _GPGRT__RESTRICT stream,
                         const char *_GPGRT__RESTRICT format, ...)
 {
   va_list ap;
   int rc;
 
   va_start (ap, format);
   rc = _gpgrt_vfprintf_unlocked (stream, NULL, NULL, format, ap);
   va_end (ap);
 
   return rc;
 }
 
 int
 gpgrt_fprintf_sf (estream_t _GPGRT__RESTRICT stream,
                   gpgrt_string_filter_t sf, void *sfvalue,
                   const char *_GPGRT__RESTRICT format, ...)
 {
   va_list ap;
   int rc;
 
   va_start (ap, format);
   rc = _gpgrt_vfprintf (stream, sf, sfvalue, format, ap);
   va_end (ap);
 
   return rc;
 }
 
 int
 gpgrt_fprintf_sf_unlocked (estream_t _GPGRT__RESTRICT stream,
                            gpgrt_string_filter_t sf, void *sfvalue,
                            const char *_GPGRT__RESTRICT format, ...)
 {
   va_list ap;
   int rc;
 
   va_start (ap, format);
   rc = _gpgrt_vfprintf_unlocked (stream, sf, sfvalue, format, ap);
   va_end (ap);
 
   return rc;
 }
 
 int
 gpgrt_setvbuf (estream_t _GPGRT__RESTRICT stream,
                 char *_GPGRT__RESTRICT buf, int type, size_t size)
 {
   return _gpgrt_setvbuf (stream, buf, type, size);
 }
 
 void
 gpgrt_setbuf (estream_t _GPGRT__RESTRICT stream, char *_GPGRT__RESTRICT buf)
 {
   _gpgrt_setvbuf (stream, buf, buf? _IOFBF : _IONBF, BUFSIZ);
 }
 
 void
 gpgrt_set_binary (estream_t stream)
 {
   _gpgrt_set_binary (stream);
 }
 
 int
 gpgrt_set_nonblock (estream_t stream, int onoff)
 {
   return _gpgrt_set_nonblock (stream, onoff);
 }
 
 int
 gpgrt_get_nonblock (estream_t stream)
 {
   return _gpgrt_get_nonblock (stream);
 }
 
 int
 gpgrt_poll (gpgrt_poll_t *fds, unsigned int nfds, int timeout)
 {
   return _gpgrt_poll (fds, nfds, timeout);
 }
 
 estream_t
 gpgrt_tmpfile (void)
 {
   return _gpgrt_tmpfile ();
 }
 
 void
 gpgrt_opaque_set (estream_t stream, void *opaque)
 {
   _gpgrt_opaque_set (stream, opaque);
 }
 
 void *
 gpgrt_opaque_get (estream_t stream)
 {
   return _gpgrt_opaque_get (stream);
 }
 
 void
 gpgrt_fname_set (estream_t stream, const char *fname)
 {
   _gpgrt_fname_set (stream, fname);
 }
 
 const char *
 gpgrt_fname_get (estream_t stream)
 {
   return _gpgrt_fname_get (stream);
 }
 
 int
 gpgrt_asprintf (char **r_buf, const char *_GPGRT__RESTRICT format, ...)
 {
   va_list ap;
   int rc;
 
   va_start (ap, format);
   rc = _gpgrt_estream_vasprintf (r_buf, format, ap);
   va_end (ap);
 
   return rc;
 }
 
 int
 gpgrt_vasprintf (char **r_buf, const char *_GPGRT__RESTRICT format, va_list ap)
 {
   return _gpgrt_estream_vasprintf (r_buf, format, ap);
 }
 
 char *
 gpgrt_bsprintf (const char *_GPGRT__RESTRICT format, ...)
 {
   int rc;
   va_list ap;
   char *buf;
 
   va_start (ap, format);
   rc = _gpgrt_estream_vasprintf (&buf, format, ap);
   va_end (ap);
   if (rc < 0)
     return NULL;
   return buf;
 }
 
 char *
 gpgrt_vbsprintf (const char *_GPGRT__RESTRICT format, va_list ap)
 {
   int rc;
   char *buf;
 
   rc = _gpgrt_estream_vasprintf (&buf, format, ap);
   if (rc < 0)
     return NULL;
   return buf;
 }
 
 int
 gpgrt_snprintf (char *buf, size_t bufsize, const char *format, ...)
 {
   int rc;
   va_list arg_ptr;
 
   va_start (arg_ptr, format);
   rc = _gpgrt_estream_vsnprintf (buf, bufsize, format, arg_ptr);
   va_end (arg_ptr);
 
   return rc;
 }
 
 int
 gpgrt_vsnprintf (char *buf, size_t bufsize,
                  const char *format, va_list arg_ptr)
 {
   return _gpgrt_estream_vsnprintf (buf, bufsize, format, arg_ptr);
 }
 
 
 
 void *
 gpgrt_realloc (void *a, size_t n)
 {
   return _gpgrt_realloc (a, n);
 }
 
 void *
 gpgrt_malloc (size_t n)
 {
   return _gpgrt_malloc (n);
 }
 
 void *
 gpgrt_calloc (size_t n, size_t m)
 {
   return _gpgrt_calloc (n, m);
 }
 
 char *
 gpgrt_strdup (const char *string)
 {
   return _gpgrt_strdup (string);
 }
 
 char *
 gpgrt_strconcat (const char *s1, ...)
 {
   va_list arg_ptr;
   char *result;
 
   if (!s1)
     result = _gpgrt_strdup ("");
   else
     {
       va_start (arg_ptr, s1);
       result = _gpgrt_strconcat_core (s1, arg_ptr);
       va_end (arg_ptr);
     }
   return result;
 }
 
 void
 gpgrt_free (void *a)
 {
   if (a)
     _gpgrt_free (a);
 }
 
 char *
 gpgrt_getenv (const char *name)
 {
   return _gpgrt_getenv (name);
 }
 
 gpg_err_code_t
 gpgrt_setenv (const char *name, const char *value, int overwrite)
 {
   return _gpgrt_setenv (name, value, overwrite);
 }
 
 gpg_err_code_t
 gpgrt_mkdir (const char *name, const char *modestr)
 {
   return _gpgrt_mkdir (name, modestr);
 }
 
 gpg_err_code_t
 gpgrt_chdir (const char *name)
 {
   return _gpgrt_chdir (name);
 }
 
 char *
 gpgrt_getcwd (void)
 {
   return _gpgrt_getcwd ();
 }
 
 
 
 gpgrt_b64state_t
 gpgrt_b64enc_start (estream_t stream, const char *title)
 {
   return _gpgrt_b64enc_start (stream, title);
 }
 
 gpg_err_code_t
 gpgrt_b64enc_write (gpgrt_b64state_t state, const void *buffer, size_t nbytes)
 {
   return _gpgrt_b64enc_write (state, buffer, nbytes);
 }
 
 gpg_err_code_t
 gpgrt_b64enc_finish (gpgrt_b64state_t state)
 {
   return _gpgrt_b64enc_finish (state);
 }
 
 gpgrt_b64state_t
 gpgrt_b64dec_start (const char *title)
 {
   return _gpgrt_b64dec_start (title);
 }
 
 gpg_error_t
 gpgrt_b64dec_proc (gpgrt_b64state_t state, void *buffer,
                    size_t length, size_t *r_nbytes)
 {
   return _gpgrt_b64dec_proc (state, buffer, length, r_nbytes);
 }
 
 gpg_error_t
 gpgrt_b64dec_finish (gpgrt_b64state_t state)
 {
   return _gpgrt_b64dec_finish (state);
 }
 
 
 
 int
 gpgrt_get_errorcount (int clear)
 {
   return _gpgrt_get_errorcount (clear);
 }
 
 void
 gpgrt_inc_errorcount (void)
 {
   _gpgrt_inc_errorcount ();
 }
 
 void
 gpgrt_log_set_sink (const char *name, estream_t stream, int fd)
 {
   _gpgrt_log_set_sink (name, stream, fd);
 }
 
 void
 gpgrt_log_set_socket_dir_cb (const char *(*fnc)(void))
 {
   _gpgrt_log_set_socket_dir_cb (fnc);
 }
 
 void
 gpgrt_log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value))
 {
   _gpgrt_log_set_pid_suffix_cb (cb);
 }
 
 void
 gpgrt_log_set_prefix (const char *text, unsigned int flags)
 {
   _gpgrt_log_set_prefix (text, flags);
 }
 
 const char *
 gpgrt_log_get_prefix (unsigned int *flags)
 {
   return _gpgrt_log_get_prefix (flags);
 }
 
 int
 gpgrt_log_test_fd (int fd)
 {
   return _gpgrt_log_test_fd (fd);
 }
 
 int
 gpgrt_log_get_fd (void)
 {
   return _gpgrt_log_get_fd ();
 }
 
 estream_t
 gpgrt_log_get_stream (void)
 {
   return _gpgrt_log_get_stream ();
 }
 
 void
 gpgrt_log (int level, const char *fmt, ...)
 {
   va_list arg_ptr ;
 
   va_start (arg_ptr, fmt) ;
   _gpgrt_logv (level, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
 void
 gpgrt_logv (int level, const char *fmt, va_list arg_ptr)
 {
   _gpgrt_logv (level, fmt, arg_ptr);
 }
 
 void
 gpgrt_logv_prefix (int level, const char *prefix,
                     const char *fmt, va_list arg_ptr)
 {
   _gpgrt_logv_prefix (level, prefix, fmt, arg_ptr);
 }
 
 void
 gpgrt_log_string (int level, const char *string)
 {
   _gpgrt_log_string (level, string);
 }
 
 void
 gpgrt_log_info (const char *fmt, ...)
 {
   va_list arg_ptr;
 
   va_start (arg_ptr, fmt);
   _gpgrt_logv (GPGRT_LOGLVL_INFO, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
 void
 gpgrt_log_error (const char *fmt, ...)
 {
   va_list arg_ptr;
 
   va_start (arg_ptr, fmt);
   _gpgrt_logv (GPGRT_LOGLVL_ERROR, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
 void
 gpgrt_log_fatal (const char *fmt, ...)
 {
   va_list arg_ptr;
 
   va_start (arg_ptr, fmt);
   _gpgrt_logv (GPGRT_LOGLVL_FATAL, fmt, arg_ptr);
   va_end (arg_ptr);
   _gpgrt_abort (); /* Never called; just to make the compiler happy.  */
 }
 
 void
 gpgrt_log_bug (const char *fmt, ...)
 {
   va_list arg_ptr;
 
   va_start (arg_ptr, fmt);
   _gpgrt_logv (GPGRT_LOGLVL_BUG, fmt, arg_ptr);
   va_end (arg_ptr);
   _gpgrt_abort (); /* Never called; just to make the compiler happy.  */
 }
 
 void
 gpgrt_log_debug (const char *fmt, ...)
 {
   va_list arg_ptr ;
 
   va_start (arg_ptr, fmt);
   _gpgrt_logv (GPGRT_LOGLVL_DEBUG, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
 void
 gpgrt_log_debug_string (const char *string, const char *fmt, ...)
 {
   va_list arg_ptr ;
 
   va_start (arg_ptr, fmt);
   _gpgrt_logv_internal (GPGRT_LOGLVL_DEBUG, 0, string, NULL, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
 void
 gpgrt_log_printf (const char *fmt, ...)
 {
   va_list arg_ptr;
 
   va_start (arg_ptr, fmt);
   _gpgrt_logv (fmt ? GPGRT_LOGLVL_CONT : GPGRT_LOGLVL_BEGIN, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
 void
 gpgrt_log_flush (void)
 {
   _gpgrt_log_flush ();
 }
 
 void
 gpgrt_log_printhex (const void *buffer, size_t length, const char *fmt, ...)
 {
   va_list arg_ptr;
 
   va_start (arg_ptr, fmt);
   _gpgrt_logv_printhex (buffer, length, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
 void
 gpgrt_log_clock (const char *fmt, ...)
 {
   va_list arg_ptr;
 
   va_start (arg_ptr, fmt);
   _gpgrt_logv_clock (fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
 void
 _gpgrt_log_assert (const char *expr, const char *file,
                    int line, const char *func)
 {
 #ifdef GPGRT_HAVE_MACRO_FUNCTION
   _gpgrt__log_assert (expr, file, line, func);
 #else
   _gpgrt__log_assert (expr, file, line);
 #endif
 }
 
 
 #if 0
 gpg_err_code_t
 gpgrt_make_pipe (int filedes[2], estream_t *r_fp, int direction, int nonblock)
 {
   return _gpgrt_make_pipe (filedes, r_fp, direction, nonblock);
 }
 
 gpg_err_code_t
 gpgrt_spawn_process (const char *pgmname, const char *argv[],
                      int *except, void (*preexec)(void), unsigned int flags,
                      estream_t *r_infp, estream_t *r_outfp, estream_t *r_errfp,
                      pid_t *pid)
 {
   return _gpgrt_spawn_process (pgmname, argv, except, preexec, flags,
                                r_infp, r_outfp, r_errfp, pid);
 }
 
 gpg_err_code_t
 gpgrt_spawn_process_fd (const char *pgmname, const char *argv[],
                         int infd, int outfd, int errfd, pid_t *pid)
 {
   return _gpgrt_spawn_process_fd (pgmname, argv, infd, outfd, errfd, pid);
 }
 
 gpg_err_code_t
 gpgrt_spawn_process_detached (const char *pgmname, const char *argv[],
                               const char *envp[])
 {
   return _gpgrt_spawn_process_detached (pgmname, argv, envp);
 }
 
 gpg_err_code_t
 gpgrt_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode)
 {
   return _gpgrt_wait_process (pgmname, pid, hang, r_exitcode);
 }
 
 gpg_err_code_t
 gpgrt_wait_processes (const char **pgmnames, pid_t *pids,
                       size_t count, int hang, int *r_exitcodes)
 {
   return _gpgrt_wait_processes (pgmnames, pids, count, hang, r_exitcodes);
 }
 
 void
 gpgrt_kill_process (pid_t pid)
 {
   _gpgrt_kill_process (pid);
 }
 
 void
 gpgrt_release_process (pid_t pid)
 {
   _gpgrt_release_process (pid);
 }
 #endif /*0*/
 
 
 int
 gpgrt_argparse (estream_t fp, gpgrt_argparse_t *arg, gpgrt_opt_t *opts)
 {
   return _gpgrt_argparse (fp, arg, opts);
 }
 
+int
+gpgrt_argparser (gpgrt_argparse_t *arg, gpgrt_opt_t *opts, const char *name)
+{
+  return _gpgrt_argparser (arg, opts, name);
+}
+
 void
 gpgrt_usage (int level)
 {
   _gpgrt_usage (level);
 }
 
 const char *
 gpgrt_strusage (int level)
 {
   return _gpgrt_strusage (level);
 }
 
 void
 gpgrt_set_strusage (const char *(*f)(int))
 {
   _gpgrt_set_strusage (f);
 }
 
 void
 gpgrt_set_usage_outfnc (int (*f)(int, const char *))
 {
   _gpgrt_set_usage_outfnc (f);
 }
 
 void
 gpgrt_set_fixed_string_mapper (const char *(*f)(const char*))
 {
   _gpgrt_set_fixed_string_mapper (f);
 }
 
+void
+gpgrt_set_confdir (int what, const char *name)
+{
+  _gpgrt_set_confdir (what, name);
+}
+
 
 
 /* Compare program versions.  */
 int
 gpgrt_cmp_version (const char *a, const char *b, int level)
 {
   return _gpgrt_cmp_version (a, b, level);
 }
 
 
 
 /* String utilities.  */
 char *
 gpgrt_fnameconcat (const char *first, ... )
 {
   va_list arg_ptr;
   char *result;
 
   va_start (arg_ptr, first);
   result = _gpgrt_vfnameconcat (0, first, arg_ptr);
   va_end (arg_ptr);
   return result;
 }
 
 char *
 gpgrt_absfnameconcat (const char *first, ... )
 {
   va_list arg_ptr;
   char *result;
 
   va_start (arg_ptr, first);
   result = _gpgrt_vfnameconcat (1, first, arg_ptr);
   va_end (arg_ptr);
   return result;
 }
 
 
 
 /* For consistency reasons we use function wrappers also for Windows
  * specific function despite that they are technically not needed.  */
 #ifdef HAVE_W32_SYSTEM
 
 char *
 gpgrt_w32_reg_query_string (const char *root, const char *dir, const char *name)
 {
   return _gpgrt_w32_reg_query_string (root, dir, name);
 }
 
 #endif /*HAVE_W32_SYSTEM*/
diff --git a/src/visibility.h b/src/visibility.h
index 192f733..0759d2f 100644
--- a/src/visibility.h
+++ b/src/visibility.h
@@ -1,406 +1,410 @@
 /* visibility.h - Set visibility attribute
  * Copyright (C) 2014  g10 Code GmbH
  *
  * This file is part of libgpg-error.
  *
  * libgpg-error is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * libgpg-error is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, see <https://www.gnu.org/licenses/>.
  * SPDX-License-Identifier: LGPL-2.1+
  */
 
 #ifndef _GPGRT_VISIBILITY_H
 #define _GPGRT_VISIBILITY_H
 
 /* Include the main header here so that public symbols are mapped to
    the internal underscored ones.  */
 #ifdef _GPGRT_INCL_BY_VISIBILITY_C
 # include "gpgrt-int.h"
 #endif
 
 
 /* Our use of the ELF visibility feature works by passing
    -fvisibiliy=hidden on the command line and by explicitly marking
    all exported functions as visible.
 
    NOTE: When adding new functions, please make sure to add them to
          gpg-error.vers and gpg-error.def.in as well.  */
 
 #ifdef _GPGRT_INCL_BY_VISIBILITY_C
 
 # ifdef GPGRT_USE_VISIBILITY
 #  define MARK_VISIBLE(name) \
      extern __typeof__ (name) name __attribute__ ((visibility("default")));
 # else
 #  define MARK_VISIBLE(name) /* */
 # endif
 
 MARK_VISIBLE (gpg_strerror)
 MARK_VISIBLE (gpg_strerror_r)
 MARK_VISIBLE (gpg_strsource)
 MARK_VISIBLE (gpg_err_code_from_errno)
 MARK_VISIBLE (gpg_err_code_to_errno)
 MARK_VISIBLE (gpg_err_code_from_syserror)
 MARK_VISIBLE (gpg_err_set_errno)
 
 MARK_VISIBLE (gpg_err_init)
 MARK_VISIBLE (gpg_err_deinit)
 MARK_VISIBLE (gpgrt_add_emergency_cleanup)
 MARK_VISIBLE (gpgrt_abort)
 MARK_VISIBLE (gpg_error_check_version)
 MARK_VISIBLE (gpgrt_check_version)
 
 MARK_VISIBLE (gpgrt_lock_init)
 MARK_VISIBLE (gpgrt_lock_lock)
 MARK_VISIBLE (gpgrt_lock_unlock)
 MARK_VISIBLE (gpgrt_lock_destroy)
 MARK_VISIBLE (gpgrt_yield)
 MARK_VISIBLE (gpgrt_lock_trylock)
 
 MARK_VISIBLE (gpgrt_fopen)
 MARK_VISIBLE (gpgrt_mopen)
 MARK_VISIBLE (gpgrt_fopenmem)
 MARK_VISIBLE (gpgrt_fopenmem_init)
 MARK_VISIBLE (gpgrt_fdopen)
 MARK_VISIBLE (gpgrt_fdopen_nc)
 MARK_VISIBLE (gpgrt_sysopen)
 MARK_VISIBLE (gpgrt_sysopen_nc)
 MARK_VISIBLE (gpgrt_fpopen)
 MARK_VISIBLE (gpgrt_fpopen_nc)
 MARK_VISIBLE (gpgrt_freopen)
 MARK_VISIBLE (gpgrt_fopencookie)
 MARK_VISIBLE (gpgrt_fclose)
 MARK_VISIBLE (gpgrt_fclose_snatch)
 MARK_VISIBLE (gpgrt_onclose)
 MARK_VISIBLE (gpgrt_fileno)
 MARK_VISIBLE (gpgrt_fileno_unlocked)
 MARK_VISIBLE (gpgrt_syshd)
 MARK_VISIBLE (gpgrt_syshd_unlocked)
 MARK_VISIBLE (_gpgrt_set_std_fd)
 MARK_VISIBLE (_gpgrt_get_std_stream)
 MARK_VISIBLE (gpgrt_flockfile)
 MARK_VISIBLE (gpgrt_ftrylockfile)
 MARK_VISIBLE (gpgrt_funlockfile)
 MARK_VISIBLE (_gpgrt_pending)
 MARK_VISIBLE (_gpgrt_pending_unlocked)
 MARK_VISIBLE (gpgrt_feof)
 MARK_VISIBLE (gpgrt_feof_unlocked)
 MARK_VISIBLE (gpgrt_ferror)
 MARK_VISIBLE (gpgrt_ferror_unlocked)
 MARK_VISIBLE (gpgrt_clearerr)
 MARK_VISIBLE (gpgrt_clearerr_unlocked)
 MARK_VISIBLE (gpgrt_fflush)
 MARK_VISIBLE (gpgrt_fseek)
 MARK_VISIBLE (gpgrt_fseeko)
 MARK_VISIBLE (gpgrt_ftell)
 MARK_VISIBLE (gpgrt_ftello)
 MARK_VISIBLE (gpgrt_rewind)
 MARK_VISIBLE (gpgrt_ftruncate)
 MARK_VISIBLE (gpgrt_fgetc)
 MARK_VISIBLE (_gpgrt_getc_underflow)
 MARK_VISIBLE (gpgrt_fputc)
 MARK_VISIBLE (_gpgrt_putc_overflow)
 MARK_VISIBLE (gpgrt_ungetc)
 MARK_VISIBLE (gpgrt_read)
 MARK_VISIBLE (gpgrt_write)
 MARK_VISIBLE (gpgrt_write_sanitized)
 MARK_VISIBLE (gpgrt_write_hexstring)
 MARK_VISIBLE (gpgrt_fread)
 MARK_VISIBLE (gpgrt_fwrite)
 MARK_VISIBLE (gpgrt_fgets)
 MARK_VISIBLE (gpgrt_fputs)
 MARK_VISIBLE (gpgrt_fputs_unlocked)
 MARK_VISIBLE (gpgrt_getline)
 MARK_VISIBLE (gpgrt_read_line)
 MARK_VISIBLE (gpgrt_fprintf)
 MARK_VISIBLE (gpgrt_fprintf_unlocked)
 MARK_VISIBLE (gpgrt_fprintf_sf)
 MARK_VISIBLE (gpgrt_fprintf_sf_unlocked)
 MARK_VISIBLE (gpgrt_printf)
 MARK_VISIBLE (gpgrt_printf_unlocked)
 MARK_VISIBLE (gpgrt_vfprintf)
 MARK_VISIBLE (gpgrt_vfprintf_unlocked)
 MARK_VISIBLE (gpgrt_setvbuf)
 MARK_VISIBLE (gpgrt_setbuf)
 MARK_VISIBLE (gpgrt_set_binary)
 MARK_VISIBLE (gpgrt_set_nonblock)
 MARK_VISIBLE (gpgrt_get_nonblock)
 MARK_VISIBLE (gpgrt_poll)
 MARK_VISIBLE (gpgrt_tmpfile)
 MARK_VISIBLE (gpgrt_opaque_set)
 MARK_VISIBLE (gpgrt_opaque_get)
 MARK_VISIBLE (gpgrt_fname_set)
 MARK_VISIBLE (gpgrt_fname_get)
 MARK_VISIBLE (gpgrt_asprintf)
 MARK_VISIBLE (gpgrt_vasprintf)
 MARK_VISIBLE (gpgrt_bsprintf)
 MARK_VISIBLE (gpgrt_vbsprintf)
 MARK_VISIBLE (gpgrt_snprintf)
 MARK_VISIBLE (gpgrt_vsnprintf)
 
 MARK_VISIBLE (gpgrt_set_syscall_clamp)
 MARK_VISIBLE (gpgrt_get_syscall_clamp)
 MARK_VISIBLE (gpgrt_set_alloc_func)
 
 MARK_VISIBLE (gpgrt_realloc)
 MARK_VISIBLE (gpgrt_malloc)
 MARK_VISIBLE (gpgrt_calloc)
 MARK_VISIBLE (gpgrt_strdup)
 MARK_VISIBLE (gpgrt_strconcat)
 MARK_VISIBLE (gpgrt_free)
 MARK_VISIBLE (gpgrt_getenv)
 MARK_VISIBLE (gpgrt_setenv)
 MARK_VISIBLE (gpgrt_mkdir)
 MARK_VISIBLE (gpgrt_chdir)
 MARK_VISIBLE (gpgrt_getcwd)
 
 MARK_VISIBLE (gpgrt_b64dec_start)
 MARK_VISIBLE (gpgrt_b64dec_proc)
 MARK_VISIBLE (gpgrt_b64dec_finish)
 MARK_VISIBLE (gpgrt_b64enc_start)
 MARK_VISIBLE (gpgrt_b64enc_write)
 MARK_VISIBLE (gpgrt_b64enc_finish)
 
 MARK_VISIBLE (gpgrt_get_errorcount)
 MARK_VISIBLE (gpgrt_inc_errorcount)
 MARK_VISIBLE (gpgrt_log_set_sink)
 MARK_VISIBLE (gpgrt_log_set_socket_dir_cb)
 MARK_VISIBLE (gpgrt_log_set_pid_suffix_cb)
 MARK_VISIBLE (gpgrt_log_set_prefix)
 MARK_VISIBLE (gpgrt_log_get_prefix)
 MARK_VISIBLE (gpgrt_log_test_fd)
 MARK_VISIBLE (gpgrt_log_get_fd)
 MARK_VISIBLE (gpgrt_log_get_stream)
 MARK_VISIBLE (gpgrt_log)
 MARK_VISIBLE (gpgrt_logv)
 MARK_VISIBLE (gpgrt_logv_prefix)
 MARK_VISIBLE (gpgrt_log_string)
 MARK_VISIBLE (gpgrt_log_bug)
 MARK_VISIBLE (gpgrt_log_fatal)
 MARK_VISIBLE (gpgrt_log_error)
 MARK_VISIBLE (gpgrt_log_info)
 MARK_VISIBLE (gpgrt_log_debug)
 MARK_VISIBLE (gpgrt_log_debug_string)
 MARK_VISIBLE (gpgrt_log_printf)
 MARK_VISIBLE (gpgrt_log_printhex)
 MARK_VISIBLE (gpgrt_log_clock)
 MARK_VISIBLE (gpgrt_log_flush)
 MARK_VISIBLE (_gpgrt_log_assert)
 
 #if 0
 MARK_VISIBLE (gpgrt_make_pipe)
 MARK_VISIBLE (gpgrt_spawn_process)
 MARK_VISIBLE (gpgrt_spawn_process_fd)
 MARK_VISIBLE (gpgrt_spawn_process_detached)
 MARK_VISIBLE (gpgrt_wait_process)
 MARK_VISIBLE (gpgrt_wait_processes)
 MARK_VISIBLE (gpgrt_kill_process)
 MARK_VISIBLE (gpgrt_release_process)
 #endif
 
 MARK_VISIBLE (gpgrt_argparse)
+MARK_VISIBLE (gpgrt_argparser)
 MARK_VISIBLE (gpgrt_usage)
 MARK_VISIBLE (gpgrt_strusage)
 MARK_VISIBLE (gpgrt_set_strusage)
 MARK_VISIBLE (gpgrt_set_fixed_string_mapper);
 MARK_VISIBLE (gpgrt_set_usage_outfnc);
+MARK_VISIBLE (gpgrt_set_confdir);
 
 MARK_VISIBLE (gpgrt_cmp_version);
 
 MARK_VISIBLE (gpgrt_fnameconcat);
 MARK_VISIBLE (gpgrt_absfnameconcat);
 
 
 #undef MARK_VISIBLE
 
 #else /*!_GPGRT_INCL_BY_VISIBILITY_C*/
 
 /* To avoid accidental use of the public functions inside Libgpg-error,
    we redefine them to catch such errors.  */
 
 #define gpg_strerror                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpg_strerror_r              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpg_strsource               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpg_err_code_from_errno     _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpg_err_code_to_errno       _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpg_err_code_from_syserror  _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpg_err_set_errno           _gpgrt_USE_UNDERSCORED_FUNCTION
 
 #define gpg_err_init                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpg_err_deinit              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_add_emergency_cleanup _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_abort                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpg_error_check_version     _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_check_version         _gpgrt_USE_OTHER_FUNCTION
 
 #define gpgrt_lock_init             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_lock_lock             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_lock_unlock           _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_lock_destroy          _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_yield                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_lock_trylock          _gpgrt_USE_UNDERSCORED_FUNCTION
 
 #define gpgrt_fopen                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_mopen                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fopenmem              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fopenmem_init         _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fdopen                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fdopen_nc             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_sysopen               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_sysopen_nc            _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fpopen                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fpopen_nc             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_freopen               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fopencookie           _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fclose                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fclose_snatch         _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_onclose               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fileno                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fileno_unlocked       _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_syshd                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_syshd_unlocked        _gpgrt_USE_UNDERSCORED_FUNCTION
 #define _gpgrt_set_std_fd           _gpgrt_USE_UNDERSCORED_FUNCTION
 #define _gpgrt_get_std_stream       _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_flockfile             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_ftrylockfile          _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_funlockfile           _gpgrt_USE_UNDERSCORED_FUNCTION
 #define _gpgrt_pending              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define _gpgrt_pending_unlocked     _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_feof                  _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_feof_unlocked         _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_ferror                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_ferror_unlocked       _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_clearerr              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_clearerr_unlocked     _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fflush                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fseek                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fseeko                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_ftell                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_ftello                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_rewind                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_ftruncate             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fgetc                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define _gpgrt_getc_underflow       _gpgrt_USE_DBLUNDERSCO_FUNCTION
 #define gpgrt_fputc                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define _gpgrt_putc_overflow        _gpgrt_USE_DBLUNDERSCO_FUNCTION
 #define gpgrt_ungetc                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_read                  _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_write                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_write_sanitized       _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_write_hexstring       _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fread                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fwrite                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fgets                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fputs                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fputs_unlocked        _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_getline               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_read_line             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fprintf               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fprintf_unlocked      _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fprintf_sf            _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fprintf_sf_unlocked   _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_printf                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_printf_unlocked       _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_vfprintf              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_vfprintf_unlocked     _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_setvbuf               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_setbuf                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_set_binary            _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_set_nonblock          _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_get_nonblock          _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_poll                  _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_tmpfile               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_opaque_set            _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_opaque_get            _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fname_set             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_fname_get             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_asprintf              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_vasprintf             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_bsprintf              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_vbsprintf             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_snprintf              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_vsnprintf             _gpgrt_USE_UNDERSCORED_FUNCTION
 
 #define gpgrt_realloc               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_malloc                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_calloc                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_strdup                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_strconcat             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_free                  _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_getenv                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_setenv                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_mkdir                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_chdir                 _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_getcwd                _gpgrt_USE_UNDERSCORED_FUNCTION
 
 #define gpgrt_set_syscall_clamp     _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_get_syscall_clamp     _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_set_alloc_func        _gpgrt_USE_UNDERSCORED_FUNCTION
 
 #define gpgrt_b64enc_start          _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_b64enc_write          _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_b64enc_finish         _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_b64dec_start          _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_b64dec_proc           _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_b64dec_finish         _gpgrt_USE_UNDERSCORED_FUNCTION
 
 #define gpgrt_get_errorcount        _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_inc_errorcount        _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_set_sink          _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_set_socket_dir_cb _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_set_pid_suffix_cb _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_set_prefix        _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_get_prefix        _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_test_fd           _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_get_fd            _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_get_stream        _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log                   _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_logv                  _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_logv_prefix           _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_string            _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_bug               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_fatal             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_error             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_info              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_debug             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_debug_string      _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_printf            _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_printhex          _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_clock             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_log_flush             _gpgrt_USE_UNDERSCORED_FUNCTION
 #define _gpgrt_log_assert           _gpgrt_USE_UNDERSCORED_FUNCTION
 
 #define gpgrt_make_pipe              _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_spawn_process          _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_spawn_process_fd       _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_spawn_process_detached _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_wait_process           _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_wait_processes         _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_kill_process           _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_release_process        _gpgrt_USE_UNDERSCORED_FUNCTION
 
 #define gpgrt_argparse                _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpgrt_argparser               _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_usage                   _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_set_strusage            _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_strusage                _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_set_usage_outfnc        _gpgrt_USE_UNDERSCORED_FUNCTION
 #define gpgrt_set_fixed_string_mapper _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpgrt_set_confdir             _gpgrt_USE_UNDERSCORED_FUNCTION
 
 #define gpgrt_cmp_version           _gpgrt_USE_UNDERSCORED_FUNCTION
 
 /* Windows specific functions.  */
 #define gpgrt_w32_reg_query_string  _gpgrt_USE_UNDERSCORED_FUNCTION
 
 
 #endif /*!_GPGRT_INCL_BY_VISIBILITY_C*/
 
 #endif /*_GPGRT_VISIBILITY_H*/
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 39ca241..2d199da 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,42 +1,44 @@
 # Makefile.am for libgpg-error/tests.
 # Copyright (C) 2003 g10 Code GmbH
 #
 # This file is part of libgpg-error.
 #
 # libgpg-error is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as
 # published by the Free Software Foundation; either version 2.1 of the
 # License, or (at your option) any later version.
 #
 # libgpg-error is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
 ## Process this file with automake to produce Makefile.in
 
 if HAVE_W32CE_SYSTEM
 extra_includes = -idirafter $(top_builddir)/src/gpg-extra
 else
 extra_includes =
 endif
 
+EXTRA_DIST = t-argparse.conf etc/t-argparse.conf
+
 gpg_error_lib = ../src/libgpg-error.la
 
 TESTS = t-version t-strerror t-syserror t-lock t-printf t-poll t-b64 \
 	t-argparse t-logging t-stringutils
 
 AM_CPPFLAGS = -I$(top_builddir)/src $(extra_includes)
 
 AM_LDFLAGS = -no-install
 LDADD = $(gpg_error_lib) @LDADD_FOR_TESTS_KLUDGE@
 
 noinst_PROGRAMS = $(TESTS)
 noinst_HEADERS = t-common.h
 
 t_lock_LDADD = $(LDADD) $(LIBMULTITHREAD)
 t_poll_LDADD = $(LDADD) $(LIBMULTITHREAD)
diff --git a/tests/etc/t-argparse.conf b/tests/etc/t-argparse.conf
new file mode 100644
index 0000000..87bff72
--- /dev/null
+++ b/tests/etc/t-argparse.conf
@@ -0,0 +1,36 @@
+# Global test config file for t-argparse
+
+# Options applied to all user's config files
+#verbose
+
+#[user :staff]
+# These option are applied to all users the group staff up until the
+# next [user statement]
+
+#[+force]
+
+#[ignore]
+
+# The compliance is set immutable for these users
+verbose
+
+#no-verbose
+
+
+# (parsing does not stop for a group)
+#[user wk]
+# Options for user wk
+
+# Change the immutable flag back to mutable.
+#[] compliance gnupg
+
+# Default key for wk
+my-option 42
+
+# Parsing stops for user WK here.
+
+#[user *]
+# Options for all users which have no specific user sections above
+
+# The default algorithm for new keys is set to this.
+a-long-option
diff --git a/tests/t-argparse.c b/tests/t-argparse.c
index 277d860..b2b6e51 100644
--- a/tests/t-argparse.c
+++ b/tests/t-argparse.c
@@ -1,126 +1,152 @@
 /* t-argparse.c - Check the argparse API
- * Copyright (C) 2018 g10 Code GmbH
+ * Copyright (C) 2018, 2020 g10 Code GmbH
  *
  * This file is part of Libgpg-error.
  *
  * Libgpg-error is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * Libgpg-error is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public License
  * along with this program; if not, see <https://www.gnu.org/licenses/>.
  * SPDX-License-Identifier: LGPL-2.1-or-later
  */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
-#include "../src/gpg-error.h"
+#define PGM "t-argparse"
+#include "t-common.h"
 
 
 static struct {
     int verbose;
     int debug;
     char *outfile;
     char *crf;
     int myopt;
     int echo;
     int a_long_one;
 } opt;
 
 
 
 static const char *
 my_strusage (int level)
 {
   const char *p;
 
   switch (level)
     {
-    case 9: p = "GPL-2.0-or-later"; break;
+    case 9: p = "LGPL-2.1-or-later"; break;
 
     case 11: p = "t-argparse"; break;
 
     default: p = NULL;
     }
   return p;
 }
 
 
 
 int
 main (int argc, char **argv)
 {
   gpgrt_opt_t opts[] = {
     ARGPARSE_x  ('v', "verbose", NONE, 0, "Laut sein"),
     ARGPARSE_s_n('e', "echo"   , ("Zeile ausgeben, damit wir sehen, "
                                   "was wir eingegeben haben")),
     ARGPARSE_s_n('d', "debug", "Debug\nfalls mal etwas\nschief geht"),
     ARGPARSE_s_s('o', "output", 0 ),
     ARGPARSE_o_s('c', "cross-ref", "cross-reference erzeugen\n" ),
     /* Note that on a non-utf8 terminal the ß might garble the output. */
     ARGPARSE_s_n('s', "street","|Straße|set the name of the street to Straße"),
     ARGPARSE_o_i('m', "my-option", 0),
     ARGPARSE_s_n(500, "a-long-option", 0 ),
+    ARGPARSE_conffile(501, "options", "|FILE|read options from FILE"),
+    ARGPARSE_noconffile(502, "no-options", "Ignore conf files"),
     ARGPARSE_end()
   };
   gpgrt_argparse_t pargs = { &argc, &argv, (ARGPARSE_FLAG_ALL
                                             | ARGPARSE_FLAG_MIXED
-                                            | ARGPARSE_FLAG_ONEDASH) };
+                                            | ARGPARSE_FLAG_ONEDASH
+                                            | ARGPARSE_FLAG_SYS
+                                            | ARGPARSE_FLAG_USER
+                                            /* | ARGPARSE_FLAG_VERBOSE */
+                                            ) };
   int i;
+  const char *srcdir;
 
   gpgrt_set_strusage (my_strusage);
-
-
-  while (gpgrt_argparse  (NULL, &pargs, opts))
+  srcdir = getenv ("srcdir");
+  if (!srcdir)
+    srcdir = ".";
+  gpgrt_set_confdir (GPGRT_CONFDIR_USER, srcdir);
+  {
+    char *p = gpgrt_fnameconcat (srcdir, "etc", NULL);
+    gpgrt_set_confdir (GPGRT_CONFDIR_SYS, p);
+    xfree (p);
+  }
+
+  while (gpgrt_argparser  (&pargs, opts, PGM".conf"))
     {
+      /* printf ("got option %d\n", pargs.r_opt); */
       switch (pargs.r_opt)
         {
+        case ARGPARSE_CONFFILE:
+          printf ("current conffile='%s'\n",
+                  pargs.r.ret_str? pargs.r.ret_str: "[cmdline]");
+          break;
         case ARGPARSE_IS_ARG :
           printf ("arg='%s'\n", pargs.r.ret_str);
           break;
+
         case 'v': opt.verbose++; break;
         case 'e': opt.echo++; break;
-        case 'd': opt.debug++; break;
+        case 'd': opt.debug++; debug=1;break;
         case 'o': opt.outfile = pargs.r.ret_str; break;
         case 'c': opt.crf = pargs.r_type? pargs.r.ret_str:"a.crf"; break;
         case 'm': opt.myopt = pargs.r_type? pargs.r.ret_int : 1; break;
         case 500: opt.a_long_one++;  break;
         default : pargs.err = ARGPARSE_PRINT_ERROR; break;
 	}
     }
   for (i=0; i < argc; i++ )
     printf ("%3d -> (%s)\n", i, argv[i] );
   if (opt.verbose)
     puts ("Options:");
   if (opt.verbose)
     printf ("  verbose=%d\n", opt.verbose );
   if (opt.debug)
     printf ("  debug=%d\n", opt.debug );
   if (opt.outfile)
     printf ("  outfile='%s'\n", opt.outfile );
   if (opt.crf)
     printf ("  crffile='%s'\n", opt.crf );
   if (opt.myopt)
     printf ("  myopt=%d\n", opt.myopt );
   if (opt.a_long_one)
     printf ("  a-long-one=%d\n", opt.a_long_one );
   if (opt.echo)
     printf ("  echo=%d\n", opt.echo );
 
   gpgrt_argparse (NULL, &pargs, NULL);
 
+  (void)show;
+  (void)fail;
+  (void)die;
+
   return 0;
 }
diff --git a/tests/t-argparse.conf b/tests/t-argparse.conf
new file mode 100644
index 0000000..0bbdd3e
--- /dev/null
+++ b/tests/t-argparse.conf
@@ -0,0 +1,8 @@
+# User test config file for t-argparse
+
+# Options applied to all user's config files
+echo
+
+my-option 4711
+
+verbose