]> git.stg.codes - stg.git/blobdiff - stglibs/srvconf.lib/parser.cpp
Added logger for rlm_stg.
[stg.git] / stglibs / srvconf.lib / parser.cpp
index d7c7568f848aaf63fc2f9b1c3198dc274090621a..40557e3cd6f29984917cf24b4b7e2ab97667db1f 100644 (file)
@@ -34,8 +34,8 @@
 #include <string>
 
 #include "stg/common.h"
 #include <string>
 
 #include "stg/common.h"
-#include "stg/stg_const.h"
-#include "servconf.h"
+#include "stg/const.h"
+#include "stg/servconf.h"
 
 using namespace std;
 
 
 using namespace std;
 
@@ -45,9 +45,7 @@ using namespace std;
 PARSER_GET_USERS::PARSER_GET_USERS()
     : RecvUserDataCb(NULL),
       userDataCb(NULL),
 PARSER_GET_USERS::PARSER_GET_USERS()
     : RecvUserDataCb(NULL),
       userDataCb(NULL),
-      user(),
-      depth(0),
-      error(false)
+      depth(0)
 {
 }
 //-----------------------------------------------------------------------------
 {
 }
 //-----------------------------------------------------------------------------
@@ -387,9 +385,7 @@ userDataCb = data;
 PARSER_GET_USER::PARSER_GET_USER()
     : RecvUserDataCb(NULL),
       userDataCb(NULL),
 PARSER_GET_USER::PARSER_GET_USER()
     : RecvUserDataCb(NULL),
       userDataCb(NULL),
-      user(),
-      depth(0),
-      error(false)
+      depth(0)
 {
 }
 //-----------------------------------------------------------------------------
 {
 }
 //-----------------------------------------------------------------------------
@@ -665,9 +661,7 @@ userDataCb = data;
 PARSER_GET_SERVER_INFO::PARSER_GET_SERVER_INFO()
     : RecvServerInfoDataCb(NULL),
       serverInfoDataCb(NULL),
 PARSER_GET_SERVER_INFO::PARSER_GET_SERVER_INFO()
     : RecvServerInfoDataCb(NULL),
       serverInfoDataCb(NULL),
-      depth(0),
-      error(false),
-      serverInfo()
+      depth(0)
 {
 }
 //-----------------------------------------------------------------------------
 {
 }
 //-----------------------------------------------------------------------------
@@ -822,11 +816,60 @@ if (strcmp(attr[0], "value") == 0)
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
+PARSER_AUTH_BY::PARSER_AUTH_BY()
+    : RecvAuthByDataCb(NULL),
+      authByDataCb(NULL),
+      depth(0)
+{
+}
+//-----------------------------------------------------------------------------
+int PARSER_AUTH_BY::ParseStart(const char *el, const char **attr)
+{
+depth++;
+if (depth == 1)
+    {
+    if (strcasecmp(el, "AuthorizedBy") != 0)
+        {
+        list.erase(list.begin(), list.end());
+        //printf("%s\n", el);
+        }
+    }
+else
+    {
+    if (depth == 2)
+        {
+        if (strcasecmp(el, "Auth") == 0)
+            {
+            if (attr && attr[0] && attr[1])
+                list.push_back(attr[1]);
+            return 0;
+            }
+        }
+    }
+return 0;
+}
+//-----------------------------------------------------------------------------
+void PARSER_AUTH_BY::ParseEnd(const char *)
+{
+depth--;
+if (depth == 0)
+    {
+    RecvAuthByDataCb(list, authByDataCb);
+    }
+}
+//-----------------------------------------------------------------------------
+void PARSER_AUTH_BY::SetRecvCb(RecvAuthByDataCb_t f, void * data)
+{
+RecvAuthByDataCb = f;
+authByDataCb = data;
+}
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
 PARSER_CHG_USER::PARSER_CHG_USER()
     : RecvChgUserCb(NULL),
       chgUserCbData(NULL),
 PARSER_CHG_USER::PARSER_CHG_USER()
     : RecvChgUserCb(NULL),
       chgUserCbData(NULL),
-      depth(0),
-      error(false)
+      depth(0)
 {
 }
 //-----------------------------------------------------------------------------
 {
 }
 //-----------------------------------------------------------------------------
@@ -875,8 +918,7 @@ chgUserCbData = data;
 PARSER_CHECK_USER::PARSER_CHECK_USER()
     : RecvCheckUserCb(NULL),
       checkUserCbData(NULL),
 PARSER_CHECK_USER::PARSER_CHECK_USER()
     : RecvCheckUserCb(NULL),
       checkUserCbData(NULL),
-      depth(0),
-      error(false)
+      depth(0)
 {
 }
 //-----------------------------------------------------------------------------
 {
 }
 //-----------------------------------------------------------------------------
@@ -918,8 +960,7 @@ checkUserCbData = data;
 PARSER_SEND_MESSAGE::PARSER_SEND_MESSAGE()
     : RecvSendMessageCb(NULL),
       sendMessageCbData(NULL),
 PARSER_SEND_MESSAGE::PARSER_SEND_MESSAGE()
     : RecvSendMessageCb(NULL),
       sendMessageCbData(NULL),
-      depth(0),
-      error(false)
+      depth(0)
 {
 }
 //-----------------------------------------------------------------------------
 {
 }
 //-----------------------------------------------------------------------------