]> git.stg.codes - stg.git/blob - stglibs/srvconf.lib/include/stg/servconf_types.h
Moved GET_USER and GET_USERS parsers from global scope.
[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
30 #define  STG_HEADER     "SG04"
31 #define  OK_HEADER      "OKHD"
32 #define  ERR_HEADER     "ERHD"
33 #define  OK_LOGIN       "OKLG"
34 #define  ERR_LOGIN      "ERLG"
35 #define  OK_LOGINS      "OKLS"
36 #define  ERR_LOGINS     "ERLS"
37
38 #define  ENC_MSG_LEN    (8)
39
40 namespace STG
41 {
42
43 enum status
44 {
45 st_ok = 0,
46 st_conn_fail,
47 st_send_fail,
48 st_recv_fail,
49 st_header_err,
50 st_login_err,
51 st_logins_err,
52 st_data_err,
53 st_unknown_err,
54 st_dns_err,
55 st_xml_parse_error,
56 st_data_error
57 };
58
59 enum CONF_STATE
60 {
61 confHdr = 0,
62 confLogin,
63 confLoginCipher,
64 confData
65 };
66
67 namespace AUTH_BY
68 {
69
70 typedef std::vector<std::string> INFO;
71 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
72
73 } // namespace AUTH_BY
74
75 namespace SERVER_INFO
76 {
77
78 struct INFO
79 {
80     std::string version;
81     int         tariffNum;
82     int         tariffType;
83     int         usersNum;
84     std::string uname;
85     int         dirNum;
86     std::string dirName[DIR_NUM];
87 };
88 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
89
90 } // namespace SERVER_INFO
91
92 namespace CHECK_USER
93 {
94
95 typedef int (* CALLBACK)(bool result, const std::string & reason, void * data);
96
97 } // namespace CHECK_USER
98
99 namespace GET_USER
100 {
101
102 struct STAT
103 {
104     long long  su[DIR_NUM];
105     long long  sd[DIR_NUM];
106     long long  mu[DIR_NUM];
107     long long  md[DIR_NUM];
108     double     freeMb;
109 };
110
111 struct INFO
112 {
113     std::string login;
114     std::string password;
115     double      cash;
116     double      credit;
117     time_t      creditExpire;
118     double      lastCash;
119     double      prepaidTraff;
120     int         down;
121     int         passive;
122     int         disableDetailStat;
123     int         connected;
124     int         alwaysOnline;
125     uint32_t    ip;
126     std::string ips;
127     std::string tariff;
128     std::string group;
129     std::string note;
130     std::string email;
131     std::string name;
132     std::string address;
133     std::string phone;
134     STAT        stat;
135     std::string userData[USERDATA_NUM];
136 };
137
138 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
139
140 } // namespace GET_USER
141
142 namespace GET_USERS
143 {
144
145 typedef std::vector<GET_USER::INFO> INFO;
146 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
147
148 } // namespace GET_USERS
149
150 } // namespace STG
151
152 #endif