From: Maxim Mamontov Date: Tue, 27 May 2014 14:11:48 +0000 (+0300) Subject: Added handling of "AuthBy" info. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/95d54ec2f747d0b89fff42965a781689e7d4db1e?ds=sidebyside Added handling of "AuthBy" info. --- 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