From 7adae1923ee7cde74ee96f762c994ecafa0e1ca4 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 5 May 2011 18:02:42 +0300 Subject: [PATCH] main.cpp cleaned up --- projects/sgauthstress/main.cpp | 58 ++++++++++++++-------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/projects/sgauthstress/main.cpp b/projects/sgauthstress/main.cpp index 71388477..3d0adb49 100644 --- a/projects/sgauthstress/main.cpp +++ b/projects/sgauthstress/main.cpp @@ -29,12 +29,13 @@ #include #include -#include "stg/ia.h" #include "stg/common.h" #include "stg/store.h" +#include "stg/user_conf.h" #include "settings.h" #include "store_loader.h" +#include "user.h" time_t stgTime; bool running; @@ -47,22 +48,6 @@ void Usage() std::cout << "Usage:\n\nsgauth " << std::endl; } //----------------------------------------------------------------------------- -void StatUpdate(const LOADSTAT &, void *) -{ -} -//----------------------------------------------------------------------------- -void StatusChanged(int, void *) -{ -} -//----------------------------------------------------------------------------- -void ShowMessage(const string &, int, int, int, void *) -{ -} -//----------------------------------------------------------------------------- -void ShowError(const string &, int, void *) -{ -} -//----------------------------------------------------------------------------- void CatchTERM(int) { running = false; @@ -125,21 +110,28 @@ if (dataStore->GetUsersList(&userList)) 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()); -proto.SetPassword(settings.GetPassword()); - -proto.SetStatusChangedCb(StatusChanged, NULL); -proto.SetInfoCb(ShowMessage, NULL); -proto.SetErrorCb(ShowError, NULL); -proto.SetStatChangedCb(StatUpdate, NULL); - -proto.Start(); +std::vector users; +std::vector::const_iterator it; +for (it = userList.begin(); it != userList.end(); ++it) + { + USER_CONF userConf; + if (dataStore->RestoreUserConf(&userConf, *it)) + { + std::cerr << "Failed to read user conf: '" << dataStore->GetStrError() << "'" << std::endl; + return -1; + } + users.push_back( + USER( + settings.GetServerName(), + settings.GetServerPort(), + settings.GetLocalPort(), + *it, + userConf.password + ) + ); + } -proto.Connect(); +std::cout << "Successfully loaded " << users.size() << " users" << std::endl; running = true; while (running) @@ -147,10 +139,6 @@ while (running) usleep(200000); } -proto.Disconnect(); - -proto.Stop(); - storeLoader.Unload(); return 0; -- 2.43.2