]> git.stg.codes - stg.git/blobdiff - stglibs/srvconf.lib/parser.cpp
Added ability to list authorizers for user.
[stg.git] / stglibs / srvconf.lib / parser.cpp
index 0038f03da27dcb1ee9c25d3278090febe9728f5e..625373594e0b86b12fb1bf92632e396ae19171a9 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "stg/common.h"
 #include "stg/const.h"
-#include "servconf.h"
+#include "stg/servconf.h"
 
 using namespace std;
 
@@ -822,6 +822,58 @@ if (strcmp(attr[0], "value") == 0)
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
+PARSER_AUTH_BY::PARSER_AUTH_BY()
+    : RecvAuthByDataCb(NULL),
+      authByDataCb(NULL),
+      depth(0),
+      error(false),
+      list()
+{
+}
+//-----------------------------------------------------------------------------
+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])
+                list.push_back(attr[0]);
+            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),