diff options
author | Martin Ebourne <martin@ebourne.me.uk> | 2005-12-12 20:50:00 +0000 |
---|---|---|
committer | Martin Ebourne <martin@ebourne.me.uk> | 2005-12-12 20:50:00 +0000 |
commit | 3bedf8846f4d7a5cb38276b274662d62a36dcd52 (patch) | |
tree | 9d51de8b0f3d06ba6549a5a1958e52f592343140 /bin/bbackupctl/bbackupctl.cpp | |
parent | 81d8eda2419e7a23088a98cdfc52a305c9ceac0d (diff) |
Marged chris/win32/merge/07-win32-fixes at r210 to trunk
Diffstat (limited to 'bin/bbackupctl/bbackupctl.cpp')
-rwxr-xr-x | bin/bbackupctl/bbackupctl.cpp | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/bin/bbackupctl/bbackupctl.cpp b/bin/bbackupctl/bbackupctl.cpp index 0dc4f98d..d39092e8 100755 --- a/bin/bbackupctl/bbackupctl.cpp +++ b/bin/bbackupctl/bbackupctl.cpp @@ -19,6 +19,10 @@ #include "SocketStream.h" #include "IOStreamGetLine.h" +#ifdef WIN32 + #include "WinNamedPipeStream.h" +#endif + #include "MemLeakFindOn.h" void PrintUsageAndExit() @@ -26,7 +30,8 @@ void PrintUsageAndExit() printf("Usage: bbackupctl [-q] [-c config_file] <command>\n" "Commands are:\n" " sync -- start a syncronisation run now\n" - " force-sync -- force the start of a syncronisation run, even if SyncAllowScript says no\n" + " force-sync -- force the start of a syncronisation run, " + "even if SyncAllowScript says no\n" " reload -- reload daemon configuration\n" " terminate -- terminate daemon now\n" " wait-for-sync -- wait until the next sync starts, then exit\n" @@ -38,7 +43,12 @@ int main(int argc, const char *argv[]) { int returnCode = 0; - MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbackupctl.memleaks", "bbackupctl") +#if defined WIN32 && ! defined NDEBUG + ::openlog("Box Backup (bbackupctl)", 0, 0); +#endif + + MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbackupctl.memleaks", + "bbackupctl") MAINHELPER_START @@ -99,20 +109,35 @@ int main(int argc, const char *argv[]) } // Connect to socket + +#ifndef WIN32 SocketStream connection; +#else /* WIN32 */ + WinNamedPipeStream connection; +#endif /* ! WIN32 */ + try { +#ifdef WIN32 + connection.Connect(BOX_NAMED_PIPE_NAME); +#else connection.Open(Socket::TypeUNIX, conf.GetKeyValue("CommandSocket").c_str()); +#endif } catch(...) { - printf("Failed to connect to daemon control socket.\n" \ - "Possible causes:\n" \ - " * Daemon not running\n" \ - " * Daemon busy syncing with store server\n" \ - " * Another bbackupctl process is communicating with the daemon\n" \ + printf("Failed to connect to daemon control socket.\n" + "Possible causes:\n" + " * Daemon not running\n" + " * Daemon busy syncing with store server\n" + " * Another bbackupctl process is communicating with the daemon\n" " * Daemon is waiting to recover from an error\n" ); + +#if defined WIN32 && ! defined NDEBUG + syslog(LOG_ERR,"Failed to connect to the command socket"); +#endif + return 1; } @@ -123,14 +148,29 @@ int main(int argc, const char *argv[]) std::string configSummary; if(!getLine.GetLine(configSummary)) { +#if defined WIN32 && ! defined NDEBUG + syslog(LOG_ERR, "Failed to receive configuration summary " + "from daemon"); +#else printf("Failed to receive configuration summary from daemon\n"); +#endif + return 1; } // Was the connection rejected by the server? if(getLine.IsEOF()) { - printf("Server rejected the connection. Are you running bbackupctl as the same user as the daemon?\n"); +#if defined WIN32 && ! defined NDEBUG + syslog(LOG_ERR, "Server rejected the connection. " + "Are you running bbackupctl as the same user " + "as the daemon?"); +#else + printf("Server rejected the connection. " + "Are you running bbackupctl as the same user " + "as the daemon?\n"); +#endif + return 1; } @@ -212,6 +252,10 @@ int main(int argc, const char *argv[]) } MAINHELPER_END + +#if defined WIN32 && ! defined NDEBUG + closelog(); +#endif return returnCode; } |