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: 2008/02/09 16:22:18 $
31 //-----------------------------------------------------------------------------
32 void RecvUserData(USERDATA * ud, void * d)
34 // ôÕÔ ×Ù×ÏÄÉÔÓÑ ÞÁÓÔØ ÉÎÆÙ Ï ÐÏÌØÚÏ×ÁÔÅÌÅ, ÎÏ × ud ÐÅÒÅÄÁÅÔÓÑ ×ÓÑ ÉÎÆÁ
35 printf("login: %s password :%s cash:%8.2f ip:%16s\n", ud->login, ud->password, ud->cash, ud->ips);
37 //-----------------------------------------------------------------------------
38 void RecvServerInfoData(SERVERINFO * si, void * d)
40 // ôÕÔ ÔÏÖÅ ÔÏÌØËÏ ÞÁÓÔØ ÉÎÆÙ ×Ù×ÏÄÉÔÓÑ ÎÁ ÜËÒÁÎ
41 printf("uname: %20s\n", si->uname);
42 printf("version: %20s\n", si->version);
43 printf("users: %20d\n", si->usersNum);
44 for (int i = 0; i < DIR_NUM; i++)
46 printf("dir name 1: >%16s<\n", si->dirName[i]);
49 //-----------------------------------------------------------------------------
50 int RecvSetUserAnswer(const char * ans, void * d)
52 printf("ans=%s\n", ans);
53 if (strcasecmp("Ok", ans) == 0)
60 //-----------------------------------------------------------------------------
61 int RecvCheckUserAnswer(const char * ans, void * d)
63 if (strcmp("Ok", ans) == 0)
69 //-----------------------------------------------------------------------------
70 int RecvSendMessageAnswer(const char * ans, void * d)
72 if (strcasecmp("Ok", ans) == 0)
78 //-----------------------------------------------------------------------------
83 bool userExist = false;
86 sc.SetServer("127.0.0.1"); // õÓÔÁÎÁ×ÌÉ×ÁÅÍ ÉÍÑ ÓÅÒ×ÅÒÁ Ó ËÏÔÏÒÇÏ ÚÁÂÉÒÁÔØ ÉÎÆÕ
87 sc.SetPort(5555); // ÁÄÍÉÎÓËÉÊ ÐÏÒÔ ÓÅÒ×ÅÒÁÐÏÒÔ
88 sc.SetAdmLogin("admin"); // ÷ÙÓÔÁ×ÌÑÅÍ ÌÏÇÉÎ É ÐÁÒÏÌØ ÁÄÍÉÎÁ
89 sc.SetAdmPassword("123456");
91 sc.SetUserDataRecvCb(RecvUserData, NULL); // óÔÁ×ÉÍ ËÏÌÂÜË-ÆÕÎËÃÉÉ, ËÏÔÏÒÙÅ
92 sc.SetGetUserDataRecvCb(RecvUserData, NULL); // GET USER
93 sc.SetServerInfoRecvCb(RecvServerInfoData, NULL); // ÂÕÄÕÔ ×ÙÚ×ÁÎÙ ÐÒÉ ÐÏÌÕÞÅÎÉÉ ÉÎÆÏÒÍÁÃÉÉ Ó ÓÅÒ×ÅÒÁ
94 sc.SetChgUserCb(RecvSetUserAnswer, &userExist);
95 sc.SetCheckUserCb(RecvCheckUserAnswer, &userExist);
96 sc.SetSendMessageCb(RecvSendMessageAnswer, &result);
97 printf("--------------- GetServerInfo ---------------\n");
98 ret = sc.GetServerInfo(); // úÁÐÒÁÛÉ×ÁÅÍ ÉÎÆÕ Ï ÓÅÒ×ÅÒÅ. üÔÏ ÍÏÖÎÏ ÉÓÐÏÌØÚÏ×ÁÔØ
99 if (ret != st_ok) // ÄÌÑ ÐÒÏ×ÅÒËÉ ÌÏÇÉÎÁ É ÐÁÒÏÌÑ ÁÄÍÉÎÁ
101 printf("error %d %s\n", ret, sc.GetStrError());
105 /*printf("--------------- GetUsers ---------------\n");
106 ret = sc.GetUsers(); // úÁÐÒÁÛÉ×ÁÅÍ ÉÎÆÕ Ï ÐÏÌØÚÏ×ÁÔÅÌÅ
109 printf("error %d %s\n", ret, sc.GetStrError());
113 printf("--------------- SendMessage ---------------\n");
114 ret = sc.SendMessage("zubr11", "test", 0); //
117 printf("error %d %s\n", ret, sc.GetStrError());
121 printf("SendMessage ok\n");
123 printf("SendMessage failed\n");
127 printf("--------------- GetUser ---------------\n");
128 ret = sc.GetUser("test"); // úÁÐÒÁÛÉ×ÁÅÍ ÉÎÆÕ Ï ÐÏÌØÚÏ×ÁÔÅÌÅ
131 printf("error %d %s\n", ret, sc.GetStrError());
137 printf("--------------- CheckUser ---------------\n");
138 sc.CheckUser("test", "123456");
140 printf("login - ok\n");
142 printf("login failed\n");
144 printf("--------------- ChgUser ON ---------------\n");
146 sprintf(req, "<SetUser> "
147 "<login value=\"test\"/> "
148 "<ips value=\"192.168.111.100\"/> "
149 "<aonline value=\"1\"/> "
150 "<iface value=\"ppp0\"/></SetUser>");
153 printf("chg user ok\n");
155 printf("chg user error\n");
157 printf("--------------- ChgUser OFF ---------------\n");
158 sprintf(req, "<SetUser> "
159 "<login value=\"test\"/> "
160 "<aonline value=\"0\"/> </SetUser>");
164 printf("chg user ok\n");
166 printf("chg user error\n");
170 //-----------------------------------------------------------------------------