mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 04:46:37 +02:00
Fix some return codes of callbacks in script plugins
This commit is contained in:
@@ -1012,7 +1012,7 @@ weechat_lua_api_config_reload_cb (void *data,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (config_file);
|
||||
lua_argv[1] = NULL;
|
||||
@@ -1023,7 +1023,7 @@ weechat_lua_api_config_reload_cb (void *data,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1035,7 +1035,7 @@ weechat_lua_api_config_reload_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1097,7 +1097,7 @@ weechat_lua_api_config_read_cb (void *data,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (config_file);
|
||||
lua_argv[1] = script_ptr2str (section);
|
||||
@@ -1143,7 +1143,7 @@ weechat_lua_api_config_section_write_cb (void *data,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (config_file);
|
||||
lua_argv[1] = (char *)section_name;
|
||||
@@ -1177,7 +1177,7 @@ weechat_lua_api_config_section_write_default_cb (void *data,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (config_file);
|
||||
lua_argv[1] = (char *)section_name;
|
||||
@@ -1212,7 +1212,7 @@ weechat_lua_api_config_section_create_option_cb (void *data,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (config_file);
|
||||
lua_argv[1] = script_ptr2str (section);
|
||||
@@ -1226,7 +1226,7 @@ weechat_lua_api_config_section_create_option_cb (void *data,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1240,7 +1240,7 @@ weechat_lua_api_config_section_create_option_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1259,7 +1259,7 @@ weechat_lua_api_config_section_delete_option_cb (void *data,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (config_file);
|
||||
lua_argv[1] = script_ptr2str (section);
|
||||
@@ -1272,7 +1272,7 @@ weechat_lua_api_config_section_delete_option_cb (void *data,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1288,7 +1288,7 @@ weechat_lua_api_config_section_delete_option_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1406,18 +1406,18 @@ weechat_lua_api_config_search_section (lua_State *L)
|
||||
* value for option
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
weechat_lua_api_config_option_check_value_cb (void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *lua_argv[3];
|
||||
int *rc;
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (option);
|
||||
lua_argv[1] = (char *)value;
|
||||
@@ -1428,12 +1428,20 @@ weechat_lua_api_config_option_check_value_cb (void *data,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = 0;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
|
||||
if (rc)
|
||||
free (rc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1450,7 +1458,7 @@ weechat_lua_api_config_option_change_cb (void *data,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (option);
|
||||
lua_argv[1] = NULL;
|
||||
@@ -1482,7 +1490,7 @@ weechat_lua_api_config_option_delete_cb (void *data,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (option);
|
||||
lua_argv[1] = NULL;
|
||||
@@ -2710,27 +2718,32 @@ weechat_lua_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
(void) argv;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
lua_argv[0] = script_ptr2str (buffer);
|
||||
lua_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
lua_argv[0] = script_ptr2str (buffer);
|
||||
lua_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2802,27 +2815,32 @@ weechat_lua_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
lua_argv[0] = script_ptr2str (buffer);
|
||||
lua_argv[1] = (char *)command;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
lua_argv[0] = script_ptr2str (buffer);
|
||||
lua_argv[1] = (char *)command;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2880,23 +2898,28 @@ weechat_lua_api_hook_timer_cb (void *data)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
lua_argv[0] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
lua_argv[0] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2960,26 +2983,31 @@ weechat_lua_api_hook_fd_cb (void *data, int fd)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (str_fd, sizeof (str_fd), "%d", fd);
|
||||
|
||||
lua_argv[0] = str_fd;
|
||||
lua_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
snprintf (str_fd, sizeof (str_fd), "%d", fd);
|
||||
|
||||
lua_argv[0] = str_fd;
|
||||
lua_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3046,27 +3074,32 @@ weechat_lua_api_hook_connect_cb (void *data, int status, const char *ip_address)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (str_status, sizeof (str_status), "%d", status);
|
||||
|
||||
lua_argv[0] = str_status;
|
||||
lua_argv[1] = (char *)ip_address;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
snprintf (str_status, sizeof (str_status), "%d", status);
|
||||
|
||||
lua_argv[0] = str_status;
|
||||
lua_argv[1] = (char *)ip_address;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3149,41 +3182,46 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date);
|
||||
|
||||
lua_argv[0] = script_ptr2str (buffer);
|
||||
lua_argv[1] = timebuffer;
|
||||
lua_argv[2] = weechat_string_build_with_exploded (tags, ",");
|
||||
if (!lua_argv[2])
|
||||
lua_argv[2] = strdup ("");
|
||||
lua_argv[3] = (displayed) ? strdup ("1") : strdup ("0");
|
||||
lua_argv[4] = (highlight) ? strdup ("1") : strdup ("0");
|
||||
lua_argv[5] = (char *)prefix;
|
||||
lua_argv[6] = (char *)message;
|
||||
lua_argv[7] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date);
|
||||
|
||||
lua_argv[0] = script_ptr2str (buffer);
|
||||
lua_argv[1] = timebuffer;
|
||||
lua_argv[2] = weechat_string_build_with_exploded (tags, ",");
|
||||
if (!lua_argv[2])
|
||||
lua_argv[2] = strdup ("");
|
||||
lua_argv[3] = (displayed) ? strdup ("1") : strdup ("0");
|
||||
lua_argv[4] = (highlight) ? strdup ("1") : strdup ("0");
|
||||
lua_argv[5] = (char *)prefix;
|
||||
lua_argv[6] = (char *)message;
|
||||
lua_argv[7] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
if (lua_argv[2])
|
||||
free (lua_argv[2]);
|
||||
if (lua_argv[3])
|
||||
free (lua_argv[3]);
|
||||
if (lua_argv[4])
|
||||
free (lua_argv[4]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
if (lua_argv[2])
|
||||
free (lua_argv[2]);
|
||||
if (lua_argv[3])
|
||||
free (lua_argv[3]);
|
||||
if (lua_argv[4])
|
||||
free (lua_argv[4]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3253,41 +3291,46 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
lua_argv[0] = (char *)signal;
|
||||
free_needed = 0;
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[1] = (signal_data) ? (char *)signal_data : empty_value;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
|
||||
{
|
||||
snprintf (value_str, sizeof (value_str) - 1,
|
||||
"%d", *((int *)signal_data));
|
||||
lua_argv[1] = value_str;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
|
||||
{
|
||||
lua_argv[1] = script_ptr2str (signal_data);
|
||||
free_needed = 1;
|
||||
}
|
||||
else
|
||||
lua_argv[1] = NULL;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
lua_argv[0] = (char *)signal;
|
||||
free_needed = 0;
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
lua_argv[1] = (signal_data) ? (char *)signal_data : empty_value;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
|
||||
{
|
||||
snprintf (value_str, sizeof (value_str) - 1,
|
||||
"%d", *((int *)signal_data));
|
||||
lua_argv[1] = value_str;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
|
||||
{
|
||||
lua_argv[1] = script_ptr2str (signal_data);
|
||||
free_needed = 1;
|
||||
}
|
||||
else
|
||||
lua_argv[1] = NULL;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3403,25 +3446,30 @@ weechat_lua_api_hook_config_cb (void *data, const char *option,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
lua_argv[0] = (char *)option;
|
||||
lua_argv[1] = (char *)value;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
lua_argv[0] = (char *)option;
|
||||
lua_argv[1] = (char *)value;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3482,30 +3530,35 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion_item,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
lua_argv[0] = (char *)completion_item;
|
||||
lua_argv[1] = script_ptr2str (buffer);
|
||||
lua_argv[2] = script_ptr2str (completion);
|
||||
lua_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
lua_argv[0] = (char *)completion_item;
|
||||
lua_argv[1] = script_ptr2str (buffer);
|
||||
lua_argv[2] = script_ptr2str (completion);
|
||||
lua_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (lua_argv[1])
|
||||
free (lua_argv[1]);
|
||||
if (lua_argv[2])
|
||||
free (lua_argv[2]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (lua_argv[1])
|
||||
free (lua_argv[1]);
|
||||
if (lua_argv[2])
|
||||
free (lua_argv[2]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3609,16 +3662,21 @@ weechat_lua_api_hook_modifier_cb (void *data, const char *modifier,
|
||||
char *lua_argv[4];
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = (char *)modifier;
|
||||
lua_argv[1] = (char *)modifier_data;
|
||||
lua_argv[2] = (char *)string;
|
||||
lua_argv[3] = NULL;
|
||||
|
||||
return (char *)weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
}
|
||||
|
||||
lua_argv[0] = (char *)modifier;
|
||||
lua_argv[1] = (char *)modifier_data;
|
||||
lua_argv[2] = (char *)string;
|
||||
lua_argv[3] = NULL;
|
||||
|
||||
return (char *)weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3717,15 +3775,20 @@ weechat_lua_api_hook_info_cb (void *data, const char *info_name,
|
||||
char *lua_argv[3];
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = (char *)info_name;
|
||||
lua_argv[1] = (char *)arguments;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
return (const char *)weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
}
|
||||
|
||||
lua_argv[0] = (char *)info_name;
|
||||
lua_argv[1] = (char *)arguments;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
return (const char *)weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3786,21 +3849,26 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name,
|
||||
struct t_infolist *result;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = (char *)info_name;
|
||||
lua_argv[1] = script_ptr2str (pointer);
|
||||
lua_argv[2] = (char *)arguments;
|
||||
lua_argv[3] = NULL;
|
||||
|
||||
result = (struct t_infolist *)weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (lua_argv[1])
|
||||
free (lua_argv[1]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
lua_argv[0] = (char *)info_name;
|
||||
lua_argv[1] = script_ptr2str (pointer);
|
||||
lua_argv[2] = (char *)arguments;
|
||||
lua_argv[3] = NULL;
|
||||
|
||||
result = (struct t_infolist *)weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (lua_argv[1])
|
||||
free (lua_argv[1]);
|
||||
|
||||
return result;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3920,27 +3988,32 @@ weechat_lua_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
lua_argv[0] = script_ptr2str (buffer);
|
||||
lua_argv[1] = (char *)input_data;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
lua_argv[0] = script_ptr2str (buffer);
|
||||
lua_argv[1] = (char *)input_data;
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3955,26 +4028,31 @@ weechat_lua_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
lua_argv[0] = script_ptr2str (buffer);
|
||||
lua_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
lua_argv[0] = script_ptr2str (buffer);
|
||||
lua_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4811,22 +4889,27 @@ weechat_lua_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
|
||||
char *lua_argv[3], *ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (item);
|
||||
lua_argv[1] = script_ptr2str (window);
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
ret = (char *)weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
if (lua_argv[1])
|
||||
free (lua_argv[1]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
lua_argv[0] = script_ptr2str (item);
|
||||
lua_argv[1] = script_ptr2str (window);
|
||||
lua_argv[2] = NULL;
|
||||
|
||||
ret = (char *)weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
if (lua_argv[1])
|
||||
free (lua_argv[1]);
|
||||
|
||||
return ret;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user