MCPcopy Create free account
hub / github.com/apache/trafficserver / initialize

Method initialize

plugins/regex_remap/regex_remap.cc:271–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269};
270
271bool
272RemapRegex::initialize(const std::string &reg, 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;

Callers 1

TSRemapNewInstanceFunction · 0.45

Calls 12

TSstrdupFunction · 0.85
memsetFunction · 0.85
TSHttpTxnConfigFindFunction · 0.85
TSErrorFunction · 0.50
emptyMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
substrMethod · 0.45
compareMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected