summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2011-01-27 20:06:04 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2011-01-27 20:07:24 +0100
commit46be1ca0485fd2e6dcb1b43fb43ffa37e7f3a3f7 (patch)
tree7ed22bea80102a28790f040ab5703740889f21c5
parent4c15c608bda5c866e4c383ca7667d8c6fca5236f (diff)
common: fix windows build
-rw-r--r--common/mem.h23
-rw-r--r--common/ssl_verify.c19
2 files changed, 40 insertions, 2 deletions
diff --git a/common/mem.h b/common/mem.h
index 5f0eb25..6863953 100644
--- a/common/mem.h
+++ b/common/mem.h
@@ -22,6 +22,29 @@
#include <stdlib.h>
#include <spice/macros.h>
+/* alloca definition from glib/galloca.h */
+#ifdef __GNUC__
+/* GCC does the right thing */
+# undef alloca
+# define alloca(size) __builtin_alloca (size)
+#elif defined (GLIB_HAVE_ALLOCA_H)
+/* a native and working alloca.h is there */
+# include <alloca.h>
+#else /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */
+# if defined(_MSC_VER) || defined(__DMC__)
+# include <malloc.h>
+# define alloca _alloca
+# else /* !_MSC_VER && !__DMC__ */
+# ifdef _AIX
+# pragma alloca
+# else /* !_AIX */
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+# endif /* !alloca */
+# endif /* !_AIX */
+# endif /* !_MSC_VER && !__DMC__ */
+#endif /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */
+
typedef struct SpiceChunk {
uint8_t *data;
uint32_t len;
diff --git a/common/ssl_verify.c b/common/ssl_verify.c
index f7d9482..a84afaf 100644
--- a/common/ssl_verify.c
+++ b/common/ssl_verify.c
@@ -19,13 +19,28 @@
#include "mem.h"
#include "ssl_verify.h"
-#include <alloca.h>
+#ifndef WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#endif
+#include <ctype.h>
#ifndef SPICE_DEBUG
-# define SPICE_DEBUG(format, ...) printf("%s: " format "\n", __FUNCTION__, ## __VA_ARGS__)
+# define SPICE_DEBUG(format, ...)
+#endif
+
+#ifdef WIN32
+static int inet_aton(const char* ip, struct in_addr* in_addr)
+{
+ unsigned long addr = inet_addr(ip);
+
+ if (addr == INADDR_NONE) {
+ return 0;
+ }
+ in_addr->S_un.S_addr = addr;
+ return 1;
+}
#endif
static int verify_pubkey(X509* cert, const char *key, size_t key_size)