From 5f1252496dfef1724c21421ea470a04d09af7ad0 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sat, 21 Sep 2013 00:35:08 +0300 Subject: [PATCH] Moved CHECK_USER parser from global scope. --- stglibs/srvconf.lib/include/stg/servconf.h | 3 +-- stglibs/srvconf.lib/include/stg/servconf_types.h | 7 +++++++ stglibs/srvconf.lib/parser_auth_by.cpp | 2 +- stglibs/srvconf.lib/parser_check_user.cpp | 12 ++++++------ .../{include/stg => }/parser_check_user.h | 11 +++++++---- stglibs/srvconf.lib/servconf.cpp | 9 +++++---- 6 files changed, 27 insertions(+), 17 deletions(-) rename stglibs/srvconf.lib/{include/stg => }/parser_check_user.h (88%) diff --git a/stglibs/srvconf.lib/include/stg/servconf.h b/stglibs/srvconf.lib/include/stg/servconf.h index 1b4033e3..40311ec2 100644 --- a/stglibs/srvconf.lib/include/stg/servconf.h +++ b/stglibs/srvconf.lib/include/stg/servconf.h @@ -27,7 +27,6 @@ #ifndef __STG_STGLIBS_SERVCONF_H__ #define __STG_STGLIBS_SERVCONF_H__ -#include "stg/parser_check_user.h" #include "stg/parser_get_user.h" #include "stg/parser_get_users.h" #include "stg/parser_chg_user.h" @@ -55,7 +54,7 @@ public: int AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data); int SendMessage(const std::string & request, PARSER_SEND_MESSAGE::CALLBACK f, void * data); int ServerInfo(SERVER_INFO::CALLBACK f, void * data); - int CheckUser(const std::string & login, const std::string & password, PARSER_CHECK_USER::CALLBACK f, void * data); + int CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data); const std::string & GetStrError() const; diff --git a/stglibs/srvconf.lib/include/stg/servconf_types.h b/stglibs/srvconf.lib/include/stg/servconf_types.h index 17432044..21abf0ed 100644 --- a/stglibs/srvconf.lib/include/stg/servconf_types.h +++ b/stglibs/srvconf.lib/include/stg/servconf_types.h @@ -87,6 +87,13 @@ struct INFO typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data); } // namespace SERVER_INFO + +namespace CHECK_USER +{ + +typedef int (* CALLBACK)(bool result, const std::string & reason, void * data); + +} } // namespace STG #endif diff --git a/stglibs/srvconf.lib/parser_auth_by.cpp b/stglibs/srvconf.lib/parser_auth_by.cpp index b3904a1b..34e490ca 100644 --- a/stglibs/srvconf.lib/parser_auth_by.cpp +++ b/stglibs/srvconf.lib/parser_auth_by.cpp @@ -80,7 +80,7 @@ if (depth == 0) } } //----------------------------------------------------------------------------- -void AUTH_BY::PARSER::SetCallback(AUTH_BY::CALLBACK f, void * d) +void AUTH_BY::PARSER::SetCallback(CALLBACK f, void * d) { callback = f; data = d; diff --git a/stglibs/srvconf.lib/parser_check_user.cpp b/stglibs/srvconf.lib/parser_check_user.cpp index 8c150357..0cb37522 100644 --- a/stglibs/srvconf.lib/parser_check_user.cpp +++ b/stglibs/srvconf.lib/parser_check_user.cpp @@ -19,7 +19,7 @@ * Author : Maxim Mamontov */ -#include "stg/parser_check_user.h" +#include "parser_check_user.h" #include @@ -27,14 +27,14 @@ using namespace STG; -PARSER_CHECK_USER::PARSER_CHECK_USER() +CHECK_USER::PARSER::PARSER() : callback(NULL), data(NULL), depth(0) { } //----------------------------------------------------------------------------- -int PARSER_CHECK_USER::ParseStart(const char * el, const char ** attr) +int CHECK_USER::PARSER::ParseStart(const char * el, const char ** attr) { depth++; if (depth == 1) @@ -43,12 +43,12 @@ if (depth == 1) return 0; } //----------------------------------------------------------------------------- -void PARSER_CHECK_USER::ParseEnd(const char *) +void CHECK_USER::PARSER::ParseEnd(const char *) { depth--; } //----------------------------------------------------------------------------- -void PARSER_CHECK_USER::ParseAnswer(const char *, const char **attr) +void CHECK_USER::PARSER::ParseAnswer(const char *, const char **attr) { if (!callback) return; @@ -58,7 +58,7 @@ else callback(false, "Invalid response.", data); } //----------------------------------------------------------------------------- -void PARSER_CHECK_USER::SetCallback(CALLBACK f, void * d) +void CHECK_USER::PARSER::SetCallback(CALLBACK f, void * d) { callback = f; data = d; diff --git a/stglibs/srvconf.lib/include/stg/parser_check_user.h b/stglibs/srvconf.lib/parser_check_user.h similarity index 88% rename from stglibs/srvconf.lib/include/stg/parser_check_user.h rename to stglibs/srvconf.lib/parser_check_user.h index 4e1f498c..11d6ab96 100644 --- a/stglibs/srvconf.lib/include/stg/parser_check_user.h +++ b/stglibs/srvconf.lib/parser_check_user.h @@ -22,19 +22,21 @@ #ifndef __STG_STGLIBS_SRVCONF_PARSER_CHECK_USER_H__ #define __STG_STGLIBS_SRVCONF_PARSER_CHECK_USER_H__ -#include "parser.h" +#include "stg/parser.h" +#include "stg/servconf_types.h" #include namespace STG { +namespace CHECK_USER +{ -class PARSER_CHECK_USER: public PARSER +class PARSER: public STG::PARSER { public: - typedef int (* CALLBACK)(bool result, const std::string & reason, void * data); - PARSER_CHECK_USER(); + PARSER(); int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); void SetCallback(CALLBACK f, void * data); @@ -46,6 +48,7 @@ private: void ParseAnswer(const char * el, const char ** attr); }; +} // namespace CHECK_USER } // namespace STG #endif diff --git a/stglibs/srvconf.lib/servconf.cpp b/stglibs/srvconf.lib/servconf.cpp index 0c24b38a..49d3ab73 100644 --- a/stglibs/srvconf.lib/servconf.cpp +++ b/stglibs/srvconf.lib/servconf.cpp @@ -23,6 +23,7 @@ #include "netunit.h" #include "parser_auth_by.h" #include "parser_server_info.h" +#include "parser_check_user.h" #include "stg/common.h" @@ -45,7 +46,7 @@ public: int AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data); int SendMessage(const std::string & request, PARSER_SEND_MESSAGE::CALLBACK f, void * data); int ServerInfo(SERVER_INFO::CALLBACK f, void * data); - int CheckUser(const std::string & login, const std::string & password, PARSER_CHECK_USER::CALLBACK f, void * data); + int CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data); const std::string & GetStrError() const; static void Start(void * data, const char * el, const char ** attr); @@ -57,7 +58,7 @@ private: AUTH_BY::PARSER parserAuthBy; SERVER_INFO::PARSER parserServerInfo; PARSER_CHG_USER parserChgUser; - PARSER_CHECK_USER parserCheckUser; + CHECK_USER::PARSER parserCheckUser; PARSER_SEND_MESSAGE parserSendMessage; NETTRANSACT nt; @@ -127,7 +128,7 @@ int SERVCONF::ServerInfo(SERVER_INFO::CALLBACK f, void * data) return pImpl->ServerInfo(f, data); } -int SERVCONF::CheckUser(const std::string & login, const std::string & password, PARSER_CHECK_USER::CALLBACK f, void * data) +int SERVCONF::CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data) { return pImpl->CheckUser(login, password, f, data); } @@ -182,7 +183,7 @@ parserSendMessage.SetCallback(f, data); return Exec(request, parserSendMessage); } //----------------------------------------------------------------------------- -int SERVCONF::IMPL::CheckUser(const std::string & login, const std::string & password, PARSER_CHECK_USER::CALLBACK f, void * data) +int SERVCONF::IMPL::CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data) { parserCheckUser.SetCallback(f, data); return Exec("", parserCheckUser); -- 2.44.2