summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/perl
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-02-20 16:14:04 +0100
committerSebastien Helleu <flashcode@flashtux.org>2009-02-20 16:14:04 +0100
commit029503f750171977e1636bde1376317879b05dfd (patch)
treefb879af5f71e9628815f313ceb76e3781fe2431e /src/plugins/scripts/perl
parent1b4028218cc6d9e369e73e769228ae05b8611dd1 (diff)
downloadweechat-029503f750171977e1636bde1376317879b05dfd.zip
Fix some return codes of callbacks in script plugins
Diffstat (limited to 'src/plugins/scripts/perl')
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c657
1 files changed, 370 insertions, 287 deletions
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index 556594270..4856d679f 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -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)
- {
- 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
+
+ if (script_callback && script_callback->function && script_callback->function[0])
{
- ret = *rc;
- free (rc);
+ 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;
}
- 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;
}
/*