| | 482 | | char *parse_special_string(const char *cmd, SERVER_REC *server, void *item, | | | 483 | | const char *data, int *arg_used, int flags) | | | 484 | | { | | | 485 | | char code, **arglist, *ret; | | | 486 | | GString *str; | | | 487 | | int need_free, chr; | | | 488 | | | | | 489 | | g_return_val_if_fail(cmd != NULL, NULL);
| | | 490 | | g_return_val_if_fail(data != NULL, NULL);
| | | 491 | | | | | 492 | | | | | 493 | | arglist = g_strsplit(data, " ", -1); | | | 494 | | | | true | 495 | | if (arg_used != NULL) *arg_used = FALSE;
| | | 496 | | code = 0; | | | 497 | | str = g_string_new(NULL);
| | | 498 | | while (*cmd != '\0') { | | | 499 | | if (code == '\\') { | | | 500 | | if (*cmd == ';') | | | 501 | | g_string_append_c(str, ';');
| | | 502 | | else { | | | 503 | | chr = expand_escape(&cmd); | | | 504 | | g_string_append_c(str, chr != -1 ? chr : *cmd);
| | | 505 | | } | | | 506 | | code = 0; | | arg_used <= 4095 | 507 | | } else if (code == '$') { | | | 508 | | char *ret; | | | 509 | | | | $param_6 <= 4095 | 510 | | ret = parse_special((char **) &cmd, server, item, | | | 511 | | arglist, &need_free, arg_used, |
| | 349 | | | | char *parse_special(char **cmd, SERVER_REC *server, void *item, | | $param_6 <= 4095 | 350 | | | | char **arglist, int *free_ret, int *arg_used, int flags) | | | 351 | | | | { | | | 352 | | | | static char **nested_orig_cmd = NULL;
| | | 353 | | | | char command, *value; | | | 354 | | | | | | | 355 | | | | char align_pad; | | | 356 | | | | int align, align_flags; | | | 357 | | | | | | | 358 | | | | char *nest_value; | | | 359 | | | | int brackets, nest_free; | | | 360 | | | | | | | 361 | | | | *free_ret = FALSE;
| | | 362 | | | | if (**cmd == '\0') | | | 363 | | | | return NULL;
| | | 364 | | | | | | | 365 | | | | command = **cmd; (*cmd)++; | | | 366 | | | | switch (command) { | | | 367 | | | | case '[': | | | 368 | | | | | | | 369 | | | | if (!get_alignment_args(cmd, &align, &align_flags, | | | 370 | | | | &align_pad) || **cmd == '\0') { | | | 371 | | | | (*cmd)--; | | | 372 | | | | return NULL;
| | | 373 | | | | } | | | 374 | | | | break; | | | 375 | | | | default: | | | 376 | | | | command = 0; | | | 377 | | | | (*cmd)--; | | | 378 | | | | } | | | 379 | | | | | | | 380 | | | | nest_free = FALSE; nest_value = NULL;
| | | 381 | | | | if (**cmd == '(' && (*cmd)[1] != '\0') { | | | 382 | | | | | | | 383 | | | | int toplevel = nested_orig_cmd == NULL;
| | | 384 | | | | | | | 385 | | | | if (toplevel) nested_orig_cmd = cmd; | | | 386 | | | | (*cmd)++; | | | 387 | | | | if (**cmd != '$') { | | | 388 | | | | | | | 389 | | | | nest_value = *cmd; | | | 390 | | | | } else { | | | 391 | | | | (*cmd)++; | | | | | | | ... | | | 400 | | | | while ((*nested_orig_cmd)[1] != '\0') { | | | 401 | | | | (*nested_orig_cmd)++; | | | 402 | | | | if (**nested_orig_cmd == ')') | | | 403 | | | | break; | | | 404 | | | | } | | | 405 | | | | cmd = &nest_value; | | | 406 | | | | | | | 407 | | | | if (toplevel) nested_orig_cmd = NULL;
| | | 408 | | | | } | | | 409 | | | | | | | 410 | | | | if (**cmd != '{') | | | 411 | | | | brackets = FALSE;
| | | 412 | | | | else { | | | 413 | | | | | | | 414 | | | | if ((*cmd)[1] == '\0') | | | 415 | | | | return NULL;
| | | 416 | | | | (*cmd)++; | | | 417 | | | | brackets = TRUE;
| | | 418 | | | | } | | | 419 | | | | | | | 420 | | | | value = get_special_value(cmd, server, item, arglist, | | | 421 | | | | free_ret, arg_used, flags); | | | 422 | | | | if (**cmd == '\0') | | | 423 | | | | g_error("parse_special() : buffer overflow!");
| | | 424 | | | | | | | 425 | | | | if (value != NULL && *value != '\0' && (flags & PARSE_FLAG_ISSET_ANY))
| | arg_used <= 4095 | 426 | | | | *arg_used = TRUE;
|
|