[git] GpgOL - branch, master, updated. gpgol-2.3.1-17-ge60a442

by Andre Heinecke cvs at cvs.gnupg.org
Mon Oct 29 11:14:28 CET 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, master has been updated
       via  e60a442820182e4a6958f374c4de5a661551107d (commit)
      from  12535d4e5d510e6c66578399a534c334d6337749 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e60a442820182e4a6958f374c4de5a661551107d
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Oct 29 11:13:08 2018 +0100

    Enable building tests for windows
    
    * src/debug.cpp: Use platform indepentent gpgrt_locks.
    * src/main.c (initialize_main): Drop mutex init.

diff --git a/Makefile.am b/Makefile.am
index 1c99b44..4f80a37 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,7 +25,7 @@ DISTCHECK_CONFIGURE_FLAGS = --host=@host@  --build=@build@ \
 EXTRA_DIST = autogen.sh autogen.rc
 
 if HAVE_W32_SYSTEM
-SUBDIRS = src forms po m4 doc
+SUBDIRS = src tests forms po m4 doc
 else
 SUBDIRS = tests
 endif
diff --git a/src/debug.cpp b/src/debug.cpp
index 88e2923..fcc0450 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -29,14 +29,14 @@
 static char *logfile;
 static FILE *logfp;
 
-#ifdef HAVE_W32_SYSTEM
+GPGRT_LOCK_DEFINE (log_lock);
 
 /* Acquire the mutex for logging.  Returns 0 on success. */
 static int
 lock_log (void)
 {
-  int code = WaitForSingleObject (log_mutex, 10000);
-  return code != WAIT_OBJECT_0;
+  gpgrt_lock_lock (&log_lock);
+  return 0;
 }
 
 /* Release the mutex for logging. No error return is done because this
@@ -45,9 +45,8 @@ lock_log (void)
 static void
 unlock_log (void)
 {
-  ReleaseMutex (log_mutex);
+  gpgrt_lock_unlock (&log_lock);
 }
-#endif
 
 const char *
 get_log_file (void)
diff --git a/src/main.c b/src/main.c
index 50f5061..56b92ad 100644
--- a/src/main.c
+++ b/src/main.c
@@ -39,26 +39,6 @@ static void drop_locale_dir (char *locale_dir);
 int g_ol_version_major;
 
 
-/* For certain operations we need to acquire a log on the logging
-   functions.  This lock is controlled by this Mutex. */
-HANDLE log_mutex;
-
-/* Early initialization of this module.  This is done right at startup
-   with only one thread running.  Should be called only once. Returns
-   0 on success. */
-static int
-initialize_main (void)
-{
-  SECURITY_ATTRIBUTES sa;
-
-  memset (&sa, 0, sizeof sa);
-  sa.bInheritHandle = FALSE;
-  sa.lpSecurityDescriptor = NULL;
-  sa.nLength = sizeof sa;
-  log_mutex = CreateMutex (&sa, FALSE, NULL);
-  return log_mutex? 0 : -1;
-}
-
 void
 i18n_init (void)
 {
@@ -134,10 +114,6 @@ DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
          version string) is not used here.  It may be called at any
          time later for this. */
       gpgme_check_version (NULL);
-
-      /* Early initializations of our subsystems. */
-      if (initialize_main ())
-        return FALSE;
     }
   else if (reason == DLL_PROCESS_DETACH)
     {
diff --git a/src/memdbg.cpp b/src/memdbg.cpp
index a720e4f..9653c0b 100644
--- a/src/memdbg.cpp
+++ b/src/memdbg.cpp
@@ -39,7 +39,7 @@ GPGRT_LOCK_DEFINE (memdbg_log);
 
 #define DBGGUARD if (!(opt.enable_debug & DBG_MEMORY)) return
 
-#ifdef HAVE_W32_SYSTEM
+#ifndef BUILD_TESTS
 # include "oomhelp.h"
 #endif
 
@@ -47,7 +47,7 @@ GPGRT_LOCK_DEFINE (memdbg_log);
 static bool
 register_name (void *obj, const char *nameSuggestion)
 {
-#ifdef HAVE_W32_SYSTEM
+#ifndef BUILD_TESTS
 
   char *name = get_object_name ((LPUNKNOWN)obj);
   bool suggestionUsed = false;
@@ -94,6 +94,7 @@ register_name (void *obj, const char *nameSuggestion)
     }
 #else
   (void) obj;
+  (void) nameSuggestion;
 #endif
   return false;
 }
diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index 826b597..9c925f8 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -43,7 +43,6 @@
 #endif
 
 
-
 const char decrypt_template_html[] = {
 "<html><head></head><body>"
 "<table border=\"0\" width=\"100%%\" cellspacing=\"1\" cellpadding=\"1\" bgcolor=\"#0069cc\">"
@@ -76,6 +75,39 @@ expect_no_mime (msgtype_t type)
          type == MSGTYPE_GPGOL_CLEAR_SIGNED;
 }
 
+#ifdef BUILD_TESTS
+static void
+get_and_print_key_test (const char *fingerprint, GpgME::Protocol proto)
+{
+  if (!fingerprint)
+    {
+      STRANGEPOINT;
+      return;
+    }
+  auto ctx = std::unique_ptr<GpgME::Context> (GpgME::Context::createForProtocol
+                                              (proto));
+
+  if (!ctx)
+    {
+      STRANGEPOINT;
+      return;
+    }
+  ctx->setKeyListMode (GpgME::KeyListMode::Local |
+                       GpgME::KeyListMode::Signatures |
+                       GpgME::KeyListMode::Validate |
+                       GpgME::KeyListMode::WithTofu);
+
+  GpgME::Error err;
+  const auto newKey = ctx->key (fingerprint, err, false);
+
+  std::stringstream ss;
+  ss << newKey;
+
+  log_debug ("Key: %s", ss.str().c_str());
+  return;
+}
+#endif
+
 #ifdef HAVE_W32_SYSTEM
 ParseController::ParseController(LPSTREAM instream, msgtype_t type):
     m_inputprovider  (new MimeDataProvider(instream,
@@ -498,7 +530,9 @@ ParseController::parse()
       TRACEPOINT;
       has_valid_encrypted_checksum = is_valid_chksum (sig);
 
+#ifndef BUILD_TESTS
       KeyCache::instance ()->update (sig.fingerprint (), protocol);
+#endif
       TRACEPOINT;
     }
 
@@ -520,8 +554,12 @@ ParseController::parse()
           const auto key = sig.key();
           if (key.isNull())
             {
+#ifndef BUILD_TESTS
               ss << '\n' << "Cached key:\n" << KeyCache::instance()->getByFpr(
                   sig.fingerprint(), false);
+#else
+              get_and_print_key_test (sig.fingerprint (), protocol);
+#endif
             }
           else
             {
diff --git a/src/rfc2047parse.c b/src/rfc2047parse.c
index fd8bd1b..7dd81af 100644
--- a/src/rfc2047parse.c
+++ b/src/rfc2047parse.c
@@ -605,12 +605,12 @@ rfc2047_decode_tokens (rfc2047_token *tokens, size_t buflen)
           if (!strcasecmp (charset, "UTF-8")) {
               strncat (decoded, (char *) outptr, outlen);
           } else {
-#ifdef HAVE_W32_SYSTEM
+#ifndef BUILD_TESTS
               str = ansi_charset_to_utf8 (charset, outptr, outlen, 0);
 #else
-              log_debug ("%s:%s: Conversion not available on non W32 systems",
+              log_debug ("%s:%s: Conversion not available for testing",
                          SRCNAME, __func__);
-              str = strndup (outptr, outlen);
+              str = strdup (outptr);
 #endif
               if (!str)
                 {
diff --git a/src/w32-gettext.cpp b/src/w32-gettext.cpp
index ab762b2..6fd14dc 100644
--- a/src/w32-gettext.cpp
+++ b/src/w32-gettext.cpp
@@ -791,7 +791,11 @@ _nl_locale_name (int category, const char *categoryname)
     return retval;
 
   /* Prefer the Ui language of Outlook. */
+#ifndef BUILD_TESTS
   lcid = get_ol_ui_language ();
+#else
+  lcid = 0;
+#endif
 
   if (!lcid)
     {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bb4a5a6..42ca92e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,14 +21,25 @@
 
 GPG = gpg
 
+if HAVE_W32_SYSTEM
 TESTS = t-parser
+endif
 
 AM_LDFLAGS = @GPGME_LIBS@ -lgpgmepp
 
-AM_CFLAGS = -I$(top_srcdir)/src $(GPGME_CFLAGS) $(LIBASSUAN_CFLAGS)
+AM_CFLAGS = -I$(top_srcdir)/src $(GPGME_CFLAGS) $(LIBASSUAN_CFLAGS) -DBUILD_TESTS
 AM_CXXFLAGS = -I$(top_srcdir)/src $(GPGME_CFLAGS) $(GPGME_CFLAGS)/gpgme++ \
-			  $(LIBASSUAN_CFLAGS) -std=c++11 -DDATADIR=\"$(abs_srcdir)/data\" \
-			  -DGPGHOMEDIR=\"$(abs_srcdir)/gnupg_home\"
+			  $(LIBASSUAN_CFLAGS) -std=c++11  -D_FILE_OFFSET_BITS=64 \
+			  -DBUILD_TESTS
+LDADD = ../src/gpgol.la @GPG_ERROR_LIBS@
+
+if HAVE_W32_SYSTEM
+run_parser_LDADD =  \
+	-L ../src -lgpgmepp -lgpgme -lassuan -lgpg-error \
+	-lmapi32 -lshell32 -lgdi32 -lcomdlg32 \
+	-lole32 -loleaut32 -lws2_32 -ladvapi32 \
+	-luuid -lgdiplus -lrpcrt4
+endif
 
 parser_SRC= ../src/parsecontroller.cpp \
 			../src/parsecontroller.h \
@@ -37,9 +48,19 @@ parser_SRC= ../src/parsecontroller.cpp \
 			../src/rfc822parse.c ../src/rfc822parse.h \
 			../src/rfc2047parse.c ../src/rfc2047parse.h \
 			../src/common_indep.c ../src/common_indep.h \
+			../src/debug.cpp ../src/debug.h \
+			../src/memdbg.cpp ../src/memdbg.h \
+			../src/cpphelp.cpp ../src/cpphelp.h \
+			../src/w32-gettext.cpp ../src/w32-gettext.h \
 			../src/xmalloc.h
 
+if !HAVE_W32_SYSTEM
 t_parser_SOURCES = t-parser.cpp $(parser_SRC)
+endif
 run_parser_SOURCES = run-parser.cpp $(parser_SRC)
 
+if !HAVE_W32_SYSTEM
 noinst_PROGRAMS = t-parser run-parser
+else
+noinst_PROGRAMS = run-parser
+endif
diff --git a/tests/run-parser.cpp b/tests/run-parser.cpp
index f759496..b908360 100644
--- a/tests/run-parser.cpp
+++ b/tests/run-parser.cpp
@@ -63,7 +63,7 @@ int main(int argc, char **argv)
         show_usage (0);
       else if (!strcmp (*argv, "--verbose"))
         {
-          opt.enable_debug |= DBG_MIME_PARSER;
+          opt.enable_debug |= DBG_DATA;
           opt.enable_debug |= 1;
           set_log_file ("stderr");
           argc--; argv++;

-----------------------------------------------------------------------

Summary of changes:
 Makefile.am             |  2 +-
 src/debug.cpp           |  9 ++++-----
 src/main.c              | 24 ------------------------
 src/memdbg.cpp          |  5 +++--
 src/parsecontroller.cpp | 40 +++++++++++++++++++++++++++++++++++++++-
 src/rfc2047parse.c      |  6 +++---
 src/w32-gettext.cpp     |  4 ++++
 tests/Makefile.am       | 27 ++++++++++++++++++++++++---
 tests/run-parser.cpp    |  2 +-
 9 files changed, 79 insertions(+), 40 deletions(-)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list