summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/bbackupd/BackupClientContext.cpp2
-rw-r--r--bin/bbackupd/BackupClientContext.h4
-rw-r--r--bin/bbackupd/BackupDaemon.cpp2
-rw-r--r--lib/backupclient/BackupDaemonConfigVerify.cpp2
-rw-r--r--lib/common/Configuration.cpp48
-rw-r--r--lib/common/Configuration.h6
6 files changed, 56 insertions, 8 deletions
diff --git a/bin/bbackupd/BackupClientContext.cpp b/bin/bbackupd/BackupClientContext.cpp
index b978f54c..6b51b9e8 100644
--- a/bin/bbackupd/BackupClientContext.cpp
+++ b/bin/bbackupd/BackupClientContext.cpp
@@ -45,7 +45,7 @@ BackupClientContext::BackupClientContext
TLSContext &rTLSContext,
const std::string &rHostname,
int Port,
- int32_t AccountNumber,
+ uint32_t AccountNumber,
bool ExtendedLogging,
bool ExtendedLogToFile,
std::string ExtendedLogFile,
diff --git a/bin/bbackupd/BackupClientContext.h b/bin/bbackupd/BackupClientContext.h
index 4665df2b..404d2d77 100644
--- a/bin/bbackupd/BackupClientContext.h
+++ b/bin/bbackupd/BackupClientContext.h
@@ -45,7 +45,7 @@ public:
TLSContext &rTLSContext,
const std::string &rHostname,
int32_t Port,
- int32_t AccountNumber,
+ uint32_t AccountNumber,
bool ExtendedLogging,
bool ExtendedLogToFile,
std::string ExtendedLogFile,
@@ -213,7 +213,7 @@ private:
TLSContext &mrTLSContext;
std::string mHostname;
int mPort;
- int32_t mAccountNumber;
+ uint32_t mAccountNumber;
SocketStreamTLS *mpSocket;
BackupProtocolClient *mpConnection;
bool mExtendedLogging;
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp
index c02cb031..e0063494 100644
--- a/bin/bbackupd/BackupDaemon.cpp
+++ b/bin/bbackupd/BackupDaemon.cpp
@@ -743,7 +743,7 @@ void BackupDaemon::RunSyncNow()
mTlsContext,
conf.GetKeyValue("StoreHostname"),
conf.GetKeyValueInt("StorePort"),
- conf.GetKeyValueInt("AccountNumber"),
+ conf.GetKeyValueUint32("AccountNumber"),
conf.GetKeyValueBool("ExtendedLogging"),
conf.KeyExists("ExtendedLogFile"),
extendedLogFile, *mpProgressNotifier
diff --git a/lib/backupclient/BackupDaemonConfigVerify.cpp b/lib/backupclient/BackupDaemonConfigVerify.cpp
index e70ba865..dfef5b03 100644
--- a/lib/backupclient/BackupDaemonConfigVerify.cpp
+++ b/lib/backupclient/BackupDaemonConfigVerify.cpp
@@ -65,7 +65,7 @@ static const ConfigurationVerify verifyserver[] =
static const ConfigurationVerifyKey verifyrootkeys[] =
{
ConfigurationVerifyKey("AccountNumber",
- ConfigTest_Exists | ConfigTest_IsInt),
+ ConfigTest_Exists | ConfigTest_IsUint32),
ConfigurationVerifyKey("UpdateStoreInterval",
ConfigTest_Exists | ConfigTest_IsInt),
ConfigurationVerifyKey("MinimumFileAge",
diff --git a/lib/common/Configuration.cpp b/lib/common/Configuration.cpp
index 2eb5fbca..f49f3c6e 100644
--- a/lib/common/Configuration.cpp
+++ b/lib/common/Configuration.cpp
@@ -453,7 +453,8 @@ int Configuration::GetKeyValueInt(const std::string& rKeyName) const
}
else
{
- long value = ::strtol((i->second).c_str(), NULL, 0 /* C style handling */);
+ long value = ::strtol((i->second).c_str(), NULL,
+ 0 /* C style handling */);
if(value == LONG_MAX || value == LONG_MIN)
{
THROW_EXCEPTION(CommonException, ConfigBadIntValue)
@@ -466,6 +467,36 @@ int Configuration::GetKeyValueInt(const std::string& rKeyName) const
// --------------------------------------------------------------------------
//
// Function
+// Name: Configuration::GetKeyValueUint32(const std::string& rKeyName)
+// Purpose: Gets a key value as a 32-bit unsigned integer
+// Created: 2003/07/23
+//
+// --------------------------------------------------------------------------
+uint32_t Configuration::GetKeyValueUint32(const std::string& rKeyName) const
+{
+ std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName));
+
+ if(i == mKeys.end())
+ {
+ THROW_EXCEPTION(CommonException, ConfigNoKey)
+ }
+ else
+ {
+ errno = 0;
+ long value = ::strtoul((i->second).c_str(), NULL,
+ 0 /* C style handling */);
+ if(errno != 0)
+ {
+ THROW_EXCEPTION(CommonException, ConfigBadIntValue)
+ }
+ return (int)value;
+ }
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Function
// Name: Configuration::GetKeyValueBool(const std::string&)
// Purpose: Gets a key value as a boolean
// Created: 17/2/04
@@ -680,6 +711,21 @@ bool Configuration::Verify(const ConfigurationVerify &rVerify,
rErrorMsg += rLevel + mName + "." + pvkey->Name() + " (key) is not a valid integer.\n";
}
}
+
+ // Check it's a number?
+ if(pvkey->Flags() & ConfigTest_IsUint32)
+ {
+ // Test it...
+ char *end;
+ errno = 0;
+ uint32_t r = ::strtoul(val, &end, 0);
+ if(errno != 0 || end != (val + rval.size()))
+ {
+ // not a good value
+ ok = false;
+ rErrorMsg += rLevel + mName + "." + pvkey->Name() + " (key) is not a valid unsigned 32-bit integer.\n";
+ }
+ }
// Check it's a bool?
if((pvkey->Flags() & ConfigTest_IsBool) == ConfigTest_IsBool)
diff --git a/lib/common/Configuration.h b/lib/common/Configuration.h
index 2babd753..4828b315 100644
--- a/lib/common/Configuration.h
+++ b/lib/common/Configuration.h
@@ -22,8 +22,9 @@ enum
ConfigTest_LastEntry = 1,
ConfigTest_Exists = 2,
ConfigTest_IsInt = 4,
- ConfigTest_MultiValueAllowed = 8,
- ConfigTest_IsBool = 16
+ ConfigTest_IsUint32 = 8,
+ ConfigTest_MultiValueAllowed = 16,
+ ConfigTest_IsBool = 32
};
class ConfigurationVerifyKey
@@ -112,6 +113,7 @@ public:
bool KeyExists(const std::string& rKeyName) const;
const std::string &GetKeyValue(const std::string& rKeyName) const;
int GetKeyValueInt(const std::string& rKeyName) const;
+ uint32_t GetKeyValueUint32(const std::string& rKeyName) const;
bool GetKeyValueBool(const std::string& rKeyName) const;
std::vector<std::string> GetKeyNames() const;