* @brief initializes plugin configuration. * @param argc number of plugin parameters * @param argv plugin parameters * @param perRemapConfig boolean showing if this is per-remap config (vs global config). * */
| 373 | * |
| 374 | */ |
| 375 | bool |
| 376 | Configs::init(int argc, const char *argv[], bool perRemapConfig) |
| 377 | { |
| 378 | static const struct option longopt[] = { |
| 379 | {const_cast<char *>("exclude-params"), optional_argument, nullptr, 'a'}, |
| 380 | {const_cast<char *>("include-params"), optional_argument, nullptr, 'b'}, |
| 381 | {const_cast<char *>("include-match-params"), optional_argument, nullptr, 'c'}, |
| 382 | {const_cast<char *>("exclude-match-params"), optional_argument, nullptr, 'd'}, |
| 383 | {const_cast<char *>("sort-params"), optional_argument, nullptr, 'e'}, |
| 384 | {const_cast<char *>("remove-all-params"), optional_argument, nullptr, 'f'}, |
| 385 | {const_cast<char *>("include-headers"), optional_argument, nullptr, 'g'}, |
| 386 | {const_cast<char *>("include-cookies"), optional_argument, nullptr, 'h'}, |
| 387 | {const_cast<char *>("ua-capture"), optional_argument, nullptr, 'i'}, |
| 388 | {const_cast<char *>("ua-allowlist"), optional_argument, nullptr, 'j'}, |
| 389 | {const_cast<char *>("ua-denylist"), optional_argument, nullptr, 'k'}, |
| 390 | {const_cast<char *>("static-prefix"), optional_argument, nullptr, 'l'}, |
| 391 | {const_cast<char *>("capture-prefix"), optional_argument, nullptr, 'm'}, |
| 392 | {const_cast<char *>("capture-prefix-uri"), optional_argument, nullptr, 'n'}, |
| 393 | {const_cast<char *>("capture-path"), optional_argument, nullptr, 'o'}, |
| 394 | {const_cast<char *>("capture-path-uri"), optional_argument, nullptr, 'p'}, |
| 395 | {const_cast<char *>("remove-prefix"), optional_argument, nullptr, 'q'}, |
| 396 | {const_cast<char *>("remove-path"), optional_argument, nullptr, 'r'}, |
| 397 | {const_cast<char *>("separator"), optional_argument, nullptr, 's'}, |
| 398 | {const_cast<char *>("uri-type"), optional_argument, nullptr, 't'}, |
| 399 | {const_cast<char *>("key-type"), optional_argument, nullptr, 'u'}, |
| 400 | {const_cast<char *>("capture-header"), optional_argument, nullptr, 'v'}, |
| 401 | {const_cast<char *>("canonical-prefix"), optional_argument, nullptr, 'w'}, |
| 402 | /* reserve 'z' for 'config' files */ |
| 403 | {nullptr, 0, nullptr, 0 }, |
| 404 | }; |
| 405 | |
| 406 | bool status = true; |
| 407 | |
| 408 | /* For remap.config: argv contains the "to" and "from" URLs. Skip the first so that the second one poses as the program name. |
| 409 | * For plugin.config: argv contains the plugin shared object name. Don't skip any */ |
| 410 | if (perRemapConfig) { |
| 411 | argc--; |
| 412 | argv++; |
| 413 | } |
| 414 | |
| 415 | for (;;) { |
| 416 | int opt; |
| 417 | opt = getopt_long(argc, const_cast<char *const *>(argv), "", longopt, nullptr); |
| 418 | |
| 419 | if (opt == -1) { |
| 420 | break; |
| 421 | } |
| 422 | CacheKeyDebug("processing %s", argv[optind - 1]); |
| 423 | |
| 424 | switch (opt) { |
| 425 | case 'a': /* exclude-params */ |
| 426 | _query.setExclude(optarg); |
| 427 | break; |
| 428 | case 'b': /* include-params */ |
| 429 | _query.setInclude(optarg); |
| 430 | break; |
| 431 | case 'c': /* include-match-params */ |
| 432 | _query.setIncludePatterns(optarg); |