]> git.stg.codes - stg.git/blob - stglibs/srvconf.lib/include/stg/servconf_types.h
Use single simple parser for one-tag answers.
[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 namespace SIMPLE
71 {
72
73 typedef void (* CALLBACK)(bool result, const std::string & reason, void * data);
74
75 } // namespace SIMPLE
76
77 namespace AUTH_BY
78 {
79
80 typedef std::vector<std::string> INFO;
81 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
82
83 } // namespace AUTH_BY
84
85 namespace SERVER_INFO
86 {
87
88 struct INFO
89 {
90     std::string version;
91     int         tariffNum;
92     int         tariffType;
93     int         usersNum;
94     std::string uname;
95     int         dirNum;
96     std::string dirName[DIR_NUM];
97 };
98 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
99
100 } // namespace SERVER_INFO
101
102 namespace GET_USER
103 {
104
105 struct STAT
106 {
107     long long  su[DIR_NUM];
108     long long  sd[DIR_NUM];
109     long long  mu[DIR_NUM];
110     long long  md[DIR_NUM];
111     double     freeMb;
112 };
113
114 struct INFO
115 {
116     std::string login;
117     std::string password;
118     double      cash;
119     double      credit;
120     time_t      creditExpire;
121     double      lastCash;
122     double      prepaidTraff;
123     int         down;
124     int         passive;
125     int         disableDetailStat;
126     int         connected;
127     int         alwaysOnline;
128     uint32_t    ip;
129     std::string ips;
130     std::string tariff;
131     std::string group;
132     std::string note;
133     std::string email;
134     std::string name;
135     std::string address;
136     std::string phone;
137     STAT        stat;
138     std::string userData[USERDATA_NUM];
139 };
140
141 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
142
143 } // namespace GET_USER
144
145 namespace GET_USERS
146 {
147
148 typedef std::vector<GET_USER::INFO> INFO;
149 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
150
151 } // namespace GET_USERS
152
153 namespace GET_ADMIN
154 {
155
156 typedef ADMIN_CONF INFO;
157 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
158
159 }
160
161 namespace GET_ADMINS
162 {
163
164 typedef std::vector<GET_ADMIN::INFO> INFO;
165 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
166
167 }
168
169 } // namespace STG
170
171 #endif