From: Maxim Mamontov Date: Thu, 5 May 2011 11:22:10 +0000 (+0300) Subject: Add user list loading X-Git-Tag: 2.407-p1~32 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/18caba20e60d31488fc27402515a811f689b0672?hp=307bdaafb43a43a8385551e3f12ae1745b4089b6 Add user list loading --- diff --git a/projects/sgauthstress/main.cpp b/projects/sgauthstress/main.cpp index 3460457a..71388477 100644 --- a/projects/sgauthstress/main.cpp +++ b/projects/sgauthstress/main.cpp @@ -31,8 +31,10 @@ #include "stg/ia.h" #include "stg/common.h" +#include "stg/store.h" #include "settings.h" +#include "store_loader.h" time_t stgTime; bool running; @@ -42,7 +44,7 @@ bool running; //----------------------------------------------------------------------------- void Usage() { -std::cout << "sgauth " << std::endl; +std::cout << "Usage:\n\nsgauth " << std::endl; } //----------------------------------------------------------------------------- void StatUpdate(const LOADSTAT &, void *) @@ -99,14 +101,32 @@ if (argc == 2) if (settings.ReadSettings()) { - std::cerr << "Failed to read settings\n" - << settings.GetStrError() << std::endl; + std::cerr << "Failed to read settings: '" + << settings.GetStrError() << "'" << std::endl; Usage(); return -1; } SetSignalHandlers(); +STORE_LOADER storeLoader(settings.GetModulesPath(), settings.GetStoreModuleSettings()); +if (storeLoader.Load()) + { + std::cerr << "Failed to load storage plugin: '" << storeLoader.GetStrError() << "'" << std::endl; + return -1; + } + +STORE * dataStore = storeLoader.GetStore(); + +std::vector userList; +if (dataStore->GetUsersList(&userList)) + { + std::cerr << "Failed to get user list: '" << dataStore->GetStrError() << "'" << std::endl; + return -1; + } + +std::cout << "Successfully loaded " << userList.size() << " users" << std::endl; + IA_CLIENT_PROT proto(settings.GetServerName(), settings.GetServerPort(), settings.GetLocalPort()); proto.SetLogin(settings.GetLogin()); @@ -131,6 +151,8 @@ proto.Disconnect(); proto.Stop(); +storeLoader.Unload(); + return 0; } //-----------------------------------------------------------------------------