summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/tcl
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-03-06 23:30:58 +0100
committerSebastien Helleu <flashcode@flashtux.org>2009-03-06 23:30:58 +0100
commit700ce289aeb87ed4d07ac498cb2771bcf67a7549 (patch)
tree15a0dcb7f28b7f52a254ef89256ae0646826e48a /src/plugins/scripts/tcl
parent8e551473641151d1e5f043ac279eca399daff5fb (diff)
downloadweechat-700ce289aeb87ed4d07ac498cb2771bcf67a7549.zip
Fix callbacks in script plugins: always return empty string instead of NULL for arguments
Diffstat (limited to 'src/plugins/scripts/tcl')
-rw-r--r--src/plugins/scripts/tcl/weechat-tcl-api.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c
index 09cd94ea0..59927ec36 100644
--- a/src/plugins/scripts/tcl/weechat-tcl-api.c
+++ b/src/plugins/scripts/tcl/weechat-tcl-api.c
@@ -1104,7 +1104,7 @@ weechat_tcl_api_config_section_read_cb (void *data,
const char *option_name, const char *value)
{
struct t_script_callback *script_callback;
- char *tcl_argv[5];
+ char *tcl_argv[5], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -1113,8 +1113,8 @@ weechat_tcl_api_config_section_read_cb (void *data,
{
tcl_argv[0] = script_ptr2str (config_file);
tcl_argv[1] = script_ptr2str (section);
- tcl_argv[2] = (char *)option_name;
- tcl_argv[3] = (char *)value;
+ tcl_argv[2] = (option_name) ? (char *)option_name : empty_arg;
+ tcl_argv[3] = (value) ? (char *)value : empty_arg;
tcl_argv[4] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
@@ -1150,7 +1150,7 @@ weechat_tcl_api_config_section_write_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
- char *tcl_argv[3];
+ char *tcl_argv[3], empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@@ -1158,7 +1158,7 @@ weechat_tcl_api_config_section_write_cb (void *data,
if (script_callback && script_callback->function && script_callback->function[0])
{
tcl_argv[0] = script_ptr2str (config_file);
- tcl_argv[1] = (char *)section_name;
+ tcl_argv[1] = (section_name) ? (char *)section_name : empty_arg;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
@@ -1184,7 +1184,7 @@ weechat_tcl_api_config_section_write_default_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
- char *tcl_argv[3];
+ char *tcl_argv[3], empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@@ -1192,7 +1192,7 @@ weechat_tcl_api_config_section_write_default_cb (void *data,
if (script_callback && script_callback->function && script_callback->function[0])
{
tcl_argv[0] = script_ptr2str (config_file);
- tcl_argv[1] = (char *)section_name;
+ tcl_argv[1] = (section_name) ? (char *)section_name : empty_arg;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
@@ -1220,7 +1220,7 @@ weechat_tcl_api_config_section_create_option_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
- char *tcl_argv[5];
+ char *tcl_argv[5], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -1229,8 +1229,8 @@ weechat_tcl_api_config_section_create_option_cb (void *data,
{
tcl_argv[0] = script_ptr2str (config_file);
tcl_argv[1] = script_ptr2str (section);
- tcl_argv[2] = (char *)option_name;
- tcl_argv[3] = (char *)value;
+ tcl_argv[2] = (option_name) ? (char *)option_name : empty_arg;
+ tcl_argv[3] = (value) ? (char *)value : empty_arg;
tcl_argv[4] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
@@ -1416,7 +1416,7 @@ weechat_tcl_api_config_option_check_value_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
- char *tcl_argv[3];
+ char *tcl_argv[3], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -1424,7 +1424,7 @@ weechat_tcl_api_config_option_check_value_cb (void *data,
if (script_callback && script_callback->function && script_callback->function[0])
{
tcl_argv[0] = script_ptr2str (option);
- tcl_argv[1] = (char *)value;
+ tcl_argv[1] = (value) ? (char *)value : empty_arg;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
@@ -2929,7 +2929,7 @@ weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
- char *tcl_argv[3];
+ char *tcl_argv[3], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -2937,7 +2937,7 @@ weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
if (script_callback && script_callback->function && script_callback->function[0])
{
tcl_argv[0] = script_ptr2str (buffer);
- tcl_argv[1] = (char *)command;
+ tcl_argv[1] = (command) ? (char *)command : empty_arg;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
@@ -3193,7 +3193,7 @@ weechat_tcl_api_hook_process_cb (void *data,
{
snprintf (str_rc, sizeof (str_rc), "%d", return_code);
- tcl_argv[0] = (char *)command;
+ tcl_argv[0] = (command) ? (char *)command : empty_arg;
tcl_argv[1] = str_rc;
tcl_argv[2] = (stdout) ? (char *)stdout : empty_arg;
tcl_argv[3] = (stderr) ? (char *)stderr : empty_arg;
@@ -3273,7 +3273,7 @@ weechat_tcl_api_hook_connect_cb (void *data, int status,
const char *ip_address)
{
struct t_script_callback *script_callback;
- char *tcl_argv[3], str_status[32];
+ char *tcl_argv[3], str_status[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -3283,7 +3283,7 @@ weechat_tcl_api_hook_connect_cb (void *data, int status,
snprintf (str_status, sizeof (str_status), "%d", status);
tcl_argv[0] = str_status;
- tcl_argv[1] = (char *)ip_address;
+ tcl_argv[1] = (ip_address) ? (char *)ip_address : empty_arg;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
@@ -3372,7 +3372,7 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
const char *prefix, const char *message)
{
struct t_script_callback *script_callback;
- char *tcl_argv[8];
+ char *tcl_argv[8], empty_arg[1] = { '\0' };
static char timebuffer[64];
int *rc, ret;
@@ -3392,8 +3392,8 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
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[5] = (prefix) ? (char *)prefix : empty_arg;
+ tcl_argv[6] = (message) ? (char *)message : empty_arg;
tcl_argv[7] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
@@ -3481,8 +3481,8 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type
void *signal_data)
{
struct t_script_callback *script_callback;
- char *tcl_argv[3];
- static char value_str[64], empty_value[1] = { '\0' };
+ char *tcl_argv[3], empty_arg[1] = { '\0' };
+ static char value_str[64];
int *rc, ret, free_needed;
script_callback = (struct t_script_callback *)data;
@@ -3493,7 +3493,7 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type
free_needed = 0;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
- tcl_argv[1] = (signal_data) ? (char *)signal_data : empty_value;
+ tcl_argv[1] = (signal_data) ? (char *)signal_data : empty_arg;
}
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
{
@@ -3507,7 +3507,7 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type
free_needed = 1;
}
else
- tcl_argv[1] = NULL;
+ tcl_argv[1] = empty_arg;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
@@ -3636,15 +3636,15 @@ int
weechat_tcl_api_hook_config_cb (void *data, const char *option, const char *value)
{
struct t_script_callback *script_callback;
- char *tcl_argv[3];
+ char *tcl_argv[3], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
- tcl_argv[0] = (char *)option;
- tcl_argv[1] = (char *)value;
+ tcl_argv[0] = (option) ? (char *)option : empty_arg;
+ tcl_argv[1] = (value) ? (char *)value : empty_arg;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
@@ -3714,14 +3714,14 @@ weechat_tcl_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
- char *tcl_argv[4];
+ char *tcl_argv[4], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
- tcl_argv[0] = (char *)completion_item;
+ tcl_argv[0] = (completion_item) ? (char *)completion_item : empty_arg;
tcl_argv[1] = script_ptr2str (buffer);
tcl_argv[2] = script_ptr2str (completion);
tcl_argv[3] = NULL;
@@ -3841,15 +3841,15 @@ weechat_tcl_api_hook_modifier_cb (void *data, const char *modifier,
const char *modifier_data, const char *string)
{
struct t_script_callback *script_callback;
- char *tcl_argv[4];
+ char *tcl_argv[4], empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
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[0] = (modifier) ? (char *)modifier : empty_arg;
+ tcl_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg;
+ tcl_argv[2] = (string) ? (char *)string : empty_arg;
tcl_argv[3] = NULL;
return (char *)weechat_tcl_exec (script_callback->script,
@@ -3943,14 +3943,14 @@ weechat_tcl_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
struct t_script_callback *script_callback;
- char *tcl_argv[3];
+ char *tcl_argv[3], empty_arg[1] = { '\0' };
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[0] = (info_name) ? (char *)info_name : empty_arg;
+ tcl_argv[1] = (arguments) ? (char *)arguments : empty_arg;
tcl_argv[2] = NULL;
return (const char *)weechat_tcl_exec (script_callback->script,
@@ -4011,16 +4011,16 @@ weechat_tcl_api_hook_infolist_cb (void *data, const char *infolist_name,
void *pointer, const char *arguments)
{
struct t_script_callback *script_callback;
- char *tcl_argv[4];
+ char *tcl_argv[4], empty_arg[1] = { '\0' };
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[0] = (infolist_name) ? (char *)infolist_name : empty_arg;
tcl_argv[1] = script_ptr2str (pointer);
- tcl_argv[2] = (char *)arguments;
+ tcl_argv[2] = (arguments) ? (char *)arguments : empty_arg;
tcl_argv[3] = NULL;
result = (struct t_infolist *)weechat_tcl_exec (script_callback->script,
@@ -4145,7 +4145,7 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
const char *input_data)
{
struct t_script_callback *script_callback;
- char *tcl_argv[3];
+ char *tcl_argv[3], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -4153,7 +4153,7 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
if (script_callback && script_callback->function && script_callback->function[0])
{
tcl_argv[0] = script_ptr2str (buffer);
- tcl_argv[1] = (char *)input_data;
+ tcl_argv[1] = (input_data) ? (char *)input_data : empty_arg;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,