////////////////////////////////////////////////////////////////////////// We don't have any specific "instances" here, at least not yet.
| 642 | // We don't have any specific "instances" here, at least not yet. |
| 643 | // |
| 644 | TSReturnCode |
| 645 | TSRemapNewInstance(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)) { |
nothing calls this directly
no test coverage detected