[git] GPGME - branch, master, updated. gpgme-1.12.0-36-g63ba09b

by Werner Koch cvs at cvs.gnupg.org
Thu Nov 1 09:55:42 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 Made Easy".

The branch, master has been updated
       via  63ba09b541dabbe838253926896e721cb9be564a (commit)
       via  338e9edfdb9239f1c9d4409f6d08d79a9d6f285b (commit)
       via  79fc7c0fe825014e75bb825c4966a04a22e78254 (commit)
       via  3c04dea3ecebed35208f6b631b2e8b04222ea432 (commit)
      from  2e07d4f89a26bb56a55b2743d39fb37532028ffd (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 63ba09b541dabbe838253926896e721cb9be564a
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Nov 1 09:55:24 2018 +0100

    w32: Use CancelSynchronousIo in destroy_reader.
    
    * src/w32-util.c (_gpgme_w32_cancel_synchronous_io): New.
    * src/w32-io.c (destroy_reader): Use it here.
    --
    
    This has not been tested but should on Vista and later help to fix a
    possible hang.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/sys-util.h b/src/sys-util.h
index 094399c..6cb2224 100644
--- a/src/sys-util.h
+++ b/src/sys-util.h
@@ -30,6 +30,7 @@ char *_gpgme_get_gpgconf_path (void);
 
 #ifdef HAVE_W32_SYSTEM
 const char *_gpgme_get_inst_dir (void);
+void _gpgme_w32_cancel_synchronous_io (HANDLE thread);
 #endif
 
 #endif /* SYS_UTIL_H */
diff --git a/src/w32-io.c b/src/w32-io.c
index ad1e330..436bb7b 100644
--- a/src/w32-io.c
+++ b/src/w32-io.c
@@ -485,7 +485,7 @@ destroy_reader (struct reader_context_s *ctx)
      dlopen that syscall.  */
   if (ctx->file_hd != INVALID_HANDLE_VALUE)
     {
-      /* Fixme: Call CancelSynchronousIo (handle_of_thread).  */
+      _gpgme_w32_cancel_synchronous_io (ctx->thread_hd);
     }
   else if (ctx->file_sock != INVALID_SOCKET)
     {
diff --git a/src/w32-util.c b/src/w32-util.c
index 7954189..8a04c8c 100644
--- a/src/w32-util.c
+++ b/src/w32-util.c
@@ -99,8 +99,6 @@ static char *default_gpgconf_name;
    gpgme_set_global_flag and accessed by _gpgme_get_inst_dir.  */
 static char *override_inst_dir;
 
-#ifdef HAVE_ALLOW_SET_FOREGROUND_WINDOW
-
 #define RTLD_LAZY 0
 
 static GPG_ERR_INLINE void *
@@ -135,7 +133,6 @@ dlclose (void * hd)
     }
   return -1;
 }
-#endif /* HAVE_ALLOW_SET_FOREGROUND_WINDOW */
 
 
 /* Return a malloced string encoded in UTF-8 from the wide char input
@@ -241,6 +238,45 @@ _gpgme_allow_set_foreground_window (pid_t pid)
 }
 
 
+/* Wrapper around CancelSynchronousIo which is only available since
+ * Vista.  */
+void
+_gpgme_w32_cancel_synchronous_io (HANDLE thread)
+{
+  static int initialized;
+  static BOOL (WINAPI * func)(DWORD);
+  void *handle;
+
+  if (!initialized)
+    {
+      /* Available since Vista; thus we dynload it.  */
+      initialized = 1;
+      handle = dlopen ("kerner32.dll", RTLD_LAZY);
+      if (handle)
+        {
+          func = dlsym (handle, "CancelSynchronousIo");
+          if (!func)
+            {
+              dlclose (handle);
+              handle = NULL;
+            }
+        }
+    }
+
+  if (func)
+    {
+      int rc = func (thread);
+      TRACE2 (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", 0,
+	      "called for thread %p; result=%d", thread, rc);
+    }
+  else
+    {
+      TRACE0 (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", 0,
+	      "function not available");
+    }
+}
+
+
 /* Return a string from the W32 Registry or NULL in case of error.
    Caller must release the return value.  A NULL for root is an alias
    for HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE in turn. */

commit 338e9edfdb9239f1c9d4409f6d08d79a9d6f285b
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Nov 1 09:53:48 2018 +0100

    w32: Merge all the object tables of w32-io into one.
    
    * src/w32-io.c (fd_table_size): New.  Used in most places instead of
    the MAX_SLAFD constant.
    (reader_table, writer_table, notify_table): Merge them into ...
    (fd_table): this table.  Chnage all affected code to take just one
    lock.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/w32-io.c b/src/w32-io.c
index e3201b7..ad1e330 100644
--- a/src/w32-io.c
+++ b/src/w32-io.c
@@ -43,13 +43,73 @@
 #include "sys-util.h"
 
 
-/* FIXME: Optimize.  */
+/* The number of entries in our file table.  We may eventually use a
+ * lower value and dynamically resize the table.  */
 #define MAX_SLAFD 512
 
+#define handle_to_fd(a)  ((int)(a))
+
+#define READBUF_SIZE 4096
+#define WRITEBUF_SIZE 4096
+#define PIPEBUF_SIZE  4096
+
+
+/* The context used by a reader thread.  */
+struct reader_context_s
+{
+  HANDLE file_hd;
+  int file_sock;
+  HANDLE thread_hd;
+  int refcount;   /* Bumbed if the FD has been duped and thus we have
+                   * another FD referencinf this context.  */
+
+  DECLARE_LOCK (mutex);
+
+  int stop_me;
+  int eof;
+  int eof_shortcut;
+  int error;
+  int error_code;
+
+  /* This is manually reset.  */
+  HANDLE have_data_ev;
+  /* This is automatically reset.  */
+  HANDLE have_space_ev;
+  /* This is manually reset but actually only triggered once.  */
+  HANDLE close_ev;
+
+  size_t readpos, writepos;
+  char buffer[READBUF_SIZE];
+};
+
+
+/* The context used by a writer thread.  */
+struct writer_context_s
+{
+  HANDLE file_hd;
+  int file_sock;
+  HANDLE thread_hd;
+  int refcount;
+
+  DECLARE_LOCK (mutex);
+
+  int stop_me;
+  int error;
+  int error_code;
+
+  /* This is manually reset.  */
+  HANDLE have_data;
+  HANDLE is_empty;
+  HANDLE close_ev;
+  size_t nbytes;
+  char buffer[WRITEBUF_SIZE];
+};
+
+
 /* An object to keep track of HANDLEs and sockets and map them to an
  * integer similar to what we use in Unix.  Note that despite this
  * integer is often named "fd", it is not a file descriptor but really
- * only an index into this table. Never ever pass such an fd to any
+ * only an index into this table.  Never ever pass such an fd to any
  * other function except for those implemented here.  */
 static struct
 {
@@ -75,7 +135,23 @@ static struct
      want to close something.  Using the same handle for these
      duplicates works just fine.  */
   int dup_from;
+
+  /* The context of an associated reader object or NULL.  */
+  struct reader_context_s *reader;
+
+  /* The context of an associated writer object or NULL.  */
+  struct writer_context_s *writer;
+
+  /* A notification hanlder.  Noet that we current support only one
+   * callback per fd.  */
+  struct {
+    _gpgme_close_notify_handler_t handler;
+    void *value;
+  } notify;
+
 } fd_table[MAX_SLAFD];
+static size_t fd_table_size = MAX_SLAFD;
+
 DEFINE_STATIC_LOCK (fd_table_lock);
 
 
@@ -89,11 +165,11 @@ new_fd (void)
 
   LOCK (fd_table_lock);
 
-  for (idx = 0; idx < MAX_SLAFD; idx++)
+  for (idx = 0; idx < fd_table_size; idx++)
     if (! fd_table[idx].used)
       break;
 
-  if (idx == MAX_SLAFD)
+  if (idx == fd_table_size)
     {
       gpg_err_set_errno (EIO);
       idx = -1;
@@ -104,6 +180,8 @@ new_fd (void)
       fd_table[idx].handle = INVALID_HANDLE_VALUE;
       fd_table[idx].socket = INVALID_SOCKET;
       fd_table[idx].dup_from = -1;
+      fd_table[idx].notify.handler = NULL;
+      fd_table[idx].notify.value = NULL;
     }
 
   UNLOCK (fd_table_lock);
@@ -117,7 +195,7 @@ new_fd (void)
 void
 release_fd (int fd)
 {
-  if (fd < 0 || fd >= MAX_SLAFD)
+  if (fd < 0 || fd >= fd_table_size)
     return;
 
   LOCK (fd_table_lock);
@@ -128,99 +206,14 @@ release_fd (int fd)
       fd_table[fd].handle = INVALID_HANDLE_VALUE;
       fd_table[fd].socket = INVALID_SOCKET;
       fd_table[fd].dup_from = -1;
+      fd_table[fd].notify.handler = NULL;
+      fd_table[fd].notify.value = NULL;
     }
 
   UNLOCK (fd_table_lock);
 }
 
 
-#define handle_to_fd(a)  ((int)(a))
-
-#define READBUF_SIZE 4096
-#define WRITEBUF_SIZE 4096
-#define PIPEBUF_SIZE  4096
-#define MAX_READERS 64
-#define MAX_WRITERS 64
-
-static struct
-{
-  int inuse;
-  int fd;
-  _gpgme_close_notify_handler_t handler;
-  void *value;
-} notify_table[MAX_SLAFD];
-DEFINE_STATIC_LOCK (notify_table_lock);
-
-
-struct reader_context_s
-{
-  HANDLE file_hd;
-  int file_sock;
-  HANDLE thread_hd;
-  int refcount;
-
-  DECLARE_LOCK (mutex);
-
-  int stop_me;
-  int eof;
-  int eof_shortcut;
-  int error;
-  int error_code;
-
-  /* This is manually reset.  */
-  HANDLE have_data_ev;
-  /* This is automatically reset.  */
-  HANDLE have_space_ev;
-  /* This is manually reset but actually only triggered once.  */
-  HANDLE close_ev;
-
-  size_t readpos, writepos;
-  char buffer[READBUF_SIZE];
-};
-
-
-static struct
-{
-  volatile int used;
-  int fd;
-  struct reader_context_s *context;
-} reader_table[MAX_READERS];
-static int reader_table_size= MAX_READERS;
-DEFINE_STATIC_LOCK (reader_table_lock);
-
-
-struct writer_context_s
-{
-  HANDLE file_hd;
-  int file_sock;
-  HANDLE thread_hd;
-  int refcount;
-
-  DECLARE_LOCK (mutex);
-
-  int stop_me;
-  int error;
-  int error_code;
-
-  /* This is manually reset.  */
-  HANDLE have_data;
-  HANDLE is_empty;
-  HANDLE close_ev;
-  size_t nbytes;
-  char buffer[WRITEBUF_SIZE];
-};
-
-
-static struct
-{
-  volatile int used;
-  int fd;
-  struct writer_context_s *context;
-} writer_table[MAX_WRITERS];
-static int writer_table_size= MAX_WRITERS;
-DEFINE_STATIC_LOCK (writer_table_lock);
-
-
 static int
 get_desired_thread_priority (void)
 {
@@ -241,6 +234,9 @@ get_desired_thread_priority (void)
 }
 
 
+/* The reader thread.  Created on the fly by gpgme_io_read and
+ * destroyed by destroy_reader.  Note that this functions works with a
+ * copy of the value of the HANDLE variable frm the FS_TABLE.  */
 static DWORD CALLBACK
 reader (void *arg)
 {
@@ -382,14 +378,18 @@ reader (void *arg)
 }
 
 
+/* Create a new reader thread and return its context object.  The
+ * input is a HANDLE or a socket SOCK.  This function may not call any
+ * fd based functions because the caller already holds a lock on the
+ * fd_table.  */
 static struct reader_context_s *
-create_reader (int fd)
+create_reader (HANDLE handle, int sock)
 {
   struct reader_context_s *ctx;
   SECURITY_ATTRIBUTES sec_attr;
   DWORD tid;
 
-  TRACE_BEG (DEBUG_SYSIO, "gpgme:create_reader", fd);
+  TRACE_BEG (DEBUG_SYSIO, "gpgme:create_reader", handle);
 
   memset (&sec_attr, 0, sizeof sec_attr);
   sec_attr.nLength = sizeof sec_attr;
@@ -402,17 +402,8 @@ create_reader (int fd)
       return NULL;
     }
 
-  if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
-    {
-      TRACE_SYSERR (EIO);
-      free (ctx);
-      return NULL;
-    }
-  TRACE_LOG4 ("fd=%d -> handle=%p socket=%d dupfrom=%d",
-              fd, fd_table[fd].handle, fd_table[fd].socket,
-              fd_table[fd].dup_from);
-  ctx->file_hd = fd_table[fd].handle;
-  ctx->file_sock = fd_table[fd].socket;
+  ctx->file_hd = handle;
+  ctx->file_sock = sock;
 
   ctx->refcount = 1;
   ctx->have_data_ev = CreateEvent (&sec_attr, TRUE, FALSE, NULL);
@@ -511,37 +502,44 @@ destroy_reader (struct reader_context_s *ctx)
 
 
 /* Find a reader context or create a new one.  Note that the reader
-   context will last until a _gpgme_io_close.  */
+ * context will last until a _gpgme_io_close.  NULL is returned for a
+ * bad FD or for other errors.  */
 static struct reader_context_s *
 find_reader (int fd)
 {
   struct reader_context_s *rd = NULL;
-  int i;
 
-  LOCK (reader_table_lock);
-  for (i = 0; i < reader_table_size; i++)
-    if (reader_table[i].used && reader_table[i].fd == fd)
-      rd = reader_table[i].context;
+  TRACE_BEG0 (DEBUG_SYSIO, "gpgme:find_reader", fd, "");
 
-  if (rd)
+  LOCK (fd_table_lock);
+  if (fd < 0 || fd >= fd_table_size || !fd_table[fd].used)
     {
-      UNLOCK (reader_table_lock);
-      return rd;
+      UNLOCK (fd_table_lock);
+      gpg_err_set_errno (EBADF);
+      TRACE_SUC0 ("EBADF");
+      return NULL;
     }
 
-  for (i = 0; i < reader_table_size; i++)
-    if (!reader_table[i].used)
-      break;
-
-  if (i != reader_table_size)
+  rd = fd_table[fd].reader;
+  if (rd)
     {
-      rd = create_reader (fd);
-      reader_table[i].fd = fd;
-      reader_table[i].context = rd;
-      reader_table[i].used = 1;
+      UNLOCK (fd_table_lock);
+      TRACE_SUC1 ("rd=%p", rd);
+      return rd;  /* Return already initialized reader thread object.  */
     }
 
-  UNLOCK (reader_table_lock);
+  /* Create a new reader thread.  */
+  TRACE_LOG4 ("fd=%d -> handle=%p socket=%d dupfrom=%d creating reader",
+              fd, fd_table[fd].handle, fd_table[fd].socket,
+              fd_table[fd].dup_from);
+  rd = create_reader (fd_table[fd].handle, fd_table[fd].socket);
+  if (!rd)
+    gpg_err_set_errno (EIO);
+  else
+    fd_table[fd].reader = rd;
+
+  UNLOCK (fd_table_lock);
+  TRACE_SUC1 ("rd=%p (new)", rd);
   return rd;
 }
 
@@ -556,10 +554,7 @@ _gpgme_io_read (int fd, void *buffer, size_t count)
 
   ctx = find_reader (fd);
   if (!ctx)
-    {
-      gpg_err_set_errno (EBADF);
-      return TRACE_SYSRES (-1);
-    }
+    return TRACE_SYSRES (-1);
   if (ctx->eof_shortcut)
     return TRACE_SYSRES (0);
 
@@ -734,13 +729,13 @@ writer (void *arg)
 
 
 static struct writer_context_s *
-create_writer (int fd)
+create_writer (HANDLE handle, int sock)
 {
   struct writer_context_s *ctx;
   SECURITY_ATTRIBUTES sec_attr;
   DWORD tid;
 
-  TRACE_BEG (DEBUG_SYSIO, "gpgme:create_writer", fd);
+  TRACE_BEG (DEBUG_SYSIO, "gpgme:create_writer", handle);
 
   memset (&sec_attr, 0, sizeof sec_attr);
   sec_attr.nLength = sizeof sec_attr;
@@ -753,17 +748,8 @@ create_writer (int fd)
       return NULL;
     }
 
-  if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
-    {
-      TRACE_SYSERR (EIO);
-      free (ctx);
-      return NULL;
-    }
-  TRACE_LOG4 ("fd=%d -> handle=%p socket=%d dupfrom=%d",
-              fd, fd_table[fd].handle, fd_table[fd].socket,
-              fd_table[fd].dup_from);
-  ctx->file_hd = fd_table[fd].handle;
-  ctx->file_sock = fd_table[fd].socket;
+  ctx->file_hd = handle;
+  ctx->file_sock = sock;
 
   ctx->refcount = 1;
   ctx->have_data = CreateEvent (&sec_attr, TRUE, FALSE, NULL);
@@ -840,37 +826,44 @@ destroy_writer (struct writer_context_s *ctx)
 
 
 /* Find a writer context or create a new one.  Note that the writer
- * context will last until a _gpgme_io_close.  */
+ * context will last until a _gpgme_io_close.  NULL is returned for a
+ * bad FD or for other errors.  */
 static struct writer_context_s *
 find_writer (int fd)
 {
   struct writer_context_s *wt = NULL;
-  int i;
 
-  LOCK (writer_table_lock);
-  for (i = 0; i < writer_table_size; i++)
-    if (writer_table[i].used && writer_table[i].fd == fd)
-      wt = writer_table[i].context;
+  TRACE_BEG0 (DEBUG_SYSIO, "gpgme:find_writer", fd, "");
 
-  if (wt)
+  LOCK (fd_table_lock);
+  if (fd < 0 || fd >= fd_table_size || !fd_table[fd].used)
     {
-      UNLOCK (writer_table_lock);
-      return wt;
+      UNLOCK (fd_table_lock);
+      gpg_err_set_errno (EBADF);
+      TRACE_SUC0 ("EBADF");
+      return NULL;
     }
 
-  for (i = 0; i < writer_table_size; i++)
-    if (!writer_table[i].used)
-      break;
-
-  if (i != writer_table_size)
+  wt = fd_table[fd].writer;
+  if (wt)
     {
-      wt = create_writer (fd);
-      writer_table[i].fd = fd;
-      writer_table[i].context = wt;
-      writer_table[i].used = 1;
+      UNLOCK (fd_table_lock);
+      TRACE_SUC1 ("wt=%p", wt);
+      return wt;  /* Return already initialized writer thread object.  */
     }
 
-  UNLOCK (writer_table_lock);
+  /* Create a new writer thread.  */
+  TRACE_LOG4 ("fd=%d -> handle=%p socket=%d dupfrom=%d creating writer",
+              fd, fd_table[fd].handle, fd_table[fd].socket,
+              fd_table[fd].dup_from);
+  wt = create_writer (fd_table[fd].handle, fd_table[fd].socket);
+  if (!wt)
+    gpg_err_set_errno (EIO);
+  else
+    fd_table[fd].writer = wt;
+
+  UNLOCK (fd_table_lock);
+  TRACE_SUC1 ("wt=%p (new)", wt);
   return wt;
 }
 
@@ -931,7 +924,7 @@ _gpgme_io_write (int fd, const void *buffer, size_t count)
   ctx->nbytes = count;
 
   /* We have to reset the is_empty event early, because it is also
-     used by the select() implementation to probe the channel.  */
+   * used by the select() implementation to probe the channel.  */
   if (!ResetEvent (ctx->is_empty))
     {
       TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ());
@@ -1035,7 +1028,10 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
       wh = hd;
     }
 
-  /* Put the HANDLEs of the new pipe into the file descriptor table.  */
+  /* Put the HANDLEs of the new pipe into the file descriptor table.
+   * Note that we don't need to lock the table because we have just
+   * acquired these two fresh fds and they are not known by any other
+   * thread.  */
   fd_table[rfd].handle = rh;
   fd_table[wfd].handle = wh;
 
@@ -1046,22 +1042,27 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
 }
 
 
+/* Close out File descriptor FD.  */
 int
 _gpgme_io_close (int fd)
 {
-  int i;
   _gpgme_close_notify_handler_t handler = NULL;
   void *value = NULL;
 
   TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", fd);
 
-  if (fd == -1)
+  if (fd < 0)
     {
       gpg_err_set_errno (EBADF);
       return TRACE_SYSRES (-1);
     }
-  if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
+
+  LOCK (fd_table_lock);
+  /* Check the size in the locked state because we may eventually add
+   * code to change that size.  */
+  if (fd >= fd_table_size || !fd_table[fd].used)
     {
+      UNLOCK (fd_table_lock);
       gpg_err_set_errno (EBADF);
       return TRACE_SYSRES (-1);
     }
@@ -1070,48 +1071,22 @@ _gpgme_io_close (int fd)
               fd, fd_table[fd].handle, fd_table[fd].socket,
               fd_table[fd].dup_from);
 
-  LOCK (reader_table_lock);
-  for (i = 0; i < reader_table_size; i++)
+  if (fd_table[fd].reader)
     {
-      if (reader_table[i].used && reader_table[i].fd == fd)
-	{
-	  destroy_reader (reader_table[i].context);
-	  reader_table[i].context = NULL;
-	  reader_table[i].used = 0;
-	  break;
-	}
+      destroy_reader (fd_table[fd].reader);
+      fd_table[fd].reader = NULL;
     }
-  UNLOCK (reader_table_lock);
 
-  LOCK (writer_table_lock);
-  for (i = 0; i < writer_table_size; i++)
+  if (fd_table[fd].writer)
     {
-      if (writer_table[i].used && writer_table[i].fd == fd)
-	{
-	  destroy_writer (writer_table[i].context);
-	  writer_table[i].context = NULL;
-	  writer_table[i].used = 0;
-	  break;
-	}
+      destroy_writer (fd_table[fd].writer);
+      fd_table[fd].writer = NULL;
     }
-  UNLOCK (writer_table_lock);
 
-  LOCK (notify_table_lock);
-  for (i = 0; i < DIM (notify_table); i++)
-    {
-      if (notify_table[i].inuse && notify_table[i].fd == fd)
-	{
-	  handler = notify_table[i].handler;
-	  value   = notify_table[i].value;
-	  notify_table[i].handler = NULL;
-	  notify_table[i].value = NULL;
-	  notify_table[i].inuse = 0;
-	  break;
-	}
-    }
-  UNLOCK (notify_table_lock);
-  if (handler)
-    handler (fd, value);
+  /* FIXME: The handler may not use any fd fucntion becuase the table
+   * is locked.  Can we avoid this?  */
+  handler = fd_table[fd].notify.handler;
+  value   = fd_table[fd].notify.value;
 
   if (fd_table[fd].dup_from == -1)
     {
@@ -1122,6 +1097,7 @@ _gpgme_io_close (int fd)
 	      TRACE_LOG1 ("CloseHandle failed: ec=%d", (int) GetLastError ());
 	      /* FIXME: Should translate the error code.  */
 	      gpg_err_set_errno (EIO);
+              UNLOCK (fd_table_lock);
 	      return TRACE_SYSRES (-1);
 	    }
 	}
@@ -1129,49 +1105,50 @@ _gpgme_io_close (int fd)
 	{
 	  if (closesocket (fd_table[fd].socket))
 	    {
-	      TRACE_LOG1 ("closesocket failed: ec=%d", (int) WSAGetLastError ());
+	      TRACE_LOG1 ("closesocket failed: ec=%d", (int)WSAGetLastError ());
 	      /* FIXME: Should translate the error code.  */
 	      gpg_err_set_errno (EIO);
+              UNLOCK (fd_table_lock);
 	      return TRACE_SYSRES (-1);
 	    }
 	}
     }
 
-  release_fd (fd);
+  UNLOCK (fd_table_lock);
+
+  /* Run the notification callback.  */
+  if (handler)
+    handler (fd, value);
+
+  release_fd (fd);  /* FIXME: We should have a release_fd_locked () */
 
   return TRACE_SYSRES (0);
 }
 
 
+/* Set a close notification callback which is called right after FD
+ * has been closed but before its slot (ie. the FD number) is beeing
+ * released.  Tha HANDLER may thus use the provided value of the FD
+ * but it may not pass it to any I/O functions.  Note: Only the last
+ * handler set for an FD is used.  */
 int
 _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler,
 			    void *value)
 {
-  int i;
   TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd,
 	      "close_handler=%p/%p", handler, value);
 
-  assert (fd != -1);
-
-  LOCK (notify_table_lock);
-  for (i=0; i < DIM (notify_table); i++)
-    if (notify_table[i].inuse && notify_table[i].fd == fd)
-      break;
-  if (i == DIM (notify_table))
-    for (i = 0; i < DIM (notify_table); i++)
-      if (!notify_table[i].inuse)
-	break;
-  if (i == DIM (notify_table))
-    {
-      UNLOCK (notify_table_lock);
-      gpg_err_set_errno (EINVAL);
-      return TRACE_SYSRES (-1);
+  LOCK (fd_table_lock);
+  if (fd < 0 || fd >= fd_table_size || !fd_table[fd].used)
+    {
+      UNLOCK (fd_table_lock);
+      gpg_err_set_errno (EBADF);
+      return TRACE_SYSRES (-1);;
     }
-  notify_table[i].fd = fd;
-  notify_table[i].handler = handler;
-  notify_table[i].value = value;
-  notify_table[i].inuse = 1;
-  UNLOCK (notify_table_lock);
+
+  fd_table[fd].notify.handler = handler;
+  fd_table[fd].notify.value = value;
+  UNLOCK (fd_table_lock);
   return TRACE_SYSRES (0);
 }
 
@@ -1267,6 +1244,10 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
 
   TRACE_BEG1 (DEBUG_SYSIO, "_gpgme_io_spawn", path,
 	      "path=%s", path);
