From: Werner Koch Date: Wed, 3 Nov 2010 09:56:27 +0000 (+0000) Subject: More include guards. X-Git-Tag: gpgme-1.3.1~36 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=21eb91ae3a8578b678d71083f4513de67b2e4e0f;p=gpgme.git More include guards. Provide access for Wince. Install dummy sehmap.h --- diff --git a/ChangeLog b/ChangeLog index 13d4125..ce3f2c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-11-03 Werner Koch + + * configure.ac (AC_CHECK_HEADERS): Check for sys/types.h and + sys.stat.h. + 2010-11-02 Werner Koch * configure.ac (AC_CHECK_HEADERS): Check for sys.time.h. diff --git a/configure.ac b/configure.ac index 5850ace..9f36925 100644 --- a/configure.ac +++ b/configure.ac @@ -774,7 +774,7 @@ AC_CHECK_FUNCS(getgid getegid) # Replacement functions. AC_REPLACE_FUNCS(stpcpy) # Check for unistd.h for setenv replacement function. -AC_CHECK_HEADERS([unistd.h sys/time.h]) +AC_CHECK_HEADERS([unistd.h sys/time.h sys/types.h sys/stat.h]) AC_REPLACE_FUNCS(setenv) # Assuan check for descriptor passing. diff --git a/contrib/ChangeLog b/contrib/ChangeLog index 406d107..ccee494 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,7 @@ +2010-11-03 Werner Koch + + * conf-w32ce-msc/build.mk (copy-built-source): Create dummy sehmap.h. + 2010-11-01 Werner Koch * conf-w32ce-msc/config.h: New. diff --git a/contrib/conf-w32ce-msc/build.mk b/contrib/conf-w32ce-msc/build.mk index 4a77a99..70cae83 100755 --- a/contrib/conf-w32ce-msc/build.mk +++ b/contrib/conf-w32ce-msc/build.mk @@ -219,15 +219,21 @@ copy-static-source: cd ../contrib/conf-w32ce-msc ; \ cp -t $(targetsrc)/gpgme/src $(conf_sources) - +# We create a dummy sehmap.h which will be included first due to -I. . +# For some reasons sehmap.h is included by MSC for WindowsCE and +# introduces a macro "leave" which conflicts of our use of "leave" for +# a label (leave and enter are pretty common names for pro- and epilog +# code). copy-built-source: @if [ ! -f ./gpgme.h ]; then \ echo "Please build using ./autogen.sh --build-w32ce first"; \ exit 1; \ fi cp -t $(targetsrc)/gpgme/src $(built_sources) + echo '/* Dummy replacement for useless header. */' \ + > $(targetsrc)/gpgme/src/sehmap.h -copy-source: copy-static-source copy-built-source +copy-source: copy-static-source copy-built-source .c.obj: diff --git a/src/ChangeLog b/src/ChangeLog index 562d297..207647e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2010-11-03 Werner Koch + + * setenv.c: Include string.h due to our strerror replacement. + + * w32-ce.h (access): New macro. + * w32-ce.c (_gpgme_wince_access): New. + (RegQueryValueExA): Change DATA to a void*. + + Guard include of sys/stat.h and sys/types.h. + 2010-11-02 Werner Koch * data-fd.c (read, write, lseek) [W32CE && ! __MINGW32CE__]: New. diff --git a/src/ath.c b/src/ath.c index a303ffc..e5acbda 100644 --- a/src/ath.c +++ b/src/ath.c @@ -33,7 +33,9 @@ # include # endif #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #ifndef HAVE_W32_SYSTEM #include #endif @@ -60,7 +62,6 @@ ath_self (void) } #else # ifdef __linux -#include #include uintptr_t ath_self (void) diff --git a/src/ath.h b/src/ath.h index 8a7a507..424e345 100644 --- a/src/ath.h +++ b/src/ath.h @@ -40,7 +40,9 @@ # include # endif # endif -# include +# ifdef HAVE_SYS_TYPES_H +# include +# endif # include #endif /*!HAVE_W32_SYSTEM*/ diff --git a/src/conversion.c b/src/conversion.c index 9d8f403..e6282fa 100644 --- a/src/conversion.c +++ b/src/conversion.c @@ -25,8 +25,10 @@ #include #include -/* Solaris 8 needs sys/types.h before time.h. */ -#include +#ifdef HAVE_SYS_TYPES_H + /* Solaris 8 needs sys/types.h before time.h. */ +# include +#endif #include #include diff --git a/src/data-compat.c b/src/data-compat.c index 0843ffd..bf61538 100644 --- a/src/data-compat.c +++ b/src/data-compat.c @@ -26,7 +26,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_STAT_H +# include +#endif #include #include "data.h" diff --git a/src/data-fd.c b/src/data-fd.c index 779202e..388b45c 100644 --- a/src/data-fd.c +++ b/src/data-fd.c @@ -25,7 +25,9 @@ #ifdef HAVE_UNISTD_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include "debug.h" #include "data.h" diff --git a/src/data-stream.c b/src/data-stream.c index 34a18d4..0e84065 100644 --- a/src/data-stream.c +++ b/src/data-stream.c @@ -23,7 +23,9 @@ #endif #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include "debug.h" #include "data.h" diff --git a/src/data-user.c b/src/data-user.c index 79e62ba..65065e7 100644 --- a/src/data-user.c +++ b/src/data-user.c @@ -22,7 +22,9 @@ #include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include "debug.h" diff --git a/src/data.h b/src/data.h index 370751d..1257a8d 100644 --- a/src/data.h +++ b/src/data.h @@ -25,7 +25,9 @@ #include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include "gpgme.h" diff --git a/src/debug.c b/src/debug.c index 754c8e1..1d9a40e 100644 --- a/src/debug.c +++ b/src/debug.c @@ -33,9 +33,13 @@ #include #include #ifndef HAVE_DOSISH_SYSTEM +# ifdef HAVE_SYS_TYPES_H # include +# endif +# ifdef HAVE_SYS_STAT_H # include -# include +# endif +# include #endif #include diff --git a/src/engine-assuan.c b/src/engine-assuan.c index e521d6d..dedb8a1 100644 --- a/src/engine-assuan.c +++ b/src/engine-assuan.c @@ -30,7 +30,9 @@ #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_UNISTD_H # include diff --git a/src/engine-g13.c b/src/engine-g13.c index f3119b5..6ba49c4 100644 --- a/src/engine-g13.c +++ b/src/engine-g13.c @@ -25,7 +25,9 @@ #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_UNISTD_H # include diff --git a/src/engine-gpgconf.c b/src/engine-gpgconf.c index cf4df56..990b1b9 100644 --- a/src/engine-gpgconf.c +++ b/src/engine-gpgconf.c @@ -24,7 +24,9 @@ #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_UNISTD_H # include diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 8a9cd89..4b7b5a2 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -26,7 +26,9 @@ #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_UNISTD_H # include diff --git a/src/engine-uiserver.c b/src/engine-uiserver.c index fec7d7d..92f7536 100644 --- a/src/engine-uiserver.c +++ b/src/engine-uiserver.c @@ -29,7 +29,9 @@ #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_UNISTD_H # include diff --git a/src/gpgme-w32spawn.c b/src/gpgme-w32spawn.c index 6f7c609..ccf88a9 100644 --- a/src/gpgme-w32spawn.c +++ b/src/gpgme-w32spawn.c @@ -28,8 +28,12 @@ #include #include #include -#include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif #include #include #include diff --git a/src/keylist.c b/src/keylist.c index f76904b..8f61a26 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -25,8 +25,10 @@ #include #include #include -/* Solaris 8 needs sys/types.h before time.h. */ -#include +#ifdef HAVE_SYS_TYPES_H + /* Solaris 8 needs sys/types.h before time.h. */ +# include +#endif #include #include #include diff --git a/src/memrchr.c b/src/memrchr.c index 21662b1..16ed6ac 100644 --- a/src/memrchr.c +++ b/src/memrchr.c @@ -52,7 +52,9 @@ # define LONG_MAX LONG_MAX_32_BITS #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #undef __memrchr #undef memrchr diff --git a/src/posix-io.c b/src/posix-io.c index 762051e..0278217 100644 --- a/src/posix-io.c +++ b/src/posix-io.c @@ -34,7 +34,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_SYS_UIO_H # include diff --git a/src/posix-sema.c b/src/posix-sema.c index 7ab08df..b1808fd 100644 --- a/src/posix-sema.c +++ b/src/posix-sema.c @@ -35,7 +35,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include "util.h" #include "sema.h" diff --git a/src/priv-io.h b/src/priv-io.h index 2c9d1e7..9c70d22 100644 --- a/src/priv-io.h +++ b/src/priv-io.h @@ -32,7 +32,9 @@ #endif /* For pid_t. */ -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif /* A single file descriptor passed to spawn. For child fds, dup_to diff --git a/src/setenv.c b/src/setenv.c index 5a7e638..d85bec9 100644 --- a/src/setenv.c +++ b/src/setenv.c @@ -20,6 +20,7 @@ # include #endif +#include #include #define __set_errno(ev) (gpg_err_set_errno (ev)) diff --git a/src/util.h b/src/util.h index b7dfbbd..6c2cec6 100644 --- a/src/util.h +++ b/src/util.h @@ -31,7 +31,9 @@ #endif /* For pid_t. */ -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include "gpgme.h" diff --git a/src/w32-ce.c b/src/w32-ce.c index e6c512c..b7dfc38 100644 --- a/src/w32-ce.c +++ b/src/w32-ce.c @@ -290,7 +290,7 @@ RegQueryValueExA (HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, { wchar_t *name; LONG err; - BYTE *data; + void *data; DWORD data_len; DWORD type; @@ -335,8 +335,8 @@ RegQueryValueExA (HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, int data_c_len; /* This is valid since we allocated one more above. */ - data[data_len] = '\0'; - data[data_len + 1] = '\0'; + ((char*)data)[data_len] = '\0'; + ((char*)data)[data_len + 1] = '\0'; data_c = wchar_to_utf8 ((wchar_t*) data); if (!data_c) @@ -445,3 +445,31 @@ SHGetSpecialFolderPathA (HWND hwndOwner, LPSTR lpszPath, int nFolder, lpszPath[MAX_PATH - 1] = '\0'; return result; } + +/* Replacement for the access function. Note that we can't use fopen + here because wince might now allow to have a shared read for an + executable; it is better to to read the file attributes. + + Limitation: Only F_OK is supported. +*/ +int +_gpgme_wince_access (const char *fname, int mode) +{ + DWORD attr; + wchar_t *wfname; + + (void)mode; + + wfname = utf8_to_wchar (fname); + if (!wfname) + return -1; + + attr = GetFileAttributes (wfname); + free (wfname); + if (attr == (DWORD)(-1)) + { + gpg_err_set_errno (ENOENT); + return -1; + } + return 0; +} diff --git a/src/w32-ce.h b/src/w32-ce.h index f34eb1b..2bc34ca 100644 --- a/src/w32-ce.h +++ b/src/w32-ce.h @@ -67,5 +67,9 @@ DWORD GetTempPathA(DWORD,LPSTR); #define SHGetSpecialFolderPathA _gpgme_wince_SHGetSpecialFolderPathA BOOL SHGetSpecialFolderPathA(HWND,LPSTR,int,BOOL); +int _gpgme_wince_access (const char *fname, int mode); +#define access(a,b) _gpgme_wince_access ((a), (b)) + + #endif /* GPGME_W32_CE_H */ diff --git a/src/w32-glib-io.c b/src/w32-glib-io.c index 6b7cd15..5c72f03 100644 --- a/src/w32-glib-io.c +++ b/src/w32-glib-io.c @@ -34,7 +34,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include #include diff --git a/src/w32-io.c b/src/w32-io.c index d7abbf4..6f73203 100644 --- a/src/w32-io.c +++ b/src/w32-io.c @@ -31,7 +31,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include "util.h" diff --git a/src/w32-sema.c b/src/w32-sema.c index 3396104..504e682 100644 --- a/src/w32-sema.c +++ b/src/w32-sema.c @@ -31,7 +31,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include "util.h" diff --git a/src/w32-util.c b/src/w32-util.c index ec2fe50..532f89e 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -32,8 +32,12 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif #ifdef HAVE_UNISTD_H # include #endif @@ -104,7 +108,6 @@ dlclose (void * hd) } #endif /* HAVE_ALLOW_SET_FOREGROUND_WINDOW */ - void _gpgme_allow_set_foreground_window (pid_t pid) { diff --git a/src/wait.c b/src/wait.c index febd5bd..a552b54 100644 --- a/src/wait.c +++ b/src/wait.c @@ -26,7 +26,9 @@ #include #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include "util.h" #include "context.h"