[svn] gpgme - r1140 - in trunk: . doc gpgme

svn author wk cvs at cvs.gnupg.org
Fri Nov 18 17:52:39 CET 2005


Author: wk
Date: 2005-11-18 17:52:38 +0100 (Fri, 18 Nov 2005)
New Revision: 1140

Modified:
   trunk/ChangeLog
   trunk/autogen.sh
   trunk/configure.ac
   trunk/doc/gpgme.texi
   trunk/gpgme/ChangeLog
   trunk/gpgme/versioninfo.rc.in
   trunk/gpgme/w32-glib-io.c
Log:
GPA does now work with the glib based i/o backend.

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-11-18 14:00:50 UTC (rev 1139)
+++ trunk/ChangeLog	2005-11-18 16:52:38 UTC (rev 1140)
@@ -1,3 +1,7 @@
+2005-11-18  Werner Koch  <wk at g10code.com>
+
+	* configure.ac (BUILD_REVISION): New.
+
 2005-11-17  Marcus Brinkmann  <marcus at g10code.de>
 
 	* configure.ac: Add support for --enable-w32-glib (disabled by
@@ -3,4 +7,8 @@
 	default).  Invoke AM_PATH_GLIB_2_0.
 
+2005-11-16  Werner Koch  <wk at g10code.com>
+
+	* configure.ac (CFLAGS) [W32]: Make sure that -mms-bitfields are used.
+
 2005-11-15  Werner Koch  <wk at g10code.com>
 

Modified: trunk/autogen.sh
===================================================================
--- trunk/autogen.sh	2005-11-18 14:00:50 UTC (rev 1139)
+++ trunk/autogen.sh	2005-11-18 16:52:38 UTC (rev 1140)
@@ -76,7 +76,8 @@
     ./configure --enable-maintainer-mode  --prefix=${w32root}  \
             --host=i586-mingw32msvc --build=${build} \
             --with-gpg-error-prefix=${w32root} --without-gpgsm \
-            --enable-shared --enable-static
+            --enable-shared --enable-static --enable-w32-glib \
+            PKG_CONFIG_LIBDIR="$w32root/lib/pkgconfig"
 
     exit $?
 fi

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2005-11-18 14:00:50 UTC (rev 1139)
+++ trunk/configure.ac	2005-11-18 16:52:38 UTC (rev 1140)
@@ -170,6 +170,9 @@
 # Checks for compiler features.
 if test "$GCC" = yes; then
     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
+    if test "$have_w32_system" = yes; then
+       CFLAGS="$CFLAGS -mms-bitfields"
+    fi
 fi
 
 
@@ -449,15 +452,18 @@
 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
 
 # Generate values for the DLL version info
+changequote(,)dnl 
+BUILD_REVISION="`echo '$Revision$' | sed 's/[^0-9]//g'`"
+changequote([,])dnl
+test -z "$BUILD_REVISION" && BUILD_REVISION="0"
 if test "$have_w32_system" = yes; then
     BUILD_TIMESTAMP=`date --iso-8601=minutes`
     changequote(,)dnl 
     BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
-    tmp="`echo '$Revision$' | sed 's/[^0-9]//g'`"
     changequote([,])dnl
-    test -z "$tmp" && tmp="0"
-    BUILD_FILEVERSION="${BUILD_FILEVERSION}$tmp"
+    BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
 fi
+AC_SUBST(BUILD_REVISION)
 AC_SUBST(BUILD_TIMESTAMP)
 AC_SUBST(BUILD_FILEVERSION)
 

Modified: trunk/doc/gpgme.texi
===================================================================
--- trunk/doc/gpgme.texi	2005-11-18 14:00:50 UTC (rev 1139)
+++ trunk/doc/gpgme.texi	2005-11-18 16:52:38 UTC (rev 1140)
@@ -4738,7 +4738,7 @@
 callback functions.  Usually this is done in an event loop, that also
 checks for events in other parts of the program.  If the callback
 functions are only called when the file descriptors are ready,
- at acronym{GPGME} will never block.  This gives the user mroe control
+ at acronym{GPGME} will never block.  This gives the user more control
 over the program flow, and allows to perform other tasks when
 @acronym{GPGME} would block otherwise.
 
@@ -4777,7 +4777,7 @@
 @deftp {Data type} {gpgme_error_t (*gpgme_register_io_cb_t) (@w{void *@var{data}}, @w{int @var{fd}}, @w{int @var{dir}}, @w{gpgme_io_cb_t @var{fnc}}, @w{void *@var{fnc_data}}, @w{void **@var{tag}})}
 @tindex gpgme_register_io_cb_t
 The @code{gpgme_register_io_cb_t} type is the type of functions which can
