Debian Codegraph @

src/bnetd/alias_command.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2000 Onlyer ([email protected])
3 * Copyright (C) 2002 Ross Combs ([email protected])
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19 #define ALIAS_COMMAND_INTERNAL_ACCESScxx . . $ `src/bnetd/alias_command.cpp:19:9`!
20 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
21
22 #include <cerrno>
23 #include <cstring>
24 #include <cctype>
25
26 #include "alias_command.h"cxx . . $ `<file>/src/bnetd/alias_command.h`/
27 #include "compat/strcasecmp.h"cxx . . $ `<file>/src/compat/strcasecmp.h`/
28 #include "common/field_sizes.h"cxx . . $ `<file>/src/common/field_sizes.h`/
29 #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/
30 #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/
31 #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/
32 #include "common/xalloc.h"cxx . . $ `<file>/src/common/xalloc.h`/
33 #include "message.h"cxx . . $ `<file>/src/bnetd/message.h`/
34 #include "connection.h"cxx . . $ `<file>/src/bnetd/connection.h`/
35 #include "i18n.h"cxx . . $ `<file>/src/bnetd/i18n.h`/
36 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
37
38
39 namespace pvpgncxx . . $ pvpgn/
40 {
41
42 namespace bnetdcxx . . $ pvpgn/bnetd/
43 {
44
45 static t_listcxx . . $ pvpgn/t_list# * aliaslist_headcxx . . $ pvpgn/bnetd/aliaslist_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
46
47 #define MAX_ALIAS_LENcxx . . $ `src/bnetd/alias_command.cpp:47:9`! 32
48
49
50 static int list_aliasescxx . . $ pvpgn/bnetd/list_aliases(c4dfbc2386fe4fc3).(t_connection * c);
51 static char * replace_argscxx . . $ pvpgn/bnetd/replace_args(b62a765b6e89d250).(char const * in, unsigned int * offsets, int numargs, char const * text);
52 static int do_aliascxx . . $ pvpgn/bnetd/do_alias(973a17a902b892b0).(t_connection * c, char const * cmd, char const * args);
53
54
55 static int list_aliasescxx . . $ pvpgn/bnetd/list_aliases(c4dfbc2386fe4fc3).(t_connection * c)
56 {
57 t_elemcxx . . $ pvpgn/t_elem# const * elem1;
58 t_elemcxx . . $ pvpgn/t_elem# const * elem2;
59 t_aliascxx . . $ pvpgn/bnetd/t_alias# const * alias;
60 t_outputcxx . . $ pvpgn/bnetd/t_output# * output;
61 char temp[MAX_MESSAGE_LENcxx . . $ MAX_MESSAGE_LEN.];
62
63 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_infocxx . . $ pvpgn/bnetd/message_type_info., c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "Alias list:"));
64 LIST_TRAVERSE_CONSTcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:95:9`!(aliaslist_head, elem1)
65 {
66 if (!(alias = (t_aliascxx . . $ pvpgn/bnetd/t_alias#*)elem_get_data(elem1)))
67 continue;
68
69 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(temp, "@%.128s", alias->aliascxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#alias.);
70 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(61daf7e3ba1862c4).(c, message_type_infocxx . . $ pvpgn/bnetd/message_type_info., c, temp);
71 LIST_TRAVERSE_CONSTcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:95:9`!(alias->output, elem2)
72 {
73 if (!(output = (t_outputcxx . . $ pvpgn/bnetd/t_output#*)elem_get_data(elem2)))
74 continue;
75
76 /*
77 * FIXME: need a more user-friendly way to express this... maybe
78 * add a help line to the file format?
79 */
80 if (output->mincxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#min. == -1)
81 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(temp, "[*]%.128s", output->linecxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#line.);
82 else if (output->maxcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#max. == -1)
83 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(temp, "[%d+]%.128s", output->mincxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#min., output->linecxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#line.);
84 else if (output->mincxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#min. == output->maxcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#max.)
85 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(temp, "[%d]%.128s", output->mincxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#min., output->linecxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#line.);
86 else
87 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(temp, "[%d-%d]%.128s", output->mincxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#min., output->maxcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#max., output->linecxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#line.);
88 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(61daf7e3ba1862c4).(c, message_type_infocxx . . $ pvpgn/bnetd/message_type_info., c, temp);
89 }
90 }
91 return 0;
92 }
93
94
95 static char * replace_argscxx . . $ pvpgn/bnetd/replace_args(b62a765b6e89d250).(char const * in, unsigned int * offsets, int numargs, char const * text)
96 {
97 char * out;
98 unsigned int inpos;
99 unsigned int outpos;
100 unsigned int off1;
101 unsigned int off2;
102 unsigned int size;
103
104 off1 = off2 = 0;
105
106 out = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(in);
107 size = stdcxx . . $ std/::strlen(out);
108 size_t textlen = stdcxx . . $ std/::strlen(text);
109
110 for (inpos = outpos = 0; inpos < stdcxx . . $ std/::strlen(in); inpos++)
111 {
112 if (in[inpos] != '$')
113 {
114 out[outpos] = in[inpos];
115 outpos++;
116 continue;
117 }
118
119 inpos++;
120
121 if (in[inpos] == '*')
122 {
123 off1 = offsets[0];
124 off2 = textlen;
125 }
126 else if (in[inpos] == '{')
127 {
128 int arg1, arg2;
129 char symbol;
130
131 if (stdcxx . . $ std/::sscanfcxx . . $ std/sscanf(6246fabbf6b5312d).(&in[inpos], "{%d-%d}", &arg1, &arg2) != 2)
132 {
133 if (stdcxx . . $ std/::sscanfcxx . . $ std/sscanf(6246fabbf6b5312d).(&in[inpos], "{%d%c", &arg2, &symbol) != 2)
134 {
135 while (in[inpos] != '\0' && in[inpos] != '}')
136 inpos++;
137 continue;
138 }
139 else
140 {
141 if (symbol == '}')
142 {
143 if (arg2 < 0)
144 {
145 arg1 = 0;
146 arg2 = -arg2;
147 }
148 else
149 {
150 arg1 = arg2;
151 }
152 }
153 else if (symbol == '-')
154 {
155 arg1 = arg2;
156 arg2 = numargs - 1;
157 }
158 else
159 {
160 while (in[inpos] != '\0' && in[inpos] != '}') inpos++;
161 continue;
162 }
163
164 }
165 }
166
167 if (arg2 >= numargs)
168 arg2 = numargs - 1;
169 if (arg1 > arg2)
170 {
171 while (in[inpos] != '\0' && in[inpos] != '}')
172 inpos++;
173 continue;
174 }
175 off1 = offsets[arg1];
176 if (arg2 + 1 == numargs)
177 off2 = textlen;
178 else
179 off2 = offsets[arg2 + 1] - 1;
180
181 while (in[inpos] != '\0' && in[inpos] != '}')
182 inpos++;
183 }
184 else if (stdcxx . . $ std/::isdigitcxx . . $ std/isdigit(a1851578aea3f541).((int)in[inpos]))
185 {
186 int arg;
187
188 if (in[inpos] == '0') arg = 0;
189 else if (in[inpos] == '1') arg = 1;
190 else if (in[inpos] == '2') arg = 2;
191 else if (in[inpos] == '3') arg = 3;
192 else if (in[inpos] == '4') arg = 4;
193 else if (in[inpos] == '5') arg = 5;
194 else if (in[inpos] == '6') arg = 6;
195 else if (in[inpos] == '7') arg = 7;
196 else if (in[inpos] == '8') arg = 8;
197 else arg = 9;
198
199 if (arg >= numargs)
200 continue;
201 for (off1 = off2 = offsets[arg]; text[off2] != '\0' && text[off2] != ' ' && text[off2] != '\t'; off2++);
202 }
203
204 {
205 char * newout;
206
207 newout = (char*)xmalloccxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:43:9`!(size + (off2 - off1) + 1); /* curr + new + nul */
208 size = size + (off2 - off1) + 1;
209 stdcxx . . $ std/::memmove(newout, out, outpos);
210 xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(out);
211 out = newout;
212
213 while (off1 < off2)
214 out[outpos++] = text[off1++];
215 }
216 }
217 out[outpos] = '\0';
218
219 return out;
220 }
221
222 int count_argscxx . . $ pvpgn/bnetd/count_args(5c4306d8553b3696).(char const * text)
223 {
224 int args = 1;
225 char * pointer = (char *)text;
226 int not_ws = 1;
227
228 for (; *pointer != '\0'; pointer++)
229 {
230 if ((not_ws) && (*pointer == ' ')) not_ws = 0;
231 if ((not_ws == 0) && (*pointer != ' ')) { not_ws = 1; args++; }
232 }
233
234 return args;
235 }
236
237 void get_offsetscxx . . $ pvpgn/bnetd/get_offsets(8d33a2061a03c434).(char const * text, unsigned int * offsets)
238 {
239 char * pointer = (char *)text;
240 int counter = 1;
241 int not_ws = 1;
242
243 offsets[0] = 0;
244 for (; *pointer != '\0'; pointer++)
245 {
246 if ((not_ws) && (*pointer == ' ')) not_ws = 0;
247 if ((not_ws == 0) && (*pointer != ' '))
248 {
249 not_ws = 1;
250 offsets[counter] = (unsigned int)(pointer - text);
251 counter++;
252 }
253 }
254
255 }
256
257 static int do_aliascxx . . $ pvpgn/bnetd/do_alias(973a17a902b892b0).(t_connection * c, char const * cmd, char const * text)
258 {
259 t_elemcxx . . $ pvpgn/t_elem# const * elem1;
260 t_elemcxx . . $ pvpgn/t_elem# const * elem2;
261 t_aliascxx . . $ pvpgn/bnetd/t_alias# const * alias;
262 t_outputcxx . . $ pvpgn/bnetd/t_output# * output;
263 unsigned int * offsets;
264 int numargs;
265 int match = -1;
266
267 numargs = count_argscxx . . $ pvpgn/bnetd/count_args(5c4306d8553b3696).(text) - 1;
268 offsets = (unsigned int*)xmalloccxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:43:9`!(sizeof(unsigned int)*(numargs + 1));
269 get_offsetscxx . . $ pvpgn/bnetd/get_offsets(8d33a2061a03c434).(text, offsets);
270
271 LIST_TRAVERSE_CONSTcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:95:9`!(aliaslist_head, elem1)
272 {
273 if (!(alias = (t_aliascxx . . $ pvpgn/bnetd/t_alias#*)elem_get_data(elem1)))
274 continue;
275
276 if (stdcxx . . $ std/::strstr(alias->aliascxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#alias., cmd) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
277 continue;
278
279 LIST_TRAVERSE_CONSTcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:95:9`!(alias->output, elem2)
280 {
281 if (!(output = (t_outputcxx . . $ pvpgn/bnetd/t_output#*)elem_get_data(elem2)))
282 continue;
283
284 if (!output->linecxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#line.)
285 continue;
286
287 if ((output->mincxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#min. == -1) ||
288 ((output->mincxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#min. <= numargs) && (output->maxcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#max. == -1)) ||
289 ((output->mincxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#min. <= numargs) && (output->maxcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#max. >= numargs)))
290
291 //TODO: initialize offsets
292
293 {
294 char * msgtmp;
295 char * tmp2;
296 const char * cmd = "%C";
297 match = 1;
298
299 if ((msgtmp = replace_argscxx . . $ pvpgn/bnetd/replace_args(b62a765b6e89d250).(output->linecxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#line., offsets, numargs + 1, text)))
300 {
301 if (msgtmp[0] != '\0')
302 {
303 if ((msgtmp[0] == '/') && (msgtmp[1] != '/')) // to make sure we don't get endless aliasing loop
304 {
305 tmp2 = (char*)xmalloccxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:43:9`!(std::strlen(msgtmp) + 3);
306 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(tmp2, "%s%s", cmd, msgtmp);
307 xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void *)msgtmp);
308 msgtmp = tmp2;
309
310 }
311 if (stdcxx . . $ std/::strlen(msgtmp) > MAX_MESSAGE_LENcxx . . $ MAX_MESSAGE_LEN.)
312 {
313 msgtmp[MAX_MESSAGE_LENcxx . . $ MAX_MESSAGE_LEN.] = '\0';
314 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "message line after alias expansion was too long, truncating it");
315 }
316 message_send_formattedcxx . . $ pvpgn/bnetd/message_send_formatted(2e9022cda97b266d).(c, msgtmp);
317 }
318 xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void *)msgtmp); /* avoid warning */
319 }
320 else
321 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not perform argument replacement");
322 }
323 }
324 }
325 xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(offsets);
326 return match;
327 }
328
329
330 extern int aliasfile_loadcxx . . $ pvpgn/bnetd/aliasfile_load(5c4306d8553b3696).(char const * filename)
331 {
332 stdcxx . . $ std/::FILEcxx . . $ std/FILE# * afp;
333 char * buff;
334 char * temp;
335 unsigned int line;
336 unsigned int pos;
337 int inalias;
338 t_aliascxx . . $ pvpgn/bnetd/t_alias# * alias = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
339
340
341 if (!filename)
342 {
343 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL filename");
344 return -1;
345 }
346 if (!(afp = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(filename, "r")))
347 {
348 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "unable to open alias file \"{}\" for reading (std::fopen: {})", filename, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
349 return -1;
350 }
351
352 aliaslist_headcxx . . $ pvpgn/bnetd/aliaslist_head. = list_create();
353
354 inalias = 0;
355 for (line = 1; (buff = file_get_linecxx . . $ pvpgn/file_get_line(e31226b218f63160).(afp)); line++)
356 {
357 for (pos = 0; buff[pos] == '\t' || buff[pos] == ' '; pos++);
358 if (buff[pos] == '\0' || buff[pos] == '#')
359 {
360 continue;
361 }
362 if (!(temp = stdcxx . . $ std/::strrchr(buff, '"'))) /* FIXME: assumes comments don't contain " */
363 temp = buff;
364 if ((temp = stdcxx . . $ std/::strrchr(temp, '#')))
365 {
366 unsigned int len;
367 unsigned int endpos;
368
369 *temp = '\0';
370 len = stdcxx . . $ std/::strlen(buff) + 1;
371 for (endpos = len - 1; buff[endpos] == '\t' || buff[endpos] == ' '; endpos--);
372 buff[endpos + 1] = '\0';
373 }
374
375 switch (inalias)
376 {
377 case 0:
378 if (buff[pos] != '@') /* not start of alias */
379 {
380 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "expected start of alias stanza on line {} of alias file \"{}\" but found \"{}\"", line, filename, &buff[pos]);
381 break;
382 }
383 inalias = 1;
384 break;
385
386 case 1:
387 {
388 if (buff[pos] == '\0') break;
389
390 inalias = 2;
391 alias = (t_aliascxx . . $ pvpgn/bnetd/t_alias#*)xmalloccxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:43:9`!(sizeof(t_alias));
392 alias->outputcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#output. = 0;
393 alias->aliascxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#alias. = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(&buff[pos]);
394 }
395 break;
396
397 case 2:
398 {
399 char * dummy;
400 char * out = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
401 int min, max;
402 t_outputcxx . . $ pvpgn/bnetd/t_output# * output;
403
404 min = max = 0;
405 if (buff[pos] != '[')
406 {
407 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "expected output entry on line {} of alias file \"{}\" but found \"{}\"", line, filename, &buff[pos]);
408 break;
409 }
410
411 if ((dummy = stdcxx . . $ std/::strchr(&buff[pos], ']')))
412 {
413 if (dummy[1] != '\0') out = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(&dummy[1]);
414 }
415
416 if (buff[pos + 1] == '*')
417 {
418 min = max = -1;
419 }
420 else if (buff[pos + 1] == '+')
421 {
422 min = 1;
423 max = -1;
424 }
425 else if (stdcxx . . $ std/::sscanfcxx . . $ std/sscanf(6246fabbf6b5312d).(&buff[pos], "[%i", &min) == 1)
426 {
427 if (*(dummy - 1) == '+')
428 max = -1;
429 else max = min;
430 }
431 else
432 {
433 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "error parsing min/max value for alias output");
434 }
435
436 if (out != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
437 {
438 output = (t_outputcxx . . $ pvpgn/bnetd/t_output#*)xmalloccxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:43:9`!(sizeof(t_output));
439 output->mincxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#min. = min;
440 output->maxcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#max. = max;
441 output->linecxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#line. = out;
442 alias->outputcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#output. = list_create();
443 list_append_data(alias->outputcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#output., output);
444 inalias = 3;
445 }
446 }
447 break;
448 case 3:
449 {
450 if (buff[pos] == '@')
451 {
452 inalias = 1;
453 if (alias != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) list_append_data(aliaslist_headcxx . . $ pvpgn/bnetd/aliaslist_head., alias);
454 alias = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
455 break;
456 }
457 else if (buff[pos] == '[')
458 {
459 char * dummy;
460 char * out = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
461 int min, max;
462 t_outputcxx . . $ pvpgn/bnetd/t_output# * output;
463
464 min = max = 0;
465 if ((dummy = stdcxx . . $ std/::strchr(&buff[pos], ']')))
466 {
467 if (dummy[1] != '\0') out = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(&dummy[1]);
468 }
469
470
471 if (buff[pos + 1] == '*')
472 {
473 min = max = -1;
474 }
475 else if (buff[pos + 1] == '+')
476 {
477 min = 1;
478 max = -1;
479 }
480 else if (stdcxx . . $ std/::sscanfcxx . . $ std/sscanf(6246fabbf6b5312d).(&buff[pos], "[%i", &min) == 1)
481 {
482 if (*(dummy - 1) == '+')
483 max = -1;
484 else max = min;
485 }
486 else
487 {
488 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "error parsing min/max value for alias output");
489 }
490
491 if (out != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
492 {
493 output = (t_outputcxx . . $ pvpgn/bnetd/t_output#*)xmalloccxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:43:9`!(sizeof(t_output));
494 output->mincxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#min. = min;
495 output->maxcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#max. = max;
496 output->linecxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_0#line. = out;
497
498 list_append_data(alias->outputcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#output., output);
499 }
500 }
501 else
502 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "expected output entry or next alias stanza on line {} of file \"{}\"i but found \"{}\"", line, filename, &buff[pos]);
503 break;
504 }
505 }
506 }
507 if (alias != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) list_append_data(aliaslist_headcxx . . $ pvpgn/bnetd/aliaslist_head., alias);
508
509 file_get_linecxx . . $ pvpgn/file_get_line(e31226b218f63160).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); // clear file_get_line buffer
510 stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(afp);
511 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "done loading aliases");
512 return 0;
513 }
514
515
516 extern int aliasfile_unloadcxx . . $ pvpgn/bnetd/aliasfile_unload(b126dc7c1de90089).(void)
517 {
518 t_elemcxx . . $ pvpgn/t_elem# * elem1;
519 t_elemcxx . . $ pvpgn/t_elem# * elem2;
520 t_aliascxx . . $ pvpgn/bnetd/t_alias# const * alias;
521 t_outputcxx . . $ pvpgn/bnetd/t_output# * output;
522
523 if (aliaslist_headcxx . . $ pvpgn/bnetd/aliaslist_head.)
524 {
525 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(aliaslist_head, elem1)
526 {
527 if (!(alias = (t_aliascxx . . $ pvpgn/bnetd/t_alias#*)elem_get_data(elem1))) /* should not happen */
528 {
529 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "alias list contains NULL item");
530 continue;
531 }
532
533 if (list_remove_elem(aliaslist_headcxx . . $ pvpgn/bnetd/aliaslist_head., &elem1) < 0)
534 {
535 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not remove alias");
536 continue;
537 }
538 if (alias->outputcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#output.)
539 {
540 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(alias->output, elem2)
541 {
542 if (!(output = (t_outputcxx . . $ pvpgn/bnetd/t_output#*)elem_get_data(elem2)))
543 {
544 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "output list contains NULL item");
545 continue;
546 }
547
548 if (list_remove_elem(alias->outputcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#output., &elem2) < 0)
549 {
550 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not remove output");
551 continue;
552 }
553 xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void *)output->line); /* avoid warning */
554 xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void *)output);
555 }
556 list_destroy(alias->outputcxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#output.);
557 }
558 if (alias->aliascxx . . $ pvpgn/bnetd/$anonymous_type_5832d4721bf0229a_1#alias.) xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void *)alias->alias);
559 xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void *)alias);
560 }
561
562 if (list_destroy(aliaslist_headcxx . . $ pvpgn/bnetd/aliaslist_head.) < 0)
563 return -1;
564 aliaslist_headcxx . . $ pvpgn/bnetd/aliaslist_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
565 }
566
567 return 0;
568 }
569
570
571 extern int handle_alias_commandcxx . . $ pvpgn/bnetd/handle_alias_command(2e9022cda97b266d).(t_connection * c, char const * text)
572 {
573 unsigned int i, j;
574 char cmd[MAX_COMMAND_LENcxx . . $ MAX_COMMAND_LEN.];
575
576 for (i = j = 0; text[i] != ' ' && text[i] != '\0'; i++) /* get command */
577 if (j < sizeof(cmd)-1) cmd[j++] = text[i];
578 cmd[j] = '\0';
579
580 if (cmd[2] == '\0')
581 return list_aliasescxx . . $ pvpgn/bnetd/list_aliases(c4dfbc2386fe4fc3).(c);
582
583 if (do_aliascxx . . $ pvpgn/bnetd/do_alias(973a17a902b892b0).(c, cmd, text) < 0)
584 {
585 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_infocxx . . $ pvpgn/bnetd/message_type_info., c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "No such alias. Use // to show the list."));
586 return -1;
587 }
588 return 0;
589 }
590
591 }
592
593 }