X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/641204dfbdb9fc870cdd2e7f9e3169a44693e7bf..16d1f76d5dc58c9b0000f86464c3d49a48e2aff4:/projects/convertor/main.cpp?ds=sidebyside diff --git a/projects/convertor/main.cpp b/projects/convertor/main.cpp index 58ff7fbd..e0679d07 100644 --- a/projects/convertor/main.cpp +++ b/projects/convertor/main.cpp @@ -32,19 +32,20 @@ #include #include -#include "common.h" -#include "base_store.h" -#include "settings.h" -#include "conffiles.h" - -#include "user_stat.h" -#include "user_conf.h" -#include "corp_conf.h" -#include "service_conf.h" -#include "admin_conf.h" -#include "tariff_conf.h" -#include "base_settings.h" -#include "stg_message.h" +#include "stg/common.h" +#include "stg/store.h" +#include "stg/conffiles.h" + +#include "stg/user_stat.h" +#include "stg/user_conf.h" +#include "stg/corp_conf.h" +#include "stg/service_conf.h" +#include "stg/admin_conf.h" +#include "stg/tariff_conf.h" +#include "stg/settings.h" +#include "stg/message.h" + +#include "settings_impl.h" using namespace std; @@ -54,10 +55,10 @@ int main(int argc, char **argv) { printfd(__FILE__, "Start\n"); -BASE_STORE * fromStore = NULL; -BASE_STORE * toStore = NULL; +STORE * fromStore = NULL; +STORE * toStore = NULL; -SETTINGS * settings = NULL; +SETTINGS_IMPL * settings = NULL; string modulePath; @@ -72,22 +73,18 @@ TARIFF_DATA td; CORP_CONF cc; SERVICE_CONF sc; vector hdrs; -vector::iterator mit; - -void * src_lh; -void * dst_lh; if (argc == 2) - settings = new SETTINGS(argv[1]); + settings = new SETTINGS_IMPL(argv[1]); else - settings = new SETTINGS(); + settings = new SETTINGS_IMPL(); if (settings->ReadSettings()) -{ + { printfd(__FILE__, "Error reading settings\n"); delete settings; return -1; -} + } fromStoreSettings = settings->GetSourceStoreModuleSettings(); toStoreSettings = settings->GetDestStoreModuleSettings(); @@ -96,7 +93,7 @@ modulePath = settings->GetModulesPath(); string sourcePlugin(modulePath + "/mod_" + fromStoreSettings.moduleName + ".so"); string destPlugin(modulePath + "/mod_" + toStoreSettings.moduleName + ".so"); -src_lh = dlopen(sourcePlugin.c_str(), RTLD_NOW); +void * src_lh = dlopen(sourcePlugin.c_str(), RTLD_NOW); if (!src_lh) { printfd(__FILE__, "Source storage plugin loading failed: %s\n", dlerror()); @@ -104,7 +101,7 @@ if (!src_lh) return -1; } -dst_lh = dlopen(destPlugin.c_str(), RTLD_NOW); +void * dst_lh = dlopen(destPlugin.c_str(), RTLD_NOW); if (!dst_lh) { printfd(__FILE__, "Destination storage plugin loading failed: %s\n", dlerror()); @@ -112,16 +109,16 @@ if (!dst_lh) return -1; } -BASE_STORE * (*GetSourceStore)(); -BASE_STORE * (*GetDestStore)(); -GetSourceStore = (BASE_STORE * (*)())dlsym(src_lh, "GetStore"); +STORE * (*GetSourceStore)(); +STORE * (*GetDestStore)(); +GetSourceStore = (STORE * (*)())dlsym(src_lh, "GetStore"); if (!GetSourceStore) { printfd(__FILE__, "Source storage plugin loading failed. GetStore not found: %s\n", dlerror()); delete settings; return -1; } -GetDestStore = (BASE_STORE * (*)())dlsym(dst_lh, "GetStore"); +GetDestStore = (STORE * (*)())dlsym(dst_lh, "GetStore"); if (!GetDestStore) { printfd(__FILE__, "Storage plugin (firebird) loading failed. GetStore not found: %s\n", dlerror()); @@ -134,7 +131,6 @@ toStore = GetDestStore(); vector entities; vector ready; -vector::const_iterator it; fromStore->SetSettings(fromStoreSettings); fromStore->ParseSettings(); toStore->SetSettings(toStoreSettings); @@ -159,6 +155,8 @@ if (toStore->GetAdminsList(&ready)) delete settings; return -1; } + +vector::const_iterator it; for (it = entities.begin(); it != entities.end(); ++it) { printfd(__FILE__, "\t - %s\n", it->c_str()); @@ -209,6 +207,7 @@ if (toStore->GetTariffsList(&ready)) delete settings; return -1; } + for (it = entities.begin(); it != entities.end(); ++it) { printfd(__FILE__, "\t - %s\n", it->c_str()); @@ -258,6 +257,7 @@ if (toStore->GetServicesList(&ready)) delete settings; return -1; } + for (it = entities.begin(); it != entities.end(); ++it) { printfd(__FILE__, "\t - %s\n", it->c_str()); @@ -307,6 +307,7 @@ if (toStore->GetCorpsList(&ready)) delete settings; return -1; } + for (it = entities.begin(); it != entities.end(); ++it) { printfd(__FILE__, "\t - %s\n", it->c_str()); @@ -356,6 +357,7 @@ if (toStore->GetUsersList(&ready)) delete settings; return -1; } + sort(ready.begin(), ready.end()); for (it = entities.begin(); it != entities.end(); ++it) { @@ -413,6 +415,7 @@ for (it = entities.begin(); it != entities.end(); ++it) delete settings; return -1; } + vector::iterator mit; for (mit = hdrs.begin(); mit != hdrs.end(); ++mit) { if (fromStore->GetMessage(mit->id, &msg, *it)) @@ -433,7 +436,6 @@ for (it = entities.begin(); it != entities.end(); ++it) return -1; } } - } dlclose(src_lh);