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

Function parse_include_directive

src/proxy/http/remap/RemapConfig.cc:349–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347}
348
349static const char *
350parse_include_directive(const char *directive, BUILD_TABLE_INFO *bti, char *errbuf, size_t errbufsize)
351{
352 if (bti->paramc < 2) {
353 snprintf(errbuf, errbufsize, "Directive \"%s\" must have a path argument", directive);
354 Dbg(dbg_ctl_url_rewrite, "[%s] %s", __func__, errbuf);
355 return errbuf;
356 }
357
358 for (unsigned i = 1; i < static_cast<unsigned>(bti->paramc); ++i) {
359 ats_scoped_str path;
360 const char *errmsg = nullptr;
361
362 // The included path is relative to SYSCONFDIR, just like remap.config is.
363 path = RecConfigReadConfigPath(nullptr, bti->paramv[i]);
364
365 if (ink_file_is_directory(path)) {
366 struct dirent **entrylist;
367 int n_entries;
368
369 n_entries = scandir(path, &entrylist, nullptr, alphasort);
370 if (n_entries == -1) {
371 snprintf(errbuf, errbufsize, "failed to open %s: %s", path.get(), strerror(errno));
372 return errbuf;
373 }
374
375 for (int j = 0; j < n_entries; ++j) {
376 ats_scoped_str subpath;
377
378 if (isdot(entrylist[j]->d_name) || isdotdot(entrylist[j]->d_name)) {
379 continue;
380 }
381
382 subpath = Layout::relative_to(path.get(), entrylist[j]->d_name);
383
384 if (ink_file_is_directory(subpath)) {
385 continue;
386 }
387
388 errmsg = parse_remap_fragment(subpath, bti, errbuf, errbufsize);
389 if (errmsg != nullptr) {
390 break;
391 }
392 }
393
394 free_directory_list(n_entries, entrylist);
395
396 } else {
397 errmsg = parse_remap_fragment(path, bti, errbuf, errbufsize);
398 }
399
400 if (errmsg) {
401 return errmsg;
402 }
403 }
404
405 return nullptr;
406}

Callers

nothing calls this directly

Calls 7

RecConfigReadConfigPathFunction · 0.85
ink_file_is_directoryFunction · 0.85
isdotFunction · 0.85
isdotdotFunction · 0.85
parse_remap_fragmentFunction · 0.85
free_directory_listFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected