Initialize plugin (required). */
| 120 | |
| 121 | /* Initialize plugin (required). */ |
| 122 | bool |
| 123 | RemapPluginInfo::init(std::string &error) |
| 124 | { |
| 125 | TSRemapInterface ri; |
| 126 | bool result = true; |
| 127 | |
| 128 | PluginDbg(_dbg_ctl(), "started initializing plugin '%s'", _configPath.c_str()); |
| 129 | |
| 130 | /* A buffer to get the error from the plugin instance init function, be defensive here. */ |
| 131 | char tmpbuf[2048]; |
| 132 | ink_zero(tmpbuf); |
| 133 | |
| 134 | ink_zero(ri); |
| 135 | ri.size = sizeof(ri); |
| 136 | ri.tsremap_version = TSREMAP_VERSION; |
| 137 | ri.plugin_info = reinterpret_cast<TSRemapPluginInfo>(this); |
| 138 | |
| 139 | setPluginContext(); |
| 140 | |
| 141 | if (init_cb && init_cb(&ri, tmpbuf, sizeof(tmpbuf) - 1) != TS_SUCCESS) { |
| 142 | error.assign("failed to initialize plugin ") |
| 143 | .append(_configPath.string()) |
| 144 | .append(": ") |
| 145 | .append(tmpbuf[0] ? tmpbuf : "Unknown plugin error"); |
| 146 | result = false; |
| 147 | } |
| 148 | |
| 149 | resetPluginContext(); |
| 150 | |
| 151 | PluginDbg(_dbg_ctl(), "finished initializing plugin '%s'", _configPath.c_str()); |
| 152 | |
| 153 | return result; |
| 154 | } |
| 155 | |
| 156 | /* Called when plugin is unloaded (optional). */ |
| 157 | void |