aboutsummaryrefslogtreecommitdiffstats
path: root/assuan/assuan-logging.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2007-07-04 20:03:39 +0000
committerMarcus Brinkmann <[email protected]>2007-07-04 20:03:39 +0000
commita63c5c013771799432dadec5e2f0aabd48db6af4 (patch)
treefad748a885a93d27c78fa043a87a4ad3753baee3 /assuan/assuan-logging.c
parent2007-07-04 Marcus Brinkmann <[email protected]> (diff)
downloadgpgme-a63c5c013771799432dadec5e2f0aabd48db6af4.tar.gz
gpgme-a63c5c013771799432dadec5e2f0aabd48db6af4.zip
2007-07-04 Marcus Brinkmann <[email protected]>
* assuan/: Update files to 2007-07-04 version of assuan.
Diffstat (limited to '')
-rw-r--r--assuan/assuan-logging.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/assuan/assuan-logging.c b/assuan/assuan-logging.c
index cfc3d846..5d4f2bb1 100644
--- a/assuan/assuan-logging.c
+++ b/assuan/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*/