From 18caba20e60d31488fc27402515a811f689b0672 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 5 May 2011 14:22:10 +0300 Subject: [PATCH 1/1] Add user list loading --- projects/sgauthstress/main.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) 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; } //----------------------------------------------------------------------------- -- 2.44.2