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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -828,7 +828,7 @@ weechat_perl_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])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (config_file);
|
||||
perl_argv[1] = NULL;
|
||||
@@ -839,7 +839,7 @@ weechat_perl_api_config_reload_cb (void *data,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -851,7 +851,7 @@ weechat_perl_api_config_reload_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -906,7 +906,7 @@ weechat_perl_api_config_section_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])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (config_file);
|
||||
perl_argv[1] = script_ptr2str (section);
|
||||
@@ -952,7 +952,7 @@ weechat_perl_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])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (config_file);
|
||||
perl_argv[1] = (char *)section_name;
|
||||
@@ -986,7 +986,7 @@ weechat_perl_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])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (config_file);
|
||||
perl_argv[1] = (char *)section_name;
|
||||
@@ -1021,7 +1021,7 @@ weechat_perl_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])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (config_file);
|
||||
perl_argv[1] = script_ptr2str (section);
|
||||
@@ -1035,7 +1035,7 @@ weechat_perl_api_config_section_create_option_cb (void *data,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1049,7 +1049,7 @@ weechat_perl_api_config_section_create_option_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1068,7 +1068,7 @@ weechat_perl_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])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (config_file);
|
||||
perl_argv[1] = script_ptr2str (section);
|
||||
@@ -1081,7 +1081,7 @@ weechat_perl_api_config_section_delete_option_cb (void *data,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1097,7 +1097,7 @@ weechat_perl_api_config_section_delete_option_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1190,18 +1190,18 @@ static XS (XS_weechat_api_config_search_section)
|
||||
* value for option
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
weechat_perl_api_config_option_check_value_cb (void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *perl_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])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (option);
|
||||
perl_argv[1] = (char *)value;
|
||||
@@ -1212,12 +1212,20 @@ weechat_perl_api_config_option_check_value_cb (void *data,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = 0;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
|
||||
if (rc)
|
||||
free (rc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1234,7 +1242,7 @@ weechat_perl_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])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (option);
|
||||
perl_argv[1] = NULL;
|
||||
@@ -1266,7 +1274,7 @@ weechat_perl_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])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (option);
|
||||
perl_argv[1] = NULL;
|
||||
@@ -2259,26 +2267,31 @@ weechat_perl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
perl_argv[0] = script_ptr2str (buffer);
|
||||
perl_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
perl_argv[0] = script_ptr2str (buffer);
|
||||
perl_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2338,27 +2351,32 @@ weechat_perl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
perl_argv[0] = script_ptr2str (buffer);
|
||||
perl_argv[1] = (char *)command;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
perl_argv[0] = script_ptr2str (buffer);
|
||||
perl_argv[1] = (char *)command;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2408,23 +2426,28 @@ weechat_perl_api_hook_timer_cb (void *data)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
perl_argv[0] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
perl_argv[0] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2475,25 +2498,30 @@ weechat_perl_api_hook_fd_cb (void *data, int fd)
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (str_fd, sizeof (str_fd), "%d", fd);
|
||||
|
||||
perl_argv[0] = str_fd;
|
||||
perl_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_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);
|
||||
|
||||
perl_argv[0] = str_fd;
|
||||
perl_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2545,27 +2573,32 @@ weechat_perl_api_hook_connect_cb (void *data, int status,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (str_status, sizeof (str_status), "%d", status);
|
||||
|
||||
perl_argv[0] = str_status;
|
||||
perl_argv[1] = (char *)ip_address;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_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);
|
||||
|
||||
perl_argv[0] = str_status;
|
||||
perl_argv[1] = (char *)ip_address;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2631,42 +2664,47 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
|
||||
(void) tags_count;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date);
|
||||
|
||||
perl_argv[0] = script_ptr2str (buffer);
|
||||
perl_argv[1] = timebuffer;
|
||||
perl_argv[2] = weechat_string_build_with_exploded (tags, ",");
|
||||
if (!perl_argv[2])
|
||||
perl_argv[2] = strdup ("");
|
||||
perl_argv[3] = (displayed) ? strdup ("1") : strdup ("0");
|
||||
perl_argv[4] = (highlight) ? strdup ("1") : strdup ("0");
|
||||
perl_argv[5] = (char *)prefix;
|
||||
perl_argv[6] = (char *)message;
|
||||
perl_argv[7] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_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);
|
||||
|
||||
perl_argv[0] = script_ptr2str (buffer);
|
||||
perl_argv[1] = timebuffer;
|
||||
perl_argv[2] = weechat_string_build_with_exploded (tags, ",");
|
||||
if (!perl_argv[2])
|
||||
perl_argv[2] = strdup ("");
|
||||
perl_argv[3] = (displayed) ? strdup ("1") : strdup ("0");
|
||||
perl_argv[4] = (highlight) ? strdup ("1") : strdup ("0");
|
||||
perl_argv[5] = (char *)prefix;
|
||||
perl_argv[6] = (char *)message;
|
||||
perl_argv[7] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
if (perl_argv[2])
|
||||
free (perl_argv[2]);
|
||||
if (perl_argv[3])
|
||||
free (perl_argv[3]);
|
||||
if (perl_argv[4])
|
||||
free (perl_argv[4]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
if (perl_argv[2])
|
||||
free (perl_argv[2]);
|
||||
if (perl_argv[3])
|
||||
free (perl_argv[3]);
|
||||
if (perl_argv[4])
|
||||
free (perl_argv[4]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2723,44 +2761,49 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ
|
||||
int *rc, ret, free_needed;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
perl_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])
|
||||
{
|
||||
perl_argv[1] = (signal_data) ? (char *)signal_data : empty_value;
|
||||
perl_argv[0] = (char *)signal;
|
||||
free_needed = 0;
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
perl_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));
|
||||
perl_argv[1] = value_str;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
|
||||
{
|
||||
perl_argv[1] = script_ptr2str (signal_data);
|
||||
free_needed = 1;
|
||||
}
|
||||
else
|
||||
perl_argv[1] = NULL;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (free_needed && perl_argv[1])
|
||||
free (perl_argv[1]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
|
||||
{
|
||||
snprintf (value_str, sizeof (value_str) - 1,
|
||||
"%d", *((int *)signal_data));
|
||||
perl_argv[1] = value_str;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
|
||||
{
|
||||
perl_argv[1] = script_ptr2str (signal_data);
|
||||
free_needed = 1;
|
||||
}
|
||||
else
|
||||
perl_argv[1] = NULL;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (free_needed && perl_argv[1])
|
||||
free (perl_argv[1]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2863,25 +2906,30 @@ weechat_perl_api_hook_config_cb (void *data, const char *option, const char *val
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
perl_argv[0] = (char *)option;
|
||||
perl_argv[1] = (char *)value;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
perl_argv[0] = (char *)option;
|
||||
perl_argv[1] = (char *)value;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2933,30 +2981,35 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion_item,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
perl_argv[0] = (char *)completion_item;
|
||||
perl_argv[1] = script_ptr2str (buffer);
|
||||
perl_argv[2] = script_ptr2str (completion);
|
||||
perl_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
perl_argv[0] = (char *)completion_item;
|
||||
perl_argv[1] = script_ptr2str (buffer);
|
||||
perl_argv[2] = script_ptr2str (completion);
|
||||
perl_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (perl_argv[1])
|
||||
free (perl_argv[1]);
|
||||
if (perl_argv[2])
|
||||
free (perl_argv[2]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (perl_argv[1])
|
||||
free (perl_argv[1]);
|
||||
if (perl_argv[2])
|
||||
free (perl_argv[2]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3042,16 +3095,21 @@ weechat_perl_api_hook_modifier_cb (void *data, const char *modifier,
|
||||
char *perl_argv[4];
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
perl_argv[0] = (char *)modifier;
|
||||
perl_argv[1] = (char *)modifier_data;
|
||||
perl_argv[2] = (char *)string;
|
||||
perl_argv[3] = NULL;
|
||||
|
||||
return (char *)weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
perl_argv[0] = (char *)modifier;
|
||||
perl_argv[1] = (char *)modifier_data;
|
||||
perl_argv[2] = (char *)string;
|
||||
perl_argv[3] = NULL;
|
||||
|
||||
return (char *)weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3133,15 +3191,20 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name,
|
||||
char *perl_argv[3];
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
perl_argv[0] = (char *)info_name;
|
||||
perl_argv[1] = (char *)arguments;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
return (const char *)weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
}
|
||||
|
||||
perl_argv[0] = (char *)info_name;
|
||||
perl_argv[1] = (char *)arguments;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
return (const char *)weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3194,21 +3257,26 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name,
|
||||
struct t_infolist *result;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
perl_argv[0] = (char *)infolist_name;
|
||||
perl_argv[1] = script_ptr2str (pointer);
|
||||
perl_argv[2] = (char *)arguments;
|
||||
perl_argv[3] = NULL;
|
||||
|
||||
result = (struct t_infolist *)weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (perl_argv[1])
|
||||
free (perl_argv[1]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
perl_argv[0] = (char *)infolist_name;
|
||||
perl_argv[1] = script_ptr2str (pointer);
|
||||
perl_argv[2] = (char *)arguments;
|
||||
perl_argv[3] = NULL;
|
||||
|
||||
result = (struct t_infolist *)weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (perl_argv[1])
|
||||
free (perl_argv[1]);
|
||||
|
||||
return result;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3314,26 +3382,31 @@ weechat_perl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
perl_argv[0] = script_ptr2str (buffer);
|
||||
perl_argv[1] = (char *)input_data;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
perl_argv[0] = script_ptr2str (buffer);
|
||||
perl_argv[1] = (char *)input_data;
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3348,25 +3421,30 @@ weechat_perl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
perl_argv[0] = script_ptr2str (buffer);
|
||||
perl_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
perl_argv[0] = script_ptr2str (buffer);
|
||||
perl_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4047,22 +4125,27 @@ weechat_perl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
|
||||
char *perl_argv[3], *ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (item);
|
||||
perl_argv[1] = script_ptr2str (window);
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
ret = (char *)weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
if (perl_argv[1])
|
||||
free (perl_argv[1]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
perl_argv[0] = script_ptr2str (item);
|
||||
perl_argv[1] = script_ptr2str (window);
|
||||
perl_argv[2] = NULL;
|
||||
|
||||
ret = (char *)weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
if (perl_argv[1])
|
||||
free (perl_argv[1]);
|
||||
|
||||
return ret;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -882,7 +882,7 @@ weechat_python_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])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (config_file);
|
||||
python_argv[1] = NULL;
|
||||
@@ -893,7 +893,7 @@ weechat_python_api_config_reload_cb (void *data,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -905,7 +905,7 @@ weechat_python_api_config_reload_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -961,7 +961,7 @@ weechat_python_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])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (config_file);
|
||||
python_argv[1] = script_ptr2str (section);
|
||||
@@ -981,9 +981,6 @@ weechat_python_api_config_read_cb (void *data,
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
if (rc)
|
||||
free (rc);
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
if (python_argv[1])
|
||||
@@ -1010,7 +1007,7 @@ weechat_python_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])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (config_file);
|
||||
python_argv[1] = (char *)section_name;
|
||||
@@ -1044,7 +1041,7 @@ weechat_python_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])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (config_file);
|
||||
python_argv[1] = (char *)section_name;
|
||||
@@ -1079,7 +1076,7 @@ weechat_python_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])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (config_file);
|
||||
python_argv[1] = script_ptr2str (section);
|
||||
@@ -1093,7 +1090,7 @@ weechat_python_api_config_section_create_option_cb (void *data,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1107,7 +1104,7 @@ weechat_python_api_config_section_create_option_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1126,7 +1123,7 @@ weechat_python_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])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (config_file);
|
||||
python_argv[1] = script_ptr2str (section);
|
||||
@@ -1139,7 +1136,7 @@ weechat_python_api_config_section_delete_option_cb (void *data,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1155,7 +1152,7 @@ weechat_python_api_config_section_delete_option_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1260,18 +1257,18 @@ weechat_python_api_config_search_section (PyObject *self, PyObject *args)
|
||||
* for option
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
weechat_python_api_config_option_check_value_cb (void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *python_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])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (option);
|
||||
python_argv[1] = (char *)value;
|
||||
@@ -1282,12 +1279,20 @@ weechat_python_api_config_option_check_value_cb (void *data,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = 0;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
|
||||
if (rc)
|
||||
free (rc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1304,7 +1309,7 @@ weechat_python_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])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (option);
|
||||
python_argv[1] = NULL;
|
||||
@@ -1336,7 +1341,7 @@ weechat_python_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])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (option);
|
||||
python_argv[1] = NULL;
|
||||
@@ -2408,26 +2413,31 @@ weechat_python_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
python_argv[0] = script_ptr2str (buffer);
|
||||
python_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
python_argv[0] = script_ptr2str (buffer);
|
||||
python_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2490,27 +2500,32 @@ weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
python_argv[0] = script_ptr2str (buffer);
|
||||
python_argv[1] = (char *)command;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
python_argv[0] = script_ptr2str (buffer);
|
||||
python_argv[1] = (char *)command;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2562,23 +2577,28 @@ weechat_python_api_hook_timer_cb (void *data)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
python_argv[0] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
python_argv[0] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2636,26 +2656,31 @@ weechat_python_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);
|
||||
|
||||
python_argv[0] = str_fd;
|
||||
python_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_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);
|
||||
|
||||
python_argv[0] = str_fd;
|
||||
python_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2716,27 +2741,32 @@ weechat_python_api_hook_connect_cb (void *data, int status,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (str_status, sizeof (str_status), "%d", status);
|
||||
|
||||
python_argv[0] = str_status;
|
||||
python_argv[1] = (char *)ip_address;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_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);
|
||||
|
||||
python_argv[0] = str_status;
|
||||
python_argv[1] = (char *)ip_address;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2809,42 +2839,47 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
|
||||
(void) tags_count;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date);
|
||||
|
||||
python_argv[0] = script_ptr2str (buffer);
|
||||
python_argv[1] = timebuffer;
|
||||
python_argv[2] = weechat_string_build_with_exploded (tags, ",");
|
||||
if (!python_argv[2])
|
||||
python_argv[2] = strdup ("");
|
||||
python_argv[3] = (displayed) ? strdup ("1") : strdup ("0");
|
||||
python_argv[4] = (highlight) ? strdup ("1") : strdup ("0");
|
||||
python_argv[5] = (char *)prefix;
|
||||
python_argv[6] = (char *)message;
|
||||
python_argv[7] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_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);
|
||||
|
||||
python_argv[0] = script_ptr2str (buffer);
|
||||
python_argv[1] = timebuffer;
|
||||
python_argv[2] = weechat_string_build_with_exploded (tags, ",");
|
||||
if (!python_argv[2])
|
||||
python_argv[2] = strdup ("");
|
||||
python_argv[3] = (displayed) ? strdup ("1") : strdup ("0");
|
||||
python_argv[4] = (highlight) ? strdup ("1") : strdup ("0");
|
||||
python_argv[5] = (char *)prefix;
|
||||
python_argv[6] = (char *)message;
|
||||
python_argv[7] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
if (python_argv[2])
|
||||
free (python_argv[2]);
|
||||
if (python_argv[3])
|
||||
free (python_argv[3]);
|
||||
if (python_argv[4])
|
||||
free (python_argv[4]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
if (python_argv[2])
|
||||
free (python_argv[2]);
|
||||
if (python_argv[3])
|
||||
free (python_argv[3]);
|
||||
if (python_argv[4])
|
||||
free (python_argv[4]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2906,44 +2941,49 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t
|
||||
int *rc, ret, free_needed;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
python_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])
|
||||
{
|
||||
python_argv[1] = (signal_data) ? (char *)signal_data : empty_value;
|
||||
python_argv[0] = (char *)signal;
|
||||
free_needed = 0;
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
python_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));
|
||||
python_argv[1] = value_str;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
|
||||
{
|
||||
python_argv[1] = script_ptr2str (signal_data);
|
||||
free_needed = 1;
|
||||
}
|
||||
else
|
||||
python_argv[1] = NULL;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (free_needed && python_argv[1])
|
||||
free (python_argv[1]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
|
||||
{
|
||||
snprintf (value_str, sizeof (value_str) - 1,
|
||||
"%d", *((int *)signal_data));
|
||||
python_argv[1] = value_str;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
|
||||
{
|
||||
python_argv[1] = script_ptr2str (signal_data);
|
||||
free_needed = 1;
|
||||
}
|
||||
else
|
||||
python_argv[1] = NULL;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (free_needed && python_argv[1])
|
||||
free (python_argv[1]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3049,25 +3089,30 @@ weechat_python_api_hook_config_cb (void *data, const char *option, const char *v
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
python_argv[0] = (char *)option;
|
||||
python_argv[1] = (char *)value;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
python_argv[0] = (char *)option;
|
||||
python_argv[1] = (char *)value;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3121,30 +3166,35 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion_item,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
python_argv[0] = (char *)completion_item;
|
||||
python_argv[1] = script_ptr2str (buffer);
|
||||
python_argv[2] = script_ptr2str (completion);
|
||||
python_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
python_argv[0] = (char *)completion_item;
|
||||
python_argv[1] = script_ptr2str (buffer);
|
||||
python_argv[2] = script_ptr2str (completion);
|
||||
python_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (python_argv[1])
|
||||
free (python_argv[1]);
|
||||
if (python_argv[2])
|
||||
free (python_argv[2]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (python_argv[1])
|
||||
free (python_argv[1]);
|
||||
if (python_argv[2])
|
||||
free (python_argv[2]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3235,16 +3285,21 @@ weechat_python_api_hook_modifier_cb (void *data, const char *modifier,
|
||||
char *python_argv[4];
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
python_argv[0] = (char *)modifier;
|
||||
python_argv[1] = (char *)modifier_data;
|
||||
python_argv[2] = (char *)string;
|
||||
python_argv[3] = NULL;
|
||||
|
||||
return (char *)weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
}
|
||||
|
||||
python_argv[0] = (char *)modifier;
|
||||
python_argv[1] = (char *)modifier_data;
|
||||
python_argv[2] = (char *)string;
|
||||
python_argv[3] = NULL;
|
||||
|
||||
return (char *)weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3330,15 +3385,20 @@ weechat_python_api_hook_info_cb (void *data, const char *info_name,
|
||||
char *python_argv[3];
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
python_argv[0] = (char *)info_name;
|
||||
python_argv[1] = (char *)arguments;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
return (const char *)weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
}
|
||||
|
||||
python_argv[0] = (char *)info_name;
|
||||
python_argv[1] = (char *)arguments;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
return (const char *)weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3393,21 +3453,26 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name,
|
||||
struct t_infolist *result;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
python_argv[0] = (char *)infolist_name;
|
||||
python_argv[1] = script_ptr2str (pointer);
|
||||
python_argv[2] = (char *)arguments;
|
||||
python_argv[3] = NULL;
|
||||
|
||||
result = (struct t_infolist *)weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (python_argv[1])
|
||||
free (python_argv[1]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
python_argv[0] = (char *)infolist_name;
|
||||
python_argv[1] = script_ptr2str (pointer);
|
||||
python_argv[2] = (char *)arguments;
|
||||
python_argv[3] = NULL;
|
||||
|
||||
result = (struct t_infolist *)weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (python_argv[1])
|
||||
free (python_argv[1]);
|
||||
|
||||
return result;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3514,29 +3579,34 @@ weechat_python_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *python_argv[3];
|
||||
int *r, ret;
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
python_argv[0] = script_ptr2str (buffer);
|
||||
python_argv[1] = (char *)input_data;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
r = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
if (!r)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *r;
|
||||
free (r);
|
||||
python_argv[0] = script_ptr2str (buffer);
|
||||
python_argv[1] = (char *)input_data;
|
||||
python_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3548,28 +3618,33 @@ weechat_python_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *python_argv[2];
|
||||
int *r, ret;
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
python_argv[0] = script_ptr2str (buffer);
|
||||
python_argv[1] = NULL;
|
||||
|
||||
r = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
if (!r)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *r;
|
||||
free (r);
|
||||
python_argv[0] = script_ptr2str (buffer);
|
||||
python_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4297,22 +4372,27 @@ weechat_python_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
|
||||
char *python_argv[3], *ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (item);
|
||||
python_argv[1] = script_ptr2str (window);
|
||||
python_argv[2] = NULL;
|
||||
|
||||
ret = (char *)weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
if (python_argv[1])
|
||||
free (python_argv[1]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
python_argv[0] = script_ptr2str (item);
|
||||
python_argv[1] = script_ptr2str (window);
|
||||
python_argv[2] = NULL;
|
||||
|
||||
ret = (char *)weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
if (python_argv[1])
|
||||
free (python_argv[1]);
|
||||
|
||||
return ret;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1009,7 +1009,7 @@ weechat_ruby_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])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (config_file);
|
||||
ruby_argv[1] = NULL;
|
||||
@@ -1020,7 +1020,7 @@ weechat_ruby_api_config_reload_cb (void *data,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1032,7 +1032,7 @@ weechat_ruby_api_config_reload_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1094,7 +1094,7 @@ weechat_ruby_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])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (config_file);
|
||||
ruby_argv[1] = script_ptr2str (section);
|
||||
@@ -1140,7 +1140,7 @@ weechat_ruby_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])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (config_file);
|
||||
ruby_argv[1] = (char *)section_name;
|
||||
@@ -1174,7 +1174,7 @@ weechat_ruby_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])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (config_file);
|
||||
ruby_argv[1] = (char *)section_name;
|
||||
@@ -1209,7 +1209,7 @@ weechat_ruby_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])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (config_file);
|
||||
ruby_argv[1] = script_ptr2str (section);
|
||||
@@ -1223,7 +1223,7 @@ weechat_ruby_api_config_section_create_option_cb (void *data,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1237,7 +1237,7 @@ weechat_ruby_api_config_section_create_option_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1256,7 +1256,7 @@ weechat_ruby_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])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (config_file);
|
||||
ruby_argv[1] = script_ptr2str (section);
|
||||
@@ -1269,7 +1269,7 @@ weechat_ruby_api_config_section_delete_option_cb (void *data,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1285,7 +1285,7 @@ weechat_ruby_api_config_section_delete_option_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1423,18 +1423,18 @@ weechat_ruby_api_config_search_section (VALUE class, VALUE config_file,
|
||||
* value for option
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
weechat_ruby_api_config_option_check_value_cb (void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *ruby_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])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (option);
|
||||
ruby_argv[1] = (char *)value;
|
||||
@@ -1445,12 +1445,20 @@ weechat_ruby_api_config_option_check_value_cb (void *data,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = 0;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
|
||||
if (rc)
|
||||
free (rc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1467,7 +1475,7 @@ weechat_ruby_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])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (option);
|
||||
ruby_argv[1] = NULL;
|
||||
@@ -1499,7 +1507,7 @@ weechat_ruby_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])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (option);
|
||||
ruby_argv[1] = NULL;
|
||||
@@ -2758,27 +2766,32 @@ weechat_ruby_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
(void) argv;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
ruby_argv[0] = script_ptr2str (buffer);
|
||||
ruby_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
ruby_argv[0] = script_ptr2str (buffer);
|
||||
ruby_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2857,27 +2870,32 @@ weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
ruby_argv[0] = script_ptr2str (buffer);
|
||||
ruby_argv[1] = (char *)command;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
ruby_argv[0] = script_ptr2str (buffer);
|
||||
ruby_argv[1] = (char *)command;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2935,23 +2953,28 @@ weechat_ruby_api_hook_timer_cb (void *data)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
ruby_argv[0] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
ruby_argv[0] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3020,26 +3043,31 @@ weechat_ruby_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);
|
||||
|
||||
ruby_argv[0] = str_fd;
|
||||
ruby_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_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);
|
||||
|
||||
ruby_argv[0] = str_fd;
|
||||
ruby_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3113,27 +3141,32 @@ weechat_ruby_api_hook_connect_cb (void *data, int status,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (str_status, sizeof (str_status), "%d", status);
|
||||
|
||||
ruby_argv[0] = str_status;
|
||||
ruby_argv[1] = (char *)ip_address;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_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);
|
||||
|
||||
ruby_argv[0] = str_status;
|
||||
ruby_argv[1] = (char *)ip_address;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3224,42 +3257,47 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
|
||||
(void) tags_count;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date);
|
||||
|
||||
ruby_argv[0] = script_ptr2str (buffer);
|
||||
ruby_argv[1] = timebuffer;
|
||||
ruby_argv[2] = weechat_string_build_with_exploded (tags, ",");
|
||||
if (!ruby_argv[2])
|
||||
ruby_argv[2] = strdup ("");
|
||||
ruby_argv[3] = (displayed) ? strdup ("1") : strdup ("0");
|
||||
ruby_argv[4] = (highlight) ? strdup ("1") : strdup ("0");
|
||||
ruby_argv[5] = (char *)prefix;
|
||||
ruby_argv[6] = (char *)message;
|
||||
ruby_argv[7] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_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);
|
||||
|
||||
ruby_argv[0] = script_ptr2str (buffer);
|
||||
ruby_argv[1] = timebuffer;
|
||||
ruby_argv[2] = weechat_string_build_with_exploded (tags, ",");
|
||||
if (!ruby_argv[2])
|
||||
ruby_argv[2] = strdup ("");
|
||||
ruby_argv[3] = (displayed) ? strdup ("1") : strdup ("0");
|
||||
ruby_argv[4] = (highlight) ? strdup ("1") : strdup ("0");
|
||||
ruby_argv[5] = (char *)prefix;
|
||||
ruby_argv[6] = (char *)message;
|
||||
ruby_argv[7] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
if (ruby_argv[2])
|
||||
free (ruby_argv[2]);
|
||||
if (ruby_argv[3])
|
||||
free (ruby_argv[3]);
|
||||
if (ruby_argv[4])
|
||||
free (ruby_argv[4]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
if (ruby_argv[2])
|
||||
free (ruby_argv[2]);
|
||||
if (ruby_argv[3])
|
||||
free (ruby_argv[3]);
|
||||
if (ruby_argv[4])
|
||||
free (ruby_argv[4]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3335,43 +3373,48 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
ruby_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])
|
||||
{
|
||||
ruby_argv[1] = (signal_data) ? (char *)signal_data : empty_value;
|
||||
ruby_argv[0] = (char *)signal;
|
||||
free_needed = 0;
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
ruby_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));
|
||||
ruby_argv[1] = value_str;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
|
||||
{
|
||||
ruby_argv[1] = script_ptr2str (signal_data);
|
||||
free_needed = 1;
|
||||
}
|
||||
else
|
||||
ruby_argv[1] = NULL;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (free_needed && ruby_argv[1])
|
||||
free (ruby_argv[1]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
|
||||
{
|
||||
snprintf (value_str, sizeof (value_str) - 1,
|
||||
"%d", *((int *)signal_data));
|
||||
ruby_argv[1] = value_str;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
|
||||
{
|
||||
ruby_argv[1] = script_ptr2str (signal_data);
|
||||
free_needed = 1;
|
||||
}
|
||||
else
|
||||
ruby_argv[1] = NULL;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (free_needed && ruby_argv[1])
|
||||
free (ruby_argv[1]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3492,24 +3535,29 @@ weechat_ruby_api_hook_config_cb (void *data, const char *option, const char *val
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
ruby_argv[0] = (char *)option;
|
||||
ruby_argv[1] = (char *)value;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
ruby_argv[0] = (char *)option;
|
||||
ruby_argv[1] = (char *)value;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3569,30 +3617,35 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
ruby_argv[0] = (char *)completion_item;
|
||||
ruby_argv[1] = script_ptr2str (buffer);
|
||||
ruby_argv[2] = script_ptr2str (completion);
|
||||
ruby_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
ruby_argv[0] = (char *)completion_item;
|
||||
ruby_argv[1] = script_ptr2str (buffer);
|
||||
ruby_argv[2] = script_ptr2str (completion);
|
||||
ruby_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (ruby_argv[1])
|
||||
free (ruby_argv[1]);
|
||||
if (ruby_argv[2])
|
||||
free (ruby_argv[2]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (ruby_argv[1])
|
||||
free (ruby_argv[1]);
|
||||
if (ruby_argv[2])
|
||||
free (ruby_argv[2]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3702,16 +3755,21 @@ weechat_ruby_api_hook_modifier_cb (void *data, const char *modifier,
|
||||
char *ruby_argv[4];
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ruby_argv[0] = (char *)modifier;
|
||||
ruby_argv[1] = (char *)modifier_data;
|
||||
ruby_argv[2] = (char *)string;
|
||||
ruby_argv[3] = NULL;
|
||||
|
||||
return (char *)weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
}
|
||||
|
||||
ruby_argv[0] = (char *)modifier;
|
||||
ruby_argv[1] = (char *)modifier_data;
|
||||
ruby_argv[2] = (char *)string;
|
||||
ruby_argv[3] = NULL;
|
||||
|
||||
return (char *)weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3812,15 +3870,20 @@ weechat_ruby_api_hook_info_cb (void *data, const char *info_name,
|
||||
char *ruby_argv[3];
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ruby_argv[0] = (char *)info_name;
|
||||
ruby_argv[1] = (char *)arguments;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
return (const char *)weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
}
|
||||
|
||||
ruby_argv[0] = (char *)info_name;
|
||||
ruby_argv[1] = (char *)arguments;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
return (const char *)weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3884,21 +3947,26 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name,
|
||||
struct t_infolist *result;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ruby_argv[0] = (char *)infolist_name;
|
||||
ruby_argv[1] = script_ptr2str (pointer);
|
||||
ruby_argv[2] = (char *)arguments;
|
||||
ruby_argv[3] = NULL;
|
||||
|
||||
result = (struct t_infolist *)weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (ruby_argv[1])
|
||||
free (ruby_argv[1]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ruby_argv[0] = (char *)infolist_name;
|
||||
ruby_argv[1] = script_ptr2str (pointer);
|
||||
ruby_argv[2] = (char *)arguments;
|
||||
ruby_argv[3] = NULL;
|
||||
|
||||
result = (struct t_infolist *)weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (ruby_argv[1])
|
||||
free (ruby_argv[1]);
|
||||
|
||||
return result;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4020,27 +4088,32 @@ weechat_ruby_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
ruby_argv[0] = script_ptr2str (buffer);
|
||||
ruby_argv[1] = (char *)input_data;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
ruby_argv[0] = script_ptr2str (buffer);
|
||||
ruby_argv[1] = (char *)input_data;
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4055,26 +4128,31 @@ weechat_ruby_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
ruby_argv[0] = script_ptr2str (buffer);
|
||||
ruby_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
ruby_argv[0] = script_ptr2str (buffer);
|
||||
ruby_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4911,22 +4989,27 @@ weechat_ruby_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
|
||||
char *ruby_argv[3], *ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (item);
|
||||
ruby_argv[1] = script_ptr2str (window);
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
ret = (char *)weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
if (ruby_argv[1])
|
||||
free (ruby_argv[1]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ruby_argv[0] = script_ptr2str (item);
|
||||
ruby_argv[1] = script_ptr2str (window);
|
||||
ruby_argv[2] = NULL;
|
||||
|
||||
ret = (char *)weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
if (ruby_argv[1])
|
||||
free (ruby_argv[1]);
|
||||
|
||||
return ret;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -349,9 +349,9 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin,
|
||||
const char *default_value,
|
||||
const char *value,
|
||||
int null_value_allowed,
|
||||
void (*callback_check_value)(void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value),
|
||||
int (*callback_check_value)(void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value),
|
||||
const char *function_check_value,
|
||||
void (*callback_change)(void *data,
|
||||
struct t_config_option *option),
|
||||
|
||||
@@ -70,9 +70,9 @@ extern struct t_config_option *script_api_config_new_option (struct t_weechat_pl
|
||||
const char *default_value,
|
||||
const char *value,
|
||||
int null_value_allowed,
|
||||
void (*callback_check_value)(void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value),
|
||||
int (*callback_check_value)(void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value),
|
||||
const char *function_check_value,
|
||||
void (*callback_change)(void *data,
|
||||
struct t_config_option *option),
|
||||
|
||||
@@ -1028,7 +1028,7 @@ weechat_tcl_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])
|
||||
{
|
||||
tcl_argv[0] = script_ptr2str (config_file);
|
||||
tcl_argv[1] = NULL;
|
||||
@@ -1039,7 +1039,7 @@ weechat_tcl_api_config_reload_cb (void *data,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1051,7 +1051,7 @@ weechat_tcl_api_config_reload_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1109,7 +1109,7 @@ weechat_tcl_api_config_section_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])
|
||||
{
|
||||
tcl_argv[0] = script_ptr2str (config_file);
|
||||
tcl_argv[1] = script_ptr2str (section);
|
||||
@@ -1155,7 +1155,7 @@ weechat_tcl_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])
|
||||
{
|
||||
tcl_argv[0] = script_ptr2str (config_file);
|
||||
tcl_argv[1] = (char *)section_name;
|
||||
@@ -1189,7 +1189,7 @@ weechat_tcl_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])
|
||||
{
|
||||
tcl_argv[0] = script_ptr2str (config_file);
|
||||
tcl_argv[1] = (char *)section_name;
|
||||
@@ -1225,7 +1225,7 @@ weechat_tcl_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])
|
||||
{
|
||||
tcl_argv[0] = script_ptr2str (config_file);
|
||||
tcl_argv[1] = script_ptr2str (section);
|
||||
@@ -1239,7 +1239,7 @@ weechat_tcl_api_config_section_create_option_cb (void *data,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1253,7 +1253,7 @@ weechat_tcl_api_config_section_create_option_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1273,7 +1273,7 @@ weechat_tcl_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])
|
||||
{
|
||||
tcl_argv[0] = script_ptr2str (config_file);
|
||||
tcl_argv[1] = script_ptr2str (section);
|
||||
@@ -1286,7 +1286,7 @@ weechat_tcl_api_config_section_delete_option_cb (void *data,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
@@ -1302,7 +1302,7 @@ weechat_tcl_api_config_section_delete_option_cb (void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1410,18 +1410,18 @@ weechat_tcl_api_config_search_section (ClientData clientData, Tcl_Interp *interp
|
||||
* value for option
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
weechat_tcl_api_config_option_check_value_cb (void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *tcl_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])
|
||||
{
|
||||
tcl_argv[0] = script_ptr2str (option);
|
||||
tcl_argv[1] = (char *)value;
|
||||
@@ -1432,12 +1432,20 @@ weechat_tcl_api_config_option_check_value_cb (void *data,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = 0;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
|
||||
if (rc)
|
||||
free (rc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1454,7 +1462,7 @@ weechat_tcl_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])
|
||||
{
|
||||
tcl_argv[0] = script_ptr2str (option);
|
||||
tcl_argv[1] = NULL;
|
||||
@@ -1486,7 +1494,7 @@ weechat_tcl_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])
|
||||
{
|
||||
tcl_argv[0] = script_ptr2str (option);
|
||||
tcl_argv[1] = NULL;
|
||||
@@ -1656,7 +1664,7 @@ weechat_tcl_api_config_option_reset (ClientData clientData, Tcl_Interp *interp,
|
||||
Tcl_Obj* objp;
|
||||
int rc;
|
||||
char *option;
|
||||
int i,run_cb;
|
||||
int i, run_callback;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
@@ -1673,7 +1681,7 @@ weechat_tcl_api_config_option_reset (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (Tcl_GetIntFromObj (interp, objv[2], &run_cb) != TCL_OK)
|
||||
if (Tcl_GetIntFromObj (interp, objv[2], &run_callback) != TCL_OK)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset");
|
||||
TCL_RETURN_INT(0);
|
||||
@@ -1681,7 +1689,7 @@ weechat_tcl_api_config_option_reset (ClientData clientData, Tcl_Interp *interp,
|
||||
|
||||
option = Tcl_GetStringFromObj (objv[1], &i);
|
||||
rc = weechat_config_option_reset (script_str2ptr (option),
|
||||
run_cb); /* run_callback */
|
||||
run_callback);
|
||||
|
||||
TCL_RETURN_INT(rc);
|
||||
}
|
||||
@@ -2611,27 +2619,32 @@ weechat_tcl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
(void) argv;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
tcl_argv[0] = script_ptr2str (buffer);
|
||||
tcl_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
tcl_argv[0] = script_ptr2str (buffer);
|
||||
tcl_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2694,27 +2707,32 @@ weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
tcl_argv[0] = script_ptr2str (buffer);
|
||||
tcl_argv[1] = (char *)command;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
tcl_argv[0] = script_ptr2str (buffer);
|
||||
tcl_argv[1] = (char *)command;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2767,23 +2785,28 @@ weechat_tcl_api_hook_timer_cb (void *data)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
tcl_argv[0] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
tcl_argv[0] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2846,26 +2869,31 @@ weechat_tcl_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);
|
||||
|
||||
tcl_argv[0] = str_fd;
|
||||
tcl_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_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);
|
||||
|
||||
tcl_argv[0] = str_fd;
|
||||
tcl_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2930,26 +2958,31 @@ weechat_tcl_api_hook_connect_cb (void *data, int status,
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (str_status, sizeof (str_status), "%d", status);
|
||||
|
||||
tcl_argv[0] = str_status;
|
||||
tcl_argv[1] = (char *)ip_address;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_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);
|
||||
|
||||
tcl_argv[0] = str_status;
|
||||
tcl_argv[1] = (char *)ip_address;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3026,42 +3059,47 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
|
||||
(void) tags_count;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date);
|
||||
|
||||
tcl_argv[0] = script_ptr2str (buffer);
|
||||
tcl_argv[1] = timebuffer;
|
||||
tcl_argv[2] = weechat_string_build_with_exploded (tags, ",");
|
||||
if (!tcl_argv[2])
|
||||
tcl_argv[2] = strdup ("");
|
||||
tcl_argv[3] = (displayed) ? strdup ("1") : strdup ("0");
|
||||
tcl_argv[4] = (highlight) ? strdup ("1") : strdup ("0");
|
||||
tcl_argv[5] = (char *)prefix;
|
||||
tcl_argv[6] = (char *)message;
|
||||
tcl_argv[7] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
if (tcl_argv[2])
|
||||
free (tcl_argv[2]);
|
||||
if (tcl_argv[3])
|
||||
free (tcl_argv[3]);
|
||||
if (tcl_argv[4])
|
||||
free (tcl_argv[4]);
|
||||
snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date);
|
||||
|
||||
tcl_argv[0] = script_ptr2str (buffer);
|
||||
tcl_argv[1] = timebuffer;
|
||||
tcl_argv[2] = weechat_string_build_with_exploded (tags, ",");
|
||||
if (!tcl_argv[2])
|
||||
tcl_argv[2] = strdup ("");
|
||||
tcl_argv[3] = (displayed) ? strdup ("1") : strdup ("0");
|
||||
tcl_argv[4] = (highlight) ? strdup ("1") : strdup ("0");
|
||||
tcl_argv[5] = (char *)prefix;
|
||||
tcl_argv[6] = (char *)message;
|
||||
tcl_argv[7] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
if (tcl_argv[2])
|
||||
free (tcl_argv[2]);
|
||||
if (tcl_argv[3])
|
||||
free (tcl_argv[3]);
|
||||
if (tcl_argv[4])
|
||||
free (tcl_argv[4]);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3127,44 +3165,49 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type
|
||||
int *rc, ret, free_needed;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
tcl_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])
|
||||
{
|
||||
tcl_argv[1] = (signal_data) ? (char *)signal_data : empty_value;
|
||||
tcl_argv[0] = (char *)signal;
|
||||
free_needed = 0;
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
tcl_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));
|
||||
tcl_argv[1] = value_str;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
|
||||
{
|
||||
tcl_argv[1] = script_ptr2str (signal_data);
|
||||
free_needed = 1;
|
||||
}
|
||||
else
|
||||
tcl_argv[1] = NULL;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (free_needed && tcl_argv[1])
|
||||
free (tcl_argv[1]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
|
||||
{
|
||||
snprintf (value_str, sizeof (value_str) - 1,
|
||||
"%d", *((int *)signal_data));
|
||||
tcl_argv[1] = value_str;
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
|
||||
{
|
||||
tcl_argv[1] = script_ptr2str (signal_data);
|
||||
free_needed = 1;
|
||||
}
|
||||
else
|
||||
tcl_argv[1] = NULL;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (free_needed && tcl_argv[1])
|
||||
free (tcl_argv[1]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3276,25 +3319,30 @@ weechat_tcl_api_hook_config_cb (void *data, const char *option, const char *valu
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
tcl_argv[0] = (char *)option;
|
||||
tcl_argv[1] = (char *)value;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
tcl_argv[0] = (char *)option;
|
||||
tcl_argv[1] = (char *)value;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3349,30 +3397,35 @@ weechat_tcl_api_hook_completion_cb (void *data, const char *completion_item,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
tcl_argv[0] = (char *)completion_item;
|
||||
tcl_argv[1] = script_ptr2str (buffer);
|
||||
tcl_argv[2] = script_ptr2str (completion);
|
||||
tcl_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
tcl_argv[0] = (char *)completion_item;
|
||||
tcl_argv[1] = script_ptr2str (buffer);
|
||||
tcl_argv[2] = script_ptr2str (completion);
|
||||
tcl_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (tcl_argv[1])
|
||||
free (tcl_argv[1]);
|
||||
if (tcl_argv[2])
|
||||
free (tcl_argv[2]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (tcl_argv[1])
|
||||
free (tcl_argv[1]);
|
||||
if (tcl_argv[2])
|
||||
free (tcl_argv[2]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3470,18 +3523,23 @@ weechat_tcl_api_hook_modifier_cb (void *data, const char *modifier,
|
||||
char *tcl_argv[4];
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
tcl_argv[0] = (char *)modifier;
|
||||
tcl_argv[1] = (char *)modifier_data;
|
||||
tcl_argv[2] = (char *)string;
|
||||
tcl_argv[3] = NULL;
|
||||
|
||||
return (char *)weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
}
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
tcl_argv[0] = (char *)modifier;
|
||||
tcl_argv[1] = (char *)modifier_data;
|
||||
tcl_argv[2] = (char *)string;
|
||||
tcl_argv[3] = NULL;
|
||||
|
||||
return (char *)weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hook_modifier: hook a modifier
|
||||
*/
|
||||
@@ -3567,15 +3625,20 @@ weechat_tcl_api_hook_info_cb (void *data, const char *info_name,
|
||||
char *tcl_argv[3];
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
tcl_argv[0] = (char *)info_name;
|
||||
tcl_argv[1] = (char *)arguments;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
return (const char *)weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
}
|
||||
|
||||
tcl_argv[0] = (char *)info_name;
|
||||
tcl_argv[1] = (char *)arguments;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
return (const char *)weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3631,21 +3694,26 @@ weechat_tcl_api_hook_infolist_cb (void *data, const char *infolist_name,
|
||||
struct t_infolist *result;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
tcl_argv[0] = (char *)infolist_name;
|
||||
tcl_argv[1] = script_ptr2str (pointer);
|
||||
tcl_argv[2] = (char *)arguments;
|
||||
tcl_argv[3] = NULL;
|
||||
|
||||
result = (struct t_infolist *)weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (tcl_argv[1])
|
||||
free (tcl_argv[1]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
tcl_argv[0] = (char *)infolist_name;
|
||||
tcl_argv[1] = script_ptr2str (pointer);
|
||||
tcl_argv[2] = (char *)arguments;
|
||||
tcl_argv[3] = NULL;
|
||||
|
||||
result = (struct t_infolist *)weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (tcl_argv[1])
|
||||
free (tcl_argv[1]);
|
||||
|
||||
return result;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3760,26 +3828,31 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
tcl_argv[0] = script_ptr2str (buffer);
|
||||
tcl_argv[1] = (char *)input_data;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
tcl_argv[0] = script_ptr2str (buffer);
|
||||
tcl_argv[1] = (char *)input_data;
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3794,25 +3867,30 @@ weechat_tcl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
tcl_argv[0] = script_ptr2str (buffer);
|
||||
tcl_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
tcl_argv[0] = script_ptr2str (buffer);
|
||||
tcl_argv[1] = NULL;
|
||||
|
||||
rc = (int *) weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
|
||||
return ret;
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4575,22 +4653,27 @@ weechat_tcl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
|
||||
char *tcl_argv[3], *ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
tcl_argv[0] = script_ptr2str (item);
|
||||
tcl_argv[1] = script_ptr2str (window);
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
ret = (char *)weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
if (tcl_argv[1])
|
||||
free (tcl_argv[1]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
tcl_argv[0] = script_ptr2str (item);
|
||||
tcl_argv[1] = script_ptr2str (window);
|
||||
tcl_argv[2] = NULL;
|
||||
|
||||
ret = (char *)weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_STRING,
|
||||
script_callback->function,
|
||||
tcl_argv);
|
||||
|
||||
if (tcl_argv[0])
|
||||
free (tcl_argv[0]);
|
||||
if (tcl_argv[1])
|
||||
free (tcl_argv[1]);
|
||||
|
||||
return ret;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user