X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/8569ecdc2c9368dc0fe650b901cce7b37337ffec..9af0b6faad1f5e6ca2206f7cddc02885a08e718c:/stglibs/srvconf.lib/parsers/get_admin.cpp?ds=sidebyside diff --git a/stglibs/srvconf.lib/parsers/get_admin.cpp b/stglibs/srvconf.lib/parsers/get_admin.cpp index 41217dfb..29e35ba7 100644 --- a/stglibs/srvconf.lib/parsers/get_admin.cpp +++ b/stglibs/srvconf.lib/parsers/get_admin.cpp @@ -34,10 +34,10 @@ namespace STG template <> inline -bool GetValue(const char ** attr, PRIV & value) +bool GetValue(const char ** attr, PRIV & value, const std::string & attrName) { uint32_t priv; -if (!GetValue(attr, priv)) +if (!GetValue(attr, priv, attrName)) return false; value = priv; return true; @@ -45,9 +45,10 @@ return true; } // namespace STG -GET_ADMIN::PARSER::PARSER(CALLBACK f, void * d) +GET_ADMIN::PARSER::PARSER(CALLBACK f, void * d, const std::string & e) : callback(f), data(d), + encoding(e), depth(0), parsingAnswer(false) { @@ -69,8 +70,8 @@ depth++; if (depth == 1) ParseAdmin(el, attr); -if (depth == 2 && parsingAnswer) - ParseAdminParams(el, attr); +/*if (depth == 2 && parsingAnswer) + ParseAdminParams(el, attr);*/ return 0; } @@ -101,15 +102,23 @@ if (strcasecmp(el, "admin") == 0) error = "Admin not found."; } else + { parsingAnswer = true; + for (const char ** pos = attr; *pos != NULL; pos = pos + 2) + if (!TryParse(propertyParsers, ToLower(*pos), pos, encoding, *pos)) + { + error = std::string("Invalid parameter '") + *pos + "'."; + break; + } + } } else parsingAnswer = true; } } //----------------------------------------------------------------------------- -void GET_ADMIN::PARSER::ParseAdminParams(const char * el, const char ** attr) +/*void GET_ADMIN::PARSER::ParseAdminParams(const char * el, const char ** attr) { if (!TryParse(propertyParsers, ToLower(el), attr)) error = "Invalid parameter."; -} +}*/