diff --git a/src/gpg-error.def.in b/src/gpg-error.def.in
index f4f3668..6aa3867 100644
--- a/src/gpg-error.def.in
+++ b/src/gpg-error.def.in
@@ -1,232 +1,232 @@
/* 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 .
* 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
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_secmem_init @169
gpgrt_secmem_term @170
gpgrt_secmem_malloc @171
gpgrt_secmem_realloc @172
gpgrt_secmem_free @173
gpgrt_secmem_dump_stats @174
gpgrt_secmem_set_auto_expand @175
gpgrt_secmem_set_flags @176
gpgrt_secmem_get_flags @177
- gpgrt_private_is_secure @178
+ gpgrt_secmem_is_secure @178
;; end of file with public symbols for Windows.
diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in
index 46d4ea7..feceb95 100644
--- a/src/gpg-error.h.in
+++ b/src/gpg-error.h.in
@@ -1,1301 +1,1301 @@
/* gpg-error.h or gpgrt.h - Common code for GnuPG and others. -*- c -*-
* Copyright (C) 2001-2018 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 .
* 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
#include
#include
/* 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
#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));
/*
* 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);
/* 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
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);
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_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_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. */
/* 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)
/* 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. */
/* 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) \
{ (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 */
/* 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);
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*));
/*
* secmem functions.
*/
/* Flags for _gpgrt_secmem_{set,get}_flags. */
#define GPGRT_SECMEM_FLAG_NO_WARNING (1 << 0)
#define GPGRT_SECMEM_FLAG_SUSPEND_WARNING (1 << 1)
#define GPGRT_SECMEM_FLAG_NOT_LOCKED (1 << 2)
#define GPGRT_SECMEM_FLAG_NO_MLOCK (1 << 3)
#define GPGRT_SECMEM_FLAG_NO_PRIV_DROP (1 << 4)
void gpgrt_secmem_init (size_t npool);
void gpgrt_secmem_term (void);
void *gpgrt_secmem_malloc (size_t size, int xhint) GPGRT_ATTR_MALLOC;
void *gpgrt_secmem_realloc (void *a, size_t newsize, int xhint);
int gpgrt_secmem_free (void *a);
void gpgrt_secmem_dump_stats (int extended);
void gpgrt_secmem_set_auto_expand (unsigned int chunksize);
void gpgrt_secmem_set_flags (unsigned flags);
unsigned gpgrt_secmem_get_flags (void);
-int gpgrt_private_is_secure (const void *p);
+int gpgrt_secmem_is_secure (const void *p);
#ifdef __cplusplus
}
#endif
#endif /* GPGRT_H */
#endif /* GPG_ERROR_H */
diff --git a/src/gpg-error.vers b/src/gpg-error.vers
index 4e58300..fdb1d1b 100644
--- a/src/gpg-error.vers
+++ b/src/gpg-error.vers
@@ -1,206 +1,206 @@
# 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 .
# 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_usage;
gpgrt_strusage;
gpgrt_set_strusage;
gpgrt_set_usage_outfnc;
gpgrt_set_fixed_string_mapper;
gpgrt_b64enc_start;
gpgrt_b64enc_write;
gpgrt_b64enc_finish;
gpgrt_secmem_init;
gpgrt_secmem_term;
gpgrt_secmem_malloc;
gpgrt_secmem_realloc;
gpgrt_secmem_free;
gpgrt_secmem_dump_stats;
gpgrt_secmem_set_auto_expand;
gpgrt_secmem_set_flags;
gpgrt_secmem_get_flags;
- gpgrt_private_is_secure;
+ gpgrt_secmem_is_secure;
local:
*;
};
diff --git a/src/gpgrt-int.h b/src/gpgrt-int.h
index 2cc3a4c..fec9c49 100644
--- a/src/gpgrt-int.h
+++ b/src/gpgrt-int.h
@@ -1,813 +1,813 @@
/* 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 .
* 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
# 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
# include
# else
# ifdef HAVE_WINSOCK2_H
# include
# endif
# include
# 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_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.
* and ist IOCTL numbers.
*/
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
/* 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.
*/
#define BUFFER_BLOCK_SIZE BUFSIZ
#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_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,
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_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 */
#define snprintf _gpgrt_estream_snprintf
#if HAVE_W32_SYSTEM
/* Prototypes for w32-estream.c. */
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;
int stop_seen:1;
int invalid_encoding:1;
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);
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*));
/*
* Local prototypes for secmem.
*/
void _gpgrt_secmem_init (size_t npool);
void _gpgrt_secmem_term (void);
void *_gpgrt_secmem_malloc (size_t size, int xhint) GPGRT_ATTR_MALLOC;
void *_gpgrt_secmem_realloc (void *a, size_t newsize, int xhint);
int _gpgrt_secmem_free (void *a);
void _gpgrt_secmem_dump_stats (int extended);
void _gpgrt_secmem_set_auto_expand (unsigned int chunksize);
void _gpgrt_secmem_set_flags (unsigned flags);
unsigned _gpgrt_secmem_get_flags (void);
-int _gpgrt_private_is_secure (const void *p);
+int _gpgrt_secmem_is_secure (const void *p);
/*
* 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);
/*
* 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/secmem.c b/src/secmem.c
index 7645093..108705f 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -1,887 +1,887 @@
/* secmem.c - memory allocation from a secure heap
* Copyright (C) 1998, 1999, 2000, 2001, 2002,
* 2003, 2007 Free Software Foundation, Inc.
* Copyright (C) 2013, 2016 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 .
* SPDX-License-Identifier: LGPL-2.1+
*
* This file was originally a part of libgcrypt.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#if defined(HAVE_MLOCK) || defined(HAVE_MMAP)
#include
#include
#include
#ifdef USE_CAPABILITIES
#include
#endif
#endif
#include "gpgrt-int.h"
#include "secmem.h"
#if defined (MAP_ANON) && ! defined (MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
#define MINIMUM_POOL_SIZE 16384
#define STANDARD_POOL_SIZE 32768
#define DEFAULT_PAGE_SIZE 4096
typedef struct memblock
{
unsigned size; /* Size of the memory available to the
user. */
int flags; /* See below. */
PROPERLY_ALIGNED_TYPE aligned;
} memblock_t;
/* This flag specifies that the memory block is in use. */
#define MB_FLAG_ACTIVE (1 << 0)
/* An object describing a memory pool. */
typedef struct pooldesc_s
{
/* A link to the next pool. This is used to connect the overflow
* pools. */
struct pooldesc_s *next;
/* A memory buffer used as allocation pool. */
void *mem;
/* The allocated size of MEM. */
size_t size;
/* Flag indicating that this memory pool is ready for use. May be
* checked in an atexit function. */
volatile int okay;
/* Flag indicating whether MEM is mmapped. */
volatile int is_mmapped;
/* The number of allocated bytes and the number of used blocks in
* this pool. */
unsigned int cur_alloced, cur_blocks;
} pooldesc_t;
/* The pool of secure memory. This is the head of a linked list with
* the first element being the standard mlock-ed pool and the
* following elements being the overflow pools. */
static pooldesc_t mainpool;
/* A couple of flags with some being set early. */
static int disable_secmem;
static int show_warning;
static int not_locked;
static int no_warning;
static int suspend_warning;
static int no_mlock;
static int no_priv_drop;
static unsigned int auto_expand;
/* Lock protecting accesses to the memory pools. */
GPGRT_LOCK_DEFINE (secmem_lock);
/* Convenient macros. */
#define SECMEM_LOCK _gpgrt_lock_lock (&secmem_lock)
#define SECMEM_UNLOCK _gpgrt_lock_unlock (&secmem_lock)
/* The size of the memblock structure; this does not include the
memory that is available to the user. */
#define BLOCK_HEAD_SIZE \
offsetof (memblock_t, aligned)
/* Convert an address into the according memory block structure. */
#define ADDR_TO_BLOCK(addr) \
(memblock_t *) (void *) ((char *) addr - BLOCK_HEAD_SIZE)
/* Check whether P points into POOL. */
static inline int
ptr_into_pool_p (pooldesc_t *pool, const void *p)
{
/* We need to convert pointers to addresses. This is required by
C-99 6.5.8 to avoid undefined behaviour. See also
http://lists.gnupg.org/pipermail/gcrypt-devel/2007-February/001102.html
*/
uintptr_t p_addr = (uintptr_t)p;
uintptr_t pool_addr = (uintptr_t)pool->mem;
return p_addr >= pool_addr && p_addr < pool_addr + pool->size;
}
/* Update the stats. */
static void
stats_update (pooldesc_t *pool, size_t add, size_t sub)
{
if (add)
{
pool->cur_alloced += add;
pool->cur_blocks++;
}
if (sub)
{
pool->cur_alloced -= sub;
pool->cur_blocks--;
}
}
/* Return the block following MB or NULL, if MB is the last block. */
static memblock_t *
mb_get_next (pooldesc_t *pool, memblock_t *mb)
{
memblock_t *mb_next;
mb_next = (memblock_t *) (void *) ((char *) mb + BLOCK_HEAD_SIZE + mb->size);
if (! ptr_into_pool_p (pool, mb_next))
mb_next = NULL;
return mb_next;
}
/* Return the block preceding MB or NULL, if MB is the first
block. */
static memblock_t *
mb_get_prev (pooldesc_t *pool, memblock_t *mb)
{
memblock_t *mb_prev, *mb_next;
if (mb == pool->mem)
mb_prev = NULL;
else
{
mb_prev = (memblock_t *) pool->mem;
while (1)
{
mb_next = mb_get_next (pool, mb_prev);
if (mb_next == mb)
break;
else
mb_prev = mb_next;
}
}
return mb_prev;
}
/* If the preceding block of MB and/or the following block of MB
exist and are not active, merge them to form a bigger block. */
static void
mb_merge (pooldesc_t *pool, memblock_t *mb)
{
memblock_t *mb_prev, *mb_next;
mb_prev = mb_get_prev (pool, mb);
mb_next = mb_get_next (pool, mb);
if (mb_prev && (! (mb_prev->flags & MB_FLAG_ACTIVE)))
{
mb_prev->size += BLOCK_HEAD_SIZE + mb->size;
mb = mb_prev;
}
if (mb_next && (! (mb_next->flags & MB_FLAG_ACTIVE)))
mb->size += BLOCK_HEAD_SIZE + mb_next->size;
}
/* Return a new block, which can hold SIZE bytes. */
static memblock_t *
mb_get_new (pooldesc_t *pool, memblock_t *block, size_t size)
{
memblock_t *mb, *mb_split;
for (mb = block; ptr_into_pool_p (pool, mb); mb = mb_get_next (pool, mb))
if (! (mb->flags & MB_FLAG_ACTIVE) && mb->size >= size)
{
/* Found a free block. */
mb->flags |= MB_FLAG_ACTIVE;
if (mb->size - size > BLOCK_HEAD_SIZE)
{
/* Split block. */
mb_split = (memblock_t *) (void *) (((char *) mb) + BLOCK_HEAD_SIZE
+ size);
mb_split->size = mb->size - size - BLOCK_HEAD_SIZE;
mb_split->flags = 0;
mb->size = size;
mb_merge (pool, mb_split);
}
break;
}
if (! ptr_into_pool_p (pool, mb))
{
_gpg_err_set_errno (ENOMEM);
mb = NULL;
}
return mb;
}
/* Print a warning message. */
static void
print_warn (void)
{
if (!no_warning)
_gpgrt_log_info (_("Warning: using insecure memory!\n"));
}
/* Lock the memory pages of pool P of size N into core and drop
* privileges. */
static void
lock_pool_pages (void *p, size_t n)
{
#if defined(USE_CAPABILITIES) && defined(HAVE_MLOCK)
int err;
{
cap_t cap;
if (!no_priv_drop)
{
cap = cap_from_text ("cap_ipc_lock+ep");
cap_set_proc (cap);
cap_free (cap);
}
err = no_mlock? 0 : mlock (p, n);
if (err && errno)
err = errno;
if (!no_priv_drop)
{
cap = cap_from_text ("cap_ipc_lock+p");
cap_set_proc (cap);
cap_free(cap);
}
}
if (err)
{
if (err != EPERM
#ifdef EAGAIN /* BSD and also Linux may return EAGAIN */
&& err != EAGAIN
#endif
#ifdef ENOSYS /* Some SCOs return this (function not implemented) */
&& err != ENOSYS
#endif
#ifdef ENOMEM /* Linux might return this. */
&& err != ENOMEM
#endif
)
_gpgrt_log_error ("can't lock memory: %s\n", strerror (err));
show_warning = 1;
not_locked = 1;
}
#elif defined(HAVE_MLOCK)
uid_t uid;
int err;
uid = getuid ();
#ifdef HAVE_BROKEN_MLOCK
/* Under HP/UX mlock segfaults if called by non-root. Note, we have
noch checked whether mlock does really work under AIX where we
also detected a broken nlock. Note further, that using plock ()
is not a good idea under AIX. */
if (uid)
{
errno = EPERM;
err = errno;
}
else
{
err = no_mlock? 0 : mlock (p, n);
if (err && errno)
err = errno;
}
#else /* !HAVE_BROKEN_MLOCK */
err = no_mlock? 0 : mlock (p, n);
if (err && errno)
err = errno;
#endif /* !HAVE_BROKEN_MLOCK */
/* Test whether we are running setuid(0). */
if (uid && ! geteuid ())
{
/* Yes, we are. */
if (!no_priv_drop)
{
/* Check that we really dropped the privs.
* Note: setuid(0) should always fail */
if (setuid (uid) || getuid () != geteuid () || !setuid (0))
_gpgrt_log_fatal ("failed to reset uid: %s\n", strerror (errno));
}
}
if (err)
{
if (err != EPERM
#ifdef EAGAIN /* BSD and also Linux may return this. */
&& err != EAGAIN
#endif
#ifdef ENOSYS /* Some SCOs return this (function not implemented). */
&& err != ENOSYS
#endif
#ifdef ENOMEM /* Linux might return this. */
&& err != ENOMEM
#endif
)
_gpgrt_log_error ("can't lock memory: %s\n", strerror (err));
show_warning = 1;
not_locked = 1;
}
#elif defined ( __QNX__ )
/* QNX does not page at all, so the whole secure memory stuff does
* not make much sense. However it is still of use because it
* wipes out the memory on a free().
* Therefore it is sufficient to suppress the warning. */
(void)p;
(void)n;
#elif defined (HAVE_DOSISH_SYSTEM) || defined (__CYGWIN__)
/* It does not make sense to print such a warning, given the fact that
* this whole Windows !@#$% and their user base are inherently insecure. */
(void)p;
(void)n;
#elif defined (__riscos__)
/* No virtual memory on RISC OS, so no pages are swapped to disc,
* besides we don't have mmap, so we don't use it! ;-)
* But don't complain, as explained above. */
(void)p;
(void)n;
#else
(void)p;
(void)n;
if (!no_mlock)
_gpgrt_log_info ("Please note that you don't have secure memory on this system\n");
#endif
}
/* Initialize POOL. */
static void
init_pool (pooldesc_t *pool, size_t n)
{
memblock_t *mb;
pool->size = n;
if (disable_secmem)
_gpgrt_log_bug ("secure memory is disabled");
#if HAVE_MMAP
{
size_t pgsize;
long int pgsize_val;
# if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
pgsize_val = sysconf (_SC_PAGESIZE);
# elif defined(HAVE_GETPAGESIZE)
pgsize_val = getpagesize ();
# else
pgsize_val = -1;
# endif
pgsize = (pgsize_val > 0)? pgsize_val:DEFAULT_PAGE_SIZE;
pool->size = (pool->size + pgsize - 1) & ~(pgsize - 1);
# ifdef MAP_ANONYMOUS
pool->mem = mmap (0, pool->size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
# else /* map /dev/zero instead */
{
int fd;
fd = open ("/dev/zero", O_RDWR);
if (fd == -1)
{
_gpgrt_log_error ("can't open /dev/zero: %s\n", strerror (errno));
pool->mem = (void *) -1;
}
else
{
pool->mem = mmap (0, pool->size,
(PROT_READ | PROT_WRITE), MAP_PRIVATE, fd, 0);
close (fd);
}
}
# endif
if (pool->mem == (void *) -1)
_gpgrt_log_info ("can't mmap pool of %u bytes: %s - using malloc\n",
(unsigned) pool->size, strerror (errno));
else
{
pool->is_mmapped = 1;
pool->okay = 1;
}
}
#endif /*HAVE_MMAP*/
if (!pool->okay)
{
pool->mem = malloc (pool->size);
if (!pool->mem)
_gpgrt_log_fatal ("can't allocate memory pool of %u bytes\n",
(unsigned) pool->size);
else
pool->okay = 1;
}
/* Initialize first memory block. */
mb = (memblock_t *) pool->mem;
mb->size = pool->size - BLOCK_HEAD_SIZE;
mb->flags = 0;
}
/* Enable overflow pool allocation in all cases. CHUNKSIZE is a hint
* on how large to allocate overflow pools. */
void
_gpgrt_secmem_set_auto_expand (unsigned int chunksize)
{
/* Round up to a multiple of the STANDARD_POOL_SIZE. */
chunksize = ((chunksize + (2*STANDARD_POOL_SIZE) - 1)
/ STANDARD_POOL_SIZE ) * STANDARD_POOL_SIZE;
if (chunksize < STANDARD_POOL_SIZE) /* In case of overflow. */
chunksize = STANDARD_POOL_SIZE;
SECMEM_LOCK;
auto_expand = chunksize;
SECMEM_UNLOCK;
}
void
_gpgrt_secmem_set_flags (unsigned flags)
{
int was_susp;
SECMEM_LOCK;
was_susp = suspend_warning;
no_warning = flags & GPGRT_SECMEM_FLAG_NO_WARNING;
suspend_warning = flags & GPGRT_SECMEM_FLAG_SUSPEND_WARNING;
no_mlock = flags & GPGRT_SECMEM_FLAG_NO_MLOCK;
no_priv_drop = flags & GPGRT_SECMEM_FLAG_NO_PRIV_DROP;
/* and now issue the warning if it is not longer suspended */
if (was_susp && !suspend_warning && show_warning)
{
show_warning = 0;
print_warn ();
}
SECMEM_UNLOCK;
}
unsigned int
_gpgrt_secmem_get_flags (void)
{
unsigned flags;
SECMEM_LOCK;
flags = no_warning ? GPGRT_SECMEM_FLAG_NO_WARNING : 0;
flags |= suspend_warning ? GPGRT_SECMEM_FLAG_SUSPEND_WARNING : 0;
flags |= not_locked ? GPGRT_SECMEM_FLAG_NOT_LOCKED : 0;
flags |= no_mlock ? GPGRT_SECMEM_FLAG_NO_MLOCK : 0;
flags |= no_priv_drop ? GPGRT_SECMEM_FLAG_NO_PRIV_DROP : 0;
SECMEM_UNLOCK;
return flags;
}
/* This function initializes the main memory pool MAINPOOL. Itis
* expected to be called with the secmem lock held. */
static void
_gpgrt_secmem_init_internal (size_t n)
{
pooldesc_t *pool;
pool = &mainpool;
if (!n)
{
#ifdef USE_CAPABILITIES
/* drop all capabilities */
if (!no_priv_drop)
{
cap_t cap;
cap = cap_from_text ("all-eip");
cap_set_proc (cap);
cap_free (cap);
}
#elif !defined(HAVE_DOSISH_SYSTEM)
uid_t uid;
disable_secmem = 1;
uid = getuid ();
if (uid != geteuid ())
{
if (setuid (uid) || getuid () != geteuid () || !setuid (0))
_gpgrt_log_fatal ("failed to drop setuid\n");
}
#endif
}
else
{
if (n < MINIMUM_POOL_SIZE)
n = MINIMUM_POOL_SIZE;
if (! pool->okay)
{
init_pool (pool, n);
lock_pool_pages (pool->mem, n);
}
else
_gpgrt_log_error ("Oops, secure memory pool already initialized\n");
}
}
/* Initialize the secure memory system. If running with the necessary
privileges, the secure memory pool will be locked into the core in
order to prevent page-outs of the data. Furthermore allocated
secure memory will be wiped out when released. */
void
_gpgrt_secmem_init (size_t n)
{
SECMEM_LOCK;
_gpgrt_secmem_init_internal (n);
SECMEM_UNLOCK;
}
static void *
_gpgrt_secmem_malloc_internal (size_t size, int xhint)
{
pooldesc_t *pool;
memblock_t *mb;
pool = &mainpool;
if (!pool->okay)
{
/* Try to initialize the pool if the user forgot about it. */
_gpgrt_secmem_init_internal (STANDARD_POOL_SIZE);
if (!pool->okay)
{
_gpgrt_log_info (_("operation is not possible without "
"initialized secure memory\n"));
_gpg_err_set_errno (ENOMEM);
return NULL;
}
}
if (show_warning && !suspend_warning)
{
show_warning = 0;
print_warn ();
}
/* Blocks are always a multiple of 32. */
size = ((size + 31) / 32) * 32;
mb = mb_get_new (pool, (memblock_t *) pool->mem, size);
if (mb)
{
stats_update (pool, mb->size, 0);
return &mb->aligned.c;
}
/* If we are called from xmalloc style function resort to the
* overflow pools to return memory. */
if ((xhint || auto_expand))
{
for (pool = pool->next; pool; pool = pool->next)
{
mb = mb_get_new (pool, (memblock_t *) pool->mem, size);
if (mb)
{
stats_update (pool, mb->size, 0);
return &mb->aligned.c;
}
}
/* Allocate a new overflow pool. We put a new pool right after
* the mainpool so that the next allocation will happen in that
* pool and not in one of the older pools. When this new pool
* gets full we will try to find space in the older pools. */
pool = calloc (1, sizeof *pool);
if (!pool)
return NULL; /* Not enough memory for a new pool descriptor. */
pool->size = auto_expand? auto_expand : STANDARD_POOL_SIZE;
pool->mem = malloc (pool->size);
if (!pool->mem)
return NULL; /* Not enough memory available for a new pool. */
/* Initialize first memory block. */
mb = (memblock_t *) pool->mem;
mb->size = pool->size - BLOCK_HEAD_SIZE;
mb->flags = 0;
pool->okay = 1;
/* Take care: in _gpgrt_private_is_secure we do not lock and thus
* we assume that the second assignment below is atomic. */
pool->next = mainpool.next;
mainpool.next = pool;
/* After the first time we allocated an overflow pool, print a
* warning. */
if (!pool->next)
print_warn ();
/* Allocate. */
mb = mb_get_new (pool, (memblock_t *) pool->mem, size);
if (mb)
{
stats_update (pool, mb->size, 0);
return &mb->aligned.c;
}
}
return NULL;
}
/* Allocate a block from the secmem of SIZE. With XHINT set assume
* that the caller is a xmalloc style function. */
void *
_gpgrt_secmem_malloc (size_t size, int xhint)
{
void *p;
SECMEM_LOCK;
p = _gpgrt_secmem_malloc_internal (size, xhint);
SECMEM_UNLOCK;
return p;
}
static int
_gpgrt_secmem_free_internal (void *a)
{
pooldesc_t *pool;
memblock_t *mb;
int size;
for (pool = &mainpool; pool; pool = pool->next)
if (pool->okay && ptr_into_pool_p (pool, a))
break;
if (!pool)
return 0; /* A does not belong to use. */
mb = ADDR_TO_BLOCK (a);
size = mb->size;
/* This does not make much sense: probably this memory is held in the
* cache. We do it anyway: */
#define MB_WIPE_OUT(byte) \
wipememory2 (((char *) mb + BLOCK_HEAD_SIZE), (byte), size);
MB_WIPE_OUT (0xff);
MB_WIPE_OUT (0xaa);
MB_WIPE_OUT (0x55);
MB_WIPE_OUT (0x00);
/* Update stats. */
stats_update (pool, 0, size);
mb->flags &= ~MB_FLAG_ACTIVE;
mb_merge (pool, mb);
return 1; /* Freed. */
}
/* Wipe out and release memory. Returns true if this function
* actually released A. */
int
_gpgrt_secmem_free (void *a)
{
int mine;
if (!a)
return 1; /* Tell caller that we handled it. */
SECMEM_LOCK;
mine = _gpgrt_secmem_free_internal (a);
SECMEM_UNLOCK;
return mine;
}
static void *
_gpgrt_secmem_realloc_internal (void *p, size_t newsize, int xhint)
{
memblock_t *mb;
size_t size;
void *a;
mb = (memblock_t *) (void *) ((char *) p
- ((size_t) &((memblock_t *) 0)->aligned.c));
size = mb->size;
if (newsize < size)
{
/* It is easier to not shrink the memory. */
a = p;
}
else
{
a = _gpgrt_secmem_malloc_internal (newsize, xhint);
if (a)
{
memcpy (a, p, size);
memset ((char *) a + size, 0, newsize - size);
_gpgrt_secmem_free_internal (p);
}
}
return a;
}
/* Realloc memory. With XHINT set assume that the caller is a xmalloc
* style function. */
void *
_gpgrt_secmem_realloc (void *p, size_t newsize, int xhint)
{
void *a;
SECMEM_LOCK;
a = _gpgrt_secmem_realloc_internal (p, newsize, xhint);
SECMEM_UNLOCK;
return a;
}
/* Return true if P points into the secure memory areas. */
int
-_gpgrt_private_is_secure (const void *p)
+_gpgrt_secmem_is_secure (const void *p)
{
pooldesc_t *pool;
/* We do no lock here because once a pool is allocatred it will not
* be removed anymore (except for gpgrt_secmem_term). Further,
* adding a new pool to the list should be atomic. */
for (pool = &mainpool; pool; pool = pool->next)
if (pool->okay && ptr_into_pool_p (pool, p))
return 1;
return 0;
}
/****************
* Warning: This code might be called by an interrupt handler
* and frankly, there should really be such a handler,
* to make sure that the memory is wiped out.
* We hope that the OS wipes out mlocked memory after
* receiving a SIGKILL - it really should do so, otherwise
* there is no chance to get the secure memory cleaned.
*/
void
_gpgrt_secmem_term ()
{
pooldesc_t *pool, *next;
for (pool = &mainpool; pool; pool = next)
{
next = pool->next;
if (!pool->okay)
continue;
wipememory2 (pool->mem, 0xff, pool->size);
wipememory2 (pool->mem, 0xaa, pool->size);
wipememory2 (pool->mem, 0x55, pool->size);
wipememory2 (pool->mem, 0x00, pool->size);
if (0)
;
#if HAVE_MMAP
else if (pool->is_mmapped)
munmap (pool->mem, pool->size);
#endif
else
free (pool->mem);
pool->mem = NULL;
pool->okay = 0;
pool->size = 0;
if (pool != &mainpool)
free (pool);
}
mainpool.next = NULL;
not_locked = 0;
}
/* Print stats of the secmem allocator. With EXTENDED passwed as true
* a detiled listing is returned (used for testing). */
void
_gpgrt_secmem_dump_stats (int extended)
{
pooldesc_t *pool;
memblock_t *mb;
int i, poolno;
SECMEM_LOCK;
for (pool = &mainpool, poolno = 0; pool; pool = pool->next, poolno++)
{
if (!extended)
{
if (pool->okay)
_gpgrt_log_info ("%-13s %u/%lu bytes in %u blocks\n",
pool == &mainpool? "secmem usage:":"",
pool->cur_alloced, (unsigned long)pool->size,
pool->cur_blocks);
}
else
{
for (i = 0, mb = (memblock_t *) pool->mem;
ptr_into_pool_p (pool, mb);
mb = mb_get_next (pool, mb), i++)
_gpgrt_log_info ("SECMEM: pool %d %s block %i size %i\n",
poolno,
(mb->flags & MB_FLAG_ACTIVE) ? "used" : "free",
i,
mb->size);
}
}
SECMEM_UNLOCK;
}
diff --git a/src/visibility.c b/src/visibility.c
index e11dc98..8d396ea 100644
--- a/src/visibility.c
+++ b/src/visibility.c
@@ -1,1195 +1,1195 @@
/* 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 .
* SPDX-License-Identifier: LGPL-2.1+
*/
#include
#include
#include /* 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);
}
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_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, format, ap);
}
int
gpgrt_vfprintf_unlocked (estream_t _GPGRT__RESTRICT stream,
const char *_GPGRT__RESTRICT format,
va_list ap)
{
return _gpgrt_vfprintf_unlocked (stream, format, ap);
}
int
gpgrt_printf (const char *_GPGRT__RESTRICT format, ...)
{
va_list ap;
int rc;
va_start (ap, format);
rc = _gpgrt_vfprintf (es_stdout, 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, 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, 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, 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);
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);
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);
}
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_secmem_init (size_t n)
{
_gpgrt_secmem_init (n);
}
void
gpgrt_secmem_term (void)
{
_gpgrt_secmem_term ();
}
void *
gpgrt_secmem_malloc (size_t size, int xhint)
{
return _gpgrt_secmem_malloc (size, xhint);
}
void *
gpgrt_secmem_realloc (void *a, size_t newsize, int xhint)
{
return _gpgrt_secmem_realloc (a, newsize, xhint);
}
int
gpgrt_secmem_free (void *a)
{
return _gpgrt_secmem_free (a);
}
void
gpgrt_secmem_dump_stats (int extended)
{
_gpgrt_secmem_dump_stats (extended);
}
void
gpgrt_secmem_set_auto_expand (unsigned int chunksize)
{
_gpgrt_secmem_set_auto_expand (chunksize);
}
void
gpgrt_secmem_set_flags (unsigned flags)
{
_gpgrt_secmem_set_flags (flags);
}
unsigned
gpgrt_secmem_get_flags (void)
{
return _gpgrt_secmem_get_flags ();
}
int
-gpgrt_private_is_secure (const void *p)
+gpgrt_secmem_is_secure (const void *p)
{
- return _gpgrt_private_is_secure (p);
+ return _gpgrt_secmem_is_secure (p);
}
/* 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 47ade34..afbf9ad 100644
--- a/src/visibility.h
+++ b/src/visibility.h
@@ -1,410 +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 .
* 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 (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_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_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_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_secmem_init);
MARK_VISIBLE (gpgrt_secmem_term);
MARK_VISIBLE (gpgrt_secmem_malloc);
MARK_VISIBLE (gpgrt_secmem_realloc);
MARK_VISIBLE (gpgrt_secmem_free);
MARK_VISIBLE (gpgrt_secmem_dump_stats);
MARK_VISIBLE (gpgrt_secmem_set_auto_expand);
MARK_VISIBLE (gpgrt_secmem_set_flags);
MARK_VISIBLE (gpgrt_secmem_get_flags);
-MARK_VISIBLE (gpgrt_private_is_secure);
+MARK_VISIBLE (gpgrt_secmem_is_secure);
#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 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_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_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_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_secmem_init _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_secmem_term _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_secmem_malloc _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_secmem_realloc _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_secmem_free _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_secmem_dump_stats _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_secmem_set_auto_expand _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_secmem_set_flags _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_secmem_get_flags _gpgrt_USE_UNDERSCORED_FUNCTION
-#define gpgrt_private_is_secure _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpgrt_secmem_is_secure _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*/