| 1596 | } |
| 1597 | |
| 1598 | static int |
| 1599 | esiPluginInit(int argc, const char *argv[], OptionInfo *pOptionInfo) |
| 1600 | { |
| 1601 | static TSStatSystem *statSystem = nullptr; |
| 1602 | |
| 1603 | if (statSystem == nullptr) { |
| 1604 | statSystem = new TSStatSystem(); |
| 1605 | Stats::init(statSystem); |
| 1606 | } |
| 1607 | |
| 1608 | if (gHandlerManager == nullptr) { |
| 1609 | gHandlerManager = new HandlerManager(); |
| 1610 | } |
| 1611 | |
| 1612 | new (pOptionInfo) OptionInfo; |
| 1613 | |
| 1614 | if (argc > 1) { |
| 1615 | int c; |
| 1616 | static const struct option longopts[] = { |
| 1617 | {const_cast<char *>("packed-node-support"), no_argument, nullptr, 'n'}, |
| 1618 | {const_cast<char *>("private-response"), no_argument, nullptr, 'p'}, |
| 1619 | {const_cast<char *>("disable-gzip-output"), no_argument, nullptr, 'z'}, |
| 1620 | {const_cast<char *>("first-byte-flush"), no_argument, nullptr, 'b'}, |
| 1621 | {const_cast<char *>("handler-filename"), required_argument, nullptr, 'f'}, |
| 1622 | {const_cast<char *>("max-doc-size"), required_argument, nullptr, 'd'}, |
| 1623 | {const_cast<char *>("max-inclusion-depth"), required_argument, nullptr, 'i'}, |
| 1624 | {nullptr, 0, nullptr, 0 }, |
| 1625 | }; |
| 1626 | |
| 1627 | int longindex = 0; |
| 1628 | while ((c = getopt_long(argc, const_cast<char *const *>(argv), "npzbf:d:i:", longopts, &longindex)) != -1) { |
| 1629 | switch (c) { |
| 1630 | case 'n': |
| 1631 | pOptionInfo->packed_node_support = true; |
| 1632 | break; |
| 1633 | case 'p': |
| 1634 | pOptionInfo->private_response = true; |
| 1635 | break; |
| 1636 | case 'z': |
| 1637 | pOptionInfo->disable_gzip_output = true; |
| 1638 | break; |
| 1639 | case 'b': |
| 1640 | pOptionInfo->first_byte_flush = true; |
| 1641 | break; |
| 1642 | case 'f': { |
| 1643 | Utils::KeyValueMap handler_conf; |
| 1644 | loadHandlerConf(optarg, handler_conf); |
| 1645 | gHandlerManager->loadObjects(handler_conf); |
| 1646 | break; |
| 1647 | } |
| 1648 | case 'd': { |
| 1649 | unsigned max, coeff{1}; |
| 1650 | char multiplier, crap; |
| 1651 | auto num_assigned = std::sscanf(optarg, "%u%c%c", &max, &multiplier, &crap); |
| 1652 | if (2 == num_assigned) { |
| 1653 | if ('K' == multiplier) { |
| 1654 | coeff = 1024; |
| 1655 | num_assigned = 1; |
no test coverage detected