| 302 | struct Loader |
| 303 | { |
| 304 | Loader() |
| 305 | { |
| 306 | if (gBinary) { |
| 307 | assert(OfxGetNumberOfPlugins_binary); |
| 308 | assert(OfxGetPlugin_binary); |
| 309 | |
| 310 | return; |
| 311 | } |
| 312 | gBinaryPath = std::getenv("OFX_DEBUGPROXY_BINARY"); |
| 313 | if (gBinaryPath == NULL) { |
| 314 | gBinaryPath = BINARY_PATH; |
| 315 | } |
| 316 | if (gBinaryPath) { |
| 317 | if (std::strncmp( gBinaryPath, OFX_PATH, std::strlen(OFX_PATH) ) == 0) { |
| 318 | std::cout << "OFX DebugProxy: Error: plugin binary seems to be in the default plugin path:" << std::endl; |
| 319 | std::cout << "OFX DebugProxy: OFX_DEBUGPROXY_BINARY=" << gBinaryPath << " is in " << OFX_PATH << std::endl; |
| 320 | std::cout << "OFX DebugProxy: This is probably a very bad idea, since the host will load twice" << std::endl; |
| 321 | std::cout << "OFX DebugProxy: the same plugin, and wouldn't be able to tell one from the other." << std::endl; |
| 322 | std::cout << "OFX DebugProxy: Please move the plugin binary to another location.\n" << std::endl; |
| 323 | |
| 324 | return; |
| 325 | } |
| 326 | gBinary = new Binary(gBinaryPath); |
| 327 | } |
| 328 | if (gBinary) { |
| 329 | gBinary->load(); |
| 330 | if ( gBinary->isInvalid() ) { |
| 331 | std::cout << "OFX DebugProxy: Error: Cannot load the plugin binary." << std::endl; |
| 332 | std::cout << "OFX DebugProxy: OFX_DEBUGPROXY_BINARY=" << gBinaryPath << " is propably not an OFX plugin," << std::endl; |
| 333 | std::cout << "OFX DebugProxy: or misses some of its dynamic dependencies (see help below)." << std::endl; |
| 334 | std::cout << help_string; |
| 335 | |
| 336 | return; |
| 337 | } |
| 338 | // fetch the binary entry points |
| 339 | OfxGetNumberOfPlugins_binary = ( int (*)() )gBinary->findSymbol("OfxGetNumberOfPlugins"); |
| 340 | OfxGetPlugin_binary = ( OfxPlugin * (*)(int) )gBinary->findSymbol("OfxGetPlugin"); |
| 341 | if (!OfxGetNumberOfPlugins_binary || !OfxGetPlugin_binary) { |
| 342 | std::cout << "OFX DebugProxy: Error: Cannot find the mandatory symbols OfxGetNumberOfPlugins and OfxGetPlugin." << std::endl; |
| 343 | std::cout << "OFX DebugProxy: OFX_DEBUGPROXY_BINARY=" << gBinaryPath << " is propably not an OFX plugin." << std::endl; |
| 344 | std::cout << help_string; |
| 345 | gBinary->setInvalid(true); |
| 346 | |
| 347 | return; |
| 348 | } |
| 349 | std::cout << "OFX DebugProxy: OFX_DEBUGPROXY_BINARY=" << gBinaryPath << " succesfully loaded" << std::endl; |
| 350 | } else { |
| 351 | std::cout << "OFX DebugProxy: Error: Cannot load the plugin binary OFX_DEBUGPROXY_BINARY=" << gBinaryPath << std::endl; |
| 352 | std::cout << help_string; |
| 353 | |
| 354 | return; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | ~Loader() |
| 359 | { |