]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/authorization/ao/ao.cpp
Produce debug output only if SMUX_DEBUG is defined
[stg.git] / projects / stargazer / plugins / authorization / ao / ao.cpp
index 193b20bc2e5ffe3160b6182b4c170541a9ab6caa..bdbfe3a9bfa1c911741ba41a984fc0e0d71ce4f5 100644 (file)
@@ -27,6 +27,7 @@ $Author: faust $
 #include <unistd.h>
 
 #include <csignal>
+#include <cassert>
 #include <algorithm> // for_each
 #include <functional> // mem_fun_ref
 
@@ -34,32 +35,20 @@ $Author: faust $
 #include "stg/users.h"
 #include "stg/user_property.h"
 #include "stg/common.h"
+#include "stg/plugin_creator.h"
 #include "ao.h"
 
-class AO_CREATOR
-{
-private:
-    AUTH_AO * ao;
-
-public:
-    AO_CREATOR()
-        : ao(new AUTH_AO())
-        {
-        };
-    ~AO_CREATOR()
-        {
-        delete ao;
-        };
-
-    AUTH_AO * GetPlugin()
-        {
-        return ao;
-        };
-};
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-AO_CREATOR aoc;
+PLUGIN_CREATOR<AUTH_AO> aoc;
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+PLUGIN * GetPlugin()
+{
+return aoc.GetPlugin();
+}
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -75,13 +64,6 @@ public:
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-PLUGIN * GetPlugin()
-{
-return aoc.GetPlugin();
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
 const string AUTH_AO::GetVersion() const
 {
 return "Always Online authorizator v.1.0";
@@ -219,11 +201,7 @@ void AUTH_AO::GetUsers()
 {
 USER_PTR u;
 int h = users->OpenSearch();
-if (!h)
-    {
-    printfd(__FILE__, "users->OpenSearch() error\n");
-    return;
-    }
+assert(h && "USERS::OpenSearch is always correct");
 
 while (!users->SearchNext(h, &u))
     {