From 95d54ec2f747d0b89fff42965a781689e7d4db1e Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Tue, 27 May 2014 17:11:48 +0300 Subject: [PATCH] Added handling of "AuthBy" info. --- projects/sgconf/users.cpp | 6 ++++++ stglibs/srvconf.lib/include/stg/servconf_types.h | 1 + stglibs/srvconf.lib/parsers/get_user.cpp | 16 +++++++++++++++- stglibs/srvconf.lib/parsers/get_user.h | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/projects/sgconf/users.cpp b/projects/sgconf/users.cpp index 61d36736..37b3db5e 100644 --- a/projects/sgconf/users.cpp +++ b/projects/sgconf/users.cpp @@ -57,6 +57,12 @@ for (size_t i = 0; i < DIR_NUM; ++i) std::cout << Indent(level) << "user data:\n"; for (size_t i = 0; i < USERDATA_NUM; ++i) std::cout << Indent(level + 1, true) << "user data " << i << ": " << info.userData[i] << "\n"; +if (!info.authBy.empty()) + { + std::cout << Indent(level) << "auth by:\n"; + for (size_t i = 0; i < info.authBy.size(); ++i) + std::cout << Indent(level + 1, true) << info.authBy[i] << "\n"; + } } void SimpleCallback(bool result, diff --git a/stglibs/srvconf.lib/include/stg/servconf_types.h b/stglibs/srvconf.lib/include/stg/servconf_types.h index 84ceae89..7cdf2475 100644 --- a/stglibs/srvconf.lib/include/stg/servconf_types.h +++ b/stglibs/srvconf.lib/include/stg/servconf_types.h @@ -162,6 +162,7 @@ struct INFO time_t pingTime; time_t lastActivityTime; ARRAY userData; + std::vector authBy; }; typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data); diff --git a/stglibs/srvconf.lib/parsers/get_user.cpp b/stglibs/srvconf.lib/parsers/get_user.cpp index e796d450..a851e380 100644 --- a/stglibs/srvconf.lib/parsers/get_user.cpp +++ b/stglibs/srvconf.lib/parsers/get_user.cpp @@ -112,6 +112,9 @@ if (depth == 1) if (depth == 2 && parsingAnswer) ParseUserParams(el, attr); +if (depth == 3 && parsingAnswer) + ParseAuthBy(el, attr); + return 0; } //----------------------------------------------------------------------------- @@ -149,6 +152,17 @@ if (strcasecmp(el, "user") == 0) //----------------------------------------------------------------------------- void GET_USER::PARSER::ParseUserParams(const char * el, const char ** attr) { -if (!TryParse(propertyParsers, ToLower(el), attr)) +if (strcasecmp(el, "AuthorizedBy") != 0 && + !TryParse(propertyParsers, ToLower(el), attr)) error = "Invalid parameter."; } +//----------------------------------------------------------------------------- +void GET_USER::PARSER::ParseAuthBy(const char * el, const char ** attr) +{ +if (strcasecmp(el, "Auth") == 0 && + attr && attr[0] && attr[1] && + strcasecmp(attr[0], "name") == 0) + info.authBy.push_back(attr[1]); +else + error = "Invalid auth description."; +} diff --git a/stglibs/srvconf.lib/parsers/get_user.h b/stglibs/srvconf.lib/parsers/get_user.h index eba12ed5..ffd6f224 100644 --- a/stglibs/srvconf.lib/parsers/get_user.h +++ b/stglibs/srvconf.lib/parsers/get_user.h @@ -56,6 +56,7 @@ private: void ParseUser(const char * el, const char ** attr); void ParseUserParams(const char * el, const char ** attr); + void ParseAuthBy(const char * el, const char ** attr); }; } // namespace GET_USER -- 2.43.2