diff options
author | Nader Morshed <morshed.nader@gmail.com> | 2011-11-30 15:36:51 -0500 |
---|---|---|
committer | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2011-11-30 15:36:51 -0500 |
commit | 1fe527bef1f52b96cbbd755db8bbcab93bed49f8 (patch) | |
tree | e6a14a4d48b0c4056e54ae9e9a8c921cc7ef882c /stun | |
parent | 1b44dca9978bfded1c34e8c33d5bd242c070d80e (diff) | |
download | libnice-1fe527bef1f52b96cbbd755db8bbcab93bed49f8.tar.gz |
Add support for windows's compilation through MinGW
Diffstat (limited to 'stun')
-rw-r--r-- | stun/Makefile.am | 4 | ||||
-rw-r--r-- | stun/rand.c | 5 | ||||
-rw-r--r-- | stun/tools/Makefile.am | 4 | ||||
-rw-r--r-- | stun/tools/stunbdc.c | 14 | ||||
-rw-r--r-- | stun/tools/stund.c | 2 | ||||
-rw-r--r-- | stun/usages/bind.c | 4 | ||||
-rw-r--r-- | stun/usages/bind.h | 2 | ||||
-rw-r--r-- | stun/usages/turn.h | 2 | ||||
-rw-r--r-- | stun/win32_common.h | 3 |
9 files changed, 25 insertions, 15 deletions
diff --git a/stun/Makefile.am b/stun/Makefile.am index 0059187..7601964 100644 --- a/stun/Makefile.am +++ b/stun/Makefile.am @@ -13,6 +13,10 @@ include $(top_srcdir)/common.mk AM_CFLAGS = -std=gnu99 -DG_LOG_DOMAIN=\"libnice-stun\" $(ERROR_CFLAGS) AM_CPPFLAGS = -I$(top_srcdir) +if WINDOWS + AM_CFLAGS += -DWINVER=0x0501 # _WIN32_WINNT_WINXP +endif + noinst_LTLIBRARIES = libstun.la libstun_la_SOURCES = constants.h \ diff --git a/stun/rand.c b/stun/rand.c index a17e29d..964bb68 100644 --- a/stun/rand.c +++ b/stun/rand.c @@ -43,6 +43,7 @@ #ifdef _WIN32 #include <windows.h> +#include <Wincrypt.h> void RAND_bytes (uint8_t *dst, int len) { @@ -51,7 +52,9 @@ void RAND_bytes (uint8_t *dst, int len) if(!CryptAcquireContext(&hCryptProv, container, NULL, PROV_RSA_FULL, 0)) { /* non existing container. try to create a new one */ - if (GetLastError() == NTE_BAD_KEYSET) { + // I hope this cast here doesn't cause issues + // gcc was complaining about comparing signed and unsigned values + if (GetLastError() == (DWORD) NTE_BAD_KEYSET) { if(!CryptAcquireContext(&hCryptProv, container, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) { return; } diff --git a/stun/tools/Makefile.am b/stun/tools/Makefile.am index 48fc0a5..42b3108 100644 --- a/stun/tools/Makefile.am +++ b/stun/tools/Makefile.am @@ -23,3 +23,7 @@ stunbdc_SOURCES = stunbdc.c stunbdc_LDADD = $(top_builddir)/stun/libstun.la +if WINDOWS + AM_CFLAGS += -DWINVER=0x0501 # _WIN32_WINNT_WINXP + stunbdc_LDADD += -lws2_32 +endif diff --git a/stun/tools/stunbdc.c b/stun/tools/stunbdc.c index c39f3f4..b539ab9 100644 --- a/stun/tools/stunbdc.c +++ b/stun/tools/stunbdc.c @@ -40,9 +40,12 @@ # include <config.h> #endif -#ifndef _WIN32 -#include <sys/socket.h> -#include <netdb.h> +#ifdef _WIN32 +# include <winsock2.h> +#else +# include <sys/socket.h> +# include <netdb.h> +#endif #include <sys/types.h> #include "stun/stunagent.h" @@ -184,8 +187,3 @@ int main (int argc, char *argv[]) return run (family, server, port) ? 1 : 0; } -#else -int main () { - return 0; -} -#endif diff --git a/stun/tools/stund.c b/stun/tools/stund.c index 86f72cc..8498318 100644 --- a/stun/tools/stund.c +++ b/stun/tools/stund.c @@ -346,7 +346,7 @@ int main (int argc, char *argv[]) } #else -int main () { +int main (int argc, char **argv) { return 0; } #endif diff --git a/stun/usages/bind.c b/stun/usages/bind.c index fc9ed51..34302e1 100644 --- a/stun/usages/bind.c +++ b/stun/usages/bind.c @@ -54,6 +54,7 @@ #include <unistd.h> #include <errno.h> #include <sys/time.h> +#include <fcntl.h> #endif @@ -70,7 +71,6 @@ #include <stdlib.h> #include <time.h> #include <errno.h> -#include <fcntl.h> #include "timer.h" @@ -394,11 +394,13 @@ stun_trans_recv (StunTransport *tr, uint8_t *buf, size_t maxlen) } +#ifdef HAVE_POLL static int stun_trans_fd (const StunTransport *tr) { assert (tr != NULL); return tr->fd; } +#endif /* diff --git a/stun/usages/bind.h b/stun/usages/bind.h index 30175ec..a8d72fa 100644 --- a/stun/usages/bind.h +++ b/stun/usages/bind.h @@ -52,7 +52,7 @@ #ifdef _WIN32 -#include "win32_common.h" +# include "../win32_common.h" #else # include <stdbool.h> # include <stdint.h> diff --git a/stun/usages/turn.h b/stun/usages/turn.h index def7501..68f0fab 100644 --- a/stun/usages/turn.h +++ b/stun/usages/turn.h @@ -53,7 +53,7 @@ #ifdef _WIN32 -#include "win32_common.h" +# include "../win32_common.h" #else # include <stdbool.h> # include <stdint.h> diff --git a/stun/win32_common.h b/stun/win32_common.h index 2797eba..cfb862d 100644 --- a/stun/win32_common.h +++ b/stun/win32_common.h @@ -57,6 +57,7 @@ #ifndef _WIN32_COMMON_H #define _WIN32_COMMON_H +#include <sys/types.h> /* 7.18.1.1 Exact-width integer types */ typedef signed char int8_t; @@ -67,8 +68,6 @@ typedef int int32_t; typedef unsigned uint32_t; typedef long long int64_t; typedef unsigned long long uint64_t; -typedef unsigned int size_t; -typedef unsigned long ssize_t; typedef uint8_t bool; #define true 1 |