X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/8f1d13e63e83c5f590d59f6d09f2d1dae69ba526..87300676aa712b358ab98beaa5082b7a19e5d97a:/stglibs/srvconf.lib/include/stg/servconf.h?ds=sidebyside diff --git a/stglibs/srvconf.lib/include/stg/servconf.h b/stglibs/srvconf.lib/include/stg/servconf.h index b9705851..6bf33ddb 100644 --- a/stglibs/srvconf.lib/include/stg/servconf.h +++ b/stglibs/srvconf.lib/include/stg/servconf.h @@ -27,17 +27,15 @@ #ifndef SERVCONF_H #define SERVCONF_H -#include "netunit.h" - -#include "stg/parser_auth_by.h" -#include "stg/os_int.h" -#include "stg/const.h" +#include #include #include #include -#include +#include "stg/os_int.h" +#include "stg/const.h" +#include "netunit.h" void Start(void *data, const char *el, const char **attr); void End(void *data, const char *el); @@ -104,12 +102,22 @@ typedef void(*RecvServerInfoDataCb_t)(SERVERINFO * si, void * data); typedef int(*RecvChgUserCb_t)(const char * asnwer, void * data); typedef int(*RecvCheckUserCb_t)(const char * answer, void * data); typedef int(*RecvSendMessageCb_t)(const char * answer, void * data); +typedef void(*RecvAuthByDataCb_t)(const std::vector & list, void * data); //----------------------------------------------------------------------------- struct ADMINDATA { char login[ADM_LOGIN_LEN]; }; //----------------------------------------------------------------------------- +class PARSER +{ +public: + PARSER() {} + virtual ~PARSER() {} + virtual int ParseStart(const char *el, const char **attr) = 0; + virtual void ParseEnd(const char *el) = 0; +}; +//----------------------------------------------------------------------------- class PARSER_CHG_USER: public PARSER { public: @@ -122,7 +130,6 @@ private: RecvChgUserCb_t RecvChgUserCb; void * chgUserCbData; int depth; - bool error; }; //----------------------------------------------------------------------------- class PARSER_CHECK_USER: public PARSER @@ -137,7 +144,6 @@ private: RecvCheckUserCb_t RecvCheckUserCb; void * checkUserCbData; int depth; - bool error; }; //----------------------------------------------------------------------------- class PARSER_GET_USERS: public PARSER @@ -156,7 +162,6 @@ private: void * userDataCb; USERDATA user; int depth; - bool error; }; //----------------------------------------------------------------------------- class PARSER_GET_USER: public PARSER @@ -215,13 +220,30 @@ private: RecvSendMessageCb_t RecvSendMessageCb; void * sendMessageCbData; int depth; +}; +//----------------------------------------------------------------------------- +class PARSER_AUTH_BY: public PARSER +{ +public: + PARSER_AUTH_BY(); + int ParseStart(const char *el, const char **attr); + void ParseEnd(const char *el); + void ParseServerInfo(const char *el, const char **attr); + bool GetError(); + void SetRecvCb(RecvAuthByDataCb_t, void * data); +private: + RecvAuthByDataCb_t RecvAuthByDataCb; + void * authByDataCb; + int depth; bool error; + std::vector list; }; //----------------------------------------------------------------------------- class SERVCONF { public: SERVCONF(); + ~SERVCONF(); void SetServer(const char * server); void SetPort(uint16_t port); @@ -229,7 +251,7 @@ public: void SetAdmPassword(const char * password); void SetUserDataRecvCb(RecvUserDataCb_t, void * data); - void SetAuthByCallback(PARSER_AUTH_BY::CALLBACK f, void * data); + void SetGetUserAuthByRecvCb(RecvAuthByDataCb_t, void * data); void SetServerInfoRecvCb(RecvServerInfoDataCb_t, void * data); void SetChgUserCb(RecvChgUserCb_t, void * data); void SetCheckUserCb(RecvCheckUserCb_t, void * data); @@ -239,7 +261,7 @@ public: int GetUsers(); int GetUser(const char * login); int ChgUser(const char * request); - int AuthBy(const char * login); + int GetUserAuthBy(const char * login); // TODO: Remove this shit! int MsgUser(const char * request); int SendMessage(const char * login, const char * message, int prio); @@ -263,7 +285,6 @@ private: PARSER_SEND_MESSAGE parserSendMessage; NETTRANSACT nt; - int parseDepth; std::string errorMsg; int error; @@ -271,14 +292,14 @@ private: RecvUserDataCb_t RecvUserDataCb; RecvUserDataCb_t RecvGetUserDataCb; - PARSER_AUTH_BY::CALLBACK authByCallback; + RecvAuthByDataCb_t RecvAuthByCb; RecvServerInfoDataCb_t RecvServerInfoDataCb; RecvChgUserCb_t RecvChgUserCb; RecvCheckUserCb_t RecvCheckUserCb; RecvSendMessageCb_t RecvSendMessageCb; void * getUserDataDataCb; - void * authByData; + void * getUserAuthByDataCb; void * getUsersDataDataCb; void * getServerInfoDataCb; void * chgUserDataCb;