[svn] assuan - r240 - in trunk: . src

svn author wk cvs at cvs.gnupg.org
Wed Jul 4 11:35:23 CEST 2007


Author: wk
Date: 2007-07-04 11:34:54 +0200 (Wed, 04 Jul 2007)
New Revision: 240

Modified:
   trunk/ChangeLog
   trunk/autogen.sh
   trunk/configure.ac
   trunk/src/ChangeLog
   trunk/src/assuan-defs.h
   trunk/src/assuan-handler.c
   trunk/src/assuan-logging.c
Log:
A couple of Changes for Windows


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-06-15 11:05:31 UTC (rev 239)
+++ trunk/ChangeLog	2007-07-04 09:34:54 UTC (rev 240)
@@ -1,3 +1,12 @@
+2007-07-03  Werner Koch  <wk at g10code.com>
+
+	* configure.ac (NETLIBS): Use ws2_32 instead of wsock32.
+
+2007-06-15  Werner Koch  <wk at g10code.com>
+
+	* autogen.sh: Use = and not == in test to be POSIXly correct.
+	Change shell back to /bin/sh.
+
 2007-06-15  Marcus Brinkmann  <marcus at g10code.de>
 
 	* autogen.sh: Require bash.

Modified: trunk/autogen.sh
===================================================================
--- trunk/autogen.sh	2007-06-15 11:05:31 UTC (rev 239)
+++ trunk/autogen.sh	2007-07-04 09:34:54 UTC (rev 240)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 # Run this to generate all the initial makefiles, etc. 
 #
 # Copyright (C) 2003 g10 Code GmbH
@@ -31,7 +31,7 @@
 
 DIE=no
 FORCE=
-if test "$1" == "--force"; then
+if test x"$1" = x"--force"; then
   FORCE=" --force"
   shift
 fi

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2007-06-15 11:05:31 UTC (rev 239)
+++ trunk/configure.ac	2007-07-04 09:34:54 UTC (rev 240)
@@ -154,7 +154,7 @@
 fi
 LIBASSUAN_CONFIG_EXTRA_LIBS=
 if test "$have_w32_system" = yes; then
-  LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS -lwsock32"
+  LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS -lws2_32"
 fi
 if test x"$NETLIBS" != x; then
   LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS $NETLIBS"

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2007-06-15 11:05:31 UTC (rev 239)
+++ trunk/src/ChangeLog	2007-07-04 09:34:54 UTC (rev 240)
@@ -1,3 +1,10 @@
+2007-06-18  Werner Koch  <wk at g10code.com>
+
+	* assuan-logging.c (load_libgpg_error, _assuan_gpg_strerror_r) 
+	(_assuan_gpg_strsource): New.
+	* assuan-handler.c (process_request) [W32]: Use these new
+	functions for human understable error codes.
+
 2007-06-12  Werner Koch  <wk at g10code.com>
 
 	* assuan-io.c (_assuan_simple_read): Hack to allow reading from a

Modified: trunk/src/assuan-defs.h
===================================================================
--- trunk/src/assuan-defs.h	2007-06-15 11:05:31 UTC (rev 239)
+++ trunk/src/assuan-defs.h	2007-07-04 09:34:54 UTC (rev 240)
@@ -261,6 +261,8 @@
 #ifdef HAVE_W32_SYSTEM
 const char *_assuan_w32_strerror (int ec);
 #define w32_strerror(e) _assuan_w32_strerror ((e))
+int _assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen);
+const char *_assuan_gpg_strsource (unsigned int err);
 #endif /*HAVE_W32_SYSTEM*/
 
 

Modified: trunk/src/assuan-handler.c
===================================================================
--- trunk/src/assuan-handler.c	2007-06-15 11:05:31 UTC (rev 239)
+++ trunk/src/assuan-handler.c	2007-07-04 09:34:54 UTC (rev 240)
@@ -509,7 +509,24 @@
         {
           const char *text = ctx->err_no == rc? ctx->err_str:NULL;
 
-#if defined(__GNUC__) && defined(__ELF__)
+#if defined(HAVE_W32_SYSTEM)
+          unsigned int source, code;
+          char ebuf[50];
+          const char *esrc;
+
+          source = ((rc >> 24) & 0xff);
+          code = (rc & 0x00ffffff);
+          if (source
+              && !_assuan_gpg_strerror_r (rc, ebuf, sizeof ebuf)
+              && (esrc=_assuan_gpg_strsource (rc)))
+            {
+              /* Assume this is an libgpg-error. */
+              sprintf (errline, "ERR %d %.50s <%.30s>%s%.100s",
+                       rc, ebuf, esrc,
+                       text? " - ":"", text?text:"");
+            }
+          else
+#elif defined(__GNUC__) && defined(__ELF__)
           /* If we have weak symbol support we try to use the error
              strings from libgpg-error without creating a dependency.
              They are used for debugging purposes only, so there is no
@@ -526,7 +543,7 @@
             __attribute__ ((weak));
           const char *gpg_strsource (unsigned int err)
             __attribute__ ((weak));
-#if !defined(HAVE_W32_SYSTEM) && __GNUC__ < 3
+#if __GNUC__ < 3
 #pragma weak gpg_strerror_r
 #pragma weak gpg_strsource
 #endif

Modified: trunk/src/assuan-logging.c
===================================================================
--- trunk/src/assuan-logging.c	2007-06-15 11:05:31 UTC (rev 239)
+++ trunk/src/assuan-logging.c	2007-07-04 09:34:54 UTC (rev 240)
@@ -1,5 +1,5 @@
 /* assuan-logging.c - Default logging function.
- *	Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ * Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
  *
  * This file is part of Assuan.
  *
@@ -238,4 +238,51 @@
                  strerr, sizeof (strerr)-1, NULL);
   return strerr;    
 }
+
+static int (*my_strerror_r) (unsigned int err, char *buf, size_t buflen);
+static const char * (*my_strsource) (unsigned int err);
+
+static int
+load_libgpg_error (void)
+{
+  /* This code is not race free but suitable for our purpose.  */
+  static volatile int initialized;
+  void *handle;
+
+  if (initialized)
+    return (my_strerror_r && my_strsource)? 0:-1;
+  handle = LoadLibrary ("libgpg-error-0.dll");
+  if (handle)
+    {
+      void *foo, *bar;
+      foo = GetProcAddress (handle, "gpg_strerror_r");
+      bar = GetProcAddress (handle, "gpg_strsource");
+      if (foo && bar)
+        {
+          my_strerror_r = foo;
+          my_strsource = bar;
+        }
+      else
+        CloseHandle (handle);
+    }
+  initialized = 1;
+  return 0;
+}
+
+int
+_assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen)
+{
+  if (load_libgpg_error ())
+    return -1;
+  return my_strerror_r (err, buf, buflen);
+}
+
+
+const char *
+_assuan_gpg_strsource (unsigned int err)
+{
+  if (load_libgpg_error ())
+    return NULL;
+  return my_strsource (err);
+}
 #endif /*HAVE_W32_SYSTEM*/




More information about the Gnupg-commits mailing list