+
+  (void)atfork;
+  (void)atforkvalue;
+
   i = 0;
   while (argv[i])
     {
@@ -1374,6 +1355,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
     _gpgme_allow_set_foreground_window ((pid_t)pi.dwProcessId);
 
   /* Insert the inherited handles.  */
+  LOCK (fd_table_lock);
   for (i = 0; fd_list[i].fd != -1; i++)
     {
       int fd = fd_list[i].fd;
@@ -1381,7 +1363,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
       HANDLE hd = INVALID_HANDLE_VALUE;
 
       /* Make it inheritable for the wrapper process.  */
-      if (fd >= 0 && fd < MAX_SLAFD && fd_table[fd].used)
+      if (fd >= 0 && fd < fd_table_size && fd_table[fd].used)
 	ohd = fd_table[fd].handle;
 
       if (!DuplicateHandle (GetCurrentProcess(), ohd,
@@ -1401,6 +1383,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
 
 	  /* FIXME: Should translate the error code.  */
 	  gpg_err_set_errno (EIO);
+          UNLOCK (fd_table_lock);
 	  return TRACE_SYSRES (-1);
         }
       /* Return the child name of this handle.  */
@@ -1454,6 +1437,8 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
   free (tmp_name);
   free (arg_string);
 
+  UNLOCK (fd_table_lock);
+
   TRACE_LOG4 ("CreateProcess ready: hProcess=%p, hThread=%p, "
 	      "dwProcessID=%d, dwThreadId=%d",
 	      pi.hProcess, pi.hThread,
@@ -1528,6 +1513,8 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
 	{
 	  if (fds[i].for_read)
 	    {
+              /* FIXME: A find_reader_locked() along with separate
+               * lock calls might be a better appaoched here.  */
 	      struct reader_context_s *ctx = find_reader (fds[i].fd);
 
 	      if (!ctx)
@@ -1581,11 +1568,11 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
   code = WaitForMultipleObjects (nwait, waitbuf, 0, nonblock ? 0 : 1000);
   if (code >= WAIT_OBJECT_0 && code < WAIT_OBJECT_0 + nwait)
     {
-      /* This WFMO is a really silly function: It does return either
+      /* The WFMO is a really silly function: It does return either
 	 the index of the signaled object or if 2 objects have been
 	 signalled at the same time, the index of the object with the
 	 lowest object is returned - so and how do we find out how
-	 many objects have been signaled???.  The only solution I can
+	 many objects have been signaled?.  The only solution I can
 	 imagine is to test each object starting with the returned
 	 index individually - how dull.  */
       any = 0;
@@ -1668,13 +1655,15 @@ _gpgme_io_subsystem_init (void)
 }
 
 
-/* Write the printable version of FD to the buffer BUF of length
-   BUFLEN.  The printable version is the representation on the command
-   line that the child process expects.  */
+/* Write the printable version of FD to BUFFER which has an allocated
+ * length of BUFLEN.  The printable version is the representation on
+ * the command line that the child process expects.  Note that this
+ * works closely together with the gpgme-32spawn wrapper process which
+ * translates these command line args to the real handles. */
 int
-_gpgme_io_fd2str (char *buf, int buflen, int fd)
+_gpgme_io_fd2str (char *buffer, int buflen, int fd)
 {
-  return snprintf (buf, buflen, "%d", fd);
+  return snprintf (buffer, buflen, "%d", fd);
 }
 
 
@@ -1684,60 +1673,47 @@ _gpgme_io_dup (int fd)
   int newfd;
   struct reader_context_s *rd_ctx;
   struct writer_context_s *wt_ctx;
-  int i;
 
   TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_dup", fd);
 
-  if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
+  LOCK (fd_table_lock);
+  if (fd < 0 || fd >= fd_table_size || !fd_table[fd].used)
     {
-      gpg_err_set_errno (EINVAL);
+      UNLOCK (fd_table_lock);
+      gpg_err_set_errno (EBADF);
       return TRACE_SYSRES (-1);
     }
 
   newfd = new_fd();
   if (newfd == -1)
-    return TRACE_SYSRES (-1);
+    {
+      UNLOCK (fd_table_lock);
+      gpg_err_set_errno (EMFILE);
+      return TRACE_SYSRES (-1);
+    }
 
   fd_table[newfd].handle = fd_table[fd].handle;
   fd_table[newfd].socket = fd_table[fd].socket;
   fd_table[newfd].dup_from = fd;
 
+  UNLOCK (fd_table_lock);
+
   rd_ctx = find_reader (fd);
   if (rd_ctx)
     {
-      /* No need for locking, as the only races are against the reader
-	 thread itself, which doesn't touch refcount.  */
+      /* No need for locking in the context, as the only races are
+       * against the reader thread itself, which doesn't touch
+       * refcount.  NEWFD initializes a freshly allocated slot and
+       * does not need locking either. */
       rd_ctx->refcount++;
-
-      LOCK (reader_table_lock);
-      for (i = 0; i < reader_table_size; i++)
-	if (!reader_table[i].used)
-	  break;
-      /* FIXME.  */
-      assert (i != reader_table_size);
-      reader_table[i].fd = newfd;
-      reader_table[i].context = rd_ctx;
-      reader_table[i].used = 1;
-      UNLOCK (reader_table_lock);
+      fd_table[newfd].reader = rd_ctx;
     }
 
   wt_ctx = find_writer (fd);
   if (wt_ctx)
     {
-      /* No need for locking, as the only races are against the writer
-	 thread itself, which doesn't touch refcount.  */
       wt_ctx->refcount++;
-
-      LOCK (writer_table_lock);
-      for (i = 0; i < writer_table_size; i++)
-	if (!writer_table[i].used)
-	  break;
-      /* FIXME.  */
-      assert (i != writer_table_size);
-      writer_table[i].fd = newfd;
-      writer_table[i].context = wt_ctx;
-      writer_table[i].used = 1;
-      UNLOCK (writer_table_lock);
+      fd_table[newfd].writer = wt_ctx;
     }
 
   return TRACE_SYSRES (newfd);
@@ -1815,17 +1791,22 @@ int
 _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen)
 {
   int res;
+  int sock;
 
   TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_connect", fd,
 	      "addr=%p, addrlen=%i", addr, addrlen);
 
-  if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
+  LOCK (fd_table_lock);
+  if (fd < 0 || fd >= fd_table_size || !fd_table[fd].used)
     {
       gpg_err_set_errno (EBADF);
+      UNLOCK (fd_table_lock);
       return TRACE_SYSRES (-1);
     }
+  sock = fd_table[fd].socket;
+  UNLOCK (fd_table_lock);
 
-  res = connect (fd_table[fd].socket, addr, addrlen);
+  res = connect (sock, addr, addrlen);
   if (res)
     {
       gpg_err_set_errno (wsa2errno (WSAGetLastError ()));

commit 79fc7c0fe825014e75bb825c4966a04a22e78254
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Oct 31 14:58:23 2018 +0100

    w32: Remove unused arg from two functions.
    
    * src/w32-io.c (find_reader, find_writer): Remove unused start_it
    arg.  It is always passed as true.  Change callers.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/w32-io.c b/src/w32-io.c
index bb59a5e..e3201b7 100644
--- a/src/w32-io.c
+++ b/src/w32-io.c
@@ -1,23 +1,23 @@
 /* w32-io.c - W32 API I/O functions.
-   Copyright (C) 2000 Werner Koch (dd9jn)
-   Copyright (C) 2001, 2002, 2003, 2004, 2007, 2010 g10 Code GmbH
-
-   This file is part of GPGME.
-
-   GPGME 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.
-
-   GPGME is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+ * Copyright (C) 2000 Werner Koch (dd9jn)
+ * Copyright (C) 2001-2004, 2007, 2010, 2018 g10 Code GmbH
+ *
+ * This file is part of GPGME.
+ *
+ * GPGME 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.
+ *
+ * GPGME is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <https://gnu.org/licenses/>.
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -46,6 +46,11 @@
 /* FIXME: Optimize.  */
 #define MAX_SLAFD 512
 
+/* An object to keep track of HANDLEs and sockets and map them to an
+ * integer similar to what we use in Unix.  Note that despite this
+ * integer is often named "fd", it is not a file descriptor but really
+ * only an index into this table. Never ever pass such an fd to any
+ * other function except for those implemented here.  */
 static struct
 {
   int used;
@@ -74,7 +79,9 @@ static struct
 DEFINE_STATIC_LOCK (fd_table_lock);
 
 
-/* Returns the FD or -1 on resource limit.  */
+/* Returns our FD or -1 on resource limit.  The returned integer
+ * references a new object which has not been intialized but can be
+ * release with release_fd.  */
 int
 new_fd (void)
 {
@@ -104,7 +111,9 @@ new_fd (void)
   return idx;
 }
 
-
+/* Releases our FD but it this is just this entry.  No close operation
+ * is involved here; it must be done prior to calling this
+ * function.  */
 void
 release_fd (int fd)
 {
@@ -504,7 +513,7 @@ destroy_reader (struct reader_context_s *ctx)
 /* Find a reader context or create a new one.  Note that the reader
    context will last until a _gpgme_io_close.  */
 static struct reader_context_s *
-find_reader (int fd, int start_it)
+find_reader (int fd)
 {
   struct reader_context_s *rd = NULL;
   int i;
@@ -514,7 +523,7 @@ find_reader (int fd, int start_it)
     if (reader_table[i].used && reader_table[i].fd == fd)
       rd = reader_table[i].context;
 
-  if (rd || !start_it)
+  if (rd)
     {
       UNLOCK (reader_table_lock);
       return rd;
@@ -545,7 +554,7 @@ _gpgme_io_read (int fd, void *buffer, size_t count)
   TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_read", fd,
 	      "buffer=%p, count=%u", buffer, count);
 
-  ctx = find_reader (fd, 1);
+  ctx = find_reader (fd);
   if (!ctx)
     {
       gpg_err_set_errno (EBADF);
@@ -831,9 +840,9 @@ destroy_writer (struct writer_context_s *ctx)
 
 
 /* Find a writer context or create a new one.  Note that the writer
-   context will last until a _gpgme_io_close.  */
+ * context will last until a _gpgme_io_close.  */
 static struct writer_context_s *
-find_writer (int fd, int start_it)
+find_writer (int fd)
 {
   struct writer_context_s *wt = NULL;
   int i;
@@ -843,7 +852,7 @@ find_writer (int fd, int start_it)
     if (writer_table[i].used && writer_table[i].fd == fd)
       wt = writer_table[i].context;
 
-  if (wt || !start_it)
+  if (wt)
     {
       UNLOCK (writer_table_lock);
       return wt;
@@ -877,7 +886,7 @@ _gpgme_io_write (int fd, const void *buffer, size_t count)
   if (count == 0)
     return TRACE_SYSRES (0);
 
-  ctx = find_writer (fd, 1);
+  ctx = find_writer (fd);
   if (!ctx)
     return TRACE_SYSRES (-1);
 
@@ -958,6 +967,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
 	      "inherit_idx=%i (GPGME uses it for %s)",
 	      inherit_idx, inherit_idx ? "reading" : "writing");
 
+  /* Get a new empty file descriptor.  */
   rfd = new_fd ();
   if (rfd == -1)
     return TRACE_SYSRES (-1);
@@ -968,6 +978,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
       return TRACE_SYSRES (-1);
     }
 
+  /* Create a pipe.  */
   memset (&sec_attr, 0, sizeof (sec_attr));
   sec_attr.nLength = sizeof (sec_attr);
   sec_attr.bInheritHandle = FALSE;
@@ -1023,6 +1034,8 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
       CloseHandle (wh);
       wh = hd;
     }
+
+  /* Put the HANDLEs of the new pipe into the file descriptor table.  */
   fd_table[rfd].handle = rh;
   fd_table[wfd].handle = wh;
 
@@ -1515,7 +1528,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
 	{
 	  if (fds[i].for_read)
 	    {
-	      struct reader_context_s *ctx = find_reader (fds[i].fd,1);
+	      struct reader_context_s *ctx = find_reader (fds[i].fd);
 
 	      if (!ctx)
 		TRACE_LOG1 ("error: no reader for FD 0x%x (ignored)",
@@ -1538,7 +1551,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
             }
 	  else if (fds[i].for_write)
 	    {
-	      struct writer_context_s *ctx = find_writer (fds[i].fd,1);
+	      struct writer_context_s *ctx = find_writer (fds[i].fd);
 
 	      if (!ctx)
 		TRACE_LOG1 ("error: no writer for FD 0x%x (ignored)",
@@ -1689,7 +1702,7 @@ _gpgme_io_dup (int fd)
   fd_table[newfd].socket = fd_table[fd].socket;
   fd_table[newfd].dup_from = fd;
 
-  rd_ctx = find_reader (fd, 1);
+  rd_ctx = find_reader (fd);
   if (rd_ctx)
     {
       /* No need for locking, as the only races are against the reader
@@ -1708,7 +1721,7 @@ _gpgme_io_dup (int fd)
       UNLOCK (reader_table_lock);
     }
 
-  wt_ctx = find_writer (fd, 1);
+  wt_ctx = find_writer (fd);
   if (wt_ctx)
     {
       /* No need for locking, as the only races are against the writer
@@ -1737,6 +1750,7 @@ _gpgme_io_dup (int fd)
 void *
 gpgme_get_giochannel (int fd)
 {
+  (void)fd;
   return NULL;
 }
 
@@ -1745,6 +1759,7 @@ gpgme_get_giochannel (int fd)
 void *
 gpgme_get_fdptr (int fd)
 {
+  (void)fd;
   return NULL;
 }
 

commit 3c04dea3ecebed35208f6b631b2e8b04222ea432
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Oct 31 12:27:27 2018 +0100

    w32: Remove all support for WindowsCE
    
    * configure.ac: Remove WindwosCE support.
    * contrib/: Remove all; it was only used for WindowsCE.
    * src/w32-ce.c, src/w32-ce.h: Remove files.
    * src/Makefile.am (system_components): Remove these files.
    * src/ath.c, src/ath.h: Remove W32CE support.
    * src/data-compat.c (gpgme_data_new_from_filepart): Ditto.
    (gpgme_data_new_from_file): Ditto.
    * src/debug.c (debug_init, _gpgme_debug): Ditto.
    * src/gpgme-tool.c (gpgme_server): Ditto.
    (main): Ditto.
    * src/priv-io.h: Do not include w32-ce.h.
    * src/util.h: Remove WindowsCE support.
    * src/w32-io.c: Ditto.
    * src/w32-util.c: Ditto.
    * src/debug.h (TRACE_SUC4): New.
    --
    
    There is no more hardware to test our code, the support for Windows CE
    terminated along time ago.  Note that our code worked only with the
    old WindowsCE with that overall system limit of 31 processes.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/Makefile.am b/Makefile.am
index 1264618..7b35128 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,8 +33,8 @@ ACLOCAL_AMFLAGS = -I m4
 
 DISTCHECK_CONFIGURE_FLAGS =
 
-EXTRA_DIST = autogen.sh autogen.rc gpgme.spec.in                   	\
-             ChangeLog-2011 m4/ChangeLog-2011 contrib/ChangeLog-2011    \
+EXTRA_DIST = autogen.sh autogen.rc gpgme.spec.in  \
+             ChangeLog-2011 m4/ChangeLog-2011     \
              conf/whatisthis VERSION
 
 
diff --git a/configure.ac b/configure.ac
index 1493554..1398993 100644
--- a/configure.ac
+++ b/configure.ac
@@ -186,9 +186,6 @@ case "${host}" in
     x86_64-*mingw32*)
         have_w64_system=yes
         ;;
-    *-mingw32ce*)
-        have_w32ce_system=yes
-	;;
     *-linux-androideabi)
         have_android_system=yes
         ;;
@@ -197,7 +194,7 @@ case "${host}" in
         ;;
 esac
 case "${host}" in
-    *-mingw32ce*|*-mingw32*)
+    *-mingw32*)
 	have_dosish_system=yes
         have_w32_system=yes
         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
@@ -241,12 +238,6 @@ if test "$have_w64_system" = yes; then
 fi
 AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes)
 
-if test "$have_w32ce_system" = yes; then
-   AC_DEFINE(HAVE_W32CE_SYSTEM,1,
-             [Defined if we run on a W32 CE API based system])
-fi
-AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
-
 if test "$have_android_system" = yes; then
    AC_DEFINE(HAVE_ANDROID_SYSTEM,1, [Defined if we build for an Android system])
 fi
diff --git a/contrib/ChangeLog-2011 b/contrib/ChangeLog-2011
deleted file mode 100644
index cfe5876..0000000
--- a/contrib/ChangeLog-2011
+++ /dev/null
@@ -1,49 +0,0 @@
-2011-12-02  Werner Koch  <wk at g10code.com>
-
-	NB: ChangeLog files are no longer manually maintained.  Starting
-	on December 1st, 2011 we put change information only in the GIT
-	commit log, and generate a top-level ChangeLog file from logs at
-	"make dist".  See doc/HACKING for details.
-
-2010-11-15  Marcus Brinkmann  <mb at g10code.com>
-
-	* conf-w32ce-msc/fcntl.h: New file.
-	* conf-w32ce-msc/build.mk (conf_sources): Add fnctl.h.
-	(sources): Remove memrchr.c.
-
-	* conf-w32ce-msc/io.h: New file.
-	* conf-w32ce-msc/build.mk (conf_sources): Add io.h.
-
-	* conf-w32ce-msc/stdint.h: New file.
-	* conf-w32ce-msc/build.mk (conf_sources): Add stdint.h.
-	* conf-w32ce-msc/build.mk (copy-static-source): Revert last change.
-
-2010-11-15  Werner Koch  <wk at g10code.com>
-
-	* conf-w32ce-msc/build.mk (copy-static-source): Create stdint.h.
-	(all): Add ws2.lib
-	(clean): New.
-
-2010-11-04  Werner Koch  <wk at g10code.com>
-
-	* conf-w32ce-msc/build.mk (copy-built-source): Revert last
-	change.  Does not work with W32CE where MSC defines it in except.h.
-
-2010-11-03  Werner Koch  <wk at g10code.com>
-
-	* conf-w32ce-msc/build.mk (copy-built-source): Create dummy sehmap.h.
-
-2010-11-01  Werner Koch  <wk at g10code.com>
-
-	* conf-w32ce-msc/config.h: New.
-	* conf-w32ce-msc/build.mk: New.
-
- Copyright (C) 2010 g10 Code GmbH
-
- This file is free software; as a special exception the author gives
- unlimited permission to copy and/or distribute it, with or without
- modifications, as long as this notice is preserved.
-
- This file is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/contrib/conf-w32ce-msc/build.mk b/contrib/conf-w32ce-msc/build.mk
deleted file mode 100755
index ac3b6a3..0000000
--- a/contrib/conf-w32ce-msc/build.mk
+++ /dev/null
@@ -1,256 +0,0 @@
-# build.mk - Makefile to build libgpg-error using Visual-C
-# Copyright 2010 g10 Code GmbH
-#
-# This file is free software; as a special exception the author gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-#
-# This file is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-# This is a helper make script to build libgpg-error for WindowsCE
-# using the Microsoft Visual C compiler.  
-
-targetdir = /home/smb/xppro-gnu/src/gpgme/src
-# The target build directory where we run the Visual C compiler/ This
-# needs to be an absolute directory name.  Further we expect this
-# structure of the tree:
-# 
-#   TARGET/src - Source directories:  One directory for each project
-#         /bin - Installed DLLs
-#         /lib - Installed import libs.
-#         /include - Instaled header files.
-
-targetdir = /home/smb/xppro-gnu
-targetsrc = $(targetdir)/src
-
-# Install directories (relative)
-bindir = ../../../bin
-libdir = ../../../lib
-incdir = ../../../include
-
-
-help:
-	@echo "Run "
-	@echo "  make -f ../contrib/conf-w32ce-msc/build.mk copy-source"
-	@echo "on the POSIX system and then"
-	@echo "  nmake -f build.mk all"
-	@echo "  nmake -f build.mk install"
-	@echo "on the Windows system"
-
-ce_defines = -DWINCE -D_WIN32_WCE=0x502 -DUNDER_CE \
-             -DWIN32_PLATFORM_PSPC -D_UNICODE -DUNICODE \
-             -D_CONSOLE -DARM -D_ARM_
-#-D_DEBUG -DDEBUG 
-
-CFLAGS = -nologo -W3 -fp:fast -Os $(ce_defines) \
-         -DHAVE_CONFIG_H -DDLL_EXPORT -D_CRT_SECURE_NO_WARNINGS \
-	 -I. -I$(incdir) -I$(incdir)/gpg-extra
-
-LDFLAGS =
-
-# Standard source files
-sources = \
-	assuan-support.c    \
-	ath-pth.c	    \
-	ath-pthread.c	    \
-	ath.c		    \
-	ath.h		    \
-	context.h	    \
-	conversion.c	    \
-	data-compat.c	    \
-	data-fd.c	    \
-	data-mem.c	    \
-	data-stream.c	    \
-	data-user.c	    \
-	data.c		    \
-	data.h		    \
-	debug.c		    \
-	debug.h		    \
-	decrypt-verify.c    \
-	decrypt.c	    \
-	delete.c	    \
-	dirinfo.c	    \
-	edit.c		    \
-	encrypt-sign.c	    \
-	encrypt.c	    \
-	engine-assuan.c	    \
-	engine-backend.h    \
-	engine-g13.c	    \
-	engine-gpg.c	    \
-	engine-gpgconf.c    \
-	engine-gpgsm.c	    \
-	engine-uiserver.c   \
-	engine.c	    \
-	engine.h	    \
-	error.c		    \
-	export.c	    \
-	funopen.c	    \
-	genkey.c	    \
-	get-env.c	    \
-	getauditlog.c	    \
-	gpgconf.c	    \
-	gpgme-tool.c	    \
-	gpgme-w32spawn.c    \
-	gpgme.c		    \
-	import.c	    \
-	isascii.c	    \
-	kdpipeiodevice.h    \
-	key.c		    \
-	keylist.c	    \
-	op-support.c	    \
-	opassuan.c	    \
-	ops.h		    \
-	passphrase.c	    \
-	passwd.c	    \
-	priv-io.h	    \
-	progress.c	    \
-	putc_unlocked.c	    \
-	sema.h		    \
-	setenv.c	    \
-	sig-notation.c	    \
-	sign.c		    \
-	signers.c	    \
-	stpcpy.c	    \
-	trust-item.c	    \
-	trustlist.c	    \
-	ttyname_r.c	    \
-	util.h		    \
-	vasprintf.c	    \
-	verify.c	    \
-	version.c	    \
-	vfs-create.c	    \
-	vfs-mount.c	    \
-	w32-ce.c	    \
-	w32-ce.h	    \
-	w32-glib-io.c	    \
-	w32-io.c	    \
-	w32-sema.c	    \
-	w32-util.c	    \
-	wait-global.c	    \
-	wait-private.c	    \
-	wait-user.c	    \
-	wait.c		    \
-	wait.h              \
-	gpgme.def
-
-# The object files we need to create from sources.
-objs = \
-	conversion.obj     \
-	get-env.obj  	   \
-	data.obj  	   \
-	data-fd.obj  	   \
-	data-stream.obj    \
-	data-mem.obj  	   \
-	data-user.obj  	   \
-	data-compat.obj    \
-	signers.obj  	   \
-	sig-notation.obj   \
-	wait.obj  	   \
-	wait-global.obj    \
-	wait-private.obj   \
-	wait-user.obj  	   \
-	op-support.obj     \
-	encrypt.obj  	   \
-	encrypt-sign.obj   \
-	decrypt.obj  	   \
-	decrypt-verify.obj \
-	verify.obj  	   \
-	sign.obj  	   \
-	passphrase.obj 	   \
-	progress.obj  	   \
-	key.obj  	   \
-	keylist.obj  	   \
-	trust-item.obj 	   \
-	trustlist.obj  	   \
-	import.obj  	   \
-	export.obj  	   \
-	genkey.obj  	   \
-	delete.obj  	   \
-	edit.obj  	   \
-	getauditlog.obj	   \
-	opassuan.obj  	   \
-	passwd.obj  	   \
-	engine.obj  	   \
-	engine-gpg.obj 	   \
-	engine-gpgsm.obj     \
-	assuan-support.obj   \
-	engine-assuan.obj    \
-	engine-gpgconf.obj   \
-	engine-g13.obj 	   \
-	vfs-mount.obj  	   \
-	vfs-create.obj 	   \
-	gpgconf.obj  	   \
-	w32-ce.obj  	   \
-	w32-util.obj  	   \
-	w32-sema.obj  	   \
-	w32-io.obj  	   \
-	dirinfo.obj  	   \
-	debug.obj  	   \
-	gpgme.obj  	   \
-	version.obj  	   \
-	error.obj  	   \
-	ath.obj  	   \
-	vasprintf.obj  	   \
-	ttyname_r.obj  	   \
-	stpcpy.obj  	   \
-	setenv.obj
-
-
-# Sources files in this directory inclduing this Makefile
-conf_sources = \
-	build.mk \
-	config.h \
-        stdint.h io.h fcntl.h
-
-# Source files built by running the standard build system.
-built_sources = \
-	gpgme.h         \
-	status-table.h
-
-copy-static-source:
-	@if [ ! -f ./gpgme.c ]; then \
-           echo "Please cd to the src/ directory first"; \
-	   exit 1; \
-        fi
-	cp -t $(targetsrc)/gpgme/src $(sources);
-	cd ../contrib/conf-w32ce-msc ; \
-            cp -t $(targetsrc)/gpgme/src $(conf_sources)
-
-copy-built-source:
-	@if [ ! -f ./gpgme.h ]; then \
-           echo "Please build using ./autogen.sh --build-w32ce first"; \
-	   exit 1; \
-        fi
-	cp -t $(targetsrc)/gpgme/src $(built_sources)
-
-copy-source: copy-static-source copy-built-source 
-
-
-.c.obj:
-	$(CC) $(CFLAGS) -c $<
-
-all:  $(sources) $(conf_sources) $(built_sources) $(objs)
-	link    /DLL /IMPLIB:libgpgme-11-msc.lib \
-                /OUT:libgpgme-11-msc.dll \
-		/DEF:gpgme.def /NOLOGO /MANIFEST:NO \
-		/NODEFAULTLIB:"oldnames.lib" /DYNAMICBASE:NO \
-	        $(objs) \
-		$(libdir)/libgpg-error-0-msc.lib \
-		$(libdir)/libassuan-0-msc.lib \
-		coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib \
-		commctrl.lib ws2.lib /subsystem:windowsce,5.02
-
-# Note that we don't need to create the install directories because
-# libgpg-error must have been build and installed prior to this
-# package.
-install: all
-	copy /y gpgme.h $(incdir:/=\)
-	copy /y libgpgme-11-msc.dll $(bindir:/=\)
-	copy /y libgpgme-11-msc.lib $(libdir:/=\)
-
-
-clean:
-	del *.obj libgpgme-11-msc.lib libgpgme-11-msc.dll libgpgme-11-msc.exp
-
diff --git a/contrib/conf-w32ce-msc/config.h b/contrib/conf-w32ce-msc/config.h
deleted file mode 100644
index d8ab5d7..0000000
--- a/contrib/conf-w32ce-msc/config.h
+++ /dev/null
@@ -1,314 +0,0 @@
-/* config.h for building with Visual-C for WindowsCE. 
- * Copyright 2010 g10 Code GmbH
- * 
- * This file is free software; as a special exception the author gives
- * unlimited permission to copy and/or distribute it, with or without
- * modifications, as long as this notice is preserved.
- * 
- * This file is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/* This file was originally created by running 
- *   ./autogen.sh --build-w32ce
- * on svn revision 1495 (gpgme 1.3.1-svn1495) and then adjusted to work
- * with Visual-C.
- */
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.3.1-svn1495-msc1"
-
-/* Name of this package */
-#define PACKAGE "gpgme"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "bug-gpgme at gnupg.org"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "gpgme"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "gpgme " PACKAGE_VERSION
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "gpgme"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-
-
-/* Whether Assuan support is enabled */
-#define ENABLE_ASSUAN 1
-
-/* Whether G13 support is enabled */
-#define ENABLE_G13 1
-
-/* Whether GPGCONF support is enabled */
-#define ENABLE_GPGCONF 1
-
-/* Whether GPGSM support is enabled */
-#define ENABLE_GPGSM 1
-
-/* Defined if we are building with uiserver support. */
-/* #undef ENABLE_UISERVER */
-
-/* Path to the G13 binary. */
-#define G13_PATH "c:\\gnupg\\g13.exe"
-
-/* Path to the GPGCONF binary. */
-#define GPGCONF_PATH "c:\\gnupg\\gpgconf.exe"
-
-/* version of the libassuan library */
-#define GPGME_LIBASSUAN_VERSION "2.0.2-svn381"
-
-/* Path to the GPGSM binary. */
-#define GPGSM_PATH "c:\\gnupg\\gpgsm.exe"
-
-/* The default error source for GPGME. */
-#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_GPGME
-
-/* Path to the GnuPG binary. */
-#define GPG_PATH "c:\\gnupg\\gpg.exe"
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-/* #undef HAVE_DLFCN_H */
-
-/* Defined if we run on some of the PCDOS like systems (DOS, Windoze. OS/2)
-   with special properties like no file modes */
-#define HAVE_DOSISH_SYSTEM 1
-
-/* Define to 1 if the system has the type `error_t'. */
-/* #undef HAVE_ERROR_T */
-
-/* Define to 1 if you have the `fopencookie' function. */
-/* #undef HAVE_FOPENCOOKIE */
-
-/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
-/* #undef HAVE_FSEEKO */
-
-/* Define to 1 if you have the `funopen' function. */
-/* #undef HAVE_FUNOPEN */
-
-/* Define to 1 if you have the `getegid' function. */
-/* #undef HAVE_GETEGID */
-
-/* Define to 1 if you have the `getenv_r' function. */
-/* #undef HAVE_GETENV_R */
-
-/* Define to 1 if you have the `getgid' function. */
-/* #undef HAVE_GETGID */
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the <locale.h> header file. */
-/* #undef HAVE_LOCALE_H */
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define if we have Pth. */
-/* #undef HAVE_PTH */
-
-/* Define if we have pthread. */
-/* #undef HAVE_PTHREAD */
-
-/* Define to 1 if you have the `setenv' function. */
-/* #undef HAVE_SETENV */
-
-/* Define to 1 if you have the `setlocale' function. */
-/* #undef HAVE_SETLOCALE */
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `stpcpy' function. */
-/* #undef HAVE_STPCPY */
-
-/* Define to 1 if you have the <strings.h> header file. */
-/* #undef HAVE_STRINGS_H */
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <sys/select.h> header file. */
-/* #undef HAVE_SYS_SELECT_H */
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-/* #undef HAVE_SYS_STAT_H */
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-/* #undef HAVE_SYS_TYPES_H */
-
-/* Define to 1 if you have the <sys/uio.h> header file. */
-/* #undef HAVE_SYS_UIO_H */
-
-/* Define if getenv() is thread-safe */
-/* #undef HAVE_THREAD_SAFE_GETENV */
-
-/* Define to 1 if you have the `timegm' function. */
-/* #undef HAVE_TIMEGM */
-
-/* Define if __thread is supported */
-/* #define HAVE_TLS 1 */
-
-/* Define to 1 if you have the `ttyname_r' function. */
-/* #undef HAVE_TTYNAME_R */
-
-/* Define to 1 if the system has the type `uintptr_t'. */
-#define HAVE_UINTPTR_T 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-/* #define HAVE_UNISTD_H 1 */
-
-/* Define to 1 if you have the `vasprintf' function. */
-/* #undef HAVE_VASPRINTF */
-
-/* Defined if we run on a W32 CE API based system */
-#define HAVE_W32CE_SYSTEM 1
-
-/* Defined if we run on a W32 API based system */
-#define HAVE_W32_SYSTEM 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
-#define LT_OBJDIR ".libs/"
-
-/* used to implement the va_copy macro */
-/* #undef MUST_COPY_VA_BYVAL */
-
-/* Min. needed G13 version. */
-#define NEED_G13_VERSION "2.1.0"
-
-/* Min. needed GPGCONF version. */
-#define NEED_GPGCONF_VERSION "2.0.4"
-
-/* Min. needed GPGSM version. */
-#define NEED_GPGSM_VERSION "1.9.6"
-
-/* Min. needed GnuPG version. */
-#define NEED_GPG_VERSION "1.4.0"
-
-
-/* Separators as used in $PATH.  */
-#ifdef HAVE_DOSISH_SYSTEM
-#define PATHSEP_C ';'
-#else
-#define PATHSEP_C ':'
-#endif
-
-
-/* The size of `unsigned int', as computed by sizeof. */
-#define SIZEOF_UNSIGNED_INT 4
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Defined if descriptor passing is enabled and supported */
-/* #undef USE_DESCRIPTOR_PASSING */
-
-/* Enable extensions on AIX 3, Interix.  */
-#ifndef _ALL_SOURCE
-# define _ALL_SOURCE 1
-#endif
-/* Enable GNU extensions on systems that have them.  */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-/* Enable threading extensions on Solaris.  */
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# define _POSIX_PTHREAD_SEMANTICS 1
-#endif
-/* Enable extensions on HP NonStop.  */
-#ifndef _TANDEM_SOURCE
-# define _TANDEM_SOURCE 1
-#endif
-/* Enable general extensions on Solaris.  */
-#ifndef __EXTENSIONS__
-# define __EXTENSIONS__ 1
-#endif
-
-
-/* Version of this package */
-#define VERSION PACKAGE_VERSION
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-/* #undef _FILE_OFFSET_BITS */
-
-/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
-/* #undef _LARGEFILE_SOURCE */
-
-/* Define for large files, on AIX-style hosts. */
-/* #undef _LARGE_FILES */
-
-/* Define to 1 if on MINIX. */
-/* #undef _MINIX */
-
-/* Define to 2 if the system does not provide POSIX.1 features except with
-   this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define to 1 if you need to in order for `stat' and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* To allow the use of GPGME in multithreaded programs we have to use
-  special features from the library.
-  IMPORTANT: gpgme is not yet fully reentrant and you should use it
-  only from one thread.  */
-#ifndef _REENTRANT
-# define _REENTRANT 1
-#endif
-
-/* Activate POSIX interface on MacOS X */
-/* #undef _XOPEN_SOURCE */
-
-/* Define to a type to use for `error_t' if it is not otherwise available. */
-#define error_t int
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
-   calls it, or to nothing if 'inline' is not supported under any name.  */
-#ifndef __cplusplus
-#define inline __inline
-#endif
-
-/* Define to `long int' if <sys/types.h> does not define. */
-/* #undef off_t */
-
-/* Define to the type of an unsigned integer type wide enough to hold a
-   pointer, if such a type exists, and if the system does not define it. */
-/* #undef uintptr_t */
-
-
-/* Definition of GCC specific attributes.  */
-#if __GNUC__ > 2 
-# define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
-#else
-# define GPGME_GCC_A_PURE
-#endif
-
-/* Under WindowsCE we need gpg-error's strerror macro.  */
-#define GPG_ERR_ENABLE_ERRNO_MACROS 1
-
-/* snprintf is not part of oldnames.lib thus we redefine it here. */
-#define snprintf _snprintf
-
-/* We don't want warnings like this:
-
-   warning C4996: e.g. "The POSIX name for this item is
-   deprecated. Instead, use the ISO C++ conformant name: _fileno"
-
-   warning C4018: '<' : signed/unsigned mismatch
-
-   warning C4244: '=' : conversion from 'time_t' to
-                        'unsigned long', possible loss of data
-
- */
-#pragma warning(disable:4996 4018 4244)
-
-
-
diff --git a/contrib/conf-w32ce-msc/fcntl.h b/contrib/conf-w32ce-msc/fcntl.h
deleted file mode 100755
index 08c7415..0000000
--- a/contrib/conf-w32ce-msc/fcntl.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Dummy fcntl.h header.  */
diff --git a/contrib/conf-w32ce-msc/io.h b/contrib/conf-w32ce-msc/io.h
deleted file mode 100755
index d586b8c..0000000
--- a/contrib/conf-w32ce-msc/io.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Dummy io.h header. */
-
diff --git a/contrib/conf-w32ce-msc/stdint.h b/contrib/conf-w32ce-msc/stdint.h
deleted file mode 100755
index 0a821b7..0000000
--- a/contrib/conf-w32ce-msc/stdint.h
+++ /dev/null
@@ -1,9 +0,0 @@
-typedef unsigned long long uint64_t;
-typedef long long int64_t;
-typedef unsigned int uint32_t;
-typedef int int32_t;
-typedef unsigned short uint16_t;
-typedef short int16_t;
-typedef unsigned int uintptr_t;
-typedef int intptr_t;
-
diff --git a/src/Makefile.am b/src/Makefile.am
index 1394c02..276d976 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,10 +50,6 @@ system_components = ath.h posix-util.c posix-io.c
 system_components_not_extra =
 endif
 
-if HAVE_W32CE_SYSTEM
-system_components += w32-ce.h w32-ce.c
-endif
-
 if HAVE_UISERVER
 uiserver_components = engine-uiserver.c
 else
@@ -111,12 +107,7 @@ if HAVE_W32_SYSTEM
 # Windows provides us with an endless stream of Tough Love.  To spawn
 # processes with a controlled set of inherited handles, we need a
 # wrapper process.
-# Except on Windows CE.  There nothing is inheritable anyway.
-if HAVE_W32CE_SYSTEM
-libexec_PROGRAMS =
-else
 libexec_PROGRAMS = gpgme-w32spawn
-endif
 
 RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
 LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE)
diff --git a/src/ath.c b/src/ath.c
index 6b4667e..94d5eb1 100644
--- a/src/ath.c
+++ b/src/ath.c
@@ -78,22 +78,14 @@ ath_self (void)
 gpgme_ssize_t
 ath_read (int fd, void *buf, size_t nbytes)
 {
-#if defined(HAVE_W32CE_SYSTEM) && defined(_MSC_VER)
-  return -1; /* Not supported. */
-#else
   return read (fd, buf, nbytes);
-#endif
 }
 
 
 gpgme_ssize_t
 ath_write (int fd, const void *buf, size_t nbytes)
 {
-#if defined(HAVE_W32CE_SYSTEM) && defined(_MSC_VER)
-  return -1; /* Not supported. */
-#else
   return write (fd, buf, nbytes);
-#endif
 }
 
 
diff --git a/src/ath.h b/src/ath.h
index a1be9e5..d4c1c6f 100644
--- a/src/ath.h
+++ b/src/ath.h
@@ -28,9 +28,6 @@
   /* fixme: Check how we did it in libgcrypt.  */
   struct msghdr { int dummy; };
   typedef int socklen_t;
-# if defined(HAVE_W32CE_SYSTEM) && defined(_MSC_VER)
-#  include <winsock2.h>
-# endif
 # include <windows.h>
 # include <io.h>
 
diff --git a/src/data-compat.c b/src/data-compat.c
index 87eaeef..1f04c46 100644
--- a/src/data-compat.c
+++ b/src/data-compat.c
@@ -43,9 +43,6 @@ gpgme_error_t
 gpgme_data_new_from_filepart (gpgme_data_t *r_dh, const char *fname,
 			      FILE *stream, gpgme_off_t offset, size_t length)
 {
-#if defined (HAVE_W32CE_SYSTEM) && defined (_MSC_VER)
-  return gpgme_error (GPG_ERR_NOT_IMPLEMENTED);
-#else
   gpgme_error_t err;
   char *buf = NULL;
   int res;
@@ -114,7 +111,6 @@ gpgme_data_new_from_filepart (gpgme_data_t *r_dh, const char *fname,
   (*r_dh)->data.mem.length = length;
 
   return TRACE_SUC1 ("r_dh=%p", *r_dh);
-#endif
 }
 
 

@@ -123,9 +119,6 @@ gpgme_data_new_from_filepart (gpgme_data_t *r_dh, const char *fname,
 gpgme_error_t
 gpgme_data_new_from_file (gpgme_data_t *r_dh, const char *fname, int copy)
 {
-#if defined (HAVE_W32CE_SYSTEM) && defined (_MSC_VER)
-  return gpgme_error (GPG_ERR_NOT_IMPLEMENTED);
-#else
   gpgme_error_t err;
   struct stat statbuf;
   TRACE_BEG3 (DEBUG_DATA, "gpgme_data_new_from_file", r_dh,
@@ -139,7 +132,6 @@ gpgme_data_new_from_file (gpgme_data_t *r_dh, const char *fname, int copy)
 
   err = gpgme_data_new_from_filepart (r_dh, fname, NULL, 0, statbuf.st_size);
   return TRACE_ERR (err);
-#endif
 }
 
 

diff --git a/src/data-fd.c b/src/data-fd.c
index 42d6a0d..cf17f00 100644
--- a/src/data-fd.c
+++ b/src/data-fd.c
@@ -33,62 +33,6 @@
 #include "data.h"
 
 
-

-#if defined(HAVE_W32CE_SYSTEM) && !defined(__MINGW32CE__)
-/* We need to provide replacements for read, write and lseek.  They
-   are taken from the cegcc runtime files, written by Pedro Alves
-   <pedro_alves at portugalmail.pt> in Feb 2007 and placed in the public
-   domain. (cf. cegcc/src/mingw/mingwex/wince/)  */
-
-#include <windows.h>
-
-static int
-read (int fildes, void *buf, unsigned int bufsize)
-{
-  DWORD NumberOfBytesRead;
-  if (bufsize > 0x7fffffff)
-    bufsize = 0x7fffffff;
-  if (!ReadFile ((HANDLE) fildes, buf, bufsize, &NumberOfBytesRead, NULL))
-    return -1;
-  return (int) NumberOfBytesRead;
-}
-
-static int
-write (int fildes, const void *buf, unsigned int bufsize)
-{
-  DWORD NumberOfBytesWritten;
-  if (bufsize > 0x7fffffff)
-    bufsize = 0x7fffffff;
-  if (!WriteFile ((HANDLE) fildes, buf, bufsize, &NumberOfBytesWritten, NULL))
-    return -1;
-  return (int) NumberOfBytesWritten;
-}
-
-static long
-lseek (int fildes, long offset, int whence)
-{
-  DWORD mode;
-  switch (whence)
-    {
-    case SEEK_SET:
-      mode = FILE_BEGIN;
-      break;
-    case SEEK_CUR:
-      mode = FILE_CURRENT;
-      break;
-    case SEEK_END:
-      mode = FILE_END;
-      break;
-    default:
-      /* Specify an invalid mode so SetFilePointer catches it.  */
-      mode = (DWORD)-1;
-    }
-  return (long) SetFilePointer ((HANDLE) fildes, offset, NULL, mode);
-}
-#endif /*HAVE_W32CE_SYSTEM && !__MINGW32CE__*/
-
-
-

 static gpgme_ssize_t
 fd_read (gpgme_data_t dh, void *buffer, size_t size)
 {
diff --git a/src/debug.c b/src/debug.c
index 37baabb..84aa408 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -150,16 +150,12 @@ debug_init (void)
         }
       else
         {
-#ifdef HAVE_W32CE_SYSTEM
-          e = _gpgme_w32ce_get_debug_envvar ();
-#else /*!HAVE_W32CE_SYSTEM*/
           err = _gpgme_getenv ("GPGME_DEBUG", &e);
           if (err)
             {
               UNLOCK (debug_lock);
               return;
             }
-#endif /*!HAVE_W32CE_SYSTEM*/
         }
 
       initialized = 1;
@@ -257,15 +253,6 @@ _gpgme_debug (int level, const char *format, ...)
   va_start (arg_ptr, format);
   LOCK (debug_lock);
   {
-#ifdef HAVE_W32CE_SYSTEM
-    SYSTEMTIME t;
-
-    GetLocalTime (&t);
-    fprintf (errfp, "GPGME %04d-%02d-%02d %02d:%02d:%02d <0x%04llx>  ",
-	     t.wYear, t.wMonth, t.wDay,
-	     t.wHour, t.wMinute, t.wSecond,
-	     (unsigned long long) ath_self ());
-#else
     struct tm *tp;
     time_t atime = time (NULL);
 
@@ -274,7 +261,6 @@ _gpgme_debug (int level, const char *format, ...)
 	     1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday,
 	     tp->tm_hour, tp->tm_min, tp->tm_sec,
 	     (unsigned long long) ath_self ());
-#endif
   }
 #ifdef FRAME_NR
   {
diff --git a/src/debug.h b/src/debug.h
index 6bde998..ca65d9e 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -211,6 +211,10 @@ _gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line)
 #define TRACE_SUC2(fmt, arg1, arg2)					\
   _gpgme_debug (_gpgme_trace_level, "%s: leave: " fmt "\n",	\
 		_gpgme_trace_func, arg1, arg2), _gpgme_debug_frame_end ()
+#define TRACE_SUC4(fmt, arg1, arg2, arg3, arg4)			\
+  _gpgme_debug (_gpgme_trace_level, "%s: leave: " fmt "\n",	\
+		_gpgme_trace_func, arg1, arg2, arg3, arg4), \
+    _gpgme_debug_frame_end ()
 #define TRACE_SUC5(fmt, arg1, arg2, arg3, arg4, arg5)			\
   _gpgme_debug (_gpgme_trace_level, "%s: leave: " fmt "\n",	\
 		_gpgme_trace_func, arg1, arg2, arg3, arg4, arg5), \
diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c
index e7a7a6f..5c34b0b 100644
--- a/src/gpgme-tool.c
+++ b/src/gpgme-tool.c
@@ -3282,15 +3282,11 @@ gpgme_server (gpgme_tool_t gt)
   gt->write_data_hook = &server;
 
   /* We use a pipe based server so that we can work from scripts.
-     assuan_init_pipe_server will automagically detect when we are
-     called with a socketpair and ignore FIELDES in this case. */
-#ifdef HAVE_W32CE_SYSTEM
-  filedes[0] = ASSUAN_STDIN;
-  filedes[1] = ASSUAN_STDOUT;
-#else
+   * assuan_init_pipe_server will automagically detect when we are
+   * called with a socketpair and ignore FILEDES in this case. */
   filedes[0] = assuan_fdopen (0);
   filedes[1] = assuan_fdopen (1);
-#endif
+
   err = assuan_new (&server.assuan_ctx);
   if (err)
     log_error (1, err, "can't create assuan context");
@@ -3439,10 +3435,5 @@ main (int argc, char *argv[])
   if (needgt)
     gpgme_release (gt.ctx);
 
-#ifdef HAVE_W32CE_SYSTEM
-  /* Give the buggy ssh server time to flush the output buffers.  */
-  Sleep (300);
-#endif
-
   return 0;
 }
diff --git a/src/priv-io.h b/src/priv-io.h
index bc9d3d5..d21f1b3 100644
--- a/src/priv-io.h
+++ b/src/priv-io.h
@@ -23,9 +23,6 @@
 #define IO_H
 
 #ifdef HAVE_W32_SYSTEM
-# ifdef HAVE_W32CE_SYSTEM
-#  include "w32-ce.h"
-# endif
 # include <winsock2.h>
 # include <windows.h>
 #else
diff --git a/src/util.h b/src/util.h
index da929eb..cea5e1f 100644
--- a/src/util.h
+++ b/src/util.h
@@ -23,12 +23,8 @@
 #define UTIL_H
 
 #ifdef HAVE_W32_SYSTEM
-# ifdef HAVE_W32CE_SYSTEM
-#  include "w32-ce.h"
-# else
-#  include "winsock2.h"
-#  include "windows.h"
-# endif
+# include "winsock2.h"
+# include "windows.h"
 #endif
 
 /* For pid_t.  */
@@ -208,9 +204,6 @@ const char *_gpgme_status_to_string (gpgme_status_code_t code);
 int _gpgme_mkstemp (int *fd, char **name);
 const char *_gpgme_get_w32spawn_path (void);
 #endif /*HAVE_W32_SYSTEM*/
-#ifdef HAVE_W32CE_SYSTEM
-char *_gpgme_w32ce_get_debug_envvar (void);
-#endif /*HAVE_W32CE_SYSTEM*/
 
 
 

diff --git a/src/w32-ce.c b/src/w32-ce.c
deleted file mode 100644
index e326bfe..0000000
--- a/src/w32-ce.c
+++ /dev/null
@@ -1,507 +0,0 @@
-/* w32-ce.h
-   Copyright (C) 2010 g10 Code GmbH
-   Copyright (C) 1991,92,97,2000,02 Free Software Foundation, Inc.
-
-   This file is part of GPGME.
-
-   GPGME 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.
-
-   GPGME is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this program; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
-
-#include <gpg-error.h>
-
-#define _WIN32_IE 0x0400 /* Required for SHGetSpecialFolderPathW.  */
-
-/* We need to include the windows stuff here prior to shlobj.h so that
-   we get the right winsock version.  This is usually done in w32-ce.h
-   but that header also redefines some Windows functions which we need
-   to avoid unless having included shlobj.h.  */
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#include <windows.h>
-#include <shlobj.h>
-
-#include "w32-ce.h"
-
-/* Return a malloced string encoded in UTF-8 from the wide char input
-   string STRING.  Caller must free this value.  Returns NULL and sets
-   ERRNO on failure.  Calling this function with STRING set to NULL is
-   not defined.  */
-char *
-wchar_to_utf8 (const wchar_t *string)
-{
-  int n;
-  char *result;
-
-  n = WideCharToMultiByte (CP_UTF8, 0, string, -1, NULL, 0, NULL, NULL);
-  if (n < 0)
-    {
-      gpg_err_set_errno (EINVAL);
-      return NULL;
-    }
-
-  result = malloc (n+1);
-  if (!result)
-    return NULL;
-
-  n = WideCharToMultiByte (CP_UTF8, 0, string, -1, result, n, NULL, NULL);
-  if (n < 0)
-    {
-      free (result);
-      gpg_err_set_errno (EINVAL);
-      result = NULL;
-    }
-  return result;
-}
-
-
-/* Return a malloced wide char string from an UTF-8 encoded input
-   string STRING.  Caller must free this value.  Returns NULL and sets
-   ERRNO on failure.  Calling this function with STRING set to NULL is
-   not defined.  */
-wchar_t *
-utf8_to_wchar (const char *string)
-{
-  int n;
-  size_t nbytes;
-  wchar_t *result;
-
-  n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0);
-  if (n < 0)
-    {
-      gpg_err_set_errno (EINVAL);
-      return NULL;
-    }
-
-  nbytes = (size_t)(n+1) * sizeof(*result);
-  if (nbytes / sizeof(*result) != (n+1))
-    {
-      gpg_err_set_errno (ENOMEM);
-      return NULL;
-    }
-  result = malloc (nbytes);
-  if (!result)
-    return NULL;
-
-  n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n);
-  if (n < 0)
-    {
-      free (result);
-      gpg_err_set_errno (EINVAL);
-      result = NULL;
-    }
-  return result;
-}
-
-
-#define MAX_ENV 30
-
-char *environ[MAX_ENV + 1];
-
-char *
-getenv (const char *name)
-{
-  static char *past_result;
-  char **envp;
-
-  if (past_result)
-    {
-      free (past_result);
-      past_result = NULL;
-    }
-
-#if 0
-  if (! strcmp (name, "DBUS_VERBOSE"))
-    return past_result = get_verbose_setting ();
-  else if (! strcmp (name, "HOMEPATH"))
-    return past_result = find_my_documents_folder ();
-  else if (! strcmp (name, "DBUS_DATADIR"))
-    return past_result = find_inst_subdir ("share");
-#endif
-
-  for (envp = environ; *envp != 0; envp++)
-    {
-      const char *varp = name;
-      char *ep = *envp;
-
-      while (*varp == *ep && *varp != '\0')
-	{
-	  ++ep;
-	  ++varp;
-	};
-
-      if (*varp == '\0' && *ep == '=')
-	return ep + 1;
-    }
-
-  return NULL;
-}
-
-
-void
-GetSystemTimeAsFileTime (LPFILETIME ftp)
-{
-  SYSTEMTIME st;
-  GetSystemTime (&st);
-  SystemTimeToFileTime (&st, ftp);
-}
-
-
-BOOL
-DeleteFileA (LPCSTR lpFileName)
-{
-  wchar_t *filename;
-  BOOL result;
-  int err;
-
-  filename = utf8_to_wchar (lpFileName);
-  if (!filename)
-    return FALSE;
-
-  result = DeleteFileW (filename);
-
-  err = GetLastError ();
-  free (filename);
-  SetLastError (err);
-  return result;
-}
-
-
-HANDLE
-CreateFileA (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwSharedMode,
-	     LPSECURITY_ATTRIBUTES lpSecurityAttributes,
-	     DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
-	     HANDLE hTemplateFile)
-{
-  wchar_t *filename;
-  HANDLE result;
-  int err;
-
-  filename = utf8_to_wchar (lpFileName);
-  if (!filename)
-    return INVALID_HANDLE_VALUE;
-
-  result = CreateFileW (filename, dwDesiredAccess, dwSharedMode,
-			lpSecurityAttributes, dwCreationDisposition,
-			dwFlagsAndAttributes, hTemplateFile);
-
-  err = GetLastError ();
-  free (filename);
-  SetLastError (err);
-  return result;
-}
-
-
-BOOL
-CreateProcessA (LPCSTR pszImageName, LPSTR pszCmdLine,
-                LPSECURITY_ATTRIBUTES psaProcess,
-                LPSECURITY_ATTRIBUTES psaThread, BOOL fInheritHandles,
-                DWORD fdwCreate, PVOID pvEnvironment, LPCSTR pszCurDir,
-                LPSTARTUPINFOA psiStartInfo,
-                LPPROCESS_INFORMATION pProcInfo)
-{
-  wchar_t *image_name = NULL;
-  wchar_t *cmd_line = NULL;
-  BOOL result;
-  int err;
-
-  assert (psaProcess == NULL);
-  assert (psaThread == NULL);
-  assert (fInheritHandles == FALSE);
-  assert (pvEnvironment == NULL);
-  assert (pszCurDir == NULL);
-  /* psiStartInfo is generally not NULL.  */
-
-  if (pszImageName)
-    {
-      image_name = utf8_to_wchar (pszImageName);
-      if (!image_name)
-	return 0;
-    }
-  if (pszCmdLine)
-    {
-      cmd_line = utf8_to_wchar (pszCmdLine);
-      if (!cmd_line)
-        {
-          if (image_name)
-            free (image_name);
-          return 0;
-        }
-    }
-
-  result = CreateProcessW (image_name, cmd_line, NULL, NULL, FALSE,
-                           fdwCreate, NULL, NULL, NULL, pProcInfo);
-
-  err = GetLastError ();
-  free (image_name);
-  free (cmd_line);
-  SetLastError (err);
-  return result;
-}
-
-
-LONG
-RegOpenKeyExA (HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions,
-               REGSAM samDesired, PHKEY phkResult)
-{
-  wchar_t *subkey;
-  LONG result;
-  int err;
-
-  if (lpSubKey)
-    {
-      subkey = utf8_to_wchar (lpSubKey);
-      if (!subkey)
-	return 0;
-    }
-  else
-    subkey = NULL;
-
-  result = RegOpenKeyEx (hKey, subkey, ulOptions, samDesired, phkResult);
-
-  err = GetLastError ();
-  free (subkey);
-  SetLastError (err);
-  return result;
-}
-
-
-LONG WINAPI
-RegQueryValueExA (HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved,
-                  LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData)
-{
-  wchar_t *name;
-  LONG err;
-  void *data;
-  DWORD data_len;
-  DWORD type;
-
-  if (lpValueName)
-    {
-      name = utf8_to_wchar (lpValueName);
-      if (!name)
-	return GetLastError ();
-    }
-  else
-    name = NULL;
-
-  data_len = 0;
-  err = RegQueryValueExW (hKey, name, lpReserved, lpType, NULL, &data_len);
-  if (err || !lpcbData)
-    {
-      free (name);
-      return err;
-    }
-
-  data = malloc (data_len + sizeof (wchar_t));
-  if (!data)
-    {
-      free (name);
-      return ERROR_NOT_ENOUGH_MEMORY;
-    }
-
-  err = RegQueryValueExW (hKey, name, lpReserved, &type, data, &data_len);
-  if (lpType)
-    *lpType = type;
-  free (name);
-  /* If err is ERROR_MORE_DATA, there probably was a race condition.
-     We can punt this to the caller just as well.  */
-  if (err)
-    return err;
-
-  /* NOTE: REG_MULTI_SZ and REG_EXPAND_SZ not supported, because they
-     are not needed in this module.  */
-  if (type == REG_SZ)
-    {
-      char *data_c;
-      int data_c_len;
-
-      /* This is valid since we allocated one more above.  */
-      ((char*)data)[data_len] = '\0';
-      ((char*)data)[data_len + 1] = '\0';
-
-      data_c = wchar_to_utf8 ((wchar_t*) data);
-      if (!data_c)
-        return GetLastError();
-
-      data_c_len = strlen (data_c) + 1;
-      assert (data_c_len <= data_len + sizeof (wchar_t));
-      memcpy (data, data_c, data_c_len);
-      data_len = data_c_len;
-      free (data_c);
-    }
-
-  /* DATA and DATA_LEN now contain the result.  */
-  if (lpData)
-    {
-      if (data_len > *lpcbData)
-        err = ERROR_MORE_DATA;
-      else
-        memcpy (lpData, data, data_len);
-    }
-  *lpcbData = data_len;
-  return err;
-}
-
-
-DWORD
-GetTempPathA (DWORD nBufferLength, LPSTR lpBuffer)
-{
-  wchar_t dummy[1];
-  DWORD len;
-
-  len = GetTempPathW (0, dummy);
-  if (len == 0)
-    return 0;
-
-  assert (len <= MAX_PATH);
-
-  /* Better be safe than sorry.  MSDN doesn't say if len is with or
-     without terminating 0.  */
-  len++;
-
-  {
-    wchar_t *buffer_w;
-    DWORD len_w;
-    char *buffer_c;
-    DWORD len_c;
-
-    buffer_w = malloc (sizeof (wchar_t) * len);
-    if (! buffer_w)
-      return 0;
-
-    len_w = GetTempPathW (len, buffer_w);
-    /* Give up if we still can't get at it.  */
-    if (len_w == 0 || len_w >= len)
-      {
-        free (buffer_w);
-        return 0;
-      }
-
-    /* Better be really safe.  */
-    buffer_w[len_w] = '\0';
-
-    buffer_c = wchar_to_utf8 (buffer_w);
-    free (buffer_w);
-    if (! buffer_c)
-      return 0;
-
-    /* strlen is correct (not _mbstrlen), because we want storage and
-       not string length.  */
-    len_c = strlen (buffer_c) + 1;
-    if (len_c > nBufferLength)
-      return len_c;
-
-    strcpy (lpBuffer, buffer_c);
-    free (buffer_c);
-    return len_c - 1;
-  }
-}
-
-
-/* The symbol is named SHGetSpecialFolderPath and not
-   SHGetSpecialFolderPathW but shlobj.h from cegcc redefines it to *W
-   which is a bug.  Work around it.  */
-#ifdef __MINGW32CE__
-# undef SHGetSpecialFolderPath
-#endif
-BOOL
-SHGetSpecialFolderPathA (HWND hwndOwner, LPSTR lpszPath, int nFolder,
-                         BOOL fCreate)
-{
-  wchar_t path[MAX_PATH];
-  char *path_c;
-  BOOL result;
-
-  path[0] = (wchar_t) 0;
-  result = SHGetSpecialFolderPath (hwndOwner, path, nFolder, fCreate);
-  /* Note: May return false even if succeeds.  */
-
-  path[MAX_PATH - 1] = (wchar_t) 0;
-  path_c = wchar_to_utf8 (path);
-  if (! path_c)
-    return 0;
-
-  strncpy (lpszPath, path_c, MAX_PATH);
-  free (path_c);
-  lpszPath[MAX_PATH - 1] = '\0';
-  return result;
-}
-
-/* Replacement for the access function.  Note that we can't use fopen
-   here because wince might now allow to have a shared read for an
-   executable; it is better to to read the file attributes.
-
-   Limitation:  Only F_OK is supported.
-*/
-int
-_gpgme_wince_access (const char *fname, int mode)
-{
-  DWORD attr;
-  wchar_t *wfname;
-
-  (void)mode;
-
-  wfname = utf8_to_wchar (fname);
-  if (!wfname)
-    return -1;
-
-  attr = GetFileAttributes (wfname);
-  free (wfname);
-  if (attr == (DWORD)(-1))
-    {
-      gpg_err_set_errno (ENOENT);
-      return -1;
-    }
-  return 0;
-}
-
-
-/* Perform a binary search for KEY in BASE which has NMEMB elements
-   of SIZE bytes each.  The comparisons are done by (*COMPAR)().
-   Code taken from glibc-2.6. */
-void *
-_gpgme_wince_bsearch (const void *key, const void *base,
-                      size_t nmemb, size_t size,
-                      int (*compar) (const void *, const void *))
-{
-  size_t l, u, idx;
-  const void *p;
-  int comparison;
-
-  l = 0;
-  u = nmemb;
-  while (l < u)
-    {
-      idx = (l + u) / 2;
-      p = (void *) (((const char *) base) + (idx * size));
-      comparison = (*compar) (key, p);
-      if (comparison < 0)
-	u = idx;
-      else if (comparison > 0)
-	l = idx + 1;
-      else
-	return (void *) p;
-    }
-
-  return NULL;
-}
-
diff --git a/src/w32-ce.h b/src/w32-ce.h
deleted file mode 100644
index c52ea99..0000000
--- a/src/w32-ce.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* w32-ce.h
-   Copyright (C) 2010 g10 Code GmbH
-
-   This file is part of GPGME.
-
-   GPGME 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.
-
-   GPGME is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
-
-#ifndef GPGME_W32_CE_H
-#define GPGME_W32_CE_H
-
-#include <time.h>
-#include <stdarg.h>
-
-#ifdef _MSC_VER
-typedef int pid_t;
-#define strdup _strdup
-#define strcasecmp _stricmp
-#endif
-
-#include <winsock2.h>
-#include <ws2tcpip.h> /* For getaddrinfo.  */
-#include <windows.h>
-
-#define getenv _gpgme_wince_getenv
-char *getenv (const char *name);
-
-#include <io.h>
-#define isatty(fd) 0
-
-
-/* Windows CE is missing some Windows functions that we want.  */
-
-#define GetSystemTimeAsFileTime _gpgme_wince_GetSystemTimeAsFileTime
-void GetSystemTimeAsFileTime (LPFILETIME ftp);
-
-#define DeleteFileA _gpgme_wince_DeleteFileA
-BOOL DeleteFileA(LPCSTR);
-
-#define CreateFileA _gpgme_wince_CreateFileA
-HANDLE CreateFileA (LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES,
-                    DWORD, DWORD, HANDLE);
-
-#define CreateProcessA _gpgme_wince_CreateProcessA
-BOOL CreateProcessA(LPCSTR,LPSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,PVOID,LPCSTR,LPSTARTUPINFOA,LPPROCESS_INFORMATION);
-
-#define RegOpenKeyExA _gpgme_wince_RegOpenKeyExA
-LONG RegOpenKeyExA(HKEY,LPCSTR,DWORD,REGSAM,PHKEY);
-
-#define RegQueryValueExA _gpgme_wince_RegQueryValueExA
-LONG WINAPI RegQueryValueExA(HKEY,LPCSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
-
-#define GetTempPathA _gpgme_wince_GetTempPathA
-DWORD GetTempPathA(DWORD,LPSTR);
-
-#define SHGetSpecialFolderPathA _gpgme_wince_SHGetSpecialFolderPathA
-BOOL SHGetSpecialFolderPathA(HWND,LPSTR,int,BOOL);
-
-int _gpgme_wince_access (const char *fname, int mode);
-#define access(a,b) _gpgme_wince_access ((a), (b))
-
-void *_gpgme_wince_bsearch (const void *key, const void *base,
-                            size_t nmemb, size_t size,
-                            int (*compar) (const void *, const void *));
-#define bsearch(a,b,c,d,e) _gpgme_wince_bsearch ((a),(b),(c),(d),(e))
-
-#if defined(_MSC_VER)
-  /* Remove the redefined __leave keyword.  It is defined by MSC for
-     W32 in excpt.h and not in sehmap.h as for the plain windows
-     version.  */
-# undef leave
-# define HKEY_PERFORMANCE_DATA ((HKEY)0x80000004)
-# define HKEY_CURRENT_CONFIG  ((HKEY)0x80000005)
-  /* Replace the Mingw32CE provided abort function.  */
-# define abort() do { TerminateProcess (GetCurrentProcess(), 8); } while (0)
-# define _IOLBF 0x40
-#endif
-
-#endif /* GPGME_W32_CE_H */
diff --git a/src/w32-io.c b/src/w32-io.c
index aea0547..bb59a5e 100644
--- a/src/w32-io.c
+++ b/src/w32-io.c
@@ -37,16 +37,6 @@
 #include <io.h>
 
 #include "util.h"
-
-#ifdef HAVE_W32CE_SYSTEM
-#include <assuan.h>
-#include <winioctl.h>
-#define GPGCEDEV_IOCTL_UNBLOCK                                        \
-  CTL_CODE (FILE_DEVICE_STREAMS, 2050, METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define GPGCEDEV_IOCTL_ASSIGN_RVID                                    \
-  CTL_CODE (FILE_DEVICE_STREAMS, 2051, METHOD_BUFFERED, FILE_ANY_ACCESS)
-#endif
-
 #include "sema.h"
 #include "priv-io.h"
 #include "debug.h"
@@ -66,9 +56,6 @@ static struct
   /* If this is not INVALID_SOCKET, then it's a Windows socket.  */
   int socket;
 
-  /* If this is not 0, then it's a rendezvous ID for the pipe server.  */
-  int rvid;
-
   /* DUP_FROM is -1 if this file descriptor was allocated by pipe or
      socket functions.  Only then should the handle or socket be
      destroyed when this FD is closed.  This, together with the fact
@@ -109,7 +96,6 @@ new_fd (void)
       fd_table[idx].used = 1;
       fd_table[idx].handle = INVALID_HANDLE_VALUE;
       fd_table[idx].socket = INVALID_SOCKET;
-      fd_table[idx].rvid = 0;
       fd_table[idx].dup_from = -1;
     }
 
@@ -132,7 +118,6 @@ release_fd (int fd)
       fd_table[fd].used = 0;
       fd_table[fd].handle = INVALID_HANDLE_VALUE;
       fd_table[fd].socket = INVALID_SOCKET;
-      fd_table[fd].rvid = 0;
       fd_table[fd].dup_from = -1;
     }
 
@@ -334,8 +319,6 @@ reader (void *arg)
                          ctx->buffer + ctx->writepos, nbytes, &nread, NULL))
             {
               ctx->error_code = (int) GetLastError ();
-	      /* NOTE (W32CE): Do not ignore ERROR_BUSY!  Check at
-		 least stop_me if that happens.  */
               if (ctx->error_code == ERROR_BROKEN_PIPE)
                 {
                   ctx->eof = 1;
@@ -445,12 +428,7 @@ create_reader (int fd)
 
   INIT_LOCK (ctx->mutex);
 
-#ifdef HAVE_W32CE_SYSTEM
-  ctx->thread_hd = CreateThread (&sec_attr, 64 * 1024, reader, ctx,
-				 STACK_SIZE_PARAM_IS_A_RESERVATION, &tid);
-#else
   ctx->thread_hd = CreateThread (&sec_attr, 0, reader, ctx, 0, &tid);
-#endif
 
   if (!ctx->thread_hd)
     {
@@ -497,22 +475,6 @@ destroy_reader (struct reader_context_s *ctx)
     SetEvent (ctx->have_space_ev);
   UNLOCK (ctx->mutex);
 
-#ifdef HAVE_W32CE_SYSTEM
-  /* Scenario: We never create a full pipe, but already started
-     reading.  Then we need to unblock the reader in the pipe driver
-     to make our reader thread notice that we want it to go away.  */
-
-  if (ctx->file_hd != INVALID_HANDLE_VALUE)
-    {
-      if (!DeviceIoControl (ctx->file_hd, GPGCEDEV_IOCTL_UNBLOCK,
-			NULL, 0, NULL, 0, NULL, NULL))
-	{
-	  TRACE1 (DEBUG_SYSIO, "gpgme:destroy_reader", ctx->file_hd,
-		  "unblock control call failed for thread %p", ctx->thread_hd);
-	}
-    }
-#endif
-
   /* The reader thread is usually blocking in recv or ReadFile.  If
      the peer does not send an EOF or breaks the pipe the WFSO might
      get stuck waiting for the termination of the reader thread.  This
@@ -817,13 +779,7 @@ create_writer (int fd)
 
   INIT_LOCK (ctx->mutex);
 
-#ifdef HAVE_W32CE_SYSTEM
-  ctx->thread_hd = CreateThread (&sec_attr, 64 * 1024, writer, ctx,
-				 STACK_SIZE_PARAM_IS_A_RESERVATION, &tid);
-#else
   ctx->thread_hd = CreateThread (&sec_attr, 0, writer, ctx, 0, &tid );
-#endif
-
   if (!ctx->thread_hd)
     {
       TRACE_LOG1 ("CreateThread failed: ec=%d", (int) GetLastError ());
@@ -869,20 +825,6 @@ destroy_writer (struct writer_context_s *ctx)
   /* Give the writer a chance to flush the buffer.  */
   WaitForSingleObject (ctx->is_empty, INFINITE);
 
-#ifdef HAVE_W32CE_SYSTEM
-  /* Scenario: We never create a full pipe, but already started
-     writing more than the pipe buffer.  Then we need to unblock the
-     writer in the pipe driver to make our writer thread notice that
-     we want it to go away.  */
-
-  if (!DeviceIoControl (ctx->file_hd, GPGCEDEV_IOCTL_UNBLOCK,
-			NULL, 0, NULL, 0, NULL, NULL))
-    {
-      TRACE1 (DEBUG_SYSIO, "gpgme:destroy_writer", ctx->file_hd,
-	      "unblock control call failed for thread %p", ctx->thread_hd);
-    }
-#endif
-
   /* After setting this event CTX is void.  */
   SetEvent (ctx->close_ev);
 }
@@ -1008,14 +950,9 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
 {
   int rfd;
   int wfd;
-#ifdef HAVE_W32CE_SYSTEM
-  HANDLE hd;
-  int rvid;
-#else
   HANDLE rh;
   HANDLE wh;
   SECURITY_ATTRIBUTES sec_attr;
-#endif
 
   TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_pipe", filedes,
 	      "inherit_idx=%i (GPGME uses it for %s)",
@@ -1031,32 +968,6 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
       return TRACE_SYSRES (-1);
     }
 
-#ifdef HAVE_W32CE_SYSTEM
-  hd = _assuan_w32ce_prepare_pipe (&rvid, !inherit_idx);
-  if (hd == INVALID_HANDLE_VALUE)
-    {
-      TRACE_LOG1 ("_assuan_w32ce_prepare_pipe failed: ec=%d",
-		  (int) GetLastError ());
-      release_fd (rfd);
-      release_fd (wfd);
-      /* FIXME: Should translate the error code.  */
-      gpg_err_set_errno (EIO);
-      return TRACE_SYSRES (-1);
-    }
-
-  if (inherit_idx == 0)
-    {
-      fd_table[rfd].rvid = rvid;
-      fd_table[wfd].handle = hd;
-    }
-  else
-    {
-      fd_table[rfd].handle = hd;
-      fd_table[wfd].rvid = rvid;
-    }
-
-#else
-
   memset (&sec_attr, 0, sizeof (sec_attr));
   sec_attr.nLength = sizeof (sec_attr);
   sec_attr.bInheritHandle = FALSE;
@@ -1114,13 +1025,11 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
     }
   fd_table[rfd].handle = rh;
   fd_table[wfd].handle = wh;
-#endif
 
   filedes[0] = rfd;
   filedes[1] = wfd;
-  return TRACE_SUC6 ("read=0x%x (%p/0x%x), write=0x%x (%p/0x%x)",
-		     rfd, fd_table[rfd].handle, fd_table[rfd].rvid,
-		     wfd, fd_table[wfd].handle, fd_table[wfd].rvid);
+  return TRACE_SUC4 ("read=0x%x (%p), write=0x%x (%p)",
+		     rfd, fd_table[rfd].handle, wfd, fd_table[wfd].handle);
 }
 
 
@@ -1213,7 +1122,6 @@ _gpgme_io_close (int fd)
 	      return TRACE_SYSRES (-1);
 	    }
 	}
-      /* Nothing to do for RVIDs.  */
     }
 
   release_fd (fd);
@@ -1263,91 +1171,6 @@ _gpgme_io_set_nonblocking (int fd)
 }
 
 
-#ifdef HAVE_W32CE_SYSTEM
-static char *
-build_commandline (char **argv, int fd0, int fd0_isnull,
-		   int fd1, int fd1_isnull,
-		   int fd2, int fd2_isnull)
-{
-  int i, n;
-  const char *s;
-  char *buf, *p;
-  char fdbuf[3*30];
-
-  p = fdbuf;
-  *p = 0;
-
-  if (fd0 != -1)
-    {
-      if (fd0_isnull)
-        strcpy (p, "-&S0=null ");
-      else
-	snprintf (p, 25, "-&S0=%d ", fd_table[fd0].rvid);
-      p += strlen (p);
-    }
-  if (fd1 != -1)
-    {
-      if (fd1_isnull)
-        strcpy (p, "-&S1=null ");
-      else
-	snprintf (p, 25, "-&S1=%d ", fd_table[fd1].rvid);
-      p += strlen (p);
-    }
-  if (fd2 != -1)
-    {
-      if (fd2_isnull)
-        strcpy (p, "-&S2=null ");
-      else
-        snprintf (p, 25, "-&S2=%d ", fd_table[fd2].rvid);
-      p += strlen (p);
-    }
-  strcpy (p, "-&S2=null ");
-  p += strlen (p);
-
-  n = strlen (fdbuf);
-  for (i=0; (s = argv[i]); i++)
-    {
-      if (!i)
-        continue; /* Ignore argv[0].  */
-      n += strlen (s) + 1 + 2;  /* (1 space, 2 quoting) */
-      for (; *s; s++)
-        if (*s == '\"')
-          n++;  /* Need to double inner quotes.  */
-    }
-  n++;
-  buf = p = malloc (n);
-  if (! buf)
-    return NULL;
-
-  p = stpcpy (p, fdbuf);
-  for (i = 0; argv[i]; i++)
-    {
-      if (!i)
-        continue; /* Ignore argv[0].  */
-      if (i > 1)
-        p = stpcpy (p, " ");
-
-      if (! *argv[i]) /* Empty string. */
-        p = stpcpy (p, "\"\"");
-      else if (strpbrk (argv[i], " \t\n\v\f\""))
-        {
-          p = stpcpy (p, "\"");
-          for (s = argv[i]; *s; s++)
-            {
-              *p++ = *s;
-              if (*s == '\"')
-                *p++ = *s;
-            }
-          *p++ = '\"';
-          *p = 0;
-        }
-      else
-        p = stpcpy (p, argv[i]);
-    }
-
-  return buf;
-}
-#else
 static char *
 build_commandline (char **argv)
 {
@@ -1401,7 +1224,6 @@ build_commandline (char **argv)
 
   return buf;
 }
-#endif
 
 
 int
@@ -1419,120 +1241,6 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
     };
   int i;
 
-#ifdef HAVE_W32CE_SYSTEM
-  int fd_in = -1;
-  int fd_out = -1;
-  int fd_err = -1;
-  int fd_in_isnull = 1;
-  int fd_out_isnull = 1;
-  int fd_err_isnull = 1;
-  char *cmdline;
-  HANDLE hd = INVALID_HANDLE_VALUE;
-
-  TRACE_BEG1 (DEBUG_SYSIO, "_gpgme_io_spawn", path,
-	      "path=%s", path);
-  i = 0;
-  while (argv[i])
-    {
-      TRACE_LOG2 ("argv[%2i] = %s", i, argv[i]);
-      i++;
-    }
-
-  for (i = 0; fd_list[i].fd != -1; i++)
-    {
-      int fd = fd_list[i].fd;
-
-      TRACE_LOG3 ("fd_list[%2i] = fd %i, dup_to %i", i, fd, fd_list[i].dup_to);
-      if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
-	{
-	  TRACE_LOG1 ("invalid fd 0x%x", fd);
-	  gpg_err_set_errno (EBADF);
-	  return TRACE_SYSRES (-1);
-	}
-      if (fd_table[fd].rvid == 0)
-	{
-	  TRACE_LOG1 ("fd 0x%x not inheritable (not an RVID)", fd);
-	  gpg_err_set_errno (EBADF);
-	  return TRACE_SYSRES (-1);
-	}
-
-      if (fd_list[i].dup_to == 0)
-	{
-	  fd_in = fd_list[i].fd;
-	  fd_in_isnull = 0;
-	}
-      else if (fd_list[i].dup_to == 1)
-	{
-	  fd_out = fd_list[i].fd;
-	  fd_out_isnull = 0;
-	}
-      else if (fd_list[i].dup_to == 2)
-	{
-	  fd_err = fd_list[i].fd;
-	  fd_err_isnull = 0;
-	}
-    }
-
-  cmdline = build_commandline (argv, fd_in, fd_in_isnull,
-			       fd_out, fd_out_isnull, fd_err, fd_err_isnull);
-  if (!cmdline)
-    {
-      TRACE_LOG1 ("build_commandline failed: %s", strerror (errno));
-      return TRACE_SYSRES (-1);
-    }
-
-  if (!CreateProcessA (path,                /* Program to start.  */
-		       cmdline,             /* Command line arguments.  */
-		       NULL,                 /* (not supported)  */
-		       NULL,                 /* (not supported)  */
-		       FALSE,                /* (not supported)  */
-		       (CREATE_SUSPENDED),   /* Creation flags.  */
-		       NULL,                 /* (not supported)  */
-		       NULL,                 /* (not supported)  */
-		       NULL,                 /* (not supported) */
-		       &pi                   /* Returns process information.*/
-		       ))
-    {
-      TRACE_LOG1 ("CreateProcess failed: ec=%d", (int) GetLastError ());
-      free (cmdline);
-      gpg_err_set_errno (EIO);
-      return TRACE_SYSRES (-1);
-    }
-
-  /* Create arbitrary pipe descriptor to send in ASSIGN_RVID
-     commands.  Errors are ignored.  We don't need read or write access,
-     as ASSIGN_RVID works without any permissions, yay!  */
-  hd = CreateFile (L"GPG1:", 0, 0,
-		   NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-  if (hd == INVALID_HANDLE_VALUE)
-    {
-      TRACE_LOG1 ("CreateFile failed (ignored): ec=%d",
-		  (int) GetLastError ());
-    }
-
-  /* Insert the inherited handles.  */
-  for (i = 0; fd_list[i].fd != -1; i++)
-    {
-      /* Return the child name of this handle.  */
-      fd_list[i].peer_name = fd_table[fd_list[i].fd].rvid;
-
-      if (hd != INVALID_HANDLE_VALUE)
-	{
-	  DWORD data[2];
-	  data[0] = (DWORD) fd_table[fd_list[i].fd].rvid;
-	  data[1] = pi.dwProcessId;
-	  if (!DeviceIoControl (hd, GPGCEDEV_IOCTL_ASSIGN_RVID,
-				data, sizeof (data), NULL, 0, NULL, NULL))
-	    {
-	      TRACE_LOG3 ("ASSIGN_RVID(%i, %i) failed (ignored): %i",
-			  data[0], data[1], (int) GetLastError ());
-	    }
-	}
-    }
-  if (hd != INVALID_HANDLE_VALUE)
-    CloseHandle (hd);
-
-#else
   SECURITY_ATTRIBUTES sec_attr;
   STARTUPINFOA si;
   int cr_flags = CREATE_DEFAULT_ERROR_MODE;
@@ -1729,7 +1437,6 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
   close (tmp_fd);
   /* The temporary file is deleted by the gpgme-w32spawn process
      (hopefully).  */
-#endif
 
   free (tmp_name);
   free (arg_string);
@@ -1954,15 +1661,6 @@ _gpgme_io_subsystem_init (void)
 int
 _gpgme_io_fd2str (char *buf, int buflen, int fd)
 {
-#ifdef HAVE_W32CE_SYSTEM
-  /* FIXME: For now. See above.  */
-  if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used
-      || fd_table[fd].rvid == 0)
-    fd = -1;
-  else
-    fd = fd_table[fd].rvid;
-#endif
-
   return snprintf (buf, buflen, "%d", fd);
 }
 
@@ -1989,7 +1687,6 @@ _gpgme_io_dup (int fd)
 
   fd_table[newfd].handle = fd_table[fd].handle;
   fd_table[newfd].socket = fd_table[fd].socket;
-  fd_table[newfd].rvid = fd_table[fd].rvid;
   fd_table[newfd].dup_from = fd;
 
   rd_ctx = find_reader (fd, 1);
diff --git a/src/w32-util.c b/src/w32-util.c
index ef9b5f3..7954189 100644
--- a/src/w32-util.c
+++ b/src/w32-util.c
@@ -65,9 +65,7 @@
 #include "sys-util.h"
 
 
-#ifndef HAVE_W32CE_SYSTEM
 #define HAVE_ALLOW_SET_FOREGROUND_WINDOW 1
-#endif
 #ifndef F_OK
 # define F_OK 0
 #endif
@@ -303,53 +301,6 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
     }
   result[nbytes] = 0; /* Make sure it is really a string.  */
 
-#ifndef HAVE_W32CE_SYSTEM
-  /* Windows CE does not have an environment.  */
-  if (type == REG_EXPAND_SZ && strchr (result, '%'))
-    {
-      char *tmp;
-
-      n1 += 1000;
-      tmp = malloc (n1 + 1);
-      if (!tmp)
-        goto leave;
-      nbytes = ExpandEnvironmentStrings (result, tmp, n1);
-      if (nbytes && nbytes > n1)
-        {
-          free (tmp);
-          n1 = nbytes;
-          tmp = malloc (n1 + 1);
-          if (!tmp)
-            goto leave;
-          nbytes = ExpandEnvironmentStrings (result, tmp, n1);
-          if (nbytes && nbytes > n1) {
-            free (tmp); /* Oops - truncated, better don't expand at all. */
-            goto leave;
-          }
-          tmp[nbytes] = 0;
-          free (result);
-          result = tmp;
-        }
-      else if (nbytes)  /* Okay, reduce the length. */
-        {
-          tmp[nbytes] = 0;
-          free (result);
-          result = malloc (strlen (tmp)+1);
-          if (!result)
-            result = tmp;
-          else
-            {
-              strcpy (result, tmp);
-              free (tmp);
-            }
-        }
-      else  /* Error - don't expand. */
-        {
-          free (tmp);
-        }
-    }
-#endif
-
  leave:
   RegCloseKey (key_handle);
   return result;
@@ -652,15 +603,8 @@ _gpgme_get_conf_int (const char *key, int *value)
   return 1;
 }
 
-

-#ifdef HAVE_W32CE_SYSTEM
-int
-_gpgme_mkstemp (int *fd, char **name)
-{
-  return -1;
-}
-#else
 
+

 /* mkstemp extracted from libc/sysdeps/posix/tempname.c.  Copyright
    (C) 1991-1999, 2000, 2001, 2006 Free Software Foundation, Inc.
 
@@ -794,30 +738,9 @@ _gpgme_mkstemp (int *fd, char **name)
   *name = tmpname;
   return 0;
 }
-#endif
 
 
 

-#ifdef HAVE_W32CE_SYSTEM
-/* Return a malloced string with the replacement value for the
-   GPGME_DEBUG envvar.  Caller must release.  Returns NULL if not
-   set.  */
-char *
-_gpgme_w32ce_get_debug_envvar (void)
-{
-  char *tmp;
-
-  tmp = read_w32_registry_string (NULL, "\\Software\\GNU\\gpgme", "debug");
-  if (tmp && !*tmp)
-    {
-      free (tmp);
-      tmp = NULL;
-    }
-  return tmp;
-}
-#endif /*HAVE_W32CE_SYSTEM*/
-
-
 /* Entry point called by the DLL loader.  */
 #ifdef DLL_EXPORT
 int WINAPI

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

Summary of changes:
 Makefile.am                     |   4 +-
 configure.ac                    |  11 +-
 contrib/ChangeLog-2011          |  49 ---
 contrib/conf-w32ce-msc/build.mk | 256 ------------
 contrib/conf-w32ce-msc/config.h | 314 --------------
 contrib/conf-w32ce-msc/fcntl.h  |   1 -
 contrib/conf-w32ce-msc/io.h     |   2 -
 contrib/conf-w32ce-msc/stdint.h |   9 -
 src/Makefile.am                 |   9 -
 src/ath.c                       |   8 -
 src/ath.h                       |   3 -
 src/data-compat.c               |   8 -
 src/data-fd.c                   |  56 ---
 src/debug.c                     |  14 -
 src/debug.h                     |   4 +
 src/gpgme-tool.c                |  15 +-
 src/priv-io.h                   |   3 -
 src/sys-util.h                  |   1 +
 src/util.h                      |  11 +-
 src/w32-ce.c                    | 507 -----------------------
 src/w32-ce.h                    |  91 -----
 src/w32-io.c                    | 887 +++++++++++++---------------------------
 src/w32-util.c                  | 121 ++----
 23 files changed, 343 insertions(+), 2041 deletions(-)
 delete mode 100644 contrib/ChangeLog-2011
 delete mode 100755 contrib/conf-w32ce-msc/build.mk
 delete mode 100644 contrib/conf-w32ce-msc/config.h
 delete mode 100755 contrib/conf-w32ce-msc/fcntl.h
 delete mode 100755 contrib/conf-w32ce-msc/io.h
 delete mode 100755 contrib/conf-w32ce-msc/stdint.h
 delete mode 100644 src/w32-ce.c
 delete mode 100644 src/w32-ce.h


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list