| 251 | } // end anonymous namespace |
| 252 | |
| 253 | TSReturnCode |
| 254 | TSRemapInit(TSRemapInterface *api_info, char * /* errbuf ATS_UNUSED */, int /* errbuf_size ATS_UNUSED */) |
| 255 | { |
| 256 | Dbg(dbg_ctl, "TSRemapInit()"); |
| 257 | |
| 258 | SpecificDbg(true, off_dbg_ctl, "Should see this"); |
| 259 | SpecificDbg(false, dbg_ctl, "Should see this"); |
| 260 | SpecificDbg(false, off_dbg_ctl, "Should NOT see this"); |
| 261 | |
| 262 | TSReleaseAssert(api_info != nullptr); |
| 263 | TSReleaseAssert(api_info->size == sizeof(TSRemapInterface)); |
| 264 | TSReleaseAssert(api_info->tsremap_version == TSREMAP_VERSION); |
| 265 | |
| 266 | const char *fileSpec = std::getenv("OUTPUT_FILE"); |
| 267 | |
| 268 | if (nullptr == fileSpec) { |
| 269 | TSError(PINAME ": Environment variable OUTPUT_FILE not found."); |
| 270 | |
| 271 | return TS_ERROR; |
| 272 | } |
| 273 | |
| 274 | // Disable output buffering for logFile, so that explicit flushing is not necessary. |
| 275 | logFile.rdbuf()->pubsetbuf(nullptr, 0); |
| 276 | |
| 277 | logFile.open(fileSpec, std::ios::out); |
| 278 | if (!logFile.is_open()) { |
| 279 | TSError(PINAME ": could not open log file \"%s\"", fileSpec); |
| 280 | |
| 281 | return TS_ERROR; |
| 282 | } |
| 283 | |
| 284 | // Mutex to protect the logFile object. |
| 285 | // |
| 286 | TSMutex mtx = TSMutexCreate(); |
| 287 | |
| 288 | gCont = TSContCreate(globalContFunc, mtx); |
| 289 | |
| 290 | TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, gCont); |
| 291 | TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, gCont); |
| 292 | TSHttpHookAdd(TS_HTTP_SEND_REQUEST_HDR_HOOK, gCont); |
| 293 | |
| 294 | tCont = TSContCreate(transactionContFunc, mtx); |
| 295 | return TS_SUCCESS; |
| 296 | } |
| 297 | |
| 298 | TSReturnCode |
| 299 | TSRemapNewInstance(int argc, char *argv[], void **instance, char *errbuf, int errbuf_size) |
nothing calls this directly
no test coverage detected