Browse Source

Try not to break windows builds.

pull/33/head
Meeh 11 years ago
parent
commit
bcf10eb979
  1. 14
      i2p.cpp

14
i2p.cpp

@ -2,9 +2,13 @@
#include <thread> #include <thread>
#include <cryptopp/integer.h> #include <cryptopp/integer.h>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#ifndef _WIN32
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#endif
#include "Log.h" #include "Log.h"
#include "base64.h" #include "base64.h"
#include "Transports.h" #include "Transports.h"
@ -16,6 +20,7 @@
#include "HTTPServer.h" #include "HTTPServer.h"
#include "util.h" #include "util.h"
#ifndef _WIN32
void handle_sighup(int n) void handle_sighup(int n)
{ {
if (i2p::util::config::GetArg("daemon", 0) == 1) if (i2p::util::config::GetArg("daemon", 0) == 1)
@ -30,6 +35,7 @@ void handle_sighup(int n)
LogPrint("Reloading config."); LogPrint("Reloading config.");
i2p::util::filesystem::ReadConfigFile(i2p::util::config::mapArgs, i2p::util::config::mapMultiArgs); i2p::util::filesystem::ReadConfigFile(i2p::util::config::mapArgs, i2p::util::config::mapMultiArgs);
} }
#endif
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
@ -46,6 +52,7 @@ int main( int argc, char* argv[] )
LogPrint("data directory: ", i2p::util::filesystem::GetDataDir().string()); LogPrint("data directory: ", i2p::util::filesystem::GetDataDir().string());
i2p::util::filesystem::ReadConfigFile(i2p::util::config::mapArgs, i2p::util::config::mapMultiArgs); i2p::util::filesystem::ReadConfigFile(i2p::util::config::mapArgs, i2p::util::config::mapMultiArgs);
#ifndef _WIN32
struct sigaction sa; struct sigaction sa;
sa.sa_handler = handle_sighup; sa.sa_handler = handle_sighup;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
@ -77,11 +84,16 @@ int main( int argc, char* argv[] )
return -1; return -1;
} }
} }
#endif
if (i2p::util::config::GetArg("-log", 0) == 1) if (i2p::util::config::GetArg("-log", 0) == 1)
{ {
std::string logfile = i2p::util::filesystem::GetDataDir().string(); std::string logfile = i2p::util::filesystem::GetDataDir().string();
#ifndef _WIN32
logfile.append("/debug.log"); logfile.append("/debug.log");
#else
logfile.append("\\debug.log");
#endif
LogPrint("Logging to file enabled."); LogPrint("Logging to file enabled.");
freopen(logfile.c_str(),"a",stdout); freopen(logfile.c_str(),"a",stdout);
} }
@ -102,6 +114,7 @@ int main( int argc, char* argv[] )
int running = 1; int running = 1;
while (running) while (running)
{ {
//TODO Meeh: Find something better to do here.
std::this_thread::sleep_for (std::chrono::seconds(1000)); std::this_thread::sleep_for (std::chrono::seconds(1000));
} }
@ -109,6 +122,7 @@ int main( int argc, char* argv[] )
i2p::transports.Stop (); i2p::transports.Stop ();
i2p::data::netdb.Stop (); i2p::data::netdb.Stop ();
httpServer.Stop (); httpServer.Stop ();
if (i2p::util::config::GetArg("-log", 0) == 1) if (i2p::util::config::GetArg("-log", 0) == 1)
{ {
fclose (stdout); fclose (stdout);

Loading…
Cancel
Save