Changeset 2696


Ignore:
Timestamp:
06/06/2010 16:12:20 (2 years ago)
Author:
chris
Message:

Add support for account numbers greater than 0x7fffffff without wrapping.

Location:
box/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupd/BackupClientContext.cpp

    r2300 r2696  
    4646        const std::string &rHostname, 
    4747        int Port, 
    48         int32_t AccountNumber,  
     48        uint32_t AccountNumber,  
    4949        bool ExtendedLogging, 
    5050        bool ExtendedLogToFile, 
  • box/trunk/bin/bbackupd/BackupClientContext.h

    r2414 r2696  
    4646                const std::string &rHostname, 
    4747                int32_t Port, 
    48                 int32_t AccountNumber,  
     48                uint32_t AccountNumber,  
    4949                bool ExtendedLogging, 
    5050                bool ExtendedLogToFile, 
     
    214214        std::string mHostname; 
    215215        int mPort; 
    216         int32_t mAccountNumber; 
     216        uint32_t mAccountNumber; 
    217217        SocketStreamTLS *mpSocket; 
    218218        BackupProtocolClient *mpConnection; 
  • box/trunk/bin/bbackupd/BackupDaemon.cpp

    r2632 r2696  
    744744                conf.GetKeyValue("StoreHostname"), 
    745745                conf.GetKeyValueInt("StorePort"), 
    746                 conf.GetKeyValueInt("AccountNumber"),  
     746                conf.GetKeyValueUint32("AccountNumber"),  
    747747                conf.GetKeyValueBool("ExtendedLogging"), 
    748748                conf.KeyExists("ExtendedLogFile"), 
  • box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp

    r2302 r2696  
    6666{ 
    6767        ConfigurationVerifyKey("AccountNumber", 
    68                 ConfigTest_Exists | ConfigTest_IsInt), 
     68                ConfigTest_Exists | ConfigTest_IsUint32), 
    6969        ConfigurationVerifyKey("UpdateStoreInterval", 
    7070                ConfigTest_Exists | ConfigTest_IsInt), 
  • box/trunk/lib/common/Configuration.cpp

    r2493 r2696  
    454454        else 
    455455        { 
    456                 long value = ::strtol((i->second).c_str(), NULL, 0 /* C style handling */); 
     456                long value = ::strtol((i->second).c_str(), NULL, 
     457                        0 /* C style handling */); 
    457458                if(value == LONG_MAX || value == LONG_MIN) 
     459                { 
     460                        THROW_EXCEPTION(CommonException, ConfigBadIntValue) 
     461                } 
     462                return (int)value; 
     463        } 
     464} 
     465 
     466 
     467// -------------------------------------------------------------------------- 
     468// 
     469// Function 
     470//              Name:    Configuration::GetKeyValueUint32(const std::string& rKeyName) 
     471//              Purpose: Gets a key value as a 32-bit unsigned integer 
     472//              Created: 2003/07/23 
     473// 
     474// -------------------------------------------------------------------------- 
     475uint32_t Configuration::GetKeyValueUint32(const std::string& rKeyName) const 
     476{ 
     477        std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName)); 
     478         
     479        if(i == mKeys.end()) 
     480        { 
     481                THROW_EXCEPTION(CommonException, ConfigNoKey) 
     482        } 
     483        else 
     484        { 
     485                errno = 0; 
     486                long value = ::strtoul((i->second).c_str(), NULL, 
     487                        0 /* C style handling */); 
     488                if(errno != 0) 
    458489                { 
    459490                        THROW_EXCEPTION(CommonException, ConfigBadIntValue) 
     
    681712                                        } 
    682713                                } 
     714 
     715                                // Check it's a number? 
     716                                if(pvkey->Flags() & ConfigTest_IsUint32) 
     717                                {                                        
     718                                        // Test it... 
     719                                        char *end; 
     720                                        errno = 0; 
     721                                        uint32_t r = ::strtoul(val, &end, 0); 
     722                                        if(errno != 0 || end != (val + rval.size())) 
     723                                        { 
     724                                                // not a good value 
     725                                                ok = false; 
     726                                                rErrorMsg += rLevel + mName + "." + pvkey->Name() + " (key) is not a valid unsigned 32-bit integer.\n"; 
     727                                        } 
     728                                } 
    683729                                 
    684730                                // Check it's a bool? 
  • box/trunk/lib/common/Configuration.h

    r2251 r2696  
    2323        ConfigTest_Exists = 2, 
    2424        ConfigTest_IsInt = 4, 
    25         ConfigTest_MultiValueAllowed = 8, 
    26         ConfigTest_IsBool = 16 
     25        ConfigTest_IsUint32 = 8,  
     26        ConfigTest_MultiValueAllowed = 16, 
     27        ConfigTest_IsBool = 32 
    2728}; 
    2829 
     
    113114        const std::string &GetKeyValue(const std::string& rKeyName) const; 
    114115        int GetKeyValueInt(const std::string& rKeyName) const; 
     116        uint32_t GetKeyValueUint32(const std::string& rKeyName) const; 
    115117        bool GetKeyValueBool(const std::string& rKeyName) const; 
    116118        std::vector<std::string> GetKeyNames() const; 
Note: See TracChangeset for help on using the changeset viewer.