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

Method loadSpanConfig

src/traffic_cache_tool/CacheTool.cc:509–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

507}
508
509Errata
510Cache::loadSpanConfig(swoc::file::path const &path)
511{
512 static const swoc::TextView TAG_ID("id");
513 static const swoc::TextView TAG_VOL("volume");
514
515 Errata zret;
516 std::error_code ec;
517 std::string load_content = swoc::file::load(path, ec);
518 if (ec.value() == 0) {
519 swoc::TextView content(load_content);
520 while (content) {
521 swoc::TextView line = content.take_prefix_at('\n');
522 line.ltrim_if(&isspace);
523 if (line.empty() || '#' == *line) {
524 continue;
525 }
526 swoc::TextView localpath = line.take_prefix_if(&isspace);
527 if (localpath) {
528 // After this the line is [size] [id=string] [volume=#]
529 while (line) {
530 swoc::TextView value(line.take_prefix_if(&isspace));
531 if (value) {
532 swoc::TextView tag(value.take_prefix_at('='));
533 if (!tag) { // must be the size
534 } else if (0 == strcasecmp(tag, TAG_ID)) {
535 } else if (0 == strcasecmp(tag, TAG_VOL)) {
536 swoc::TextView text;
537 auto n = swoc::svtoi(value, &text);
538 if (text == value && 0 < n && n < 256) {
539 } else {
540 zret.note("Invalid volume index '{}'", value);
541 }
542 }
543 }
544 }
545 zret = this->loadSpan(swoc::file::path(localpath));
546 }
547 }
548 } else {
549 zret = Errata(make_errno_code(EBADF), "Unable to load {}", path);
550 }
551 return zret;
552}
553
554Errata
555Cache::loadURLs(swoc::file::path const &path)

Callers 1

loadSpanMethod · 0.95

Calls 12

loadSpanMethod · 0.95
strcasecmpFunction · 0.85
svtoiFunction · 0.85
pathClass · 0.85
ErrataClass · 0.85
make_errno_codeFunction · 0.85
take_prefix_atMethod · 0.80
take_prefix_ifMethod · 0.80
loadFunction · 0.50
valueMethod · 0.45
emptyMethod · 0.45
noteMethod · 0.45

Tested by

no test coverage detected