mirror of
https://github.com/weechat/weechat.git
synced 2026-06-19 09:34:47 +02:00
Fix some return codes of callbacks in script plugins
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user