mirror of
https://github.com/weechat/weechat.git
synced 2026-07-07 10:13:12 +02:00
api: return value in function command(), remove WeeChat error after command callback if return code is WEECHAT_RC_ERROR
This commit is contained in:
+103
-145
@@ -224,8 +224,7 @@ COMMAND_CALLBACK(bar)
|
||||
/* add a new bar */
|
||||
if (string_strcasecmp (argv[1], "add") == 0)
|
||||
{
|
||||
if (argc < 8)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(8, "add");
|
||||
pos_condition = strchr (argv[3], ',');
|
||||
if (pos_condition)
|
||||
{
|
||||
@@ -329,8 +328,7 @@ COMMAND_CALLBACK(bar)
|
||||
/* delete a bar */
|
||||
if (string_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "del");
|
||||
if (string_strcasecmp (argv[2], "-all") == 0)
|
||||
{
|
||||
gui_bar_free_all ();
|
||||
@@ -361,8 +359,7 @@ COMMAND_CALLBACK(bar)
|
||||
/* set a bar property */
|
||||
if (string_strcasecmp (argv[1], "set") == 0)
|
||||
{
|
||||
if (argc < 5)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(5, "set");
|
||||
ptr_bar = gui_bar_search (argv[2]);
|
||||
if (!ptr_bar)
|
||||
{
|
||||
@@ -387,8 +384,7 @@ COMMAND_CALLBACK(bar)
|
||||
/* hide a bar */
|
||||
if (string_strcasecmp (argv[1], "hide") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "hide");
|
||||
ptr_bar = gui_bar_search (argv[2]);
|
||||
if (!ptr_bar)
|
||||
{
|
||||
@@ -406,8 +402,7 @@ COMMAND_CALLBACK(bar)
|
||||
/* show a bar */
|
||||
if (string_strcasecmp (argv[1], "show") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "show");
|
||||
ptr_bar = gui_bar_search (argv[2]);
|
||||
if (!ptr_bar)
|
||||
{
|
||||
@@ -425,8 +420,7 @@ COMMAND_CALLBACK(bar)
|
||||
/* toggle a bar visible/hidden */
|
||||
if (string_strcasecmp (argv[1], "toggle") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "toggle");
|
||||
ptr_bar = gui_bar_search (argv[2]);
|
||||
if (!ptr_bar)
|
||||
{
|
||||
@@ -444,8 +438,7 @@ COMMAND_CALLBACK(bar)
|
||||
/* scroll in a bar */
|
||||
if (string_strcasecmp (argv[1], "scroll") == 0)
|
||||
{
|
||||
if (argc < 5)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(5, "scroll");
|
||||
ptr_bar = gui_bar_search (argv[2]);
|
||||
if (ptr_bar)
|
||||
{
|
||||
@@ -478,7 +471,7 @@ COMMAND_CALLBACK(bar)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -644,8 +637,7 @@ COMMAND_CALLBACK(buffer)
|
||||
/* move buffer to another number in the list */
|
||||
if (string_strcasecmp (argv[1], "move") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "move");
|
||||
if (strcmp (argv[2], "-") == 0)
|
||||
{
|
||||
gui_buffer_move_to_number (buffer, gui_buffers->number);
|
||||
@@ -689,8 +681,7 @@ COMMAND_CALLBACK(buffer)
|
||||
/* swap buffers */
|
||||
if (string_strcasecmp (argv[1], "swap") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "swap");
|
||||
|
||||
ptr_buffer = NULL;
|
||||
ptr_buffer2 = NULL;
|
||||
@@ -716,8 +707,7 @@ COMMAND_CALLBACK(buffer)
|
||||
/* merge buffer with another number in the list */
|
||||
if (string_strcasecmp (argv[1], "merge") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "merge");
|
||||
error = NULL;
|
||||
number = strtol (argv[2], &error, 10);
|
||||
if (error && !error[0])
|
||||
@@ -762,7 +752,7 @@ COMMAND_CALLBACK(buffer)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
if (!command_buffer_check_number ((int)number))
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
}
|
||||
gui_buffer_unmerge (buffer, (int)number);
|
||||
@@ -939,7 +929,7 @@ COMMAND_CALLBACK(buffer)
|
||||
if (!error || error[0])
|
||||
{
|
||||
free (str_number1);
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1013,8 +1003,7 @@ COMMAND_CALLBACK(buffer)
|
||||
/* set notify level */
|
||||
if (string_strcasecmp (argv[1], "notify") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "notify");
|
||||
if (!config_weechat_notify_set (buffer, argv_eol[2]))
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
@@ -1048,8 +1037,7 @@ COMMAND_CALLBACK(buffer)
|
||||
/* set a property on buffer */
|
||||
if (string_strcasecmp (argv[1], "set") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(4, "set");
|
||||
value = string_remove_quotes (argv_eol[3], "'\"");
|
||||
gui_buffer_set (buffer, argv[2], (value) ? value : argv_eol[3]);
|
||||
if (value)
|
||||
@@ -1060,8 +1048,7 @@ COMMAND_CALLBACK(buffer)
|
||||
/* get a buffer property */
|
||||
if (string_strcasecmp (argv[1], "get") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "get");
|
||||
if (gui_buffer_property_in_list (gui_buffer_properties_get_integer,
|
||||
argv[2]))
|
||||
{
|
||||
@@ -1288,7 +1275,7 @@ COMMAND_CALLBACK(buffer)
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1319,15 +1306,14 @@ COMMAND_CALLBACK(color)
|
||||
if (string_strcasecmp (argv[1], "-o") == 0)
|
||||
{
|
||||
gui_color_info_term_colors (str_color, sizeof (str_color));
|
||||
input_data (buffer, str_color);
|
||||
(void) input_data (buffer, str_color);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* add a color alias */
|
||||
if (string_strcasecmp (argv[1], "alias") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(4, "alias");
|
||||
|
||||
/* check color number */
|
||||
error = NULL;
|
||||
@@ -1379,7 +1365,7 @@ COMMAND_CALLBACK(color)
|
||||
"/set weechat.palette.%d \"%s\"",
|
||||
(int)number,
|
||||
(str_color[0]) ? str_color + 1 : "");
|
||||
input_exec_command (buffer, 1, NULL, str_command);
|
||||
(void) input_exec_command (buffer, 1, NULL, str_command);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -1387,8 +1373,7 @@ COMMAND_CALLBACK(color)
|
||||
/* delete a color alias */
|
||||
if (string_strcasecmp (argv[1], "unalias") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "unalias");
|
||||
|
||||
/* check color number */
|
||||
error = NULL;
|
||||
@@ -1427,7 +1412,7 @@ COMMAND_CALLBACK(color)
|
||||
snprintf (str_command, sizeof (str_command),
|
||||
"/unset weechat.palette.%d",
|
||||
(int)number);
|
||||
input_exec_command (buffer, 1, NULL, str_command);
|
||||
(void) input_exec_command (buffer, 1, NULL, str_command);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -1449,12 +1434,11 @@ COMMAND_CALLBACK(color)
|
||||
/* convert terminal color to RGB color */
|
||||
if (string_strcasecmp (argv[1], "term2rgb") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "term2rgb");
|
||||
error = NULL;
|
||||
number = strtol (argv[2], &error, 10);
|
||||
if (!error || error[0] || (number < 0) || (number > 255))
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
gui_chat_printf (NULL,
|
||||
"%ld -> #%06x",
|
||||
number,
|
||||
@@ -1465,19 +1449,18 @@ COMMAND_CALLBACK(color)
|
||||
/* convert RGB color to terminal color */
|
||||
if (string_strcasecmp (argv[1], "rgb2term") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "rgb2term");
|
||||
if (sscanf ((argv[2][0] == '#') ? argv[2] + 1 : argv[2], "%x", &rgb) != 1)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
if (rgb > 0xFFFFFF)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
limit = 256;
|
||||
if (argc > 3)
|
||||
{
|
||||
error = NULL;
|
||||
limit = strtol (argv[3], &error, 10);
|
||||
if (!error || error[0] || (limit < 1) || (limit > 256))
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
gui_chat_printf (NULL,
|
||||
"#%06x -> %d",
|
||||
@@ -1486,7 +1469,7 @@ COMMAND_CALLBACK(color)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1503,8 +1486,7 @@ COMMAND_CALLBACK(command)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
ptr_buffer = buffer;
|
||||
index_args = 1;
|
||||
@@ -1537,8 +1519,8 @@ COMMAND_CALLBACK(command)
|
||||
}
|
||||
if (string_is_command_char (argv_eol[index_args + 1]))
|
||||
{
|
||||
input_exec_command (ptr_buffer, any_plugin, ptr_plugin,
|
||||
argv_eol[index_args + 1]);
|
||||
(void) input_exec_command (ptr_buffer, any_plugin, ptr_plugin,
|
||||
argv_eol[index_args + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1547,7 +1529,8 @@ COMMAND_CALLBACK(command)
|
||||
if (command)
|
||||
{
|
||||
snprintf (command, length, "/%s", argv_eol[index_args + 1]);
|
||||
input_exec_command (ptr_buffer, any_plugin, ptr_plugin, command);
|
||||
(void) input_exec_command (ptr_buffer, any_plugin, ptr_plugin,
|
||||
command);
|
||||
free (command);
|
||||
}
|
||||
}
|
||||
@@ -1639,7 +1622,7 @@ COMMAND_CALLBACK(cursor)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1792,8 +1775,7 @@ COMMAND_CALLBACK(debug)
|
||||
|
||||
if (string_strcasecmp (argv[1], "set") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(4, "set");
|
||||
if (strcmp (argv[3], "0") == 0)
|
||||
{
|
||||
/* disable debug for a plugin */
|
||||
@@ -1823,7 +1805,7 @@ COMMAND_CALLBACK(debug)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1844,8 +1826,7 @@ COMMAND_CALLBACK(eval)
|
||||
print_only = 0;
|
||||
condition = 0;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
ptr_args = argv_eol[1];
|
||||
for (i = 1; i < argc; i++)
|
||||
@@ -1930,7 +1911,7 @@ COMMAND_CALLBACK(eval)
|
||||
{
|
||||
for (i = 0; commands[i]; i++)
|
||||
{
|
||||
input_data (buffer, commands[i]);
|
||||
(void) input_data (buffer, commands[i]);
|
||||
}
|
||||
string_free_split_command (commands);
|
||||
}
|
||||
@@ -2173,8 +2154,7 @@ COMMAND_CALLBACK(filter)
|
||||
/* add filter */
|
||||
if (string_strcasecmp (argv[1], "add") == 0)
|
||||
{
|
||||
if (argc < 6)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(6, "add");
|
||||
if (gui_filter_search_by_name (argv[2]))
|
||||
{
|
||||
gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER,
|
||||
@@ -2215,8 +2195,7 @@ COMMAND_CALLBACK(filter)
|
||||
/* rename a filter */
|
||||
if (string_strcasecmp (argv[1], "rename") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(4, "rename");
|
||||
ptr_filter = gui_filter_search_by_name (argv[2]);
|
||||
if (ptr_filter)
|
||||
{
|
||||
@@ -2250,8 +2229,7 @@ COMMAND_CALLBACK(filter)
|
||||
/* delete filter */
|
||||
if (string_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "del");
|
||||
if (string_strcasecmp (argv[2], "-all") == 0)
|
||||
{
|
||||
if (gui_filters)
|
||||
@@ -2290,7 +2268,7 @@ COMMAND_CALLBACK(filter)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2916,8 +2894,7 @@ COMMAND_CALLBACK(input)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (string_strcasecmp (argv[1], "clipboard_paste") == 0)
|
||||
gui_input_clipboard_paste (buffer);
|
||||
@@ -2981,7 +2958,7 @@ COMMAND_CALLBACK(input)
|
||||
gui_input_jump_smart (buffer);
|
||||
/* not used any more in WeeChat >= 1.0 (replaced by "/buffer ++") */
|
||||
else if (string_strcasecmp (argv[1], "jump_last_buffer") == 0)
|
||||
input_data (buffer, "/buffer +");
|
||||
(void) input_data (buffer, "/buffer +");
|
||||
else if (string_strcasecmp (argv[1], "jump_last_buffer_displayed") == 0)
|
||||
gui_input_jump_last_buffer_displayed (buffer);
|
||||
else if (string_strcasecmp (argv[1], "jump_previously_visited_buffer") == 0)
|
||||
@@ -3014,7 +2991,7 @@ COMMAND_CALLBACK(input)
|
||||
gui_input_insert (buffer, argv_eol[2]);
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "send") == 0)
|
||||
input_data (buffer, argv_eol[2]);
|
||||
(void) input_data (buffer, argv_eol[2]);
|
||||
else if (string_strcasecmp (argv[1], "undo") == 0)
|
||||
gui_input_undo (buffer);
|
||||
else if (string_strcasecmp (argv[1], "redo") == 0)
|
||||
@@ -3028,7 +3005,9 @@ COMMAND_CALLBACK(input)
|
||||
/* do nothing here */
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
{
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -3341,8 +3320,7 @@ COMMAND_CALLBACK(key)
|
||||
/* bind a key (or display binding) */
|
||||
if (string_strcasecmp (argv[1], "bind") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "bind");
|
||||
|
||||
/* display a key binding */
|
||||
if (argc == 3)
|
||||
@@ -3402,8 +3380,7 @@ COMMAND_CALLBACK(key)
|
||||
/* bind a key for given context (or display binding) */
|
||||
if (string_strcasecmp (argv[1], "bindctxt") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(4, "bindctxt");
|
||||
|
||||
/* search context */
|
||||
context = gui_key_search_context (argv[2]);
|
||||
@@ -3474,8 +3451,7 @@ COMMAND_CALLBACK(key)
|
||||
/* unbind a key */
|
||||
if (string_strcasecmp (argv[1], "unbind") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "unbind");
|
||||
|
||||
gui_key_verbose = 1;
|
||||
rc = gui_key_unbind (NULL, GUI_KEY_CONTEXT_DEFAULT, argv[2]);
|
||||
@@ -3495,8 +3471,7 @@ COMMAND_CALLBACK(key)
|
||||
/* unbind a key for a given context */
|
||||
if (string_strcasecmp (argv[1], "unbindctxt") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(4, "unbindctxt");
|
||||
|
||||
/* search context */
|
||||
context = gui_key_search_context (argv[2]);
|
||||
@@ -3527,17 +3502,14 @@ COMMAND_CALLBACK(key)
|
||||
/* reset a key to default binding */
|
||||
if (string_strcasecmp (argv[1], "reset") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
COMMAND_MIN_ARGS(3, "reset");
|
||||
return command_key_reset (GUI_KEY_CONTEXT_DEFAULT, argv[2]);
|
||||
}
|
||||
|
||||
/* reset a key to default binding for a given context */
|
||||
if (string_strcasecmp (argv[1], "resetctxt") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(4, "resetctxt");
|
||||
|
||||
/* search context */
|
||||
context = gui_key_search_context (argv[2]);
|
||||
@@ -3608,7 +3580,7 @@ COMMAND_CALLBACK(key)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3753,7 +3725,7 @@ COMMAND_CALLBACK(layout)
|
||||
{
|
||||
ptr_layout = gui_layout_alloc ((layout_name) ? layout_name : GUI_LAYOUT_DEFAULT_NAME);
|
||||
if (!ptr_layout)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
gui_layout_add (ptr_layout);
|
||||
}
|
||||
if (flag_buffers)
|
||||
@@ -3858,8 +3830,7 @@ COMMAND_CALLBACK(layout)
|
||||
/* rename layout */
|
||||
if (string_strcasecmp (argv[1], "rename") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(4, "rename");
|
||||
ptr_layout = gui_layout_search (argv[2]);
|
||||
if (!ptr_layout)
|
||||
{
|
||||
@@ -3885,7 +3856,7 @@ COMMAND_CALLBACK(layout)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3979,7 +3950,7 @@ COMMAND_CALLBACK(mouse)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4023,8 +3994,7 @@ COMMAND_CALLBACK(mute)
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "-buffer") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "-buffer");
|
||||
ptr_buffer = gui_buffer_search_by_full_name (argv[2]);
|
||||
if (ptr_buffer)
|
||||
{
|
||||
@@ -4049,7 +4019,7 @@ COMMAND_CALLBACK(mute)
|
||||
|
||||
if (string_is_command_char (ptr_command))
|
||||
{
|
||||
input_exec_command (buffer, 1, NULL, ptr_command);
|
||||
(void) input_exec_command (buffer, 1, NULL, ptr_command);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4058,7 +4028,7 @@ COMMAND_CALLBACK(mute)
|
||||
if (command)
|
||||
{
|
||||
snprintf (command, length, "/%s", ptr_command);
|
||||
input_exec_command (buffer, 1, NULL, command);
|
||||
(void) input_exec_command (buffer, 1, NULL, command);
|
||||
free (command);
|
||||
}
|
||||
}
|
||||
@@ -4416,8 +4386,7 @@ COMMAND_CALLBACK(plugin)
|
||||
|
||||
if (string_strcasecmp (argv[1], "load") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "load");
|
||||
plugin_argv = NULL;
|
||||
plugin_argc = 0;
|
||||
if (argc > 3)
|
||||
@@ -4466,7 +4435,7 @@ COMMAND_CALLBACK(plugin)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4500,11 +4469,11 @@ COMMAND_CALLBACK(print)
|
||||
if (string_strcasecmp (argv[i], "-buffer") == 0)
|
||||
{
|
||||
if (i + 1 >= argc)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
i++;
|
||||
ptr_buffer = gui_buffer_search_by_number_or_name (argv[i]);
|
||||
if (!ptr_buffer)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
else if (string_strcasecmp (argv[i], "-current") == 0)
|
||||
{
|
||||
@@ -4521,14 +4490,14 @@ COMMAND_CALLBACK(print)
|
||||
else if (string_strcasecmp (argv[i], "-date") == 0)
|
||||
{
|
||||
if (i + 1 >= argc)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
i++;
|
||||
if ((argv[i][0] == '-') || (argv[i][0] == '+'))
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (argv[i] + 1, &error, 10);
|
||||
if (!error || error[0])
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
date = (argv[i][0] == '-') ?
|
||||
time (NULL) - value : time (NULL) + value;
|
||||
}
|
||||
@@ -4566,7 +4535,7 @@ COMMAND_CALLBACK(print)
|
||||
else if (string_strcasecmp (argv[i], "-tags") == 0)
|
||||
{
|
||||
if (i + 1 >= argc)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
i++;
|
||||
tags = argv[i];
|
||||
}
|
||||
@@ -4606,7 +4575,7 @@ COMMAND_CALLBACK(print)
|
||||
else if (argv[i][0] == '-')
|
||||
{
|
||||
/* unknown argument starting with "-", exit */
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -4726,8 +4695,7 @@ COMMAND_CALLBACK(proxy)
|
||||
/* add a new proxy */
|
||||
if (string_strcasecmp (argv[1], "add") == 0)
|
||||
{
|
||||
if (argc < 6)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(6, "add");
|
||||
type = proxy_search_type (argv[3]);
|
||||
if (type < 0)
|
||||
{
|
||||
@@ -4774,8 +4742,7 @@ COMMAND_CALLBACK(proxy)
|
||||
/* delete a proxy */
|
||||
if (string_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "del");
|
||||
if (string_strcasecmp (argv[2], "-all") == 0)
|
||||
{
|
||||
proxy_free_all ();
|
||||
@@ -4801,8 +4768,7 @@ COMMAND_CALLBACK(proxy)
|
||||
/* set a proxy property */
|
||||
if (string_strcasecmp (argv[1], "set") == 0)
|
||||
{
|
||||
if (argc < 5)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(5, "set");
|
||||
ptr_proxy = proxy_search (argv[2]);
|
||||
if (!ptr_proxy)
|
||||
{
|
||||
@@ -4824,7 +4790,7 @@ COMMAND_CALLBACK(proxy)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4974,7 +4940,7 @@ command_repeat_timer_cb (void *data, int remaining_calls)
|
||||
|
||||
/* execute command */
|
||||
if (ptr_buffer)
|
||||
input_exec_command (ptr_buffer, 1, NULL, repeat_args[1]);
|
||||
(void) input_exec_command (ptr_buffer, 1, NULL, repeat_args[1]);
|
||||
}
|
||||
|
||||
if (remaining_calls == 0)
|
||||
@@ -5002,8 +4968,7 @@ COMMAND_CALLBACK(repeat)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
arg_count = 1;
|
||||
interval = 0;
|
||||
@@ -5040,14 +5005,14 @@ COMMAND_CALLBACK(repeat)
|
||||
|
||||
if (command)
|
||||
{
|
||||
input_exec_command (buffer, 1, NULL, command);
|
||||
(void) input_exec_command (buffer, 1, NULL, command);
|
||||
if (count > 1)
|
||||
{
|
||||
if (interval == 0)
|
||||
{
|
||||
for (i = 0; i < count - 1; i++)
|
||||
{
|
||||
input_exec_command (buffer, 1, NULL, command);
|
||||
(void) input_exec_command (buffer, 1, NULL, command);
|
||||
}
|
||||
free (command);
|
||||
}
|
||||
@@ -5185,8 +5150,7 @@ COMMAND_CALLBACK(secure)
|
||||
/* decrypt data still encrypted */
|
||||
if (string_strcasecmp (argv[1], "decrypt") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "decrypt");
|
||||
if (count_encrypted == 0)
|
||||
{
|
||||
gui_chat_printf (NULL, _("There is no encrypted data"));
|
||||
@@ -5227,8 +5191,7 @@ COMMAND_CALLBACK(secure)
|
||||
/* set the passphrase */
|
||||
if (string_strcasecmp (argv[1], "passphrase") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "passphrase");
|
||||
passphrase_was_set = 0;
|
||||
if (secure_passphrase)
|
||||
{
|
||||
@@ -5264,8 +5227,7 @@ COMMAND_CALLBACK(secure)
|
||||
/* set a secured data */
|
||||
if (string_strcasecmp (argv[1], "set") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(4, "set");
|
||||
hashtable_set (secure_hashtable_data, argv[2], argv_eol[3]);
|
||||
gui_chat_printf (NULL, _("Secured data \"%s\" set"), argv[2]);
|
||||
command_save_file (secure_config_file);
|
||||
@@ -5276,8 +5238,7 @@ COMMAND_CALLBACK(secure)
|
||||
/* delete a secured data */
|
||||
if (string_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "del");
|
||||
if (hashtable_has_key (secure_hashtable_data, argv[2]))
|
||||
{
|
||||
hashtable_remove (secure_hashtable_data, argv[2]);
|
||||
@@ -5306,7 +5267,7 @@ COMMAND_CALLBACK(secure)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5704,7 +5665,7 @@ COMMAND_CALLBACK(set)
|
||||
/* display a sorted list of all environment variables */
|
||||
list = weelist_new ();
|
||||
if (!list)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
for (i = 0; environ[i]; i++)
|
||||
{
|
||||
weelist_add (list, environ[i], WEECHAT_LIST_POS_SORT, NULL);
|
||||
@@ -5926,8 +5887,7 @@ COMMAND_CALLBACK(unset)
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
mask = 0;
|
||||
ptr_name = argv_eol[1];
|
||||
@@ -5936,9 +5896,8 @@ COMMAND_CALLBACK(unset)
|
||||
|
||||
if (string_strcasecmp (argv[1], "-mask") == 0)
|
||||
{
|
||||
COMMAND_MIN_ARGS(3, "-mask");
|
||||
mask = 1;
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
ptr_name = argv_eol[2];
|
||||
}
|
||||
|
||||
@@ -6161,7 +6120,7 @@ COMMAND_CALLBACK(upgrade)
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
/* never executed */
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6195,7 +6154,7 @@ COMMAND_CALLBACK(uptime)
|
||||
sec,
|
||||
ctime (&weechat_first_start_time));
|
||||
string[strlen (string) - 1] = '\0';
|
||||
input_data (buffer, string);
|
||||
(void) input_data (buffer, string);
|
||||
}
|
||||
else if ((argc >= 2) && (string_strcasecmp (argv[1], "-ol") == 0))
|
||||
{
|
||||
@@ -6208,7 +6167,7 @@ COMMAND_CALLBACK(uptime)
|
||||
min,
|
||||
sec,
|
||||
util_get_time_string (&weechat_first_start_time));
|
||||
input_data (buffer, string);
|
||||
(void) input_data (buffer, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6259,7 +6218,7 @@ command_version_display (struct t_gui_buffer *buffer,
|
||||
_("compiled on"),
|
||||
version_get_compilation_date (),
|
||||
version_get_compilation_time ());
|
||||
input_data (buffer, string);
|
||||
(void) input_data (buffer, string);
|
||||
if (weechat_upgrade_count > 0)
|
||||
{
|
||||
snprintf (string, sizeof (string),
|
||||
@@ -6268,7 +6227,7 @@ command_version_display (struct t_gui_buffer *buffer,
|
||||
/* TRANSLATORS: text is: "upgraded xx times" */
|
||||
NG_("time", "times", weechat_upgrade_count),
|
||||
util_get_time_string (&weechat_first_start_time));
|
||||
input_data (buffer, string);
|
||||
(void) input_data (buffer, string);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -6279,7 +6238,7 @@ command_version_display (struct t_gui_buffer *buffer,
|
||||
"compiled on",
|
||||
version_get_compilation_date (),
|
||||
version_get_compilation_time ());
|
||||
input_data (buffer, string);
|
||||
(void) input_data (buffer, string);
|
||||
if (weechat_upgrade_count > 0)
|
||||
{
|
||||
snprintf (string, sizeof (string),
|
||||
@@ -6288,7 +6247,7 @@ command_version_display (struct t_gui_buffer *buffer,
|
||||
(weechat_upgrade_count > 1) ? "times" : "time",
|
||||
ctime (&weechat_first_start_time));
|
||||
string[strlen (string) - 1] = '\0';
|
||||
input_data (buffer, string);
|
||||
(void) input_data (buffer, string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6375,7 +6334,7 @@ command_wait_timer_cb (void *data, int remaining_calls)
|
||||
|
||||
/* execute command */
|
||||
if (ptr_buffer)
|
||||
input_data (ptr_buffer, timer_args[1]);
|
||||
(void) input_data (ptr_buffer, timer_args[1]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
@@ -6401,8 +6360,7 @@ COMMAND_CALLBACK(wait)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
pos = argv[1];
|
||||
while (pos[0] && isdigit ((unsigned char)pos[0]))
|
||||
@@ -6425,20 +6383,20 @@ COMMAND_CALLBACK(wait)
|
||||
else if (strcmp (pos, "h") == 0)
|
||||
factor = 1000 * 60 * 60;
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
else
|
||||
str_number = strdup (argv[1]);
|
||||
|
||||
if (!str_number)
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
|
||||
error = NULL;
|
||||
number = strtol (str_number, &error, 10);
|
||||
if (!error || error[0])
|
||||
{
|
||||
free (str_number);
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
free (str_number);
|
||||
|
||||
@@ -6713,7 +6671,7 @@ COMMAND_CALLBACK(window)
|
||||
if (string_strcasecmp (argv[win_args], "all") == 0)
|
||||
gui_window_merge_all (ptr_win);
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6786,7 +6744,7 @@ COMMAND_CALLBACK(window)
|
||||
else if (string_strcasecmp (argv[win_args], "right") == 0)
|
||||
gui_window_swap (ptr_win, 2);
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6830,7 +6788,7 @@ COMMAND_CALLBACK(window)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -8038,7 +7996,7 @@ command_exec_list (const char *command_list)
|
||||
weechat_buffer = gui_buffer_search_main ();
|
||||
for (ptr_cmd = commands; *ptr_cmd; ptr_cmd++)
|
||||
{
|
||||
input_data (weechat_buffer, *ptr_cmd);
|
||||
(void) input_data (weechat_buffer, *ptr_cmd);
|
||||
}
|
||||
string_free_split_command (commands);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,39 @@
|
||||
return WEECHAT_RC_OK; \
|
||||
}
|
||||
|
||||
/*
|
||||
* macro to return error in case of missing arguments in callback of
|
||||
* hook_command
|
||||
*/
|
||||
#define COMMAND_MIN_ARGS(__min_args, __option) \
|
||||
if (argc < __min_args) \
|
||||
{ \
|
||||
gui_chat_printf_date_tags ( \
|
||||
NULL, 0, GUI_FILTER_TAG_NO_FILTER, \
|
||||
_("%sToo few arguments for command \"%s%s%s\" " \
|
||||
"(help on command: /help %s)"), \
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], \
|
||||
argv[0], \
|
||||
(__option && __option[0]) ? " " : "", \
|
||||
(__option && __option[0]) ? __option : "", \
|
||||
argv[0] + 1); \
|
||||
return WEECHAT_RC_ERROR; \
|
||||
}
|
||||
|
||||
/* macro to return error in callback of hook_command */
|
||||
#define COMMAND_ERROR \
|
||||
{ \
|
||||
gui_chat_printf_date_tags ( \
|
||||
NULL, 0, GUI_FILTER_TAG_NO_FILTER, \
|
||||
_("%sError with command \"%s\" " \
|
||||
"(help on command: /help %s)"), \
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], \
|
||||
argv_eol[0], \
|
||||
argv[0] + 1); \
|
||||
return WEECHAT_RC_ERROR; \
|
||||
}
|
||||
|
||||
|
||||
struct t_gui_buffer;
|
||||
|
||||
extern int command_reload (void *data, struct t_gui_buffer *buffer,
|
||||
|
||||
+31
-14
@@ -61,22 +61,27 @@ input_exec_data (struct t_gui_buffer *buffer, const char *data)
|
||||
|
||||
/*
|
||||
* Executes a command.
|
||||
*
|
||||
* Returns:
|
||||
* WEECHAT_RC_OK: command executed
|
||||
* WEECHAT_RC_ERROR: error, command not executed
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
input_exec_command (struct t_gui_buffer *buffer,
|
||||
int any_plugin,
|
||||
struct t_weechat_plugin *plugin,
|
||||
const char *string)
|
||||
{
|
||||
char *command, *command_name, *pos;
|
||||
int rc;
|
||||
|
||||
if ((!string) || (!string[0]))
|
||||
return;
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
command = strdup (string);
|
||||
if (!command)
|
||||
return;
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
/* ignore spaces at the end of command */
|
||||
pos = &command[strlen (command) - 1];
|
||||
@@ -94,10 +99,11 @@ input_exec_command (struct t_gui_buffer *buffer,
|
||||
if (!command_name)
|
||||
{
|
||||
free (command);
|
||||
return;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/* execute command */
|
||||
rc = WEECHAT_RC_OK;
|
||||
switch (hook_command_exec (buffer, any_plugin, plugin, command))
|
||||
{
|
||||
case HOOK_COMMAND_EXEC_OK:
|
||||
@@ -105,11 +111,7 @@ input_exec_command (struct t_gui_buffer *buffer,
|
||||
break;
|
||||
case HOOK_COMMAND_EXEC_ERROR:
|
||||
/* command hooked, error */
|
||||
gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER,
|
||||
_("%sError with command \"%s\" (help on "
|
||||
"command: /help %s)"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
command, command_name + 1);
|
||||
rc = WEECHAT_RC_ERROR;
|
||||
break;
|
||||
case HOOK_COMMAND_EXEC_NOT_FOUND:
|
||||
/*
|
||||
@@ -128,6 +130,7 @@ input_exec_command (struct t_gui_buffer *buffer,
|
||||
"(type /help for help)"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
command_name);
|
||||
rc = WEECHAT_RC_ERROR;
|
||||
}
|
||||
break;
|
||||
case HOOK_COMMAND_EXEC_AMBIGUOUS_PLUGINS:
|
||||
@@ -139,6 +142,7 @@ input_exec_command (struct t_gui_buffer *buffer,
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
command_name,
|
||||
plugin_get_name (plugin));
|
||||
rc = WEECHAT_RC_ERROR;
|
||||
break;
|
||||
case HOOK_COMMAND_EXEC_AMBIGUOUS_INCOMPLETE:
|
||||
/*
|
||||
@@ -151,6 +155,7 @@ input_exec_command (struct t_gui_buffer *buffer,
|
||||
"this name"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
command_name);
|
||||
rc = WEECHAT_RC_ERROR;
|
||||
break;
|
||||
case HOOK_COMMAND_EXEC_RUNNING:
|
||||
/* command is running */
|
||||
@@ -159,34 +164,44 @@ input_exec_command (struct t_gui_buffer *buffer,
|
||||
"\"%s\" (looping)"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
command_name);
|
||||
rc = WEECHAT_RC_ERROR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
free (command);
|
||||
free (command_name);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reads user input and sends data to buffer's callback.
|
||||
*
|
||||
* Returns:
|
||||
* WEECHAT_RC_OK: data properly sent (or command executed successfully)
|
||||
* WEECHAT_RC_ERROR: error
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
input_data (struct t_gui_buffer *buffer, const char *data)
|
||||
{
|
||||
char *pos, *buf, str_buffer[128], *new_data, *buffer_full_name;
|
||||
const char *ptr_data, *ptr_data_for_buffer;
|
||||
int length, char_size, first_command;
|
||||
int length, char_size, first_command, rc;
|
||||
|
||||
rc = WEECHAT_RC_OK;
|
||||
|
||||
if (!buffer || !gui_buffer_valid (buffer)
|
||||
|| !data || !data[0] || (data[0] == '\r') || (data[0] == '\n'))
|
||||
{
|
||||
return;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
buffer_full_name = strdup (buffer->full_name);
|
||||
if (!buffer_full_name)
|
||||
return;
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
/* execute modifier "input_text_for_buffer" */
|
||||
snprintf (str_buffer, sizeof (str_buffer),
|
||||
@@ -252,7 +267,7 @@ input_data (struct t_gui_buffer *buffer, const char *data)
|
||||
else
|
||||
{
|
||||
/* input string is a command */
|
||||
input_exec_command (buffer, 1, buffer->plugin, ptr_data);
|
||||
rc = input_exec_command (buffer, 1, buffer->plugin, ptr_data);
|
||||
}
|
||||
|
||||
if (pos)
|
||||
@@ -271,4 +286,6 @@ end:
|
||||
free (new_data);
|
||||
if (buffer_full_name)
|
||||
free (buffer_full_name);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
struct t_gui_buffer;
|
||||
struct t_weechat_plugin;
|
||||
|
||||
extern void input_exec_command (struct t_gui_buffer *buffer,
|
||||
int any_plugin,
|
||||
struct t_weechat_plugin *plugin,
|
||||
const char *string);
|
||||
extern void input_data (struct t_gui_buffer *buffer, const char *data);
|
||||
extern int input_exec_command (struct t_gui_buffer *buffer,
|
||||
int any_plugin,
|
||||
struct t_weechat_plugin *plugin,
|
||||
const char *string);
|
||||
extern int input_data (struct t_gui_buffer *buffer, const char *data);
|
||||
|
||||
#endif /* WEECHAT_INPUT_H */
|
||||
|
||||
+1
-1
@@ -437,7 +437,7 @@ gui_input_return (struct t_gui_buffer *buffer)
|
||||
gui_input_text_changed_modifier_and_signal (window->buffer,
|
||||
0, /* save undo */
|
||||
1); /* stop completion */
|
||||
input_data (window->buffer, command);
|
||||
(void) input_data (window->buffer, command);
|
||||
free (command);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1148,7 +1148,7 @@ gui_key_focus_command (const char *key, int context,
|
||||
command,
|
||||
ptr_buffer->full_name);
|
||||
}
|
||||
input_data (ptr_buffer, command);
|
||||
(void) input_data (ptr_buffer, command);
|
||||
}
|
||||
free (command);
|
||||
}
|
||||
@@ -1377,7 +1377,8 @@ gui_key_pressed (const char *key_str)
|
||||
{
|
||||
for (i = 0; commands[i]; i++)
|
||||
{
|
||||
input_data (gui_current_window->buffer, commands[i]);
|
||||
(void) input_data (gui_current_window->buffer,
|
||||
commands[i]);
|
||||
}
|
||||
string_free_split (commands);
|
||||
}
|
||||
|
||||
@@ -815,8 +815,7 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) buffer;
|
||||
(void) argv_eol;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
|
||||
@@ -420,8 +420,7 @@ weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
/* set dictionary for current buffer */
|
||||
if (weechat_strcasecmp (argv[1], "setdict") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "setdict");
|
||||
dicts = weechat_string_replace (argv_eol[2], " ", "");
|
||||
weechat_aspell_command_set_dict (buffer,
|
||||
(dicts) ? dicts : argv[2]);
|
||||
@@ -440,8 +439,7 @@ weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
/* add word to personal dictionary */
|
||||
if (weechat_strcasecmp (argv[1], "addword") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "addword");
|
||||
if (argc > 3)
|
||||
{
|
||||
/* use a given dict */
|
||||
@@ -455,7 +453,7 @@ weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -488,7 +488,7 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
length = strlen (plugin_name) + 1 + strlen (name) + 1;
|
||||
option_name = malloc (length);
|
||||
if (!option_name)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
|
||||
snprintf (option_name, length, "%s.%s", plugin_name, name);
|
||||
}
|
||||
|
||||
@@ -627,8 +627,7 @@ exec_command_exec (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* send text to a running process */
|
||||
if (weechat_strcasecmp (argv[1], "-in") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(4, "-in");
|
||||
ptr_exec_cmd = exec_command_search_running_id (argv[2]);
|
||||
if (ptr_exec_cmd && ptr_exec_cmd->hook)
|
||||
{
|
||||
@@ -647,8 +646,7 @@ exec_command_exec (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* send text to a running process (if given), then close stdin */
|
||||
if (weechat_strcasecmp (argv[1], "-inclose") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "-inclose");
|
||||
ptr_exec_cmd = exec_command_search_running_id (argv[2]);
|
||||
if (ptr_exec_cmd && ptr_exec_cmd->hook)
|
||||
{
|
||||
@@ -671,8 +669,7 @@ exec_command_exec (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* send a signal to a running process */
|
||||
if (weechat_strcasecmp (argv[1], "-signal") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(4, "-signal");
|
||||
ptr_exec_cmd = exec_command_search_running_id (argv[2]);
|
||||
if (ptr_exec_cmd)
|
||||
weechat_hook_set (ptr_exec_cmd->hook, "signal", argv[3]);
|
||||
@@ -682,8 +679,7 @@ exec_command_exec (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* send a KILL signal to a running process */
|
||||
if (weechat_strcasecmp (argv[1], "-kill") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "-kill");
|
||||
ptr_exec_cmd = exec_command_search_running_id (argv[2]);
|
||||
if (ptr_exec_cmd)
|
||||
weechat_hook_set (ptr_exec_cmd->hook, "signal", "kill");
|
||||
@@ -707,8 +703,7 @@ exec_command_exec (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* set a hook property */
|
||||
if (weechat_strcasecmp (argv[1], "-set") == 0)
|
||||
{
|
||||
if (argc < 5)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(5, "-set");
|
||||
ptr_exec_cmd = exec_command_search_running_id (argv[2]);
|
||||
if (ptr_exec_cmd)
|
||||
weechat_hook_set (ptr_exec_cmd->hook, argv[3], argv_eol[4]);
|
||||
@@ -718,8 +713,7 @@ exec_command_exec (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* delete terminated command(s) */
|
||||
if (weechat_strcasecmp (argv[1], "-del") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "-del");
|
||||
if (weechat_strcasecmp (argv[2], "-all") == 0)
|
||||
{
|
||||
count = 0;
|
||||
|
||||
@@ -3875,16 +3875,18 @@ weechat_guile_api_bar_remove (SCM bar)
|
||||
SCM
|
||||
weechat_guile_api_command (SCM buffer, SCM command)
|
||||
{
|
||||
int rc;
|
||||
|
||||
API_FUNC(1, "command", API_RETURN_ERROR);
|
||||
if (!scm_is_string (buffer) || !scm_is_string (command))
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
plugin_script_api_command (weechat_guile_plugin,
|
||||
guile_current_script,
|
||||
API_STR2PTR(API_SCM_TO_STRING(buffer)),
|
||||
API_SCM_TO_STRING(command));
|
||||
rc = plugin_script_api_command (weechat_guile_plugin,
|
||||
guile_current_script,
|
||||
API_STR2PTR(API_SCM_TO_STRING(buffer)),
|
||||
API_SCM_TO_STRING(command));
|
||||
|
||||
API_RETURN_OK;
|
||||
API_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
SCM
|
||||
|
||||
@@ -630,7 +630,7 @@ weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_guile_unload_all ();
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -691,7 +691,7 @@ weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_guile_stdout_flush ();
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
+65
-113
@@ -373,8 +373,7 @@ irc_command_allchan (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
current_server = 0;
|
||||
ptr_exclude_channels = NULL;
|
||||
@@ -425,8 +424,7 @@ irc_command_allpv (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
current_server = 0;
|
||||
ptr_exclude_channels = NULL;
|
||||
@@ -547,8 +545,7 @@ irc_command_allserv (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
ptr_exclude_servers = NULL;
|
||||
ptr_command = argv_eol[1];
|
||||
@@ -1277,12 +1274,11 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
irc_cmd = strdup (argv[2]);
|
||||
if (!irc_cmd)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
|
||||
weechat_string_toupper (irc_cmd);
|
||||
|
||||
@@ -1462,8 +1458,7 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
/* use the local interface, from the server socket */
|
||||
memset (&addr, 0, sizeof (addr));
|
||||
@@ -1484,8 +1479,7 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* DCC SEND file */
|
||||
if (weechat_strcasecmp (argv[1], "send") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(4, "send");
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
{
|
||||
@@ -1513,8 +1507,7 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* DCC CHAT */
|
||||
if (weechat_strcasecmp (argv[1], "chat") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "chat");
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
{
|
||||
@@ -1539,7 +1532,7 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1948,8 +1941,7 @@ irc_command_ignore (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* add ignore */
|
||||
if (weechat_strcasecmp (argv[1], "add") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "add");
|
||||
|
||||
mask = argv[2];
|
||||
server = (argc > 3) ? argv[3] : NULL;
|
||||
@@ -2015,8 +2007,7 @@ irc_command_ignore (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* delete ignore */
|
||||
if (weechat_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "del");
|
||||
|
||||
if (weechat_strcasecmp (argv[2], "-all") == 0)
|
||||
{
|
||||
@@ -2069,7 +2060,7 @@ irc_command_ignore (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2119,8 +2110,7 @@ irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv_eol;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
@@ -2182,8 +2172,7 @@ irc_command_ison (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"ISON :%s", argv_eol[1]);
|
||||
@@ -2345,10 +2334,10 @@ irc_command_join (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
if (weechat_strcasecmp (argv[i], "-server") == 0)
|
||||
{
|
||||
if (argc <= i + 1)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
ptr_server = irc_server_search (argv[i + 1]);
|
||||
if (!ptr_server)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
arg_channels = i + 2;
|
||||
i++;
|
||||
}
|
||||
@@ -2380,7 +2369,7 @@ irc_command_join (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
1, noswitch);
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
@@ -2437,13 +2426,11 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (irc_channel_is_channel (ptr_server, argv[1]))
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
pos_channel = argv[1];
|
||||
pos_nick = argv[2];
|
||||
pos_comment = argv_eol[3];
|
||||
@@ -2488,13 +2475,11 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (irc_channel_is_channel (ptr_server, argv[1]))
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
pos_channel = argv[1];
|
||||
pos_nick = argv[2];
|
||||
pos_comment = argv_eol[3];
|
||||
@@ -2518,7 +2503,7 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* kick nick from channel */
|
||||
nick_only = strdup (pos_nick);
|
||||
if (!nick_only)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
|
||||
pos = strchr (nick_only, '@');
|
||||
if (pos)
|
||||
@@ -2582,8 +2567,7 @@ irc_command_kill (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
@@ -2951,8 +2935,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
arg_target = 1;
|
||||
arg_text = 2;
|
||||
@@ -2970,7 +2953,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
targets = weechat_string_split (argv[arg_target], ",", 0, 0,
|
||||
&num_targets);
|
||||
if (!targets)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
|
||||
for (i = 0; i < num_targets; i++)
|
||||
{
|
||||
@@ -3222,13 +3205,12 @@ irc_command_nick (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv_eol;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "-all") != 0)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -3259,8 +3241,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
arg_target = 1;
|
||||
arg_text = 2;
|
||||
@@ -3356,8 +3337,7 @@ irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* add notify */
|
||||
if (weechat_strcasecmp (argv[1], "add") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "add");
|
||||
|
||||
check_away = 0;
|
||||
|
||||
@@ -3440,8 +3420,7 @@ irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* delete notify */
|
||||
if (weechat_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "del");
|
||||
|
||||
if (argc > 3)
|
||||
{
|
||||
@@ -3514,7 +3493,7 @@ irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3572,8 +3551,7 @@ irc_command_oper (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"OPER %s", argv_eol[1]);
|
||||
@@ -3693,8 +3671,7 @@ irc_command_ping (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"PING %s", argv_eol[1]);
|
||||
@@ -3717,8 +3694,7 @@ irc_command_pong (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"PONG %s", argv_eol[1]);
|
||||
@@ -3742,8 +3718,7 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
arg_nick = 1;
|
||||
arg_text = 2;
|
||||
@@ -3758,7 +3733,7 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
nicks = weechat_string_split (argv[arg_nick], ",", 0, 0, &num_nicks);
|
||||
if (!nicks)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
|
||||
for (i = 0; i < num_nicks; i++)
|
||||
{
|
||||
@@ -3901,21 +3876,20 @@ irc_command_quote (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if ((argc >= 4) && (weechat_strcasecmp (argv[1], "-server") == 0))
|
||||
{
|
||||
ptr_server = irc_server_search (argv[2]);
|
||||
if (!ptr_server || (ptr_server->sock < 0))
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"%s", argv_eol[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ptr_server || (ptr_server->sock < 0))
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"%s", argv_eol[1]);
|
||||
}
|
||||
@@ -4102,16 +4076,14 @@ irc_command_remove (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
ptr_channel_name = (ptr_channel) ? ptr_channel->name : NULL;
|
||||
index_nick = 1;
|
||||
|
||||
if (irc_channel_is_channel (ptr_server, argv[1]))
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
ptr_channel_name = argv[1];
|
||||
index_nick = 2;
|
||||
}
|
||||
@@ -4192,8 +4164,7 @@ irc_command_sajoin (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"SAJOIN %s %s", argv[1], argv_eol[2]);
|
||||
@@ -4276,8 +4247,7 @@ irc_command_sanick (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"SANICK %s %s", argv[1], argv_eol[2]);
|
||||
@@ -4299,8 +4269,7 @@ irc_command_sapart (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"SAPART %s %s", argv[1], argv_eol[2]);
|
||||
@@ -4322,8 +4291,7 @@ irc_command_saquit (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"SAQUIT %s :%s", argv[1], argv_eol[2]);
|
||||
@@ -4784,8 +4752,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "add") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(4, "add");
|
||||
ptr_server2 = irc_server_casesearch (argv[2]);
|
||||
if (ptr_server2)
|
||||
{
|
||||
@@ -4829,8 +4796,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "copy") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(4, "copy");
|
||||
|
||||
/* look for server by name */
|
||||
server_found = irc_server_search (argv[2]);
|
||||
@@ -4873,13 +4839,12 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "rename") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(4, "rename");
|
||||
|
||||
/* look for server by name */
|
||||
server_found = irc_server_search (argv[2]);
|
||||
@@ -4921,13 +4886,12 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "keep") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "keep");
|
||||
|
||||
/* look for server by name */
|
||||
server_found = irc_server_search (argv[2]);
|
||||
@@ -4968,8 +4932,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "del");
|
||||
|
||||
/* look for server by name */
|
||||
server_found = irc_server_search (argv[2]);
|
||||
@@ -5040,8 +5003,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "fakerecv") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "fakerecv");
|
||||
IRC_COMMAND_CHECK_SERVER("server fakerecv", 1);
|
||||
length = strlen (argv_eol[2]);
|
||||
if (length > 0)
|
||||
@@ -5060,7 +5022,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5078,8 +5040,7 @@ irc_command_service (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"SERVICE %s", argv_eol[1]);
|
||||
@@ -5131,8 +5092,7 @@ irc_command_squery (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
@@ -5163,8 +5123,7 @@ irc_command_squit (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
irc_server_sendf (ptr_server, 0, NULL, "SQUIT %s", argv_eol[1]);
|
||||
|
||||
@@ -5216,8 +5175,7 @@ irc_command_summon (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"SUMMON %s", argv_eol[1]);
|
||||
@@ -5379,8 +5337,7 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv_eol;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (irc_channel_is_channel (ptr_server, argv[1]))
|
||||
{
|
||||
@@ -5438,8 +5395,7 @@ irc_command_unquiet (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv_eol;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (irc_channel_is_channel (ptr_server, argv[1]))
|
||||
{
|
||||
@@ -5505,8 +5461,7 @@ irc_command_userhost (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"USERHOST %s", argv_eol[1]);
|
||||
@@ -5641,8 +5596,7 @@ irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (irc_channel_is_channel (ptr_server, argv[1]))
|
||||
{
|
||||
@@ -5750,8 +5704,7 @@ irc_command_wallops (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"WALLOPS :%s", argv_eol[1]);
|
||||
@@ -5829,7 +5782,7 @@ irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
|
||||
if (!ptr_nick)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"WHOIS %s%s%s",
|
||||
@@ -5856,8 +5809,7 @@ irc_command_whowas (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
if (argc < 2)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"WHOWAS %s", argv_eol[1]);
|
||||
|
||||
@@ -906,7 +906,7 @@ logger_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -4249,6 +4249,7 @@ static int
|
||||
weechat_lua_api_command (lua_State *L)
|
||||
{
|
||||
const char *buffer, *command;
|
||||
int rc;
|
||||
|
||||
API_FUNC(1, "command", API_RETURN_ERROR);
|
||||
if (lua_gettop (L) < 2)
|
||||
@@ -4257,12 +4258,12 @@ weechat_lua_api_command (lua_State *L)
|
||||
buffer = lua_tostring (L, -2);
|
||||
command = lua_tostring (L, -1);
|
||||
|
||||
plugin_script_api_command (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
command);
|
||||
rc = plugin_script_api_command (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
command);
|
||||
|
||||
API_RETURN_OK;
|
||||
API_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -645,7 +645,7 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_lua_unload_all ();
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -695,7 +695,7 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
lua_quiet = 0;
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -4019,6 +4019,7 @@ XS (XS_weechat_api_bar_remove)
|
||||
XS (XS_weechat_api_command)
|
||||
{
|
||||
char *buffer, *command;
|
||||
int rc;
|
||||
dXSARGS;
|
||||
|
||||
API_FUNC(1, "command", API_RETURN_ERROR);
|
||||
@@ -4028,12 +4029,12 @@ XS (XS_weechat_api_command)
|
||||
buffer = SvPV_nolen (ST (0));
|
||||
command = SvPV_nolen (ST (1));
|
||||
|
||||
plugin_script_api_command (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
command);
|
||||
rc = plugin_script_api_command (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
command);
|
||||
|
||||
API_RETURN_OK;
|
||||
API_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
XS (XS_weechat_api_info_get)
|
||||
|
||||
@@ -674,7 +674,7 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_perl_unload_all ();
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -724,7 +724,7 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
perl_quiet = 0;
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -260,21 +260,24 @@ plugin_api_color (const char *color_name)
|
||||
* Executes a command on a buffer (simulates user entry).
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
plugin_api_command (struct t_weechat_plugin *plugin,
|
||||
struct t_gui_buffer *buffer, const char *command)
|
||||
{
|
||||
char *command2;
|
||||
int rc;
|
||||
|
||||
if (!plugin || !command)
|
||||
return;
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
command2 = string_iconv_to_internal (plugin->charset, command);
|
||||
if (!buffer)
|
||||
buffer = gui_current_window->buffer;
|
||||
input_data (buffer, (command2) ? command2 : command);
|
||||
rc = input_data (buffer, (command2) ? command2 : command);
|
||||
if (command2)
|
||||
free (command2);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -53,8 +53,9 @@ extern const char *plugin_api_prefix (const char *prefix);
|
||||
extern const char *plugin_api_color (const char *color_name);
|
||||
|
||||
/* command */
|
||||
extern void plugin_api_command (struct t_weechat_plugin *plugin,
|
||||
struct t_gui_buffer *buffer, const char *command);
|
||||
extern int plugin_api_command (struct t_weechat_plugin *plugin,
|
||||
struct t_gui_buffer *buffer,
|
||||
const char *command);
|
||||
|
||||
/* infolist */
|
||||
extern int plugin_api_infolist_next (struct t_infolist *infolist);
|
||||
|
||||
@@ -1331,20 +1331,23 @@ plugin_script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
* Executes a command on a buffer (simulates user entry).
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
plugin_script_api_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer, const char *command)
|
||||
{
|
||||
char *command2;
|
||||
int rc;
|
||||
|
||||
command2 = (script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, command) : NULL;
|
||||
|
||||
weechat_command (buffer, (command2) ? command2 : command);
|
||||
rc = weechat_command (buffer, (command2) ? command2 : command);
|
||||
|
||||
if (command2)
|
||||
free (command2);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -330,10 +330,10 @@ extern struct t_gui_bar_item *plugin_script_api_bar_item_new (struct t_weechat_p
|
||||
extern void plugin_script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_bar_item *item);
|
||||
extern void plugin_script_api_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
const char *command);
|
||||
extern int plugin_script_api_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
const char *command);
|
||||
extern const char *plugin_script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *option);
|
||||
|
||||
@@ -4198,6 +4198,7 @@ static PyObject *
|
||||
weechat_python_api_command (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *buffer, *command;
|
||||
int rc;
|
||||
|
||||
API_FUNC(1, "command", API_RETURN_ERROR);
|
||||
buffer = NULL;
|
||||
@@ -4205,12 +4206,12 @@ weechat_python_api_command (PyObject *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple (args, "ss", &buffer, &command))
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
plugin_script_api_command (weechat_python_plugin,
|
||||
python_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
command);
|
||||
rc = plugin_script_api_command (weechat_python_plugin,
|
||||
python_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
command);
|
||||
|
||||
API_RETURN_OK;
|
||||
API_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
||||
@@ -960,7 +960,7 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_python_unload_all ();
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1010,7 +1010,7 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
python_quiet = 0;
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -216,8 +216,7 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "add") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(4, "add");
|
||||
if (relay_config_create_option_port (NULL,
|
||||
relay_config_file,
|
||||
relay_config_section_port,
|
||||
@@ -234,8 +233,7 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "del");
|
||||
ptr_server = relay_server_search (argv_eol[2]);
|
||||
if (ptr_server)
|
||||
{
|
||||
@@ -264,8 +262,7 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "stop") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "stop");
|
||||
ptr_server = relay_server_search (argv_eol[2]);
|
||||
if (ptr_server)
|
||||
{
|
||||
@@ -284,8 +281,7 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "restart") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_MIN_ARGS(3, "restart");
|
||||
ptr_server = relay_server_search (argv_eol[2]);
|
||||
if (ptr_server)
|
||||
{
|
||||
@@ -315,7 +311,7 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
if (!relay_buffer)
|
||||
|
||||
@@ -4897,6 +4897,7 @@ static VALUE
|
||||
weechat_ruby_api_command (VALUE class, VALUE buffer, VALUE command)
|
||||
{
|
||||
char *c_buffer, *c_command;
|
||||
int rc;
|
||||
|
||||
API_FUNC(1, "command", API_RETURN_ERROR);
|
||||
if (NIL_P (buffer) || NIL_P (command))
|
||||
@@ -4908,12 +4909,12 @@ weechat_ruby_api_command (VALUE class, VALUE buffer, VALUE command)
|
||||
c_buffer = StringValuePtr (buffer);
|
||||
c_command = StringValuePtr (command);
|
||||
|
||||
plugin_script_api_command (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
API_STR2PTR(c_buffer),
|
||||
c_command);
|
||||
rc = plugin_script_api_command (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
API_STR2PTR(c_buffer),
|
||||
c_command);
|
||||
|
||||
API_RETURN_OK;
|
||||
API_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
||||
@@ -814,7 +814,7 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_ruby_unload_all ();
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -864,7 +864,7 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
ruby_quiet = 0;
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -275,7 +275,7 @@ script_command_script (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -4663,7 +4663,7 @@ weechat_tcl_api_command (ClientData clientData, Tcl_Interp *interp,
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *buffer, *command;
|
||||
int i;
|
||||
int i, rc;
|
||||
|
||||
API_FUNC(1, "command", API_RETURN_ERROR);
|
||||
if (objc < 3)
|
||||
@@ -4672,12 +4672,12 @@ weechat_tcl_api_command (ClientData clientData, Tcl_Interp *interp,
|
||||
buffer = Tcl_GetStringFromObj (objv[1], &i);
|
||||
command = Tcl_GetStringFromObj (objv[2], &i);
|
||||
|
||||
plugin_script_api_command (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
command);
|
||||
rc = plugin_script_api_command (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
command);
|
||||
|
||||
API_RETURN_OK;
|
||||
API_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -550,7 +550,7 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_tcl_unload_all ();
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -600,7 +600,7 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
tcl_quiet = 0;
|
||||
}
|
||||
else
|
||||
return WEECHAT_RC_ERROR;
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -1049,6 +1049,9 @@ end:
|
||||
if (sargv)
|
||||
weechat_string_free_split (sargv);
|
||||
|
||||
if (rc == WEECHAT_RC_ERROR)
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ struct timeval;
|
||||
* please change the date with current one; for a second change at same
|
||||
* date, increment the 01, otherwise please keep 01.
|
||||
*/
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20140829-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20141122-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -192,6 +192,38 @@ struct timeval;
|
||||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
* macro to return error in case of missing arguments in callback of
|
||||
* hook_command
|
||||
*/
|
||||
#define WEECHAT_COMMAND_MIN_ARGS(__min_args, __option) \
|
||||
if (argc < __min_args) \
|
||||
{ \
|
||||
weechat_printf_date_tags ( \
|
||||
NULL, 0, "no_filter", \
|
||||
_("%sToo few arguments for command \"%s%s%s\" " \
|
||||
"(help on command: /help %s)"), \
|
||||
weechat_prefix ("error"), \
|
||||
argv[0], \
|
||||
(__option && __option[0]) ? " " : "", \
|
||||
(__option && __option[0]) ? __option : "", \
|
||||
argv[0] + 1); \
|
||||
return WEECHAT_RC_ERROR; \
|
||||
}
|
||||
|
||||
/* macro to return error in callback of hook_command */
|
||||
#define WEECHAT_COMMAND_ERROR \
|
||||
{ \
|
||||
weechat_printf_date_tags ( \
|
||||
NULL, 0, "no_filter", \
|
||||
_("%sError with command \"%s\" " \
|
||||
"(help on command: /help %s)"), \
|
||||
weechat_prefix ("error"), \
|
||||
argv_eol[0], \
|
||||
argv[0] + 1); \
|
||||
return WEECHAT_RC_ERROR; \
|
||||
}
|
||||
|
||||
struct t_weechat_plugin
|
||||
{
|
||||
/* plugin variables */
|
||||
@@ -813,8 +845,8 @@ struct t_weechat_plugin
|
||||
void (*bar_remove) (struct t_gui_bar *bar);
|
||||
|
||||
/* command */
|
||||
void (*command) (struct t_weechat_plugin *plugin,
|
||||
struct t_gui_buffer *buffer, const char *command);
|
||||
int (*command) (struct t_weechat_plugin *plugin,
|
||||
struct t_gui_buffer *buffer, const char *command);
|
||||
|
||||
/* network */
|
||||
int (*network_pass_proxy) (const char *proxy, int sock,
|
||||
|
||||
Reference in New Issue
Block a user