string cur_conf;
list<string> confs;
for (auto c : s) {
- switch (c) {
- case '{':
- ++level;
- break;
- case '}':
- --level;
- break;
- case ',':
- if (level == 0) {
- confs.push_back(cur_conf);
- }
- cur_conf.clear();
- break;
- default:
- cur_conf += c;
- break;
- };
+ if (c == ',') {
+ if (level == 0) {
+ confs.push_back(cur_conf);
+ }
+ cur_conf.clear();
+ continue;
+ }
+ if (c == '{') {
+ ++level;
+ } else if (c == '}') {
+ --level;
+ }
+ cur_conf += c;
}
if (!cur_conf.empty()) {
confs.push_back(cur_conf);
for (auto c : confs) {
ssize_t pos = c.find("=");
if (pos < 0) {
- out[""] = c;
+ out[c] = "";
} else {
out[c.substr(0, pos)] = c.substr(pos + 1);
}
}
string *ptier_type = (tier_type_specified ? &tier_type : nullptr);
+
for (auto a : tier_config_add) {
int r = zone.tier_config.set(a.first, a.second);
if (r < 0) {
if (tier_config_add.size() > 0) {
for (auto add : tier_config_add) {
- zone.tier_config.set(add.first, add.second);
+ int r = zone.tier_config.set(add.first, add.second);
+ if (r < 0) {
+ cerr << "ERROR: failed to set configurable: " << add << std::endl;
+ return EINVAL;
+ }
}
need_zone_update = true;
}
- if (tier_config_rm.size() > 0) {
- for (auto rm : tier_config_rm) {
+ for (auto rm : tier_config_rm) {
+ if (!rm.first.empty()) { /* otherwise will remove the entire config */
zone.tier_config.erase(rm.first);
+ need_zone_update = true;
}
- need_zone_update = true;
}
if (need_zone_update) {