| 1755 | } |
| 1756 | |
| 1757 | TSReturnCode |
| 1758 | TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_size) |
| 1759 | { |
| 1760 | if (argc < 2) { |
| 1761 | snprintf(errbuf, errbuf_size, |
| 1762 | "Unable to create remap instance, " |
| 1763 | "argc: %d < 2", |
| 1764 | argc); |
| 1765 | TSError("[esi]Unable to create remap instance! argc: %d < 2", argc); |
| 1766 | return TS_ERROR; |
| 1767 | } |
| 1768 | |
| 1769 | int index = 0; |
| 1770 | const char *new_argv[argc]; |
| 1771 | |
| 1772 | new_argv[index++] = "esi.so"; |
| 1773 | for (int i = 2; i < argc; i++) { |
| 1774 | new_argv[index++] = argv[i]; |
| 1775 | } |
| 1776 | new_argv[index] = nullptr; |
| 1777 | |
| 1778 | OptionInfo *pOptionInfo = TSRalloc<OptionInfo>(); |
| 1779 | if (pOptionInfo == nullptr) { |
| 1780 | snprintf(errbuf, errbuf_size, "malloc %d bytes fail", static_cast<int>(sizeof(OptionInfo))); |
| 1781 | TSError("[esi][%s] malloc %d bytes fail", __FUNCTION__, static_cast<int>(sizeof(OptionInfo))); |
| 1782 | return TS_ERROR; |
| 1783 | } |
| 1784 | if (esiPluginInit(index, new_argv, pOptionInfo) != 0) { |
| 1785 | snprintf(errbuf, errbuf_size, "esiPluginInit fail!"); |
| 1786 | TSfree(pOptionInfo); |
| 1787 | return TS_ERROR; |
| 1788 | } |
| 1789 | TSCont contp = TSContCreate(globalHookHandler, nullptr); |
| 1790 | TSContDataSet(contp, pOptionInfo); |
| 1791 | *ih = static_cast<void *>(contp); |
| 1792 | |
| 1793 | return TS_SUCCESS; |
| 1794 | } |
| 1795 | |
| 1796 | void |
| 1797 | TSRemapDeleteInstance(void *ih) |
nothing calls this directly
no test coverage detected