summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2007-07-04 09:34:54 +0000
committerWerner Koch <wk@gnupg.org>2007-07-04 09:34:54 +0000
commit9786fe23fd24159897df32d2b18f184a1f607791 (patch)
treede1a8442c8bda7bfd37bc07f962e5b7b0ec8306e
parent70e2314b4ecf6fe9af0da2692ccbafedbf0c5fab (diff)
downloadlibassuan-9786fe23fd24159897df32d2b18f184a1f607791.tar.gz
A couple of Changes for Windows
-rw-r--r--ChangeLog9
-rwxr-xr-xautogen.sh4
-rw-r--r--configure.ac2
-rw-r--r--src/ChangeLog7
-rw-r--r--src/assuan-defs.h2
-rw-r--r--src/assuan-handler.c21
-rw-r--r--src/assuan-logging.c49
7 files changed, 88 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index f96b72c..ead5369 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-07-03 Werner Koch <wk@g10code.com>
+
+ * configure.ac (NETLIBS): Use ws2_32 instead of wsock32.
+
+2007-06-15 Werner Koch <wk@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@g10code.de>
* autogen.sh: Require bash.
diff --git a/autogen.sh b/autogen.sh
index ba2fb2b..1c53b0d 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -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 @@ check_version () {
DIE=no
FORCE=
-if test "$1" == "--force"; then
+if test x"$1" = x"--force"; then
FORCE=" --force"
shift
fi
diff --git a/configure.ac b/configure.ac
index 64c3cf3..2c6dfb4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,7 +154,7 @@ LIBASSUAN_CONFIG_THREAD_MODULES="pth"
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"
diff --git a/src/ChangeLog b/src/ChangeLog
index 9928072..44f106b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2007-06-18 Werner Koch <wk@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@g10code.com>
* assuan-io.c (_assuan_simple_read): Hack to allow reading from a
diff --git a/src/assuan-defs.h b/src/assuan-defs.h
index 58c30d4..6f47454 100644
--- a/src/assuan-defs.h
+++ b/src/assuan-defs.h
@@ -261,6 +261,8 @@ void _assuan_free (void *p);
#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*/
diff --git a/src/assuan-handler.c b/src/assuan-handler.c
index e7ac426..45a901c 100644
--- a/src/assuan-handler.c
+++ b/src/assuan-handler.c
@@ -509,7 +509,24 @@ process_request (assuan_context_t ctx)
{
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 @@ process_request (assuan_context_t ctx)
__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
diff --git a/src/assuan-logging.c b/src/assuan-logging.c
index cfc3d84..5d4f2bb 100644
--- a/src/assuan-logging.c
+++ b/src/assuan-logging.c
@@ -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 @@ _assuan_w32_strerror (int ec)
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*/