2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
23 $Date: 2010/10/04 20:24:14 $
32 #include <sys/types.h>
33 #include <sys/socket.h>
38 #include "stg/users.h"
39 #include "stg/admins.h"
40 #include "stg/tariffs.h"
41 #include "stg/logger.h"
44 #define STG_HEADER "SG04"
45 #define OK_HEADER "OKHD"
46 #define ERR_HEADER "ERHD"
47 #define OK_LOGIN "OKLG"
48 #define ERR_LOGIN "ERLG"
49 #define OK_LOGINS "OKLS"
50 #define ERR_LOGINS "ERLS"
52 //-----------------------------------------------------------------------------
55 CONFIGPROTO(PLUGIN_LOGGER & l);
58 void SetPort(uint16_t port);
59 void SetAdmins(ADMINS * a);
60 void SetUsers(USERS * u);
61 void SetTariffs(TARIFFS * t);
62 void SetStore(STORE * s);
63 void SetStgSettings(const SETTINGS * s);
64 uint32_t GetAdminIP() const { return adminIP; }
67 const std::string & GetStrError() const { return errorStr; }
71 CONFIGPROTO(const CONFIGPROTO & rvalue);
72 CONFIGPROTO & operator=(const CONFIGPROTO & rvalue);
74 int RecvHdr(int sock);
75 int RecvLogin(int sock);
76 int SendLoginAnswer(int sock);
77 int SendHdrAnswer(int sock, int err);
78 int RecvLoginS(int sock);
79 int SendLoginSAnswer(int sock, int err);
80 int RecvData(int sock);
81 int SendDataAnswer(int sock);
82 void SendError(const char * text);
83 void WriteLogAccessFailed(uint32_t ip);
87 std::list<std::string> answerList;
88 std::list<std::string> requestList;
90 std::string adminLogin;
92 pthread_t thrReciveSendConf;
96 PLUGIN_LOGGER & logger;
100 PARSER_GET_SERVER_INFO parserGetServInfo;
102 PARSER_GET_USERS parserGetUsers;
103 PARSER_GET_USER parserGetUser;
104 PARSER_CHG_USER parserChgUser;
105 PARSER_ADD_USER parserAddUser;
106 PARSER_DEL_USER parserDelUser;
107 PARSER_CHECK_USER parserCheckUser;
108 PARSER_SEND_MESSAGE parserSendMessage;
110 PARSER_GET_ADMINS parserGetAdmins;
111 PARSER_ADD_ADMIN parserAddAdmin;
112 PARSER_DEL_ADMIN parserDelAdmin;
113 PARSER_CHG_ADMIN parserChgAdmin;
115 PARSER_GET_TARIFFS parserGetTariffs;
116 PARSER_ADD_TARIFF parserAddTariff;
117 PARSER_DEL_TARIFF parserDelTariff;
118 PARSER_CHG_TARIFF parserChgTariff;
122 BASE_PARSER * currParser;
123 vector<BASE_PARSER *> dataParser;
125 XML_Parser xmlParser;
127 std::string errorStr;
129 friend void ParseXMLStart(void *data, const char *el, const char **attr);
130 friend void ParseXMLEnd(void *data, const char *el);
132 //-----------------------------------------------------------------------------
133 #endif //CONFIGPROTO_H