]> git.stg.codes - stg.git/commitdiff
Add user list loading
authorMaxim Mamontov <faust@gts.dp.ua>
Thu, 5 May 2011 11:22:10 +0000 (14:22 +0300)
committerMaxim Mamontov <faust@gts.dp.ua>
Thu, 5 May 2011 11:22:10 +0000 (14:22 +0300)
projects/sgauthstress/main.cpp

index 3460457a6f1d0e67ee4786173f194b044652f4d4..7138847723966a02d3d0c79c0f9e8cf9b8de8380 100644 (file)
 
 #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 <path_to_config>" << std::endl;
+std::cout << "Usage:\n\nsgauth <path_to_config>" << 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<std::string> 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;
 }
 //-----------------------------------------------------------------------------