summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--m4/estream.m42
-rw-r--r--src/estream.c26
-rw-r--r--src/init.c24
3 files changed, 30 insertions, 22 deletions
diff --git a/m4/estream.m4 b/m4/estream.m4
index 92ddead..402ef74 100644
--- a/m4/estream.m4
+++ b/m4/estream.m4
@@ -45,5 +45,5 @@ AC_DEFUN([estream_INIT],
[
AC_REQUIRE([estream_PRINTF_INIT])
AC_MSG_NOTICE([checking system features for estream])
-
+ AC_CHECK_FUNCS([memrchr])
])
diff --git a/src/estream.c b/src/estream.c
index 8476f8b..e7a81e8 100644
--- a/src/estream.c
+++ b/src/estream.c
@@ -103,16 +103,8 @@
# include "../common/util.h"
#endif
-#ifndef HAVE_MKSTEMP
-int mkstemp (char *template);
-#endif
-
-#ifndef HAVE_MEMRCHR
-void *memrchr (const void *block, int c, size_t size);
-#endif
-
-#include <estream.h>
-#include <estream-printf.h>
+#include "estream.h"
+#include "estream-printf.h"
@@ -340,6 +332,20 @@ map_w32_to_errno (DWORD w32_err)
}
#endif /*HAVE_W32_SYSTEM*/
+/* Replacement fucntions. */
+
+#ifndef HAVE_MEMRCHR
+static void *
+memrchr (const void *buffer, int c, size_t n)
+{
+ const unsigned char *p = buffer;
+
+ for (p += n; n ; n--)
+ if (*--p == c)
+ return (void *)p;
+ return NULL;
+}
+#endif /*HAVE_MEMRCHR*/
/*
diff --git a/src/init.c b/src/init.c
index d4282ac..40fa2a8 100644
--- a/src/init.c
+++ b/src/init.c
@@ -7,12 +7,12 @@
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.
-
+
libgpg-error 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 <http://www.gnu.org/licenses/>.
*/
@@ -29,6 +29,7 @@
#include <gpg-error.h>
#include "gettext.h"
+#include "estream.h"
#include "init.h"
#ifdef HAVE_W32CE_SYSTEM
@@ -49,7 +50,7 @@
#include <windows.h>
-static int tls_index = TLS_OUT_OF_INDEXES; /* Index for the TLS functions. */
+static int tls_index = TLS_OUT_OF_INDEXES; /* Index for the TLS functions. */
static char *get_locale_dir (void);
static void drop_locale_dir (char *locale_dir);
@@ -76,6 +77,7 @@ real_init (void)
drop_locale_dir (locale_dir);
}
#endif
+ _gpgrt_es_init ();
}
/* Initialize the library. This function should be run early. */
@@ -127,7 +129,7 @@ gpg_err_deinit (int mode)
{
#if defined (HAVE_W32_SYSTEM) && !defined(DLL_EXPORT)
struct tls_space_s *tls;
-
+
tls = TlsGetValue (tls_index);
if (tls)
{
@@ -226,7 +228,7 @@ get_locale_dir (void)
nbytes = WideCharToMultiByte (CP_UTF8, 0, moddir, -1, NULL, 0, NULL, NULL);
if (nbytes < 0)
return NULL;
-
+
result = malloc (nbytes + strlen (SLDIR) + 1);
if (result)
{
@@ -275,8 +277,8 @@ get_locale_dir (void)
strcpy (result, "c:\\gnupg");
strcat (result, SLDIR);
}
- }
-#undef SLDIR
+ }
+#undef SLDIR
return result;
}
@@ -309,7 +311,7 @@ get_tls (void)
tls->gt_use_utf8 = 0;
TlsSetValue (tls_index, tls);
}
-
+
return tls;
}
@@ -357,7 +359,7 @@ _gpg_w32ce_strerror (int err)
if (n < 0)
snprintf (tls->strerror_buffer, sizeof tls->strerror_buffer -1,
"[w32err=%d]", err);
- return tls->strerror_buffer;
+ return tls->strerror_buffer;
}
#endif /*HAVE_W32CE_SYSTEM*/
@@ -386,7 +388,7 @@ DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
case DLL_PROCESS_ATTACH:
tls_index = TlsAlloc ();
if (tls_index == TLS_OUT_OF_INDEXES)
- return FALSE;
+ return FALSE;
#ifndef _GPG_ERR_HAVE_CONSTRUCTOR
/* If we have not constructors (e.g. MSC) we call it here. */
_gpg_w32__init_gettext_module ();
@@ -420,7 +422,7 @@ DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
default:
break;
}
-
+
return TRUE;
}
#endif /*DLL_EXPORT*/