| 745 | } |
| 746 | |
| 747 | void |
| 748 | TSPluginInit(int argc, const char *argv[]) |
| 749 | { |
| 750 | TSPluginRegistrationInfo info; |
| 751 | TSCont main_cont, config_cont; |
| 752 | plugin_state_t *pstate; |
| 753 | invalidate_t *iptr = nullptr; |
| 754 | bool disable_timed_reload = false; |
| 755 | |
| 756 | Dbg(dbg_ctl, "Starting plugin init"); |
| 757 | |
| 758 | pstate = (plugin_state_t *)TSmalloc(sizeof(plugin_state_t)); |
| 759 | init_plugin_state_t(pstate); |
| 760 | |
| 761 | int c; |
| 762 | static const struct option longopts[] = { |
| 763 | {"config", required_argument, nullptr, 'c'}, |
| 764 | {"log", required_argument, nullptr, 'l'}, |
| 765 | {"disable-timed-reload", no_argument, nullptr, 'd'}, |
| 766 | {"state-file", required_argument, nullptr, 'f'}, |
| 767 | {"match-header", required_argument, nullptr, 'm'}, |
| 768 | {nullptr, 0, nullptr, 0 } |
| 769 | }; |
| 770 | |
| 771 | while ((c = getopt_long(argc, (char *const *)argv, "c:l:f:m:", longopts, nullptr)) != -1) { |
| 772 | switch (c) { |
| 773 | case 'c': |
| 774 | pstate->config_path = TSstrdup(optarg); |
| 775 | break; |
| 776 | case 'l': |
| 777 | if (TS_SUCCESS == TSTextLogObjectCreate(optarg, TS_LOG_MODE_ADD_TIMESTAMP, &pstate->log)) { |
| 778 | TSTextLogObjectRollingIntervalSecSet(pstate->log, LOG_ROLL_INTERVAL); |
| 779 | TSTextLogObjectRollingOffsetHrSet(pstate->log, LOG_ROLL_OFFSET); |
| 780 | } |
| 781 | break; |
| 782 | case 'd': |
| 783 | disable_timed_reload = true; |
| 784 | break; |
| 785 | case 'f': |
| 786 | pstate->state_path = make_state_path(optarg); |
| 787 | break; |
| 788 | case 'm': |
| 789 | pstate->match_header = TSstrdup(optarg); |
| 790 | break; |
| 791 | default: |
| 792 | break; |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | if (nullptr == pstate->config_path) { |
| 797 | TSError("[regex_revalidate] Plugin requires a --config option along with a config file name"); |
| 798 | free_plugin_state_t(pstate); |
| 799 | return; |
| 800 | } |
| 801 | |
| 802 | if (!load_config(pstate, &iptr)) { |
| 803 | Dbg(dbg_ctl, "Problem loading config from file %s", pstate->config_path); |
| 804 | } else { |
nothing calls this directly
no test coverage detected