-be called by @acronym{GPGME} to register an I/O callback funtion
+be called by @acronym{GPGME} to register an I/O callback function
 @var{fnc} for the file descriptor @var{fd} with the user.
 @var{fnc_data} should be passed as the first argument to @var{fnc}
 when the handler is invoked (the second argument should be @var{fd}).

Modified: trunk/gpgme/ChangeLog
===================================================================
--- trunk/gpgme/ChangeLog	2005-11-18 14:00:50 UTC (rev 1139)
+++ trunk/gpgme/ChangeLog	2005-11-18 16:52:38 UTC (rev 1140)
@@ -1,3 +1,12 @@
+2005-11-18  Werner Koch  <wk at g10code.com>
+
+	* w32-glib-io.c: Include glib.h before windows to avoid a symbol
+	shadowing warning.
+	(find_channel): Better use g_io_channel_win32_new_fd instead of
+	the autodetection function g_io_channel_unix_new.
+	(_gpgme_io_select): Rewritten.  It is now a fully working select
+	implementation.
+
 2005-11-18  Marcus Brinkmann  <marcus at g10code.de>
 
 	* priv-io.h (_gpgme_io_fd2str): New prototype.
@@ -12,6 +21,10 @@
 	but we create pseudo fds in a private namespace that designate a
 	handle and potentially a giochannel.
 
+2005-11-18  Werner Koch  <wk at g10code.com>
+
+	* versioninfo.rc.in: Set file version to LT-version + Svn-revision.
+
 2005-11-17  Marcus Brinkmann  <marcus at g10code.de>
 
 	* w32-glib-io.c: New file.

Modified: trunk/gpgme/versioninfo.rc.in
===================================================================
--- trunk/gpgme/versioninfo.rc.in	2005-11-18 14:00:50 UTC (rev 1139)
+++ trunk/gpgme/versioninfo.rc.in	2005-11-18 16:52:38 UTC (rev 1140)
@@ -18,7 +18,7 @@
 
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION @BUILD_FILEVERSION@
+ FILEVERSION @LIBGPGME_LT_CURRENT@, at LIBGPGME_LT_AGE@, at LIBGPGME_LT_REVISION@, at BUILD_REVISION@
  PRODUCTVERSION @BUILD_FILEVERSION@
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
@@ -37,7 +37,7 @@
             VALUE "Comments", "Provided under the terms of the GNU Lesser General Public License.\0"
             VALUE "CompanyName", "g10 Code GmbH\0"
             VALUE "FileDescription", "GPGME - GnuPG Made Easy\0"
-            VALUE "FileVersion", "@VERSION@\0"
+            VALUE "FileVersion", "@LIBGPGME_LT_CURRENT at .@LIBGPGME_LT_AGE at .@LIBGPGME_LT_REVISION at .@BUILD_REVISION@\0"
             VALUE "InternalName", "gpgme\0"
             VALUE "LegalCopyright", "Copyright © 2005 g10 Code GmbH\0"
             VALUE "LegalTrademarks", "\0"

Modified: trunk/gpgme/w32-glib-io.c
===================================================================
--- trunk/gpgme/w32-glib-io.c	2005-11-18 14:00:50 UTC (rev 1139)
+++ trunk/gpgme/w32-glib-io.c	2005-11-18 16:52:38 UTC (rev 1140)
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <glib.h>
 #include <windows.h>
 #include <io.h>
 
@@ -40,7 +41,6 @@
 #include "sema.h"
 #include "debug.h"
 
-#include <glib.h>
 
 
 /* This file is an ugly hack to get GPGME working with glib on Windows
@@ -81,7 +81,7 @@
     return NULL;
 
   if (create && !giochannel_table[fd])
-    giochannel_table[fd] = g_io_channel_unix_new (fd);
+    giochannel_table[fd] = g_io_channel_win32_new_fd (fd);
       
   return giochannel_table[fd];
 }
@@ -515,72 +515,115 @@
 int
 _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
 {
-  int i;
-  int res = 0;
+  int     npollfds;
+  GPollFD *pollfds;
+  int     *pollfds_map; 
+  int i, j;
+  int any, n, count;
+  int timeout = 1000;  /* Use a 1s timeout.  */
   void *dbg_help = NULL;
 
-  /* Use g_io_channel_get_buffer_condition.  This will help with the
-     _gpgme_io_select uses in rungpg.c and wait.c::_gpgme_run_io_cb,
-     but not with the global or private event loop.  The user still
-     must define io cbs for all operations.  */
+  if (nonblock)
+    timeout = 0;
 
