summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/anytun.cpp16
-rw-r--r--src/log.cpp13
2 files changed, 18 insertions, 11 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp
index c4339dc..189385f 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -344,6 +344,14 @@ int main(int argc, char* argv[])
}
}
+#ifndef NOCRYPT
+#ifndef USE_SSL_CRYPTO
+// this must be called before any other libgcrypt call
+ if(!initLibGCrypt())
+ return -1;
+#endif
+#endif
+
TunDevice dev(gOpt.getDevName(), gOpt.getDevType(), gOpt.getIfconfigParamLocal(), gOpt.getIfconfigParamRemoteNetmask());
cLog.msg(Log::PRIO_NOTICE) << "dev created (opened)";
cLog.msg(Log::PRIO_NOTICE) << "dev opened - actual name is '" << dev.getActualName() << "'";
@@ -415,14 +423,6 @@ int main(int argc, char* argv[])
OptionConnectTo* connTo = new OptionConnectTo();
ThreadParam p(dev, *src, *connTo);
-#ifndef NOCRYPT
-#ifndef USE_SSL_CRYPTO
-// this must be called before any other libgcrypt call
- if(!initLibGCrypt())
- return -1;
-#endif
-#endif
-
boost::thread senderThread(boost::bind(sender,&p));
#ifndef NOSIGNALCONTROLLER
boost::thread receiverThread(boost::bind(receiver,&p));
diff --git a/src/log.cpp b/src/log.cpp
index 3fb569c..2fa603e 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -57,9 +57,16 @@ std::ostream& operator<<(std::ostream& stream, LogErrno const& value)
{
char buf[STERROR_TEXT_MAX];
buf[0] = 0;
-// TODO: fix to use XSI Compliant strerror_r
- char* tmp = strerror_r(value.err_, buf, STERROR_TEXT_MAX);
- return stream << tmp;
+ char* errStr;
+// this really sucks, g++ seems to unconditionally define _GNU_SOURCE
+// and undefining it breaks the build...
+#ifdef _GNU_SOURCE
+ errStr = strerror_r(value.err_, buf, STERROR_TEXT_MAX);
+#else
+ strerror_r(value.err_, buf, STERROR_TEXT_MAX);
+ errStr = buf;
+#endif
+ return stream << errStr;
}
LogStringBuilder::LogStringBuilder(LogStringBuilder const& src) : log(src.log), prio(src.prio)