From 84c7cad404a6073453edcb2045a57642d5744811 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Tue, 8 Oct 2013 15:56:11 +0300 Subject: [PATCH] Use single simple parser for one-tag answers. --- stglibs/srvconf.lib/Makefile | 5 +- stglibs/srvconf.lib/include/stg/servconf.h | 12 ++-- .../srvconf.lib/include/stg/servconf_types.h | 49 ++-------------- stglibs/srvconf.lib/parsers/add_admin.h | 51 ----------------- stglibs/srvconf.lib/parsers/check_user.cpp | 57 ------------------- stglibs/srvconf.lib/parsers/check_user.h | 52 ----------------- stglibs/srvconf.lib/parsers/chg_admin.cpp | 4 +- stglibs/srvconf.lib/parsers/chg_admin.h | 4 +- stglibs/srvconf.lib/parsers/chg_user.cpp | 2 +- stglibs/srvconf.lib/parsers/chg_user.h | 4 +- stglibs/srvconf.lib/parsers/del_admin.cpp | 57 ------------------- stglibs/srvconf.lib/parsers/send_message.cpp | 57 ------------------- stglibs/srvconf.lib/parsers/send_message.h | 52 ----------------- .../parsers/{add_admin.cpp => simple.cpp} | 18 +++--- .../parsers/{del_admin.h => simple.h} | 13 +++-- stglibs/srvconf.lib/servconf.cpp | 33 ++++++----- 16 files changed, 56 insertions(+), 414 deletions(-) delete mode 100644 stglibs/srvconf.lib/parsers/add_admin.h delete mode 100644 stglibs/srvconf.lib/parsers/check_user.cpp delete mode 100644 stglibs/srvconf.lib/parsers/check_user.h delete mode 100644 stglibs/srvconf.lib/parsers/del_admin.cpp delete mode 100644 stglibs/srvconf.lib/parsers/send_message.cpp delete mode 100644 stglibs/srvconf.lib/parsers/send_message.h rename stglibs/srvconf.lib/parsers/{add_admin.cpp => simple.cpp} (77%) rename stglibs/srvconf.lib/parsers/{del_admin.h => simple.h} (83%) diff --git a/stglibs/srvconf.lib/Makefile b/stglibs/srvconf.lib/Makefile index 09111f1b..60177a97 100644 --- a/stglibs/srvconf.lib/Makefile +++ b/stglibs/srvconf.lib/Makefile @@ -9,18 +9,15 @@ STGLIBS = -lstgcommon \ LIBS = -lexpat SRCS = parsers/property.cpp \ + parsers/simple.cpp \ parsers/server_info.cpp \ parsers/get_admins.cpp \ parsers/get_admin.cpp \ parsers/chg_admin.cpp \ - parsers/add_admin.cpp \ - parsers/del_admin.cpp \ parsers/auth_by.cpp \ - parsers/check_user.cpp \ parsers/get_user.cpp \ parsers/get_users.cpp \ parsers/chg_user.cpp \ - parsers/send_message.cpp \ netunit.cpp \ servconf.cpp diff --git a/stglibs/srvconf.lib/include/stg/servconf.h b/stglibs/srvconf.lib/include/stg/servconf.h index d4ab651c..0b929317 100644 --- a/stglibs/srvconf.lib/include/stg/servconf.h +++ b/stglibs/srvconf.lib/include/stg/servconf.h @@ -48,16 +48,16 @@ public: int GetAdmins(GET_ADMINS::CALLBACK f, void * data); int GetAdmin(const std::string & login, GET_ADMIN::CALLBACK f, void * data); - int ChgAdmin(const ADMIN_CONF_RES & conf, CHG_ADMIN::CALLBACK f, void * data); - int AddAdmin(const std::string & login, const ADMIN_CONF & conf, ADD_ADMIN::CALLBACK f, void * data); - int DelAdmin(const std::string & login, DEL_ADMIN::CALLBACK f, void * data); + int ChgAdmin(const ADMIN_CONF_RES & conf, SIMPLE::CALLBACK f, void * data); + int AddAdmin(const std::string & login, const ADMIN_CONF & conf, SIMPLE::CALLBACK f, void * data); + int DelAdmin(const std::string & login, SIMPLE::CALLBACK f, void * data); int GetUsers(GET_USERS::CALLBACK f, void * data); int GetUser(const std::string & login, GET_USER::CALLBACK f, void * data); - int ChgUser(const std::string & request, CHG_USER::CALLBACK f, void * data); + int ChgUser(const std::string & request, SIMPLE::CALLBACK f, void * data); int AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data); - int SendMessage(const std::string & request, SEND_MESSAGE::CALLBACK f, void * data); - int CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data); + int SendMessage(const std::string & request, SIMPLE::CALLBACK f, void * data); + int CheckUser(const std::string & login, const std::string & password, SIMPLE::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 09f9b970..f46aadb5 100644 --- a/stglibs/srvconf.lib/include/stg/servconf_types.h +++ b/stglibs/srvconf.lib/include/stg/servconf_types.h @@ -67,7 +67,12 @@ confLoginCipher, confData }; -typedef void (* SIMPLE_CALLBACK)(bool result, const std::string & reason, void * data); +namespace SIMPLE +{ + +typedef void (* CALLBACK)(bool result, const std::string & reason, void * data); + +} // namespace SIMPLE namespace AUTH_BY { @@ -94,13 +99,6 @@ typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & } // namespace SERVER_INFO -namespace CHECK_USER -{ - -typedef SIMPLE_CALLBACK CALLBACK; - -} // namespace CHECK_USER - namespace GET_USER { @@ -152,20 +150,6 @@ typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & } // namespace GET_USERS -namespace CHG_USER -{ - -typedef SIMPLE_CALLBACK CALLBACK; - -} - -namespace SEND_MESSAGE -{ - -typedef SIMPLE_CALLBACK CALLBACK; - -} - namespace GET_ADMIN { @@ -182,27 +166,6 @@ typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & } -namespace ADD_ADMIN -{ - -typedef SIMPLE_CALLBACK CALLBACK; - -} - -namespace DEL_ADMIN -{ - -typedef SIMPLE_CALLBACK CALLBACK; - -} - -namespace CHG_ADMIN -{ - -typedef SIMPLE_CALLBACK CALLBACK; - -} - } // namespace STG #endif diff --git a/stglibs/srvconf.lib/parsers/add_admin.h b/stglibs/srvconf.lib/parsers/add_admin.h deleted file mode 100644 index a1349d97..00000000 --- a/stglibs/srvconf.lib/parsers/add_admin.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Maxim Mamontov - */ - -#ifndef __STG_STGLIBS_SRVCONF_PARSER_ADD_ADMIN_H__ -#define __STG_STGLIBS_SRVCONF_PARSER_ADD_ADMIN_H__ - -#include "base.h" - -#include "stg/servconf_types.h" - -namespace STG -{ -namespace ADD_ADMIN -{ - -class PARSER: public STG::PARSER -{ -public: - PARSER(CALLBACK f, void * data); - int ParseStart(const char * el, const char ** attr); - void ParseEnd(const char * el); - -private: - CALLBACK callback; - void * data; - int depth; - - void ParseAnswer(const char * el, const char ** attr); -}; - -} // namespace ADD_ADMIN -} // namespace STG - -#endif diff --git a/stglibs/srvconf.lib/parsers/check_user.cpp b/stglibs/srvconf.lib/parsers/check_user.cpp deleted file mode 100644 index 5f131292..00000000 --- a/stglibs/srvconf.lib/parsers/check_user.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Boris Mikhailenko - * Author : Maxim Mamontov - */ - -#include "check_user.h" - -#include - -using namespace STG; - -CHECK_USER::PARSER::PARSER(CALLBACK f, void * d) - : callback(f), - data(d), - depth(0) -{ -} -//----------------------------------------------------------------------------- -int CHECK_USER::PARSER::ParseStart(const char * el, const char ** attr) -{ -depth++; -if (depth == 1) - if (strcasecmp(el, "CheckUser") == 0) - ParseAnswer(el, attr); -return 0; -} -//----------------------------------------------------------------------------- -void CHECK_USER::PARSER::ParseEnd(const char *) -{ -depth--; -} -//----------------------------------------------------------------------------- -void CHECK_USER::PARSER::ParseAnswer(const char *, const char **attr) -{ -if (!callback) - return; -if (attr && attr[0] && attr[1] && strcasecmp(attr[0], "value") == 0) - callback(strcasecmp(attr[1], "ok") == 0, attr[2] && attr[3] ? attr[3] : "", data); -else - callback(false, "Invalid response.", data); -} diff --git a/stglibs/srvconf.lib/parsers/check_user.h b/stglibs/srvconf.lib/parsers/check_user.h deleted file mode 100644 index 71dfec13..00000000 --- a/stglibs/srvconf.lib/parsers/check_user.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Boris Mikhailenko - * Author : Maxim Mamontov - */ - -#ifndef __STG_STGLIBS_SRVCONF_PARSER_CHECK_USER_H__ -#define __STG_STGLIBS_SRVCONF_PARSER_CHECK_USER_H__ - -#include "base.h" - -#include "stg/servconf_types.h" - -namespace STG -{ -namespace CHECK_USER -{ - -class PARSER: public STG::PARSER -{ -public: - PARSER(CALLBACK f, void * data); - int ParseStart(const char * el, const char ** attr); - void ParseEnd(const char * el); - -private: - CALLBACK callback; - void * data; - int depth; - - void ParseAnswer(const char * el, const char ** attr); -}; - -} // namespace CHECK_USER -} // namespace STG - -#endif diff --git a/stglibs/srvconf.lib/parsers/chg_admin.cpp b/stglibs/srvconf.lib/parsers/chg_admin.cpp index 6edcec1c..de918514 100644 --- a/stglibs/srvconf.lib/parsers/chg_admin.cpp +++ b/stglibs/srvconf.lib/parsers/chg_admin.cpp @@ -27,7 +27,7 @@ using namespace STG; -CHG_ADMIN::PARSER::PARSER(CALLBACK f, void * d) +CHG_ADMIN::PARSER::PARSER(SIMPLE::CALLBACK f, void * d) : callback(f), data(d), depth(0) @@ -53,7 +53,7 @@ void CHG_ADMIN::PARSER::ParseAnswer(const char * /*el*/, const char ** attr) if (!callback) return; if (attr && attr[0] && attr[1]) - callback(strcasecmp(attr[1], "ok") == 0, attr[2] && attr[3] ? attr[3] : "", data); + callback(strcasecmp(attr[1], "ok") == 0, attr[1], data); else callback(false, "Invalid response.", data); } diff --git a/stglibs/srvconf.lib/parsers/chg_admin.h b/stglibs/srvconf.lib/parsers/chg_admin.h index 03da22c3..9fd38104 100644 --- a/stglibs/srvconf.lib/parsers/chg_admin.h +++ b/stglibs/srvconf.lib/parsers/chg_admin.h @@ -37,12 +37,12 @@ namespace CHG_ADMIN class PARSER: public STG::PARSER { public: - PARSER(CALLBACK f, void * data); + PARSER(SIMPLE::CALLBACK f, void * data); int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); private: - CALLBACK callback; + SIMPLE::CALLBACK callback; void * data; int depth; diff --git a/stglibs/srvconf.lib/parsers/chg_user.cpp b/stglibs/srvconf.lib/parsers/chg_user.cpp index f05c21fd..a656c287 100644 --- a/stglibs/srvconf.lib/parsers/chg_user.cpp +++ b/stglibs/srvconf.lib/parsers/chg_user.cpp @@ -25,7 +25,7 @@ using namespace STG; -CHG_USER::PARSER::PARSER(CALLBACK f, void * d) +CHG_USER::PARSER::PARSER(SIMPLE::CALLBACK f, void * d) : callback(f), data(d), depth(0) diff --git a/stglibs/srvconf.lib/parsers/chg_user.h b/stglibs/srvconf.lib/parsers/chg_user.h index c3ec1888..6bc76fde 100644 --- a/stglibs/srvconf.lib/parsers/chg_user.h +++ b/stglibs/srvconf.lib/parsers/chg_user.h @@ -34,12 +34,12 @@ namespace CHG_USER class PARSER: public STG::PARSER { public: - PARSER(CALLBACK f, void * data); + PARSER(SIMPLE::CALLBACK f, void * data); int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); private: - CALLBACK callback; + SIMPLE::CALLBACK callback; void * data; int depth; diff --git a/stglibs/srvconf.lib/parsers/del_admin.cpp b/stglibs/srvconf.lib/parsers/del_admin.cpp deleted file mode 100644 index 2357cbc4..00000000 --- a/stglibs/srvconf.lib/parsers/del_admin.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Boris Mikhailenko - * Author : Maxim Mamontov - */ - -#include "del_admin.h" - -#include - -using namespace STG; - -DEL_ADMIN::PARSER::PARSER(CALLBACK f, void * d) - : callback(f), - data(d), - depth(0) -{ -} -//----------------------------------------------------------------------------- -int DEL_ADMIN::PARSER::ParseStart(const char *el, const char **attr) -{ -depth++; -if (depth == 1) - if (strcasecmp(el, "DelAdmin") == 0) - ParseAnswer(el, attr); -return 0; -} -//----------------------------------------------------------------------------- -void DEL_ADMIN::PARSER::ParseEnd(const char *) -{ -depth--; -} -//----------------------------------------------------------------------------- -void DEL_ADMIN::PARSER::ParseAnswer(const char * /*el*/, const char ** attr) -{ -if (!callback) - return; -if (attr && attr[0] && attr[1]) - callback(strcasecmp(attr[1], "ok") == 0, attr[2] && attr[3] ? attr[3] : "", data); -else - callback(false, "Invalid response.", data); -} diff --git a/stglibs/srvconf.lib/parsers/send_message.cpp b/stglibs/srvconf.lib/parsers/send_message.cpp deleted file mode 100644 index 053583f4..00000000 --- a/stglibs/srvconf.lib/parsers/send_message.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Boris Mikhailenko - * Author : Maxim Mamontov - */ - -#include "send_message.h" - -#include - -using namespace STG; - -SEND_MESSAGE::PARSER::PARSER(CALLBACK f, void * d) - : callback(f), - data(d), - depth(0) -{ -} -//----------------------------------------------------------------------------- -int SEND_MESSAGE::PARSER::ParseStart(const char * el, const char ** attr) -{ -depth++; -if (depth == 1) - if (strcasecmp(el, "SendMessageResult") == 0) - ParseAnswer(el, attr); -return 0; -} -//----------------------------------------------------------------------------- -void SEND_MESSAGE::PARSER::ParseEnd(const char * /*el*/) -{ -depth--; -} -//----------------------------------------------------------------------------- -void SEND_MESSAGE::PARSER::ParseAnswer(const char * /*el*/, const char **attr) -{ -if (!callback) - return; -if (attr && attr[0] && attr[1]) - callback(strcasecmp(attr[1], "ok") == 0, attr[1], data); -else - callback(false, "Invalid response.", data); -} diff --git a/stglibs/srvconf.lib/parsers/send_message.h b/stglibs/srvconf.lib/parsers/send_message.h deleted file mode 100644 index 13132a0d..00000000 --- a/stglibs/srvconf.lib/parsers/send_message.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Boris Mikhailenko - * Author : Maxim Mamontov - */ - -#ifndef __STG_STGLIBS_SRVCONF_PARSER_SEND_MESSAGE_H__ -#define __STG_STGLIBS_SRVCONF_PARSER_SEND_MESSAGE_H__ - -#include "base.h" - -#include "stg/servconf_types.h" - -namespace STG -{ -namespace SEND_MESSAGE -{ - -class PARSER: public STG::PARSER -{ -public: - PARSER(CALLBACK f, void * data); - int ParseStart(const char * el, const char ** attr); - void ParseEnd(const char * el); - -private: - CALLBACK callback; - void * data; - int depth; - - void ParseAnswer(const char * el, const char ** attr); -}; - -} // namespace SEND_MESSAGE -} // namespace STG - -#endif diff --git a/stglibs/srvconf.lib/parsers/add_admin.cpp b/stglibs/srvconf.lib/parsers/simple.cpp similarity index 77% rename from stglibs/srvconf.lib/parsers/add_admin.cpp rename to stglibs/srvconf.lib/parsers/simple.cpp index 786fc1e5..89537f2c 100644 --- a/stglibs/srvconf.lib/parsers/add_admin.cpp +++ b/stglibs/srvconf.lib/parsers/simple.cpp @@ -15,43 +15,43 @@ */ /* - * Author : Boris Mikhailenko * Author : Maxim Mamontov */ -#include "add_admin.h" +#include "simple.h" #include using namespace STG; -ADD_ADMIN::PARSER::PARSER(CALLBACK f, void * d) - : callback(f), +SIMPLE::PARSER::PARSER(const std::string & t, CALLBACK f, void * d) + : tag(t), + callback(f), data(d), depth(0) { } //----------------------------------------------------------------------------- -int ADD_ADMIN::PARSER::ParseStart(const char *el, const char **attr) +int SIMPLE::PARSER::ParseStart(const char *el, const char **attr) { depth++; if (depth == 1) - if (strcasecmp(el, "AddAdmin") == 0) + if (strcasecmp(el, tag.c_str()) == 0) ParseAnswer(el, attr); return 0; } //----------------------------------------------------------------------------- -void ADD_ADMIN::PARSER::ParseEnd(const char *) +void SIMPLE::PARSER::ParseEnd(const char *) { depth--; } //----------------------------------------------------------------------------- -void ADD_ADMIN::PARSER::ParseAnswer(const char * /*el*/, const char ** attr) +void SIMPLE::PARSER::ParseAnswer(const char * /*el*/, const char ** attr) { if (!callback) return; if (attr && attr[0] && attr[1]) - callback(strcasecmp(attr[1], "ok") == 0, attr[2] && attr[3] ? attr[3] : "", data); + callback(strcasecmp(attr[1], "ok") == 0, attr[2] && attr[3] ? attr[3] : attr[1], data); else callback(false, "Invalid response.", data); } diff --git a/stglibs/srvconf.lib/parsers/del_admin.h b/stglibs/srvconf.lib/parsers/simple.h similarity index 83% rename from stglibs/srvconf.lib/parsers/del_admin.h rename to stglibs/srvconf.lib/parsers/simple.h index ec44ef62..03c950bc 100644 --- a/stglibs/srvconf.lib/parsers/del_admin.h +++ b/stglibs/srvconf.lib/parsers/simple.h @@ -18,26 +18,29 @@ * Author : Maxim Mamontov */ -#ifndef __STG_STGLIBS_SRVCONF_PARSER_DEL_ADMIN_H__ -#define __STG_STGLIBS_SRVCONF_PARSER_DEL_ADMIN_H__ +#ifndef __STG_STGLIBS_SRVCONF_PARSER_SIMPLE_H__ +#define __STG_STGLIBS_SRVCONF_PARSER_SIMPLE_H__ #include "base.h" #include "stg/servconf_types.h" +#include + namespace STG { -namespace DEL_ADMIN +namespace SIMPLE { class PARSER: public STG::PARSER { public: - PARSER(CALLBACK f, void * data); + PARSER(const std::string & tag, CALLBACK f, void * data); int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); private: + std::string tag; CALLBACK callback; void * data; int depth; @@ -45,7 +48,7 @@ private: void ParseAnswer(const char * el, const char ** attr); }; -} // namespace DEL_ADMIN +} // namespace SIMPLE } // namespace STG #endif diff --git a/stglibs/srvconf.lib/servconf.cpp b/stglibs/srvconf.lib/servconf.cpp index d2241b0e..e8e07e10 100644 --- a/stglibs/srvconf.lib/servconf.cpp +++ b/stglibs/srvconf.lib/servconf.cpp @@ -22,20 +22,18 @@ #include "netunit.h" +#include "parsers/simple.h" + #include "parsers/server_info.h" #include "parsers/get_admins.h" #include "parsers/get_admin.h" #include "parsers/chg_admin.h" -#include "parsers/add_admin.h" -#include "parsers/del_admin.h" #include "parsers/auth_by.h" -#include "parsers/check_user.h" #include "parsers/get_users.h" #include "parsers/get_user.h" #include "parsers/chg_user.h" -#include "parsers/send_message.h" #include "parsers/base.h" @@ -65,6 +63,13 @@ public: return ExecImpl(request, cp); } + template + int Exec(const std::string & tag, const std::string & request, C callback, void * data) + { + P cp(tag, callback, data); + return ExecImpl(request, cp); + } + private: NETTRANSACT nt; @@ -119,22 +124,22 @@ int SERVCONF::GetAdmin(const std::string & login, GET_ADMIN::CALLBACK f, void * return pImpl->Exec("", f, data); } -int SERVCONF::ChgAdmin(const ADMIN_CONF_RES & conf, CHG_ADMIN::CALLBACK f, void * data) +int SERVCONF::ChgAdmin(const ADMIN_CONF_RES & conf, SIMPLE::CALLBACK f, void * data) { return pImpl->Exec("", f, data); } -int SERVCONF::AddAdmin(const std::string & login, const ADMIN_CONF & conf, ADD_ADMIN::CALLBACK f, void * data) +int SERVCONF::AddAdmin(const std::string & login, const ADMIN_CONF & conf, SIMPLE::CALLBACK f, void * data) { -int res = pImpl->Exec("", f, data); +int res = pImpl->Exec("AddAdmin", "", f, data); if (res != st_ok) return res; return pImpl->Exec("", f, data); } -int SERVCONF::DelAdmin(const std::string & login, DEL_ADMIN::CALLBACK f, void * data) +int SERVCONF::DelAdmin(const std::string & login, SIMPLE::CALLBACK f, void * data) { -return pImpl->Exec("", f, data); +return pImpl->Exec("DelAdmin", "", f, data); } // -- Users -- @@ -149,7 +154,7 @@ int SERVCONF::GetUser(const std::string & login, GET_USER::CALLBACK f, void * da return pImpl->Exec("", f, data); } -int SERVCONF::ChgUser(const std::string & request, CHG_USER::CALLBACK f, void * data) +int SERVCONF::ChgUser(const std::string & request, SIMPLE::CALLBACK f, void * data) { return pImpl->Exec(request, f, data); } @@ -159,14 +164,14 @@ int SERVCONF::AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data return pImpl->Exec("", f, data); } -int SERVCONF::SendMessage(const std::string & request, SEND_MESSAGE::CALLBACK f, void * data) +int SERVCONF::SendMessage(const std::string & request, SIMPLE::CALLBACK f, void * data) { -return pImpl->Exec(request, f, data); +return pImpl->Exec("SendMessage", request, f, data); } -int SERVCONF::CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data) +int SERVCONF::CheckUser(const std::string & login, const std::string & password, SIMPLE::CALLBACK f, void * data) { -return pImpl->Exec("", f, data); +return pImpl->Exec("CheckUser", "", f, data); } const std::string & SERVCONF::GetStrError() const -- 2.44.2