-  if (!nonblock)
-    assert (!"Can not provide blocking select on this target.");
+  pollfds = calloc (nfds, sizeof *pollfds);
+  if (!pollfds)
+    return -1;
+  pollfds_map = calloc (nfds, sizeof *pollfds_map);
+  if (!pollfds_map)
+    {
+      free (pollfds);
+      return -1;
+    }
+  npollfds = 0;
 
   DEBUG_BEGIN (dbg_help, 3, "gpgme:select on [ ");
+  any = 0;
   for (i = 0; i < nfds; i++)
     {
       if (fds[i].fd == -1) 
 	continue;
       if (fds[i].frozen)
 	DEBUG_ADD1 (dbg_help, "f%d ", fds[i].fd);
-      else if (fds[i].for_read)
+      else if (fds[i].for_read )
 	{
-	  GIOChannel *chan = find_channel (fds[i].fd, 0);
-	  assert (chan);
-
-	  DEBUG2("channel %p cond %i\n",
-		 chan,
-		 g_io_channel_get_buffer_condition (chan));
-
-	  if (g_io_channel_get_buffer_condition (chan) & G_IO_IN)
-	    {
-	      fds[i].signaled = 1;
-	      res++;
-	    }
-	  DEBUG_ADD1 (dbg_help, "r%d ", fds[i].fd);
+          GIOChannel *chan = find_channel (fds[i].fd, 0);
+          assert (chan);
+          g_io_channel_win32_make_pollfd (chan, G_IO_IN, pollfds + npollfds);
+          pollfds_map[npollfds] = i;
+	  DEBUG_ADD2 (dbg_help, "r%d<%d> ", fds[i].fd, pollfds[npollfds].fd);
+          npollfds++;
+	  any = 1;
         }
       else if (fds[i].for_write)
 	{
-	  GIOChannel *chan = find_channel (fds[i].fd, 0);
-	  assert (chan);
-
-	  if (g_io_channel_get_buffer_condition (chan) & G_IO_OUT)
-	    {
-	      fds[i].signaled = 1;
-	      res++;
-	    }
-	  DEBUG_ADD1 (dbg_help, "w%d ", fds[i].fd);
+          GIOChannel *chan = find_channel (fds[i].fd, 0);
+          assert (chan);
+          g_io_channel_win32_make_pollfd (chan, G_IO_OUT, pollfds + npollfds);
+          pollfds_map[npollfds] = i;
+	  DEBUG_ADD2 (dbg_help, "w%d<%d> ", fds[i].fd, pollfds[npollfds].fd);
+          npollfds++;
+	  any = 1;
         }
-      else
-	fds[i].signaled = 0;
+      fds[i].signaled = 0;
     }
   DEBUG_END (dbg_help, "]"); 
+  if (!any)
+    {
+      count = 0;
+      goto leave;
+    }
 
+
+  count = g_io_channel_win32_poll (pollfds, npollfds, timeout);
+  if (count < 0)
+    {
+      int saved_errno = errno;
+      DEBUG1 ("_gpgme_io_select failed: %s\n", strerror (errno));
+      errno = saved_errno;
+      goto leave;
+    }
+
   DEBUG_BEGIN (dbg_help, 3, "select OK [ ");
   if (DEBUG_ENABLED (dbg_help))
     {
-      for (i = 0; i <= nfds; i++)
+      for (i = 0; i < npollfds; i++)
 	{
-	  if (fds[i].fd == -1 || fds[i].frozen || !fds[i].signaled) 
-	    continue;
-	  else if (fds[i].for_read)
+	  if ((pollfds[i].revents & G_IO_IN))
 	    DEBUG_ADD1 (dbg_help, "r%d ", i);
-	  else if (fds[i].for_write)
-	    DEBUG_ADD1 (dbg_help, "w%d ", i);
+          if ((pollfds[i].revents & G_IO_OUT))
+            DEBUG_ADD1 (dbg_help, "w%d ", i);
         }
       DEBUG_END (dbg_help, "]");
     }
+    
+  /* COUNT is used to stop the lop as soon as possible.  */
+  for (n = count, i = 0; i < npollfds && n; i++)
+    {
+      j = pollfds_map[i];
+      assert (j >= 0 && j < nfds);
+      if (fds[j].fd == -1)
+	;
+      else if (fds[j].for_read)
+	{
+	  if ((pollfds[i].revents & G_IO_IN))
+	    {
+	      fds[j].signaled = 1;
+	      n--;
+            }
+        }
+      else if (fds[j].for_write)
+	{
+	  if ((pollfds[i].revents & G_IO_OUT))
+	    {
+	      fds[j].signaled = 1;
+	      n--;
+            }
+        }
+    }
 
-  return 1;
+leave:
+  free (pollfds);
+  free (pollfds_map);
+  return count;
 }




More information about the Gnupg-commits mailing list