summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2012-01-05 21:41:59 +0000
committerChristian Pointner <equinox@anytun.org>2012-01-05 21:41:59 +0000
commit2019e311b10bc56d0ab99759d7a8a42a85b97dc0 (patch)
tree353324a2cbad16080f3e703dc917bad0f8f5778a /src
parentadded helper scripts for mingw environment (diff)
compiler clean windows checks
Diffstat (limited to 'src')
-rw-r--r--src/anytun.cpp2
-rwxr-xr-xsrc/configure1
-rw-r--r--src/datatypes.h6
-rw-r--r--src/deviceConfig.hpp2
-rw-r--r--src/options.cpp6
-rw-r--r--src/packetSource.cpp2
-rw-r--r--src/signalController.cpp2
-rw-r--r--src/syncServer.cpp2
-rw-r--r--src/sysExec.cpp2
-rw-r--r--src/sysExec.h8
-rw-r--r--src/tunDevice.h12
11 files changed, 25 insertions, 20 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp
index d125ee9..4d367f1 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -50,7 +50,7 @@
#include "authAlgoFactory.h"
#include "keyDerivationFactory.h"
#include "signalController.h"
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
# include "daemonService.h"
#else
# ifdef WIN_SERVICE
diff --git a/src/configure b/src/configure
index 2cb394b..4501704 100755
--- a/src/configure
+++ b/src/configure
@@ -198,6 +198,7 @@ case $TARGET in
rm -f sysExec.hpp
rm -f daemonService.h daemonService.cpp
echo "loading Windows specific TUN Device"
+ CXXFLAGS=$CXXFLAGS' -DMINGW'
LDFLAGS=$LDFLAGS' -static'
;;
*)
diff --git a/src/datatypes.h b/src/datatypes.h
index cc13fb1..d758b66 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -59,10 +59,14 @@ typedef enum { ANY, IPV4_ONLY, IPV6_ONLY } ResolvAddrType;
#ifndef _MSC_VER
#define ATTR_PACKED __attribute__((__packed__))
+#else
+#define ATTR_PACKED
+#endif
+
+#if !defined(_MSC_VER) && !defined(MINGW)
typedef int system_error_t;
#else
#include <windows.h>
-#define ATTR_PACKED
typedef DWORD system_error_t;
#endif
diff --git a/src/deviceConfig.hpp b/src/deviceConfig.hpp
index ede6f34..cf9f530 100644
--- a/src/deviceConfig.hpp
+++ b/src/deviceConfig.hpp
@@ -47,7 +47,7 @@ public:
DeviceConfig(std::string dev_name ,std::string dev_type, std::string ifcfg_addr, uint16_t ifcfg_prefix, uint16_t mtu) {
mtu_ = mtu;
type_ = TYPE_UNDEF;
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
if(dev_type != "") {
if(!dev_type.compare(0,3,"tun")) {
type_ = TYPE_TUN;
diff --git a/src/options.cpp b/src/options.cpp
index 9682873..16f6ee6 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -392,7 +392,7 @@ bool Options::parse(int argc, char* argv[])
#if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
PARSE_INVERSE_BOOL_PARAM("-D","--nodaemonize", daemonize_, NOTHING)
PARSE_SCALAR_PARAM("-u","--username", username_, NOTHING)
PARSE_SCALAR_PARAM("-g","--groupname", groupname_, NOTHING)
@@ -498,7 +498,7 @@ bool Options::parse(int argc, char* argv[])
}
if(log_targets_.empty()) {
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
#if !defined(ANYCONF_OPTIONS)
log_targets_.push_back(std::string("syslog:3,").append(progname_).append(",daemon"));
#else
@@ -573,7 +573,7 @@ void Options::printUsage()
#if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
std::cout << " [-D|--nodaemonize] don't run in background" << std::endl;
std::cout << " [-u|--username] <username> change to this user" << std::endl;
std::cout << " [-g|--groupname] <groupname> change to this group" << std::endl;
diff --git a/src/packetSource.cpp b/src/packetSource.cpp
index bd3590d..6a96d18 100644
--- a/src/packetSource.cpp
+++ b/src/packetSource.cpp
@@ -79,7 +79,7 @@ void UDPPacketSource::onResolve(PacketSourceResolverIt& it)
}
sock.sock_->open(e.protocol());
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
if(e.protocol() == proto::v6()) {
sock.sock_->set_option(boost::asio::ip::v6_only(true));
}
diff --git a/src/signalController.cpp b/src/signalController.cpp
index d0df71c..1731649 100644
--- a/src/signalController.cpp
+++ b/src/signalController.cpp
@@ -62,7 +62,7 @@ int SigErrorHandler(int /*sig*/, const std::string& msg)
}
//use system specific signal handler
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
#include "signalHandler.hpp"
#else
#ifdef WIN_SERVICE
diff --git a/src/syncServer.cpp b/src/syncServer.cpp
index 71052b8..a2406fd 100644
--- a/src/syncServer.cpp
+++ b/src/syncServer.cpp
@@ -64,7 +64,7 @@ void SyncServer::onResolve(SyncTcpConnection::proto::resolver::iterator& it)
}
acceptor.acceptor_->open(e.protocol());
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
if(e.protocol() == boost::asio::ip::tcp::v6()) {
acceptor.acceptor_->set_option(boost::asio::ip::v6_only(true));
}
diff --git a/src/sysExec.cpp b/src/sysExec.cpp
index bf3714d..8db7dc5 100644
--- a/src/sysExec.cpp
+++ b/src/sysExec.cpp
@@ -39,7 +39,7 @@
#include "anytunError.h"
//use system specific sys exec
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
#include "sysExec.hpp"
#else
#include "win32/sysExec.hpp"
diff --git a/src/sysExec.h b/src/sysExec.h
index 7b99638..e2347d0 100644
--- a/src/sysExec.h
+++ b/src/sysExec.h
@@ -59,13 +59,13 @@ private:
std::string script_;
bool closed_;
-#ifdef _MSC_VER
- PROCESS_INFORMATION process_info_;
- DWORD return_code_;
-#else
+#if !defined(_MSC_VER) && !defined(MINGW)
pid_t pid_;
int pipefd_;
int return_code_;
+#else
+ PROCESS_INFORMATION process_info_;
+ DWORD return_code_;
#endif
diff --git a/src/tunDevice.h b/src/tunDevice.h
index 8b2d613..aaf49e8 100644
--- a/src/tunDevice.h
+++ b/src/tunDevice.h
@@ -36,10 +36,10 @@
#include "buffer.h"
#include "deviceConfig.hpp"
#include "threadUtils.hpp"
-#ifdef _MSC_VER
-#include <windows.h>
-#else
+#if !defined(_MSC_VER) && !defined(MINGW)
#include "sysExec.h"
+#else
+#include <windows.h>
#endif
class TunDevice
@@ -56,7 +56,7 @@ public:
device_type_t getType() const { return conf_.type_; }
void waitUntilReady();
const char* getTypeString() const {
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
if(fd_ < 0)
#else
if(handle_ == INVALID_HANDLE_VALUE)
@@ -85,7 +85,7 @@ private:
void do_ifconfig();
int fix_return(int ret, size_t pi_length) const;
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
int fd_;
#else
bool getAdapter(std::string const& dev_name);
@@ -96,7 +96,7 @@ private:
#endif
DeviceConfig conf_;
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(MINGW)
SysExec* sys_exec_;
#endif
bool with_pi_;