From 83d88d444eef15e128dd4080d6b1978b4d8657c2 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 3 Nov 2010 10:33:10 +0000 Subject: [PATCH] Hopefully last changes for building with MSC. --- src/ChangeLog | 10 +++++++++- src/debug.c | 10 ++++++++++ src/signers.c | 2 +- src/w32-ce.c | 38 +++++++++++++++++++++++++++++++++++--- src/w32-ce.h | 5 +++++ src/w32-util.c | 6 +++--- 6 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 207647e..53de1f5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,10 +1,18 @@ 2010-11-03 Werner Koch + * debug.c (_gpgme_debug) [W32CE]: Replace locatime by GetLocalTime. + + * signers.c (gpgme_signers_clear): Remove useless return. + Reported by Patrick Spendrin. + + * w32-util.c: s/__inline__/GPG_ERR_INLINE/ + * setenv.c: Include string.h due to our strerror replacement. - * w32-ce.h (access): New macro. + * w32-ce.h (access, bsearch): New macros. * w32-ce.c (_gpgme_wince_access): New. (RegQueryValueExA): Change DATA to a void*. + (_gpgme_wince_bsearch): New. Taken from glibc 2.6. Guard include of sys/stat.h and sys/types.h. diff --git a/src/debug.c b/src/debug.c index 1d9a40e..34c5d18 100644 --- a/src/debug.c +++ b/src/debug.c @@ -209,6 +209,15 @@ _gpgme_debug (int level, const char *format, ...) va_start (arg_ptr, format); LOCK (debug_lock); { +#ifdef HAVE_W32CE_SYSTEM + SYSTEMTIME t; + + GetLocalTime (&t); + fprintf (errfp, "GPGME %04d-%02d-%02d %02d:%02d:%02d <0x%04llx> ", + t.wYear, t.wMonth, t.wDay, + t.wHour, t.wMinute, t.wSecond, + (unsigned long long) ath_self ()); +#else struct tm *tp; time_t atime = time (NULL); @@ -217,6 +226,7 @@ _gpgme_debug (int level, const char *format, ...) 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec, (unsigned long long) ath_self ()); +#endif } #ifdef FRAME_NR { diff --git a/src/signers.c b/src/signers.c index 021a878..ae74e81 100644 --- a/src/signers.c +++ b/src/signers.c @@ -57,7 +57,7 @@ void gpgme_signers_clear (gpgme_ctx_t ctx) { TRACE (DEBUG_CTX, "gpgme_signers_clear", ctx); - return _gpgme_signers_clear (ctx); + _gpgme_signers_clear (ctx); } diff --git a/src/w32-ce.c b/src/w32-ce.c index b7dfc38..88a8f31 100644 --- a/src/w32-ce.c +++ b/src/w32-ce.c @@ -1,5 +1,6 @@ /* w32-ce.h Copyright (C) 2010 g10 Code GmbH + Copyright (C) 1991,92,97,2000,02 Free Software Foundation, Inc. This file is part of GPGME. @@ -14,9 +15,8 @@ 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + License along with this program; if not, see . + */ #ifdef HAVE_CONFIG_H #include @@ -473,3 +473,35 @@ _gpgme_wince_access (const char *fname, int mode) } return 0; } + + +/* Perform a binary search for KEY in BASE which has NMEMB elements + of SIZE bytes each. The comparisons are done by (*COMPAR)(). + Code taken from glibc-2.6. */ +void * +_gpgme_wince_bsearch (const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *)) +{ + size_t l, u, idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p); + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} + diff --git a/src/w32-ce.h b/src/w32-ce.h index 2bc34ca..9be361f 100644 --- a/src/w32-ce.h +++ b/src/w32-ce.h @@ -70,6 +70,11 @@ BOOL SHGetSpecialFolderPathA(HWND,LPSTR,int,BOOL); int _gpgme_wince_access (const char *fname, int mode); #define access(a,b) _gpgme_wince_access ((a), (b)) +void *_gpgme_wince_bsearch (const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *)); +#define bsearch(a,b,c,d,e) _gpgme_wince_bsearch ((a),(b),(c),(d),(e)) + #endif /* GPGME_W32_CE_H */ diff --git a/src/w32-util.c b/src/w32-util.c index 532f89e..50052de 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -76,14 +76,14 @@ DEFINE_STATIC_LOCK (get_path_lock); #define RTLD_LAZY 0 -static __inline__ void * +static GPG_ERR_INLINE void * dlopen (const char * name, int flag) { void * hd = LoadLibrary (name); return hd; } -static __inline__ void * +static GPG_ERR_INLINE void * dlsym (void * hd, const char * sym) { if (hd && sym) @@ -96,7 +96,7 @@ dlsym (void * hd, const char * sym) return NULL; } -static __inline__ int +static GPG_ERR_INLINE int dlclose (void * hd) { if (hd) -- 2.26.2