From 433bb8e84b2d1e50b5c5b9f7f2006b60cd7d7785 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Mon, 22 Feb 2016 19:07:41 +0100 Subject: [PATCH] Remove feature check ifdefs * lang/cpp/src/assuanresult.cpp, lang/cpp/src/callbacks.cpp, lang/cpp/src/configuration.cpp, lang/cpp/src/context.cpp, lang/cpp/src/context_glib.cpp, lang/cpp/src/context_qt.cpp, lang/cpp/src/context_vanilla.cpp, lang/cpp/src/data.cpp, lang/cpp/src/decryptionresult.cpp, lang/cpp/src/defaultassuantransaction.cpp, lang/cpp/src/editinteractor.cpp, lang/cpp/src/encryptionresult.cpp, lang/cpp/src/engineinfo.cpp, lang/cpp/src/eventloopinteractor.cpp, lang/cpp/src/global.h, lang/cpp/src/gpgagentgetinfoassuantransaction.cpp, lang/cpp/src/importresult.cpp, lang/cpp/src/interfaces/assuantransaction.h, lang/cpp/src/key.cpp, lang/cpp/src/keygenerationresult.cpp, lang/cpp/src/keylistresult.cpp, lang/cpp/src/scdgetinfoassuantransaction.cpp, lang/cpp/src/signingresult.cpp, lang/cpp/src/trustitem.cpp, lang/cpp/src/util.h, lang/cpp/src/verificationresult.cpp, lang/cpp/src/vfsmountresult.cpp: Remove feature checks. --- lang/cpp/src/assuanresult.cpp | 8 - lang/cpp/src/callbacks.cpp | 38 ---- lang/cpp/src/configuration.cpp | 214 +----------------- lang/cpp/src/context.cpp | 214 ------------------ lang/cpp/src/context_glib.cpp | 9 - lang/cpp/src/context_qt.cpp | 9 - lang/cpp/src/context_vanilla.cpp | 2 - lang/cpp/src/data.cpp | 11 - lang/cpp/src/decryptionresult.cpp | 36 --- lang/cpp/src/defaultassuantransaction.cpp | 2 - lang/cpp/src/editinteractor.cpp | 29 +-- lang/cpp/src/encryptionresult.cpp | 2 - lang/cpp/src/engineinfo.cpp | 6 - lang/cpp/src/eventloopinteractor.cpp | 2 - lang/cpp/src/global.h | 1 - .../src/gpgagentgetinfoassuantransaction.cpp | 2 - lang/cpp/src/importresult.cpp | 1 - lang/cpp/src/interfaces/assuantransaction.h | 2 + lang/cpp/src/key.cpp | 30 --- lang/cpp/src/keygenerationresult.cpp | 2 - lang/cpp/src/keylistresult.cpp | 2 - lang/cpp/src/scdgetinfoassuantransaction.cpp | 2 - lang/cpp/src/signingresult.cpp | 2 - lang/cpp/src/trustitem.cpp | 2 - lang/cpp/src/util.h | 35 +-- lang/cpp/src/verificationresult.cpp | 33 --- lang/cpp/src/vfsmountresult.cpp | 8 - 27 files changed, 12 insertions(+), 692 deletions(-) diff --git a/lang/cpp/src/assuanresult.cpp b/lang/cpp/src/assuanresult.cpp index 056aefb3..3d6d0a3a 100644 --- a/lang/cpp/src/assuanresult.cpp +++ b/lang/cpp/src/assuanresult.cpp @@ -20,8 +20,6 @@ Boston, MA 02110-1301, USA. */ -#include - #include #include "result_p.h" @@ -31,7 +29,6 @@ using namespace GpgME; -#ifdef HAVE_GPGME_ASSUAN_ENGINE class AssuanResult::Private { public: @@ -45,7 +42,6 @@ public: gpgme_error_t error; }; -#endif AssuanResult::AssuanResult(gpgme_ctx_t ctx, int error) : Result(error), d() @@ -62,7 +58,6 @@ AssuanResult::AssuanResult(gpgme_ctx_t ctx, const Error &error) void AssuanResult::init(gpgme_ctx_t ctx) { (void)ctx; -#ifdef HAVE_GPGME_ASSUAN_ENGINE if (!ctx) { return; } @@ -71,18 +66,15 @@ void AssuanResult::init(gpgme_ctx_t ctx) return; } d.reset(new Private(res)); -#endif } make_standard_stuff(AssuanResult) Error AssuanResult::assuanError() const { -#ifdef HAVE_GPGME_ASSUAN_ENGINE if (d) { return Error(d->error); } -#endif return Error(); } diff --git a/lang/cpp/src/callbacks.cpp b/lang/cpp/src/callbacks.cpp index 091975d7..4b4dd806 100644 --- a/lang/cpp/src/callbacks.cpp +++ b/lang/cpp/src/callbacks.cpp @@ -20,8 +20,6 @@ Boston, MA 02110-1301, USA. */ -#include - #include "callbacks.h" #include "util.h" @@ -39,21 +37,9 @@ #include #include -#ifndef HAVE_GPGME_SSIZE_T -# define gpgme_ssize_t ssize_t -#endif - -#ifndef HAVE_GPGME_OFF_T -# define gpgme_off_t off_t -#endif - static inline gpgme_error_t make_err_from_syserror() { -#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS return gpgme_error_from_syserror(); -#else - return gpg_error_from_syserror(); -#endif } using GpgME::ProgressProvider; @@ -92,11 +78,7 @@ gpgme_error_t passphrase_callback(void *opaque, const char *uid_hint, const char size_t passphrase_length = std::strlen(passphrase); size_t written = 0; do { -#ifdef HAVE_GPGME_IO_READWRITE ssize_t now_written = gpgme_io_write(fd, passphrase + written, passphrase_length - written); -#else - ssize_t now_written = write(fd, passphrase + written, passphrase_length - written); -#endif if (now_written < 0) { err = make_err_from_syserror(); break; @@ -110,11 +92,7 @@ gpgme_error_t passphrase_callback(void *opaque, const char *uid_hint, const char wipememory(passphrase, std::strlen(passphrase)); } free(passphrase); -#ifdef HAVE_GPGME_IO_READWRITE gpgme_io_write(fd, "\n", 1); -#else - write(fd, "\n", 1); -#endif return err; } @@ -123,11 +101,7 @@ data_read_callback(void *opaque, void *buf, size_t buflen) { DataProvider *provider = static_cast(opaque); if (!provider) { -#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); -#else - gpg_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); -#endif return -1; } return (gpgme_ssize_t)provider->read(buf, buflen); @@ -138,11 +112,7 @@ data_write_callback(void *opaque, const void *buf, size_t buflen) { DataProvider *provider = static_cast(opaque); if (!provider) { -#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); -#else - gpg_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); -#endif return -1; } return (gpgme_ssize_t)provider->write(buf, buflen); @@ -153,19 +123,11 @@ data_seek_callback(void *opaque, gpgme_off_t offset, int whence) { DataProvider *provider = static_cast(opaque); if (!provider) { -#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); -#else - gpg_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); -#endif return -1; } if (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END) { -#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); -#else - gpg_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); -#endif return -1; } return provider->seek((off_t)offset, whence); diff --git a/lang/cpp/src/configuration.cpp b/lang/cpp/src/configuration.cpp index fc19020e..8a23efcf 100644 --- a/lang/cpp/src/configuration.cpp +++ b/lang/cpp/src/configuration.cpp @@ -20,8 +20,6 @@ Boston, MA 02110-1301, USA. */ -#include - #include "configuration.h" #include "error.h" #include "util.h" @@ -58,7 +56,6 @@ struct nodelete { std::vector Component::load(Error &returnedError) { -#ifdef HAVE_GPGME_PROTOCOL_GPGCONF // // 1. get a context: // @@ -101,16 +98,11 @@ std::vector Component::load(Error &returnedError) } return result; -#else - returnedError = Error(make_error(GPG_ERR_NOT_SUPPORTED)); - return std::vector(); -#endif } Error Component::save() const { -#ifdef HAVE_GPGME_PROTOCOL_GPGCONF if (isNull()) { return Error(make_error(GPG_ERR_INV_ARG)); } @@ -128,41 +120,25 @@ Error Component::save() const // 2. save the config: // return Error(gpgme_op_conf_save(ctx.get(), comp.get())); -#else - return Error(make_error(GPG_ERR_NOT_SUPPORTED)); -#endif } const char *Component::name() const { -#ifdef HAVE_GPGME_PROTOCOL_GPGCONF return comp ? comp->name : 0 ; -#else - return 0; -#endif } const char *Component::description() const { -#ifdef HAVE_GPGME_PROTOCOL_GPGCONF return comp ? comp->description : 0 ; -#else - return 0; -#endif } const char *Component::programName() const { -#ifdef HAVE_GPGME_PROTOCOL_GPGCONF return comp ? comp->program_name : 0 ; -#else - return 0; -#endif } Option Component::option(unsigned int idx) const { -#ifdef HAVE_GPGME_PROTOCOL_GPGCONF gpgme_conf_opt_t opt = 0; if (comp) { opt = comp->options; @@ -173,17 +149,12 @@ Option Component::option(unsigned int idx) const } if (opt) { return Option(comp, opt); - } else { -#endif - return Option(); -#ifdef HAVE_GPGME_PROTOCOL_GPGCONF } -#endif + return Option(); } Option Component::option(const char *name) const { -#ifdef HAVE_GPGME_PROTOCOL_GPGCONF gpgme_conf_opt_t opt = 0; if (comp) { opt = comp->options; @@ -194,37 +165,28 @@ Option Component::option(const char *name) const } if (opt) { return Option(comp, opt); - } else { -#endif - return Option(); -#ifdef HAVE_GPGME_PROTOCOL_GPGCONF } -#endif + return Option(); } unsigned int Component::numOptions() const { unsigned int result = 0; -#ifdef HAVE_GPGME_PROTOCOL_GPGCONF for (gpgme_conf_opt_t opt = comp ? comp->options : 0 ; opt ; opt = opt->next) { ++result; } -#endif return result; } std::vector