]> git.stg.codes - stg.git/blob - stglibs/srvconf.lib/include/stg/servconf_types.h
Simplified parser interfaces.
[stg.git] / stglibs / srvconf.lib / include / stg / servconf_types.h
1 /*
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.
6  *
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.
11  *
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
15  */
16
17 /*
18  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
19  */
20
21 #ifndef __STG_STGLIBS_SRVCONF_TYPES_H__
22 #define __STG_STGLIBS_SRVCONF_TYPES_H__
23
24 #include "stg/const.h" // DIR_NUM
25 #include "stg/os_int.h" // uint32_t, etc...
26
27 #include <string>
28 #include <vector>
29 #include <ctime>
30
31 #define  STG_HEADER     "SG04"
32 #define  OK_HEADER      "OKHD"
33 #define  ERR_HEADER     "ERHD"
34 #define  OK_LOGIN       "OKLG"
35 #define  ERR_LOGIN      "ERLG"
36 #define  OK_LOGINS      "OKLS"
37 #define  ERR_LOGINS     "ERLS"
38
39 #define  ENC_MSG_LEN    (8)
40
41 struct ADMIN_CONF;
42
43 namespace STG
44 {
45
46 enum status
47 {
48 st_ok = 0,
49 st_conn_fail,
50 st_send_fail,
51 st_recv_fail,
52 st_header_err,
53 st_login_err,
54 st_logins_err,
55 st_data_err,
56 st_unknown_err,
57 st_dns_err,
58 st_xml_parse_error,
59 st_data_error
60 };
61
62 enum CONF_STATE
63 {
64 confHdr = 0,
65 confLogin,
66 confLoginCipher,
67 confData
68 };
69
70 typedef void (* SIMPLE_CALLBACK)(bool result, const std::string & reason, void * data);
71
72 namespace AUTH_BY
73 {
74
75 typedef std::vector<std::string> INFO;
76 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
77
78 } // namespace AUTH_BY
79
80 namespace SERVER_INFO
81 {
82
83 struct INFO
84 {
85     std::string version;
86     int         tariffNum;
87     int         tariffType;
88     int         usersNum;
89     std::string uname;
90     int         dirNum;
91     std::string dirName[DIR_NUM];
92 };
93 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
94
95 } // namespace SERVER_INFO
96
97 namespace CHECK_USER
98 {
99
100 typedef SIMPLE_CALLBACK CALLBACK;
101
102 } // namespace CHECK_USER
103
104 namespace GET_USER
105 {
106
107 struct STAT
108 {
109     long long  su[DIR_NUM];
110     long long  sd[DIR_NUM];
111     long long  mu[DIR_NUM];
112     long long  md[DIR_NUM];
113     double     freeMb;
114 };
115
116 struct INFO
117 {
118     std::string login;
119     std::string password;
120     double      cash;
121     double      credit;
122     time_t      creditExpire;
123     double      lastCash;
124     double      prepaidTraff;
125     int         down;
126     int         passive;
127     int         disableDetailStat;
128     int         connected;
129     int         alwaysOnline;
130     uint32_t    ip;
131     std::string ips;
132     std::string tariff;
133     std::string group;
134     std::string note;
135     std::string email;
136     std::string name;
137     std::string address;
138     std::string phone;
139     STAT        stat;
140     std::string userData[USERDATA_NUM];
141 };
142
143 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
144
145 } // namespace GET_USER
146
147 namespace GET_USERS
148 {
149
150 typedef std::vector<GET_USER::INFO> INFO;
151 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
152
153 } // namespace GET_USERS
154
155 namespace CHG_USER
156 {
157
158 typedef SIMPLE_CALLBACK CALLBACK;
159
160 }
161
162 namespace SEND_MESSAGE
163 {
164
165 typedef SIMPLE_CALLBACK CALLBACK;
166
167 }
168
169 namespace GET_ADMIN
170 {
171
172 typedef ADMIN_CONF INFO;
173 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
174
175 }
176
177 namespace GET_ADMINS
178 {
179
180 typedef std::vector<GET_ADMIN::INFO> INFO;
181 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
182
183 }
184
185 namespace ADD_ADMIN
186 {
187
188 typedef SIMPLE_CALLBACK CALLBACK;
189
190 }
191
192 namespace DEL_ADMIN
193 {
194
195 typedef SIMPLE_CALLBACK CALLBACK;
196
197 }
198
199 namespace CHG_ADMIN
200 {
201
202 typedef SIMPLE_CALLBACK CALLBACK;
203
204 }
205
206 } // namespace STG
207
208 #endif