From e19baa83c7f24b07e8925473a0d322d6fec440f9 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sat, 27 Jul 2013 20:04:03 +0300 Subject: [PATCH] Added missing files. --- .../configuration/sgconfig/parser_auth_by.cpp | 46 +++++++++++++++++++ .../configuration/sgconfig/parser_auth_by.h | 18 ++++++++ 2 files changed, 64 insertions(+) create mode 100644 projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.cpp create mode 100644 projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.h diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.cpp new file mode 100644 index 00000000..e1da75b6 --- /dev/null +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.cpp @@ -0,0 +1,46 @@ +#include "parser_auth_by.h" + +int PARSER_AUTH_BY::ParseStart(void * /*data*/, const char *el, const char **attr) +{ +if (strcasecmp(el, "GetUserAuthBy") == 0) + { + if (attr[0] && attr[1]) + login = attr[1]; + else + { + login.erase(login.begin(), login.end()); + return -1; + } + return 0; + } +return -1; +} + +int PARSER_AUTH_BY::ParseEnd(void * /*data*/, const char *el) +{ +if (strcasecmp(el, "GetUserAuthBy") == 0) + { + CreateAnswer(); + return 0; + } +return -1; +} + +void PARSER_AUTH_BY::CreateAnswer() +{ +answerList->erase(answerList->begin(), answerList->end()); + +USER_PTR u; +if (users->FindByName(login, &u)) + { + answerList->push_back(""); + return; + } + +std::string s = ""; +std::vector list(u->GetAuthorizers()); +for (std::vector::const_iterator it = list.begin(); it != list.end(); ++it) + s += ""; +s += ""; +answerList->push_back(s); +} diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.h b/projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.h new file mode 100644 index 00000000..c34586c9 --- /dev/null +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.h @@ -0,0 +1,18 @@ +#ifndef __STG_PARSER_AUTH_BY_H__ +#define __STG_PARSER_AUTH_BY_H__ + +#include + +#include "parser.h" + +class PARSER_AUTH_BY : public BASE_PARSER { +public: + int ParseStart(void *data, const char *el, const char **attr); + int ParseEnd(void *data, const char *el); + void CreateAnswer(); + +private: + std::string login; +}; + +#endif -- 2.43.2