diff --git a/core/src/stored/reserve.cc b/core/src/stored/reserve.cc index ecb46deaed2..78f356c2ad8 100644 --- a/core/src/stored/reserve.cc +++ b/core/src/stored/reserve.cc @@ -305,14 +305,14 @@ bool UseDeviceReserve(JobControlRecord *jcr) } StorageDefinitionMessage::StorageDefinitionMessage() - : is_valid(false) + : is_valid_(false) { return; } bool StorageDefinitionMessage::ParseMessage(const char *msg_in) { - is_valid = false; + is_valid_ = false; bool conversion_ok = false; char msg[600]; /* do not alter original message */ @@ -324,29 +324,33 @@ bool StorageDefinitionMessage::ParseMessage(const char *msg_in) "pool_name=%127s pool_type=%127s append=%d copy=%d stripe=%d\n"; char sn[128], mt[128], pn[128], pt[128]; + int ap, cp, st; conversion_ok = sscanf(msg, use_storage, - sn, mt, pn, pt, &append, &Copy, &Stripe) == 7; + sn, mt, pn, pt, &ap, &cp, &st) == 7; if (conversion_ok) { - StoreName = sn; - media_type = mt; - pool_name = pn; - pool_type = pt; + store_name_ = sn; + media_type_ = mt; + pool_name_ = pn; + pool_type_ = pt; + append_ = ap == 0 ? false : true; + copy_ = cp == 0 ? false : true; + stripe_ = st == 0 ? false : true; } - is_valid = conversion_ok; + is_valid_ = conversion_ok; return conversion_ok; } UseDeviceMessage::UseDeviceMessage() - : is_valid(false) + : is_valid_(false) { return; } bool UseDeviceMessage::ParseMessage(const char *msg_in) { - is_valid = false; + is_valid_ = false; bool conversion_ok = false; char msg[200]; /* do not alter original message */ @@ -358,10 +362,10 @@ bool UseDeviceMessage::ParseMessage(const char *msg_in) conversion_ok = sscanf(msg, use_device, dn) == 1; if (conversion_ok) { - dev_name = dn; + dev_name_ = dn; } - is_valid = conversion_ok; + is_valid_ = conversion_ok; return conversion_ok; } @@ -396,7 +400,7 @@ static bool UseDeviceCmd(JobControlRecord *jcr) if (!ok) { break; } - if (storage_definition_message.append) { + if (storage_definition_message.Append()) { jcr->write_store = dirstore; } else { jcr->read_store = dirstore; @@ -405,11 +409,11 @@ static bool UseDeviceCmd(JobControlRecord *jcr) dirstore->append(store); memset(store, 0, sizeof(DirectorStorage)); store->device = New(alist(10)); - bstrncpy(store->name, storage_definition_message.StoreName.c_str(), sizeof(store->name)); - bstrncpy(store->media_type, storage_definition_message.media_type.c_str(), sizeof(store->media_type)); - bstrncpy(store->pool_name, storage_definition_message.pool_name.c_str(), sizeof(store->pool_name)); - bstrncpy(store->pool_type, storage_definition_message.pool_type.c_str(), sizeof(store->pool_type)); - store->append = storage_definition_message.append; + bstrncpy(store->name, storage_definition_message.StoreName(), sizeof(store->name)); + bstrncpy(store->media_type, storage_definition_message.MediaType(), sizeof(store->media_type)); + bstrncpy(store->pool_name, storage_definition_message.PoolName(), sizeof(store->pool_name)); + bstrncpy(store->pool_type, storage_definition_message.PoolType(), sizeof(store->pool_type)); + store->append = storage_definition_message.Append(); /* * Now get all devices @@ -420,14 +424,14 @@ static bool UseDeviceCmd(JobControlRecord *jcr) if (!ok) { break; } - store->device->append(bstrdup(use_device_message.dev_name.c_str())); + store->device->append(bstrdup(use_device_message.DevName())); } } while (ok && jcr->dir_bsock->recv() >= 0); InitJcrDeviceWaitTimers(jcr); jcr->dcr = New(StorageDaemonDeviceControlRecord); SetupNewDcrDevice(jcr, jcr->dcr, NULL, NULL); - if (storage_definition_message.append) { + if (storage_definition_message.Append()) { jcr->dcr->SetWillWrite(); } @@ -439,8 +443,8 @@ static bool UseDeviceCmd(JobControlRecord *jcr) } if (ok) { - jcr->append = storage_definition_message.append; - strcpy(jcr->dev_name, use_device_message.dev_name.c_str()); + jcr->append = storage_definition_message.Append(); + strcpy(jcr->dev_name, use_device_message.DevName()); return true; } else { UnbashSpaces(jcr->dir_bsock->msg); diff --git a/core/src/stored/reserve.h b/core/src/stored/reserve.h index dcde035a68f..d7bf2b11000 100644 --- a/core/src/stored/reserve.h +++ b/core/src/stored/reserve.h @@ -64,16 +64,24 @@ struct ReserveContext { char VolumeName[MAX_NAME_LENGTH]; /**< Vol name suggested by DIR */ }; -#include class StorageDefinitionMessage { public: StorageDefinitionMessage(); bool ParseMessage(const char *msg); - std::string StoreName, media_type, pool_name, pool_type; - unsigned int append, Copy, Stripe; - bool is_valid; + const char *StoreName() const { return store_name_.c_str(); } + const char *MediaType() const { return media_type_.c_str(); } + const char *PoolName() const { return pool_name_.c_str(); } + const char *PoolType() const { return pool_type_.c_str(); } + bool Append() const { return append_; } + bool Copy() const { return copy_; } + bool Stripe() const { return stripe_; } + +private: + bool is_valid_; + bool append_, copy_, stripe_; + std::string store_name_, media_type_, pool_name_, pool_type_; }; class UseDeviceMessage @@ -81,9 +89,11 @@ class UseDeviceMessage public: UseDeviceMessage(); bool ParseMessage(const char *msg); + const char *DevName() const { return dev_name_.c_str(); } - std::string dev_name; - bool is_valid; +private: + std::string dev_name_; + bool is_valid_; }; DLL_IMP_EXP void InitReservationsLock();