summaryrefslogtreecommitdiff
path: root/bin/bbackupctl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bbackupctl')
-rwxr-xr-xbin/bbackupctl/bbackupctl.cpp60
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;
}