Debian Codegraph @

src/bnetd/friends.cpp

raw symbols SCIP
1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (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 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
18 #include "friends.h"cxx . . $ `<file>/src/bnetd/friends.h`/
19
20 #include <new>
21
22 #include "compat/strcasecmp.h"cxx . . $ `<file>/src/compat/strcasecmp.h`/
23 #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/
24 #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/
25
26 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
27
28 namespace pvpgncxx . . $ pvpgn/
29 {
30
31 namespace bnetdcxx . . $ pvpgn/bnetd/
32 {
33
34 extern t_accountcxx . . $ pvpgn/bnetd/t_account# * friend_get_accountcxx . . $ pvpgn/bnetd/friend_get_account(9d018d83140d552c).(t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr)
35 {
36 if (fr == nullptr)
37 {
38 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL friend");
39 return nullptr;
40 }
41
42 return fr->friendacccxx . . $ pvpgn/bnetd/friend_struct#friendacc.;
43 }
44
45 extern int friend_set_accountcxx . . $ pvpgn/bnetd/friend_set_account(78b07ca30a5f2982).(t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr, t_accountcxx . . $ pvpgn/bnetd/t_account# * acc)
46 {
47 if (fr == nullptr)
48 {
49 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL friend");
50 return -1;
51 }
52
53 if (acc == nullptr)
54 {
55 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL account");
56 return -1;
57 }
58
59 fr->friendacccxx . . $ pvpgn/bnetd/friend_struct#friendacc. = acc;
60 return 0;
61 }
62
63 extern char friend_get_mutualcxx . . $ pvpgn/bnetd/friend_get_mutual(1bd0d6ddce271d17).(t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr)
64 {
65 if (fr == nullptr)
66 {
67 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL friend");
68 return 0;
69 }
70
71 return fr->mutualcxx . . $ pvpgn/bnetd/friend_struct#mutual.;
72 }
73
74 extern int friend_set_mutualcxx . . $ pvpgn/bnetd/friend_set_mutual(213560cf9f8c5a35).(t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr, int mutual)
75 {
76 if (fr == nullptr)
77 {
78 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL friend");
79 return -1;
80 }
81
82 if (mutual != FRIEND_UNLOADEDMUTUALcxx . . $ `src/bnetd/friends.h:20:9`! && mutual != FRIEND_NOTMUTUALcxx . . $ `src/bnetd/friends.h:21:9`! && mutual != FRIEND_ISMUTUALcxx . . $ `src/bnetd/friends.h:22:9`!)
83 {
84 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got invalid mutual status");
85 return -1;
86 }
87
88 fr->mutualcxx . . $ pvpgn/bnetd/friend_struct#mutual. = mutual;
89 return 0;
90 }
91
92 extern int friendlist_unloadcxx . . $ pvpgn/bnetd/friendlist_unload(20db0232078327de).(t_list * flist)
93 {
94 if (flist == nullptr)
95 {
96 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL flist");
97 return -1;
98 }
99
100 t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr = nullptr;
101 t_elem * curr = nullptr;
102 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(flist, curr)
103 {
104 fr = (t_friendcxx . . $ pvpgn/bnetd/t_friend#*)elem_get_data(curr);
105 if (fr == nullptr)
106 {
107 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list");
108 continue;
109 }
110 fr->mutualcxx . . $ pvpgn/bnetd/friend_struct#mutual. = FRIEND_UNLOADEDMUTUALcxx . . $ `src/bnetd/friends.h:20:9`!;
111 }
112
113 return 0;
114 }
115
116 extern int friendlist_closecxx . . $ pvpgn/bnetd/friendlist_close(20db0232078327de).(t_list * flist)
117 {
118 if (flist == nullptr)
119 {
120 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_tracecxx . . $ pvpgn/eventlog_level_trace., __FUNCTION__, "got NULL flist");
121 return -1;
122 }
123
124 t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr = nullptr;
125 t_elem * curr = nullptr;
126 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(flist, curr)
127 {
128 fr = (t_friendcxx . . $ pvpgn/bnetd/t_friend#*)elem_get_data(curr);
129 if (fr == nullptr)
130 {
131 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list");
132 continue;
133 }
134
135 if (list_remove_elem(flist, &curr) != 0)
136 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not remove elem from flist");
137 delete(fr);
138 }
139
140 list_destroy(flist);
141
142 return 0;
143 }
144
145 extern int friendlist_purgecxx . . $ pvpgn/bnetd/friendlist_purge(20db0232078327de).(t_list * flist)
146 {
147 if (flist == nullptr)
148 {
149 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL flist");
150 return -1;
151 }
152
153 t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr = nullptr;
154 t_elem * curr = nullptr;
155 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(flist, curr)
156 {
157 fr = (t_friendcxx . . $ pvpgn/bnetd/t_friend#*)elem_get_data(curr);
158 if (fr == nullptr)
159 {
160 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list");
161 continue;
162 }
163 if (fr->mutualcxx . . $ pvpgn/bnetd/friend_struct#mutual. == FRIEND_UNLOADEDMUTUALcxx . . $ `src/bnetd/friends.h:20:9`!)
164 {
165 if (list_remove_elem(flist, &curr) != 0)
166 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not remove item from list");
167 }
168 }
169 return 0;
170 }
171
172 extern int friendlist_add_accountcxx . . $ pvpgn/bnetd/friendlist_add_account(7bf52703037b2a17).(t_list * flist, t_accountcxx . . $ pvpgn/bnetd/t_account# * acc, int mutual)
173 {
174 if (flist == nullptr)
175 {
176 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL flist");
177 return -1;
178 }
179
180 if (acc == nullptr)
181 {
182 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL account");
183 return -1;
184 }
185
186 if (mutual != FRIEND_UNLOADEDMUTUALcxx . . $ `src/bnetd/friends.h:20:9`! && mutual != FRIEND_NOTMUTUALcxx . . $ `src/bnetd/friends.h:21:9`! && mutual != FRIEND_ISMUTUALcxx . . $ `src/bnetd/friends.h:22:9`!)
187 {
188 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got invalid mutual status");
189 return -1;
190 }
191
192 t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr = new t_friendcxx . . $ pvpgn/bnetd/t_friend#; //(t_friend*)xmalloc(sizeof(t_friend));
193 fr->friendacccxx . . $ pvpgn/bnetd/friend_struct#friendacc. = acc;
194 fr->mutualcxx . . $ pvpgn/bnetd/friend_struct#mutual. = mutual;
195 list_append_data(flist, fr);
196
197 return 0;
198 }
199
200 extern int friendlist_remove_friendcxx . . $ pvpgn/bnetd/friendlist_remove_friend(d0b94f001b0983df).(t_list * flist, t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr)
201 {
202 if (flist == nullptr)
203 {
204 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL flist");
205 return -1;
206 }
207
208 if (fr == nullptr)
209 {
210 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL friend");
211 return -1;
212 }
213
214 t_elem * elem = nullptr;
215 if (list_remove_data(flist, fr, &elem) != 0)
216 {
217 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not remove item from list");
218 return -1;
219 }
220
221 delete(fr);
222 return 0;
223 }
224
225 extern int friendlist_remove_accountcxx . . $ pvpgn/bnetd/friendlist_remove_account(64175c61b32b880).(t_list * flist, t_accountcxx . . $ pvpgn/bnetd/t_account# * acc)
226 {
227 if (flist == nullptr)
228 {
229 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL flist");
230 return -1;
231 }
232
233 if (acc == nullptr)
234 {
235 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL account");
236 return -1;
237 }
238
239 t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr = friendlist_find_accountcxx . . $ pvpgn/bnetd/friendlist_find_account(b551094904635f5).(flist, acc);
240 if (fr == nullptr)
241 {
242 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not find friend");
243 return -1;
244 }
245
246 t_elem * elem = nullptr;
247 if (list_remove_data(flist, fr, &elem) != 0)
248 {
249 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not remove item from list");
250 return -1;
251 }
252
253 delete(fr);
254 return 0;
255 }
256
257 extern int friendlist_remove_usernamecxx . . $ pvpgn/bnetd/friendlist_remove_username(5c73f545432fb6b5).(t_list * flist, const char * accname)
258 {
259 if (flist == nullptr)
260 {
261 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL flist");
262 return -1;
263 }
264
265 if (accname == nullptr)
266 {
267 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL account name");
268 return -1;
269 }
270
271 t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr = friendlist_find_usernamecxx . . $ pvpgn/bnetd/friendlist_find_username(2a7eae59f8eb384d).(flist, accname);
272 if (fr == nullptr)
273 {
274 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not find friend");
275 return -1;
276 }
277
278 t_elem * elem = nullptr;
279 if (list_remove_data(flist, fr, &elem) != 0)
280 {
281 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not remove item from list");
282 return -1;
283 }
284
285 delete(fr);
286 return 0;
287 }
288
289 extern t_friendcxx . . $ pvpgn/bnetd/t_friend# * friendlist_find_accountcxx . . $ pvpgn/bnetd/friendlist_find_account(b551094904635f5).(t_list * flist, t_accountcxx . . $ pvpgn/bnetd/t_account# * acc)
290 {
291 if (flist == nullptr)
292 {
293 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL flist");
294 return nullptr;
295 }
296
297 if (acc == nullptr)
298 {
299 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL account");
300 return nullptr;
301 }
302
303 t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr = nullptr;
304 t_elem * curr = nullptr;
305 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(flist, curr)
306 {
307 fr = (t_friendcxx . . $ pvpgn/bnetd/t_friend#*)elem_get_data(curr);
308 if (fr == nullptr)
309 {
310 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list");
311 continue;
312 }
313
314 if (fr->friendacccxx . . $ pvpgn/bnetd/friend_struct#friendacc. == acc)
315 return fr;
316 }
317
318 return nullptr;
319 }
320
321 extern t_friendcxx . . $ pvpgn/bnetd/t_friend# * friendlist_find_usernamecxx . . $ pvpgn/bnetd/friendlist_find_username(2a7eae59f8eb384d).(t_list * flist, const char * accname)
322 {
323 if (flist == nullptr)
324 {
325 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL flist");
326 return nullptr;
327 }
328
329 if (accname == nullptr)
330 {
331 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL account name");
332 return nullptr;
333 }
334
335 t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr = nullptr;
336 t_elem * curr = nullptr;
337 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(flist, curr)
338 {
339 fr = (t_friendcxx . . $ pvpgn/bnetd/t_friend#*)elem_get_data(curr);
340 if (fr == nullptr)
341 {
342 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list");
343 continue;
344 }
345
346 if (strcasecmp(account_get_namecxx . . $ `src/bnetd/account.h:115:10`!(fr->friendacc), accname) == 0)
347 return fr;
348 }
349
350 return nullptr;
351 }
352
353 extern t_friendcxx . . $ pvpgn/bnetd/t_friend# * friendlist_find_uidcxx . . $ pvpgn/bnetd/friendlist_find_uid(9da8c1d9dfa566eb).(t_list * flist, unsigned int uid)
354 {
355 if (flist == nullptr)
356 {
357 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL flist");
358 return nullptr;
359 }
360
361 t_friendcxx . . $ pvpgn/bnetd/t_friend# * fr = nullptr;
362 t_elem * curr = nullptr;
363 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(flist, curr)
364 {
365 fr = (t_friendcxx . . $ pvpgn/bnetd/t_friend#*)elem_get_data(curr);
366 if (fr == nullptr)
367 {
368 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list");
369 continue;
370 }
371
372 if (account_get_uidcxx . . $ `src/bnetd/account.h:91:9`!(fr->friendacc) == uid)
373 return fr;
374 }
375 return nullptr;
376 }
377
378 }
379
380 }