Debian Codegraph @

netcon/mtclient/chat_api.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifdef WIN32
20 #include "windows.h"
21 #endif
22
23 #include <cstdio>
24 #include <cstring>
25
26 #if defined(POSIXcxx . . $ `<built-in>:477:9`!)
27 #include <sys/time.h>
28 #include <unistd.h>
29 #endif
30
31 #include "chat_api.h"cxx . . $ `<file>/netcon/mtclient/chat_api.h`/
32 #include "grdefs.h"cxx . . $ `<file>/lib/grdefs.h`/
33 #include "mtstrings.h"cxx . . $ `<file>/netcon/mtclient/mtstrings.h`/
34 #include "networking.h"cxx . . $ `<file>/lib/networking.h`/
35
36 extern const char *GetStringcxx . . $ GetString(f7ae7e56280f18ae).(int d);
37
38 typedef void *(*mem_malloc_fpcxx . . $ mem_malloc_fp#)(int size);
39 extern mem_malloc_fpcxx . . $ mem_malloc_fp# DLLmem_malloccxx . . $ DLLmem_malloc.;
40
41 typedef void (*mem_free_fpcxx . . $ mem_free_fp#)(void *memblock);
42 extern mem_free_fpcxx . . $ mem_free_fp# DLLmem_freecxx . . $ DLLmem_free.;
43
44 typedef int (*nw_Asyncgethostbyname_fpcxx . . $ nw_Asyncgethostbyname_fp#)(uint32_tcxx . . $ uint32_t# *ip, int command, const char *hostname);
45 extern nw_Asyncgethostbyname_fpcxx . . $ nw_Asyncgethostbyname_fp# DLLnw_Asyncgethostbynamecxx . . $ DLLnw_Asyncgethostbyname.;
46
47 typedef int (*PollUI_fpcxx . . $ PollUI_fp#)();
48 extern PollUI_fpcxx . . $ PollUI_fp# DLLPollUIcxx . . $ DLLPollUI.;
49
50 #ifndef RELEASE
51 #define DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(...) DLLDebug_ConsolePrintf(__VA_ARGS__)
52 #else
53 #define DLLmprintf(...)
54 #endif
55
56 typedef void (*Debug_ConsolePrintf_fpcxx . . $ Debug_ConsolePrintf_fp#)(int n, const char *format, ...);
57 extern Debug_ConsolePrintf_fpcxx . . $ Debug_ConsolePrintf_fp# DLLDebug_ConsolePrintfcxx . . $ DLLDebug_ConsolePrintf.;
58 #define MAXCHATBUFFERcxx . . $ `netcon/mtclient/chat_api.cpp:58:9`! 500
59
60 SOCKETcxx . . $ `lib/networking.h:217:9`! Chatsockcxx . . $ Chatsock.;
61 SOCKADDR_INcxx . . $ `lib/networking.h:219:9`! Chataddrcxx . . $ Chataddr.;
62 int Socket_connectingcxx . . $ Socket_connecting. = 0;
63 char Nick_namecxx . . $ Nick_name.[33];
64 char Orignial_nick_namecxx . . $ Orignial_nick_name.[33];
65 int Nick_varietycxx . . $ Nick_variety. = 0;
66 char szChat_channelcxx . . $ szChat_channel.[33] = "";
67 char Input_chat_buffercxx . . $ Input_chat_buffer.[MAXCHATBUFFERcxx . . $ `netcon/mtclient/chat_api.cpp:58:9`!] = "";
68 char Chat_tracker_idcxx . . $ Chat_tracker_id.[33];
69 char Getting_user_channel_info_forcxx . . $ Getting_user_channel_info_for.[33] = "";
70 char Getting_user_tracker_info_forcxx . . $ Getting_user_tracker_info_for.[33] = "";
71 int Getting_user_channel_errorcxx . . $ Getting_user_channel_error. = 0;
72 int Getting_user_tracker_errorcxx . . $ Getting_user_tracker_error. = 0;
73 char User_req_tracker_idcxx . . $ User_req_tracker_id.[100] = ""; // These are oversized for saftey
74 char User_req_channelcxx . . $ User_req_channel.[100] = "";
75 char *User_listcxx . . $ User_list. = nullptr;
76 char *Chan_listcxx . . $ Chan_list. = nullptr;
77 int Socket_connectedcxx . . $ Socket_connected. = 0;
78 int Chat_server_connectedcxx . . $ Chat_server_connected. = 0;
79 int Joining_channelcxx . . $ Joining_channel. = 0;
80 int Joined_channelcxx . . $ Joined_channel. = 0;
81 int GettingChannelListcxx . . $ GettingChannelList. = 0;
82 int GettingUserTIDcxx . . $ GettingUserTID. = 0;
83 int GettingUserChannelcxx . . $ GettingUserChannel. = 0;
84
85 Chat_usercxx . . $ Chat_user# *Firstusercxx . . $ Firstuser., *Currusercxx . . $ Curruser.;
86 Chat_commandcxx . . $ Chat_command# *Firstcommandcxx . . $ Firstcommand., *Currcommandcxx . . $ Currcommand.;
87 Chat_channelcxx . . $ Chat_channel# *Firstchannelcxx . . $ Firstchannel., *Currchannelcxx . . $ Currchannel.;
88
89 void ChatInitcxx . . $ ChatInit(49f6e7a06ebc5aa8).() {
90 Socket_connectingcxx . . $ Socket_connecting. = 0;
91 Nick_namecxx . . $ Nick_name.[0] = 0;
92 Orignial_nick_namecxx . . $ Orignial_nick_name.[0] = 0;
93 Nick_varietycxx . . $ Nick_variety. = 0;
94 szChat_channelcxx . . $ szChat_channel.[0] = '\0';
95 Input_chat_buffercxx . . $ Input_chat_buffer.[0] = '\0';
96 Chat_tracker_idcxx . . $ Chat_tracker_id.[0] = 0;
97 Getting_user_channel_info_forcxx . . $ Getting_user_channel_info_for.[0] = '\0';
98 Getting_user_tracker_info_forcxx . . $ Getting_user_tracker_info_for.[0] = '\0';
99 Getting_user_channel_errorcxx . . $ Getting_user_channel_error. = 0;
100 Getting_user_tracker_errorcxx . . $ Getting_user_tracker_error. = 0;
101 User_req_tracker_idcxx . . $ User_req_tracker_id.[0] = '\0';
102 User_req_channelcxx . . $ User_req_channel.[0] = '\0';
103 User_listcxx . . $ User_list. = nullptr;
104 Chan_listcxx . . $ Chan_list. = nullptr;
105 Socket_connectedcxx . . $ Socket_connected. = 0;
106 Chat_server_connectedcxx . . $ Chat_server_connected. = 0;
107 Joining_channelcxx . . $ Joining_channel. = 0;
108 Joined_channelcxx . . $ Joined_channel. = 0;
109 GettingChannelListcxx . . $ GettingChannelList. = 0;
110 GettingUserTIDcxx . . $ GettingUserTID. = 0;
111 GettingUserChannelcxx . . $ GettingUserChannel. = 0;
112 }
113
114 // Return codes:
115 //-2 Already connected
116 //-1 Failed to connect
117 // 0 Connecting
118 // 1 Connected
119 // Call it once with the server IP address, and it will return immediately
120 // with 0. Keep calling it until it returns something other than 0
121 // note: the nickname may be changed if someone with that name already
122 // exists (Scourge1 for instance)
123 int ConnectToChatServercxx . . $ ConnectToChatServer(1abe9d7d0dbf60ed).(const char *serveraddr, int16_tcxx . . $ int16_t# chat_port, char *nickname, char *trackerid) {
124 char signon_str[100];
125
126 // if(Socket_connected && ) return -2;
127
128 if (!Socket_connectingcxx . . $ Socket_connecting.) {
129 strcpy(Nick_namecxx . . $ Nick_name., nickname);
130 for (uint32_tcxx . . $ uint32_t# l = 0; l < strlen(Nick_namecxx . . $ Nick_name.); l++)
131 if (Nick_namecxx . . $ Nick_name.[l] == ' ')
132 Nick_namecxx . . $ Nick_name.[l] = '_';
133 strcpy(Orignial_nick_namecxx . . $ Orignial_nick_name., nickname);
134 strcpy(Chat_tracker_idcxx . . $ Chat_tracker_id., trackerid);
135
136 Firstusercxx . . $ Firstuser. = nullptr;
137 Firstcommandcxx . . $ Firstcommand. = nullptr;
138 Chat_server_connectedcxx . . $ Chat_server_connected. = 0;
139 FlushChatCommandQueuecxx . . $ FlushChatCommandQueue(49f6e7a06ebc5aa8).();
140
141 if (chat_port == 0) {
142 // AfxMessageBox("Invalid chat port, must be host.com:port (ie. irc.dal.net:6667)");
143 return -1;
144 }
145
146 Chatsockcxx . . $ Chatsock. = socket(AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, 0);
147 if (INVALID_SOCKETcxx . . $ `lib/networking.h:221:9`! == Chatsockcxx . . $ Chatsock.) {
148 // AfxMessageBox("Unable to open socket!");
149 return -1;
150 }
151
152 memset(&Chataddrcxx . . $ Chataddr., 0, sizeof(SOCKADDR_INcxx . . $ `lib/networking.h:219:9`!));
153 Chataddrcxx . . $ Chataddr..sin_family = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!;
154 Chataddrcxx . . $ Chataddr..sin_addr.s_addr = INADDR_ANYcxx . . $ `<external>/9581057695539925927/in.h:198:9`!;
155 Chataddrcxx . . $ Chataddr..sin_port = 0;
156
157 if (SOCKET_ERRORcxx . . $ `lib/networking.h:233:9`! == bind(Chatsockcxx . . $ Chatsock., (SOCKADDRcxx . . $ `lib/networking.h:220:9`! *)&Chataddrcxx . . $ Chataddr., sizeof(sockaddr))) {
158 // AfxMessageBox("Unable to bind socket!");
159 return -1;
160 }
161
162 #ifdef WIN32
163 unsigned long arg = 1;
164 ioctlsocket(Chatsock, FIONBIO, &arg);
165 #else // WIN32
166 fcntl(Chatsockcxx . . $ Chatsock., F_SETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:169:9`!, fcntl(Chatsockcxx . . $ Chatsock., F_GETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:168:9`!, 0) | O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`!);
167 #endif
168
169 /*
170 HOSTENT *he;
171 he = gethostbyname(chat_server);
172 if(!he)
173 {
174 //AfxMessageBox("Unable to gethostbyname.\n");
175 return -1;
176 }
177
178 memcpy(&Chataddr.sin_addr.s_addr, he->h_addr_list[0],4);//&iaddr, 4);
179
180 */
181
182 int rcode;
183 uint32_tcxx . . $ uint32_t# ip;
184
185 DLLnw_Asyncgethostbynamecxx . . $ DLLnw_Asyncgethostbyname.(&ip, NW_AGHBN_LOOKUPcxx . . $ `lib/networking.h:482:9`!, serveraddr);
186 do {
187 rcode = DLLnw_Asyncgethostbynamecxx . . $ DLLnw_Asyncgethostbyname.(&ip, NW_AGHBN_READcxx . . $ `lib/networking.h:483:9`!, serveraddr);
188 if (99 == DLLPollUIcxx . . $ DLLPollUI.()) {
189 return 0;
190 }
191 } while (rcode == 0);
192
193 if (rcode != 1) {
194 DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(0, "Unable to gethostbyname(\"%s\").\n", serveraddr);
195 DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(0, "WSAGetLastError() returned %d.\n", WSAGetLastErrorcxx . . $ `lib/networking.h:241:9`!());
196 DLLnw_Asyncgethostbynamecxx . . $ DLLnw_Asyncgethostbyname.(nullptr, NW_AGHBN_CANCELcxx . . $ `lib/networking.h:481:9`!, nullptr);
197 return 0;
198 }
199 memcpy(&Chataddrcxx . . $ Chataddr..sin_addr.s_addr, &ip, 4);
200
201 Chataddrcxx . . $ Chataddr..sin_port = htons(chat_port);
202
203 if (SOCKET_ERRORcxx . . $ `lib/networking.h:233:9`! == connect(Chatsockcxx . . $ Chatsock., (SOCKADDRcxx . . $ `lib/networking.h:220:9`! *)&Chataddrcxx . . $ Chataddr., sizeof(SOCKADDR_INcxx . . $ `lib/networking.h:219:9`!))) {
204 int ret = WSAGetLastErrorcxx . . $ `lib/networking.h:241:9`!();
205 #if !defined(POSIXcxx . . $ `<built-in>:477:9`!)
206 if (WSAEWOULDBLOCK == WSAGetLastError())
207 #else
208 if (EINPROGRESScxx . . $ `<external>/17922322188510340118/errno.h:99:9`! == ret || 0 == ret)
209 #endif
210 {
211 DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(0, "Beginning socket connect\n");
212 Socket_connectingcxx . . $ Socket_connecting. = 1;
213 return 0;
214 }
215 } else {
216 // This should never happen, connect should always return WSAEWOULDBLOCK
217 DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(0, "connect returned too soon!\n");
218 Socket_connectingcxx . . $ Socket_connecting. = 1;
219 Socket_connectedcxx . . $ Socket_connected. = 1;
220 DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(0, "Socket connected, sending user and nickname request\n");
221 snprintf(signon_str, sizeof(signon_str), "/USER %s %s %s :%s", "user", "user", "user", Chat_tracker_idcxx . . $ Chat_tracker_id.);
222 SendChatStringcxx . . $ SendChatString(223c544933887702).(signon_str, 1);
223 snprintf(signon_str, sizeof(signon_str), "/NICK %s", Nick_namecxx . . $ Nick_name.);
224 SendChatStringcxx . . $ SendChatString(223c544933887702).(signon_str, 1);
225 return 0;
226 }
227 } else {
228 if (Chat_server_connectedcxx . . $ Chat_server_connected.) {
229 return 1;
230 }
231
232 if (!Socket_connectedcxx . . $ Socket_connected.) {
233 // Do a few select to check for an error, or to see if we are writeable (connected)
234 fd_setcxx . . $ fd_set# write_fds, error_fds;
235
236 #ifdef WIN32
237 TIMEVAL timeout;
238 #else
239 struct timevalcxx . . $ timeval# timeout;
240 #endif
241
242 timeout.tv_seccxx . . $ timeval#tv_sec. = 0;
243 timeout.tv_useccxx . . $ timeval#tv_usec. = 0;
244
245 FD_ZEROcxx . . $ `<external>/946878812840035423/select.h:88:9`!(&write_fds);
246 FD_SETcxx . . $ `<external>/946878812840035423/select.h:85:9`!(Chatsock, &write_fds);
247 // Writable -- that means it's connected
248 if (select(Chatsockcxx . . $ Chatsock. + 1, nullptr, &write_fds, nullptr, &timeout)) {
249 Socket_connectedcxx . . $ Socket_connected. = 1;
250 DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(0, "Socket connected, sending user and nickname request\n");
251 snprintf(signon_str, sizeof(signon_str), "/USER %s %s %s :%s", "user", "user", "user", Chat_tracker_idcxx . . $ Chat_tracker_id.);
252 SendChatStringcxx . . $ SendChatString(223c544933887702).(signon_str, 1);
253 snprintf(signon_str, sizeof(signon_str), "/NICK %s", Nick_namecxx . . $ Nick_name.);
254 SendChatStringcxx . . $ SendChatString(223c544933887702).(signon_str, 1);
255 return 0;
256 // Now we are waiting for Chat_server_connected
257 }
258 FD_ZEROcxx . . $ `<external>/946878812840035423/select.h:88:9`!(&error_fds);
259 FD_SETcxx . . $ `<external>/946878812840035423/select.h:85:9`!(Chatsock, &error_fds);
260 // error -- that means it's not going to connect
261 if (select(Chatsockcxx . . $ Chatsock. + 1, nullptr, nullptr, &error_fds, &timeout)) {
262 DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(0, "Select returned an error!\n");
263 return -1;
264 }
265 return 0;
266 }
267 }
268
269 return 0;
270 }
271
272 // Call it to close the connection. It returns immediately
273 void DisconnectFromChatServercxx . . $ DisconnectFromChatServer(49f6e7a06ebc5aa8).() {
274 if (!Socket_connectedcxx . . $ Socket_connected.)
275 return;
276 SendChatStringcxx . . $ SendChatString(223c544933887702).("/QUIT", 1);
277 shutdown(Chatsockcxx . . $ Chatsock., 2);
278 #ifdef WIN32
279 closesocket(Chatsock);
280 #else
281 close(Chatsockcxx . . $ Chatsock.);
282 #endif
283 Socket_connectingcxx . . $ Socket_connecting. = 0;
284 Socket_connectedcxx . . $ Socket_connected. = 0;
285 Input_chat_buffercxx . . $ Input_chat_buffer.[0] = '\0';
286 if (User_listcxx . . $ User_list.) {
287 DLLmem_freecxx . . $ DLLmem_free.(User_listcxx . . $ User_list.);
288 User_listcxx . . $ User_list. = nullptr;
289 }
290 if (Chan_listcxx . . $ Chan_list.) {
291 DLLmem_freecxx . . $ DLLmem_free.(Chan_listcxx . . $ Chan_list.);
292 Chan_listcxx . . $ Chan_list. = nullptr;
293 }
294
295 Chat_server_connectedcxx . . $ Chat_server_connected. = 0;
296 Joining_channelcxx . . $ Joining_channel. = 0;
297 Joined_channelcxx . . $ Joined_channel. = 0;
298 RemoveAllChatUserscxx . . $ RemoveAllChatUsers(49f6e7a06ebc5aa8).();
299 FlushChatCommandQueuecxx . . $ FlushChatCommandQueue(49f6e7a06ebc5aa8).();
300 FlushChannelListcxx . . $ FlushChannelList(49f6e7a06ebc5aa8).();
301 }
302
303 // returns NULL if no line is there to print, otherwise returns a string to
304 // print (all preformatted of course)
305 const char *GetChatTextcxx . . $ GetChatText(33a1f659e94feb42).() {
306
307 if (!Socket_connectedcxx . . $ Socket_connected.)
308 return nullptr;
309
310 // ChatGetString will do the formatting
311 return ChatGetStringcxx . . $ ChatGetString(33a1f659e94feb42).();
312 }
313
314 // Send a string to be sent as chat, or scanned for messages (/msg <user>
315 // string)
316 const char *SendChatStringcxx . . $ SendChatString(223c544933887702).(const char *line, int raw) {
317 char szCmd[200];
318 char szTarget[50];
319 if (!Socket_connectedcxx . . $ Socket_connected.)
320 return nullptr;
321
322 if (line[0] == '/') {
323
324 // Start off by getting the command
325 strcpy(szCmd, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, line + 1));
326 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "msg") == 0) {
327 strcpy(szTarget, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(1, line + 1));
328 snprintf(szCmd, sizeof(szCmd), "PRIVMSG %s :%s\n\r", szTarget, line + strlen("/msg ") + strlen(szTarget) + 1);
329 send(Chatsockcxx . . $ Chatsock., szCmd, strlen(szCmd), 0);
330 szCmd[strlen(szCmd) - 2] = '\0';
331 return ParseIRCMessagecxx . . $ ParseIRCMessage(ad13dc7cd1ddbf0a).(szCmd, MSG_LOCALcxx . . $ `netcon/mtclient/chat_api.h:31:9`!);
332 }
333 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "me") == 0) {
334 snprintf(szCmd, sizeof(szCmd), "PRIVMSG %s :\001ACTION %s\001\n\r", szChat_channelcxx . . $ szChat_channel., line + strlen("/me "));
335 send(Chatsockcxx . . $ Chatsock., szCmd, strlen(szCmd), 0);
336 szCmd[strlen(szCmd) - 2] = '\0';
337 return ParseIRCMessagecxx . . $ ParseIRCMessage(ad13dc7cd1ddbf0a).(szCmd, MSG_LOCALcxx . . $ `netcon/mtclient/chat_api.h:31:9`!);
338 }
339 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "xyz") == 0) {
340 // Special command to send raw irc commands
341 snprintf(szCmd, sizeof(szCmd), "%s\n\r", line + strlen("/xyz "));
342 send(Chatsockcxx . . $ Chatsock., szCmd, strlen(szCmd), 0);
343 return nullptr;
344 }
345 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "list") == 0) {
346 snprintf(szCmd, sizeof(szCmd), "%s\n\r", line + 1);
347 send(Chatsockcxx . . $ Chatsock., szCmd, strlen(szCmd), 0);
348 return nullptr;
349 }
350 if (raw) {
351 snprintf(szCmd, sizeof(szCmd), "%s\n\r", line + 1);
352 send(Chatsockcxx . . $ Chatsock., szCmd, strlen(szCmd), 0);
353 return nullptr;
354 }
355 return "Unrecognized command";
356
357 } else {
358 if (szChat_channelcxx . . $ szChat_channel.[0]) {
359 snprintf(szCmd, sizeof(szCmd), "PRIVMSG %s :%s\n\r", szChat_channelcxx . . $ szChat_channel., line);
360 send(Chatsockcxx . . $ Chatsock., szCmd, strlen(szCmd), 0);
361 szCmd[strlen(szCmd) - 2] = '\0';
362 return ParseIRCMessagecxx . . $ ParseIRCMessage(ad13dc7cd1ddbf0a).(szCmd, MSG_LOCALcxx . . $ `netcon/mtclient/chat_api.h:31:9`!);
363 }
364 }
365
366 return nullptr;
367 }
368
369 // Returns a structure which contains a command and possible some data (like
370 // a user joining or leaving) if one is waiting
371 // This tells you if you need to add a user from the userlist, remove a user,
372 // etc. Also for status messages, like if you get knocked
373 // off the server for some reason.
374 Chat_commandcxx . . $ Chat_command# *GetChatCommandcxx . . $ GetChatCommand(c516c7a03995079d).() {
375 if (!Socket_connectedcxx . . $ Socket_connected.)
376 return nullptr;
377 return GetChatCommandFromQueuecxx . . $ GetChatCommandFromQueue(c516c7a03995079d).();
378 }
379
380 // This function returns a list of users in the current channel, in one
381 // string, separated by spaces, terminated by a null
382 // (Spaces aren't allowed as part of a nickname)
383 char *GetChatUserListcxx . . $ GetChatUserList(41208ce6ca65dd58).() {
384 int iuser_list_length = 0;
385 ;
386 if (User_listcxx . . $ User_list.) {
387 DLLmem_freecxx . . $ DLLmem_free.(User_listcxx . . $ User_list.);
388 User_listcxx . . $ User_list. = nullptr;
389 }
390 if (!Socket_connectedcxx . . $ Socket_connected.)
391 return nullptr;
392
393 Currusercxx . . $ Curruser. = Firstusercxx . . $ Firstuser.;
394 while (Currusercxx . . $ Curruser.) {
395 iuser_list_length += strlen(Currusercxx . . $ Curruser.->nick_namecxx . . $ Chat_user#nick_name.) + 1;
396 Currusercxx . . $ Curruser. = Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next.;
397 }
398 Currusercxx . . $ Curruser. = Firstusercxx . . $ Firstuser.;
399 User_listcxx . . $ User_list. = (char *)DLLmem_malloccxx . . $ DLLmem_malloc.(iuser_list_length + 1);
400 User_listcxx . . $ User_list.[0] = '\0';
401 while (Currusercxx . . $ Curruser.) {
402 strcat(User_listcxx . . $ User_list., Currusercxx . . $ Curruser.->nick_namecxx . . $ Chat_user#nick_name.);
403 strcat(User_listcxx . . $ User_list., " ");
404 Currusercxx . . $ Curruser. = Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next.;
405 }
406
407 return User_listcxx . . $ User_list.;
408 }
409
410 // Call this to set/join a channel. Since we can't be sure that we will be
411 // able to join that channel, check it for completion
412 // You can't be in more than one channel at a time with this API, so you
413 // leave the current channel before trying to join
414 // a new one. Because of this if the join fails, make sure you try to join
415 // another channel, or the user wont be able to chat
416 //-1 Failed to join
417 // 0 joining
418 // 1 successfully joined
419 int SetNewChatChannelcxx . . $ SetNewChatChannel(5c4306d8553b3696).(const char *channel) {
420 char partstr[100];
421 if (!Socket_connectedcxx . . $ Socket_connected.)
422 return -1;
423 if (Joining_channelcxx . . $ Joining_channel. == 1) {
424 if (Joined_channelcxx . . $ Joined_channel. == 1) {
425 // We made it in!
426 Joining_channelcxx . . $ Joining_channel. = 0;
427 return 1;
428 } else if (Joined_channelcxx . . $ Joined_channel. == -1) {
429 // Error -- we got a message that the channel was invite only, or we were banned or something
430 Joining_channelcxx . . $ Joining_channel. = 0;
431 strcpy(szChat_channelcxx . . $ szChat_channel., "");
432 return -1;
433 }
434 } else {
435 if (szChat_channelcxx . . $ szChat_channel.[0]) {
436 snprintf(partstr, sizeof(partstr), "/PART %s", szChat_channelcxx . . $ szChat_channel.);
437 SendChatStringcxx . . $ SendChatString(223c544933887702).(partstr, 1);
438 }
439 strcpy(szChat_channelcxx . . $ szChat_channel., channel);
440 snprintf(partstr, sizeof(partstr), "/JOIN %s", szChat_channelcxx . . $ szChat_channel.);
441 SendChatStringcxx . . $ SendChatString(223c544933887702).(partstr, 1);
442 Joining_channelcxx . . $ Joining_channel. = 1;
443 Joined_channelcxx . . $ Joined_channel. = 0;
444 }
445
446 return 0;
447 }
448
449 const char *ChatGetStringcxx . . $ ChatGetString(33a1f659e94feb42).() {
450 char ch[2];
451 char *p;
452 int bytesread = 1;
453 static char return_string[MAXCHATBUFFERcxx . . $ `netcon/mtclient/chat_api.cpp:58:9`!];
454
455 while ((bytesread != 0) && (bytesread != SOCKET_ERRORcxx . . $ `lib/networking.h:233:9`!)) {
456 bytesread = recv(Chatsockcxx . . $ Chatsock., ch, 1, 0);
457 if (bytesread == SOCKET_ERRORcxx . . $ `lib/networking.h:233:9`!) {
458 uint32_tcxx . . $ uint32_t# lerror = WSAGetLastErrorcxx . . $ `lib/networking.h:241:9`!();
459 #if !defined(POSIXcxx . . $ `<built-in>:477:9`!)
460 if (WSAEWOULDBLOCK != lerror)
461 #else
462 if (WSAEWOULDBLOCKcxx . . $ `lib/networking.h:236:9`! != lerror && 0 != lerror)
463 #endif
464 {
465 DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(0, "recv caused an error: %d\n", lerror);
466 }
467 return nullptr;
468 }
469 if (bytesread) {
470 ch[1] = '\0';
471 // DLLmprintf(0,ch);
472 if ((ch[0] == 0x0a) || (ch[0] == 0x0d)) {
473 if (Input_chat_buffercxx . . $ Input_chat_buffer.[0] == '\0') {
474 // Blank line, ignore it
475 return nullptr;
476 }
477 strcpy(return_string, Input_chat_buffercxx . . $ Input_chat_buffer.);
478 Input_chat_buffercxx . . $ Input_chat_buffer.[0] = '\0';
479 // DLLmprintf(0,"->|%s\n",return_string);
480 p = ParseIRCMessagecxx . . $ ParseIRCMessage(ad13dc7cd1ddbf0a).(return_string, MSG_REMOTEcxx . . $ `netcon/mtclient/chat_api.h:30:9`!);
481
482 return p;
483 }
484 strcat(Input_chat_buffercxx . . $ Input_chat_buffer., ch);
485 } else {
486 // Select said we had read data, but 0 bytes read means disconnected
487 DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(0, "Disconnected! Doh!");
488 AddChatCommandToQueuecxx . . $ AddChatCommandToQueue(7b93ffa09ebcfde0).(CC_DISCONNECTEDcxx . . $ `netcon/mtclient/chat_api.h:24:9`!, nullptr, 0);
489 return nullptr;
490 }
491 }
492 return nullptr;
493 }
494
495 const char *GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(int num, const char *l_String) {
496 static char strreturn[600];
497 static char ptokstr[600];
498 char seps[10] = " \n\r\t";
499 char *token, *strstart;
500
501 strstart = ptokstr;
502
503 strcpy(ptokstr, l_String);
504
505 token = strtok(ptokstr, seps);
506
507 for (int i = 0; i != num; i++) {
508 token = strtok(nullptr, seps);
509 }
510 if (token) {
511 strcpy(strreturn, token);
512 } else {
513 return "";
514 }
515 // check for the ':' char....
516 if (token[0] == ':') {
517 // Its not pretty, but it works, return the rest of the string
518 strcpy(strreturn, l_String + ((token - strstart) + 1));
519 }
520
521 // return the appropriate response.
522 return strreturn;
523 }
524
525 int AddChatUsercxx . . $ AddChatUser(5c4306d8553b3696).(const char *nickname) {
526 Currusercxx . . $ Curruser. = Firstusercxx . . $ Firstuser.;
527 while (Currusercxx . . $ Curruser.) {
528 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(nickname, Curruser->nick_name) == 0)
529 return 0;
530 Currusercxx . . $ Curruser. = Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next.;
531 }
532
533 Currusercxx . . $ Curruser. = Firstusercxx . . $ Firstuser.;
534 if (Firstusercxx . . $ Firstuser. == nullptr) {
535 Firstusercxx . . $ Firstuser. = (Chat_usercxx . . $ Chat_user# *)DLLmem_malloccxx . . $ DLLmem_malloc.(sizeof(Chat_usercxx . . $ Chat_user#));
536 // ASSERT(Firstuser);
537 strcpy(Firstusercxx . . $ Firstuser.->nick_namecxx . . $ Chat_user#nick_name., nickname);
538 Firstusercxx . . $ Firstuser.->nextcxx . . $ Chat_user#next. = nullptr;
539 AddChatCommandToQueuecxx . . $ AddChatCommandToQueue(7b93ffa09ebcfde0).(CC_USER_JOININGcxx . . $ `netcon/mtclient/chat_api.h:22:9`!, nickname, strlen(nickname) + 1);
540 return 1;
541 } else {
542 while (Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next.) {
543 Currusercxx . . $ Curruser. = Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next.;
544 }
545 Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next. = (Chat_usercxx . . $ Chat_user# *)DLLmem_malloccxx . . $ DLLmem_malloc.(sizeof(Chat_usercxx . . $ Chat_user#));
546 Currusercxx . . $ Curruser. = Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next.;
547 // ASSERT(Curruser);
548 strcpy(Currusercxx . . $ Curruser.->nick_namecxx . . $ Chat_user#nick_name., nickname);
549 Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next. = nullptr;
550 AddChatCommandToQueuecxx . . $ AddChatCommandToQueue(7b93ffa09ebcfde0).(CC_USER_JOININGcxx . . $ `netcon/mtclient/chat_api.h:22:9`!, nickname, strlen(nickname) + 1);
551 return 1;
552 }
553 }
554
555 int RemoveChatUsercxx . . $ RemoveChatUser(1ef8e6ec083aabb9).(char *nickname) {
556 Chat_usercxx . . $ Chat_user# *prv_user = nullptr;
557
558 Currusercxx . . $ Curruser. = Firstusercxx . . $ Firstuser.;
559 while (Currusercxx . . $ Curruser.) {
560 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(nickname, Curruser->nick_name) == 0) {
561 if (prv_user) {
562 prv_user->nextcxx . . $ Chat_user#next. = Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next.;
563
564 } else {
565 Firstusercxx . . $ Firstuser. = Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next.;
566 }
567 AddChatCommandToQueuecxx . . $ AddChatCommandToQueue(7b93ffa09ebcfde0).(CC_USER_LEAVINGcxx . . $ `netcon/mtclient/chat_api.h:23:9`!, Currusercxx . . $ Curruser.->nick_namecxx . . $ Chat_user#nick_name., strlen(Currusercxx . . $ Curruser.->nick_namecxx . . $ Chat_user#nick_name.) + 1);
568 DLLmem_freecxx . . $ DLLmem_free.(Currusercxx . . $ Curruser.);
569 return 1;
570 }
571 prv_user = Currusercxx . . $ Curruser.;
572 Currusercxx . . $ Curruser. = Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next.;
573 }
574 return 0;
575 }
576
577 void RemoveAllChatUserscxx . . $ RemoveAllChatUsers(49f6e7a06ebc5aa8).() {
578 Chat_usercxx . . $ Chat_user# *tmp_user = nullptr;
579 Currusercxx . . $ Curruser. = Firstusercxx . . $ Firstuser.;
580 while (Currusercxx . . $ Curruser.) {
581 tmp_user = Currusercxx . . $ Curruser.->nextcxx . . $ Chat_user#next.;
582 AddChatCommandToQueuecxx . . $ AddChatCommandToQueue(7b93ffa09ebcfde0).(CC_USER_LEAVINGcxx . . $ `netcon/mtclient/chat_api.h:23:9`!, Currusercxx . . $ Curruser.->nick_namecxx . . $ Chat_user#nick_name., strlen(Currusercxx . . $ Curruser.->nick_namecxx . . $ Chat_user#nick_name.) + 1);
583 DLLmem_freecxx . . $ DLLmem_free.(Currusercxx . . $ Curruser.);
584 Currusercxx . . $ Curruser. = tmp_user;
585 }
586 Firstusercxx . . $ Firstuser. = nullptr;
587 }
588
589 char *ParseIRCMessagecxx . . $ ParseIRCMessage(ad13dc7cd1ddbf0a).(char *Line, int iMode) {
590 char szRemLine[MAXLOCALSTRINGcxx . . $ `netcon/mtclient/chat_api.h:29:9`!];
591 const char *pszTempStr;
592 char szPrefix[MAXLOCALSTRINGcxx . . $ `netcon/mtclient/chat_api.h:29:9`!];
593 char szHackPrefix[MAXLOCALSTRINGcxx . . $ `netcon/mtclient/chat_api.h:29:9`!];
594 char szTarget[MAXLOCALSTRINGcxx . . $ `netcon/mtclient/chat_api.h:29:9`!];
595 char szNick[MAXLOCALSTRINGcxx . . $ `netcon/mtclient/chat_api.h:29:9`!];
596 char szCmd[MAXLOCALSTRINGcxx . . $ `netcon/mtclient/chat_api.h:29:9`!];
597 char szCTCPCmd[MAXLOCALSTRINGcxx . . $ `netcon/mtclient/chat_api.h:29:9`!];
598
599 static char szResponse[MAXLOCALSTRINGcxx . . $ `netcon/mtclient/chat_api.h:29:9`!];
600
601 int iNickLen;
602 int iPrefixLen = 0;
603
604 szPrefix[0] = '\0';
605 szNick[0] = '\0';
606
607 if (strlen(Line) >= MAXLOCALSTRINGcxx . . $ `netcon/mtclient/chat_api.h:29:9`!) {
608 return nullptr;
609 }
610 // Nick included....
611 if (iMode == MSG_REMOTEcxx . . $ `netcon/mtclient/chat_api.h:30:9`!) {
612 strcpy(szRemLine, Line);
613 // Start by getting the prefix
614 szHackPrefix[0] = '\0';
615 if (Line[0] == ':') {
616 //
617 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, Line + 1);
618 strcpy(szPrefix, pszTempStr);
619 strcpy(szHackPrefix, pszTempStr);
620 strcpy(szRemLine, Line + 1 + strlen(szPrefix));
621 }
622 // Next, get the Nick
623 pszTempStr = strtok(szHackPrefix, "!");
624 if (pszTempStr) {
625 strcpy(szNick, pszTempStr);
626 } else {
627 strncpy(szNick, szPrefix, 31);
628 szNick[31] = 0;
629 }
630 // strcpy(NewMsg.Nickname,szNick);
631 iNickLen = strlen(szNick);
632 iPrefixLen = strlen(szPrefix);
633 } else if (iMode == MSG_LOCALcxx . . $ `netcon/mtclient/chat_api.h:31:9`!) {
634 strcpy(szRemLine, Line);
635 strcpy(szNick, Nick_namecxx . . $ Nick_name.);
636 strcpy(szPrefix, Nick_namecxx . . $ Nick_name.);
637 // strcpy(NewMsg.Nickname,szNick);
638 iNickLen = -2;
639 iPrefixLen = -2;
640 }
641 // Next is the command
642 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine);
643 if (pszTempStr[0]) {
644 strcpy(szCmd, pszTempStr);
645 } else {
646 // Shouldn't ever happen, but we can't be sure of what the host will send us.
647 return nullptr;
648 }
649
650 // Move the szRemLine string up
651 strcpy(szRemLine, Line + iPrefixLen + strlen(szCmd) + 2);
652 // Now parse the commands!
653 // printf("%s",szCmd);
654 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "PRIVMSG") == 0) {
655 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine);
656 strcpy(szTarget, pszTempStr);
657 strcpy(szRemLine, Line + iPrefixLen + strlen(szCmd) + strlen(szTarget) + 4);
658 if (szRemLine[0] == ':') {
659 strcpy(szCTCPCmd, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine + 1));
660 if (szCTCPCmd[strlen(szCTCPCmd) - 1] == 0x01)
661 szCTCPCmd[strlen(szCTCPCmd) - 1] = 0x00;
662
663 } else {
664 strcpy(szCTCPCmd, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine));
665 if (szCTCPCmd[strlen(szCTCPCmd) - 1] == 0x01)
666 szCTCPCmd[strlen(szCTCPCmd) - 1] = 0x00;
667 }
668 if (szCTCPCmd[0] == 0x01) {
669 // Handle ctcp message
670 strcpy(szRemLine, Line + iPrefixLen + strlen(szCmd) + strlen(szTarget) + strlen(szCTCPCmd) + 6);
671 szRemLine[strlen(szRemLine) - 1] = '\0'; // null out the ending 0x01
672 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCTCPCmd + 1, "ACTION") == 0) {
673 // Posture
674 snprintf(szResponse, sizeof(szResponse), "\1\xff\x28\x28* %s %s", szNick, szRemLine);
675 return szResponse;
676 }
677 if (iMode == MSG_LOCALcxx . . $ `netcon/mtclient/chat_api.h:31:9`!) {
678 strcpy(szHackPrefix, Line + iPrefixLen + strlen(szCmd) + strlen(szTarget) + 4);
679 szRemLine[strlen(szRemLine) - 1] = '\0';
680 snprintf(szResponse, sizeof(szResponse), "** CTCP %s %s %s", szTarget, szCTCPCmd + 1, szRemLine);
681 return szResponse;
682 }
683 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCTCPCmd + 1, "PING") == 0) {
684 snprintf(szResponse, sizeof(szResponse), "/NOTICE %s :\001PING %s\001", szNick,
685 szRemLine); // Don't need the trailing \001 because szremline has it.
686 SendChatStringcxx . . $ SendChatString(223c544933887702).(szResponse, 1);
687 return nullptr;
688 }
689 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCTCPCmd + 1, "VERSION") == 0) {
690 // reply with a notice version & copyright
691 // sprintf(szTempLine,"NOTICE %s :\001VERSION Copyright(c)\001\n",szNick);
692
693 return nullptr;
694 }
695 strcpy(szRemLine, 1 + GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, Line + iPrefixLen + strlen(szCmd) + strlen(szTarget) + 4));
696 szRemLine[strlen(szRemLine) - 1] = '\0';
697 snprintf(szResponse, sizeof(szResponse), "** CTCP Message from %s (%s)", szNick, szRemLine);
698 return nullptr; // szResponse;
699 }
700 // differentiate between channel and private
701 if ((szTarget[0] == '#') || (szTarget[0] == '+')) {
702 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine);
703 snprintf(szResponse, sizeof(szResponse), "\1\xff\xff\xff[%s] %s", szNick, pszTempStr);
704 return szResponse;
705 } else {
706 if (iMode == MSG_LOCALcxx . . $ `netcon/mtclient/chat_api.h:31:9`!) {
707 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine);
708 snprintf(szResponse, sizeof(szResponse), TXT_PXO_PRIVMSGTOcxx . . $ `netcon/mtclient/mtstrings.h:95:9`!, szTarget, pszTempStr);
709 } else {
710 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine);
711 snprintf(szResponse, sizeof(szResponse), TXT_PXO_PRIVMSGFROMcxx . . $ `netcon/mtclient/mtstrings.h:96:9`!, szNick, pszTempStr);
712 }
713 return szResponse;
714 }
715 }
716 // don't handle any other messages locally.
717 if (iMode == MSG_LOCALcxx . . $ `netcon/mtclient/chat_api.h:31:9`!) {
718 return nullptr;
719 }
720
721 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "NOTICE") == 0) {
722
723 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine);
724 strcpy(szTarget, pszTempStr);
725 strcpy(szRemLine, Line + iPrefixLen + strlen(szCmd) + strlen(szTarget) + 4);
726 if (szRemLine[0] == ':') {
727 strcpy(szCTCPCmd, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine + 1));
728 if (szCTCPCmd[strlen(szCTCPCmd) - 1] == 0x01)
729 szCTCPCmd[strlen(szCTCPCmd) - 1] = 0x00;
730
731 } else {
732 strcpy(szCTCPCmd, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine));
733 if (szCTCPCmd[strlen(szCTCPCmd) - 1] == 0x01)
734 szCTCPCmd[strlen(szCTCPCmd) - 1] = 0x00;
735 }
736 if (szCTCPCmd[0] == 0x01) {
737 // Handle ctcp message
738 strcpy(szRemLine, Line + iPrefixLen + strlen(szCmd) + strlen(szTarget) + strlen(szCTCPCmd) + 6);
739 szRemLine[strlen(szRemLine) - 1] = '\0'; // null out the ending 0x01
740 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCTCPCmd + 1, "PING") == 0) {
741 // This is a ping response, figure out time and print
742 // sprintf(NewMsg.Message,"** Ping Response from %s: %ums",szNick,ulping);
743 return nullptr;
744 }
745
746 // Default message
747 strcpy(szRemLine, 1 + GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, Line + iPrefixLen + strlen(szCmd) + strlen(szTarget) + 4));
748 szRemLine[strlen(szRemLine) - 1] = '\0';
749 snprintf(szResponse, sizeof(szResponse), "** CTCP Message from %s (%s)", szNick, szRemLine);
750 return nullptr; // szResponse;
751 }
752 strncpy(szResponse, szRemLine, sizeof(szResponse));
753 return nullptr;
754 }
755 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "JOIN") == 0) {
756 // see if it is me!
757 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(Nick_name, szNick) == 0) {
758 // Yup, it's me!
759 // if(stricmp(szChat_channel,GetWordNum(0,szRemLine))==0)
760 //{
761 Joined_channelcxx . . $ Joined_channel. = 1;
762 // if(stricmp(szChat_channel,"#autoselect")==0)
763 //{
764 strcpy(szChat_channelcxx . . $ szChat_channel., GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine));
765 AddChatCommandToQueuecxx . . $ AddChatCommandToQueue(7b93ffa09ebcfde0).(CC_YOURCHANNELcxx . . $ `netcon/mtclient/chat_api.h:27:9`!, szChat_channelcxx . . $ szChat_channel., strlen(szChat_channelcxx . . $ szChat_channel.) + 1);
766
767 //}
768 // CC_YOURCHANNEL
769 //}
770 }
771 AddChatUsercxx . . $ AddChatUser(5c4306d8553b3696).(szNick);
772
773 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine);
774 strcpy(szTarget, pszTempStr);
775 // strcpy(szRemLine,Line+iPrefixLen+strlen(szCmd)+strlen(szTarget)+3);
776
777 // strcpy(NewMsg.Channel,szTarget);
778
779 AddChatUsercxx . . $ AddChatUser(5c4306d8553b3696).(szNick);
780 snprintf(szResponse, sizeof(szResponse), "** %s has joined %s", szNick, szTarget);
781 return nullptr; // szResponse;
782 // Add them to the userlist too!
783 }
784 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "PART") == 0) {
785 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine);
786 strcpy(szTarget, pszTempStr);
787 strcpy(szRemLine, Line + iPrefixLen + strlen(szCmd) + strlen(szTarget) + 3);
788 // see if it is me!
789 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(Nick_name, szNick) == 0) {
790 // Yup, it's me!
791 // szChat_channel[0]=NULL;
792 RemoveAllChatUserscxx . . $ RemoveAllChatUsers(49f6e7a06ebc5aa8).();
793 }
794
795 RemoveChatUsercxx . . $ RemoveChatUser(1ef8e6ec083aabb9).(szNick);
796 return nullptr;
797 // Remove them to the userlist too!
798 }
799 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "KICK") == 0) {
800 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine);
801 strcpy(szTarget, pszTempStr);
802 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(1, szRemLine);
803 strcpy(szHackPrefix, pszTempStr);
804 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(2, szRemLine);
805 // see if it is me!
806 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(Nick_name, GetWordNum(1, szRemLine)) == 0) {
807 // Yup, it's me!
808 szChat_channelcxx . . $ szChat_channel.[0] = '\0';
809 // bNewStatus=1;
810 AddChatCommandToQueuecxx . . $ AddChatCommandToQueue(7b93ffa09ebcfde0).(CC_KICKEDcxx . . $ `netcon/mtclient/chat_api.h:25:9`!, nullptr, 0);
811 RemoveAllChatUserscxx . . $ RemoveAllChatUsers(49f6e7a06ebc5aa8).();
812 }
813 // sprintf(szResponse,"*** %s has kicked %s from channel %s (%s)",szNick,szHackPrefix,szTarget,pszTempStr);
814 // Remove them to the userlist too!
815 RemoveChatUsercxx . . $ RemoveChatUser(1ef8e6ec083aabb9).(szNick);
816 return nullptr; // szResponse;
817 }
818 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "NICK") == 0) {
819 // see if it is me!
820 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(Nick_name, szNick) == 0) {
821 // Yup, it's me!
822 strcpy(Nick_namecxx . . $ Nick_name., GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine));
823 }
824 char nicks[70];
825 snprintf(nicks, sizeof(nicks), "%s %s", szNick, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine));
826 AddChatCommandToQueuecxx . . $ AddChatCommandToQueue(7b93ffa09ebcfde0).(CC_NICKCHANGEDcxx . . $ `netcon/mtclient/chat_api.h:26:9`!, nicks, strlen(nicks) + 1);
827 RemoveChatUsercxx . . $ RemoveChatUser(1ef8e6ec083aabb9).(szNick);
828 AddChatUsercxx . . $ AddChatUser(5c4306d8553b3696).(GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine));
829 // sprintf(szResponse,"*** %s is now known as %s",szNick,GetWordNum(0,szRemLine));
830 return nullptr; // szResponse;
831 }
832 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "PING") == 0) {
833 // respond with pong (GetWordNum(0,szRemLine))
834 snprintf(szResponse, sizeof(szResponse), "/PONG :%s", GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine));
835 SendChatStringcxx . . $ SendChatString(223c544933887702).(szResponse, 1);
836 return nullptr;
837 }
838 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "MODE") == 0) {
839 // Channel Mode info
840 return nullptr;
841 }
842
843 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "401") == 0) {
844 // This is whois user info, we can get their tracker info from here. -5
845 char szWhoisUser[33];
846 strcpy(szWhoisUser, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(1, szRemLine));
847 Getting_user_tracker_errorcxx . . $ Getting_user_tracker_error. = 1;
848 Getting_user_channel_errorcxx . . $ Getting_user_channel_error. = 1;
849
850 snprintf(szResponse, sizeof(szResponse), TXT_PXO_ERRORNOTONLINEcxx . . $ `netcon/mtclient/mtstrings.h:93:9`!, szWhoisUser);
851 return szResponse;
852 }
853 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "311") == 0) {
854 char szWhoisUser[33];
855 strcpy(szWhoisUser, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(1, szRemLine));
856 // This is whois user info, we can get their tracker info from here. -5
857 // if(stricmp(Getting_user_tracker_info_for,szWhoisUser)==0)
858 //{
859 strcpy(User_req_tracker_idcxx . . $ User_req_tracker_id., GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(5, szRemLine));
860 //}
861 return nullptr;
862 }
863 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "319") == 0) {
864 char szWhoisUser[33];
865 strcpy(szWhoisUser, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(1, szRemLine));
866 // This is whois channel info -- what channel they are on -2
867 // if(stricmp(Getting_user_channel_info_for,szWhoisUser)==0)
868 //{
869 strcpy(User_req_channelcxx . . $ User_req_channel., GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(2, szRemLine));
870 //}
871 return nullptr;
872 }
873
874 // End of whois and we didn't get a channel means they aren't in a channel.
875 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "318") == 0) {
876 if (!*User_req_channelcxx . . $ User_req_channel.) {
877 User_req_channelcxx . . $ User_req_channel.[0] = '*';
878 }
879 }
880
881 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "321") == 0) {
882 // start of channel list
883 FlushChannelListcxx . . $ FlushChannelList(49f6e7a06ebc5aa8).();
884 GettingChannelListcxx . . $ GettingChannelList. = 1;
885 return nullptr;
886 }
887 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "322") == 0) {
888 // channel list data
889 if (GettingChannelListcxx . . $ GettingChannelList. == 1) {
890 char channel_list_name[33];
891 char sztopic[200];
892 strcpy(sztopic, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(3, szRemLine));
893 strcpy(channel_list_name, GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(1, szRemLine));
894 AddChannelcxx . . $ AddChannel(2efb20bf9f5bff1e).(channel_list_name, atoicxx . . $ atoi(f5ecf3191ed0cd93).(GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(2, szRemLine)), sztopic);
895 }
896 return nullptr;
897 }
898 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "323") == 0) {
899 // end of channel list
900 GettingChannelListcxx . . $ GettingChannelList. = 2;
901 return nullptr;
902 }
903 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "324") == 0) {
904 // Channel Mode info
905 return nullptr;
906 }
907
908 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "332") == 0) {
909 // Channel Topic, update status bar.
910 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szChat_channel, szTarget) == 0) {
911 // strncpy(szChanTopic,GetWordNum(2,szRemLine),70);
912 }
913 // sprintf(NewMsg.Message,"*** %s has changed the topic to: %s",szNick,GetWordNum(2,szRemLine));
914
915 return nullptr;
916 }
917 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "TOPIC") == 0) {
918 // Channel Topic, update status bar.
919 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szChat_channel, szTarget) == 0) {
920 // strncpy(szChanTopic,GetWordNum(1,szRemLine),70);
921 }
922 // sprintf(NewMsg.Message,"*** %s has changed the topic to: %s",szNick,GetWordNum(1,szRemLine));
923 return nullptr;
924 }
925 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "QUIT") == 0) {
926 // Remove the user!
927 RemoveChatUsercxx . . $ RemoveChatUser(1ef8e6ec083aabb9).(szNick);
928 return nullptr;
929 }
930 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "376") == 0) // end of motd, trigger autojoin...
931 {
932 if (!Chat_server_connectedcxx . . $ Chat_server_connected.) {
933 DLLmprintfcxx . . $ `netcon/mtclient/chat_api.cpp:51:9`!(0, "Connected to chat server!\n");
934 Chat_server_connectedcxx . . $ Chat_server_connected. = 1;
935 // We want to make sure we know our nick. This is somewhat of a hack
936 strcpy(Nick_namecxx . . $ Nick_name., GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(0, szRemLine + 1));
937 }
938 return nullptr;
939 }
940 if ((stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "377") == 0) || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "372") == 0) || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "372") == 0)
941
942 ) {
943 // Stip the message, and display it.
944 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(3, Line);
945 snprintf(szResponse, sizeof(szResponse), "\1\xcf\xf8\xb9%s", pszTempStr);
946 return szResponse;
947 }
948 // Ignore these messages
949 if (((stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "366") == 0)) || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "333") == 0) || // Who set the topic
950 (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "329") == 0)) // Time Channel created
951 /*
952 (stricmp(szCmd,"305")==0) ||
953 (stricmp(szCmd,"306")==0) ||
954 (stricmp(szCmd,"311")==0) || //WHOIS stuff
955 (stricmp(szCmd,"312")==0) ||
956 (stricmp(szCmd,"313")==0) ||
957 (stricmp(szCmd,"317")==0) ||
958 (stricmp(szCmd,"318")==0) ||
959 (stricmp(szCmd,"319")==0) ||
960 */
961
962 {
963 return nullptr;
964 }
965 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "353") == 0) {
966
967 // Names in the channel.
968 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(3, Line + iPrefixLen + strlen(szCmd) + 2);
969 strcpy(szRemLine, pszTempStr);
970 pszTempStr = strtok(szRemLine, " ");
971
972 while (pszTempStr) {
973 if (pszTempStr[0] == '@') {
974 AddChatUsercxx . . $ AddChatUser(5c4306d8553b3696).(pszTempStr + 1);
975 } else if (pszTempStr[0] == '+') {
976 AddChatUsercxx . . $ AddChatUser(5c4306d8553b3696).(pszTempStr + 1);
977 } else {
978 AddChatUsercxx . . $ AddChatUser(5c4306d8553b3696).(pszTempStr);
979 }
980 pszTempStr = strtok(nullptr, " ");
981 }
982 return nullptr;
983 }
984 // MOTD Codes
985 if ((stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "001") == 0) || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "002") == 0) || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "003") == 0) ||
986 (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "004") == 0) || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "251") == 0) || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "254") == 0) ||
987 (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "255") == 0) || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "265") == 0) || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "375") == 0) ||
988 (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "372") == 0) || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "375") == 0)) {
989 // Stip the message, and display it.
990 pszTempStr = GetWordNumcxx . . $ GetWordNum(75c700d7e7a896fe).(3, Line);
991 strcpy(szResponse, pszTempStr);
992 return nullptr;
993 // return szResponse;
994 }
995 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "432") == 0) {
996 // Channel Mode info
997 snprintf(szResponse, sizeof(szResponse), "%s", TXT_PXO_BADNICKcxx . . $ `netcon/mtclient/mtstrings.h:94:9`!);
998 AddChatCommandToQueuecxx . . $ AddChatCommandToQueue(7b93ffa09ebcfde0).(CC_DISCONNECTEDcxx . . $ `netcon/mtclient/chat_api.h:24:9`!, nullptr, 0);
999 return szResponse;
1000 }
1001 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(szCmd, "433") == 0) {
1002 // Channel Mode info
1003 char new_nick[33];
1004 snprintf(new_nick, sizeof(new_nick), "%s%d", Orignial_nick_namecxx . . $ Orignial_nick_name., Nick_varietycxx . . $ Nick_variety.);
1005 strcpy(Nick_namecxx . . $ Nick_name., new_nick);
1006 Nick_varietycxx . . $ Nick_variety.++;
1007 snprintf(szResponse, sizeof(szResponse), "/NICK %s", new_nick);
1008 SendChatStringcxx . . $ SendChatString(223c544933887702).(szResponse, 1);
1009 return nullptr;
1010 }
1011 // Default print
1012 strcpy(szResponse, Line);
1013 // return szResponse;
1014 return nullptr;
1015 }
1016
1017 void AddChatCommandToQueuecxx . . $ AddChatCommandToQueue(7b93ffa09ebcfde0).(int command, const void *data, int len) {
1018 Currcommandcxx . . $ Currcommand. = Firstcommandcxx . . $ Firstcommand.;
1019 if (Firstcommandcxx . . $ Firstcommand. == nullptr) {
1020 Firstcommandcxx . . $ Firstcommand. = (Chat_commandcxx . . $ Chat_command# *)DLLmem_malloccxx . . $ DLLmem_malloc.(sizeof(Chat_commandcxx . . $ Chat_command#));
1021 // ASSERT(Firstcommand);
1022 Firstcommandcxx . . $ Firstcommand.->nextcxx . . $ Chat_command#next. = nullptr;
1023 Currcommandcxx . . $ Currcommand. = Firstcommandcxx . . $ Firstcommand.;
1024 } else {
1025 while (Currcommandcxx . . $ Currcommand.->nextcxx . . $ Chat_command#next.) {
1026 Currcommandcxx . . $ Currcommand. = Currcommandcxx . . $ Currcommand.->nextcxx . . $ Chat_command#next.;
1027 }
1028 Currcommandcxx . . $ Currcommand.->nextcxx . . $ Chat_command#next. = (Chat_commandcxx . . $ Chat_command# *)DLLmem_malloccxx . . $ DLLmem_malloc.(sizeof(Chat_commandcxx . . $ Chat_command#));
1029 // ASSERT(Currcommand->next);
1030 Currcommandcxx . . $ Currcommand. = Currcommandcxx . . $ Currcommand.->nextcxx . . $ Chat_command#next.;
1031 }
1032 Currcommandcxx . . $ Currcommand.->commandcxx . . $ Chat_command#command. = command;
1033 if (len && data)
1034 memcpy(&Currcommandcxx . . $ Currcommand.->datacxx . . $ Chat_command#data., data, len);
1035 Currcommandcxx . . $ Currcommand.->nextcxx . . $ Chat_command#next. = nullptr;
1036 }
1037
1038 Chat_commandcxx . . $ Chat_command# *GetChatCommandFromQueuecxx . . $ GetChatCommandFromQueue(c516c7a03995079d).() {
1039 static Chat_commandcxx . . $ Chat_command# response_cmd;
1040 Chat_commandcxx . . $ Chat_command# *tmp_cmd;
1041 if (!Firstcommandcxx . . $ Firstcommand.)
1042 return nullptr;
1043 Currcommandcxx . . $ Currcommand. = Firstcommandcxx . . $ Firstcommand.;
1044 memcpy(&response_cmd, Currcommandcxx . . $ Currcommand., sizeof(Chat_commandcxx . . $ Chat_command#));
1045 tmp_cmd = Currcommandcxx . . $ Currcommand.->nextcxx . . $ Chat_command#next.;
1046 DLLmem_freecxx . . $ DLLmem_free.(Firstcommandcxx . . $ Firstcommand.);
1047 Firstcommandcxx . . $ Firstcommand. = tmp_cmd;
1048 return &response_cmd;
1049 }
1050
1051 void FlushChatCommandQueuecxx . . $ FlushChatCommandQueue(49f6e7a06ebc5aa8).() {
1052 Chat_commandcxx . . $ Chat_command# *tmp_cmd;
1053 Currcommandcxx . . $ Currcommand. = Firstcommandcxx . . $ Firstcommand.;
1054
1055 while (Currcommandcxx . . $ Currcommand.) {
1056 tmp_cmd = Currcommandcxx . . $ Currcommand.->nextcxx . . $ Chat_command#next.;
1057 DLLmem_freecxx . . $ DLLmem_free.(Currcommandcxx . . $ Currcommand.);
1058 Currcommandcxx . . $ Currcommand. = tmp_cmd;
1059 }
1060 Firstcommandcxx . . $ Firstcommand. = nullptr;
1061 }
1062
1063 void FlushChannelListcxx . . $ FlushChannelList(49f6e7a06ebc5aa8).() {
1064 Chat_channelcxx . . $ Chat_channel# *tmp_chan;
1065 Currchannelcxx . . $ Currchannel. = Firstchannelcxx . . $ Firstchannel.;
1066
1067 while (Currchannelcxx . . $ Currchannel.) {
1068 tmp_chan = Currchannelcxx . . $ Currchannel.->nextcxx . . $ Chat_channel#next.;
1069 DLLmem_freecxx . . $ DLLmem_free.(Currchannelcxx . . $ Currchannel.);
1070 Currchannelcxx . . $ Currchannel. = tmp_chan;
1071 }
1072 Firstchannelcxx . . $ Firstchannel. = nullptr;
1073 }
1074 char *GetChannelListcxx . . $ GetChannelList(41208ce6ca65dd58).() {
1075 int ichan_list_length = 0;
1076 char sznumusers[10];
1077
1078 if (GettingChannelListcxx . . $ GettingChannelList. != 2)
1079 return nullptr;
1080 if (!Socket_connectedcxx . . $ Socket_connected.)
1081 return nullptr;
1082
1083 if (Chan_listcxx . . $ Chan_list.) {
1084 DLLmem_freecxx . . $ DLLmem_free.(Chan_listcxx . . $ Chan_list.);
1085 Chan_listcxx . . $ Chan_list. = nullptr;
1086 }
1087
1088 Currchannelcxx . . $ Currchannel. = Firstchannelcxx . . $ Firstchannel.;
1089 while (Currchannelcxx . . $ Currchannel.) {
1090 ichan_list_length += strlen(Currchannelcxx . . $ Currchannel.->topiccxx . . $ Chat_channel#topic.) + 1 + strlen(Currchannelcxx . . $ Currchannel.->channel_namecxx . . $ Chat_channel#channel_name.) + 1 +
1091 5; // 1 for the space, and 4 for the number of users 0000-9999 + space
1092 Currchannelcxx . . $ Currchannel. = Currchannelcxx . . $ Currchannel.->nextcxx . . $ Chat_channel#next.;
1093 }
1094 Currchannelcxx . . $ Currchannel. = Firstchannelcxx . . $ Firstchannel.;
1095 Chan_listcxx . . $ Chan_list. = (char *)DLLmem_malloccxx . . $ DLLmem_malloc.(ichan_list_length + 1);
1096 Chan_listcxx . . $ Chan_list.[0] = '\0';
1097 while (Currchannelcxx . . $ Currchannel.) {
1098 strcat(Chan_listcxx . . $ Chan_list., "$");
1099 strcat(Chan_listcxx . . $ Chan_list., Currchannelcxx . . $ Currchannel.->channel_namecxx . . $ Chat_channel#channel_name.);
1100 strcat(Chan_listcxx . . $ Chan_list., " ");
1101 snprintf(sznumusers, sizeof(sznumusers), "%d ", Currchannelcxx . . $ Currchannel.->userscxx . . $ Chat_channel#users.);
1102 strcat(Chan_listcxx . . $ Chan_list., sznumusers);
1103 strcat(Chan_listcxx . . $ Chan_list., Currchannelcxx . . $ Currchannel.->topiccxx . . $ Chat_channel#topic.); // fgets
1104 strcat(Chan_listcxx . . $ Chan_list., " ");
1105 Currchannelcxx . . $ Currchannel. = Currchannelcxx . . $ Currchannel.->nextcxx . . $ Chat_channel#next.;
1106 }
1107 FlushChannelListcxx . . $ FlushChannelList(49f6e7a06ebc5aa8).();
1108 GettingChannelListcxx . . $ GettingChannelList. = 0;
1109 return Chan_listcxx . . $ Chan_list.;
1110 }
1111
1112 void AddChannelcxx . . $ AddChannel(2efb20bf9f5bff1e).(char *channel, uint16_tcxx . . $ uint16_t# numusers, char *topic) {
1113 Currchannelcxx . . $ Currchannel. = Firstchannelcxx . . $ Firstchannel.;
1114 if (Firstchannelcxx . . $ Firstchannel. == nullptr) {
1115 Firstchannelcxx . . $ Firstchannel. = (Chat_channelcxx . . $ Chat_channel# *)DLLmem_malloccxx . . $ DLLmem_malloc.(sizeof(Chat_channelcxx . . $ Chat_channel#));
1116 // ASSERT(Firstchannel);
1117 strcpy(Firstchannelcxx . . $ Firstchannel.->channel_namecxx . . $ Chat_channel#channel_name., channel);
1118 strcpy(Firstchannelcxx . . $ Firstchannel.->topiccxx . . $ Chat_channel#topic., topic);
1119 Firstchannelcxx . . $ Firstchannel.->userscxx . . $ Chat_channel#users. = numusers;
1120 Firstchannelcxx . . $ Firstchannel.->nextcxx . . $ Chat_channel#next. = nullptr;
1121 Currchannelcxx . . $ Currchannel. = Firstchannelcxx . . $ Firstchannel.;
1122 } else {
1123 while (Currchannelcxx . . $ Currchannel.->nextcxx . . $ Chat_channel#next.) {
1124 Currchannelcxx . . $ Currchannel. = Currchannelcxx . . $ Currchannel.->nextcxx . . $ Chat_channel#next.;
1125 }
1126 Currchannelcxx . . $ Currchannel.->nextcxx . . $ Chat_channel#next. = (Chat_channelcxx . . $ Chat_channel# *)DLLmem_malloccxx . . $ DLLmem_malloc.(sizeof(Chat_channelcxx . . $ Chat_channel#));
1127 // ASSERT(Currchannel->next);
1128 Currchannelcxx . . $ Currchannel. = Currchannelcxx . . $ Currchannel.->nextcxx . . $ Chat_channel#next.;
1129 strcpy(Currchannelcxx . . $ Currchannel.->channel_namecxx . . $ Chat_channel#channel_name., channel);
1130 strcpy(Currchannelcxx . . $ Currchannel.->topiccxx . . $ Chat_channel#topic., topic);
1131 Currchannelcxx . . $ Currchannel.->userscxx . . $ Chat_channel#users. = numusers;
1132 }
1133 Currchannelcxx . . $ Currchannel.->nextcxx . . $ Chat_channel#next. = nullptr;
1134 }
1135
1136 char *GetTrackerIdByUsercxx . . $ GetTrackerIdByUser(a8b8e32347182212).(const char *nickname) {
1137 char szWhoisCmd[100];
1138
1139 if (nickname == (char *)-1) {
1140 GettingUserTIDcxx . . $ GettingUserTID. = 0;
1141 Getting_user_tracker_errorcxx . . $ Getting_user_tracker_error. = 0;
1142 return nullptr;
1143 } else if (GettingUserTIDcxx . . $ GettingUserTID.) {
1144 if (Getting_user_tracker_errorcxx . . $ Getting_user_tracker_error.) {
1145 Getting_user_tracker_errorcxx . . $ Getting_user_tracker_error. = 0;
1146 GettingUserTIDcxx . . $ GettingUserTID. = 0;
1147 return (char *)-1;
1148 }
1149
1150 if (*User_req_tracker_idcxx . . $ User_req_tracker_id.) {
1151 GettingUserTIDcxx . . $ GettingUserTID. = 0;
1152 return User_req_tracker_idcxx . . $ User_req_tracker_id.;
1153 }
1154 } else {
1155 strcpy(Getting_user_tracker_info_forcxx . . $ Getting_user_tracker_info_for., nickname);
1156 snprintf(szWhoisCmd, sizeof(szWhoisCmd), "/WHOIS %s", nickname);
1157 User_req_tracker_idcxx . . $ User_req_tracker_id.[0] = '\0';
1158 SendChatStringcxx . . $ SendChatString(223c544933887702).(szWhoisCmd, 1);
1159 GettingUserTIDcxx . . $ GettingUserTID. = 1;
1160 }
1161 return nullptr;
1162 }
1163
1164 char *GetChannelByUsercxx . . $ GetChannelByUser(a8b8e32347182212).(const char *nickname) {
1165 char szWhoisCmd[100];
1166
1167 if (nickname == (char *)-1) {
1168 GettingUserChannelcxx . . $ GettingUserChannel. = 0;
1169 Getting_user_channel_errorcxx . . $ Getting_user_channel_error. = 0;
1170 return nullptr;
1171 } else if (GettingUserChannelcxx . . $ GettingUserChannel.) {
1172 if (Getting_user_channel_errorcxx . . $ Getting_user_channel_error.) {
1173 Getting_user_channel_errorcxx . . $ Getting_user_channel_error. = 0;
1174 GettingUserChannelcxx . . $ GettingUserChannel. = 0;
1175 return (char *)-1;
1176 }
1177 if (*User_req_channelcxx . . $ User_req_channel.) {
1178 GettingUserChannelcxx . . $ GettingUserChannel. = 0;
1179 return User_req_channelcxx . . $ User_req_channel.;
1180 }
1181 } else {
1182 strcpy(Getting_user_channel_info_forcxx . . $ Getting_user_channel_info_for., nickname);
1183 User_req_channelcxx . . $ User_req_channel.[0] = '\0';
1184 snprintf(szWhoisCmd, sizeof(szWhoisCmd), "/WHOIS %s", nickname);
1185 SendChatStringcxx . . $ SendChatString(223c544933887702).(szWhoisCmd, 1);
1186 GettingUserChannelcxx . . $ GettingUserChannel. = 1;
1187 }
1188 return nullptr;
1189 }