| 269 | }; |
| 270 | |
| 271 | bool |
| 272 | RemapRegex::initialize(const std::string ®, const std::string &sub, const std::string &opt) |
| 273 | { |
| 274 | if (!reg.empty()) { |
| 275 | _rex_string = TSstrdup(reg.c_str()); |
| 276 | } |
| 277 | |
| 278 | if (!sub.empty()) { |
| 279 | _subst = TSstrdup(sub.c_str()); |
| 280 | _subst_len = sub.length(); |
| 281 | } |
| 282 | |
| 283 | memset(_sub_pos, 0, sizeof(_sub_pos)); |
| 284 | memset(_sub_ix, 0, sizeof(_sub_ix)); |
| 285 | |
| 286 | // Parse options |
| 287 | std::string::size_type start = opt.find_first_of('@'); |
| 288 | std::string::size_type pos1, pos2; |
| 289 | Override *last_override = nullptr; |
| 290 | |
| 291 | while (start != std::string::npos) { |
| 292 | std::string opt_val; |
| 293 | |
| 294 | ++start; |
| 295 | pos1 = opt.find_first_of('=', start); |
| 296 | pos2 = opt.find_first_of(" \t\n", pos1); |
| 297 | if (pos2 == std::string::npos) { |
| 298 | pos2 = opt.length(); |
| 299 | } |
| 300 | |
| 301 | if (pos1 != std::string::npos) { |
| 302 | // Get the value as well |
| 303 | ++pos1; |
| 304 | opt_val = opt.substr(pos1, pos2 - pos1); |
| 305 | } |
| 306 | |
| 307 | // These take an option 0|1 value, without value it implies 1 |
| 308 | if (opt.compare(start, 8, "caseless") == 0) { |
| 309 | _options |= PCRE_CASELESS; |
| 310 | } else if (opt.compare(start, 23, "lowercase_substitutions") == 0) { |
| 311 | _lowercase_substitutions = true; |
| 312 | } else if (opt_val.size() <= 0) { |
| 313 | // All other options have a required value |
| 314 | TSError("[%s] Malformed options: %s", PLUGIN_NAME, opt.c_str()); |
| 315 | break; |
| 316 | } else if (opt.compare(start, 6, "status") == 0) { |
| 317 | _status = static_cast<TSHttpStatus>(strtol(opt_val.c_str(), nullptr, 10)); |
| 318 | } else if (opt.compare(start, 14, "active_timeout") == 0) { |
| 319 | _active_timeout = strtol(opt_val.c_str(), nullptr, 10); |
| 320 | } else if (opt.compare(start, 19, "no_activity_timeout") == 0) { |
| 321 | _no_activity_timeout = strtol(opt_val.c_str(), nullptr, 10); |
| 322 | } else if (opt.compare(start, 15, "connect_timeout") == 0) { |
| 323 | _connect_timeout = strtol(opt_val.c_str(), nullptr, 10); |
| 324 | } else if (opt.compare(start, 11, "dns_timeout") == 0) { |
| 325 | _dns_timeout = strtol(opt_val.c_str(), nullptr, 10); |
| 326 | } else { |
| 327 | TSOverridableConfigKey key; |
| 328 | TSRecordDataType type; |
no test coverage detected