summaryrefslogtreecommitdiff
path: root/bin/bbackupquery
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2008-04-04 22:11:45 +0000
committerChris Wilson <chris+github@qwirx.com>2008-04-04 22:11:45 +0000
commitf2e6283815f4b598f3aa13441f82228370b8d077 (patch)
tree82886fbcbce618878dff2fb2ab6229d91e2f69d1 /bin/bbackupquery
parentd5f9f9c253584cc12cd88c83afd6c6bfcc6ebd68 (diff)
Undo mangling by tailor
Diffstat (limited to 'bin/bbackupquery')
-rw-r--r--bin/bbackupquery/BackupQueries.cpp41
-rw-r--r--bin/bbackupquery/bbackupquery.cpp8
2 files changed, 19 insertions, 30 deletions
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp
index b6984641..0faa4770 100644
--- a/bin/bbackupquery/BackupQueries.cpp
+++ b/bin/bbackupquery/BackupQueries.cpp
@@ -27,6 +27,8 @@
#include <set>
#include <limits>
+#include <iostream>
+#include <ostream>
#include "BackupQueries.h"
#include "Utils.h"
@@ -810,8 +812,8 @@ void BackupQueries::CommandChangeLocalDir(const std::vector<std::string> &args)
}
else
{
- BOX_ERROR("Error changing to directory '" <<
- args[0] << ": " << strerror(errno));
+ BOX_LOG_SYS_ERROR("Failed to change to directory "
+ "'" << args[0] << "'");
}
SetReturnCode(COMMAND_RETURN_ERROR);
@@ -822,8 +824,7 @@ void BackupQueries::CommandChangeLocalDir(const std::vector<std::string> &args)
char wd[PATH_MAX];
if(::getcwd(wd, PATH_MAX) == 0)
{
- BOX_ERROR("Error getting current directory: " <<
- strerror(errno));
+ BOX_LOG_SYS_ERROR("Error getting current directory");
SetReturnCode(COMMAND_RETURN_ERROR);
return;
}
@@ -1399,9 +1400,8 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
}
else
{
- BOX_WARNING("Failed to access local directory '" <<
- localDirDisplay << ": " << strerror(errno) <<
- "'.");
+ BOX_LOG_SYS_WARNING("Failed to access local directory "
+ "'" << localDirDisplay << "'");
rParams.mUncheckedFiles ++;
}
return;
@@ -1449,8 +1449,8 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
DIR *dirhandle = ::opendir(rLocalDir.c_str());
if(dirhandle == 0)
{
- BOX_WARNING("Failed to open local directory '" <<
- localDirDisplay << "': " << strerror(errno));
+ BOX_LOG_SYS_WARNING("Failed to open local directory '" <<
+ localDirDisplay << "'");
rParams.mUncheckedFiles ++;
return;
}
@@ -1518,8 +1518,8 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
// Close directory
if(::closedir(dirhandle) != 0)
{
- BOX_ERROR("Failed to close local directory '" <<
- localDirDisplay << "': " << strerror(errno));
+ BOX_LOG_SYS_ERROR("Failed to close local directory "
+ "'" << localDirDisplay << "'");
}
dirhandle = 0;
@@ -2158,22 +2158,9 @@ void BackupQueries::CommandUsage()
// --------------------------------------------------------------------------
void BackupQueries::CommandUsageDisplayEntry(const char *Name, int64_t Size, int64_t HardLimit, int32_t BlockSize)
{
- // Calculate size in Mb
- double mb = (((double)Size) * ((double)BlockSize)) / ((double)(1024*1024));
- int64_t percent = (Size * 100) / HardLimit;
-
- // Bar graph
- char bar[41];
- unsigned int b = (int)((Size * (sizeof(bar)-1)) / HardLimit);
- if(b > sizeof(bar)-1) {b = sizeof(bar)-1;}
- for(unsigned int l = 0; l < b; l++)
- {
- bar[l] = '*';
- }
- bar[b] = '\0';
-
- // Print the entryj
- ::printf("%14s %10.1fMb %3d%% %s\n", Name, mb, (int32_t)percent, bar);
+ std::cout << FormatUsageLineStart(Name) <<
+ FormatUsageBar(Size, Size * BlockSize, HardLimit * BlockSize) <<
+ std::endl;
}
diff --git a/bin/bbackupquery/bbackupquery.cpp b/bin/bbackupquery/bbackupquery.cpp
index 4b97409f..b38821c1 100644
--- a/bin/bbackupquery/bbackupquery.cpp
+++ b/bin/bbackupquery/bbackupquery.cpp
@@ -174,8 +174,8 @@ int main(int argc, const char *argv[])
logFile = ::fopen(optarg, "w");
if(logFile == 0)
{
- BOX_ERROR("Failed to open log file '" <<
- optarg << "': " << strerror(errno));
+ BOX_LOG_SYS_ERROR("Failed to open log file "
+ "'" << optarg << "'");
}
break;
@@ -260,7 +260,9 @@ int main(int argc, const char *argv[])
// 2. Connect to server
if(!quiet) BOX_INFO("Connecting to store...");
SocketStreamTLS socket;
- socket.Open(tlsContext, Socket::TypeINET, conf.GetKeyValue("StoreHostname").c_str(), BOX_PORT_BBSTORED);
+ socket.Open(tlsContext, Socket::TypeINET,
+ conf.GetKeyValue("StoreHostname").c_str(),
+ conf.GetKeyValueInt("StorePort"));
// 3. Make a protocol, and handshake
if(!quiet) BOX_INFO("Handshake with store...");