aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2010-11-02 16:27:46 +0000
committerWerner Koch <[email protected]>2010-11-02 16:27:46 +0000
commit987993a38d12f6de052683711e673fa6bbbdae86 (patch)
treefd71f8e2a821a54a0f4c0b2243f5ad4c74683c97 /src
parent2010-10-28 Marcus Brinkmann <[email protected]> (diff)
downloadgpgme-987993a38d12f6de052683711e673fa6bbbdae86.tar.gz
gpgme-987993a38d12f6de052683711e673fa6bbbdae86.zip
First take on changes to allow building with MSC for W32CE.
Fixed regression in plain W32 build.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog27
-rw-r--r--src/Makefile.am3
-rw-r--r--src/ath-pthread.c8
-rw-r--r--src/ath.c13
-rw-r--r--src/ath.h4
-rw-r--r--src/data-compat.c4
-rw-r--r--src/data-fd.c4
-rw-r--r--src/data-mem.c4
-rw-r--r--src/data.c4
-rw-r--r--src/debug.c4
-rw-r--r--src/encrypt-sign.c3
-rw-r--r--src/engine-assuan.c4
-rw-r--r--src/engine-g13.c4
-rw-r--r--src/engine-gpg.c4
-rw-r--r--src/engine-gpgconf.c4
-rw-r--r--src/engine-gpgsm.c4
-rw-r--r--src/engine-uiserver.c4
-rw-r--r--src/gpgme.c4
-rw-r--r--src/posix-io.c9
-rw-r--r--src/posix-sema.c8
-rw-r--r--src/priv-io.h3
-rw-r--r--src/ttyname_r.c8
-rw-r--r--src/util.h8
-rw-r--r--src/vfs-create.c1
-rw-r--r--src/w32-ce.c3
-rw-r--r--src/w32-ce.h8
-rw-r--r--src/w32-glib-io.c8
-rw-r--r--src/w32-io.c10
-rw-r--r--src/w32-sema.c5
-rw-r--r--src/w32-util.c18
30 files changed, 151 insertions, 44 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a868d6d9..7c6d4297 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,29 @@
-2010-10-28 Marcus Brinkmann <[email protected]>
+2010-11-02 Werner Koch <[email protected]>
+
+ * w32-io.c (handle_to_fd, fd_tohandle): Add. We need them for W32.
+ * w32-util.c (_WIN32_IE): Define to 0x0400.
+
+ * util.h [W32]: Include windows.h.
+ * w32-sema.c: Do not include windows.h directly.
+ * ath.c (ssize_t, pid_t)[_MSC_VER]: Add new types.
+ * gpgme.c (gpgme_result_ref, gpgme_result_unref): Do not use a
+ void pointer in pointer arithmetic.
+ * w32-util.c: Include util.h prior to ath.h. Don't include
+ windows.h directly.
+ (F_OK): Define if not defined.
+ * w32-ce.c: Include string.h.
+ (RegQueryValueExA): Use WINAPI modifier to match the declaration.
+ * vfs-create.c: Include string.h because under W32CE with MSC we
+ get a warning related to our strerror replacement.
+ * encrypt-sign.c: Include stdlib.h, string.h and errno.h.
+ * priv-io.h [W32CE]: Include w32-ce.h
+ * w32-ce.h: Include winsock2.h and ws2tcpip.h.
+ (_MSV_VER): Remove useless macro.
+ (pid_t): Add typedef.
+
+ Guard all includes of unistd.h and sys/time.h.
+
+2010-10-28 Marcus Brinkmann <[email protected]>
* opassuan.c (gpgme_op_assuan_transact_ext): Fix uninitialized
value use. Reported by Marc Mutz.
diff --git a/src/Makefile.am b/src/Makefile.am
index e557c7bb..ecda9047 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -203,7 +203,8 @@ libgpgme_la_LDFLAGS = $(no_undefined) $(export_symbols) \
$(libgpgme_version_script_cmd) -version-info \
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
libgpgme_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps)
-libgpgme_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ @GPG_ERROR_LIBS@
+libgpgme_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
+ @GPG_ERROR_LIBS@
libgpgme_pthread_la_LDFLAGS = $(no_undefined) $(export_symbols) \
$(libgpgme_version_script_cmd) -version-info \
diff --git a/src/ath-pthread.c b/src/ath-pthread.c
index d6422999..9684afb2 100644
--- a/src/ath-pthread.c
+++ b/src/ath-pthread.c
@@ -24,11 +24,15 @@
#include <stdlib.h>
#include <errno.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#else
-# include <sys/time.h>
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# endif
#endif
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/src/ath.c b/src/ath.c
index 803dedbb..a303ffc2 100644
--- a/src/ath.c
+++ b/src/ath.c
@@ -23,17 +23,26 @@
#endif
#include <assert.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#else
-# include <sys/time.h>
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# endif
#endif
#include <sys/types.h>
#ifndef HAVE_W32_SYSTEM
#include <sys/wait.h>
#endif
+#ifdef _MSC_VER
+ typedef long ssize_t;
+ typedef int pid_t;
+#endif
+
#include "ath.h"
diff --git a/src/ath.h b/src/ath.h
index 26d0cb25..8a7a5072 100644
--- a/src/ath.h
+++ b/src/ath.h
@@ -36,7 +36,9 @@
# ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
# else
-# include <sys/time.h>
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# endif
# endif
# include <sys/types.h>
# include <sys/socket.h>
diff --git a/src/data-compat.c b/src/data-compat.c
index 76d6cd00..0843ffd4 100644
--- a/src/data-compat.c
+++ b/src/data-compat.c
@@ -23,7 +23,9 @@
#endif
#include <errno.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/stat.h>
#include <stdlib.h>
diff --git a/src/data-fd.c b/src/data-fd.c
index 47a0d990..1ada70f7 100644
--- a/src/data-fd.c
+++ b/src/data-fd.c
@@ -22,7 +22,9 @@
#include <config.h>
#endif
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <sys/types.h>
#include "debug.h"
diff --git a/src/data-mem.c b/src/data-mem.c
index 7be72bff..eda695a4 100644
--- a/src/data-mem.c
+++ b/src/data-mem.c
@@ -24,7 +24,9 @@
#include <errno.h>
#include <stdlib.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <assert.h>
#include <string.h>
diff --git a/src/data.c b/src/data.c
index be64ef07..0a629106 100644
--- a/src/data.c
+++ b/src/data.c
@@ -23,7 +23,9 @@
#endif
#include <stdlib.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include <string.h>
diff --git a/src/debug.c b/src/debug.c
index 6faf4aaf..754c8e11 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -26,7 +26,9 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <ctype.h>
#include <errno.h>
#include <time.h>
diff --git a/src/encrypt-sign.c b/src/encrypt-sign.c
index 02af1797..3b862be8 100644
--- a/src/encrypt-sign.c
+++ b/src/encrypt-sign.c
@@ -22,6 +22,9 @@
#if HAVE_CONFIG_H
#include <config.h>
#endif
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
#include "gpgme.h"
#include "debug.h"
diff --git a/src/engine-assuan.c b/src/engine-assuan.c
index 73ece80d..e521d6d6 100644
--- a/src/engine-assuan.c
+++ b/src/engine-assuan.c
@@ -32,7 +32,9 @@
#include <string.h>
#include <sys/types.h>
#include <assert.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
diff --git a/src/engine-g13.c b/src/engine-g13.c
index 8b2af4d7..f3119b5c 100644
--- a/src/engine-g13.c
+++ b/src/engine-g13.c
@@ -27,7 +27,9 @@
#include <string.h>
#include <sys/types.h>
#include <assert.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
diff --git a/src/engine-gpg.c b/src/engine-gpg.c
index da66d4d7..f163f0fd 100644
--- a/src/engine-gpg.c
+++ b/src/engine-gpg.c
@@ -27,7 +27,9 @@
#include <string.h>
#include <assert.h>
#include <errno.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
diff --git a/src/engine-gpgconf.c b/src/engine-gpgconf.c
index d3c47a75..cf4df568 100644
--- a/src/engine-gpgconf.c
+++ b/src/engine-gpgconf.c
@@ -26,7 +26,9 @@
#include <string.h>
#include <sys/types.h>
#include <assert.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <fcntl.h> /* FIXME */
#include <errno.h>
diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c
index 64be281c..8a9cd893 100644
--- a/src/engine-gpgsm.c
+++ b/src/engine-gpgsm.c
@@ -28,7 +28,9 @@
#include <string.h>
#include <sys/types.h>
#include <assert.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
diff --git a/src/engine-uiserver.c b/src/engine-uiserver.c
index 9e910b6f..fec7d7df 100644
--- a/src/engine-uiserver.c
+++ b/src/engine-uiserver.c
@@ -31,7 +31,9 @@
#include <string.h>
#include <sys/types.h>
#include <assert.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <locale.h>
#include <fcntl.h> /* FIXME */
#include <errno.h>
diff --git a/src/gpgme.c b/src/gpgme.c
index b6a518ff..7feb3be9 100644
--- a/src/gpgme.c
+++ b/src/gpgme.c
@@ -211,7 +211,7 @@ gpgme_result_ref (void *result)
if (! result)
return;
- data = result - sizeof (struct ctx_op_data);
+ data = (void*)((char*)result - sizeof (struct ctx_op_data));
assert (data->magic == CTX_OP_DATA_MAGIC);
@@ -229,7 +229,7 @@ gpgme_result_unref (void *result)
if (! result)
return;
- data = result - sizeof (struct ctx_op_data);
+ data = (void*)((char*)result - sizeof (struct ctx_op_data));
assert (data->magic == CTX_OP_DATA_MAGIC);
diff --git a/src/posix-io.c b/src/posix-io.c
index 5c3def03..762051e7 100644
--- a/src/posix-io.c
+++ b/src/posix-io.c
@@ -28,8 +28,12 @@
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
-#include <unistd.h>
-#include <sys/time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/types.h>
#include <sys/wait.h>
#ifdef HAVE_SYS_UIO_H
@@ -37,7 +41,6 @@
#endif
#include <ctype.h>
#include <sys/resource.h>
-#include <unistd.h>
#include "util.h"
#include "priv-io.h"
diff --git a/src/posix-sema.c b/src/posix-sema.c
index 4ec3abb0..7ab08dfd 100644
--- a/src/posix-sema.c
+++ b/src/posix-sema.c
@@ -29,8 +29,12 @@
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
-#include <unistd.h>
-#include <sys/time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/types.h>
#include "util.h"
diff --git a/src/priv-io.h b/src/priv-io.h
index 89c750dd..2c9d1e70 100644
--- a/src/priv-io.h
+++ b/src/priv-io.h
@@ -23,6 +23,9 @@
#define IO_H
#ifdef HAVE_W32_SYSTEM
+# ifdef HAVE_W32CE_SYSTEM
+# include "w32-ce.h"
+# endif
# include <windows.h>
#else
# include <sys/socket.h>
diff --git a/src/ttyname_r.c b/src/ttyname_r.c
index 44876587..810c2175 100644
--- a/src/ttyname_r.c
+++ b/src/ttyname_r.c
@@ -24,10 +24,14 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
-#warning ttyname is not thread-safe, and ttyname_r is missing
+#ifdef __GNUC__
+# warning ttyname is not thread-safe, and ttyname_r is missing
+#endif
int
ttyname_r (int fd, char *buf, size_t buflen)
diff --git a/src/util.h b/src/util.h
index f7e6d276..b7dfbbde 100644
--- a/src/util.h
+++ b/src/util.h
@@ -22,8 +22,12 @@
#ifndef UTIL_H
#define UTIL_H
-#ifdef HAVE_W32CE_SYSTEM
-#include "w32-ce.h"
+#ifdef HAVE_W32_SYSTEM
+# ifdef HAVE_W32CE_SYSTEM
+# include "w32-ce.h"
+# else
+# include "windows.h"
+# endif
#endif
/* For pid_t. */
diff --git a/src/vfs-create.c b/src/vfs-create.c
index 142549a1..d7fd24f1 100644
--- a/src/vfs-create.c
+++ b/src/vfs-create.c
@@ -23,6 +23,7 @@
#endif
#include <stdlib.h>
+#include <string.h>
#include "gpgme.h"
#include "debug.h"
diff --git a/src/w32-ce.c b/src/w32-ce.c
index 57590fa9..076eaae5 100644
--- a/src/w32-ce.c
+++ b/src/w32-ce.c
@@ -22,6 +22,7 @@
#include <config.h>
#endif
+#include <string.h>
#include <errno.h>
#include <assert.h>
@@ -248,7 +249,7 @@ RegOpenKeyExA (HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions,
}
-LONG
+LONG WINAPI
RegQueryValueExA (HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved,
LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData)
{
diff --git a/src/w32-ce.h b/src/w32-ce.h
index 2b761d65..bcd5344c 100644
--- a/src/w32-ce.h
+++ b/src/w32-ce.h
@@ -24,8 +24,12 @@
#include <time.h>
#include <stdarg.h>
-/* For getaddrinfo. */
-#define _MSV_VER 0x401
+#ifdef _MSC_VER
+typedef int pid_t;
+#endif
+
+#include <winsock2.h>
+#include <ws2tcpip.h> /* For getaddrinfo. */
#include <windows.h>
diff --git a/src/w32-glib-io.c b/src/w32-glib-io.c
index ff21c3d8..6b7cd150 100644
--- a/src/w32-glib-io.c
+++ b/src/w32-glib-io.c
@@ -28,8 +28,12 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
-#include <unistd.h>
-#include <sys/time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/types.h>
#include <glib.h>
#include <windows.h>
diff --git a/src/w32-io.c b/src/w32-io.c
index 12d84373..d7abbf4c 100644
--- a/src/w32-io.c
+++ b/src/w32-io.c
@@ -28,11 +28,14 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/types.h>
-#include <windows.h>
#include <io.h>
+#include "util.h"
+
#ifdef HAVE_W32CE_SYSTEM
#include <assuan.h>
#include <winioctl.h>
@@ -42,7 +45,6 @@
CTL_CODE (FILE_DEVICE_STREAMS, 2051, METHOD_BUFFERED, FILE_ANY_ACCESS)
#endif
-#include "util.h"
#include "sema.h"
#include "priv-io.h"
#include "debug.h"
@@ -123,6 +125,8 @@ release_fd (int fd)
#define pid_to_handle(a) ((HANDLE)(a))
#define handle_to_pid(a) ((int)(a))
+#define fd_to_handle(a) ((HANDLE)(a))
+#define handle_to_fd(a) ((int)(a))
#define READBUF_SIZE 4096
#define WRITEBUF_SIZE 4096
diff --git a/src/w32-sema.c b/src/w32-sema.c
index 6a5137dd..33961041 100644
--- a/src/w32-sema.c
+++ b/src/w32-sema.c
@@ -28,9 +28,10 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/types.h>
-#include <windows.h>
#include <io.h>
#include "util.h"
diff --git a/src/w32-util.c b/src/w32-util.c
index e4820c19..cbbc1260 100644
--- a/src/w32-util.c
+++ b/src/w32-util.c
@@ -29,17 +29,22 @@
#include <assert.h>
#include <errno.h>
#include <stdint.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <fcntl.h>
-#include <windows.h>
-#include <shlobj.h>
#include <io.h>
-#include "ath.h"
+#define _WIN32_IE 0x0400 /* Required for SHGetSpecialFolderPathA. */
+
#include "util.h"
+#include <shlobj.h>
+#include "ath.h"
#include "sema.h"
#include "debug.h"
@@ -47,6 +52,9 @@
#ifndef HAVE_W32CE_SYSTEM
#define HAVE_ALLOW_SET_FOREGROUND_WINDOW 1
#endif
+#ifndef F_OK
+# define F_OK 0
+#endif
DEFINE_STATIC_LOCK (get_path_lock);