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

Function TSRemapNewInstance

plugins/regex_remap/regex_remap.cc:644–805  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// We don't have any specific "instances" here, at least not yet.

Source from the content-addressed store, hash-verified

642// We don't have any specific "instances" here, at least not yet.
643//
644TSReturnCode
645TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSED */, int /* errbuf_sizeATS_UNUSED */)
646{
647 RemapInstance *ri = new RemapInstance();
648
649 std::ifstream f;
650 int lineno = 0;
651 int count = 0;
652
653 *ih = (void *)ri;
654 if (ri == nullptr) {
655 TSError("[%s] Unable to create remap instance", PLUGIN_NAME);
656 return TS_ERROR;
657 }
658
659 if (argc < 3) {
660 TSError("[%s] missing configuration file", PLUGIN_NAME);
661 return TS_ERROR;
662 }
663
664 // Really simple (e.g. basic) config parser
665 for (int i = 3; i < argc; ++i) {
666 if (strncmp(argv[i], "profile", 7) == 0) {
667 ri->profile = true;
668 } else if (strncmp(argv[i], "no-profile", 10) == 0) {
669 ri->profile = false;
670 } else if (strncmp(argv[i], "method", 6) == 0) {
671 ri->method = true;
672 } else if (strncmp(argv[i], "no-method", 9) == 0) {
673 ri->method = false;
674 } else if (strncmp(argv[i], "query-string", 12) == 0) {
675 ri->query_string = true;
676 } else if (strncmp(argv[i], "no-query-string", 15) == 0) {
677 ri->query_string = false;
678 } else if (strncmp(argv[i], "host", 4) == 0) {
679 ri->host = true;
680 } else if (strncmp(argv[i], "no-host", 7) == 0) {
681 ri->host = false;
682 } else if (strcmp(argv[i], "pristine") == 0) {
683 ri->pristine_url = true;
684 } else if (strcmp(argv[i], "no-pristine") == 0) {
685 ri->pristine_url = false;
686 } else {
687 TSError("[%s] invalid option '%s'", PLUGIN_NAME, argv[i]);
688 }
689 }
690
691 if (*argv[2] == '/') {
692 // Absolute path, just use it.
693 ri->filename = argv[2];
694 } else {
695 // Relative path. Make it relative to the configuration directory.
696 ri->filename = TSConfigDirGet();
697 ri->filename += "/";
698 ri->filename += argv[2];
699 }
700
701 if (0 != access(ri->filename.c_str(), R_OK)) {

Callers

nothing calls this directly

Calls 15

strcmpFunction · 0.85
TSConfigDirGetFunction · 0.85
eofMethod · 0.80
regex_emptyMethod · 0.80
regexMethod · 0.80
set_orderMethod · 0.80
set_nextMethod · 0.80
TSErrorFunction · 0.50
c_strMethod · 0.45
openMethod · 0.45
is_openMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected