524 |
ptr_args = NULL; |
ptr_args = NULL; |
525 |
} |
} |
526 |
|
|
527 |
argv = explode_string (ptr_args, " ", 0, &argc); |
if (!plugin_exec_command (command + 1, ptr_args)) |
|
|
|
|
for (i = 0; weechat_commands[i].command_name; i++) |
|
528 |
{ |
{ |
529 |
if (strcasecmp (weechat_commands[i].command_name, command + 1) == 0) |
argv = explode_string (ptr_args, " ", 0, &argc); |
530 |
|
|
531 |
|
for (i = 0; weechat_commands[i].command_name; i++) |
532 |
{ |
{ |
533 |
if ((argc < weechat_commands[i].min_arg) |
if (strcasecmp (weechat_commands[i].command_name, command + 1) == 0) |
|
|| (argc > weechat_commands[i].max_arg)) |
|
|
{ |
|
|
if (weechat_commands[i].min_arg == |
|
|
weechat_commands[i].max_arg) |
|
|
gui_printf (NULL, |
|
|
_("%s wrong argument count for %s command \"%s\" " |
|
|
"(expected: %d arg%s)\n"), |
|
|
WEECHAT_ERROR, PACKAGE_NAME, |
|
|
command + 1, |
|
|
weechat_commands[i].max_arg, |
|
|
(weechat_commands[i].max_arg > |
|
|
1) ? "s" : ""); |
|
|
else |
|
|
gui_printf (NULL, |
|
|
_("%s wrong argument count for %s command \"%s\" " |
|
|
"(expected: between %d and %d arg%s)\n"), |
|
|
WEECHAT_ERROR, PACKAGE_NAME, |
|
|
command + 1, |
|
|
weechat_commands[i].min_arg, |
|
|
weechat_commands[i].max_arg, |
|
|
(weechat_commands[i].max_arg > |
|
|
1) ? "s" : ""); |
|
|
} |
|
|
else |
|
534 |
{ |
{ |
535 |
if (weechat_commands[i].cmd_function_args) |
if ((argc < weechat_commands[i].min_arg) |
536 |
return_code = (int) (weechat_commands[i].cmd_function_args) |
|| (argc > weechat_commands[i].max_arg)) |
537 |
(argc, argv); |
{ |
538 |
else |
if (weechat_commands[i].min_arg == |
539 |
return_code = (int) (weechat_commands[i].cmd_function_1arg) |
weechat_commands[i].max_arg) |
540 |
(ptr_args); |
gui_printf (NULL, |
541 |
if (return_code < 0) |
_("%s wrong argument count for %s command \"%s\" " |
542 |
gui_printf (NULL, |
"(expected: %d arg%s)\n"), |
543 |
_("%s %s command \"%s\" failed\n"), |
WEECHAT_ERROR, PACKAGE_NAME, |
544 |
WEECHAT_ERROR, PACKAGE_NAME, command + 1); |
command + 1, |
545 |
} |
weechat_commands[i].max_arg, |
546 |
if (argv) |
(weechat_commands[i].max_arg > |
547 |
{ |
1) ? "s" : ""); |
548 |
for (j = 0; argv[j]; j++) |
else |
549 |
free (argv[j]); |
gui_printf (NULL, |
550 |
free (argv); |
_("%s wrong argument count for %s command \"%s\" " |
551 |
} |
"(expected: between %d and %d arg%s)\n"), |
552 |
return 1; |
WEECHAT_ERROR, PACKAGE_NAME, |
553 |
} |
command + 1, |
554 |
} |
weechat_commands[i].min_arg, |
555 |
for (i = 0; irc_commands[i].command_name; i++) |
weechat_commands[i].max_arg, |
556 |
{ |
(weechat_commands[i].max_arg > |
557 |
if ((strcasecmp (irc_commands[i].command_name, command + 1) == 0) && |
1) ? "s" : ""); |
558 |
((irc_commands[i].cmd_function_args) || |
} |
|
(irc_commands[i].cmd_function_1arg))) |
|
|
{ |
|
|
if ((argc < irc_commands[i].min_arg) |
|
|
|| (argc > irc_commands[i].max_arg)) |
|
|
{ |
|
|
if (irc_commands[i].min_arg == irc_commands[i].max_arg) |
|
|
gui_printf |
|
|
(NULL, |
|
|
_("%s wrong argument count for IRC command \"%s\" " |
|
|
"(expected: %d arg%s)\n"), |
|
|
WEECHAT_ERROR, |
|
|
command + 1, |
|
|
irc_commands[i].max_arg, |
|
|
(irc_commands[i].max_arg > 1) ? "s" : ""); |
|
559 |
else |
else |
560 |
gui_printf |
{ |
561 |
(NULL, |
if (weechat_commands[i].cmd_function_args) |
562 |
_("%s wrong argument count for IRC command \"%s\" " |
return_code = (int) (weechat_commands[i].cmd_function_args) |
563 |
"(expected: between %d and %d arg%s)\n"), |
(argc, argv); |
564 |
WEECHAT_ERROR, |
else |
565 |
command + 1, |
return_code = (int) (weechat_commands[i].cmd_function_1arg) |
566 |
irc_commands[i].min_arg, irc_commands[i].max_arg, |
(ptr_args); |
567 |
(irc_commands[i].max_arg > 1) ? "s" : ""); |
if (return_code < 0) |
568 |
|
gui_printf (NULL, |
569 |
|
_("%s %s command \"%s\" failed\n"), |
570 |
|
WEECHAT_ERROR, PACKAGE_NAME, command + 1); |
571 |
|
} |
572 |
|
if (argv) |
573 |
|
{ |
574 |
|
for (j = 0; argv[j]; j++) |
575 |
|
free (argv[j]); |
576 |
|
free (argv); |
577 |
|
} |
578 |
|
return 1; |
579 |
} |
} |
580 |
else |
} |
581 |
|
for (i = 0; irc_commands[i].command_name; i++) |
582 |
|
{ |
583 |
|
if ((strcasecmp (irc_commands[i].command_name, command + 1) == 0) && |
584 |
|
((irc_commands[i].cmd_function_args) || |
585 |
|
(irc_commands[i].cmd_function_1arg))) |
586 |
{ |
{ |
587 |
if ((irc_commands[i].need_connection) && |
if ((argc < irc_commands[i].min_arg) |
588 |
((!server) || (!server->is_connected))) |
|| (argc > irc_commands[i].max_arg)) |
589 |
{ |
{ |
590 |
gui_printf (NULL, |
if (irc_commands[i].min_arg == irc_commands[i].max_arg) |
591 |
_("%s command \"%s\" needs a server connection!\n"), |
gui_printf |
592 |
WEECHAT_ERROR, irc_commands[i].command_name); |
(NULL, |
593 |
return 0; |
_("%s wrong argument count for IRC command \"%s\" " |
594 |
} |
"(expected: %d arg%s)\n"), |
595 |
if (irc_commands[i].cmd_function_args) |
WEECHAT_ERROR, |
596 |
return_code = (int) (irc_commands[i].cmd_function_args) |
command + 1, |
597 |
(server, argc, argv); |
irc_commands[i].max_arg, |
598 |
|
(irc_commands[i].max_arg > 1) ? "s" : ""); |
599 |
|
else |
600 |
|
gui_printf |
601 |
|
(NULL, |
602 |
|
_("%s wrong argument count for IRC command \"%s\" " |
603 |
|
"(expected: between %d and %d arg%s)\n"), |
604 |
|
WEECHAT_ERROR, |
605 |
|
command + 1, |
606 |
|
irc_commands[i].min_arg, irc_commands[i].max_arg, |
607 |
|
(irc_commands[i].max_arg > 1) ? "s" : ""); |
608 |
|
} |
609 |
else |
else |
610 |
return_code = (int) (irc_commands[i].cmd_function_1arg) |
{ |
611 |
(server, ptr_args); |
if ((irc_commands[i].need_connection) && |
612 |
if (return_code < 0) |
((!server) || (!server->is_connected))) |
613 |
gui_printf (NULL, |
{ |
614 |
_("%s IRC command \"%s\" failed\n"), |
gui_printf (NULL, |
615 |
WEECHAT_ERROR, command + 1); |
_("%s command \"%s\" needs a server connection!\n"), |
616 |
} |
WEECHAT_ERROR, irc_commands[i].command_name); |
617 |
if (argv) |
return 0; |
618 |
{ |
} |
619 |
for (j = 0; argv[j]; j++) |
if (irc_commands[i].cmd_function_args) |
620 |
free (argv[j]); |
return_code = (int) (irc_commands[i].cmd_function_args) |
621 |
free (argv); |
(server, argc, argv); |
622 |
|
else |
623 |
|
return_code = (int) (irc_commands[i].cmd_function_1arg) |
624 |
|
(server, ptr_args); |
625 |
|
if (return_code < 0) |
626 |
|
gui_printf (NULL, |
627 |
|
_("%s IRC command \"%s\" failed\n"), |
628 |
|
WEECHAT_ERROR, command + 1); |
629 |
|
} |
630 |
|
if (argv) |
631 |
|
{ |
632 |
|
for (j = 0; argv[j]; j++) |
633 |
|
free (argv[j]); |
634 |
|
free (argv); |
635 |
|
} |
636 |
|
return 1; |
637 |
} |
} |
|
return 1; |
|
638 |
} |
} |
639 |
} |
for (ptr_alias = weechat_alias; ptr_alias; |
640 |
for (ptr_alias = weechat_alias; ptr_alias; |
ptr_alias = ptr_alias->next_alias) |
|
ptr_alias = ptr_alias->next_alias) |
|
|
{ |
|
|
if (strcasecmp (ptr_alias->alias_name, command + 1) == 0) |
|
641 |
{ |
{ |
642 |
if (ptr_args) |
if (strcasecmp (ptr_alias->alias_name, command + 1) == 0) |
643 |
{ |
{ |
644 |
length1 = strlen (ptr_alias->alias_command); |
if (ptr_args) |
645 |
length2 = strlen (ptr_args); |
{ |
646 |
alias_command = (char *)malloc (length1 + 1 + length2 + 1); |
length1 = strlen (ptr_alias->alias_command); |
647 |
strcpy (alias_command, ptr_alias->alias_command); |
length2 = strlen (ptr_args); |
648 |
alias_command[length1] = ' '; |
alias_command = (char *)malloc (length1 + 1 + length2 + 1); |
649 |
strcpy (alias_command + length1 + 1, ptr_args); |
strcpy (alias_command, ptr_alias->alias_command); |
650 |
exec_weechat_command (server, alias_command); |
alias_command[length1] = ' '; |
651 |
free (alias_command); |
strcpy (alias_command + length1 + 1, ptr_args); |
652 |
|
exec_weechat_command (server, alias_command); |
653 |
|
free (alias_command); |
654 |
|
} |
655 |
|
else |
656 |
|
exec_weechat_command (server, ptr_alias->alias_command); |
657 |
|
|
658 |
|
if (argv) |
659 |
|
{ |
660 |
|
for (j = 0; argv[j]; j++) |
661 |
|
free (argv[j]); |
662 |
|
free (argv); |
663 |
|
} |
664 |
|
return 1; |
665 |
} |
} |
666 |
else |
} |
667 |
exec_weechat_command (server, ptr_alias->alias_command); |
gui_printf (NULL, |
668 |
|
_("%s unknown command \"%s\" (type /help for help)\n"), |
669 |
if (argv) |
WEECHAT_ERROR, |
670 |
{ |
command + 1); |
671 |
for (j = 0; argv[j]; j++) |
if (argv) |
672 |
free (argv[j]); |
{ |
673 |
free (argv); |
for (j = 0; argv[j]; j++) |
674 |
} |
free (argv[j]); |
675 |
return 1; |
free (argv); |
676 |
} |
} |
|
} |
|
|
gui_printf (NULL, |
|
|
_("%s unknown command \"%s\" (type /help for help)\n"), |
|
|
WEECHAT_ERROR, |
|
|
command + 1); |
|
|
if (argv) |
|
|
{ |
|
|
for (j = 0; argv[j]; j++) |
|
|
free (argv[j]); |
|
|
free (argv); |
|
677 |
} |
} |
678 |
return 0; |
return 0; |
679 |
} |
} |
769 |
WEECHAT_ERROR, "alias"); |
WEECHAT_ERROR, "alias"); |
770 |
return -1; |
return -1; |
771 |
} |
} |
|
index_command_new (arguments); |
|
772 |
if (!alias_new (arguments, pos)) |
if (!alias_new (arguments, pos)) |
773 |
return -1; |
return -1; |
774 |
|
index_command_new (arguments); |
775 |
gui_printf (NULL, _("Alias \"%s\" => \"%s\" created\n"), |
gui_printf (NULL, _("Alias \"%s\" => \"%s\" created\n"), |
776 |
arguments, pos); |
arguments, pos); |
777 |
} |
} |
1001 |
if (strcmp (argv[0], "load") == 0) |
if (strcmp (argv[0], "load") == 0) |
1002 |
{ |
{ |
1003 |
/* load Perl script */ |
/* load Perl script */ |
1004 |
plugins_load (PLUGIN_PERL, argv[1]); |
plugin_load (PLUGIN_PERL, argv[1]); |
1005 |
} |
} |
1006 |
else |
else |
1007 |
{ |
{ |