| 488 | |
| 489 | |
| 490 | UdrPluginImpl* Engine::loadModule(ThrowStatusWrapper* status, IRoutineMetadata* metadata, |
| 491 | PathName* moduleName, string* entryPoint) |
| 492 | { |
| 493 | const string str(metadata->getEntryPoint(status)); |
| 494 | |
| 495 | const string::size_type pos = str.find('!'); |
| 496 | if (pos == string::npos) |
| 497 | { |
| 498 | static const ISC_STATUS statusVector[] = { |
| 499 | isc_arg_gds, isc_random, |
| 500 | isc_arg_string, (ISC_STATUS) "Invalid entry point", |
| 501 | //// TODO: isc_arg_gds, isc_random, isc_arg_string, (ISC_STATUS) entryPoint.c_str(), |
| 502 | isc_arg_end |
| 503 | }; |
| 504 | |
| 505 | throw FbException(status, statusVector); |
| 506 | } |
| 507 | |
| 508 | *moduleName = PathName(str.substr(0, pos).c_str()); |
| 509 | // Do not allow module names with directory separators as a security measure. |
| 510 | if (moduleName->find_first_of("/\\") != string::npos) |
| 511 | { |
| 512 | static const ISC_STATUS statusVector[] = { |
| 513 | isc_arg_gds, isc_random, |
| 514 | isc_arg_string, (ISC_STATUS) "Invalid module name", |
| 515 | //// TODO: isc_arg_gds, isc_random, isc_arg_string, (ISC_STATUS) moduleName->c_str(), |
| 516 | isc_arg_end |
| 517 | }; |
| 518 | |
| 519 | throw FbException(status, statusVector); |
| 520 | } |
| 521 | |
| 522 | *entryPoint = str.substr(pos + 1); |
| 523 | |
| 524 | string::size_type n = entryPoint->find('!'); |
| 525 | *entryPoint = (n == string::npos ? *entryPoint : entryPoint->substr(0, n)); |
| 526 | |
| 527 | MutexLockGuard guard(modulesMutex, FB_FUNCTION); |
| 528 | |
| 529 | UdrPluginImpl* ret; |
| 530 | |
| 531 | if (modules->get(*moduleName, ret)) |
| 532 | return ret; |
| 533 | |
| 534 | for (ObjectsArray<PathName>::iterator i = paths->begin(); i != paths->end(); ++i) |
| 535 | { |
| 536 | PathName path; |
| 537 | PathUtils::concatPath(path, *i, *moduleName); |
| 538 | |
| 539 | ISC_STATUS_ARRAY statusArray = { |
| 540 | isc_arg_gds, isc_random, |
| 541 | isc_arg_string, (ISC_STATUS) "UDR module not loaded", |
| 542 | isc_arg_end |
| 543 | }; |
| 544 | const unsigned ARG_TEXT = 3; // Keep both in sync |
| 545 | const unsigned ARG_END = 4; // with status initializer! |
| 546 | |
| 547 | ModuleLoader::Module* module = ModuleLoader::fixAndLoadModule(&statusArray[ARG_END], path); |
no test coverage detected