aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-10-28 02:15:56 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-10-28 02:15:56 +0200
commite268dbeb982d92188c6515b9571b17d864d40ef6 (patch)
tree991f9336177f0b46dba6d14ed7bf348f52be55bd /include
parent4fffc1cd8ccf1c3b1f15b2cb1942daf8cdd556ab (diff)
Fix build for mingw
Diffstat (limited to 'include')
-rw-r--r--include/env.hpp59
-rw-r--r--include/sibs/DirectConnection.hpp4
-rw-r--r--include/sibs/IpAddress.hpp16
3 files changed, 72 insertions, 7 deletions
diff --git a/include/env.hpp b/include/env.hpp
new file mode 100644
index 0000000..57ae068
--- /dev/null
+++ b/include/env.hpp
@@ -0,0 +1,59 @@
+#pragma once
+
+#define OS_FAMILY_WINDOWS 0
+#define OS_FAMILY_POSIX 1
+
+#define OS_TYPE_WINDOWS 0
+#define OS_TYPE_LINUX 1
+
+#if defined(_WIN32) || defined(_WIN64)
+ #if defined(_WIN64)
+ #define SYS_ENV_64BIT
+ #else
+ #define SYS_ENV_32BIT
+ #endif
+ #define OS_FAMILY OS_FAMILY_WINDOWS
+ #define OS_TYPE OS_TYPE_WINDOWS
+
+ #ifndef UNICODE
+ #define UNICODE
+ #endif
+
+ #ifndef _UNICODE
+ #define _UNICODE
+ #endif
+
+ #ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+ #endif
+
+ #include <windows.h>
+#endif
+
+#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined(_POSIX_VERSION)
+ #define OS_FAMILY OS_FAMILY_POSIX
+#endif
+
+#ifdef __linux__
+ #define OS_TYPE OS_TYPE_LINUX
+#endif
+
+#if defined(__GNUC__)
+ #if defined(__x86_64__) || defined(__pc64__)
+ #define SYS_ENV_64BIT
+ #else
+ #define SYS_ENV_32BIT
+ #endif
+#endif
+
+#if !defined(SYS_ENV_32BIT) && !defined(SYS_ENV_64BIT)
+ #error "System is not detected as either 32-bit or 64-bit"
+#endif
+
+#if !defined(OS_FAMILY)
+ #error "System not supported. Only Windows and Posix systems supported right now"
+#endif
+
+#if !defined(OS_TYPE)
+ #error "System not supported. Only Windows and linux systems supported right now"
+#endif
diff --git a/include/sibs/DirectConnection.hpp b/include/sibs/DirectConnection.hpp
index 2137fd2..d96890b 100644
--- a/include/sibs/DirectConnection.hpp
+++ b/include/sibs/DirectConnection.hpp
@@ -25,8 +25,8 @@ namespace sibs
enum class PubSubResult
{
- OK,
- ERROR
+ RESULT_OK,
+ RESULT_ERROR
};
struct DirectConnectionPeer;
diff --git a/include/sibs/IpAddress.hpp b/include/sibs/IpAddress.hpp
index 4403e83..54cb58a 100644
--- a/include/sibs/IpAddress.hpp
+++ b/include/sibs/IpAddress.hpp
@@ -3,12 +3,18 @@
#include <stdexcept>
#include <string>
#include <unordered_map>
-#ifndef WIN32
- #include <arpa/inet.h>
- #include <netdb.h>
+#include "../env.hpp"
+#if OS_FAMILY != OS_FAMILY_WINDOWS
+ #include <arpa/inet.h>
+ #include <netdb.h>
#else
- #include <winsock2.h>
- #include <ws2tcpip.h>
+ #include <winsock2.h>
+ #include <ws2tcpip.h>
+ int inet_pton(int af, const char *src, void *dst);
+ int inet_pton4(const char *src, void *dst);
+ int inet_pton6(const char *src, void *dst);
+ typedef u_short sa_family_t;
+ typedef uint32_t in_addr_t;
#endif
namespace sibs