diff options
author | Werner Koch <wk@gnupg.org> | 2014-08-22 09:26:28 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2014-08-25 16:37:45 +0200 |
commit | 8d57ce619aa49862caeee30181fbbd9c76846554 (patch) | |
tree | ddf93e6b991db0c1ac1c6d2ff9401eb40fcf317e | |
parent | b84c1ee0d637108a74066e0da50cb132273020e9 (diff) | |
download | libgpg-error-8d57ce619aa49862caeee30181fbbd9c76846554.tar.gz |
Fix some minor estream things.
* m4/estream.m4: Check for memrchr.
* src/estream.c (memrchr) [!HAVE_MEMRCHR]: New.
* src/init.c: Include estream.h
(real_init): Init estream.
-rw-r--r-- | m4/estream.m4 | 2 | ||||
-rw-r--r-- | src/estream.c | 26 | ||||
-rw-r--r-- | src/init.c | 24 |
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*/ /* @@ -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*/ |