| 687 | |
| 688 | |
| 689 | static int validate(Firebird::UtilSvc* svc) |
| 690 | { |
| 691 | PathName dbName; |
| 692 | string userName; |
| 693 | |
| 694 | const Switches valSwitches(val_option_in_sw_table, FB_NELEM(val_option_in_sw_table), false, true); |
| 695 | const char** argv = svc->argv.begin(); |
| 696 | const char* const* end = svc->argv.end(); |
| 697 | |
| 698 | for (++argv; argv < end; argv++) |
| 699 | { |
| 700 | if (!*argv) |
| 701 | continue; |
| 702 | |
| 703 | const Switches::in_sw_tab_t* sw = valSwitches.findSwitch(*argv); |
| 704 | if (!sw) |
| 705 | continue; |
| 706 | |
| 707 | switch (sw->in_sw) |
| 708 | { |
| 709 | case IN_SW_VAL_DATABASE: |
| 710 | *argv = NULL; |
| 711 | argv++; |
| 712 | if (argv < end && *argv) |
| 713 | dbName = *argv; |
| 714 | else |
| 715 | ; // error |
| 716 | break; |
| 717 | |
| 718 | default: |
| 719 | break; |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE); |
| 724 | if (!userName.isEmpty()) |
| 725 | { |
| 726 | dpb.insertString(isc_dpb_trusted_auth, userName); |
| 727 | } |
| 728 | dpb.insertTag(isc_dpb_no_garbage_collect); |
| 729 | |
| 730 | PathName expandedFilename; |
| 731 | if (expandDatabaseName(dbName, expandedFilename, NULL)) |
| 732 | expandedFilename = dbName; |
| 733 | |
| 734 | if (dbName != expandedFilename) |
| 735 | dpb.insertString(isc_dpb_org_filename, dbName); |
| 736 | |
| 737 | FbLocalStatus status; |
| 738 | AutoPlugin<JProvider> jProv(JProvider::getInstance()); |
| 739 | RefPtr<JAttachment> jAtt(jProv->attachDatabase(&status, expandedFilename.c_str(), dpb.getBufferLength(), dpb.getBuffer())); |
| 740 | |
| 741 | if (status->getState() & IStatus::STATE_ERRORS) |
| 742 | { |
| 743 | svc->getStatusAccessor().setServiceStatus(status->getErrors()); |
| 744 | return FB_FAILURE; |
| 745 | } |
| 746 |
no test coverage detected