mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 21:06:38 +02:00
core: remove unneeded whitespace
This commit is contained in:
@@ -77,14 +77,14 @@ void
|
||||
alias_config_cmd_change_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_config_option *ptr_option_completion;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_option_completion = weechat_config_search_option (alias_config_file,
|
||||
alias_config_section_completion,
|
||||
weechat_config_option_get_pointer (option, "name"));
|
||||
|
||||
|
||||
alias_new (weechat_config_option_get_pointer (option, "name"),
|
||||
weechat_config_option_get_pointer (option, "value"),
|
||||
(ptr_option_completion) ?
|
||||
@@ -101,18 +101,18 @@ alias_config_cmd_delete_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_config_option *ptr_option_completion;
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_option_completion = weechat_config_search_option (alias_config_file,
|
||||
alias_config_section_completion,
|
||||
weechat_config_option_get_pointer (option, "name"));
|
||||
|
||||
|
||||
ptr_alias = alias_search (weechat_config_option_get_pointer (option, "name"));
|
||||
if (ptr_alias)
|
||||
alias_free (ptr_alias);
|
||||
|
||||
|
||||
if (ptr_option_completion)
|
||||
weechat_config_option_free (ptr_option_completion);
|
||||
}
|
||||
@@ -126,10 +126,10 @@ void
|
||||
alias_config_completion_change_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_alias = alias_search (weechat_config_option_get_pointer (option, "name"));
|
||||
if (ptr_alias && ptr_alias->hook)
|
||||
{
|
||||
@@ -147,10 +147,10 @@ void
|
||||
alias_config_completion_delete_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_alias = alias_search (weechat_config_option_get_pointer (option, "name"));
|
||||
if (ptr_alias && ptr_alias->hook && ptr_alias->completion)
|
||||
{
|
||||
@@ -167,11 +167,11 @@ alias_config_reload (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
weechat_config_section_free_options (alias_config_section_cmd);
|
||||
weechat_config_section_free_options (alias_config_section_completion);
|
||||
alias_free_all ();
|
||||
|
||||
|
||||
return weechat_config_reload (config_file);
|
||||
}
|
||||
|
||||
@@ -186,10 +186,10 @@ alias_config_cmd_write_default_cb (void *data,
|
||||
const char *section_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
@@ -200,7 +200,7 @@ alias_config_cmd_write_default_cb (void *data,
|
||||
"\"%s\"", alias_default_list[i][1]))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -232,15 +232,15 @@ alias_config_cmd_create_option_cb (void *data,
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
/* create config option */
|
||||
alias_config_cmd_new_option (option_name, value);
|
||||
|
||||
|
||||
/* create alias */
|
||||
ptr_alias = alias_search (option_name);
|
||||
if (ptr_alias)
|
||||
@@ -250,7 +250,7 @@ alias_config_cmd_create_option_cb (void *data,
|
||||
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
else
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -258,7 +258,7 @@ alias_config_cmd_create_option_cb (void *data,
|
||||
weechat_prefix ("error"), ALIAS_PLUGIN_NAME,
|
||||
option_name, value);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -291,12 +291,12 @@ alias_config_completion_create_option_cb (void *data,
|
||||
const char *value)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
ptr_alias = alias_search (option_name);
|
||||
if (!ptr_alias)
|
||||
{
|
||||
@@ -307,13 +307,13 @@ alias_config_completion_create_option_cb (void *data,
|
||||
option_name);
|
||||
return WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* create config option */
|
||||
alias_config_completion_new_option (option_name, value);
|
||||
|
||||
|
||||
/* create/update completion in alias */
|
||||
alias_update_completion (ptr_alias, value);
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
|
||||
@@ -326,12 +326,12 @@ int
|
||||
alias_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
alias_config_file = weechat_config_new (ALIAS_CONFIG_NAME,
|
||||
&alias_config_reload, NULL);
|
||||
if (!alias_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
/* cmd */
|
||||
ptr_section = weechat_config_new_section (alias_config_file, "cmd",
|
||||
1, 1,
|
||||
@@ -346,7 +346,7 @@ alias_config_init ()
|
||||
return 0;
|
||||
}
|
||||
alias_config_section_cmd = ptr_section;
|
||||
|
||||
|
||||
/* completion */
|
||||
ptr_section = weechat_config_new_section (alias_config_file, "completion",
|
||||
1, 1,
|
||||
@@ -361,7 +361,7 @@ alias_config_init ()
|
||||
return 0;
|
||||
}
|
||||
alias_config_section_completion = ptr_section;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,19 +37,19 @@ alias_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) arguments;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, ALIAS_PLUGIN_NAME) == 0)
|
||||
{
|
||||
if (pointer && !alias_valid (pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ alias_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+79
-79
@@ -56,17 +56,17 @@ int
|
||||
alias_valid (struct t_alias *alias)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
if (!alias)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_alias = alias_list; ptr_alias;
|
||||
ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
if (ptr_alias == alias)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* alias not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ struct t_alias *
|
||||
alias_search (const char *alias_name)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
for (ptr_alias = alias_list; ptr_alias;
|
||||
ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
@@ -98,14 +98,14 @@ alias_string_add_word (char **alias, int *length, const char *word)
|
||||
{
|
||||
int length_word;
|
||||
char *alias2;
|
||||
|
||||
|
||||
if (!word)
|
||||
return;
|
||||
|
||||
|
||||
length_word = strlen (word);
|
||||
if (length_word == 0)
|
||||
return;
|
||||
|
||||
|
||||
if (*alias == NULL)
|
||||
{
|
||||
*alias = malloc (length_word + 1);
|
||||
@@ -139,7 +139,7 @@ alias_string_add_word_range (char **alias, int *length, const char *start,
|
||||
const char *end)
|
||||
{
|
||||
char *word;
|
||||
|
||||
|
||||
word = weechat_strndup (start, end - start);
|
||||
if (word)
|
||||
{
|
||||
@@ -158,7 +158,7 @@ alias_string_add_arguments (char **alias, int *length, char **argv, int start,
|
||||
int end)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = start; i <= end; i++)
|
||||
{
|
||||
if (i != start)
|
||||
@@ -185,9 +185,9 @@ alias_replace_args (const char *alias_args, const char *user_args)
|
||||
char **argv, *res;
|
||||
const char *start, *pos;
|
||||
int n, m, argc, length_res, args_count, offset;
|
||||
|
||||
|
||||
argv = weechat_string_split (user_args, " ", 0, 0, &argc);
|
||||
|
||||
|
||||
res = NULL;
|
||||
length_res = 0;
|
||||
args_count = 0;
|
||||
@@ -196,7 +196,7 @@ alias_replace_args (const char *alias_args, const char *user_args)
|
||||
while (pos && pos[0])
|
||||
{
|
||||
offset = 0;
|
||||
|
||||
|
||||
if ((pos[0] == '\\') && (pos[1] == '$'))
|
||||
{
|
||||
offset = 2;
|
||||
@@ -278,7 +278,7 @@ alias_replace_args (const char *alias_args, const char *user_args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (offset != 0)
|
||||
{
|
||||
pos += offset;
|
||||
@@ -287,13 +287,13 @@ alias_replace_args (const char *alias_args, const char *user_args)
|
||||
else
|
||||
pos++;
|
||||
}
|
||||
|
||||
|
||||
if (pos > start)
|
||||
alias_string_add_word (&res, &length_res, start);
|
||||
|
||||
|
||||
if (argv)
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -307,20 +307,20 @@ alias_run_command (struct t_gui_buffer **buffer, const char *command)
|
||||
{
|
||||
char *string;
|
||||
struct t_gui_buffer *old_current_buffer, *new_current_buffer;
|
||||
|
||||
|
||||
/* save current buffer pointer */
|
||||
old_current_buffer = weechat_current_buffer();
|
||||
|
||||
|
||||
/* execute command */
|
||||
string = weechat_buffer_string_replace_local_var (*buffer, command);
|
||||
weechat_command (*buffer,
|
||||
(string) ? string : command);
|
||||
if (string)
|
||||
free (string);
|
||||
|
||||
|
||||
/* get new current buffer */
|
||||
new_current_buffer = weechat_current_buffer();
|
||||
|
||||
|
||||
/*
|
||||
* if current buffer was changed by command, then we'll use this one for
|
||||
* next commands in alias
|
||||
@@ -341,12 +341,12 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
char **commands, **ptr_cmd, **ptr_next_cmd;
|
||||
char *args_replaced, *alias_command;
|
||||
int some_args_replaced, length1, length2;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) argv;
|
||||
|
||||
|
||||
ptr_alias = (struct t_alias *)data;
|
||||
|
||||
|
||||
if (ptr_alias->running)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -368,12 +368,12 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
{
|
||||
ptr_next_cmd = ptr_cmd;
|
||||
ptr_next_cmd++;
|
||||
|
||||
|
||||
args_replaced = alias_replace_args (*ptr_cmd,
|
||||
(argc > 1) ? argv_eol[1] : "");
|
||||
if (args_replaced && (strcmp (args_replaced, *ptr_cmd) != 0))
|
||||
some_args_replaced = 1;
|
||||
|
||||
|
||||
/*
|
||||
* if alias has arguments, they are now
|
||||
* arguments of the last command in the list (if no $1,$2,..$*)
|
||||
@@ -383,7 +383,7 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
{
|
||||
length1 = strlen (*ptr_cmd);
|
||||
length2 = strlen (argv_eol[1]);
|
||||
|
||||
|
||||
alias_command = malloc (1 + length1 + 1 + length2 + 1);
|
||||
if (alias_command)
|
||||
{
|
||||
@@ -391,11 +391,11 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
strcpy (alias_command, "/");
|
||||
else
|
||||
alias_command[0] = '\0';
|
||||
|
||||
|
||||
strcat (alias_command, *ptr_cmd);
|
||||
strcat (alias_command, " ");
|
||||
strcat (alias_command, argv_eol[1]);
|
||||
|
||||
|
||||
alias_run_command (&buffer,
|
||||
alias_command);
|
||||
free (alias_command);
|
||||
@@ -421,7 +421,7 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (args_replaced)
|
||||
free (args_replaced);
|
||||
}
|
||||
@@ -440,7 +440,7 @@ void
|
||||
alias_free (struct t_alias *alias)
|
||||
{
|
||||
struct t_alias *new_alias_list;
|
||||
|
||||
|
||||
/* remove alias from list */
|
||||
if (last_alias == alias)
|
||||
last_alias = alias->prev_alias;
|
||||
@@ -464,7 +464,7 @@ alias_free (struct t_alias *alias)
|
||||
if (alias->completion)
|
||||
free (alias->completion);
|
||||
free (alias);
|
||||
|
||||
|
||||
alias_list = new_alias_list;
|
||||
}
|
||||
|
||||
@@ -489,13 +489,13 @@ struct t_alias *
|
||||
alias_find_pos (const char *name)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
for (ptr_alias = alias_list; ptr_alias; ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
if (weechat_strcasecmp (name, ptr_alias->name) < 0)
|
||||
return ptr_alias;
|
||||
}
|
||||
|
||||
|
||||
/* position not found (we will add to the end of list) */
|
||||
return NULL;
|
||||
}
|
||||
@@ -510,9 +510,9 @@ alias_hook_command (struct t_alias *alias)
|
||||
{
|
||||
char *str_completion;
|
||||
int length;
|
||||
|
||||
|
||||
str_completion = NULL;
|
||||
|
||||
|
||||
if (!alias->completion)
|
||||
{
|
||||
/*
|
||||
@@ -529,12 +529,12 @@ alias_hook_command (struct t_alias *alias)
|
||||
weechat_utf8_next_char (alias->command) : alias->command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
alias->hook = weechat_hook_command (alias->name, alias->command,
|
||||
NULL, NULL,
|
||||
(str_completion) ? str_completion : alias->completion,
|
||||
&alias_cb, alias);
|
||||
|
||||
|
||||
if (str_completion)
|
||||
free (str_completion);
|
||||
}
|
||||
@@ -550,7 +550,7 @@ alias_update_completion (struct t_alias *alias, const char *completion)
|
||||
if (alias->completion)
|
||||
free (alias->completion);
|
||||
alias->completion = (completion) ? strdup (completion) : NULL;
|
||||
|
||||
|
||||
/* unhook and hook again command, with new completion */
|
||||
weechat_unhook (alias->hook);
|
||||
alias->hook = NULL;
|
||||
@@ -565,19 +565,19 @@ struct t_alias *
|
||||
alias_new (const char *name, const char *command, const char *completion)
|
||||
{
|
||||
struct t_alias *new_alias, *ptr_alias, *pos_alias;
|
||||
|
||||
|
||||
if (!name || !name[0] || !command || !command[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
while (weechat_string_is_command_char (name))
|
||||
{
|
||||
name = weechat_utf8_next_char (name);
|
||||
}
|
||||
|
||||
|
||||
ptr_alias = alias_search (name);
|
||||
if (ptr_alias)
|
||||
alias_free (ptr_alias);
|
||||
|
||||
|
||||
new_alias = malloc (sizeof (*new_alias));
|
||||
if (new_alias)
|
||||
{
|
||||
@@ -586,9 +586,9 @@ alias_new (const char *name, const char *command, const char *completion)
|
||||
new_alias->command = strdup (command);
|
||||
new_alias->completion = (completion) ? strdup (completion) : NULL;
|
||||
new_alias->running = 0;
|
||||
|
||||
|
||||
alias_hook_command (new_alias);
|
||||
|
||||
|
||||
if (alias_list)
|
||||
{
|
||||
pos_alias = alias_find_pos (name);
|
||||
@@ -620,7 +620,7 @@ alias_new (const char *name, const char *command, const char *completion)
|
||||
last_alias = new_alias;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_alias;
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ alias_get_final_command (struct t_alias *alias)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
char *result;
|
||||
|
||||
|
||||
if (alias->running)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -643,7 +643,7 @@ alias_get_final_command (struct t_alias *alias)
|
||||
alias->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ptr_alias = alias_search ((weechat_string_is_command_char (alias->command)) ?
|
||||
weechat_utf8_next_char (alias->command) : alias->command);
|
||||
if (ptr_alias)
|
||||
@@ -669,11 +669,11 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
struct t_alias *ptr_alias;
|
||||
struct t_config_option *ptr_option;
|
||||
int alias_found;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (argc > 2)
|
||||
@@ -695,7 +695,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_utf8_next_char (argv[1]) : argv[1];
|
||||
ptr_command = argv_eol[2];
|
||||
}
|
||||
|
||||
|
||||
/* define new alias */
|
||||
if (!alias_new (ptr_alias_name, ptr_command, ptr_completion))
|
||||
{
|
||||
@@ -706,7 +706,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
ptr_alias_name, ptr_command);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
/* create config option for command */
|
||||
ptr_option = weechat_config_search_option (alias_config_file,
|
||||
alias_config_section_cmd,
|
||||
@@ -714,7 +714,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
if (ptr_option)
|
||||
weechat_config_option_free (ptr_option);
|
||||
alias_config_cmd_new_option (ptr_alias_name, ptr_command);
|
||||
|
||||
|
||||
/* create config option for completion */
|
||||
ptr_option = weechat_config_search_option (alias_config_file,
|
||||
alias_config_section_completion,
|
||||
@@ -723,7 +723,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_config_option_free (ptr_option);
|
||||
if (ptr_completion)
|
||||
alias_config_completion_new_option (ptr_alias_name, ptr_completion);
|
||||
|
||||
|
||||
/* display message */
|
||||
weechat_printf (NULL,
|
||||
_("Alias \"%s\" => \"%s\" created"),
|
||||
@@ -734,7 +734,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* get pointer to alias name */
|
||||
ptr_alias_name = (weechat_string_is_command_char (argv[1])) ?
|
||||
weechat_utf8_next_char (argv[1]) : argv[1];
|
||||
|
||||
|
||||
/* display list of aliases */
|
||||
alias_found = 0;
|
||||
for (ptr_alias = alias_list; ptr_alias;
|
||||
@@ -783,7 +783,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
else
|
||||
weechat_printf (NULL, _("No alias defined"));
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -799,12 +799,12 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char *alias_name;
|
||||
struct t_alias *ptr_alias;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
(void) argv_eol;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
for (i = 1; i < argc; i++)
|
||||
@@ -823,7 +823,7 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
{
|
||||
/* remove alias */
|
||||
alias_free (ptr_alias);
|
||||
|
||||
|
||||
/* remove options */
|
||||
ptr_option = weechat_config_search_option (alias_config_file,
|
||||
alias_config_section_cmd,
|
||||
@@ -835,7 +835,7 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
alias_name);
|
||||
if (ptr_option)
|
||||
weechat_config_option_free (ptr_option);
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("Alias \"%s\" removed"),
|
||||
alias_name);
|
||||
@@ -855,19 +855,19 @@ alias_completion_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_alias = alias_list; ptr_alias;
|
||||
ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_alias->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -883,12 +883,12 @@ alias_value_completion_cb (void *data, const char *completion_item,
|
||||
const char *args;
|
||||
char *pos, *alias_name;
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
args = weechat_hook_completion_get_string (completion, "args");
|
||||
if (args)
|
||||
{
|
||||
@@ -897,7 +897,7 @@ alias_value_completion_cb (void *data, const char *completion_item,
|
||||
alias_name = weechat_strndup (args, pos - args);
|
||||
else
|
||||
alias_name = strdup (args);
|
||||
|
||||
|
||||
if (alias_name)
|
||||
{
|
||||
ptr_alias = alias_search (alias_name);
|
||||
@@ -911,7 +911,7 @@ alias_value_completion_cb (void *data, const char *completion_item,
|
||||
free (alias_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -924,14 +924,14 @@ int
|
||||
alias_add_to_infolist (struct t_infolist *infolist, struct t_alias *alias)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !alias)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_pointer (ptr_item, "hook", alias->hook))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "name", alias->name))
|
||||
@@ -942,7 +942,7 @@ alias_add_to_infolist (struct t_infolist *infolist, struct t_alias *alias)
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "running", alias->running))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -956,9 +956,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
if (!alias_config_init ())
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -967,7 +967,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
alias_config_read ();
|
||||
|
||||
|
||||
weechat_hook_command ("alias",
|
||||
N_("create an alias for a command"),
|
||||
N_("[-completion <completion>] <alias> [<command> "
|
||||
@@ -1006,20 +1006,20 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
" /alias -completion %%sajoin forcejoin /quote forcejoin"),
|
||||
"%(alias)|-completion %(commands)|%(alias_value)",
|
||||
&alias_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_command ("unalias", N_("remove aliases"),
|
||||
N_("<alias> [<alias>...]"),
|
||||
N_("alias: name of alias to remove"),
|
||||
"%(alias)|%*",
|
||||
&unalias_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_completion ("alias", N_("list of aliases"),
|
||||
&alias_completion_cb, NULL);
|
||||
weechat_hook_completion ("alias_value", N_("value of alias"),
|
||||
&alias_value_completion_cb, NULL);
|
||||
|
||||
|
||||
alias_info_init ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1032,10 +1032,10 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
alias_config_write ();
|
||||
alias_free_all ();
|
||||
weechat_config_free (alias_config_file);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ weechat_aspell_config_change_commands (void *data,
|
||||
{
|
||||
const char *value;
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (weechat_aspell_commands_to_check)
|
||||
{
|
||||
weechat_string_free_split (weechat_aspell_commands_to_check);
|
||||
@@ -80,7 +80,7 @@ weechat_aspell_config_change_commands (void *data,
|
||||
free (weechat_aspell_length_commands_to_check);
|
||||
weechat_aspell_length_commands_to_check = NULL;
|
||||
}
|
||||
|
||||
|
||||
value = weechat_config_string (option);
|
||||
if (value && value[0])
|
||||
{
|
||||
@@ -111,7 +111,7 @@ weechat_aspell_config_change_default_dict (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ weechat_aspell_config_dict_change (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
}
|
||||
|
||||
@@ -144,11 +144,11 @@ weechat_aspell_config_dict_delete_option (void *data,
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
weechat_config_option_free (option);
|
||||
|
||||
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
@@ -165,15 +165,15 @@ weechat_aspell_config_dict_create_option (void *data,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (value && value[0])
|
||||
weechat_aspell_speller_check_dictionaries (value);
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -207,7 +207,7 @@ weechat_aspell_config_dict_create_option (void *data,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -217,7 +217,7 @@ weechat_aspell_config_dict_create_option (void *data,
|
||||
}
|
||||
else
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ weechat_aspell_config_option_change (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_aspell_speller_free_all ();
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
}
|
||||
@@ -251,12 +251,12 @@ weechat_aspell_config_option_delete_option (void *data,
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
weechat_config_option_free (option);
|
||||
|
||||
|
||||
weechat_aspell_speller_free_all ();
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
@@ -273,12 +273,12 @@ weechat_aspell_config_option_create_option (void *data,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -313,7 +313,7 @@ weechat_aspell_config_option_create_option (void *data,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -326,7 +326,7 @@ weechat_aspell_config_option_create_option (void *data,
|
||||
weechat_aspell_speller_free_all ();
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -365,12 +365,12 @@ int
|
||||
weechat_aspell_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
weechat_aspell_config_file = weechat_config_new (ASPELL_CONFIG_NAME,
|
||||
NULL, NULL);
|
||||
if (!weechat_aspell_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
/* look */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "look",
|
||||
0, 0,
|
||||
@@ -382,13 +382,13 @@ weechat_aspell_config_init ()
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_aspell_config_look_color = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"color", "color",
|
||||
N_("color used for misspelled words"),
|
||||
NULL, 0, 0, "lightred", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* check */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "check",
|
||||
0, 0,
|
||||
@@ -400,7 +400,7 @@ weechat_aspell_config_init ()
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_aspell_config_check_commands = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"commands", "string",
|
||||
@@ -435,7 +435,7 @@ weechat_aspell_config_init ()
|
||||
N_("minimum length for a word to be spell checked (use 0 to check all "
|
||||
"words)"),
|
||||
NULL, 0, INT_MAX, "2", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* dict */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "dict",
|
||||
1, 1,
|
||||
@@ -449,9 +449,9 @@ weechat_aspell_config_init ()
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_aspell_config_section_dict = ptr_section;
|
||||
|
||||
|
||||
/* option */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "option",
|
||||
1, 1,
|
||||
@@ -465,7 +465,7 @@ weechat_aspell_config_init ()
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -477,14 +477,14 @@ int
|
||||
weechat_aspell_config_read ()
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
||||
rc = weechat_config_read (weechat_aspell_config_file);
|
||||
if (rc == WEECHAT_CONFIG_READ_OK)
|
||||
{
|
||||
weechat_aspell_config_change_commands (NULL,
|
||||
weechat_aspell_config_check_commands);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ void
|
||||
weechat_aspell_config_free ()
|
||||
{
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
|
||||
|
||||
if (weechat_aspell_commands_to_check)
|
||||
weechat_string_free_split (weechat_aspell_commands_to_check);
|
||||
if (weechat_aspell_length_commands_to_check)
|
||||
|
||||
@@ -47,13 +47,13 @@ weechat_aspell_speller_exists (const char *lang)
|
||||
AspellDictInfoEnumeration *el;
|
||||
const AspellDictInfo *dict;
|
||||
int rc;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
|
||||
config = new_aspell_config ();
|
||||
list = get_aspell_dict_info_list (config);
|
||||
el = aspell_dict_info_list_elements (list);
|
||||
|
||||
|
||||
while ((dict = aspell_dict_info_enumeration_next (el)))
|
||||
{
|
||||
if (strcmp (dict->name, lang) == 0)
|
||||
@@ -62,10 +62,10 @@ weechat_aspell_speller_exists (const char *lang)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
delete_aspell_dict_info_enumeration (el);
|
||||
delete_aspell_config (config);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ weechat_aspell_speller_check_dictionaries (const char *dict_list)
|
||||
{
|
||||
char **argv;
|
||||
int argc, i;
|
||||
|
||||
|
||||
if (dict_list)
|
||||
{
|
||||
argv = weechat_string_split (dict_list, ",", 0, 0, &argc);
|
||||
@@ -109,14 +109,14 @@ struct t_aspell_speller *
|
||||
weechat_aspell_speller_search (const char *lang)
|
||||
{
|
||||
struct t_aspell_speller *ptr_speller;
|
||||
|
||||
|
||||
for (ptr_speller = weechat_aspell_spellers; ptr_speller;
|
||||
ptr_speller = ptr_speller->next_speller)
|
||||
{
|
||||
if (strcmp (ptr_speller->lang, lang) == 0)
|
||||
return ptr_speller;
|
||||
}
|
||||
|
||||
|
||||
/* no speller found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -132,17 +132,17 @@ weechat_aspell_speller_new (const char *lang)
|
||||
AspellConfig *config;
|
||||
AspellCanHaveError *ret;
|
||||
struct t_infolist *infolist;
|
||||
|
||||
|
||||
if (!lang)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_aspell_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: creating new speller for lang \"%s\"",
|
||||
ASPELL_PLUGIN_NAME, lang);
|
||||
}
|
||||
|
||||
|
||||
/* create a speller instance for the newly created cell */
|
||||
config = new_aspell_config();
|
||||
aspell_config_replace (config, "lang", lang);
|
||||
@@ -159,9 +159,9 @@ weechat_aspell_speller_new (const char *lang)
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
ret = new_aspell_speller (config);
|
||||
|
||||
|
||||
if (aspell_error (ret) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -172,7 +172,7 @@ weechat_aspell_speller_new (const char *lang)
|
||||
delete_aspell_can_have_error (ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* create and add a new speller cell */
|
||||
new_speller = malloc (sizeof (*new_speller));
|
||||
if (!new_speller)
|
||||
@@ -182,7 +182,7 @@ weechat_aspell_speller_new (const char *lang)
|
||||
weechat_prefix ("error"), ASPELL_PLUGIN_NAME);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_speller->speller = to_aspell_speller (ret);
|
||||
new_speller->lang = strdup (lang);
|
||||
|
||||
@@ -194,10 +194,10 @@ weechat_aspell_speller_new (const char *lang)
|
||||
else
|
||||
weechat_aspell_spellers = new_speller;
|
||||
last_weechat_aspell_speller = new_speller;
|
||||
|
||||
|
||||
/* free config */
|
||||
delete_aspell_config (config);
|
||||
|
||||
|
||||
return new_speller;
|
||||
}
|
||||
|
||||
@@ -210,14 +210,14 @@ weechat_aspell_speller_free (struct t_aspell_speller *speller)
|
||||
{
|
||||
if (!speller)
|
||||
return;
|
||||
|
||||
|
||||
if (weechat_aspell_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: removing speller for lang \"%s\"",
|
||||
ASPELL_PLUGIN_NAME, speller->lang);
|
||||
}
|
||||
|
||||
|
||||
/* free data */
|
||||
if (speller->speller)
|
||||
{
|
||||
@@ -236,7 +236,7 @@ weechat_aspell_speller_free (struct t_aspell_speller *speller)
|
||||
weechat_aspell_spellers = speller->next_speller;
|
||||
if (last_weechat_aspell_speller == speller)
|
||||
last_weechat_aspell_speller = speller->prev_speller;
|
||||
|
||||
|
||||
free (speller);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ struct t_aspell_speller
|
||||
{
|
||||
AspellSpeller *speller; /* aspell speller */
|
||||
char *lang; /* language */
|
||||
|
||||
|
||||
struct t_aspell_speller *prev_speller; /* pointer to next speller */
|
||||
struct t_aspell_speller *next_speller; /* pointer to previous speller */
|
||||
};
|
||||
|
||||
@@ -166,20 +166,20 @@ weechat_aspell_build_option_name (struct t_gui_buffer *buffer)
|
||||
const char *plugin_name, *name;
|
||||
char *option_name;
|
||||
int length;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
|
||||
plugin_name = weechat_buffer_get_string (buffer, "plugin");
|
||||
name = weechat_buffer_get_string (buffer, "name");
|
||||
|
||||
|
||||
length = strlen (plugin_name) + 1 + strlen (name) + 1;
|
||||
option_name = malloc (length);
|
||||
if (!option_name)
|
||||
return NULL;
|
||||
|
||||
|
||||
snprintf (option_name, length, "%s.%s", plugin_name, name);
|
||||
|
||||
|
||||
return option_name;
|
||||
}
|
||||
|
||||
@@ -194,11 +194,11 @@ weechat_aspell_get_dict (struct t_gui_buffer *buffer)
|
||||
{
|
||||
char *name, *option_name, *ptr_end;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
name = weechat_aspell_build_option_name (buffer);
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
|
||||
option_name = strdup (name);
|
||||
if (option_name)
|
||||
{
|
||||
@@ -221,21 +221,21 @@ weechat_aspell_get_dict (struct t_gui_buffer *buffer)
|
||||
ptr_end[0] = '\0';
|
||||
}
|
||||
ptr_option = weechat_aspell_config_get_dict (option_name);
|
||||
|
||||
|
||||
free (option_name);
|
||||
free (name);
|
||||
|
||||
|
||||
if (ptr_option)
|
||||
return weechat_config_string (ptr_option);
|
||||
}
|
||||
else
|
||||
free (name);
|
||||
|
||||
|
||||
/* nothing found => return default dictionary (if set) */
|
||||
if (weechat_config_string (weechat_aspell_config_check_default_dict)
|
||||
&& weechat_config_string (weechat_aspell_config_check_default_dict)[0])
|
||||
return weechat_config_string (weechat_aspell_config_check_default_dict);
|
||||
|
||||
|
||||
/* no default dictionary set */
|
||||
return NULL;
|
||||
}
|
||||
@@ -248,11 +248,11 @@ void
|
||||
weechat_aspell_set_dict (struct t_gui_buffer *buffer, const char *value)
|
||||
{
|
||||
char *name;
|
||||
|
||||
|
||||
name = weechat_aspell_build_option_name (buffer);
|
||||
if (!name)
|
||||
return;
|
||||
|
||||
|
||||
if (weechat_aspell_config_set_dict (name, value) > 0)
|
||||
{
|
||||
if (value && value[0])
|
||||
@@ -262,7 +262,7 @@ weechat_aspell_set_dict (struct t_gui_buffer *buffer, const char *value)
|
||||
weechat_printf (NULL, _("%s: \"%s\" removed"),
|
||||
ASPELL_PLUGIN_NAME, name);
|
||||
}
|
||||
|
||||
|
||||
free (name);
|
||||
}
|
||||
|
||||
@@ -278,15 +278,15 @@ weechat_aspell_spellers_already_ok (const char *dict_list)
|
||||
char **argv;
|
||||
int argc, rc, i;
|
||||
struct t_aspell_speller *ptr_speller;
|
||||
|
||||
|
||||
if (!dict_list && !weechat_aspell_spellers)
|
||||
return 1;
|
||||
|
||||
|
||||
if (!dict_list || !weechat_aspell_spellers)
|
||||
return 0;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
|
||||
argv = weechat_string_split (dict_list, ",", 0, 0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
@@ -302,7 +302,7 @@ weechat_aspell_spellers_already_ok (const char *dict_list)
|
||||
}
|
||||
weechat_string_free_split (argv);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ weechat_aspell_create_spellers (struct t_gui_buffer *buffer)
|
||||
const char *dict_list;
|
||||
char **argv;
|
||||
int argc, i;
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
dict_list = weechat_aspell_get_dict (buffer);
|
||||
@@ -349,13 +349,13 @@ char *
|
||||
weechat_aspell_iso_to_lang (const char *code)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; langs_avail[i].code; i++)
|
||||
{
|
||||
if (strcmp (langs_avail[i].code, code) == 0)
|
||||
return strdup (langs_avail[i].name);
|
||||
}
|
||||
|
||||
|
||||
/* lang code not found */
|
||||
return strdup ("Unknown");
|
||||
}
|
||||
@@ -370,13 +370,13 @@ char *
|
||||
weechat_aspell_iso_to_country (const char *code)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; countries_avail[i].code; i++)
|
||||
{
|
||||
if (strcmp (countries_avail[i].code, code) == 0)
|
||||
return strdup (countries_avail[i].name);
|
||||
}
|
||||
|
||||
|
||||
/* country code not found */
|
||||
return strdup ("Unknown");
|
||||
}
|
||||
@@ -395,22 +395,22 @@ weechat_aspell_speller_list_dicts ()
|
||||
AspellDictInfoList *list;
|
||||
AspellDictInfoEnumeration *el;
|
||||
const AspellDictInfo *dict;
|
||||
|
||||
|
||||
config = new_aspell_config();
|
||||
list = get_aspell_dict_info_list (config);
|
||||
el = aspell_dict_info_list_elements (list);
|
||||
|
||||
|
||||
weechat_printf (NULL, "");
|
||||
weechat_printf (NULL,
|
||||
/* TRANSLATORS: "%s" is "aspell" */
|
||||
_( "%s dictionaries list:"),
|
||||
ASPELL_PLUGIN_NAME);
|
||||
|
||||
|
||||
while ((dict = aspell_dict_info_enumeration_next (el)))
|
||||
{
|
||||
country = NULL;
|
||||
pos = strchr (dict->code, '_');
|
||||
|
||||
|
||||
if (pos)
|
||||
{
|
||||
pos[0] = '\0';
|
||||
@@ -420,7 +420,7 @@ weechat_aspell_speller_list_dicts ()
|
||||
}
|
||||
else
|
||||
lang = weechat_aspell_iso_to_lang ((char*)dict->code);
|
||||
|
||||
|
||||
if (strlen (dict->jargon) == 0)
|
||||
{
|
||||
if (pos)
|
||||
@@ -447,15 +447,15 @@ weechat_aspell_speller_list_dicts ()
|
||||
dict->name, lang, dict->jargon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
weechat_printf (NULL, " %s", buffer);
|
||||
|
||||
|
||||
if (lang)
|
||||
free (lang);
|
||||
if (country)
|
||||
free (country);
|
||||
}
|
||||
|
||||
|
||||
delete_aspell_dict_info_enumeration (el);
|
||||
delete_aspell_config (config);
|
||||
}
|
||||
@@ -502,7 +502,7 @@ weechat_aspell_add_word (const char *lang, const char *word)
|
||||
"dictionary"),
|
||||
weechat_prefix ("error"), ASPELL_PLUGIN_NAME);
|
||||
}
|
||||
|
||||
|
||||
if (new_speller)
|
||||
weechat_aspell_speller_free (new_speller);
|
||||
}
|
||||
@@ -516,12 +516,12 @@ int
|
||||
weechat_aspell_command_authorized (const char *command)
|
||||
{
|
||||
int length_command, i;
|
||||
|
||||
|
||||
if (!command)
|
||||
return 1;
|
||||
|
||||
|
||||
length_command = strlen (command);
|
||||
|
||||
|
||||
for (i = 0; i < weechat_aspell_count_commands_to_check; i++)
|
||||
{
|
||||
if ((weechat_aspell_length_commands_to_check[i] == length_command)
|
||||
@@ -532,7 +532,7 @@ weechat_aspell_command_authorized (const char *command)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* command is not authorized */
|
||||
return 0;
|
||||
}
|
||||
@@ -565,7 +565,7 @@ weechat_aspell_string_is_url (const char *word)
|
||||
|| (weechat_strncasecmp(word, "svn+ssh://", 10) == 0)
|
||||
|| (weechat_strncasecmp(word, "git://", 6) == 0))
|
||||
return 1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -578,10 +578,10 @@ int
|
||||
weechat_aspell_string_is_simili_number (const char *word)
|
||||
{
|
||||
int utf8_char_int;
|
||||
|
||||
|
||||
if (!word || !word[0])
|
||||
return 0;
|
||||
|
||||
|
||||
while (word && word[0])
|
||||
{
|
||||
utf8_char_int = weechat_utf8_char_int (word);
|
||||
@@ -589,7 +589,7 @@ weechat_aspell_string_is_simili_number (const char *word)
|
||||
return 0;
|
||||
word = weechat_utf8_next_char (word);
|
||||
}
|
||||
|
||||
|
||||
/* there's only digit or punctuation */
|
||||
return 1;
|
||||
}
|
||||
@@ -604,9 +604,9 @@ weechat_aspell_check_word (struct t_gui_buffer *buffer, const char *word)
|
||||
{
|
||||
struct t_aspell_speller *ptr_speller;
|
||||
int rc;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
|
||||
/* word too small? then do not check word */
|
||||
if ((weechat_config_integer (weechat_aspell_config_check_word_min_length) > 0)
|
||||
&& ((int)strlen (word) < weechat_config_integer (weechat_aspell_config_check_word_min_length)))
|
||||
@@ -642,7 +642,7 @@ weechat_aspell_check_word (struct t_gui_buffer *buffer, const char *word)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -661,18 +661,18 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
int buffer_has_changed, utf8_char_int, char_size;
|
||||
int length, index_result, length_word, word_ok;
|
||||
int length_color_normal, length_color_error, rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) modifier;
|
||||
|
||||
|
||||
if (!string || !string[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
rc = sscanf (modifier_data, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return NULL;
|
||||
|
||||
|
||||
buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
buffer_has_changed = 0;
|
||||
@@ -682,15 +682,15 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
aspell_buffer_spellers = buffer;
|
||||
buffer_has_changed = 1;
|
||||
}
|
||||
|
||||
|
||||
if (!weechat_aspell_spellers)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* check text search only if option is enabled */
|
||||
if (weechat_buffer_get_integer (buffer, "text_search")
|
||||
&& !weechat_config_boolean (weechat_aspell_config_check_during_search))
|
||||
return NULL;
|
||||
|
||||
|
||||
/*
|
||||
* for performance: return last stirng built if input string is the
|
||||
* same (for example user just change cursor position, or input text is
|
||||
@@ -703,7 +703,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
return (aspell_last_modifier_result) ?
|
||||
strdup (aspell_last_modifier_result) : NULL;
|
||||
}
|
||||
|
||||
|
||||
/* free last modifier string and result */
|
||||
if (aspell_last_modifier_string)
|
||||
{
|
||||
@@ -715,25 +715,25 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
free (aspell_last_modifier_result);
|
||||
aspell_last_modifier_result = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* save last modifier string received */
|
||||
aspell_last_modifier_string = strdup (string);
|
||||
|
||||
|
||||
color_normal = weechat_color ("bar_fg");
|
||||
length_color_normal = strlen (color_normal);
|
||||
color_error = weechat_color (weechat_config_string (weechat_aspell_config_look_color));
|
||||
length_color_error = strlen (color_error);
|
||||
|
||||
|
||||
length = strlen (string);
|
||||
result = malloc (length + (length * length_color_error) + 1);
|
||||
|
||||
|
||||
if (result)
|
||||
{
|
||||
result[0] = '\0';
|
||||
|
||||
|
||||
ptr_string = aspell_last_modifier_string;
|
||||
index_result = 0;
|
||||
|
||||
|
||||
/* check if string is a command */
|
||||
if (!weechat_string_input_for_buffer (ptr_string))
|
||||
{
|
||||
@@ -749,9 +749,9 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
free (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pos_space[0] = '\0';
|
||||
|
||||
|
||||
/* exit if command is not authorized for spell checking */
|
||||
if (!weechat_aspell_command_authorized (ptr_string))
|
||||
{
|
||||
@@ -762,11 +762,11 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
index_result += char_size;
|
||||
strcpy (result + index_result, ptr_string);
|
||||
index_result += strlen (ptr_string);
|
||||
|
||||
|
||||
pos_space[0] = ' ';
|
||||
ptr_string = pos_space;
|
||||
}
|
||||
|
||||
|
||||
while (ptr_string[0])
|
||||
{
|
||||
/* find start of word */
|
||||
@@ -785,7 +785,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
}
|
||||
if (!ptr_string[0])
|
||||
break;
|
||||
|
||||
|
||||
ptr_end = weechat_utf8_next_char (ptr_string);
|
||||
utf8_char_int = weechat_utf8_char_int (ptr_end);
|
||||
while (iswalnum (utf8_char_int) || (utf8_char_int == '\'')
|
||||
@@ -799,44 +799,44 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
save_end = ptr_end[0];
|
||||
ptr_end[0] = '\0';
|
||||
length_word = ptr_end - ptr_string;
|
||||
|
||||
|
||||
if ((save_end != '\0')
|
||||
|| (weechat_config_integer (weechat_aspell_config_check_real_time)))
|
||||
word_ok = weechat_aspell_check_word (buffer, ptr_string);
|
||||
else
|
||||
word_ok = 1;
|
||||
|
||||
|
||||
/* add error color */
|
||||
if (!word_ok)
|
||||
{
|
||||
strcpy (result + index_result, color_error);
|
||||
index_result += length_color_error;
|
||||
}
|
||||
|
||||
|
||||
/* add word */
|
||||
strcpy (result + index_result, ptr_string);
|
||||
index_result += length_word;
|
||||
|
||||
|
||||
/* add normal color (after misspelled word) */
|
||||
if (!word_ok)
|
||||
{
|
||||
strcpy (result + index_result, color_normal);
|
||||
index_result += length_color_normal;
|
||||
}
|
||||
|
||||
|
||||
if (save_end == '\0')
|
||||
break;
|
||||
|
||||
ptr_end[0] = save_end;
|
||||
ptr_string = ptr_end;
|
||||
}
|
||||
|
||||
|
||||
result[index_result] = '\0';
|
||||
}
|
||||
|
||||
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
||||
aspell_last_modifier_result = strdup (result);
|
||||
return result;
|
||||
}
|
||||
@@ -850,10 +850,10 @@ weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char *dicts;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "dictlist") == 0)
|
||||
@@ -907,7 +907,7 @@ weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
@@ -921,18 +921,18 @@ weechat_aspell_completion_langs_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (i = 0; langs_avail[i].code; i++)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, langs_avail[i].code,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -946,15 +946,15 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
if (!weechat_aspell_config_init ())
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
if (weechat_aspell_config_read () < 0)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
/* command /aspell */
|
||||
weechat_hook_command ("aspell",
|
||||
N_("aspell plugin configuration"),
|
||||
@@ -978,7 +978,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
weechat_hook_completion ("aspell_langs",
|
||||
N_("list of supported langs for aspell"),
|
||||
&weechat_aspell_completion_langs_cb, NULL);
|
||||
|
||||
|
||||
/*
|
||||
* callback for spell checking input text
|
||||
* we use a low priority here, so that other modifiers "input_text_display"
|
||||
@@ -986,7 +986,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
*/
|
||||
weechat_hook_modifier ("500|input_text_display",
|
||||
&weechat_aspell_modifier_cb, NULL);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -999,17 +999,17 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
weechat_aspell_config_write ();
|
||||
|
||||
|
||||
weechat_aspell_speller_free_all ();
|
||||
|
||||
|
||||
if (aspell_last_modifier_string)
|
||||
free (aspell_last_modifier_string);
|
||||
if (aspell_last_modifier_result)
|
||||
free (aspell_last_modifier_result);
|
||||
|
||||
|
||||
weechat_aspell_config_free ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -65,11 +65,11 @@ charset_config_reload (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
/* free all decode/encode charsets */
|
||||
weechat_config_section_free_options (charset_config_section_decode);
|
||||
weechat_config_section_free_options (charset_config_section_encode);
|
||||
|
||||
|
||||
return weechat_config_reload (config_file);
|
||||
}
|
||||
|
||||
@@ -84,12 +84,12 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -120,7 +120,7 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -128,7 +128,7 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
|
||||
weechat_prefix ("error"), CHARSET_PLUGIN_NAME,
|
||||
option_name, value);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -141,12 +141,12 @@ int
|
||||
charset_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
charset_config_file = weechat_config_new (CHARSET_CONFIG_NAME,
|
||||
&charset_config_reload, NULL);
|
||||
if (!charset_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (charset_config_file, "default",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -157,7 +157,7 @@ charset_config_init ()
|
||||
weechat_config_free (charset_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
charset_default_decode = weechat_config_new_option (
|
||||
charset_config_file, ptr_section,
|
||||
"decode", "string",
|
||||
@@ -174,7 +174,7 @@ charset_config_init ()
|
||||
N_("global encoding charset"),
|
||||
NULL, 0, 0, "", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (charset_config_file, "decode",
|
||||
1, 1,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -186,9 +186,9 @@ charset_config_init ()
|
||||
weechat_config_free (charset_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
charset_config_section_decode = ptr_section;
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (charset_config_file, "encode",
|
||||
1, 1,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -200,9 +200,9 @@ charset_config_init ()
|
||||
weechat_config_free (charset_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
charset_config_section_encode = ptr_section;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -235,14 +235,14 @@ int
|
||||
charset_check (const char *charset)
|
||||
{
|
||||
iconv_t cd;
|
||||
|
||||
|
||||
if (!charset || !charset[0])
|
||||
return 0;
|
||||
|
||||
|
||||
cd = iconv_open (charset, charset_internal);
|
||||
if (cd == (iconv_t)(-1))
|
||||
return 0;
|
||||
|
||||
|
||||
iconv_close (cd);
|
||||
return 1;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ charset_get (struct t_config_section *section, const char *name,
|
||||
{
|
||||
char *option_name, *ptr_end;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
option_name = strdup (name);
|
||||
if (option_name)
|
||||
{
|
||||
@@ -285,18 +285,18 @@ charset_get (struct t_config_section *section, const char *name,
|
||||
ptr_option = weechat_config_search_option (charset_config_file,
|
||||
section,
|
||||
option_name);
|
||||
|
||||
|
||||
free (option_name);
|
||||
|
||||
|
||||
if (ptr_option)
|
||||
return weechat_config_string (ptr_option);
|
||||
}
|
||||
|
||||
|
||||
/* nothing found => return default decode/encode charset (if set) */
|
||||
if (weechat_config_string (default_charset)
|
||||
&& weechat_config_string (default_charset)[0])
|
||||
return weechat_config_string (default_charset);
|
||||
|
||||
|
||||
/* no default charset set */
|
||||
return NULL;
|
||||
}
|
||||
@@ -310,11 +310,11 @@ charset_decode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
const char *string)
|
||||
{
|
||||
const char *charset;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) modifier;
|
||||
|
||||
|
||||
charset = charset_get (charset_config_section_decode, modifier_data,
|
||||
charset_default_decode);
|
||||
if (weechat_charset_plugin->debug)
|
||||
@@ -326,7 +326,7 @@ charset_decode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
}
|
||||
if (charset && charset[0])
|
||||
return weechat_iconv_to_internal (charset, string);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -339,11 +339,11 @@ charset_encode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
const char *string)
|
||||
{
|
||||
const char *charset;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) modifier;
|
||||
|
||||
|
||||
charset = charset_get (charset_config_section_encode, modifier_data,
|
||||
charset_default_encode);
|
||||
if (weechat_charset_plugin->debug)
|
||||
@@ -355,7 +355,7 @@ charset_encode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
}
|
||||
if (charset && charset[0])
|
||||
return weechat_iconv_from_internal (charset, string);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
int length;
|
||||
char *ptr_charset, *option_name;
|
||||
const char *plugin_name, *name, *charset_modifier;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
@@ -415,9 +415,9 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
charset_display_charsets ();
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
ptr_section = NULL;
|
||||
|
||||
|
||||
plugin_name = weechat_buffer_get_string (buffer, "plugin");
|
||||
name = weechat_buffer_get_string (buffer, "name");
|
||||
|
||||
@@ -431,10 +431,10 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
option_name = malloc (length);
|
||||
if (!option_name)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
snprintf (option_name, length, "%s.%s", plugin_name, name);
|
||||
}
|
||||
|
||||
|
||||
if ((argc > 1) && (weechat_strcasecmp (argv[1], "reset") == 0))
|
||||
{
|
||||
charset_set (charset_config_section_decode, "decode", option_name,
|
||||
@@ -469,7 +469,7 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
else
|
||||
ptr_charset = argv_eol[1];
|
||||
|
||||
|
||||
if (!charset_check (ptr_charset))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -492,9 +492,9 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
ptr_charset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free (option_name);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -508,17 +508,17 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
/* get terminal & internal charsets */
|
||||
charset_terminal = weechat_info_get ("charset_terminal", "");
|
||||
charset_internal = weechat_info_get ("charset_internal", "");
|
||||
|
||||
|
||||
/* display message */
|
||||
if (weechat_charset_plugin->debug >= 1)
|
||||
charset_display_charsets ();
|
||||
|
||||
|
||||
if (!charset_config_init ())
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -527,7 +527,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
charset_config_read ();
|
||||
|
||||
|
||||
/* /charset command */
|
||||
weechat_hook_command ("charset",
|
||||
N_("change charset for current buffer"),
|
||||
@@ -539,11 +539,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
" reset: reset charsets for current buffer"),
|
||||
"decode|encode|reset",
|
||||
&charset_command_cb, NULL);
|
||||
|
||||
|
||||
/* modifiers hooks */
|
||||
weechat_hook_modifier ("charset_decode", &charset_decode_cb, NULL);
|
||||
weechat_hook_modifier ("charset_encode", &charset_encode_cb, NULL);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -556,10 +556,10 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
charset_config_write ();
|
||||
|
||||
|
||||
weechat_config_free (charset_config_file);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
+24
-24
@@ -56,7 +56,7 @@ demo_printf_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
weechat_printf (buffer,
|
||||
"demo_printf: \"%s\"", argv_eol[1]);
|
||||
@@ -75,7 +75,7 @@ demo_printf_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_color ("chat_server"),
|
||||
weechat_color ("chat_host"));
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -89,14 +89,14 @@ demo_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
weechat_printf (buffer,
|
||||
"buffer_input_data_cb: buffer = %lx (%s), "
|
||||
"input_data = \"%s\"",
|
||||
(long unsigned int)buffer,
|
||||
weechat_buffer_get_string (buffer, "name"),
|
||||
input_data);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ demo_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
(long unsigned int)buffer,
|
||||
weechat_buffer_get_string (buffer, "name"));
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ demo_buffer_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
(void) argv_eol;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
new_buffer = weechat_buffer_new (argv[1],
|
||||
@@ -148,7 +148,7 @@ demo_buffer_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -164,10 +164,10 @@ demo_infolist_print (struct t_infolist *infolist, const char *item_name)
|
||||
void *pointer;
|
||||
int i, j, argc, size;
|
||||
time_t time;
|
||||
|
||||
|
||||
if (!infolist)
|
||||
return;
|
||||
|
||||
|
||||
i = 1;
|
||||
while (weechat_infolist_next (infolist))
|
||||
{
|
||||
@@ -234,11 +234,11 @@ demo_info_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char **argv, char **argv_eol)
|
||||
{
|
||||
struct t_infolist *infolist;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
weechat_printf (NULL, "info \"%s\" = \"%s\"",
|
||||
argv[1],
|
||||
@@ -261,7 +261,7 @@ demo_info_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -274,11 +274,11 @@ demo_infolist_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char **argv, char **argv_eol)
|
||||
{
|
||||
struct t_infolist *infolist;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
infolist = weechat_infolist_get (argv[1], NULL,
|
||||
@@ -306,7 +306,7 @@ demo_infolist_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ demo_signal_cb (void *data, const char *signal, const char *type_data,
|
||||
signal, type_data, (long unsigned int)signal_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -366,23 +366,23 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
weechat_hook_command ("demo_printf",
|
||||
N_("print some messages on current buffer"),
|
||||
N_("<text>"),
|
||||
N_("text: write this text"),
|
||||
"",
|
||||
&demo_printf_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_command ("demo_buffer",
|
||||
N_("open a new buffer"),
|
||||
N_("<name>"),
|
||||
"",
|
||||
"",
|
||||
&demo_buffer_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_command ("demo_info",
|
||||
N_("get and display an info"),
|
||||
N_("<info> [<arguments>]"),
|
||||
@@ -392,7 +392,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"of available infos"),
|
||||
"%(infos)",
|
||||
&demo_info_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_command ("demo_infolist",
|
||||
N_("get and display an infolist"),
|
||||
N_("<infolist> [<arguments>]"),
|
||||
@@ -402,9 +402,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"of available infolists"),
|
||||
"%(infolists)",
|
||||
&demo_infolist_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_signal ("*", &demo_signal_cb, NULL);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -417,6 +417,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ fifo_info_get_info_cb (void *data, const char *info_name,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) arguments;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (info_name, "fifo_filename") == 0)
|
||||
{
|
||||
return fifo_filename;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+39
-39
@@ -74,17 +74,17 @@ fifo_remove_old_pipes ()
|
||||
DIR *dp;
|
||||
struct dirent *entry;
|
||||
struct stat statbuf;
|
||||
|
||||
|
||||
buf_len = PATH_MAX;
|
||||
buf = malloc (buf_len);
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
|
||||
weechat_home = weechat_info_get ("weechat_dir", "");
|
||||
dir_separator = weechat_info_get ("dir_separator", "");
|
||||
|
||||
|
||||
prefix_len = strlen (FIFO_FILENAME_PREFIX);
|
||||
|
||||
|
||||
dp = opendir (weechat_home);
|
||||
if (dp != NULL)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ fifo_remove_old_pipes ()
|
||||
}
|
||||
closedir (dp);
|
||||
}
|
||||
|
||||
|
||||
free (buf);
|
||||
}
|
||||
|
||||
@@ -121,20 +121,20 @@ fifo_create ()
|
||||
{
|
||||
int filename_length;
|
||||
const char *fifo_option, *weechat_home;
|
||||
|
||||
|
||||
fifo_option = weechat_config_get_plugin ("fifo");
|
||||
if (!fifo_option)
|
||||
{
|
||||
weechat_config_set_plugin ("fifo", "on");
|
||||
fifo_option = weechat_config_get_plugin ("fifo");
|
||||
}
|
||||
|
||||
|
||||
weechat_home = weechat_info_get ("weechat_dir", "");
|
||||
|
||||
|
||||
if (fifo_option && weechat_home)
|
||||
{
|
||||
fifo_remove_old_pipes ();
|
||||
|
||||
|
||||
if (weechat_strcasecmp (fifo_option, "on") == 0)
|
||||
{
|
||||
/*
|
||||
@@ -149,9 +149,9 @@ fifo_create ()
|
||||
"%s/%s%d",
|
||||
weechat_home, FIFO_FILENAME_PREFIX, (int) getpid());
|
||||
}
|
||||
|
||||
|
||||
fifo_fd = -1;
|
||||
|
||||
|
||||
/* create FIFO pipe, writable for user only */
|
||||
if (mkfifo (fifo_filename, 0600) == 0)
|
||||
{
|
||||
@@ -205,11 +205,11 @@ fifo_remove ()
|
||||
close (fifo_fd);
|
||||
fifo_fd = -1;
|
||||
}
|
||||
|
||||
|
||||
/* remove FIFO from disk */
|
||||
if (fifo_filename)
|
||||
unlink (fifo_filename);
|
||||
|
||||
|
||||
/* remove any unterminated message */
|
||||
if (fifo_unterminated)
|
||||
{
|
||||
@@ -223,7 +223,7 @@ fifo_remove ()
|
||||
free (fifo_filename);
|
||||
fifo_filename = NULL;
|
||||
}
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("%s: pipe closed"),
|
||||
FIFO_PLUGIN_NAME);
|
||||
@@ -238,14 +238,14 @@ fifo_exec (const char *text)
|
||||
{
|
||||
char *text2, *pos_msg, *pos_buffer;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
text2 = strdup (text);
|
||||
if (!text2)
|
||||
return;
|
||||
|
||||
|
||||
pos_msg = NULL;
|
||||
ptr_buffer = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* look for plugin + buffer name at beginning of text
|
||||
* text may be: "plugin.buffer *text" or "*text"
|
||||
@@ -268,7 +268,7 @@ fifo_exec (const char *text)
|
||||
}
|
||||
pos_msg[0] = '\0';
|
||||
pos_msg += 2;
|
||||
|
||||
|
||||
pos_buffer = strchr (text2, '.');
|
||||
if (!pos_buffer)
|
||||
{
|
||||
@@ -280,11 +280,11 @@ fifo_exec (const char *text)
|
||||
}
|
||||
pos_buffer[0] = '\0';
|
||||
pos_buffer++;
|
||||
|
||||
|
||||
if (text2[0] && pos_buffer[0])
|
||||
ptr_buffer = weechat_buffer_search (text2, pos_buffer);
|
||||
}
|
||||
|
||||
|
||||
if (!ptr_buffer)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -293,9 +293,9 @@ fifo_exec (const char *text)
|
||||
free (text2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
weechat_command (ptr_buffer, pos_msg);
|
||||
|
||||
|
||||
free (text2);
|
||||
}
|
||||
|
||||
@@ -309,12 +309,12 @@ fifo_read ()
|
||||
static char buffer[4096 + 2];
|
||||
char *buf2, *pos, *ptr_buf, *next_ptr_buf;
|
||||
int num_read;
|
||||
|
||||
|
||||
num_read = read (fifo_fd, buffer, sizeof (buffer) - 2);
|
||||
if (num_read > 0)
|
||||
{
|
||||
buffer[num_read] = '\0';
|
||||
|
||||
|
||||
buf2 = NULL;
|
||||
ptr_buf = buffer;
|
||||
if (fifo_unterminated)
|
||||
@@ -330,7 +330,7 @@ fifo_read ()
|
||||
free (fifo_unterminated);
|
||||
fifo_unterminated = NULL;
|
||||
}
|
||||
|
||||
|
||||
while (ptr_buf && ptr_buf[0])
|
||||
{
|
||||
next_ptr_buf = NULL;
|
||||
@@ -355,13 +355,13 @@ fifo_read ()
|
||||
next_ptr_buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ptr_buf)
|
||||
fifo_exec (ptr_buf);
|
||||
|
||||
|
||||
ptr_buf = next_ptr_buf;
|
||||
}
|
||||
|
||||
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
@@ -406,7 +406,7 @@ fifo_config_cb (void *data, const char *option, const char *value)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (value, "on") == 0)
|
||||
{
|
||||
if (fifo_fd < 0)
|
||||
@@ -417,7 +417,7 @@ fifo_config_cb (void *data, const char *option, const char *value)
|
||||
if (fifo_fd >= 0)
|
||||
fifo_remove ();
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -431,19 +431,19 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
fifo_quiet = 1;
|
||||
|
||||
|
||||
fifo_create ();
|
||||
|
||||
|
||||
weechat_hook_config ("plugins.var.fifo.fifo", &fifo_config_cb, NULL);
|
||||
|
||||
|
||||
fifo_info_init ();
|
||||
|
||||
|
||||
fifo_quiet = 0;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -456,8 +456,8 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
fifo_remove ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -47,22 +47,22 @@ irc_bar_item_away (void *data, struct t_gui_bar_item *item,
|
||||
struct t_irc_server *server;
|
||||
char *buf, *message;
|
||||
int length;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
buf = NULL;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_and_channel (buffer, &server, NULL);
|
||||
|
||||
|
||||
if (server && server->is_away)
|
||||
{
|
||||
if (weechat_config_boolean (irc_config_look_item_away_message)
|
||||
@@ -88,7 +88,7 @@ irc_bar_item_away (void *data, struct t_gui_bar_item *item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -103,29 +103,29 @@ irc_bar_item_buffer_title (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_buffer *buffer;
|
||||
const char *title;
|
||||
char *title_color;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
title = weechat_buffer_get_string (buffer, "title");
|
||||
if (!title)
|
||||
return NULL;
|
||||
|
||||
|
||||
title_color = irc_color_decode (title,
|
||||
(weechat_config_boolean (irc_config_look_topic_strip_colors)) ?
|
||||
0 : 1);
|
||||
|
||||
|
||||
return (title_color) ? title_color : strdup (title);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -143,16 +143,16 @@ irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item,
|
||||
const char *name;
|
||||
struct t_irc_server *server;
|
||||
struct t_irc_channel *channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
ptr_plugin = weechat_buffer_get_pointer (buffer, "plugin");
|
||||
@@ -180,7 +180,7 @@ irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item,
|
||||
}
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -198,21 +198,21 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_irc_server *server;
|
||||
struct t_irc_channel *channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buf_name[0] = '\0';
|
||||
modes[0] = '\0';
|
||||
|
||||
|
||||
display_server = (weechat_config_integer (irc_config_look_item_display_server) == IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_NAME);
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_and_channel (buffer, &server, &channel);
|
||||
@@ -282,14 +282,14 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
if (name)
|
||||
snprintf (buf_name, sizeof (buf_name), "%s", name);
|
||||
}
|
||||
|
||||
|
||||
snprintf (buf, sizeof (buf), "%s%s%s",
|
||||
(server && server->ssl_connected) ? IRC_COLOR_STATUS_NAME_SSL : IRC_COLOR_STATUS_NAME,
|
||||
buf_name,
|
||||
modes);
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -307,21 +307,21 @@ irc_bar_item_channel (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_irc_server *server;
|
||||
struct t_irc_channel *channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buf_name[0] = '\0';
|
||||
modes[0] = '\0';
|
||||
|
||||
|
||||
display_server = (weechat_config_integer (irc_config_look_item_display_server) == IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_NAME);
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_and_channel (buffer, &server, &channel);
|
||||
@@ -363,14 +363,14 @@ irc_bar_item_channel (void *data, struct t_gui_bar_item *item,
|
||||
if (name)
|
||||
snprintf (buf_name, sizeof (buf_name), "%s", name);
|
||||
}
|
||||
|
||||
|
||||
snprintf (buf, sizeof (buf), "%s%s%s",
|
||||
IRC_COLOR_STATUS_NAME,
|
||||
buf_name,
|
||||
modes);
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -385,20 +385,20 @@ irc_bar_item_lag (void *data, struct t_gui_bar_item *item,
|
||||
char buf[128];
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_irc_server *server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_and_channel (buffer, &server, NULL);
|
||||
|
||||
|
||||
if (server
|
||||
&& (server->lag >= weechat_config_integer (irc_config_network_lag_min_show)))
|
||||
{
|
||||
@@ -430,22 +430,22 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
|
||||
struct t_irc_nick *ptr_nick;
|
||||
char *buf, str_prefix[64];
|
||||
int length;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_and_channel (buffer, &server, &channel);
|
||||
if (!server || !server->nick)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* build prefix */
|
||||
str_prefix[0] = '\0';
|
||||
if (weechat_config_boolean (irc_config_look_item_nick_prefix)
|
||||
@@ -463,11 +463,11 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* build bar item */
|
||||
length = 64 + strlen (server->nick) + 64 +
|
||||
((server->nick_modes) ? strlen (server->nick_modes) : 0) + 64 + 1;
|
||||
|
||||
|
||||
buf = malloc (length);
|
||||
if (buf)
|
||||
{
|
||||
@@ -491,10 +491,10 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
|
||||
server->nick);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -511,22 +511,22 @@ irc_bar_item_focus_buffer_nicklist (void *data,
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
const char *str_buffer, *nick;
|
||||
|
||||
|
||||
str_buffer = weechat_hashtable_get (info, "_buffer");
|
||||
if (!str_buffer || !str_buffer[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
rc = sscanf (str_buffer, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return NULL;
|
||||
|
||||
|
||||
buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (ptr_server && ptr_channel)
|
||||
{
|
||||
nick = weechat_hashtable_get (info, "nick");
|
||||
@@ -540,7 +540,7 @@ irc_bar_item_focus_buffer_nicklist (void *data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -558,14 +558,14 @@ irc_bar_item_buffer_switch (void *data, const char *signal,
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
|
||||
weechat_bar_item_update ("away");
|
||||
weechat_bar_item_update ("buffer_title");
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
weechat_bar_item_update ("irc_channel");
|
||||
weechat_bar_item_update ("lag");
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,15 +49,15 @@ irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
if (server)
|
||||
*server = NULL;
|
||||
if (channel)
|
||||
*channel = NULL;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
|
||||
/* look for a server or channel using this buffer */
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
@@ -68,7 +68,7 @@ irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
|
||||
*server = ptr_server;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* no server or channel found */
|
||||
}
|
||||
|
||||
@@ -94,18 +94,18 @@ char *
|
||||
irc_buffer_build_name (const char *server, const char *channel)
|
||||
{
|
||||
static char buffer[128];
|
||||
|
||||
|
||||
buffer[0] = '\0';
|
||||
|
||||
|
||||
if (!server && !channel)
|
||||
return buffer;
|
||||
|
||||
|
||||
if (server && channel)
|
||||
snprintf (buffer, sizeof (buffer), "%s.%s", server, channel);
|
||||
else
|
||||
snprintf (buffer, sizeof (buffer), "%s",
|
||||
(server) ? server : channel);
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ int
|
||||
irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_irc_channel *next_channel;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (buffer == irc_raw_buffer)
|
||||
{
|
||||
irc_raw_buffer = NULL;
|
||||
@@ -156,7 +156,7 @@ irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -172,10 +172,10 @@ irc_buffer_search_first_for_all_servers ()
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_irc_server *ptr_server;
|
||||
int number, number_found;
|
||||
|
||||
|
||||
ptr_buffer = NULL;
|
||||
number_found = INT_MAX;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
|
||||
@@ -50,17 +50,17 @@ int
|
||||
irc_channel_valid (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
if (!server)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ptr_channel == channel)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* channel not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -77,12 +77,12 @@ irc_channel_move_near_server (struct t_irc_server *server, int channel_type,
|
||||
int number_found;
|
||||
char str_number[32];
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
number = weechat_buffer_get_integer (buffer, "number");
|
||||
number_last_channel = 0;
|
||||
number_last_private = 0;
|
||||
number_found = 0;
|
||||
|
||||
|
||||
if (server->channels)
|
||||
{
|
||||
/* search last channel/pv number for server */
|
||||
@@ -106,7 +106,7 @@ irc_channel_move_near_server (struct t_irc_server *server, int channel_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* use last channel/pv number + 1 */
|
||||
switch (channel_type)
|
||||
{
|
||||
@@ -130,7 +130,7 @@ irc_channel_move_near_server (struct t_irc_server *server, int channel_type,
|
||||
number_found = weechat_buffer_get_integer (server->buffer, "number") + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* switch to number found */
|
||||
if ((number_found >= 1) && (number_found != number))
|
||||
{
|
||||
@@ -154,7 +154,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
int i, buffer_created, current_buffer_number, buffer_position, manual_join;
|
||||
char *buffer_name, str_number[32], str_group[32], *channel_name_lower;
|
||||
const char *prefix_modes;
|
||||
|
||||
|
||||
/* alloc memory for new channel */
|
||||
if ((new_channel = malloc (sizeof (*new_channel))) == NULL)
|
||||
{
|
||||
@@ -163,7 +163,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* create buffer for channel (or use existing one) */
|
||||
buffer_created = 0;
|
||||
buffer_name = irc_buffer_build_name (server->name, channel_name);
|
||||
@@ -206,7 +206,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
}
|
||||
buffer_created = 1;
|
||||
}
|
||||
|
||||
|
||||
if (buffer_created)
|
||||
{
|
||||
if (!weechat_buffer_get_integer (new_buffer, "short_name_is_set"))
|
||||
@@ -227,7 +227,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
weechat_buffer_set (new_buffer, "nicklist", "1");
|
||||
weechat_buffer_set (new_buffer, "nicklist_display_groups", "0");
|
||||
}
|
||||
|
||||
|
||||
/* set highlights settings on channel buffer */
|
||||
weechat_buffer_set(new_buffer, "highlight_words_add", "$nick");
|
||||
if (weechat_config_string (irc_config_look_highlight_tags)
|
||||
@@ -237,7 +237,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
weechat_config_string (irc_config_look_highlight_tags));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
prefix_modes = irc_server_get_prefix_modes (server);
|
||||
@@ -253,7 +253,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
weechat_nicklist_add_group (new_buffer, NULL, str_group,
|
||||
"weechat.color.nicklist_group", 1);
|
||||
}
|
||||
|
||||
|
||||
/* initialize new channel */
|
||||
new_channel->type = channel_type;
|
||||
new_channel->name = strdup (channel_name);
|
||||
@@ -279,7 +279,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
new_channel->last_nick_speaking_time = NULL;
|
||||
new_channel->buffer = new_buffer;
|
||||
new_channel->buffer_as_string = NULL;
|
||||
|
||||
|
||||
/* add new channel to channels list */
|
||||
new_channel->prev_channel = server->last_channel;
|
||||
new_channel->next_channel = NULL;
|
||||
@@ -288,7 +288,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
else
|
||||
server->channels = new_channel;
|
||||
server->last_channel = new_channel;
|
||||
|
||||
|
||||
manual_join = 0;
|
||||
channel_name_lower = NULL;
|
||||
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
@@ -301,7 +301,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
channel_name_lower);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (switch_to_channel)
|
||||
{
|
||||
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
@@ -310,23 +310,23 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
|| (!manual_join && !weechat_config_boolean (irc_config_look_buffer_switch_autojoin)))
|
||||
switch_to_channel = 0;
|
||||
}
|
||||
|
||||
|
||||
if (switch_to_channel)
|
||||
{
|
||||
weechat_buffer_set (new_buffer, "display",
|
||||
(auto_switch) ? "auto" : "1");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (manual_join)
|
||||
weechat_hashtable_remove (server->manual_joins, channel_name_lower);
|
||||
if (channel_name_lower)
|
||||
free (channel_name_lower);
|
||||
|
||||
|
||||
weechat_hook_signal_send ((channel_type == IRC_CHANNEL_TYPE_CHANNEL) ?
|
||||
"irc_channel_opened" : "irc_pv_opened",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
|
||||
|
||||
|
||||
/* all is ok, return address of new channel */
|
||||
return new_channel;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ irc_channel_set_topic (struct t_irc_channel *channel, const char *topic)
|
||||
{
|
||||
if (channel->topic)
|
||||
free (channel->topic);
|
||||
|
||||
|
||||
channel->topic = (topic) ? strdup (topic) : NULL;
|
||||
weechat_buffer_set (channel->buffer, "title",
|
||||
(channel->topic) ? channel->topic : "");
|
||||
@@ -354,10 +354,10 @@ struct t_irc_channel *
|
||||
irc_channel_search (struct t_irc_server *server, const char *channel_name)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
@@ -375,10 +375,10 @@ int
|
||||
irc_channel_is_channel (const char *string)
|
||||
{
|
||||
char first_char[2];
|
||||
|
||||
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
|
||||
first_char[0] = string[0];
|
||||
first_char[1] = '\0';
|
||||
return (strpbrk (first_char, IRC_CHANNEL_PREFIX)) ? 1 : 0;
|
||||
@@ -393,7 +393,7 @@ irc_channel_remove_away (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
@@ -436,7 +436,7 @@ irc_channel_set_away (struct t_irc_server *server,
|
||||
int is_away)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
ptr_nick = irc_nick_search (channel, nick_name);
|
||||
@@ -456,21 +456,21 @@ irc_channel_nick_speaking_add_to_list (struct t_irc_channel *channel,
|
||||
{
|
||||
int size, to_remove, i;
|
||||
struct t_weelist_item *ptr_item;
|
||||
|
||||
|
||||
/* create list if it does not exist */
|
||||
if (!channel->nicks_speaking[highlight])
|
||||
channel->nicks_speaking[highlight] = weechat_list_new ();
|
||||
|
||||
|
||||
/* remove item if it was already in list */
|
||||
ptr_item = weechat_list_casesearch (channel->nicks_speaking[highlight],
|
||||
nick_name);
|
||||
if (ptr_item)
|
||||
weechat_list_remove (channel->nicks_speaking[highlight], ptr_item);
|
||||
|
||||
|
||||
/* add nick in list */
|
||||
weechat_list_add (channel->nicks_speaking[highlight], nick_name,
|
||||
WEECHAT_LIST_POS_END, NULL);
|
||||
|
||||
|
||||
/* reduce list size if it's too big */
|
||||
size = weechat_list_size (channel->nicks_speaking[highlight]);
|
||||
if (size > IRC_CHANNEL_NICKS_SPEAKING_LIMIT)
|
||||
@@ -498,7 +498,7 @@ irc_channel_nick_speaking_add (struct t_irc_channel *channel,
|
||||
highlight = 1;
|
||||
if (highlight)
|
||||
irc_channel_nick_speaking_add_to_list (channel, nick_name, 1);
|
||||
|
||||
|
||||
irc_channel_nick_speaking_add_to_list (channel, nick_name, 0);
|
||||
}
|
||||
|
||||
@@ -537,10 +537,10 @@ irc_channel_nick_speaking_time_search (struct t_irc_channel *channel,
|
||||
{
|
||||
struct t_irc_channel_speaking *ptr_nick;
|
||||
time_t time_limit;
|
||||
|
||||
|
||||
time_limit = time (NULL) -
|
||||
(weechat_config_integer (irc_config_look_smart_filter_delay) * 60);
|
||||
|
||||
|
||||
for (ptr_nick = channel->nicks_speaking_time; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
@@ -551,7 +551,7 @@ irc_channel_nick_speaking_time_search (struct t_irc_channel *channel,
|
||||
return ptr_nick;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* nick speaking time not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -567,7 +567,7 @@ irc_channel_nick_speaking_time_free (struct t_irc_channel *channel,
|
||||
/* free data */
|
||||
if (nick_speaking->nick)
|
||||
free (nick_speaking->nick);
|
||||
|
||||
|
||||
/* remove nick from list */
|
||||
if (nick_speaking->prev_nick)
|
||||
(nick_speaking->prev_nick)->next_nick = nick_speaking->next_nick;
|
||||
@@ -577,7 +577,7 @@ irc_channel_nick_speaking_time_free (struct t_irc_channel *channel,
|
||||
channel->nicks_speaking_time = nick_speaking->next_nick;
|
||||
if (channel->last_nick_speaking_time == nick_speaking)
|
||||
channel->last_nick_speaking_time = nick_speaking->prev_nick;
|
||||
|
||||
|
||||
free (nick_speaking);
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ void
|
||||
irc_channel_nick_speaking_time_remove_old (struct t_irc_channel *channel)
|
||||
{
|
||||
time_t time_limit;
|
||||
|
||||
|
||||
time_limit = time (NULL) -
|
||||
(weechat_config_integer (irc_config_look_smart_filter_delay) * 60);
|
||||
|
||||
@@ -611,7 +611,7 @@ irc_channel_nick_speaking_time_remove_old (struct t_irc_channel *channel)
|
||||
{
|
||||
if (channel->last_nick_speaking_time->time_last_message >= time_limit)
|
||||
break;
|
||||
|
||||
|
||||
irc_channel_nick_speaking_time_free (channel,
|
||||
channel->last_nick_speaking_time);
|
||||
}
|
||||
@@ -627,17 +627,17 @@ irc_channel_nick_speaking_time_add (struct t_irc_channel *channel,
|
||||
time_t time_last_message)
|
||||
{
|
||||
struct t_irc_channel_speaking *ptr_nick, *new_nick;
|
||||
|
||||
|
||||
ptr_nick = irc_channel_nick_speaking_time_search (channel, nick_name, 0);
|
||||
if (ptr_nick)
|
||||
irc_channel_nick_speaking_time_free (channel, ptr_nick);
|
||||
|
||||
|
||||
new_nick = malloc (sizeof (*new_nick));
|
||||
if (new_nick)
|
||||
{
|
||||
new_nick->nick = strdup (nick_name);
|
||||
new_nick->time_last_message = time_last_message;
|
||||
|
||||
|
||||
/* insert nick at beginning of list */
|
||||
new_nick->prev_nick = NULL;
|
||||
new_nick->next_nick = channel->nicks_speaking_time;
|
||||
@@ -660,7 +660,7 @@ irc_channel_nick_speaking_time_rename (struct t_irc_channel *channel,
|
||||
const char *new_nick)
|
||||
{
|
||||
struct t_irc_channel_speaking *ptr_nick;
|
||||
|
||||
|
||||
if (channel->nicks_speaking_time)
|
||||
{
|
||||
ptr_nick = irc_channel_nick_speaking_time_search (channel, old_nick, 0);
|
||||
@@ -680,12 +680,12 @@ void
|
||||
irc_channel_rejoin (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
{
|
||||
char join_args[256];
|
||||
|
||||
|
||||
snprintf (join_args, sizeof (join_args), "%s%s%s",
|
||||
channel->name,
|
||||
(channel->key) ? " " : "",
|
||||
(channel->key) ? channel->key : "");
|
||||
|
||||
|
||||
irc_command_join_server (server, join_args, 0);
|
||||
}
|
||||
|
||||
@@ -698,12 +698,12 @@ irc_channel_autorejoin_cb (void *data, int remaining_calls)
|
||||
{
|
||||
struct t_irc_server *ptr_server, *ptr_server_found;
|
||||
struct t_irc_channel *ptr_channel_arg, *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
ptr_channel_arg = (struct t_irc_channel *)data;
|
||||
|
||||
|
||||
ptr_server_found = NULL;
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
@@ -718,13 +718,13 @@ irc_channel_autorejoin_cb (void *data, int remaining_calls)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ptr_server_found && (ptr_channel_arg->hook_autorejoin))
|
||||
{
|
||||
irc_channel_rejoin (ptr_server_found, ptr_channel_arg);
|
||||
ptr_channel_arg->hook_autorejoin = NULL;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -740,10 +740,10 @@ irc_channel_display_nick_back_in_pv (struct t_irc_server *server,
|
||||
const char *nickname)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
if (!server || (!nick && !nickname))
|
||||
return;
|
||||
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
@@ -777,10 +777,10 @@ void
|
||||
irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
{
|
||||
struct t_irc_channel *new_channels;
|
||||
|
||||
|
||||
if (!server || !channel)
|
||||
return;
|
||||
|
||||
|
||||
/* remove channel from channels list */
|
||||
if (server->last_channel == channel)
|
||||
server->last_channel = channel->prev_channel;
|
||||
@@ -791,10 +791,10 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
}
|
||||
else
|
||||
new_channels = channel->next_channel;
|
||||
|
||||
|
||||
if (channel->next_channel)
|
||||
(channel->next_channel)->prev_channel = channel->prev_channel;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (channel->name)
|
||||
free (channel->name);
|
||||
@@ -818,9 +818,9 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
irc_channel_nick_speaking_time_free_all (channel);
|
||||
if (channel->buffer_as_string)
|
||||
free (channel->buffer_as_string);
|
||||
|
||||
|
||||
free (channel);
|
||||
|
||||
|
||||
server->channels = new_channels;
|
||||
}
|
||||
|
||||
@@ -845,10 +845,10 @@ struct t_hdata *
|
||||
irc_channel_hdata_channel_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_channel", "next_channel");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -889,10 +889,10 @@ struct t_hdata *
|
||||
irc_channel_hdata_channel_speaking_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -918,14 +918,14 @@ irc_channel_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_channel_speaking *ptr_nick;
|
||||
char option_name[64];
|
||||
int i, index;
|
||||
|
||||
|
||||
if (!infolist || !channel)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_pointer (ptr_item, "buffer", channel->buffer))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "buffer_name",
|
||||
@@ -1003,7 +1003,7 @@ irc_channel_add_to_infolist (struct t_infolist *infolist,
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1018,7 +1018,7 @@ irc_channel_print_log (struct t_irc_channel *channel)
|
||||
struct t_irc_channel_speaking *ptr_nick_speaking;
|
||||
int i, index;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf (" => channel %s (addr:0x%lx):", channel->name, channel);
|
||||
weechat_log_printf (" type . . . . . . . . . . : %d", channel->type);
|
||||
|
||||
+17
-17
@@ -66,17 +66,17 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
int out_length, length, out_pos;
|
||||
char str_fg[3], str_bg[3], str_color[128];
|
||||
int fg, bg, bold, reverse, italic, underline, rc;
|
||||
|
||||
|
||||
out_length = (strlen (string) * 2) + 1;
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
||||
bold = 0;
|
||||
reverse = 0;
|
||||
italic = 0;
|
||||
underline = 0;
|
||||
|
||||
|
||||
ptr_string = (unsigned char *)string;
|
||||
out[0] = '\0';
|
||||
while (ptr_string && ptr_string[0])
|
||||
@@ -197,7 +197,7 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (char *)out;
|
||||
}
|
||||
|
||||
@@ -212,12 +212,12 @@ irc_color_decode_for_user_entry (const char *string)
|
||||
{
|
||||
unsigned char *out, *ptr_string;
|
||||
int out_length, out_pos, length;
|
||||
|
||||
|
||||
out_length = (strlen (string) * 2) + 1;
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_string = (unsigned char *)string;
|
||||
out_pos = 0;
|
||||
while (ptr_string && ptr_string[0] && (out_pos < out_length - 1))
|
||||
@@ -261,9 +261,9 @@ irc_color_decode_for_user_entry (const char *string)
|
||||
ptr_string += length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out[out_pos] = '\0';
|
||||
|
||||
|
||||
return (char *)out;
|
||||
}
|
||||
|
||||
@@ -280,12 +280,12 @@ irc_color_encode (const char *string, int keep_colors)
|
||||
{
|
||||
unsigned char *out, *ptr_string;
|
||||
int out_length, out_pos, length;
|
||||
|
||||
|
||||
out_length = (strlen (string) * 2) + 1;
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_string = (unsigned char *)string;
|
||||
out_pos = 0;
|
||||
while (ptr_string && ptr_string[0] && (out_pos < out_length - 1))
|
||||
@@ -356,9 +356,9 @@ irc_color_encode (const char *string, int keep_colors)
|
||||
ptr_string += length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out[out_pos] = '\0';
|
||||
|
||||
|
||||
return (char *)out;
|
||||
}
|
||||
|
||||
@@ -374,18 +374,18 @@ irc_color_modifier_cb (void *data, const char *modifier,
|
||||
const char *modifier_data, const char *string)
|
||||
{
|
||||
int keep_colors;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
keep_colors = (modifier_data && (strcmp (modifier_data, "1") == 0)) ? 1 : 0;
|
||||
|
||||
|
||||
if (strcmp (modifier, "irc_color_decode") == 0)
|
||||
return irc_color_decode (string, keep_colors);
|
||||
|
||||
|
||||
if (strcmp (modifier, "irc_color_encode") == 0)
|
||||
return irc_color_encode (string, keep_colors);
|
||||
|
||||
|
||||
/* unknown modifier */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+370
-370
File diff suppressed because it is too large
Load Diff
@@ -48,17 +48,17 @@ irc_completion_server_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_server->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -73,17 +73,17 @@ irc_completion_server_nick_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_server && ptr_server->nick)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_server->nick,
|
||||
1, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -98,14 +98,14 @@ irc_completion_server_channels_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
@@ -118,7 +118,7 @@ irc_completion_server_channels_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -133,14 +133,14 @@ irc_completion_server_privates_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
@@ -153,7 +153,7 @@ irc_completion_server_privates_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -169,13 +169,13 @@ irc_completion_server_nicks_cb (void *data, const char *completion_item,
|
||||
{
|
||||
struct t_irc_channel *ptr_channel2;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
for (ptr_channel2 = ptr_server->channels; ptr_channel2;
|
||||
@@ -191,12 +191,12 @@ irc_completion_server_nicks_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* add self nick at the end */
|
||||
weechat_hook_completion_list_add (completion, ptr_server->nick,
|
||||
1, WEECHAT_LIST_POS_END);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -210,19 +210,19 @@ irc_completion_servers_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_server->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -236,17 +236,17 @@ irc_completion_channel_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_channel->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ irc_completion_channel_nicks_add_speakers (struct t_gui_completion *completion,
|
||||
{
|
||||
int list_size, i;
|
||||
const char *nick;
|
||||
|
||||
|
||||
if (channel->nicks_speaking[highlight])
|
||||
{
|
||||
list_size = weechat_list_size (channel->nicks_speaking[highlight]);
|
||||
@@ -291,13 +291,13 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
switch (ptr_channel->type)
|
||||
@@ -342,7 +342,7 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
|
||||
}
|
||||
ptr_channel->nick_completion_reset = 0;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -359,13 +359,13 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
|
||||
struct t_irc_nick *ptr_nick;
|
||||
char *buf;
|
||||
int length;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
switch (ptr_channel->type)
|
||||
@@ -404,7 +404,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -420,13 +420,13 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
|
||||
{
|
||||
char *topic, *topic_color;
|
||||
int length;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_channel && ptr_channel->topic && ptr_channel->topic[0])
|
||||
{
|
||||
if (weechat_strncasecmp (ptr_channel->topic, ptr_channel->name,
|
||||
@@ -449,7 +449,7 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
|
||||
}
|
||||
else
|
||||
topic = strdup (ptr_channel->topic);
|
||||
|
||||
|
||||
topic_color = irc_color_decode_for_user_entry ((topic) ? topic : ptr_channel->topic);
|
||||
weechat_hook_completion_list_add (completion,
|
||||
(topic_color) ? topic_color : ((topic) ? topic : ptr_channel->topic),
|
||||
@@ -459,7 +459,7 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
|
||||
if (topic)
|
||||
free (topic);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -475,12 +475,12 @@ irc_completion_channels_cb (void *data, const char *completion_item,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -494,7 +494,7 @@ irc_completion_channels_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -510,12 +510,12 @@ irc_completion_privates_cb (void *data, const char *completion_item,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -529,7 +529,7 @@ irc_completion_privates_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -543,13 +543,13 @@ irc_completion_msg_part_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
const char *msg_part;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
msg_part = IRC_SERVER_OPTION_STRING(ptr_server,
|
||||
@@ -560,7 +560,7 @@ irc_completion_msg_part_cb (void *data, const char *completion_item,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -576,12 +576,12 @@ irc_completion_ignores_numbers_cb (void *data, const char *completion_item,
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
char str_number[32];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
@@ -589,7 +589,7 @@ irc_completion_ignores_numbers_cb (void *data, const char *completion_item,
|
||||
weechat_hook_completion_list_add (completion, str_number,
|
||||
0, WEECHAT_LIST_POS_END);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -604,13 +604,13 @@ irc_completion_notify_nicks_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_notify *ptr_notify;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
for (ptr_notify = ptr_server->notify_list; ptr_notify;
|
||||
@@ -633,7 +633,7 @@ irc_completion_notify_nicks_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
+118
-118
@@ -144,9 +144,9 @@ irc_config_get_server_from_option_name (const char *name)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
char *pos_option, *server_name;
|
||||
|
||||
|
||||
ptr_server = NULL;
|
||||
|
||||
|
||||
if (name)
|
||||
{
|
||||
pos_option = strrchr (name, '.');
|
||||
@@ -160,7 +160,7 @@ irc_config_get_server_from_option_name (const char *name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ptr_server;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ irc_config_compute_nick_colors ()
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -199,7 +199,7 @@ irc_config_compute_nick_colors ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* if colors are displayed for nicks in nicklist, refresh them */
|
||||
if (weechat_config_boolean(irc_config_look_color_nicks_in_nicklist))
|
||||
irc_nick_nicklist_set_color_all ();
|
||||
@@ -219,7 +219,7 @@ irc_config_set_nick_colors ()
|
||||
irc_config_nick_colors = NULL;
|
||||
irc_config_num_nick_colors = 0;
|
||||
}
|
||||
|
||||
|
||||
irc_config_nick_colors =
|
||||
weechat_string_split (weechat_config_string (weechat_config_get ("weechat.color.chat_nick_colors")),
|
||||
",", 0, 0,
|
||||
@@ -239,10 +239,10 @@ irc_config_change_nick_colors_cb (void *data, const char *option,
|
||||
(void) data;
|
||||
(void) option;
|
||||
(void) value;
|
||||
|
||||
|
||||
irc_config_set_nick_colors ();
|
||||
irc_config_compute_nick_colors ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ irc_config_change_look_color_nicks_in_nicklist (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
irc_nick_nicklist_set_color_all ();
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ irc_config_change_look_server_buffer (void *data,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
@@ -297,7 +297,7 @@ irc_config_change_look_server_buffer (void *data,
|
||||
(weechat_config_integer (irc_config_look_server_buffer) ==
|
||||
IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITH_CORE) ?
|
||||
weechat_buffer_search_main () : irc_buffer_search_first_for_all_servers ();
|
||||
|
||||
|
||||
if (ptr_buffer)
|
||||
{
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
@@ -322,7 +322,7 @@ irc_config_change_look_item_away_message (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("away");
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ irc_config_change_look_item_channel_modes (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ irc_config_change_look_item_channel_modes_hide_key (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ irc_config_change_look_item_nick_modes (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ irc_config_change_look_item_nick_prefix (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
|
||||
@@ -403,11 +403,11 @@ irc_config_change_look_highlight_tags (void *data,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -439,7 +439,7 @@ irc_config_change_look_nick_color_force (void *data,
|
||||
{
|
||||
char **items, *pos;
|
||||
int num_items, i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
@@ -454,7 +454,7 @@ irc_config_change_look_nick_color_force (void *data,
|
||||
}
|
||||
else
|
||||
weechat_hashtable_remove_all (irc_config_hashtable_nick_color_force);
|
||||
|
||||
|
||||
items = weechat_string_split (weechat_config_string (irc_config_look_nick_color_force),
|
||||
";", 0, 0, &num_items);
|
||||
if (items)
|
||||
@@ -472,7 +472,7 @@ irc_config_change_look_nick_color_force (void *data,
|
||||
}
|
||||
weechat_string_free_split (items);
|
||||
}
|
||||
|
||||
|
||||
irc_config_compute_nick_colors ();
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ irc_config_change_look_nick_color_stop_chars (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
irc_config_compute_nick_colors ();
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ irc_config_change_look_topic_strip_colors (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("buffer_title");
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ irc_config_change_color_input_nick (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ irc_config_change_color_item_away (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("away");
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ irc_config_change_color_item_buffer_name (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ irc_config_change_color_item_lag (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("lag");
|
||||
}
|
||||
|
||||
@@ -601,11 +601,11 @@ irc_config_change_color_nick_prefixes (void *data,
|
||||
{
|
||||
char **items, *pos;
|
||||
int num_items, i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (!irc_config_hashtable_nick_prefixes)
|
||||
{
|
||||
irc_config_hashtable_nick_prefixes = weechat_hashtable_new (8,
|
||||
@@ -616,7 +616,7 @@ irc_config_change_color_nick_prefixes (void *data,
|
||||
}
|
||||
else
|
||||
weechat_hashtable_remove_all (irc_config_hashtable_nick_prefixes);
|
||||
|
||||
|
||||
items = weechat_string_split (weechat_config_string (irc_config_color_nick_prefixes),
|
||||
";", 0, 0, &num_items);
|
||||
if (items)
|
||||
@@ -634,9 +634,9 @@ irc_config_change_color_nick_prefixes (void *data,
|
||||
}
|
||||
weechat_string_free_split (items);
|
||||
}
|
||||
|
||||
|
||||
irc_nick_nicklist_set_prefix_color_all ();
|
||||
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
weechat_bar_item_update ("nicklist");
|
||||
}
|
||||
@@ -651,14 +651,14 @@ irc_config_change_network_lag_check (void *data,
|
||||
{
|
||||
time_t time_next_check;
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
time_next_check = (weechat_config_integer (irc_config_network_lag_check) > 0) ?
|
||||
time (NULL) : 0;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -678,7 +678,7 @@ irc_config_change_network_lag_min_show (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("lag");
|
||||
}
|
||||
|
||||
@@ -694,7 +694,7 @@ irc_config_change_network_notify_check_ison (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
irc_notify_hook_timer_ison ();
|
||||
}
|
||||
|
||||
@@ -710,7 +710,7 @@ irc_config_change_network_notify_check_whois (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
irc_notify_hook_timer_whois ();
|
||||
}
|
||||
|
||||
@@ -726,15 +726,15 @@ irc_config_change_network_send_unknown_commands (void *data,
|
||||
char value[2];
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
strcpy (value,
|
||||
(weechat_config_boolean (irc_config_network_send_unknown_commands)) ?
|
||||
"1" : "0");
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -744,7 +744,7 @@ irc_config_change_network_send_unknown_commands (void *data,
|
||||
"input_get_unknown_commands", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -770,7 +770,7 @@ irc_config_server_default_change_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
int index_option;
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
index_option = irc_server_search_option (data);
|
||||
if (index_option >= 0)
|
||||
{
|
||||
@@ -820,7 +820,7 @@ irc_config_check_gnutls_priorities (const char *priorities)
|
||||
gnutls_priority_t priority_cache;
|
||||
const char *pos_error;
|
||||
int rc;
|
||||
|
||||
|
||||
if (!priorities || !priorities[0])
|
||||
return NULL;
|
||||
|
||||
@@ -850,10 +850,10 @@ irc_config_server_check_value_cb (void *data,
|
||||
{
|
||||
int index_option;
|
||||
const char *pos_error;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) option;
|
||||
|
||||
|
||||
index_option = irc_server_search_option (data);
|
||||
if (index_option >= 0)
|
||||
{
|
||||
@@ -873,7 +873,7 @@ irc_config_server_check_value_cb (void *data,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -887,7 +887,7 @@ irc_config_server_change_cb (void *data, struct t_config_option *option)
|
||||
int index_option;
|
||||
char *name;
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
index_option = irc_server_search_option (data);
|
||||
if (index_option >= 0)
|
||||
{
|
||||
@@ -938,10 +938,10 @@ irc_config_server_default_check_notify (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (value && value[0])
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -954,26 +954,26 @@ irc_config_reload (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
int rc;
|
||||
struct t_irc_server *ptr_server, *next_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
ptr_server->reloading_from_config = 1;
|
||||
ptr_server->reloaded_from_config = 0;
|
||||
}
|
||||
|
||||
|
||||
irc_ignore_free_all ();
|
||||
|
||||
|
||||
rc = weechat_config_reload (config_file);
|
||||
|
||||
|
||||
ptr_server = irc_servers;
|
||||
while (ptr_server)
|
||||
{
|
||||
next_server = ptr_server->next_server;
|
||||
|
||||
|
||||
if (!ptr_server->reloaded_from_config)
|
||||
{
|
||||
if (ptr_server->is_connected)
|
||||
@@ -988,10 +988,10 @@ irc_config_reload (void *data, struct t_config_file *config_file)
|
||||
else
|
||||
irc_server_free (ptr_server);
|
||||
}
|
||||
|
||||
|
||||
ptr_server = next_server;
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1007,12 +1007,12 @@ irc_config_msgbuffer_create_option (void *data,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -1045,7 +1045,7 @@ irc_config_msgbuffer_create_option (void *data,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1053,7 +1053,7 @@ irc_config_msgbuffer_create_option (void *data,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
option_name, value);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1071,12 +1071,12 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
|
||||
const char *default_value;
|
||||
static char empty_value[1] = { '\0' };
|
||||
const char *pos_name;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -1097,11 +1097,11 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
|
||||
{
|
||||
pos_name = strchr (option_name, '.');
|
||||
pos_name = (pos_name) ? pos_name + 1 : option_name;
|
||||
|
||||
|
||||
default_value = irc_ctcp_get_default_reply (pos_name);
|
||||
if (!default_value)
|
||||
default_value = empty_value;
|
||||
|
||||
|
||||
ptr_option = weechat_config_new_option (
|
||||
config_file, section,
|
||||
option_name, "string",
|
||||
@@ -1124,7 +1124,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1132,7 +1132,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
option_name, value);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1149,12 +1149,12 @@ irc_config_ignore_read_cb (void *data,
|
||||
{
|
||||
char **argv, **argv_eol;
|
||||
int argc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
if (value && value[0])
|
||||
@@ -1171,7 +1171,7 @@ irc_config_ignore_read_cb (void *data,
|
||||
weechat_string_free_split (argv_eol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1184,13 +1184,13 @@ irc_config_ignore_write_cb (void *data, struct t_config_file *config_file,
|
||||
const char *section_name)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
@@ -1202,7 +1202,7 @@ irc_config_ignore_write_cb (void *data, struct t_config_file *config_file,
|
||||
ptr_ignore->mask))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -1218,13 +1218,13 @@ irc_config_server_write_default_cb (void *data,
|
||||
{
|
||||
int i;
|
||||
char option_name[128];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
|
||||
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
|
||||
{
|
||||
snprintf (option_name, sizeof (option_name),
|
||||
@@ -1246,7 +1246,7 @@ irc_config_server_write_default_cb (void *data,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -1271,9 +1271,9 @@ irc_config_server_new_option (struct t_config_file *config_file,
|
||||
void *callback_change_data)
|
||||
{
|
||||
struct t_config_option *new_option;
|
||||
|
||||
|
||||
new_option = NULL;
|
||||
|
||||
|
||||
switch (index_option)
|
||||
{
|
||||
case IRC_SERVER_OPTION_ADDRESSES:
|
||||
@@ -1701,7 +1701,7 @@ irc_config_server_new_option (struct t_config_file *config_file,
|
||||
case IRC_SERVER_NUM_OPTIONS:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return new_option;
|
||||
}
|
||||
|
||||
@@ -1717,14 +1717,14 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
|
||||
struct t_irc_server *ptr_server;
|
||||
int index_option, rc, i;
|
||||
char *pos_option, *server_name;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
pos_option = strrchr (option_name, '.');
|
||||
@@ -1769,7 +1769,7 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1777,7 +1777,7 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
option_name);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1791,13 +1791,13 @@ irc_config_server_write_cb (void *data, struct t_config_file *config_file,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -1811,7 +1811,7 @@ irc_config_server_write_cb (void *data, struct t_config_file *config_file,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -1825,11 +1825,11 @@ irc_config_server_create_default_options (struct t_config_section *section)
|
||||
int i, length;
|
||||
char *nicks, *username, *realname, *default_value;
|
||||
struct passwd *my_passwd;
|
||||
|
||||
|
||||
nicks = NULL;
|
||||
username = NULL;
|
||||
realname = strdup ("");
|
||||
|
||||
|
||||
/* Get the user's name from /etc/passwd */
|
||||
if ((my_passwd = getpwuid (geteuid ())) != NULL)
|
||||
{
|
||||
@@ -1852,7 +1852,7 @@ irc_config_server_create_default_options (struct t_config_section *section)
|
||||
nicks = strdup (IRC_SERVER_DEFAULT_NICKS);
|
||||
username = strdup ("weechat");
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
|
||||
{
|
||||
default_value = NULL;
|
||||
@@ -1870,7 +1870,7 @@ irc_config_server_create_default_options (struct t_config_section *section)
|
||||
}
|
||||
if (!default_value)
|
||||
default_value = irc_server_option_default[i];
|
||||
|
||||
|
||||
irc_config_server_default[i] = irc_config_server_new_option (
|
||||
irc_config_file,
|
||||
section,
|
||||
@@ -1884,7 +1884,7 @@ irc_config_server_create_default_options (struct t_config_section *section)
|
||||
&irc_config_server_default_change_cb,
|
||||
irc_server_option_string[i]);
|
||||
}
|
||||
|
||||
|
||||
if (nicks)
|
||||
free (nicks);
|
||||
if (username)
|
||||
@@ -1902,7 +1902,7 @@ int
|
||||
irc_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
irc_config_hashtable_nick_color_force = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -1913,12 +1913,12 @@ irc_config_init ()
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
||||
irc_config_file = weechat_config_new (IRC_CONFIG_NAME,
|
||||
&irc_config_reload, NULL);
|
||||
if (!irc_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
/* look */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "look",
|
||||
0, 0,
|
||||
@@ -2216,7 +2216,7 @@ irc_config_init ()
|
||||
N_("strip colors in topic (used only when displaying buffer title)"),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL,
|
||||
&irc_config_change_look_topic_strip_colors, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* color */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "color",
|
||||
0, 0,
|
||||
@@ -2228,7 +2228,7 @@ irc_config_init ()
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
irc_config_color_message_join = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"message_join", "color",
|
||||
@@ -2321,7 +2321,7 @@ irc_config_init ()
|
||||
N_("color for new channel topic (when topic is changed)"),
|
||||
NULL, -1, 0, "white", NULL, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* network */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "network",
|
||||
0, 0,
|
||||
@@ -2333,7 +2333,7 @@ irc_config_init ()
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
irc_config_network_autoreconnect_delay_growing = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"autoreconnect_delay_growing", "integer",
|
||||
@@ -2404,7 +2404,7 @@ irc_config_init ()
|
||||
"(in minutes)"),
|
||||
NULL, 1, 60 * 24 * 7, "5", NULL, 0, NULL, NULL,
|
||||
&irc_config_change_network_notify_check_whois, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* msgbuffer */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "msgbuffer",
|
||||
1, 1,
|
||||
@@ -2418,7 +2418,7 @@ irc_config_init ()
|
||||
return 0;
|
||||
}
|
||||
irc_config_section_msgbuffer = ptr_section;
|
||||
|
||||
|
||||
/* CTCP */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "ctcp",
|
||||
1, 1,
|
||||
@@ -2432,7 +2432,7 @@ irc_config_init ()
|
||||
return 0;
|
||||
}
|
||||
irc_config_section_ctcp = ptr_section;
|
||||
|
||||
|
||||
/* ignore */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "ignore",
|
||||
0, 0,
|
||||
@@ -2445,7 +2445,7 @@ irc_config_init ()
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* server_default */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "server_default",
|
||||
0, 0,
|
||||
@@ -2458,9 +2458,9 @@ irc_config_init ()
|
||||
return 0;
|
||||
}
|
||||
irc_config_section_server_default = ptr_section;
|
||||
|
||||
|
||||
irc_config_server_create_default_options (ptr_section);
|
||||
|
||||
|
||||
/* server */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "server",
|
||||
0, 0,
|
||||
@@ -2475,10 +2475,10 @@ irc_config_init ()
|
||||
return 0;
|
||||
}
|
||||
irc_config_section_server = ptr_section;
|
||||
|
||||
|
||||
irc_config_hook_config_nick_colors = weechat_hook_config ("weechat.color.chat_nick_colors",
|
||||
&irc_config_change_nick_colors_cb, NULL);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2490,7 +2490,7 @@ int
|
||||
irc_config_read ()
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
||||
rc = weechat_config_read (irc_config_file);
|
||||
if (rc == WEECHAT_CONFIG_READ_OK)
|
||||
{
|
||||
@@ -2511,7 +2511,7 @@ int
|
||||
irc_config_write (int write_temp_servers)
|
||||
{
|
||||
irc_config_write_temp_servers = write_temp_servers;
|
||||
|
||||
|
||||
return weechat_config_write (irc_config_file);
|
||||
}
|
||||
|
||||
@@ -2523,7 +2523,7 @@ void
|
||||
irc_config_free ()
|
||||
{
|
||||
weechat_config_free (irc_config_file);
|
||||
|
||||
|
||||
if (irc_config_hook_config_nick_colors)
|
||||
{
|
||||
weechat_unhook (irc_config_hook_config_nick_colors);
|
||||
@@ -2535,13 +2535,13 @@ irc_config_free ()
|
||||
irc_config_nick_colors = NULL;
|
||||
irc_config_num_nick_colors = 0;
|
||||
}
|
||||
|
||||
|
||||
if (irc_config_hashtable_nick_color_force)
|
||||
{
|
||||
weechat_hashtable_free (irc_config_hashtable_nick_color_force);
|
||||
irc_config_hashtable_nick_color_force = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (irc_config_hashtable_nick_prefixes)
|
||||
{
|
||||
weechat_hashtable_free (irc_config_hashtable_nick_prefixes);
|
||||
|
||||
+78
-78
@@ -59,13 +59,13 @@ const char *
|
||||
irc_ctcp_get_default_reply (const char *ctcp)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; irc_ctcp_default_reply[i].name; i++)
|
||||
{
|
||||
if (weechat_strcasecmp (irc_ctcp_default_reply[i].name, ctcp) == 0)
|
||||
return irc_ctcp_default_reply[i].reply;
|
||||
}
|
||||
|
||||
|
||||
/* unknown CTCP */
|
||||
return NULL;
|
||||
}
|
||||
@@ -81,21 +81,21 @@ irc_ctcp_get_reply (struct t_irc_server *server, const char *ctcp)
|
||||
char option_name[512];
|
||||
|
||||
snprintf (option_name, sizeof (option_name), "%s.%s", server->name, ctcp);
|
||||
|
||||
|
||||
/* search for CTCP in config file, for server */
|
||||
ptr_option = weechat_config_search_option (irc_config_file,
|
||||
irc_config_section_ctcp,
|
||||
option_name);
|
||||
if (ptr_option)
|
||||
return weechat_config_string (ptr_option);
|
||||
|
||||
|
||||
/* search for CTCP in config file */
|
||||
ptr_option = weechat_config_search_option (irc_config_file,
|
||||
irc_config_section_ctcp,
|
||||
ctcp);
|
||||
if (ptr_option)
|
||||
return weechat_config_string (ptr_option);
|
||||
|
||||
|
||||
/*
|
||||
* no CTCP reply found in config, then return default reply, or NULL
|
||||
* for unknown CTCP
|
||||
@@ -119,7 +119,7 @@ irc_ctcp_display_request (struct t_irc_server *server,
|
||||
if (reply && !reply[0]
|
||||
&& !weechat_config_boolean (irc_config_look_display_ctcp_blocked))
|
||||
return;
|
||||
|
||||
|
||||
weechat_printf_tags ((channel) ? channel->buffer : server->buffer,
|
||||
irc_protocol_tags (command, "irc_ctcp", NULL),
|
||||
_("%sCTCP requested by %s%s%s: %s%s%s%s%s%s"),
|
||||
@@ -147,13 +147,13 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
char *pos_end, *pos_space, *pos_args, *pos_usec;
|
||||
struct timeval tv;
|
||||
long sec1, usec1, sec2, usec2, difftime;
|
||||
|
||||
|
||||
while (arguments && arguments[0])
|
||||
{
|
||||
pos_end = strchr (arguments + 1, '\01');
|
||||
if (pos_end)
|
||||
pos_end[0] = '\0';
|
||||
|
||||
|
||||
pos_space = strchr (arguments + 1, ' ');
|
||||
if (pos_space)
|
||||
{
|
||||
@@ -169,16 +169,16 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
if (pos_usec)
|
||||
{
|
||||
pos_usec[0] = '\0';
|
||||
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
sec1 = atol (pos_args);
|
||||
usec1 = atol (pos_usec + 1);
|
||||
sec2 = tv.tv_sec;
|
||||
usec2 = tv.tv_usec;
|
||||
|
||||
|
||||
difftime = ((sec2 * 1000000) + usec2) -
|
||||
((sec1 * 1000000) + usec1);
|
||||
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
irc_protocol_tags (command,
|
||||
"irc_ctcp",
|
||||
@@ -196,7 +196,7 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
(difftime % 1000000) / 1000,
|
||||
(NG_("second", "seconds",
|
||||
(difftime / 1000000))));
|
||||
|
||||
|
||||
pos_usec[0] = ' ';
|
||||
}
|
||||
}
|
||||
@@ -234,10 +234,10 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
"",
|
||||
"");
|
||||
}
|
||||
|
||||
|
||||
if (pos_end)
|
||||
pos_end[0] = '\01';
|
||||
|
||||
|
||||
arguments = (pos_end) ? pos_end + 1 : NULL;
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
|
||||
int number;
|
||||
char hash_key[32];
|
||||
const char *str_args;
|
||||
|
||||
|
||||
hashtable = irc_server_sendf (server,
|
||||
IRC_SERVER_SEND_OUTQ_PRIO_LOW | IRC_SERVER_SEND_RETURN_HASHTABLE,
|
||||
NULL,
|
||||
@@ -265,7 +265,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
|
||||
nick, ctcp,
|
||||
(arguments) ? " " : "",
|
||||
(arguments) ? arguments : "");
|
||||
|
||||
|
||||
if (hashtable)
|
||||
{
|
||||
if (weechat_config_boolean (irc_config_look_display_ctcp_reply))
|
||||
@@ -311,7 +311,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
time_t now;
|
||||
char buf[1024];
|
||||
struct utsname *buf_uname;
|
||||
|
||||
|
||||
/* clientinfo */
|
||||
temp = weechat_string_replace (format, "$clientinfo",
|
||||
"ACTION DCC CLIENTINFO FINGER PING SOURCE "
|
||||
@@ -319,7 +319,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* version */
|
||||
info = weechat_info_get ("version", "");
|
||||
temp = weechat_string_replace (res, "$version", info);
|
||||
@@ -327,7 +327,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* compilation date */
|
||||
info = weechat_info_get ("date", "");
|
||||
temp = weechat_string_replace (res, "$compilation", info);
|
||||
@@ -335,7 +335,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* info about OS */
|
||||
buf_uname = (struct utsname *)malloc (sizeof (struct utsname));
|
||||
if (buf_uname && (uname (buf_uname) >= 0))
|
||||
@@ -350,7 +350,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
return NULL;
|
||||
res = temp;
|
||||
}
|
||||
|
||||
|
||||
/* site */
|
||||
info = weechat_info_get ("weechat_site", "");
|
||||
temp = weechat_string_replace (res, "$site", info);
|
||||
@@ -358,7 +358,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* site (download page) */
|
||||
info = weechat_info_get ("weechat_site_download", "");
|
||||
temp = weechat_string_replace (res, "$download", info);
|
||||
@@ -366,7 +366,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* time */
|
||||
now = time (NULL);
|
||||
snprintf (buf, sizeof (buf), "%s", ctime (&now));
|
||||
@@ -376,7 +376,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* username */
|
||||
temp = weechat_string_replace (res, "$username",
|
||||
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME));
|
||||
@@ -384,7 +384,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* realname */
|
||||
temp = weechat_string_replace (res, "$realname",
|
||||
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME));
|
||||
@@ -392,7 +392,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* return result */
|
||||
return res;
|
||||
}
|
||||
@@ -429,10 +429,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
struct t_infolist *infolist;
|
||||
struct t_infolist_item *item;
|
||||
char charset_modifier[256];
|
||||
|
||||
|
||||
if (!arguments || !arguments[0])
|
||||
return;
|
||||
|
||||
|
||||
if (strncmp (arguments, "SEND ", 5) == 0)
|
||||
{
|
||||
arguments += 5;
|
||||
@@ -441,7 +441,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
arguments++;
|
||||
}
|
||||
dcc_args = strdup (arguments);
|
||||
|
||||
|
||||
if (!dcc_args)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
@@ -451,14 +451,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
IRC_PLUGIN_NAME, "privmsg");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* DCC filename */
|
||||
pos_file = dcc_args;
|
||||
while (pos_file[0] == ' ')
|
||||
{
|
||||
pos_file++;
|
||||
}
|
||||
|
||||
|
||||
/* look for file size */
|
||||
pos_size = strrchr (pos_file, ' ');
|
||||
if (!pos_size)
|
||||
@@ -470,7 +470,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
free (dcc_args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pos = pos_size;
|
||||
pos_size++;
|
||||
while (pos[0] == ' ')
|
||||
@@ -478,7 +478,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* look for DCC port */
|
||||
pos_port = strrchr (pos_file, ' ');
|
||||
if (!pos_port)
|
||||
@@ -490,7 +490,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
free (dcc_args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pos = pos_port;
|
||||
pos_port++;
|
||||
while (pos[0] == ' ')
|
||||
@@ -498,7 +498,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* look for DCC IP address */
|
||||
pos_addr = strrchr (pos_file, ' ');
|
||||
if (!pos_addr)
|
||||
@@ -510,7 +510,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
free (dcc_args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pos = pos_addr;
|
||||
pos_addr++;
|
||||
while (pos[0] == ' ')
|
||||
@@ -518,10 +518,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* remove double quotes around filename */
|
||||
filename = irc_ctcp_dcc_filename_without_quotes (pos_file);
|
||||
|
||||
|
||||
/* add DCC file via xfer plugin */
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
@@ -548,14 +548,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_dcc",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
message);
|
||||
|
||||
|
||||
if (filename)
|
||||
free (filename);
|
||||
|
||||
|
||||
free (dcc_args);
|
||||
}
|
||||
else if (strncmp (arguments, "RESUME ", 7) == 0)
|
||||
@@ -566,7 +566,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
arguments++;
|
||||
}
|
||||
dcc_args = strdup (arguments);
|
||||
|
||||
|
||||
if (!dcc_args)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
@@ -576,14 +576,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
IRC_PLUGIN_NAME, "privmsg");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* DCC filename */
|
||||
pos_file = dcc_args;
|
||||
while (pos_file[0] == ' ')
|
||||
{
|
||||
pos_file++;
|
||||
}
|
||||
|
||||
|
||||
/* look for resume start position */
|
||||
pos_start_resume = strrchr (pos_file, ' ');
|
||||
if (!pos_start_resume)
|
||||
@@ -602,7 +602,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* look for DCC port */
|
||||
pos_port = strrchr (pos_file, ' ');
|
||||
if (!pos_port)
|
||||
@@ -621,10 +621,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* remove double quotes around filename */
|
||||
filename = irc_ctcp_dcc_filename_without_quotes (pos_file);
|
||||
|
||||
|
||||
/* accept resume via xfer plugin */
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
@@ -645,14 +645,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_dcc",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
message);
|
||||
|
||||
|
||||
if (filename)
|
||||
free (filename);
|
||||
|
||||
|
||||
free (dcc_args);
|
||||
}
|
||||
else if (strncmp (arguments, "ACCEPT ", 7) == 0)
|
||||
@@ -663,7 +663,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
arguments++;
|
||||
}
|
||||
dcc_args = strdup (arguments);
|
||||
|
||||
|
||||
if (!dcc_args)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
@@ -673,14 +673,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
"privmsg");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* DCC filename */
|
||||
pos_file = dcc_args;
|
||||
while (pos_file[0] == ' ')
|
||||
{
|
||||
pos_file++;
|
||||
}
|
||||
|
||||
|
||||
/* look for resume start position */
|
||||
pos_start_resume = strrchr (pos_file, ' ');
|
||||
if (!pos_start_resume)
|
||||
@@ -699,7 +699,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* look for DCC port */
|
||||
pos_port = strrchr (pos_file, ' ');
|
||||
if (!pos_port)
|
||||
@@ -718,10 +718,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* remove double quotes around filename */
|
||||
filename = irc_ctcp_dcc_filename_without_quotes (pos_file);
|
||||
|
||||
|
||||
/* resume file via xfer plugin */
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
@@ -742,14 +742,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_dcc",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
message);
|
||||
|
||||
|
||||
if (filename)
|
||||
free (filename);
|
||||
|
||||
|
||||
free (dcc_args);
|
||||
}
|
||||
else if (strncmp (arguments, "CHAT ", 5) == 0)
|
||||
@@ -760,7 +760,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
arguments++;
|
||||
}
|
||||
dcc_args = strdup (arguments);
|
||||
|
||||
|
||||
if (!dcc_args)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
@@ -770,14 +770,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
"privmsg");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* CHAT type */
|
||||
pos_file = dcc_args;
|
||||
while (pos_file[0] == ' ')
|
||||
{
|
||||
pos_file++;
|
||||
}
|
||||
|
||||
|
||||
/* DCC IP address */
|
||||
pos_addr = strchr (pos_file, ' ');
|
||||
if (!pos_addr)
|
||||
@@ -795,7 +795,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
{
|
||||
pos_addr++;
|
||||
}
|
||||
|
||||
|
||||
/* look for DCC port */
|
||||
pos_port = strchr (pos_addr, ' ');
|
||||
if (!pos_port)
|
||||
@@ -813,7 +813,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
{
|
||||
pos_port++;
|
||||
}
|
||||
|
||||
|
||||
if (weechat_strcasecmp (pos_file, "chat") != 0)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
@@ -828,7 +828,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
free (dcc_args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* add DCC chat via xfer plugin */
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
@@ -854,11 +854,11 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_dcc",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
message);
|
||||
|
||||
|
||||
free (dcc_args);
|
||||
}
|
||||
}
|
||||
@@ -879,13 +879,13 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
int nick_is_me;
|
||||
|
||||
|
||||
while (arguments && arguments[0])
|
||||
{
|
||||
pos_end = strrchr (arguments + 1, '\01');
|
||||
if (pos_end)
|
||||
pos_end[0] = '\0';
|
||||
|
||||
|
||||
pos_args = NULL;
|
||||
pos_space = strchr (arguments + 1, ' ');
|
||||
if (pos_space)
|
||||
@@ -897,14 +897,14 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
pos_args++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* CTCP ACTION */
|
||||
if (strcmp (arguments + 1, "ACTION") == 0)
|
||||
{
|
||||
if (channel)
|
||||
{
|
||||
ptr_nick = irc_nick_search (channel, nick);
|
||||
|
||||
|
||||
irc_channel_nick_speaking_add (channel,
|
||||
nick,
|
||||
(pos_args) ?
|
||||
@@ -913,7 +913,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
irc_channel_nick_speaking_time_remove_old (channel);
|
||||
irc_channel_nick_speaking_time_add (channel, nick,
|
||||
time (NULL));
|
||||
|
||||
|
||||
weechat_printf_tags (channel->buffer,
|
||||
irc_protocol_tags (command,
|
||||
"irc_action,notify_message",
|
||||
@@ -948,7 +948,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
{
|
||||
if (!ptr_channel->topic)
|
||||
irc_channel_set_topic (ptr_channel, address);
|
||||
|
||||
|
||||
weechat_printf_tags (ptr_channel->buffer,
|
||||
irc_protocol_tags (command,
|
||||
(nick_is_me) ?
|
||||
@@ -994,7 +994,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
{
|
||||
irc_ctcp_display_request (server, command, channel, nick,
|
||||
arguments + 1, pos_args, reply);
|
||||
|
||||
|
||||
if (reply[0])
|
||||
{
|
||||
decoded_reply = irc_ctcp_replace_variables (server, reply);
|
||||
@@ -1028,17 +1028,17 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_ctcp",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
message);
|
||||
|
||||
|
||||
if (pos_space)
|
||||
pos_space[0] = ' ';
|
||||
|
||||
|
||||
if (pos_end)
|
||||
pos_end[0] = '\01';
|
||||
|
||||
|
||||
arguments = (pos_end) ? pos_end + 1 : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,23 +44,23 @@ irc_debug_signal_debug_dump_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, IRC_PLUGIN_NAME) == 0))
|
||||
{
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
|
||||
|
||||
irc_server_print_log ();
|
||||
irc_ignore_print_log ();
|
||||
irc_redirect_pattern_print_log ();
|
||||
|
||||
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** End of \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ irc_display_hide_password (char *string, int look_for_nickserv)
|
||||
{
|
||||
char *pos_nickserv, *pos, *pos_pwd, *pos_space;
|
||||
int char_size;
|
||||
|
||||
|
||||
pos = string;
|
||||
while (pos)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ irc_display_hide_password (char *string, int look_for_nickserv)
|
||||
{
|
||||
pos_pwd++;
|
||||
}
|
||||
|
||||
|
||||
while (pos_pwd && pos_pwd[0] && (pos_pwd[0] != ' '))
|
||||
{
|
||||
char_size = weechat_utf8_char_size (pos_pwd);
|
||||
@@ -132,7 +132,7 @@ irc_display_away (struct t_irc_server *server, const char *string1,
|
||||
const char *string2)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
|
||||
@@ -46,17 +46,17 @@ int
|
||||
irc_ignore_valid (struct t_irc_ignore *ignore)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
|
||||
if (!ignore)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
if (ptr_ignore == ignore)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* ignore not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -70,12 +70,12 @@ irc_ignore_search (const char *mask, const char *server, const char *channel)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
char any[2] = "*";
|
||||
|
||||
|
||||
if (!server)
|
||||
server = any;
|
||||
if (!channel)
|
||||
channel = any;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
@@ -86,7 +86,7 @@ irc_ignore_search (const char *mask, const char *server, const char *channel)
|
||||
return ptr_ignore;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ignore not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -99,14 +99,14 @@ struct t_irc_ignore *
|
||||
irc_ignore_search_by_number (int number)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
if (ptr_ignore->number == number)
|
||||
return ptr_ignore;
|
||||
}
|
||||
|
||||
|
||||
/* ignore not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -121,14 +121,14 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
|
||||
struct t_irc_ignore *new_ignore;
|
||||
regex_t *regex;
|
||||
char *complete_mask;
|
||||
|
||||
|
||||
if (!mask || !mask[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
complete_mask = malloc (1 + strlen (mask) + 1 + 1);
|
||||
if (!complete_mask)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (mask[0] == '^')
|
||||
strcpy (complete_mask, mask);
|
||||
else
|
||||
@@ -145,14 +145,14 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
|
||||
free (complete_mask);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (regcomp (regex, complete_mask, REG_NOSUB | REG_ICASE) != 0)
|
||||
{
|
||||
free (regex);
|
||||
free (complete_mask);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_ignore = malloc (sizeof (*new_ignore));
|
||||
if (new_ignore)
|
||||
{
|
||||
@@ -161,7 +161,7 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
|
||||
new_ignore->regex_mask = regex;
|
||||
new_ignore->server = (server) ? strdup (server) : strdup ("*");
|
||||
new_ignore->channel = (channel) ? strdup (channel) : strdup ("*");
|
||||
|
||||
|
||||
/* add ignore to ignore list */
|
||||
new_ignore->prev_ignore = last_irc_ignore;
|
||||
if (irc_ignore_list)
|
||||
@@ -171,9 +171,9 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
|
||||
last_irc_ignore = new_ignore;
|
||||
new_ignore->next_ignore = NULL;
|
||||
}
|
||||
|
||||
|
||||
free (complete_mask);
|
||||
|
||||
|
||||
return new_ignore;
|
||||
}
|
||||
|
||||
@@ -190,29 +190,29 @@ irc_ignore_check (struct t_irc_server *server, const char *channel,
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
int server_match, channel_match;
|
||||
|
||||
|
||||
if (!server)
|
||||
return 0;
|
||||
|
||||
|
||||
/*
|
||||
* if nick is the same as server, then we will not ignore
|
||||
* (it is possible when connected to an irc proxy)
|
||||
*/
|
||||
if (nick && server->nick && (strcmp (server->nick, nick) == 0))
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
server_match = 0;
|
||||
channel_match = 0;
|
||||
|
||||
|
||||
if (!server || (strcmp (ptr_ignore->server, "*") == 0))
|
||||
server_match = 1;
|
||||
else
|
||||
server_match = (weechat_strcasecmp (ptr_ignore->server,
|
||||
server->name) == 0);
|
||||
|
||||
|
||||
if (!channel || (strcmp (ptr_ignore->channel, "*") == 0))
|
||||
channel_match = 1;
|
||||
else
|
||||
@@ -228,7 +228,7 @@ irc_ignore_check (struct t_irc_server *server, const char *channel,
|
||||
nick) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (server_match && channel_match)
|
||||
{
|
||||
if (nick && (regexec (ptr_ignore->regex_mask, nick, 0, NULL, 0) == 0))
|
||||
@@ -237,7 +237,7 @@ irc_ignore_check (struct t_irc_server *server, const char *channel,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -249,17 +249,17 @@ void
|
||||
irc_ignore_free (struct t_irc_ignore *ignore)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_ignore_removing",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, ignore);
|
||||
|
||||
|
||||
/* decrement number for all ignore after this one */
|
||||
for (ptr_ignore = ignore->next_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
ptr_ignore->number--;
|
||||
}
|
||||
|
||||
|
||||
/* free data */
|
||||
if (ignore->mask)
|
||||
free (ignore->mask);
|
||||
@@ -272,7 +272,7 @@ irc_ignore_free (struct t_irc_ignore *ignore)
|
||||
free (ignore->server);
|
||||
if (ignore->channel)
|
||||
free (ignore->channel);
|
||||
|
||||
|
||||
/* remove ignore from list */
|
||||
if (ignore->prev_ignore)
|
||||
(ignore->prev_ignore)->next_ignore = ignore->next_ignore;
|
||||
@@ -282,9 +282,9 @@ irc_ignore_free (struct t_irc_ignore *ignore)
|
||||
irc_ignore_list = ignore->next_ignore;
|
||||
if (last_irc_ignore == ignore)
|
||||
last_irc_ignore = ignore->prev_ignore;
|
||||
|
||||
|
||||
free (ignore);
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_ignore_removed",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
@@ -310,10 +310,10 @@ struct t_hdata *
|
||||
irc_ignore_hdata_ignore_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_ignore", "next_ignore");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -340,21 +340,21 @@ irc_ignore_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_ignore *ignore)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !ignore)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "mask", ignore->mask))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "server", ignore->server))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "channel", ignore->channel))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ void
|
||||
irc_ignore_print_log ()
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
|
||||
@@ -56,5 +56,5 @@ extern struct t_hdata *irc_ignore_hdata_ignore_cb (void *data,
|
||||
extern int irc_ignore_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_ignore *ignore);
|
||||
extern void irc_ignore_print_log ();
|
||||
|
||||
|
||||
#endif /* __WEECHAT_IRC_IGNORE_H */
|
||||
|
||||
+24
-24
@@ -74,10 +74,10 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
static char str_true[2] = "1";
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (info_name, "irc_is_channel") == 0)
|
||||
{
|
||||
if (irc_channel_is_channel (arguments))
|
||||
@@ -118,7 +118,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
host = NULL;
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
|
||||
|
||||
pos_comma = strchr (arguments, ',');
|
||||
if (pos_comma)
|
||||
{
|
||||
@@ -140,7 +140,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
else
|
||||
server = strdup (arguments);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* replace channel by nick in host if channel is not a channel
|
||||
* (private ?)
|
||||
@@ -154,10 +154,10 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
nick = irc_message_get_nick_from_host (host);
|
||||
if (nick)
|
||||
channel = strdup (nick);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* search for server or channel buffer */
|
||||
if (server)
|
||||
{
|
||||
@@ -165,14 +165,14 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
if (ptr_server && channel)
|
||||
ptr_channel = irc_channel_search (ptr_server, channel);
|
||||
}
|
||||
|
||||
|
||||
if (server)
|
||||
free (server);
|
||||
if (channel)
|
||||
free (channel);
|
||||
if (host)
|
||||
free (host);
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
irc_info_create_string_with_pointer (&ptr_channel->buffer_as_string,
|
||||
@@ -227,7 +227,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
}
|
||||
return isupport_value;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -243,13 +243,13 @@ irc_info_get_info_hashtable_cb (void *data, const char *info_name,
|
||||
const char *server, *message;
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_hashtable *value;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (info_name, "irc_message_parse") == 0)
|
||||
{
|
||||
message = weechat_hashtable_get (hashtable, "message");
|
||||
@@ -270,7 +270,7 @@ irc_info_get_info_hashtable_cb (void *data, const char *info_name,
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -290,18 +290,18 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
struct t_irc_notify *ptr_notify;
|
||||
char **argv;
|
||||
int argc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "irc_server") == 0)
|
||||
{
|
||||
if (pointer && !irc_server_valid (pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -367,7 +367,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
if (pointer && !irc_channel_valid (ptr_server, pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -441,7 +441,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
if (pointer && !irc_nick_valid (ptr_channel, pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -480,7 +480,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
if (pointer && !irc_ignore_valid (pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -514,7 +514,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
if (pointer && !irc_notify_valid (NULL, pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -553,7 +553,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@ irc_info_init ()
|
||||
N_("value of feature, if supported by server (from IRC message 005)"),
|
||||
N_("server,feature"),
|
||||
&irc_info_get_info_cb, NULL);
|
||||
|
||||
|
||||
/* info_hashtable hooks */
|
||||
weechat_hook_info_hashtable ("irc_message_parse",
|
||||
N_("parse an IRC message"),
|
||||
@@ -622,7 +622,7 @@ irc_info_init ()
|
||||
"messages, "
|
||||
"\"count\": number of messages"),
|
||||
&irc_info_get_info_hashtable_cb, NULL);
|
||||
|
||||
|
||||
/* infolist hooks */
|
||||
weechat_hook_infolist ("irc_server",
|
||||
N_("list of IRC servers"),
|
||||
|
||||
+26
-26
@@ -46,19 +46,19 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
char *text_decoded;
|
||||
|
||||
|
||||
text_decoded = irc_color_decode (text,
|
||||
weechat_config_boolean (irc_config_network_colors_send));
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
ptr_nick = irc_nick_search (ptr_channel, ptr_server->nick);
|
||||
else
|
||||
ptr_nick = NULL;
|
||||
|
||||
|
||||
weechat_printf_tags (buffer,
|
||||
irc_protocol_tags ("privmsg",
|
||||
"notify_none,no_highlight",
|
||||
@@ -70,7 +70,7 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
|
||||
IRC_COLOR_CHAT_NICK_SELF),
|
||||
(text_decoded) ? text_decoded : text);
|
||||
}
|
||||
|
||||
|
||||
if (text_decoded)
|
||||
free (text_decoded);
|
||||
}
|
||||
@@ -89,12 +89,12 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
|
||||
int number;
|
||||
char hash_key[32], *str_args;
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
if (!ptr_server || !ptr_channel || !message || !message[0])
|
||||
return;
|
||||
|
||||
|
||||
if (!ptr_server->is_connected)
|
||||
{
|
||||
weechat_printf (buffer,
|
||||
@@ -132,9 +132,9 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
|
||||
{
|
||||
const char *ptr_data;
|
||||
char *data_with_colors, *msg;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
if (buffer == irc_raw_buffer)
|
||||
{
|
||||
if (weechat_strcasecmp (input_data, "q") == 0)
|
||||
@@ -156,7 +156,7 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
ptr_data = weechat_string_input_for_buffer (input_data);
|
||||
@@ -164,14 +164,14 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
|
||||
ptr_data = input_data;
|
||||
data_with_colors = irc_color_encode (ptr_data,
|
||||
weechat_config_boolean (irc_config_network_colors_send));
|
||||
|
||||
|
||||
msg = strdup ((data_with_colors) ? data_with_colors : ptr_data);
|
||||
if (msg)
|
||||
{
|
||||
irc_input_send_user_message (buffer, flags, NULL, msg);
|
||||
free (msg);
|
||||
}
|
||||
|
||||
|
||||
if (data_with_colors)
|
||||
free (data_with_colors);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
return irc_input_data (buffer, input_data, IRC_SERVER_SEND_OUTQ_PRIO_HIGH);
|
||||
}
|
||||
|
||||
@@ -226,14 +226,14 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
ptr_string = (const char *)signal_data;
|
||||
|
||||
|
||||
server = NULL;
|
||||
channel = NULL;
|
||||
flags = NULL;
|
||||
@@ -241,7 +241,7 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
ptr_message = NULL;
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
|
||||
|
||||
pos_semicol1 = strchr (ptr_string, ';');
|
||||
if (pos_semicol1)
|
||||
{
|
||||
@@ -278,7 +278,7 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
|
||||
if (flags)
|
||||
{
|
||||
@@ -287,7 +287,7 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
if (flags_value < 0)
|
||||
flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
|
||||
}
|
||||
|
||||
|
||||
if (server && ptr_message)
|
||||
{
|
||||
ptr_server = irc_server_search (server);
|
||||
@@ -300,10 +300,10 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
if (ptr_channel)
|
||||
ptr_buffer = ptr_channel->buffer;
|
||||
}
|
||||
|
||||
|
||||
/* set tags to use by default */
|
||||
irc_server_set_send_default_tags (tags);
|
||||
|
||||
|
||||
/* send text to buffer, or execute command */
|
||||
if (weechat_string_input_for_buffer (ptr_message))
|
||||
{
|
||||
@@ -320,12 +320,12 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
if (data_with_colors)
|
||||
free (data_with_colors);
|
||||
}
|
||||
|
||||
|
||||
/* reset tags to use by default */
|
||||
irc_server_set_send_default_tags (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (server)
|
||||
free (server);
|
||||
if (channel)
|
||||
@@ -334,6 +334,6 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
free (flags);
|
||||
if (tags)
|
||||
free (tags);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ irc_message_parse (const char *message, char **nick, char **host,
|
||||
char **command, char **channel, char **arguments)
|
||||
{
|
||||
const char *pos, *pos2, *pos3, *pos4, *pos5;
|
||||
|
||||
|
||||
if (nick)
|
||||
*nick = NULL;
|
||||
if (host)
|
||||
@@ -52,10 +52,10 @@ irc_message_parse (const char *message, char **nick, char **host,
|
||||
*channel = NULL;
|
||||
if (arguments)
|
||||
*arguments = NULL;
|
||||
|
||||
|
||||
if (!message)
|
||||
return;
|
||||
|
||||
|
||||
/*
|
||||
* we will use this message as example:
|
||||
* :FlashCode!n=FlashCod@host.com PRIVMSG #channel :hello!
|
||||
@@ -177,9 +177,9 @@ irc_message_parse_to_hashtable (const char *message)
|
||||
char *nick, *host, *command, *channel, *arguments;
|
||||
char empty_str[1] = { '\0' };
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
|
||||
irc_message_parse (message, &nick, &host, &command, &channel, &arguments);
|
||||
|
||||
|
||||
hashtable = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -187,13 +187,13 @@ irc_message_parse_to_hashtable (const char *message)
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
weechat_hashtable_set (hashtable, "nick", (nick) ? nick : empty_str);
|
||||
weechat_hashtable_set (hashtable, "host", (host) ? host : empty_str);
|
||||
weechat_hashtable_set (hashtable, "command", (command) ? command : empty_str);
|
||||
weechat_hashtable_set (hashtable, "channel", (channel) ? channel : empty_str);
|
||||
weechat_hashtable_set (hashtable, "arguments", (arguments) ? arguments : empty_str);
|
||||
|
||||
|
||||
if (nick)
|
||||
free (nick);
|
||||
if (host)
|
||||
@@ -204,7 +204,7 @@ irc_message_parse_to_hashtable (const char *message)
|
||||
free (channel);
|
||||
if (arguments)
|
||||
free (arguments);
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
@@ -218,10 +218,10 @@ irc_message_get_nick_from_host (const char *host)
|
||||
static char nick[128];
|
||||
char host2[128], *pos_space, *pos;
|
||||
const char *ptr_host;
|
||||
|
||||
|
||||
if (!host)
|
||||
return NULL;
|
||||
|
||||
|
||||
nick[0] = '\0';
|
||||
if (host)
|
||||
{
|
||||
@@ -238,10 +238,10 @@ irc_message_get_nick_from_host (const char *host)
|
||||
snprintf (host2, sizeof (host2), "%s", host);
|
||||
ptr_host = host2;
|
||||
}
|
||||
|
||||
|
||||
if (ptr_host[0] == ':')
|
||||
ptr_host++;
|
||||
|
||||
|
||||
pos = strchr (ptr_host, '!');
|
||||
if (pos && (pos - ptr_host < (int)sizeof (nick)))
|
||||
{
|
||||
@@ -253,7 +253,7 @@ irc_message_get_nick_from_host (const char *host)
|
||||
snprintf (nick, sizeof (nick), "%s", ptr_host);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nick;
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ irc_message_get_address_from_host (const char *host)
|
||||
static char address[256];
|
||||
char host2[256], *pos_space, *pos;
|
||||
const char *ptr_host;
|
||||
|
||||
|
||||
address[0] = '\0';
|
||||
if (host)
|
||||
{
|
||||
@@ -284,7 +284,7 @@ irc_message_get_address_from_host (const char *host)
|
||||
snprintf (host2, sizeof (host2), "%s", host);
|
||||
ptr_host = host2;
|
||||
}
|
||||
|
||||
|
||||
if (ptr_host[0] == ':')
|
||||
ptr_host++;
|
||||
pos = strchr (ptr_host, '!');
|
||||
@@ -293,7 +293,7 @@ irc_message_get_address_from_host (const char *host)
|
||||
else
|
||||
snprintf (address, sizeof (address), "%s", ptr_host);
|
||||
}
|
||||
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
@@ -310,31 +310,31 @@ irc_message_replace_vars (struct t_irc_server *server,
|
||||
char *var_nick, *var_channel, *var_server;
|
||||
char empty_string[1] = { '\0' };
|
||||
char *res, *temp;
|
||||
|
||||
|
||||
var_nick = (server && server->nick) ? server->nick : empty_string;
|
||||
var_channel = (channel) ? channel->name : empty_string;
|
||||
var_server = (server) ? server->name : empty_string;
|
||||
|
||||
|
||||
/* replace nick */
|
||||
temp = weechat_string_replace (string, "$nick", var_nick);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* replace channel */
|
||||
temp = weechat_string_replace (res, "$channel", var_channel);
|
||||
free (res);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* replace server */
|
||||
temp = weechat_string_replace (res, "$server", var_server);
|
||||
free (res);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* return result */
|
||||
return res;
|
||||
}
|
||||
@@ -348,7 +348,7 @@ irc_message_split_add (struct t_hashtable *hashtable, int number,
|
||||
const char *message, const char *arguments)
|
||||
{
|
||||
char key[32], value[32];
|
||||
|
||||
|
||||
if (message)
|
||||
{
|
||||
snprintf (key, sizeof (key), "msg%d", number);
|
||||
@@ -398,7 +398,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
const char *pos, *pos_max, *pos_next, *pos_last_delim;
|
||||
char message[1024], *dup_arguments;
|
||||
int max_length, number;
|
||||
|
||||
|
||||
/*
|
||||
* Examples of arguments for this function:
|
||||
*
|
||||
@@ -420,7 +420,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
* arguments: "is eating"
|
||||
* suffix : "\01"
|
||||
*/
|
||||
|
||||
|
||||
max_length = 510;
|
||||
if (max_length_host >= 0)
|
||||
max_length -= max_length_host;
|
||||
@@ -433,10 +433,10 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
max_length -= strlen (prefix);
|
||||
if (suffix)
|
||||
max_length -= strlen (suffix);
|
||||
|
||||
|
||||
if (max_length < 2)
|
||||
return 0;
|
||||
|
||||
|
||||
/* debug message */
|
||||
if (weechat_irc_plugin->debug >= 2)
|
||||
{
|
||||
@@ -447,9 +447,9 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
host, command, target, prefix, arguments, suffix,
|
||||
max_length);
|
||||
}
|
||||
|
||||
|
||||
number = 1;
|
||||
|
||||
|
||||
if (!arguments || !arguments[0])
|
||||
{
|
||||
snprintf (message, sizeof (message), "%s%s%s %s%s%s%s",
|
||||
@@ -463,7 +463,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
irc_message_split_add (hashtable, 1, message, "");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
while (arguments && arguments[0])
|
||||
{
|
||||
pos = arguments;
|
||||
@@ -498,7 +498,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
}
|
||||
arguments = (pos == pos_last_delim) ? pos + 1 : pos;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -516,14 +516,14 @@ irc_message_split_join (struct t_hashtable *hashtable,
|
||||
int length_to_add, index_channel;
|
||||
char **channels, **keys, *pos, *str;
|
||||
char msg_to_send[2048], keys_to_add[2048];
|
||||
|
||||
|
||||
number = 1;
|
||||
|
||||
|
||||
channels = NULL;
|
||||
channels_count = 0;
|
||||
keys = NULL;
|
||||
keys_count = 0;
|
||||
|
||||
|
||||
pos = strchr (arguments, ' ');
|
||||
if (pos)
|
||||
{
|
||||
@@ -543,7 +543,7 @@ irc_message_split_join (struct t_hashtable *hashtable,
|
||||
{
|
||||
channels = weechat_string_split (arguments, ",", 0, 0, &channels_count);
|
||||
}
|
||||
|
||||
|
||||
snprintf (msg_to_send, sizeof (msg_to_send), "%s%sJOIN",
|
||||
(host) ? host : "",
|
||||
(host) ? " " : "");
|
||||
@@ -589,7 +589,7 @@ irc_message_split_join (struct t_hashtable *hashtable,
|
||||
keys_to_add[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (length > length_no_channel)
|
||||
{
|
||||
strcat (msg_to_send, keys_to_add);
|
||||
@@ -597,12 +597,12 @@ irc_message_split_join (struct t_hashtable *hashtable,
|
||||
msg_to_send,
|
||||
msg_to_send + length_no_channel + 1);
|
||||
}
|
||||
|
||||
|
||||
if (channels)
|
||||
weechat_string_free_split (channels);
|
||||
if (keys)
|
||||
weechat_string_free_split (keys);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable,
|
||||
{
|
||||
char prefix[512], suffix[2], *pos, saved_char;
|
||||
int length, rc;
|
||||
|
||||
|
||||
/*
|
||||
* message sent looks like:
|
||||
* PRIVMSG #channel :hello world!
|
||||
@@ -628,7 +628,7 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable,
|
||||
* when IRC server sends message to other people, message looks like:
|
||||
* :nick!user@host.com PRIVMSG #channel :hello world!
|
||||
*/
|
||||
|
||||
|
||||
/* for CTCP, prefix will be ":\01xxxx " and suffix "\01" */
|
||||
prefix[0] = '\0';
|
||||
suffix[0] = '\0';
|
||||
@@ -652,11 +652,11 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable,
|
||||
}
|
||||
if (!prefix[0])
|
||||
strcpy (prefix, ":");
|
||||
|
||||
|
||||
rc = irc_message_split_string (hashtable, host, command, target,
|
||||
prefix, arguments, suffix,
|
||||
' ', max_length_host);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -670,7 +670,7 @@ irc_message_split_005 (struct t_hashtable *hashtable,
|
||||
char *host, char *command, char *target, char *arguments)
|
||||
{
|
||||
char *pos, suffix[512];
|
||||
|
||||
|
||||
/*
|
||||
* 005 message looks like:
|
||||
* :server 005 mynick MODES=4 CHANLIMIT=#:20 NICKLEN=16 USERLEN=10
|
||||
@@ -678,7 +678,7 @@ irc_message_split_005 (struct t_hashtable *hashtable,
|
||||
* CHANTYPES=# PREFIX=(ov)@+ CASEMAPPING=ascii CAPAB IRCD=dancer
|
||||
* :are available on this server
|
||||
*/
|
||||
|
||||
|
||||
/* search suffix */
|
||||
suffix[0] = '\0';
|
||||
pos = strstr (arguments, " :");
|
||||
@@ -687,7 +687,7 @@ irc_message_split_005 (struct t_hashtable *hashtable,
|
||||
snprintf (suffix, sizeof (suffix), "%s", pos);
|
||||
pos[0] = '\0';
|
||||
}
|
||||
|
||||
|
||||
return irc_message_split_string (hashtable, host, command, target,
|
||||
NULL, arguments, suffix, ' ', -1);
|
||||
}
|
||||
@@ -713,7 +713,7 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
struct t_hashtable *hashtable;
|
||||
char **argv, **argv_eol, *host, *command, *arguments, target[512];
|
||||
int split_ok, argc, index_args, max_length_nick, max_length_host;
|
||||
|
||||
|
||||
split_ok = 0;
|
||||
host = NULL;
|
||||
command = NULL;
|
||||
@@ -721,11 +721,11 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
index_args = 0;
|
||||
argv = NULL;
|
||||
argv_eol = NULL;
|
||||
|
||||
|
||||
/* debug message */
|
||||
if (weechat_irc_plugin->debug >= 2)
|
||||
weechat_printf (NULL, "irc_message_split: message='%s'", message);
|
||||
|
||||
|
||||
hashtable = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -733,16 +733,16 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!message || !message[0])
|
||||
goto end;
|
||||
|
||||
|
||||
argv = weechat_string_split (message, " ", 0, 0, &argc);
|
||||
argv_eol = weechat_string_split (message, " ", 2, 0, NULL);
|
||||
|
||||
|
||||
if (argc < 2)
|
||||
goto end;
|
||||
|
||||
|
||||
if (argv[0][0] == ':')
|
||||
{
|
||||
if (argc < 3)
|
||||
@@ -758,7 +758,7 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
arguments = argv_eol[1];
|
||||
index_args = 1;
|
||||
}
|
||||
|
||||
|
||||
max_length_nick = (server && (server->nick_max_length > 0)) ?
|
||||
server->nick_max_length : 16;
|
||||
max_length_host = 1 + /* ":" */
|
||||
@@ -841,18 +841,18 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (!split_ok
|
||||
|| (weechat_hashtable_get_integer (hashtable, "items_count") == 0))
|
||||
{
|
||||
irc_message_split_add (hashtable, 1, message, arguments);
|
||||
}
|
||||
|
||||
|
||||
if (argv)
|
||||
weechat_string_free_split (argv);
|
||||
if (argv_eol)
|
||||
weechat_string_free_split (argv_eol);
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ irc_mode_channel_set (struct t_irc_server *server,
|
||||
char *pos_args, *str_modes, set_flag, **argv, *pos, *ptr_arg;
|
||||
int modes_count, channel_modes_updated, argc, current_arg;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
if (!server || !channel || !modes)
|
||||
return 0;
|
||||
|
||||
|
||||
channel_modes_updated = 0;
|
||||
|
||||
|
||||
argc = 0;
|
||||
argv = NULL;
|
||||
pos_args = strchr (modes, ' ');
|
||||
@@ -85,7 +85,7 @@ irc_mode_channel_set (struct t_irc_server *server,
|
||||
pos++;
|
||||
}
|
||||
current_arg = argc - modes_count;
|
||||
|
||||
|
||||
if (str_modes && str_modes[0])
|
||||
{
|
||||
set_flag = '+';
|
||||
@@ -158,14 +158,14 @@ irc_mode_channel_set (struct t_irc_server *server,
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (str_modes)
|
||||
free (str_modes);
|
||||
if (argv)
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
|
||||
|
||||
return channel_modes_updated;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
|
||||
|
||||
str_mode[0] = mode;
|
||||
str_mode[1] = '\0';
|
||||
|
||||
|
||||
if (server->nick_modes)
|
||||
{
|
||||
if (!strchr (server->nick_modes, mode))
|
||||
@@ -218,7 +218,7 @@ irc_mode_user_remove (struct t_irc_server *server, char mode)
|
||||
{
|
||||
char *pos, *nick_modes2;
|
||||
int new_size;
|
||||
|
||||
|
||||
if (server->nick_modes)
|
||||
{
|
||||
pos = strchr (server->nick_modes, mode);
|
||||
|
||||
@@ -50,7 +50,7 @@ irc_msgbuffer_get_option (struct t_irc_server *server, const char *message)
|
||||
{
|
||||
snprintf (option_name, sizeof (option_name),
|
||||
"%s.%s", server->name, message);
|
||||
|
||||
|
||||
/* search for msgbuffer in config file, for server */
|
||||
ptr_option = weechat_config_search_option (irc_config_file,
|
||||
irc_config_section_msgbuffer,
|
||||
@@ -58,14 +58,14 @@ irc_msgbuffer_get_option (struct t_irc_server *server, const char *message)
|
||||
if (ptr_option)
|
||||
return ptr_option;
|
||||
}
|
||||
|
||||
|
||||
/* search for msgbuffer in config file */
|
||||
ptr_option = weechat_config_search_option (irc_config_file,
|
||||
irc_config_section_msgbuffer,
|
||||
message);
|
||||
if (ptr_option)
|
||||
return ptr_option;
|
||||
|
||||
|
||||
/* no msgbuffer found in config */
|
||||
return NULL;
|
||||
}
|
||||
@@ -92,18 +92,18 @@ irc_msgbuffer_get_target_buffer (struct t_irc_server *server, const char *nick,
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_weechat_plugin *buffer_plugin;
|
||||
|
||||
|
||||
ptr_option = irc_msgbuffer_get_option (server, message);
|
||||
if (!ptr_option && alias && alias[0])
|
||||
ptr_option = irc_msgbuffer_get_option (server, alias);
|
||||
|
||||
|
||||
if (!ptr_option)
|
||||
{
|
||||
if (default_buffer)
|
||||
return default_buffer;
|
||||
return (server) ? server->buffer : NULL;
|
||||
}
|
||||
|
||||
|
||||
target = weechat_config_integer (ptr_option);
|
||||
switch (target)
|
||||
{
|
||||
@@ -129,11 +129,11 @@ irc_msgbuffer_get_target_buffer (struct t_irc_server *server, const char *nick,
|
||||
return (server) ? server->buffer : NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
ptr_buffer = weechat_current_buffer ();
|
||||
buffer_plugin = weechat_buffer_get_pointer (ptr_buffer, "plugin");
|
||||
if (buffer_plugin == weechat_irc_plugin)
|
||||
return ptr_buffer;
|
||||
|
||||
|
||||
return (server) ? server->buffer : NULL;
|
||||
}
|
||||
|
||||
+92
-92
@@ -47,16 +47,16 @@ int
|
||||
irc_nick_valid (struct t_irc_channel *channel, struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
if (!channel)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
if (ptr_nick == nick)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* nick not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -71,22 +71,22 @@ int
|
||||
irc_nick_is_nick (const char *string)
|
||||
{
|
||||
const char *ptr;
|
||||
|
||||
|
||||
if (!string || !string[0])
|
||||
return 0;
|
||||
|
||||
|
||||
/* first char must not be a number or hyphen */
|
||||
ptr = string;
|
||||
if (strchr ("0123456789-", *ptr))
|
||||
return 0;
|
||||
|
||||
|
||||
while (ptr && ptr[0])
|
||||
{
|
||||
if (!strchr (IRC_NICK_VALID_CHARS, *ptr))
|
||||
return 0;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ irc_nick_strdup_for_color (const char *nickname)
|
||||
{
|
||||
int char_size, other_char_seen;
|
||||
char *result, *pos, utf_char[16];
|
||||
|
||||
|
||||
result = malloc (strlen (nickname) + 1);
|
||||
pos = result;
|
||||
other_char_seen = 0;
|
||||
@@ -109,7 +109,7 @@ irc_nick_strdup_for_color (const char *nickname)
|
||||
char_size = weechat_utf8_char_size (nickname);
|
||||
memcpy (utf_char, nickname, char_size);
|
||||
utf_char[char_size] = '\0';
|
||||
|
||||
|
||||
if (strstr (weechat_config_string (irc_config_look_nick_color_stop_chars),
|
||||
utf_char))
|
||||
{
|
||||
@@ -125,7 +125,7 @@ irc_nick_strdup_for_color (const char *nickname)
|
||||
}
|
||||
memcpy (pos, utf_char, char_size);
|
||||
pos += char_size;
|
||||
|
||||
|
||||
nickname += char_size;
|
||||
}
|
||||
pos[0] = '\0';
|
||||
@@ -141,13 +141,13 @@ irc_nick_hash_color (const char *nickname)
|
||||
{
|
||||
int color;
|
||||
const char *ptr_nick;
|
||||
|
||||
|
||||
if (!irc_config_nick_colors)
|
||||
irc_config_set_nick_colors ();
|
||||
|
||||
|
||||
if (irc_config_num_nick_colors == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
color = 0;
|
||||
ptr_nick = nickname;
|
||||
while (ptr_nick && ptr_nick[0])
|
||||
@@ -155,7 +155,7 @@ irc_nick_hash_color (const char *nickname)
|
||||
color += weechat_utf8_char_int (ptr_nick);
|
||||
ptr_nick = weechat_utf8_next_char (ptr_nick);
|
||||
}
|
||||
|
||||
|
||||
return (color % irc_config_num_nick_colors);
|
||||
}
|
||||
|
||||
@@ -170,15 +170,15 @@ irc_nick_find_color (const char *nickname)
|
||||
int color;
|
||||
char *nickname2;
|
||||
const char *forced_color, *str_color;
|
||||
|
||||
|
||||
if (!irc_config_nick_colors)
|
||||
irc_config_set_nick_colors ();
|
||||
|
||||
|
||||
if (irc_config_num_nick_colors == 0)
|
||||
return weechat_color ("default");
|
||||
|
||||
|
||||
nickname2 = irc_nick_strdup_for_color (nickname);
|
||||
|
||||
|
||||
/* look if color is forced */
|
||||
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
|
||||
(nickname2) ? nickname2 : nickname);
|
||||
@@ -192,12 +192,12 @@ irc_nick_find_color (const char *nickname)
|
||||
return forced_color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* hash nickname to get color */
|
||||
color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname);
|
||||
if (nickname2)
|
||||
free (nickname2);
|
||||
|
||||
|
||||
/* return color */
|
||||
str_color = weechat_color (irc_config_nick_colors[color]);
|
||||
return (str_color[0]) ? str_color : weechat_color("default");
|
||||
@@ -215,15 +215,15 @@ irc_nick_find_color_name (const char *nickname)
|
||||
char *nickname2;
|
||||
const char *forced_color;
|
||||
static char *default_color = "default";
|
||||
|
||||
|
||||
if (!irc_config_nick_colors)
|
||||
irc_config_set_nick_colors ();
|
||||
|
||||
|
||||
if (irc_config_num_nick_colors == 0)
|
||||
return default_color;
|
||||
|
||||
|
||||
nickname2 = irc_nick_strdup_for_color (nickname);
|
||||
|
||||
|
||||
/* look if color is forced */
|
||||
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
|
||||
(nickname2) ? nickname2 : nickname);
|
||||
@@ -233,12 +233,12 @@ irc_nick_find_color_name (const char *nickname)
|
||||
free (nickname2);
|
||||
return forced_color;
|
||||
}
|
||||
|
||||
|
||||
/* hash nickname to get color */
|
||||
color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname);
|
||||
if (nickname2)
|
||||
free (nickname2);
|
||||
|
||||
|
||||
/* return color name */
|
||||
return irc_config_nick_colors[color];
|
||||
}
|
||||
@@ -252,7 +252,7 @@ void
|
||||
irc_nick_set_current_prefix (struct t_irc_nick *nick)
|
||||
{
|
||||
char *ptr_prefixes;
|
||||
|
||||
|
||||
nick->prefix[0] = ' ';
|
||||
for (ptr_prefixes = nick->prefixes; ptr_prefixes[0]; ptr_prefixes++)
|
||||
{
|
||||
@@ -275,7 +275,7 @@ irc_nick_set_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
int set, char prefix)
|
||||
{
|
||||
int index;
|
||||
|
||||
|
||||
index = irc_server_get_prefix_char_index (server, prefix);
|
||||
if (index >= 0)
|
||||
{
|
||||
@@ -293,10 +293,10 @@ irc_nick_set_prefixes (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
const char *prefixes)
|
||||
{
|
||||
const char *ptr_prefixes;
|
||||
|
||||
|
||||
/* reset all prefixes in nick */
|
||||
memset (nick->prefixes, ' ', strlen (nick->prefixes));
|
||||
|
||||
|
||||
/* add prefixes in nick */
|
||||
if (prefixes)
|
||||
{
|
||||
@@ -305,7 +305,7 @@ irc_nick_set_prefixes (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
irc_nick_set_prefix (server, nick, 1, ptr_prefixes[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* set current prefix */
|
||||
irc_nick_set_current_prefix (nick);
|
||||
}
|
||||
@@ -319,14 +319,14 @@ int
|
||||
irc_nick_is_op (struct t_irc_server *server, struct t_irc_nick *nick)
|
||||
{
|
||||
int index;
|
||||
|
||||
|
||||
if (nick->prefix[0] == ' ')
|
||||
return 0;
|
||||
|
||||
|
||||
index = irc_server_get_prefix_char_index (server, nick->prefix[0]);
|
||||
if (index < 0)
|
||||
return 0;
|
||||
|
||||
|
||||
return (index <= irc_server_get_prefix_mode_index (server, 'o')) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -342,11 +342,11 @@ irc_nick_has_prefix_mode (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
char prefix_mode)
|
||||
{
|
||||
char prefix_char;
|
||||
|
||||
|
||||
prefix_char = irc_server_get_prefix_char_for_mode (server, prefix_mode);
|
||||
if (prefix_char == ' ')
|
||||
return 0;
|
||||
|
||||
|
||||
return (strchr (nick->prefixes, prefix_char)) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -363,10 +363,10 @@ irc_nick_get_nicklist_group (struct t_irc_server *server,
|
||||
char str_group[2];
|
||||
const char *prefix_modes;
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
|
||||
|
||||
if (!server || !buffer || !nick)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_group = NULL;
|
||||
index = irc_server_get_prefix_char_index (server, nick->prefix[0]);
|
||||
if (index < 0)
|
||||
@@ -381,7 +381,7 @@ irc_nick_get_nicklist_group (struct t_irc_server *server,
|
||||
str_group[1] = '\0';
|
||||
ptr_group = weechat_nicklist_search_group (buffer, NULL, str_group);
|
||||
}
|
||||
|
||||
|
||||
return ptr_group;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ irc_nick_get_prefix_color_name (struct t_irc_server *server,
|
||||
const char *prefix_modes, *color;
|
||||
char mode[2];
|
||||
int i, index;
|
||||
|
||||
|
||||
if (irc_config_hashtable_nick_prefixes)
|
||||
{
|
||||
index = irc_server_get_prefix_char_index (server, nick->prefix[0]);
|
||||
@@ -425,7 +425,7 @@ irc_nick_get_prefix_color_name (struct t_irc_server *server,
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* no color by default */
|
||||
return default_color;
|
||||
}
|
||||
@@ -441,10 +441,10 @@ irc_nick_get_color_for_nicklist (struct t_irc_server *server,
|
||||
static char *nick_color_bar_fg = "bar_fg";
|
||||
static char *nick_color_self = "weechat.color.chat_nick_self";
|
||||
static char *nick_color_away = "weechat.color.nicklist_away";
|
||||
|
||||
|
||||
if (nick->away)
|
||||
return nick_color_away;
|
||||
|
||||
|
||||
if (weechat_config_boolean(irc_config_look_color_nicks_in_nicklist))
|
||||
{
|
||||
if (weechat_strcasecmp (nick->name, server->nick) == 0)
|
||||
@@ -452,7 +452,7 @@ irc_nick_get_color_for_nicklist (struct t_irc_server *server,
|
||||
else
|
||||
return irc_nick_find_color_name (nick->name);
|
||||
}
|
||||
|
||||
|
||||
return nick_color_bar_fg;
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ irc_nick_nicklist_add (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
|
||||
|
||||
ptr_group = irc_nick_get_nicklist_group (server, channel->buffer, nick);
|
||||
weechat_nicklist_add_nick (channel->buffer, ptr_group,
|
||||
nick->name,
|
||||
@@ -486,7 +486,7 @@ irc_nick_nicklist_remove (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
|
||||
|
||||
ptr_group = irc_nick_get_nicklist_group (server, channel->buffer, nick);
|
||||
weechat_nicklist_remove_nick (channel->buffer,
|
||||
weechat_nicklist_search_nick (channel->buffer,
|
||||
@@ -523,7 +523,7 @@ irc_nick_nicklist_set_prefix_color_all ()
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -552,7 +552,7 @@ irc_nick_nicklist_set_color_all ()
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -580,28 +580,28 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
{
|
||||
struct t_irc_nick *new_nick, *ptr_nick;
|
||||
int length;
|
||||
|
||||
|
||||
/* nick already exists on this channel? */
|
||||
ptr_nick = irc_nick_search (channel, nickname);
|
||||
if (ptr_nick)
|
||||
{
|
||||
/* remove old nick from nicklist */
|
||||
irc_nick_nicklist_remove (server, channel, ptr_nick);
|
||||
|
||||
|
||||
/* update nick */
|
||||
irc_nick_set_prefixes (server, ptr_nick, prefixes);
|
||||
ptr_nick->away = away;
|
||||
|
||||
|
||||
/* add new nick in nicklist */
|
||||
irc_nick_nicklist_add (server, channel, ptr_nick);
|
||||
|
||||
|
||||
return ptr_nick;
|
||||
}
|
||||
|
||||
|
||||
/* alloc memory for new nick */
|
||||
if ((new_nick = malloc (sizeof (*new_nick))) == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* initialize new nick */
|
||||
new_nick->name = strdup (nickname);
|
||||
new_nick->host = NULL;
|
||||
@@ -620,7 +620,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
new_nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF);
|
||||
else
|
||||
new_nick->color = strdup (irc_nick_find_color (new_nick->name));
|
||||
|
||||
|
||||
/* add nick to end of list */
|
||||
new_nick->prev_nick = channel->last_nick;
|
||||
if (channel->nicks)
|
||||
@@ -629,14 +629,14 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
channel->nicks = new_nick;
|
||||
channel->last_nick = new_nick;
|
||||
new_nick->next_nick = NULL;
|
||||
|
||||
|
||||
channel->nicks_count++;
|
||||
|
||||
|
||||
channel->nick_completion_reset = 1;
|
||||
|
||||
|
||||
/* add nick to buffer nicklist */
|
||||
irc_nick_nicklist_add (server, channel, new_nick);
|
||||
|
||||
|
||||
/* all is ok, return address of new nick */
|
||||
return new_nick;
|
||||
}
|
||||
@@ -650,15 +650,15 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
struct t_irc_nick *nick, const char *new_nick)
|
||||
{
|
||||
int nick_is_me;
|
||||
|
||||
|
||||
/* remove nick from nicklist */
|
||||
irc_nick_nicklist_remove (server, channel, nick);
|
||||
|
||||
|
||||
/* update nicks speaking */
|
||||
nick_is_me = (strcmp (nick->name, server->nick) == 0) ? 1 : 0;
|
||||
if (!nick_is_me)
|
||||
irc_channel_nick_speaking_rename (channel, nick->name, new_nick);
|
||||
|
||||
|
||||
/* change nickname */
|
||||
if (nick->name)
|
||||
free (nick->name);
|
||||
@@ -669,7 +669,7 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF);
|
||||
else
|
||||
nick->color = strdup (irc_nick_find_color (nick->name));
|
||||
|
||||
|
||||
/* add nick in nicklist */
|
||||
irc_nick_nicklist_add (server, channel, nick);
|
||||
}
|
||||
@@ -684,21 +684,21 @@ irc_nick_set_mode (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
{
|
||||
int index;
|
||||
const char *prefix_chars;
|
||||
|
||||
|
||||
index = irc_server_get_prefix_mode_index (server, mode);
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
|
||||
/* remove nick from nicklist */
|
||||
irc_nick_nicklist_remove (server, channel, nick);
|
||||
|
||||
|
||||
/* set flag */
|
||||
prefix_chars = irc_server_get_prefix_chars (server);
|
||||
irc_nick_set_prefix (server, nick, set, prefix_chars[index]);
|
||||
|
||||
|
||||
/* add nick in nicklist */
|
||||
irc_nick_nicklist_add (server, channel, nick);
|
||||
|
||||
|
||||
if (strcmp (nick->name, server->nick) == 0)
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
@@ -712,13 +712,13 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_irc_nick *new_nicks;
|
||||
|
||||
|
||||
if (!channel || !nick)
|
||||
return;
|
||||
|
||||
|
||||
/* remove nick from nicklist */
|
||||
irc_nick_nicklist_remove (server, channel, nick);
|
||||
|
||||
|
||||
/* remove nick */
|
||||
if (channel->last_nick == nick)
|
||||
channel->last_nick = nick->prev_nick;
|
||||
@@ -729,12 +729,12 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
}
|
||||
else
|
||||
new_nicks = nick->next_nick;
|
||||
|
||||
|
||||
if (nick->next_nick)
|
||||
(nick->next_nick)->prev_nick = nick->prev_nick;
|
||||
|
||||
|
||||
channel->nicks_count--;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (nick->name)
|
||||
free (nick->name);
|
||||
@@ -744,9 +744,9 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
free (nick->prefixes);
|
||||
if (nick->color)
|
||||
free (nick->color);
|
||||
|
||||
|
||||
free (nick);
|
||||
|
||||
|
||||
channel->nicks = new_nicks;
|
||||
channel->nick_completion_reset = 1;
|
||||
}
|
||||
@@ -760,13 +760,13 @@ irc_nick_free_all (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
{
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
|
||||
/* remove all nicks for the channel */
|
||||
while (channel->nicks)
|
||||
{
|
||||
irc_nick_free (server, channel, channel->nicks);
|
||||
}
|
||||
|
||||
|
||||
/* sould be zero, but prevent any bug :D */
|
||||
channel->nicks_count = 0;
|
||||
}
|
||||
@@ -779,17 +779,17 @@ struct t_irc_nick *
|
||||
irc_nick_search (struct t_irc_channel *channel, const char *nickname)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
if (!channel || !nickname)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_nick = channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
if (weechat_strcasecmp (ptr_nick->name, nickname) == 0)
|
||||
return ptr_nick;
|
||||
}
|
||||
|
||||
|
||||
/* nick not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -804,7 +804,7 @@ irc_nick_count (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
int *count_normal)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
(*total) = 0;
|
||||
(*count_op) = 0;
|
||||
(*count_halfop) = 0;
|
||||
@@ -865,7 +865,7 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
static char result[256];
|
||||
char prefix[2];
|
||||
const char *str_prefix_color;
|
||||
|
||||
|
||||
prefix[0] = (nick) ? nick->prefix[0] : '\0';
|
||||
prefix[1] = '\0';
|
||||
if (weechat_config_boolean (weechat_config_get ("weechat.look.nickmode")))
|
||||
@@ -889,7 +889,7 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
prefix[0] = '\0';
|
||||
str_prefix_color = IRC_COLOR_RESET;
|
||||
}
|
||||
|
||||
|
||||
snprintf (result, sizeof (result), "%s%s%s%s%s%s%s%s\t",
|
||||
(weechat_config_string (irc_config_look_nick_prefix)
|
||||
&& weechat_config_string (irc_config_look_nick_prefix)[0]) ?
|
||||
@@ -907,7 +907,7 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
(weechat_config_string (irc_config_look_nick_suffix)
|
||||
&& weechat_config_string (irc_config_look_nick_suffix)[0]) ?
|
||||
weechat_config_string (irc_config_look_nick_suffix) : "");
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -925,7 +925,7 @@ irc_nick_color_for_pv (struct t_irc_channel *channel, const char *nickname)
|
||||
if (channel->pv_remote_nick_color)
|
||||
return channel->pv_remote_nick_color;
|
||||
}
|
||||
|
||||
|
||||
return IRC_COLOR_CHAT_NICK_OTHER;
|
||||
}
|
||||
|
||||
@@ -937,10 +937,10 @@ struct t_hdata *
|
||||
irc_nick_hdata_nick_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -966,14 +966,14 @@ irc_nick_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !nick)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "name", nick->name))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "host", nick->host))
|
||||
@@ -986,7 +986,7 @@ irc_nick_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "color", nick->color))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ irc_notify_valid (struct t_irc_server *server, struct t_irc_notify *notify)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_notify *ptr_notify;
|
||||
|
||||
|
||||
if (!notify)
|
||||
return 0;
|
||||
|
||||
@@ -82,7 +82,7 @@ irc_notify_valid (struct t_irc_server *server, struct t_irc_notify *notify)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* notify not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -95,17 +95,17 @@ struct t_irc_notify *
|
||||
irc_notify_search (struct t_irc_server *server, const char *nick)
|
||||
{
|
||||
struct t_irc_notify *ptr_notify;
|
||||
|
||||
|
||||
if (!server || !nick)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_notify = server->notify_list; ptr_notify;
|
||||
ptr_notify = ptr_notify->next_notify)
|
||||
{
|
||||
if (strcmp (ptr_notify->nick, nick) == 0)
|
||||
return ptr_notify;
|
||||
}
|
||||
|
||||
|
||||
/* notify not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ irc_notify_set_server_option (struct t_irc_server *server)
|
||||
char *str, *str2;
|
||||
struct t_irc_notify *ptr_notify;
|
||||
int total_length, length;
|
||||
|
||||
|
||||
if (!server)
|
||||
return;
|
||||
|
||||
@@ -183,10 +183,10 @@ struct t_irc_notify *
|
||||
irc_notify_new (struct t_irc_server *server, const char *nick, int check_away)
|
||||
{
|
||||
struct t_irc_notify *new_notify;
|
||||
|
||||
|
||||
if (!server || !nick || !nick[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
new_notify = malloc (sizeof (*new_notify));
|
||||
if (new_notify)
|
||||
{
|
||||
@@ -196,7 +196,7 @@ irc_notify_new (struct t_irc_server *server, const char *nick, int check_away)
|
||||
new_notify->is_on_server = 0;
|
||||
new_notify->away_message = NULL;
|
||||
new_notify->ison_received = 0;
|
||||
|
||||
|
||||
/* add notify to notify list on server */
|
||||
new_notify->prev_notify = server->last_notify;
|
||||
if (server->notify_list)
|
||||
@@ -206,7 +206,7 @@ irc_notify_new (struct t_irc_server *server, const char *nick, int check_away)
|
||||
server->last_notify = new_notify;
|
||||
new_notify->next_notify = NULL;
|
||||
}
|
||||
|
||||
|
||||
return new_notify;
|
||||
}
|
||||
|
||||
@@ -221,14 +221,14 @@ irc_notify_new_for_server (struct t_irc_server *server)
|
||||
const char *notify;
|
||||
char **items, *pos_params, **params;
|
||||
int i, j, num_items, num_params, check_away;
|
||||
|
||||
|
||||
irc_notify_free_all (server);
|
||||
|
||||
|
||||
notify = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NOTIFY);
|
||||
|
||||
|
||||
if (!notify || !notify[0])
|
||||
return;
|
||||
|
||||
|
||||
items = weechat_string_split (notify, ",", 0, 0, &num_items);
|
||||
|
||||
if (items)
|
||||
@@ -272,7 +272,7 @@ void
|
||||
irc_notify_new_for_all_servers ()
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -289,13 +289,13 @@ irc_notify_free (struct t_irc_server *server, struct t_irc_notify *notify)
|
||||
{
|
||||
weechat_hook_signal_send ("irc_notify_removing",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, notify);
|
||||
|
||||
|
||||
/* free data */
|
||||
if (notify->nick)
|
||||
free (notify->nick);
|
||||
if (notify->away_message)
|
||||
free (notify->away_message);
|
||||
|
||||
|
||||
/* remove notify from list */
|
||||
if (notify->prev_notify)
|
||||
(notify->prev_notify)->next_notify = notify->next_notify;
|
||||
@@ -305,9 +305,9 @@ irc_notify_free (struct t_irc_server *server, struct t_irc_notify *notify)
|
||||
server->notify_list = notify->next_notify;
|
||||
if (server->last_notify == notify)
|
||||
server->last_notify = notify->prev_notify;
|
||||
|
||||
|
||||
free (notify);
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_notify_removed",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
@@ -436,13 +436,13 @@ irc_notify_get_tags (struct t_config_option *option)
|
||||
{
|
||||
static char string[1024];
|
||||
const char *tags;
|
||||
|
||||
|
||||
tags = weechat_config_string (option);
|
||||
|
||||
|
||||
snprintf (string, sizeof (string), "irc_notify%s%s",
|
||||
(tags && tags[0]) ? "," : "",
|
||||
(tags && tags[0]) ? tags : "");
|
||||
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -457,11 +457,11 @@ irc_notify_set_is_on_server (struct t_irc_notify *notify,
|
||||
{
|
||||
if (!notify)
|
||||
return;
|
||||
|
||||
|
||||
/* same status, then do nothing */
|
||||
if (notify->is_on_server == is_on_server)
|
||||
return;
|
||||
|
||||
|
||||
notify->is_on_server = is_on_server;
|
||||
|
||||
weechat_printf_tags (notify->server->buffer,
|
||||
@@ -489,13 +489,13 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
|
||||
{
|
||||
if (!notify)
|
||||
return;
|
||||
|
||||
|
||||
/* same away message, then do nothing */
|
||||
if ((!notify->away_message && !away_message)
|
||||
|| (notify->away_message && away_message
|
||||
&& (strcmp (notify->away_message, away_message) == 0)))
|
||||
return;
|
||||
|
||||
|
||||
if (!notify->away_message && away_message)
|
||||
{
|
||||
weechat_printf_tags (notify->server->buffer,
|
||||
@@ -528,7 +528,7 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
|
||||
IRC_COLOR_RESET,
|
||||
away_message);
|
||||
}
|
||||
|
||||
|
||||
if (notify->away_message)
|
||||
free (notify->away_message);
|
||||
notify->away_message = (away_message) ? strdup (away_message) : NULL;
|
||||
@@ -550,30 +550,30 @@ irc_notify_hsignal_cb (void *data, const char *signal,
|
||||
int away_message_updated, no_such_nick;
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_notify *ptr_notify;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
|
||||
error = weechat_hashtable_get (hashtable, "error");
|
||||
server = weechat_hashtable_get (hashtable, "server");
|
||||
pattern = weechat_hashtable_get (hashtable, "pattern");
|
||||
command = weechat_hashtable_get (hashtable, "command");
|
||||
output = weechat_hashtable_get (hashtable, "output");
|
||||
|
||||
|
||||
/* if there is an error on redirection, just ignore result */
|
||||
if (error && error[0])
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
/* missing things in redirection */
|
||||
if (!server || !pattern || !command || !output)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
/* search server */
|
||||
ptr_server = irc_server_search (server);
|
||||
if (!ptr_server)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
/* search for start of arguments in command sent to server */
|
||||
ptr_args = strchr (command, ' ');
|
||||
if (!ptr_args)
|
||||
@@ -585,7 +585,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
|
||||
}
|
||||
if (!ptr_args[0])
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
/* read output of command */
|
||||
if (strcmp (pattern, "ison") == 0)
|
||||
{
|
||||
@@ -663,7 +663,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
|
||||
irc_notify_set_is_on_server (ptr_notify, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
weechat_string_free_split (messages);
|
||||
}
|
||||
@@ -716,7 +716,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -733,11 +733,11 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_notify *ptr_notify, *ptr_next_notify;
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -746,16 +746,16 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
|
||||
message = malloc (7);
|
||||
if (!message)
|
||||
continue;
|
||||
|
||||
|
||||
snprintf (message, 7, "ISON :");
|
||||
total_length = 7;
|
||||
nicks_added = 0;
|
||||
|
||||
|
||||
ptr_notify = ptr_server->notify_list;
|
||||
while (ptr_notify)
|
||||
{
|
||||
ptr_next_notify = ptr_notify->next_notify;
|
||||
|
||||
|
||||
length = strlen (ptr_notify->nick);
|
||||
total_length += length + 1;
|
||||
message2 = realloc (message, total_length);
|
||||
@@ -771,10 +771,10 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
|
||||
strcat (message, " ");
|
||||
strcat (message, ptr_notify->nick);
|
||||
nicks_added++;
|
||||
|
||||
|
||||
ptr_notify = ptr_next_notify;
|
||||
}
|
||||
|
||||
|
||||
if (message && (nicks_added > 0))
|
||||
{
|
||||
hashtable = irc_message_split (ptr_server, message);
|
||||
@@ -798,12 +798,12 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
|
||||
weechat_hashtable_free (hashtable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (message)
|
||||
free (message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -816,11 +816,11 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_notify *ptr_notify, *ptr_next_notify;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -830,7 +830,7 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
|
||||
while (ptr_notify)
|
||||
{
|
||||
ptr_next_notify = ptr_notify->next_notify;
|
||||
|
||||
|
||||
if (ptr_notify->check_away)
|
||||
{
|
||||
/*
|
||||
@@ -844,12 +844,12 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
|
||||
IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
|
||||
"WHOIS :%s", ptr_notify->nick);
|
||||
}
|
||||
|
||||
|
||||
ptr_notify = ptr_next_notify;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -861,10 +861,10 @@ struct t_hdata *
|
||||
irc_notify_hdata_notify_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_notify", "next_notify");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -890,10 +890,10 @@ irc_notify_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_notify *notify)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !notify)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
@@ -910,7 +910,7 @@ irc_notify_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "away_message", notify->away_message))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -922,7 +922,7 @@ void
|
||||
irc_notify_print_log (struct t_irc_server *server)
|
||||
{
|
||||
struct t_irc_notify *ptr_notify;
|
||||
|
||||
|
||||
for (ptr_notify = server->notify_list; ptr_notify;
|
||||
ptr_notify = ptr_notify->next_notify)
|
||||
{
|
||||
@@ -948,7 +948,7 @@ irc_notify_hook_timer_ison ()
|
||||
{
|
||||
if (irc_notify_timer_ison)
|
||||
weechat_unhook (irc_notify_timer_ison);
|
||||
|
||||
|
||||
irc_notify_timer_ison = weechat_hook_timer (
|
||||
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_ison),
|
||||
0, 0, &irc_notify_timer_ison_cb, NULL);
|
||||
@@ -963,7 +963,7 @@ irc_notify_hook_timer_whois ()
|
||||
{
|
||||
if (irc_notify_timer_whois)
|
||||
weechat_unhook (irc_notify_timer_whois);
|
||||
|
||||
|
||||
irc_notify_timer_whois = weechat_hook_timer (
|
||||
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_whois),
|
||||
0, 0, &irc_notify_timer_whois_cb, NULL);
|
||||
@@ -978,7 +978,7 @@ irc_notify_init ()
|
||||
{
|
||||
irc_notify_hook_timer_ison ();
|
||||
irc_notify_hook_timer_whois ();
|
||||
|
||||
|
||||
irc_notify_hsignal = weechat_hook_hsignal ("irc_redirection_notify_*",
|
||||
&irc_notify_hsignal_cb,
|
||||
NULL);
|
||||
|
||||
@@ -64,5 +64,5 @@ extern void irc_notify_hook_timer_ison ();
|
||||
extern void irc_notify_hook_timer_whois ();
|
||||
extern void irc_notify_init ();
|
||||
extern void irc_notify_end ();
|
||||
|
||||
|
||||
#endif /* __WEECHAT_IRC_NOTIFY_H */
|
||||
|
||||
+384
-384
File diff suppressed because it is too large
Load Diff
+30
-30
@@ -67,7 +67,7 @@ void
|
||||
irc_raw_open (int switch_to_buffer)
|
||||
{
|
||||
struct t_irc_raw_message *ptr_raw_message;
|
||||
|
||||
|
||||
if (!irc_raw_buffer)
|
||||
{
|
||||
irc_raw_buffer = weechat_buffer_search (IRC_PLUGIN_NAME,
|
||||
@@ -77,14 +77,14 @@ irc_raw_open (int switch_to_buffer)
|
||||
irc_raw_buffer = weechat_buffer_new (IRC_RAW_BUFFER_NAME,
|
||||
&irc_input_data_cb, NULL,
|
||||
&irc_buffer_close_cb, NULL);
|
||||
|
||||
|
||||
/* failed to create buffer ? then return */
|
||||
if (!irc_raw_buffer)
|
||||
return;
|
||||
|
||||
|
||||
weechat_buffer_set (irc_raw_buffer,
|
||||
"title", _("IRC raw messages"));
|
||||
|
||||
|
||||
if (!weechat_buffer_get_integer (irc_raw_buffer, "short_name_is_set"))
|
||||
{
|
||||
weechat_buffer_set (irc_raw_buffer, "short_name",
|
||||
@@ -94,7 +94,7 @@ irc_raw_open (int switch_to_buffer)
|
||||
weechat_buffer_set (irc_raw_buffer, "localvar_set_server", IRC_RAW_BUFFER_NAME);
|
||||
weechat_buffer_set (irc_raw_buffer, "localvar_set_channel", IRC_RAW_BUFFER_NAME);
|
||||
weechat_buffer_set (irc_raw_buffer, "localvar_set_no_log", "1");
|
||||
|
||||
|
||||
/* disable all highlights on this buffer */
|
||||
weechat_buffer_set (irc_raw_buffer, "highlight_words", "-");
|
||||
|
||||
@@ -106,7 +106,7 @@ irc_raw_open (int switch_to_buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (irc_raw_buffer && switch_to_buffer)
|
||||
weechat_buffer_set (irc_raw_buffer, "display", "1");
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void
|
||||
irc_raw_message_free (struct t_irc_raw_message *raw_message)
|
||||
{
|
||||
struct t_irc_raw_message *new_raw_messages;
|
||||
|
||||
|
||||
/* remove message from raw messages list */
|
||||
if (last_irc_raw_message == raw_message)
|
||||
last_irc_raw_message = raw_message->prev_message;
|
||||
@@ -130,20 +130,20 @@ irc_raw_message_free (struct t_irc_raw_message *raw_message)
|
||||
}
|
||||
else
|
||||
new_raw_messages = raw_message->next_message;
|
||||
|
||||
|
||||
if (raw_message->next_message)
|
||||
(raw_message->next_message)->prev_message = raw_message->prev_message;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (raw_message->prefix)
|
||||
free (raw_message->prefix);
|
||||
if (raw_message->message)
|
||||
free (raw_message->message);
|
||||
|
||||
|
||||
free (raw_message);
|
||||
|
||||
|
||||
irc_raw_messages = new_raw_messages;
|
||||
|
||||
|
||||
irc_raw_messages_count--;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ void
|
||||
irc_raw_message_remove_old ()
|
||||
{
|
||||
int max_messages;
|
||||
|
||||
|
||||
max_messages = weechat_config_integer (irc_config_look_raw_messages);
|
||||
while (irc_raw_messages && (irc_raw_messages_count >= max_messages))
|
||||
{
|
||||
@@ -185,19 +185,19 @@ irc_raw_message_add_to_list (time_t date, const char *prefix,
|
||||
const char *message)
|
||||
{
|
||||
struct t_irc_raw_message *new_raw_message;
|
||||
|
||||
|
||||
if (!prefix || !message)
|
||||
return NULL;
|
||||
|
||||
|
||||
irc_raw_message_remove_old ();
|
||||
|
||||
|
||||
new_raw_message = malloc (sizeof (*new_raw_message));
|
||||
if (new_raw_message)
|
||||
{
|
||||
new_raw_message->date = date;
|
||||
new_raw_message->prefix = strdup (prefix);
|
||||
new_raw_message->message = strdup (message);
|
||||
|
||||
|
||||
/* add message to list */
|
||||
new_raw_message->prev_message = last_irc_raw_message;
|
||||
new_raw_message->next_message = NULL;
|
||||
@@ -206,10 +206,10 @@ irc_raw_message_add_to_list (time_t date, const char *prefix,
|
||||
else
|
||||
irc_raw_messages = new_raw_message;
|
||||
last_irc_raw_message = new_raw_message;
|
||||
|
||||
|
||||
irc_raw_messages_count++;
|
||||
}
|
||||
|
||||
|
||||
return new_raw_message;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ irc_raw_message_add (struct t_irc_server *server, int flags,
|
||||
const char *hexa = "0123456789ABCDEF";
|
||||
int pos_buf, pos_buf2, char_size, i;
|
||||
struct t_irc_raw_message *new_raw_message;
|
||||
|
||||
|
||||
buf = weechat_iconv_to_internal (NULL, message);
|
||||
buf2 = malloc ((strlen (buf) * 3) + 1);
|
||||
if (buf2)
|
||||
@@ -282,7 +282,7 @@ irc_raw_message_add (struct t_irc_server *server, int flags,
|
||||
strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
snprintf (prefix, sizeof (prefix), "%s%s%s%s%s",
|
||||
(server) ? weechat_color ("chat_server") : "",
|
||||
(server) ? server->name : "",
|
||||
@@ -291,16 +291,16 @@ irc_raw_message_add (struct t_irc_server *server, int flags,
|
||||
weechat_color ("chat_prefix_quit") :
|
||||
weechat_color ("chat_prefix_join"),
|
||||
prefix_arrow);
|
||||
|
||||
|
||||
new_raw_message = irc_raw_message_add_to_list (time (NULL),
|
||||
prefix,
|
||||
(buf2) ? buf2 : ((buf) ? buf : message));
|
||||
|
||||
|
||||
if (buf)
|
||||
free (buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
|
||||
|
||||
return new_raw_message;
|
||||
}
|
||||
|
||||
@@ -313,14 +313,14 @@ irc_raw_print (struct t_irc_server *server, int flags,
|
||||
const char *message)
|
||||
{
|
||||
struct t_irc_raw_message *new_raw_message;
|
||||
|
||||
|
||||
if (!message)
|
||||
return;
|
||||
|
||||
/* auto-open IRC raw buffer if debug for irc plugin is >= 1 */
|
||||
if (!irc_raw_buffer && (weechat_irc_plugin->debug >= 1))
|
||||
irc_raw_open (0);
|
||||
|
||||
|
||||
new_raw_message = irc_raw_message_add (server, flags, message);
|
||||
if (new_raw_message)
|
||||
{
|
||||
@@ -341,20 +341,20 @@ irc_raw_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_raw_message *raw_message)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !raw_message)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_time (ptr_item, "date", raw_message->date))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "prefix", raw_message->prefix))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "message", raw_message->message))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -249,17 +249,17 @@ struct t_irc_redirect_pattern *
|
||||
irc_redirect_pattern_search (const char *name)
|
||||
{
|
||||
struct t_irc_redirect_pattern *ptr_redirect_pattern;
|
||||
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_redirect_pattern = irc_redirect_patterns; ptr_redirect_pattern;
|
||||
ptr_redirect_pattern = ptr_redirect_pattern->next_redirect)
|
||||
{
|
||||
if (strcmp (ptr_redirect_pattern->name, name) == 0)
|
||||
return ptr_redirect_pattern;
|
||||
}
|
||||
|
||||
|
||||
/* redirect pattern not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -274,10 +274,10 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
|
||||
const char *cmd_extra)
|
||||
{
|
||||
struct t_irc_redirect_pattern *ptr_redirect_pattern, *new_redirect_pattern;
|
||||
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!cmd_stop || !cmd_stop[0])
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -286,7 +286,7 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
|
||||
"cmd_stop");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* check if redirect pattern already exists */
|
||||
ptr_redirect_pattern = irc_redirect_pattern_search (name);
|
||||
if (ptr_redirect_pattern)
|
||||
@@ -297,11 +297,11 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
|
||||
name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_redirect_pattern = malloc (sizeof (*new_redirect_pattern));
|
||||
if (!new_redirect_pattern)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* initialize new redirect */
|
||||
new_redirect_pattern->name = strdup (name);
|
||||
new_redirect_pattern->temp_pattern = temp_pattern;
|
||||
@@ -309,7 +309,7 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
|
||||
new_redirect_pattern->cmd_start = (cmd_start) ? strdup (cmd_start) : NULL;
|
||||
new_redirect_pattern->cmd_stop = strdup (cmd_stop);
|
||||
new_redirect_pattern->cmd_extra = (cmd_extra) ? strdup (cmd_extra) : NULL;
|
||||
|
||||
|
||||
/* add redirect pattern to end of list */
|
||||
new_redirect_pattern->prev_redirect = last_irc_redirect_pattern;
|
||||
if (irc_redirect_patterns)
|
||||
@@ -318,7 +318,7 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
|
||||
irc_redirect_patterns = new_redirect_pattern;
|
||||
last_irc_redirect_pattern = new_redirect_pattern;
|
||||
new_redirect_pattern->next_redirect = NULL;
|
||||
|
||||
|
||||
return new_redirect_pattern;
|
||||
}
|
||||
|
||||
@@ -330,10 +330,10 @@ void
|
||||
irc_redirect_pattern_free (struct t_irc_redirect_pattern *redirect_pattern)
|
||||
{
|
||||
struct t_irc_redirect_pattern *new_redirect_patterns;
|
||||
|
||||
|
||||
if (!redirect_pattern)
|
||||
return;
|
||||
|
||||
|
||||
/* remove redirect */
|
||||
if (last_irc_redirect_pattern == redirect_pattern)
|
||||
last_irc_redirect_pattern = redirect_pattern->prev_redirect;
|
||||
@@ -344,10 +344,10 @@ irc_redirect_pattern_free (struct t_irc_redirect_pattern *redirect_pattern)
|
||||
}
|
||||
else
|
||||
new_redirect_patterns = redirect_pattern->next_redirect;
|
||||
|
||||
|
||||
if (redirect_pattern->next_redirect)
|
||||
(redirect_pattern->next_redirect)->prev_redirect = redirect_pattern->prev_redirect;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (redirect_pattern->name)
|
||||
free (redirect_pattern->name);
|
||||
@@ -357,9 +357,9 @@ irc_redirect_pattern_free (struct t_irc_redirect_pattern *redirect_pattern)
|
||||
free (redirect_pattern->cmd_stop);
|
||||
if (redirect_pattern->cmd_extra)
|
||||
free (redirect_pattern->cmd_extra);
|
||||
|
||||
|
||||
free (redirect_pattern);
|
||||
|
||||
|
||||
irc_redirect_patterns = new_redirect_patterns;
|
||||
}
|
||||
|
||||
@@ -396,11 +396,11 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
int i, j, num_items[4];
|
||||
long value;
|
||||
struct t_hashtable *hash_cmd[4];
|
||||
|
||||
|
||||
new_redirect = malloc (sizeof (*new_redirect));
|
||||
if (!new_redirect)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* create hashtables with commands */
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -448,7 +448,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
weechat_string_free_split (items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* initialize new redirect */
|
||||
new_redirect->server = server;
|
||||
new_redirect->pattern = strdup (pattern);
|
||||
@@ -467,7 +467,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
new_redirect->cmd_filter = hash_cmd[3];
|
||||
new_redirect->output = NULL;
|
||||
new_redirect->output_size = 0;
|
||||
|
||||
|
||||
/* add redirect to end of list */
|
||||
new_redirect->prev_redirect = server->last_redirect;
|
||||
if (server->redirects)
|
||||
@@ -476,7 +476,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
server->redirects = new_redirect;
|
||||
server->last_redirect = new_redirect;
|
||||
new_redirect->next_redirect = NULL;
|
||||
|
||||
|
||||
return new_redirect;
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ irc_redirect_new (struct t_irc_server *server,
|
||||
{
|
||||
struct t_irc_redirect_pattern *ptr_redirect_pattern;
|
||||
struct t_irc_redirect *new_redirect;
|
||||
|
||||
|
||||
if (!server->is_connected)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -501,7 +501,7 @@ irc_redirect_new (struct t_irc_server *server,
|
||||
server->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!pattern || !pattern[0])
|
||||
{
|
||||
weechat_printf (NULL, _("%s%s: missing argument \"%s\" for redirect"),
|
||||
@@ -514,7 +514,7 @@ irc_redirect_new (struct t_irc_server *server,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME, "signal");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ptr_redirect_pattern = irc_redirect_pattern_search (pattern);
|
||||
if (!ptr_redirect_pattern)
|
||||
{
|
||||
@@ -523,7 +523,7 @@ irc_redirect_new (struct t_irc_server *server,
|
||||
pattern);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_redirect = irc_redirect_new_with_commands (server, pattern, signal,
|
||||
count, string,
|
||||
(timeout > 0) ? timeout : ptr_redirect_pattern->timeout,
|
||||
@@ -531,14 +531,14 @@ irc_redirect_new (struct t_irc_server *server,
|
||||
ptr_redirect_pattern->cmd_stop,
|
||||
ptr_redirect_pattern->cmd_extra,
|
||||
cmd_filter);
|
||||
|
||||
|
||||
/*
|
||||
* remove redirect pattern if it is temporary (created by external
|
||||
* plugin/script)
|
||||
*/
|
||||
if (new_redirect && ptr_redirect_pattern->temp_pattern)
|
||||
irc_redirect_pattern_free (ptr_redirect_pattern);
|
||||
|
||||
|
||||
return new_redirect;
|
||||
}
|
||||
|
||||
@@ -550,17 +550,17 @@ struct t_irc_redirect *
|
||||
irc_redirect_search_available (struct t_irc_server *server)
|
||||
{
|
||||
struct t_irc_redirect *ptr_redirect;
|
||||
|
||||
|
||||
if (!server)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_redirect = server->redirects; ptr_redirect;
|
||||
ptr_redirect = ptr_redirect->next_redirect)
|
||||
{
|
||||
if (ptr_redirect->start_time == 0)
|
||||
return ptr_redirect;
|
||||
}
|
||||
|
||||
|
||||
/* no redirect available */
|
||||
return NULL;
|
||||
}
|
||||
@@ -575,10 +575,10 @@ irc_redirect_init_command (struct t_irc_redirect *redirect,
|
||||
const char *command)
|
||||
{
|
||||
char *pos;
|
||||
|
||||
|
||||
if (!redirect)
|
||||
return;
|
||||
|
||||
|
||||
if (command)
|
||||
{
|
||||
pos = strchr (command, '\r');
|
||||
@@ -591,9 +591,9 @@ irc_redirect_init_command (struct t_irc_redirect *redirect,
|
||||
}
|
||||
else
|
||||
redirect->command = NULL;
|
||||
|
||||
|
||||
redirect->start_time = time (NULL);
|
||||
|
||||
|
||||
if (weechat_irc_plugin->debug >= 2)
|
||||
{
|
||||
weechat_printf (redirect->server->buffer,
|
||||
@@ -618,11 +618,11 @@ irc_redirect_message_match_hash (struct t_irc_redirect *redirect,
|
||||
struct t_hashtable *cmd_hash)
|
||||
{
|
||||
int *value;
|
||||
|
||||
|
||||
value = weechat_hashtable_get (cmd_hash, command);
|
||||
if (!value)
|
||||
return 0;
|
||||
|
||||
|
||||
/*
|
||||
* if string is in redirect and that this command requires string to
|
||||
* be in message, then search for this string
|
||||
@@ -631,11 +631,11 @@ irc_redirect_message_match_hash (struct t_irc_redirect *redirect,
|
||||
{
|
||||
if (!arguments_argv || (*value >= arguments_argc))
|
||||
return 0;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (arguments_argv[*value], redirect->string) != 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -648,7 +648,7 @@ irc_redirect_message_add (struct t_irc_redirect *redirect, const char *message,
|
||||
const char *command)
|
||||
{
|
||||
char *output2;
|
||||
|
||||
|
||||
/*
|
||||
* if command is not for output, then don't add message
|
||||
* (it is silently ignored)
|
||||
@@ -656,7 +656,7 @@ irc_redirect_message_add (struct t_irc_redirect *redirect, const char *message,
|
||||
if (redirect->cmd_filter
|
||||
&& !weechat_hashtable_has_key (redirect->cmd_filter, command))
|
||||
return;
|
||||
|
||||
|
||||
/* add message to output */
|
||||
if (redirect->output)
|
||||
{
|
||||
@@ -716,21 +716,21 @@ irc_redirect_stop (struct t_irc_redirect *redirect, const char *error)
|
||||
(redirect->output) ? redirect->output : "");
|
||||
snprintf (str_int, sizeof (str_int), "%d", redirect->output_size);
|
||||
weechat_hashtable_set (hashtable, "output_size", str_int);
|
||||
|
||||
|
||||
/* set some other fields with values from redirect */
|
||||
weechat_hashtable_set (hashtable, "server", redirect->server->name);
|
||||
weechat_hashtable_set (hashtable, "pattern", redirect->pattern);
|
||||
weechat_hashtable_set (hashtable, "signal", redirect->signal);
|
||||
weechat_hashtable_set (hashtable, "command", redirect->command);
|
||||
}
|
||||
|
||||
|
||||
snprintf (signal_name, sizeof (signal_name), "irc_redirection_%s_%s",
|
||||
redirect->signal, redirect->pattern);
|
||||
weechat_hook_hsignal_send (signal_name, hashtable);
|
||||
|
||||
|
||||
if (hashtable)
|
||||
weechat_hashtable_free (hashtable);
|
||||
|
||||
|
||||
irc_redirect_free (redirect);
|
||||
}
|
||||
else
|
||||
@@ -760,10 +760,10 @@ irc_redirect_message (struct t_irc_server *server, const char *message,
|
||||
struct t_irc_redirect *ptr_redirect, *ptr_next_redirect;
|
||||
int rc, match_stop, arguments_argc;
|
||||
char **arguments_argv;
|
||||
|
||||
|
||||
if (!server || !server->redirects || !message || !command)
|
||||
return 0;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
if (arguments && arguments[0])
|
||||
@@ -776,12 +776,12 @@ irc_redirect_message (struct t_irc_server *server, const char *message,
|
||||
arguments_argv = NULL;
|
||||
arguments_argc = 0;
|
||||
}
|
||||
|
||||
|
||||
ptr_redirect = server->redirects;
|
||||
while (ptr_redirect)
|
||||
{
|
||||
ptr_next_redirect = ptr_redirect->next_redirect;
|
||||
|
||||
|
||||
if (ptr_redirect->start_time > 0)
|
||||
{
|
||||
if (ptr_redirect->cmd_stop_received)
|
||||
@@ -870,14 +870,14 @@ irc_redirect_message (struct t_irc_server *server, const char *message,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_redirect = ptr_next_redirect;
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (arguments_argv)
|
||||
weechat_string_free_split (arguments_argv);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -892,12 +892,12 @@ irc_redirect_free (struct t_irc_redirect *redirect)
|
||||
struct t_irc_redirect *new_redirects;
|
||||
int priority;
|
||||
struct t_irc_outqueue *ptr_outqueue;
|
||||
|
||||
|
||||
if (!redirect)
|
||||
return;
|
||||
|
||||
|
||||
server = redirect->server;
|
||||
|
||||
|
||||
/* remove redirect */
|
||||
if (server->last_redirect == redirect)
|
||||
server->last_redirect = redirect->prev_redirect;
|
||||
@@ -908,10 +908,10 @@ irc_redirect_free (struct t_irc_redirect *redirect)
|
||||
}
|
||||
else
|
||||
new_redirects = redirect->next_redirect;
|
||||
|
||||
|
||||
if (redirect->next_redirect)
|
||||
(redirect->next_redirect)->prev_redirect = redirect->prev_redirect;
|
||||
|
||||
|
||||
/* remove any pointer to this redirect */
|
||||
for (priority = 0; priority < IRC_SERVER_NUM_OUTQUEUES_PRIO; priority++)
|
||||
{
|
||||
@@ -922,7 +922,7 @@ irc_redirect_free (struct t_irc_redirect *redirect)
|
||||
ptr_outqueue->redirect = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* free data */
|
||||
if (redirect->pattern)
|
||||
free (redirect->pattern);
|
||||
@@ -942,9 +942,9 @@ irc_redirect_free (struct t_irc_redirect *redirect)
|
||||
weechat_hashtable_free (redirect->cmd_filter);
|
||||
if (redirect->output)
|
||||
free (redirect->output);
|
||||
|
||||
|
||||
free (redirect);
|
||||
|
||||
|
||||
server->redirects = new_redirects;
|
||||
}
|
||||
|
||||
@@ -969,10 +969,10 @@ struct t_hdata *
|
||||
irc_redirect_hdata_redirect_pattern_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -998,10 +998,10 @@ struct t_hdata *
|
||||
irc_redirect_hdata_redirect_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1038,14 +1038,14 @@ irc_redirect_pattern_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_redirect_pattern *redirect_pattern)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !redirect_pattern)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "name", redirect_pattern->name))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "temp_pattern", redirect_pattern->temp_pattern))
|
||||
@@ -1058,7 +1058,7 @@ irc_redirect_pattern_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "cmd_extra", redirect_pattern->cmd_extra))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1072,14 +1072,14 @@ irc_redirect_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_redirect *redirect)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !redirect)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_pointer (ptr_item, "server", redirect->server))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "server_name", redirect->server->name))
|
||||
@@ -1116,7 +1116,7 @@ irc_redirect_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "output_size", redirect->output_size))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1129,7 +1129,7 @@ void
|
||||
irc_redirect_pattern_print_log ()
|
||||
{
|
||||
struct t_irc_redirect_pattern *ptr_redirect_pattern;
|
||||
|
||||
|
||||
for (ptr_redirect_pattern = irc_redirect_patterns; ptr_redirect_pattern;
|
||||
ptr_redirect_pattern = ptr_redirect_pattern->next_redirect)
|
||||
{
|
||||
@@ -1154,7 +1154,7 @@ void
|
||||
irc_redirect_print_log (struct t_irc_server *server)
|
||||
{
|
||||
struct t_irc_redirect *ptr_redirect;
|
||||
|
||||
|
||||
for (ptr_redirect = server->redirects; ptr_redirect;
|
||||
ptr_redirect = ptr_redirect->next_redirect)
|
||||
{
|
||||
@@ -1205,20 +1205,20 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
|
||||
const char *pattern, *str_timeout, *cmd_start, *cmd_stop, *cmd_extra;
|
||||
char *error;
|
||||
int number, timeout;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
|
||||
if (!hashtable)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
pattern = weechat_hashtable_get (hashtable, "pattern");
|
||||
str_timeout = weechat_hashtable_get (hashtable, "timeout");
|
||||
cmd_start = weechat_hashtable_get (hashtable, "cmd_start");
|
||||
cmd_stop = weechat_hashtable_get (hashtable, "cmd_stop");
|
||||
cmd_extra = weechat_hashtable_get (hashtable, "cmd_extra");
|
||||
|
||||
|
||||
if (!pattern || !pattern[0])
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1236,7 +1236,7 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME, "cmd_stop");
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
timeout = 0;
|
||||
if (str_timeout && str_timeout[0])
|
||||
{
|
||||
@@ -1244,14 +1244,14 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
|
||||
if (error && !error[0])
|
||||
timeout = number;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* create a temporary redirect pattern (it will be removed when a
|
||||
* redirect will use it)
|
||||
*/
|
||||
irc_redirect_pattern_new (pattern, 1, timeout,
|
||||
cmd_start, cmd_stop, cmd_extra);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1271,14 +1271,14 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
|
||||
char *error;
|
||||
struct t_irc_server *ptr_server;
|
||||
int number, count, timeout;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
|
||||
if (!hashtable)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
server = weechat_hashtable_get (hashtable, "server");
|
||||
pattern = weechat_hashtable_get (hashtable, "pattern");
|
||||
redirect_signal = weechat_hashtable_get (hashtable, "signal");
|
||||
@@ -1286,7 +1286,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
|
||||
string = weechat_hashtable_get (hashtable, "string");
|
||||
str_timeout = weechat_hashtable_get (hashtable, "timeout");
|
||||
cmd_filter = weechat_hashtable_get (hashtable, "cmd_filter");
|
||||
|
||||
|
||||
if (!server || !server[0])
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1302,7 +1302,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME, server);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
count = 1;
|
||||
if (str_count && str_count[0])
|
||||
{
|
||||
@@ -1310,7 +1310,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
|
||||
if (error && !error[0])
|
||||
count = number;
|
||||
}
|
||||
|
||||
|
||||
timeout = 0;
|
||||
if (str_timeout && str_timeout[0])
|
||||
{
|
||||
@@ -1318,10 +1318,10 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
|
||||
if (error && !error[0])
|
||||
timeout = number;
|
||||
}
|
||||
|
||||
|
||||
irc_redirect_new (ptr_server, pattern, redirect_signal,
|
||||
count, string, timeout, cmd_filter);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
+19
-19
@@ -51,7 +51,7 @@ irc_sasl_mechanism_plain (const char *sasl_username, const char *sasl_password)
|
||||
{
|
||||
char *string, *answer_base64;
|
||||
int length_username, length;
|
||||
|
||||
|
||||
answer_base64 = NULL;
|
||||
length_username = strlen (sasl_username);
|
||||
length = ((length_username + 1) * 2) + strlen (sasl_password) + 1;
|
||||
@@ -62,14 +62,14 @@ irc_sasl_mechanism_plain (const char *sasl_username, const char *sasl_password)
|
||||
sasl_username, sasl_username, sasl_password);
|
||||
string[length_username] = '\0';
|
||||
string[(length_username * 2) + 1] = '\0';
|
||||
|
||||
|
||||
answer_base64 = malloc (length * 4);
|
||||
if (answer_base64)
|
||||
weechat_string_encode_base64 (string, length - 1, answer_base64);
|
||||
|
||||
|
||||
free (string);
|
||||
}
|
||||
|
||||
|
||||
return answer_base64;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
gcry_mpi_t data_prime_number, data_generator_number, data_server_pub_key;
|
||||
gcry_mpi_t pub_key, priv_key, secret_mpi;
|
||||
gcry_cipher_hd_t gcrypt_handle;
|
||||
|
||||
|
||||
data = NULL;
|
||||
secret_bin = NULL;
|
||||
public_bin = NULL;
|
||||
@@ -109,12 +109,12 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
password_crypted = NULL;
|
||||
answer = NULL;
|
||||
answer_base64 = NULL;
|
||||
|
||||
|
||||
/* decode data */
|
||||
data = malloc (strlen (data_base64) + 1);
|
||||
length_data = weechat_string_decode_base64 (data_base64, data);
|
||||
ptr_data = (unsigned char *)data;
|
||||
|
||||
|
||||
/* extract prime number */
|
||||
size = ntohs ((((unsigned int)ptr_data[1]) << 8) | ptr_data[0]);
|
||||
ptr_data += 2;
|
||||
@@ -126,7 +126,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
num_bits_prime_number = gcry_mpi_get_nbits (data_prime_number);
|
||||
ptr_data += size;
|
||||
length_data -= size;
|
||||
|
||||
|
||||
/* extract generator number */
|
||||
size = ntohs ((((unsigned int)ptr_data[1]) << 8) | ptr_data[0]);
|
||||
ptr_data += 2;
|
||||
@@ -137,7 +137,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
gcry_mpi_scan (&data_generator_number, GCRYMPI_FMT_USG, ptr_data, size, NULL);
|
||||
ptr_data += size;
|
||||
length_data -= size;
|
||||
|
||||
|
||||
/* extract server-generated public key */
|
||||
size = ntohs ((((unsigned int)ptr_data[1]) << 8) | ptr_data[0]);
|
||||
ptr_data += 2;
|
||||
@@ -146,14 +146,14 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
goto end;
|
||||
data_server_pub_key = gcry_mpi_new (size * 8);
|
||||
gcry_mpi_scan (&data_server_pub_key, GCRYMPI_FMT_USG, ptr_data, size, NULL);
|
||||
|
||||
|
||||
/* generate keys */
|
||||
pub_key = gcry_mpi_new (num_bits_prime_number);
|
||||
priv_key = gcry_mpi_new (num_bits_prime_number);
|
||||
gcry_mpi_randomize (priv_key, num_bits_prime_number, GCRY_STRONG_RANDOM);
|
||||
/* pub_key = (g ^ priv_key) % p */
|
||||
gcry_mpi_powm (pub_key, data_generator_number, priv_key, data_prime_number);
|
||||
|
||||
|
||||
/* compute secret_bin */
|
||||
length_key = num_bits_prime_number / 8;
|
||||
secret_bin = malloc (length_key);
|
||||
@@ -162,12 +162,12 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
gcry_mpi_powm (secret_mpi, data_server_pub_key, priv_key, data_prime_number);
|
||||
gcry_mpi_print (GCRYMPI_FMT_USG, secret_bin, length_key,
|
||||
&num_written, secret_mpi);
|
||||
|
||||
|
||||
/* create public_bin */
|
||||
public_bin = malloc (length_key);
|
||||
gcry_mpi_print (GCRYMPI_FMT_USG, public_bin, length_key,
|
||||
&num_written, pub_key);
|
||||
|
||||
|
||||
/* create password buffers (clear and crypted) */
|
||||
length_password = strlen (sasl_password) +
|
||||
((8 - (strlen (sasl_password) % 8)) % 8);
|
||||
@@ -176,7 +176,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
memset (password_clear, 0, length_password);
|
||||
memset (password_crypted, 0, length_password);
|
||||
memcpy (password_clear, sasl_password, strlen (sasl_password));
|
||||
|
||||
|
||||
/* crypt password using blowfish */
|
||||
if (gcry_cipher_open (&gcrypt_handle, GCRY_CIPHER_BLOWFISH,
|
||||
GCRY_CIPHER_MODE_ECB, 0) != 0)
|
||||
@@ -187,7 +187,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
password_crypted, length_password,
|
||||
password_clear, length_password) != 0)
|
||||
goto end;
|
||||
|
||||
|
||||
/*
|
||||
* build answer for server, it is concatenation of:
|
||||
* 1. key length (2 bytes)
|
||||
@@ -206,12 +206,12 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
memcpy (ptr_answer, sasl_username, length_username + 1);
|
||||
ptr_answer += length_username + 1;
|
||||
memcpy (ptr_answer, password_crypted, length_password);
|
||||
|
||||
|
||||
/* encode answer to base64 */
|
||||
answer_base64 = malloc (length_answer * 4);
|
||||
if (answer_base64)
|
||||
weechat_string_encode_base64 (answer, length_answer, answer_base64);
|
||||
|
||||
|
||||
end:
|
||||
if (data)
|
||||
free (data);
|
||||
@@ -225,14 +225,14 @@ end:
|
||||
free (password_crypted);
|
||||
if (answer)
|
||||
free (answer);
|
||||
|
||||
|
||||
return answer_base64;
|
||||
#else
|
||||
/* make C compiler happy */
|
||||
(void) data_base64;
|
||||
(void) sasl_username;
|
||||
(void) sasl_password;
|
||||
|
||||
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
+280
-280
File diff suppressed because it is too large
Load Diff
@@ -121,7 +121,7 @@ struct t_irc_server
|
||||
/* user choices */
|
||||
char *name; /* internal name of server */
|
||||
struct t_config_option *options[IRC_SERVER_NUM_OPTIONS];
|
||||
|
||||
|
||||
/* internal vars */
|
||||
int temp_server; /* temporary server (not saved) */
|
||||
int reloading_from_config; /* 1 if reloading from config file */
|
||||
|
||||
@@ -59,7 +59,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
|
||||
struct t_irc_notify *ptr_notify;
|
||||
struct t_irc_raw_message *ptr_raw_message;
|
||||
int rc;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -78,7 +78,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
|
||||
weechat_infolist_free (infolist);
|
||||
if (!rc)
|
||||
return 0;
|
||||
|
||||
|
||||
/* save server channels and nicks */
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
@@ -98,7 +98,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
|
||||
weechat_infolist_free (infolist);
|
||||
if (!rc)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_nick = ptr_channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* save server redirects */
|
||||
for (ptr_redirect = ptr_server->redirects; ptr_redirect;
|
||||
ptr_redirect = ptr_redirect->next_redirect)
|
||||
@@ -139,7 +139,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
|
||||
if (!rc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* save server notify list */
|
||||
for (ptr_notify = ptr_server->notify_list; ptr_notify;
|
||||
ptr_notify = ptr_notify->next_notify)
|
||||
@@ -160,7 +160,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* save raw messages */
|
||||
for (ptr_raw_message = irc_raw_messages; ptr_raw_message;
|
||||
ptr_raw_message = ptr_raw_message->next_message)
|
||||
@@ -180,7 +180,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
|
||||
if (!rc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* save redirect patterns */
|
||||
for (ptr_redirect_pattern = irc_redirect_patterns; ptr_redirect_pattern;
|
||||
ptr_redirect_pattern = ptr_redirect_pattern->next_redirect)
|
||||
@@ -204,7 +204,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -218,15 +218,15 @@ irc_upgrade_save ()
|
||||
{
|
||||
int rc;
|
||||
struct t_upgrade_file *upgrade_file;
|
||||
|
||||
|
||||
upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME, 1);
|
||||
if (!upgrade_file)
|
||||
return 0;
|
||||
|
||||
|
||||
rc = irc_upgrade_save_all_data (upgrade_file);
|
||||
|
||||
|
||||
weechat_upgrade_close (upgrade_file);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ irc_upgrade_set_buffer_callbacks ()
|
||||
{
|
||||
struct t_infolist *infolist;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
infolist = weechat_infolist_get ("buffer", NULL, NULL);
|
||||
if (infolist)
|
||||
{
|
||||
@@ -279,11 +279,11 @@ irc_upgrade_read_cb (void *data,
|
||||
struct t_irc_redirect *ptr_redirect;
|
||||
struct t_irc_notify *ptr_notify;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) upgrade_file;
|
||||
|
||||
|
||||
weechat_infolist_reset_item_cursor (infolist);
|
||||
while (weechat_infolist_next (infolist))
|
||||
{
|
||||
@@ -603,7 +603,7 @@ irc_upgrade_read_cb (void *data,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -619,10 +619,10 @@ irc_upgrade_load ()
|
||||
struct t_upgrade_file *upgrade_file;
|
||||
|
||||
irc_upgrade_set_buffer_callbacks ();
|
||||
|
||||
|
||||
upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME, 0);
|
||||
rc = weechat_upgrade_read (upgrade_file, &irc_upgrade_read_cb, NULL);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
+32
-32
@@ -68,11 +68,11 @@ irc_signal_quit_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
@@ -82,7 +82,7 @@ irc_signal_quit_cb (void *data, const char *signal, const char *type_data,
|
||||
(signal_data) ? (char *)signal_data : NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -96,15 +96,15 @@ irc_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
int disconnected;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
|
||||
irc_signal_upgrade_received = 1;
|
||||
|
||||
|
||||
/*
|
||||
* FIXME: it's not possible to upgrade with SSL servers connected (GnuTLS
|
||||
* lib can't reload data after upgrade), so we close connection for
|
||||
@@ -142,7 +142,7 @@ irc_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
|
||||
disconnected,
|
||||
NG_("server", "servers", disconnected));
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -154,23 +154,23 @@ int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
int i, auto_connect, upgrading;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
if (!irc_config_init ())
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
if (irc_config_read () < 0)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
irc_command_init ();
|
||||
|
||||
|
||||
irc_info_init ();
|
||||
|
||||
|
||||
irc_redirect_init ();
|
||||
|
||||
|
||||
irc_notify_init ();
|
||||
|
||||
|
||||
/* hook some signals */
|
||||
irc_debug_init ();
|
||||
weechat_hook_signal ("quit", &irc_signal_quit_cb, NULL);
|
||||
@@ -179,20 +179,20 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
weechat_hook_signal ("xfer_resume_ready", &irc_server_xfer_resume_ready_cb, NULL);
|
||||
weechat_hook_signal ("xfer_send_accept_resume", &irc_server_xfer_send_accept_resume_cb, NULL);
|
||||
weechat_hook_signal ("irc_input_send", &irc_input_send_cb, NULL);
|
||||
|
||||
|
||||
/* hook hsignals for redirection */
|
||||
weechat_hook_hsignal ("irc_redirect_pattern", &irc_redirect_pattern_hsignal_cb, NULL);
|
||||
weechat_hook_hsignal ("irc_redirect_command", &irc_redirect_command_hsignal_cb, NULL);
|
||||
|
||||
|
||||
/* modifiers */
|
||||
weechat_hook_modifier ("irc_color_decode", &irc_color_modifier_cb, NULL);
|
||||
weechat_hook_modifier ("irc_color_encode", &irc_color_modifier_cb, NULL);
|
||||
|
||||
|
||||
/* hook completions */
|
||||
irc_completion_init ();
|
||||
|
||||
|
||||
irc_bar_item_init ();
|
||||
|
||||
|
||||
/* look at arguments */
|
||||
auto_connect = 1;
|
||||
upgrading = 0;
|
||||
@@ -219,7 +219,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
upgrading = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (upgrading)
|
||||
{
|
||||
if (!irc_upgrade_load ())
|
||||
@@ -236,10 +236,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
if (auto_connect)
|
||||
irc_server_auto_connect ();
|
||||
}
|
||||
|
||||
|
||||
irc_hook_timer = weechat_hook_timer (1 * 1000, 0, 0,
|
||||
&irc_server_timer_cb, NULL);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -252,10 +252,10 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
if (irc_hook_timer)
|
||||
weechat_unhook (irc_hook_timer);
|
||||
|
||||
|
||||
if (irc_signal_upgrade_received)
|
||||
{
|
||||
irc_config_write (1);
|
||||
@@ -266,18 +266,18 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
irc_config_write (0);
|
||||
irc_server_disconnect_all ();
|
||||
}
|
||||
|
||||
|
||||
irc_ignore_free_all ();
|
||||
|
||||
|
||||
irc_raw_message_free_all ();
|
||||
|
||||
|
||||
irc_server_free_all ();
|
||||
|
||||
|
||||
irc_config_free ();
|
||||
|
||||
|
||||
irc_notify_end ();
|
||||
|
||||
|
||||
irc_redirect_end ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -48,17 +48,17 @@ int
|
||||
logger_buffer_valid (struct t_logger_buffer *logger_buffer)
|
||||
{
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
|
||||
|
||||
if (!logger_buffer)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer;
|
||||
ptr_logger_buffer = ptr_logger_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_logger_buffer == logger_buffer)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* logger_buffer not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -71,10 +71,10 @@ struct t_logger_buffer *
|
||||
logger_buffer_add (struct t_gui_buffer *buffer, int log_level)
|
||||
{
|
||||
struct t_logger_buffer *new_logger_buffer;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_logger_plugin->debug)
|
||||
{
|
||||
weechat_printf_tags (NULL,
|
||||
@@ -83,7 +83,7 @@ logger_buffer_add (struct t_gui_buffer *buffer, int log_level)
|
||||
LOGGER_PLUGIN_NAME,
|
||||
weechat_buffer_get_string (buffer, "name"));
|
||||
}
|
||||
|
||||
|
||||
new_logger_buffer = malloc (sizeof (*new_logger_buffer));
|
||||
if (new_logger_buffer)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ logger_buffer_add (struct t_gui_buffer *buffer, int log_level)
|
||||
new_logger_buffer->log_level = log_level;
|
||||
new_logger_buffer->write_start_info_line = 1;
|
||||
new_logger_buffer->flush_needed = 0;
|
||||
|
||||
|
||||
new_logger_buffer->prev_buffer = last_logger_buffer;
|
||||
new_logger_buffer->next_buffer = NULL;
|
||||
if (logger_buffers)
|
||||
@@ -103,7 +103,7 @@ logger_buffer_add (struct t_gui_buffer *buffer, int log_level)
|
||||
logger_buffers = new_logger_buffer;
|
||||
last_logger_buffer = new_logger_buffer;
|
||||
}
|
||||
|
||||
|
||||
return new_logger_buffer;
|
||||
}
|
||||
|
||||
@@ -115,14 +115,14 @@ struct t_logger_buffer *
|
||||
logger_buffer_search_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
|
||||
|
||||
for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer;
|
||||
ptr_logger_buffer = ptr_logger_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_logger_buffer->buffer == buffer)
|
||||
return ptr_logger_buffer;
|
||||
}
|
||||
|
||||
|
||||
/* logger buffer not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -135,10 +135,10 @@ struct t_logger_buffer *
|
||||
logger_buffer_search_log_filename (const char *log_filename)
|
||||
{
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
|
||||
|
||||
if (!log_filename)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer;
|
||||
ptr_logger_buffer = ptr_logger_buffer->next_buffer)
|
||||
{
|
||||
@@ -148,7 +148,7 @@ logger_buffer_search_log_filename (const char *log_filename)
|
||||
return ptr_logger_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* logger buffer not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -162,9 +162,9 @@ logger_buffer_free (struct t_logger_buffer *logger_buffer)
|
||||
{
|
||||
struct t_logger_buffer *new_logger_buffers;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
ptr_buffer = logger_buffer->buffer;
|
||||
|
||||
|
||||
/* remove logger buffer */
|
||||
if (last_logger_buffer == logger_buffer)
|
||||
last_logger_buffer = logger_buffer->prev_buffer;
|
||||
@@ -175,20 +175,20 @@ logger_buffer_free (struct t_logger_buffer *logger_buffer)
|
||||
}
|
||||
else
|
||||
new_logger_buffers = logger_buffer->next_buffer;
|
||||
|
||||
|
||||
if (logger_buffer->next_buffer)
|
||||
(logger_buffer->next_buffer)->prev_buffer = logger_buffer->prev_buffer;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (logger_buffer->log_filename)
|
||||
free (logger_buffer->log_filename);
|
||||
if (logger_buffer->log_file)
|
||||
fclose (logger_buffer->log_file);
|
||||
|
||||
|
||||
free (logger_buffer);
|
||||
|
||||
|
||||
logger_buffers = new_logger_buffers;
|
||||
|
||||
|
||||
if (weechat_logger_plugin->debug)
|
||||
{
|
||||
weechat_printf_tags (NULL,
|
||||
@@ -209,14 +209,14 @@ logger_buffer_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_logger_buffer *logger_buffer)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !logger_buffer)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_pointer (ptr_item, "buffer", logger_buffer->buffer))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "log_filename", logger_buffer->log_filename))
|
||||
@@ -231,6 +231,6 @@ logger_buffer_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "flush_needed", logger_buffer->flush_needed))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ logger_config_change_file_option_restart_log (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (!logger_config_loading)
|
||||
logger_adjust_log_filenames ();
|
||||
}
|
||||
@@ -80,10 +80,10 @@ logger_config_flush_delay_change (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (logger_config_loading)
|
||||
return;
|
||||
|
||||
|
||||
if (logger_timer)
|
||||
{
|
||||
if (weechat_logger_plugin->debug)
|
||||
@@ -95,7 +95,7 @@ logger_config_flush_delay_change (void *data,
|
||||
weechat_unhook (logger_timer);
|
||||
logger_timer = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (weechat_config_integer (logger_config_file_flush_delay) > 0)
|
||||
{
|
||||
if (weechat_logger_plugin->debug)
|
||||
@@ -123,7 +123,7 @@ logger_config_level_change (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (!logger_config_loading)
|
||||
logger_start_buffer_all (1);
|
||||
}
|
||||
@@ -142,11 +142,11 @@ logger_config_level_delete_option (void *data,
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
weechat_config_option_free (option);
|
||||
|
||||
|
||||
logger_start_buffer_all (1);
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
@@ -163,12 +163,12 @@ logger_config_level_create_option (void *data,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -205,7 +205,7 @@ logger_config_level_create_option (void *data,
|
||||
|
||||
if (!logger_config_loading)
|
||||
logger_start_buffer_all (1);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -265,11 +265,11 @@ logger_config_mask_delete_option (void *data,
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
weechat_config_option_free (option);
|
||||
|
||||
|
||||
logger_adjust_log_filenames ();
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
@@ -286,12 +286,12 @@ logger_config_mask_create_option (void *data,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -325,10 +325,10 @@ logger_config_mask_create_option (void *data,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!logger_config_loading)
|
||||
logger_adjust_log_filenames ();
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -353,12 +353,12 @@ int
|
||||
logger_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
logger_config_file = weechat_config_new (LOGGER_CONFIG_NAME,
|
||||
NULL, NULL);
|
||||
if (!logger_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
/* look */
|
||||
ptr_section = weechat_config_new_section (logger_config_file, "look",
|
||||
0, 0,
|
||||
@@ -370,14 +370,14 @@ logger_config_init ()
|
||||
weechat_config_free (logger_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
logger_config_look_backlog = weechat_config_new_option (
|
||||
logger_config_file, ptr_section,
|
||||
"backlog", "integer",
|
||||
N_("maximum number of lines to display from log file when creating "
|
||||
"new buffer (0 = no backlog)"),
|
||||
NULL, 0, INT_MAX, "20", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* file */
|
||||
ptr_section = weechat_config_new_section (logger_config_file, "file",
|
||||
0, 0,
|
||||
@@ -389,7 +389,7 @@ logger_config_init ()
|
||||
weechat_config_free (logger_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
logger_config_file_auto_log = weechat_config_new_option (
|
||||
logger_config_file, ptr_section,
|
||||
"auto_log", "boolean",
|
||||
@@ -446,7 +446,7 @@ logger_config_init ()
|
||||
N_("timestamp used in log files (see man strftime for date/time "
|
||||
"specifiers)"),
|
||||
NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* level */
|
||||
ptr_section = weechat_config_new_section (logger_config_file, "level",
|
||||
1, 1,
|
||||
@@ -459,9 +459,9 @@ logger_config_init ()
|
||||
weechat_config_free (logger_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
logger_config_section_level = ptr_section;
|
||||
|
||||
|
||||
/* mask */
|
||||
ptr_section = weechat_config_new_section (logger_config_file, "mask",
|
||||
1, 1,
|
||||
@@ -474,9 +474,9 @@ logger_config_init ()
|
||||
weechat_config_free (logger_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
logger_config_section_mask = ptr_section;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -488,13 +488,13 @@ int
|
||||
logger_config_read ()
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
||||
logger_config_loading = 1;
|
||||
rc = weechat_config_read (logger_config_file);
|
||||
logger_config_loading = 0;
|
||||
|
||||
|
||||
logger_config_flush_delay_change (NULL, NULL);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,19 +39,19 @@ logger_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) arguments;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "logger_buffer") == 0)
|
||||
{
|
||||
if (pointer && !logger_buffer_valid (pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ logger_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ logger_tail_last_eol (const char *string_start, const char *string_ptr)
|
||||
return (char *)string_ptr;
|
||||
string_ptr--;
|
||||
}
|
||||
|
||||
|
||||
/* no end-of-line found in string */
|
||||
return NULL;
|
||||
}
|
||||
@@ -71,12 +71,12 @@ logger_tail_file (const char *filename, int n_lines)
|
||||
char buf[LOGGER_TAIL_BUFSIZE + 1];
|
||||
char *ptr_buf, *pos_eol, *part_of_line, *new_part_of_line;
|
||||
struct t_logger_line *ptr_line, *new_line;
|
||||
|
||||
|
||||
/* open file */
|
||||
fd = open (filename, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* seek to the end of file */
|
||||
file_length = lseek (fd, (off_t)0, SEEK_END);
|
||||
if (file_length <= 0)
|
||||
@@ -91,7 +91,7 @@ logger_tail_file (const char *filename, int n_lines)
|
||||
else
|
||||
to_read = LOGGER_TAIL_BUFSIZE;
|
||||
lseek (fd, file_pos, SEEK_SET);
|
||||
|
||||
|
||||
/* loop until we have "n_lines" lines in list */
|
||||
part_of_line = NULL;
|
||||
ptr_line = NULL;
|
||||
@@ -200,12 +200,12 @@ logger_tail_file (const char *filename, int n_lines)
|
||||
else
|
||||
to_read = LOGGER_TAIL_BUFSIZE;
|
||||
}
|
||||
|
||||
|
||||
if (part_of_line)
|
||||
free (part_of_line);
|
||||
|
||||
|
||||
close (fd);
|
||||
|
||||
|
||||
return ptr_line;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ void
|
||||
logger_tail_free (struct t_logger_line *lines)
|
||||
{
|
||||
struct t_logger_line *ptr_line, *next_line;
|
||||
|
||||
|
||||
if (!lines)
|
||||
return;
|
||||
|
||||
@@ -225,11 +225,11 @@ logger_tail_free (struct t_logger_line *lines)
|
||||
while (ptr_line)
|
||||
{
|
||||
next_line = ptr_line->next_line;
|
||||
|
||||
|
||||
if (ptr_line->data)
|
||||
free (ptr_line->data);
|
||||
free (ptr_line);
|
||||
|
||||
|
||||
ptr_line = next_line;
|
||||
}
|
||||
}
|
||||
|
||||
+115
-115
@@ -72,20 +72,20 @@ logger_get_file_path ()
|
||||
int length;
|
||||
time_t seconds;
|
||||
struct tm *date_tmp;
|
||||
|
||||
|
||||
file_path = NULL;
|
||||
file_path2 = NULL;
|
||||
file_path3 = NULL;
|
||||
|
||||
|
||||
weechat_dir = weechat_info_get ("weechat_dir", "");
|
||||
if (!weechat_dir)
|
||||
goto end;
|
||||
|
||||
|
||||
/* replace "~" with user home */
|
||||
file_path = weechat_string_expand_home (weechat_config_string (logger_config_file_path));
|
||||
if (!file_path)
|
||||
goto end;
|
||||
|
||||
|
||||
/* replace "%h" with WeeChat home (at beginning of string only) */
|
||||
if (strncmp (file_path, "%h", 2) == 0)
|
||||
{
|
||||
@@ -98,7 +98,7 @@ logger_get_file_path ()
|
||||
file_path2 = strdup (file_path);
|
||||
if (!file_path2)
|
||||
goto end;
|
||||
|
||||
|
||||
/* replace date/time specifiers in path */
|
||||
length = strlen (file_path2) + 256 + 1;
|
||||
file_path3 = malloc (length);
|
||||
@@ -108,7 +108,7 @@ logger_get_file_path ()
|
||||
date_tmp = localtime (&seconds);
|
||||
file_path3[0] = '\0';
|
||||
strftime (file_path3, length - 1, file_path2, date_tmp);
|
||||
|
||||
|
||||
if (weechat_logger_plugin->debug)
|
||||
{
|
||||
weechat_printf_tags (NULL,
|
||||
@@ -116,13 +116,13 @@ logger_get_file_path ()
|
||||
"%s: file path = \"%s\"",
|
||||
LOGGER_PLUGIN_NAME, file_path3);
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (file_path)
|
||||
free (file_path);
|
||||
if (file_path2)
|
||||
free (file_path2);
|
||||
|
||||
|
||||
return file_path3;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ logger_create_directory ()
|
||||
{
|
||||
int rc;
|
||||
char *file_path;
|
||||
|
||||
|
||||
rc = 1;
|
||||
|
||||
file_path = logger_get_file_path ();
|
||||
@@ -149,7 +149,7 @@ logger_create_directory ()
|
||||
}
|
||||
else
|
||||
rc = 0;
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -163,20 +163,20 @@ logger_build_option_name (struct t_gui_buffer *buffer)
|
||||
const char *plugin_name, *name;
|
||||
char *option_name;
|
||||
int length;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
|
||||
plugin_name = weechat_buffer_get_string (buffer, "plugin");
|
||||
name = weechat_buffer_get_string (buffer, "name");
|
||||
|
||||
|
||||
length = strlen (plugin_name) + 1 + strlen (name) + 1;
|
||||
option_name = malloc (length);
|
||||
if (!option_name)
|
||||
return NULL;
|
||||
|
||||
|
||||
snprintf (option_name, length, "%s.%s", plugin_name, name);
|
||||
|
||||
|
||||
return option_name;
|
||||
}
|
||||
|
||||
@@ -190,16 +190,16 @@ logger_get_level_for_buffer (struct t_gui_buffer *buffer)
|
||||
const char *no_log;
|
||||
char *name, *option_name, *ptr_end;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
/* no log for buffer if local variable "no_log" is defined for buffer */
|
||||
no_log = weechat_buffer_get_string (buffer, "localvar_no_log");
|
||||
if (no_log && no_log[0])
|
||||
return 0;
|
||||
|
||||
|
||||
name = logger_build_option_name (buffer);
|
||||
if (!name)
|
||||
return LOGGER_LEVEL_DEFAULT;
|
||||
|
||||
|
||||
option_name = strdup (name);
|
||||
if (option_name)
|
||||
{
|
||||
@@ -222,16 +222,16 @@ logger_get_level_for_buffer (struct t_gui_buffer *buffer)
|
||||
ptr_end[0] = '\0';
|
||||
}
|
||||
ptr_option = logger_config_get_level (option_name);
|
||||
|
||||
|
||||
free (option_name);
|
||||
free (name);
|
||||
|
||||
|
||||
if (ptr_option)
|
||||
return weechat_config_integer (ptr_option);
|
||||
}
|
||||
else
|
||||
free (name);
|
||||
|
||||
|
||||
/* nothing found => return default level */
|
||||
return LOGGER_LEVEL_DEFAULT;
|
||||
}
|
||||
@@ -247,11 +247,11 @@ logger_get_mask_for_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
char *name, *option_name, *ptr_end;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
name = logger_build_option_name (buffer);
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
|
||||
option_name = strdup (name);
|
||||
if (option_name)
|
||||
{
|
||||
@@ -274,21 +274,21 @@ logger_get_mask_for_buffer (struct t_gui_buffer *buffer)
|
||||
ptr_end[0] = '\0';
|
||||
}
|
||||
ptr_option = logger_config_get_mask (option_name);
|
||||
|
||||
|
||||
free (option_name);
|
||||
free (name);
|
||||
|
||||
|
||||
if (ptr_option)
|
||||
return weechat_config_string (ptr_option);
|
||||
}
|
||||
else
|
||||
free (name);
|
||||
|
||||
|
||||
/* nothing found => return default mask (if set) */
|
||||
if (weechat_config_string (logger_config_file_mask)
|
||||
&& weechat_config_string (logger_config_file_mask)[0])
|
||||
return weechat_config_string (logger_config_file_mask);
|
||||
|
||||
|
||||
/* no default mask set */
|
||||
return NULL;
|
||||
}
|
||||
@@ -309,7 +309,7 @@ logger_get_mask_expanded (struct t_gui_buffer *buffer, const char *mask)
|
||||
int length;
|
||||
time_t seconds;
|
||||
struct tm *date_tmp;
|
||||
|
||||
|
||||
mask2 = NULL;
|
||||
mask_decoded = NULL;
|
||||
mask_decoded2 = NULL;
|
||||
@@ -319,7 +319,7 @@ logger_get_mask_expanded (struct t_gui_buffer *buffer, const char *mask)
|
||||
dir_separator = weechat_info_get ("dir_separator", "");
|
||||
if (!dir_separator)
|
||||
return NULL;
|
||||
|
||||
|
||||
/*
|
||||
* we first replace directory separator (commonly '/') by \01 because
|
||||
* buffer mask can contain this char, and will be replaced by replacement
|
||||
@@ -328,23 +328,23 @@ logger_get_mask_expanded (struct t_gui_buffer *buffer, const char *mask)
|
||||
mask2 = weechat_string_replace (mask, dir_separator, "\01");
|
||||
if (!mask2)
|
||||
goto end;
|
||||
|
||||
|
||||
mask_decoded = weechat_buffer_string_replace_local_var (buffer, mask2);
|
||||
if (!mask_decoded)
|
||||
goto end;
|
||||
|
||||
|
||||
mask_decoded2 = weechat_string_replace (mask_decoded,
|
||||
dir_separator,
|
||||
weechat_config_string (logger_config_file_replacement_char));
|
||||
if (!mask_decoded2)
|
||||
goto end;
|
||||
|
||||
|
||||
/* restore directory separator */
|
||||
mask_decoded3 = weechat_string_replace (mask_decoded2,
|
||||
"\01", dir_separator);
|
||||
if (!mask_decoded3)
|
||||
goto end;
|
||||
|
||||
|
||||
/* replace date/time specifiers in mask */
|
||||
length = strlen (mask_decoded3) + 256 + 1;
|
||||
mask_decoded4 = malloc (length);
|
||||
@@ -354,11 +354,11 @@ logger_get_mask_expanded (struct t_gui_buffer *buffer, const char *mask)
|
||||
date_tmp = localtime (&seconds);
|
||||
mask_decoded4[0] = '\0';
|
||||
strftime (mask_decoded4, length - 1, mask_decoded3, date_tmp);
|
||||
|
||||
|
||||
/* convert to lower case? */
|
||||
if (weechat_config_boolean (logger_config_file_name_lower_case))
|
||||
weechat_string_tolower (mask_decoded4);
|
||||
|
||||
|
||||
if (weechat_logger_plugin->debug)
|
||||
{
|
||||
weechat_printf_tags (NULL,
|
||||
@@ -369,7 +369,7 @@ logger_get_mask_expanded (struct t_gui_buffer *buffer, const char *mask)
|
||||
weechat_buffer_get_string (buffer, "name"),
|
||||
mask, mask_decoded4);
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (mask2)
|
||||
free (mask2);
|
||||
@@ -379,7 +379,7 @@ end:
|
||||
free (mask_decoded2);
|
||||
if (mask_decoded3)
|
||||
free (mask_decoded3);
|
||||
|
||||
|
||||
return mask_decoded4;
|
||||
}
|
||||
|
||||
@@ -394,18 +394,18 @@ logger_get_filename (struct t_gui_buffer *buffer)
|
||||
const char *mask;
|
||||
const char *dir_separator, *weechat_dir;
|
||||
int length;
|
||||
|
||||
|
||||
res = NULL;
|
||||
mask_expanded = NULL;
|
||||
file_path = NULL;
|
||||
|
||||
|
||||
dir_separator = weechat_info_get ("dir_separator", "");
|
||||
if (!dir_separator)
|
||||
return NULL;
|
||||
weechat_dir = weechat_info_get ("weechat_dir", "");
|
||||
if (!weechat_dir)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* get filename mask for buffer */
|
||||
mask = logger_get_mask_for_buffer (buffer);
|
||||
if (!mask)
|
||||
@@ -418,15 +418,15 @@ logger_get_filename (struct t_gui_buffer *buffer)
|
||||
weechat_buffer_get_string (buffer, "name"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
mask_expanded = logger_get_mask_expanded (buffer, mask);
|
||||
if (!mask_expanded)
|
||||
goto end;
|
||||
|
||||
|
||||
file_path = logger_get_file_path ();
|
||||
if (!file_path)
|
||||
goto end;
|
||||
|
||||
|
||||
/* build string with path + mask */
|
||||
length = strlen (file_path) + strlen (dir_separator) +
|
||||
strlen (mask_expanded) + 1;
|
||||
@@ -438,13 +438,13 @@ logger_get_filename (struct t_gui_buffer *buffer)
|
||||
(file_path[strlen (file_path) - 1] == dir_separator[0]) ? "" : dir_separator,
|
||||
mask_expanded);
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (mask_expanded)
|
||||
free (mask_expanded);
|
||||
if (file_path)
|
||||
free (file_path);
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ logger_set_log_filename (struct t_logger_buffer *logger_buffer)
|
||||
char *log_filename, *pos_last_sep;
|
||||
const char *dir_separator;
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
|
||||
|
||||
/* get log filename for buffer */
|
||||
log_filename = logger_get_filename (logger_buffer->buffer);
|
||||
if (!log_filename)
|
||||
@@ -470,7 +470,7 @@ logger_set_log_filename (struct t_logger_buffer *logger_buffer)
|
||||
LOGGER_PLUGIN_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* log file is already used by another buffer? */
|
||||
ptr_logger_buffer = logger_buffer_search_log_filename (log_filename);
|
||||
if (ptr_logger_buffer)
|
||||
@@ -487,7 +487,7 @@ logger_set_log_filename (struct t_logger_buffer *logger_buffer)
|
||||
free (log_filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* create directory for path in "log_filename" */
|
||||
dir_separator = weechat_info_get ("dir_separator", "");
|
||||
if (dir_separator)
|
||||
@@ -500,7 +500,7 @@ logger_set_log_filename (struct t_logger_buffer *logger_buffer)
|
||||
pos_last_sep[0] = dir_separator[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* set log filename */
|
||||
logger_buffer->log_filename = log_filename;
|
||||
}
|
||||
@@ -518,9 +518,9 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
|
||||
time_t seconds;
|
||||
struct tm *date_tmp;
|
||||
int log_level;
|
||||
|
||||
|
||||
charset = weechat_info_get ("charset_terminal", "");
|
||||
|
||||
|
||||
if (!logger_buffer->log_file)
|
||||
{
|
||||
log_level = logger_get_level_for_buffer (logger_buffer->buffer);
|
||||
@@ -547,7 +547,7 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
|
||||
logger_buffer_free (logger_buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
logger_buffer->log_file =
|
||||
fopen (logger_buffer->log_filename, "a");
|
||||
if (!logger_buffer->log_file)
|
||||
@@ -560,7 +560,7 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
|
||||
logger_buffer_free (logger_buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (weechat_config_boolean (logger_config_file_info_lines)
|
||||
&& logger_buffer->write_start_info_line)
|
||||
{
|
||||
@@ -586,7 +586,7 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
|
||||
}
|
||||
logger_buffer->write_start_info_line = 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_va_format (format);
|
||||
if (vbuffer)
|
||||
{
|
||||
@@ -616,10 +616,10 @@ logger_stop (struct t_logger_buffer *logger_buffer, int write_info_line)
|
||||
time_t seconds;
|
||||
struct tm *date_tmp;
|
||||
char buf_time[256];
|
||||
|
||||
|
||||
if (!logger_buffer)
|
||||
return;
|
||||
|
||||
|
||||
if (logger_buffer->log_enabled && logger_buffer->log_file)
|
||||
{
|
||||
if (write_info_line && weechat_config_boolean (logger_config_file_info_lines))
|
||||
@@ -665,16 +665,16 @@ logger_start_buffer (struct t_gui_buffer *buffer, int write_info_line)
|
||||
{
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
int log_level, log_enabled;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
|
||||
log_level = logger_get_level_for_buffer (buffer);
|
||||
log_enabled = weechat_config_boolean (logger_config_file_auto_log)
|
||||
&& (log_level > 0);
|
||||
|
||||
|
||||
ptr_logger_buffer = logger_buffer_search_buffer (buffer);
|
||||
|
||||
|
||||
/* logging is disabled for buffer */
|
||||
if (!log_enabled)
|
||||
{
|
||||
@@ -690,7 +690,7 @@ logger_start_buffer (struct t_gui_buffer *buffer, int write_info_line)
|
||||
else
|
||||
{
|
||||
ptr_logger_buffer = logger_buffer_add (buffer, log_level);
|
||||
|
||||
|
||||
if (ptr_logger_buffer)
|
||||
{
|
||||
if (ptr_logger_buffer->log_filename)
|
||||
@@ -716,7 +716,7 @@ void
|
||||
logger_start_buffer_all (int write_info_line)
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL);
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -741,10 +741,10 @@ logger_list ()
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
char status[128];
|
||||
|
||||
|
||||
weechat_printf (NULL, "");
|
||||
weechat_printf (NULL, _("Logging on buffers:"));
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL);
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -796,11 +796,11 @@ logger_set_buffer (struct t_gui_buffer *buffer, const char *value)
|
||||
{
|
||||
char *name;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
name = logger_build_option_name (buffer);
|
||||
if (!name)
|
||||
return;
|
||||
|
||||
|
||||
if (logger_config_set_level (name, value) != WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
ptr_option = logger_config_get_level (name);
|
||||
@@ -811,7 +811,7 @@ logger_set_buffer (struct t_gui_buffer *buffer, const char *value)
|
||||
weechat_config_integer (ptr_option));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free (name);
|
||||
}
|
||||
|
||||
@@ -826,14 +826,14 @@ logger_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) argv_eol;
|
||||
|
||||
|
||||
if ((argc == 1)
|
||||
|| ((argc == 2) && (weechat_strcasecmp (argv[1], "list") == 0)))
|
||||
{
|
||||
logger_list ();
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "set") == 0)
|
||||
@@ -842,13 +842,13 @@ logger_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
logger_set_buffer (buffer, argv[2]);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "disable") == 0)
|
||||
{
|
||||
logger_set_buffer (buffer, "0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -864,9 +864,9 @@ logger_buffer_opened_signal_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
logger_start_buffer (signal_data, 1);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -882,9 +882,9 @@ logger_buffer_closing_signal_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
logger_stop (logger_buffer_search_buffer (signal_data), 1);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -900,10 +900,10 @@ logger_buffer_renamed_signal_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
logger_stop (logger_buffer_search_buffer (signal_data), 1);
|
||||
logger_start_buffer (signal_data, 1);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -919,7 +919,7 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines)
|
||||
time_t datetime, time_now;
|
||||
struct tm tm_line;
|
||||
int num_lines;
|
||||
|
||||
|
||||
weechat_buffer_set (buffer, "print_hooks_enabled", "0");
|
||||
num_lines = 0;
|
||||
last_lines = logger_tail_file (filename, lines);
|
||||
@@ -990,7 +990,7 @@ logger_backlog_signal_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
@@ -1003,20 +1003,20 @@ logger_backlog_signal_cb (void *data, const char *signal,
|
||||
{
|
||||
if (!ptr_logger_buffer->log_filename)
|
||||
logger_set_log_filename (ptr_logger_buffer);
|
||||
|
||||
|
||||
if (ptr_logger_buffer->log_filename)
|
||||
{
|
||||
ptr_logger_buffer->log_enabled = 0;
|
||||
|
||||
|
||||
logger_backlog (signal_data,
|
||||
ptr_logger_buffer->log_filename,
|
||||
weechat_config_integer (logger_config_look_backlog));
|
||||
|
||||
|
||||
ptr_logger_buffer->log_enabled = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1032,9 +1032,9 @@ logger_start_signal_cb (void *data, const char *signal, const char *type_data,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
logger_start_buffer (signal_data, 1);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1047,16 +1047,16 @@ logger_stop_signal_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
ptr_logger_buffer = logger_buffer_search_buffer (signal_data);
|
||||
if (ptr_logger_buffer)
|
||||
logger_stop (ptr_logger_buffer, 0);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1073,7 +1073,7 @@ logger_adjust_log_filenames ()
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
char *log_filename;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL);
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -1116,9 +1116,9 @@ logger_day_changed_signal_cb (void *data, const char *signal,
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
|
||||
logger_adjust_log_filenames ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1130,13 +1130,13 @@ int
|
||||
logger_line_log_level (int tags_count, const char **tags)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < tags_count; i++)
|
||||
{
|
||||
/* log disabled on line? return -1 */
|
||||
if (strcmp (tags[i], "no_log") == 0)
|
||||
return -1;
|
||||
|
||||
|
||||
/* log level for line? return it */
|
||||
if (strncmp (tags[i], "log", 3) == 0)
|
||||
{
|
||||
@@ -1146,7 +1146,7 @@ logger_line_log_level (int tags_count, const char **tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* return default log level for line */
|
||||
return LOGGER_LEVEL_DEFAULT;
|
||||
}
|
||||
@@ -1165,12 +1165,12 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
|
||||
struct tm *date_tmp;
|
||||
char buf_time[256];
|
||||
int line_log_level;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) displayed;
|
||||
(void) highlight;
|
||||
|
||||
|
||||
line_log_level = logger_line_log_level (tags_count, tags);
|
||||
if (line_log_level >= 0)
|
||||
{
|
||||
@@ -1188,7 +1188,7 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
|
||||
weechat_config_string (logger_config_file_time_format),
|
||||
date_tmp);
|
||||
}
|
||||
|
||||
|
||||
logger_write_line (ptr_logger_buffer,
|
||||
"%s\t%s\t%s",
|
||||
buf_time,
|
||||
@@ -1196,7 +1196,7 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
|
||||
message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1208,11 +1208,11 @@ int
|
||||
logger_timer_cb (void *data, int remaining_calls)
|
||||
{
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer;
|
||||
ptr_logger_buffer = ptr_logger_buffer->next_buffer)
|
||||
{
|
||||
@@ -1230,7 +1230,7 @@ logger_timer_cb (void *data, int remaining_calls)
|
||||
ptr_logger_buffer->flush_needed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1244,15 +1244,15 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
if (!logger_config_init ())
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
if (logger_config_read () < 0)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
/* command /logger */
|
||||
weechat_hook_command ("logger",
|
||||
N_("logger plugin configuration"),
|
||||
@@ -1291,9 +1291,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
" || set 1|2|3|4|5|6|7|8|9"
|
||||
" || disable",
|
||||
&logger_command_cb, NULL);
|
||||
|
||||
|
||||
logger_start_buffer_all (1);
|
||||
|
||||
|
||||
weechat_hook_signal ("buffer_opened", &logger_buffer_opened_signal_cb, NULL);
|
||||
weechat_hook_signal ("buffer_closing", &logger_buffer_closing_signal_cb, NULL);
|
||||
weechat_hook_signal ("buffer_renamed", &logger_buffer_renamed_signal_cb, NULL);
|
||||
@@ -1301,11 +1301,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
weechat_hook_signal ("logger_start", &logger_start_signal_cb, NULL);
|
||||
weechat_hook_signal ("logger_stop", &logger_stop_signal_cb, NULL);
|
||||
weechat_hook_signal ("day_changed", &logger_day_changed_signal_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_print (NULL, NULL, NULL, 1, &logger_print_cb, NULL);
|
||||
|
||||
|
||||
logger_info_init ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1318,18 +1318,18 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
if (logger_timer)
|
||||
{
|
||||
weechat_unhook (logger_timer);
|
||||
logger_timer = NULL;
|
||||
}
|
||||
|
||||
|
||||
logger_config_write ();
|
||||
|
||||
|
||||
logger_stop_all (1);
|
||||
|
||||
|
||||
logger_config_free ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
+46
-46
@@ -75,7 +75,7 @@ plugin_api_charset_set (struct t_weechat_plugin *plugin, const char *charset)
|
||||
|
||||
if (plugin->charset)
|
||||
free (plugin->charset);
|
||||
|
||||
|
||||
plugin->charset = (charset) ? strdup (charset) : NULL;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ plugin_api_ngettext (const char *single, const char *plural, int count)
|
||||
/* make C compiler happy */
|
||||
(void) single;
|
||||
(void) count;
|
||||
|
||||
|
||||
return NG_(single, plural, count);
|
||||
}
|
||||
|
||||
@@ -111,9 +111,9 @@ struct t_config_option *
|
||||
plugin_api_config_get (const char *option_name)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
config_file_search_with_string (option_name, NULL, NULL, &ptr_option, NULL);
|
||||
|
||||
|
||||
return ptr_option;
|
||||
}
|
||||
|
||||
@@ -126,14 +126,14 @@ plugin_api_config_get_plugin (struct t_weechat_plugin *plugin,
|
||||
const char *option_name)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
if (!plugin || !option_name)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_option = plugin_config_search (plugin->name, option_name);
|
||||
if (ptr_option)
|
||||
return ptr_option->value;
|
||||
|
||||
|
||||
/* option not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -147,14 +147,14 @@ plugin_api_config_is_set_plugin (struct t_weechat_plugin *plugin,
|
||||
const char *option_name)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
if (!plugin || !option_name)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_option = plugin_config_search (plugin->name, option_name);
|
||||
if (ptr_option)
|
||||
return 1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ plugin_api_config_set_plugin (struct t_weechat_plugin *plugin,
|
||||
{
|
||||
if (!plugin || !option_name)
|
||||
return WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND;
|
||||
|
||||
|
||||
return plugin_config_set (plugin->name, option_name, value);
|
||||
}
|
||||
|
||||
@@ -194,14 +194,14 @@ plugin_api_config_unset_plugin (struct t_weechat_plugin *plugin,
|
||||
const char *option_name)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
if (!plugin || !option_name)
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
|
||||
|
||||
ptr_option = plugin_config_search (plugin->name, option_name);
|
||||
if (!ptr_option)
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_ERROR;
|
||||
|
||||
|
||||
return config_file_option_unset (ptr_option);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ plugin_api_prefix (const char *prefix)
|
||||
{
|
||||
if (!prefix)
|
||||
return gui_chat_prefix_empty;
|
||||
|
||||
|
||||
if (string_strcasecmp (prefix, "error") == 0)
|
||||
return gui_chat_prefix[GUI_CHAT_PREFIX_ERROR];
|
||||
if (string_strcasecmp (prefix, "network") == 0)
|
||||
@@ -225,7 +225,7 @@ plugin_api_prefix (const char *prefix)
|
||||
return gui_chat_prefix[GUI_CHAT_PREFIX_JOIN];
|
||||
if (string_strcasecmp (prefix, "quit") == 0)
|
||||
return gui_chat_prefix[GUI_CHAT_PREFIX_QUIT];
|
||||
|
||||
|
||||
return gui_chat_prefix_empty;
|
||||
}
|
||||
|
||||
@@ -237,15 +237,15 @@ const char *
|
||||
plugin_api_color (const char *color_name)
|
||||
{
|
||||
const char *str_color;
|
||||
|
||||
|
||||
if (!color_name)
|
||||
return GUI_NO_COLOR;
|
||||
|
||||
|
||||
/* name is a weechat color option ? => then return this color */
|
||||
str_color = gui_color_search_config (color_name);
|
||||
if (str_color)
|
||||
return str_color;
|
||||
|
||||
|
||||
return gui_color_get_custom (color_name);
|
||||
}
|
||||
|
||||
@@ -258,10 +258,10 @@ plugin_api_command (struct t_weechat_plugin *plugin,
|
||||
struct t_gui_buffer *buffer, const char *command)
|
||||
{
|
||||
char *command2;
|
||||
|
||||
|
||||
if (!plugin || !command)
|
||||
return;
|
||||
|
||||
|
||||
command2 = string_iconv_to_internal (plugin->charset, command);
|
||||
if (!buffer)
|
||||
buffer = gui_current_window->buffer;
|
||||
@@ -281,14 +281,14 @@ plugin_api_info_get_internal (void *data, const char *info_name,
|
||||
time_t inactivity;
|
||||
static char value[32], version_number[32] = { '\0' };
|
||||
static char weechat_dir_absolute_path[PATH_MAX] = { '\0' };
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) arguments;
|
||||
|
||||
|
||||
if (!info_name)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (string_strcasecmp (info_name, "version") == 0)
|
||||
{
|
||||
return PACKAGE_VERSION;
|
||||
@@ -372,7 +372,7 @@ plugin_api_info_get_internal (void *data, const char *info_name,
|
||||
snprintf (value, sizeof (value), "%d", gui_cursor_mode);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/* info not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -403,10 +403,10 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
char buffer_full_name[1024];
|
||||
int context, number;
|
||||
char *error;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
@@ -415,7 +415,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
/* invalid bar pointer ? */
|
||||
if (pointer && (!gui_bar_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -453,7 +453,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
/* invalid bar item pointer ? */
|
||||
if (pointer && (!gui_bar_item_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -492,7 +492,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
/* invalid bar window pointer ? */
|
||||
if (pointer && (!gui_bar_window_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -543,7 +543,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
/* invalid buffer pointer ? */
|
||||
if (pointer && (!gui_buffer_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -591,7 +591,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
if (!gui_buffer_valid (pointer))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -635,7 +635,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
/* invalid buffer pointer ? */
|
||||
if (pointer && (!gui_buffer_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -711,7 +711,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
/* invalid buffer pointer ? */
|
||||
if (!pointer || (!gui_buffer_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -741,7 +741,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
/* invalid plugin pointer ? */
|
||||
if (pointer && (!plugin_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -780,7 +780,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
/* invalid window pointer ? */
|
||||
if (pointer && (!gui_window_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -849,7 +849,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* infolist not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -865,7 +865,7 @@ plugin_api_infolist_next (struct t_infolist *infolist)
|
||||
{
|
||||
if (!infolist || !infolist_valid (infolist))
|
||||
return 0;
|
||||
|
||||
|
||||
return (infolist_next (infolist)) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -906,7 +906,7 @@ plugin_api_infolist_fields (struct t_infolist *infolist)
|
||||
{
|
||||
if (!infolist || !infolist_valid (infolist))
|
||||
return NULL;
|
||||
|
||||
|
||||
return infolist_fields (infolist);
|
||||
}
|
||||
|
||||
@@ -919,7 +919,7 @@ plugin_api_infolist_integer (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
return infolist_integer (infolist, var);
|
||||
}
|
||||
|
||||
@@ -932,7 +932,7 @@ plugin_api_infolist_string (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
|
||||
return NULL;
|
||||
|
||||
|
||||
return infolist_string (infolist, var);
|
||||
}
|
||||
|
||||
@@ -945,7 +945,7 @@ plugin_api_infolist_pointer (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
|
||||
return NULL;
|
||||
|
||||
|
||||
return infolist_pointer (infolist, var);
|
||||
}
|
||||
|
||||
@@ -959,7 +959,7 @@ plugin_api_infolist_buffer (struct t_infolist *infolist, const char *var,
|
||||
{
|
||||
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
|
||||
return NULL;
|
||||
|
||||
|
||||
return infolist_buffer (infolist, var, size);
|
||||
}
|
||||
|
||||
@@ -972,7 +972,7 @@ plugin_api_infolist_time (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
return infolist_time (infolist, var);
|
||||
}
|
||||
|
||||
@@ -1027,7 +1027,7 @@ plugin_api_init ()
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "cursor_mode", N_("1 if cursor mode is enabled"), NULL,
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
|
||||
|
||||
/* WeeChat core infolist hooks */
|
||||
hook_infolist (NULL, "bar", N_("list of bars"),
|
||||
N_("bar pointer (optional)"),
|
||||
@@ -1089,7 +1089,7 @@ plugin_api_init ()
|
||||
N_("window pointer (optional)"),
|
||||
N_("\"current\" for current window or a window number (optional)"),
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
|
||||
|
||||
/* WeeChat core hdata */
|
||||
hook_hdata (NULL, "bar", N_("bar"),
|
||||
&gui_bar_hdata_bar_cb, NULL);
|
||||
|
||||
+24
-24
@@ -56,9 +56,9 @@ plugin_config_search (const char *plugin_name, const char *option_name)
|
||||
int length;
|
||||
char *option_full_name;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
ptr_option = NULL;
|
||||
|
||||
|
||||
length = strlen (plugin_name) + 1 + strlen (option_name) + 1;
|
||||
option_full_name = malloc (length);
|
||||
if (option_full_name)
|
||||
@@ -70,7 +70,7 @@ plugin_config_search (const char *plugin_name, const char *option_name)
|
||||
option_full_name);
|
||||
free (option_full_name);
|
||||
}
|
||||
|
||||
|
||||
return ptr_option;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ plugin_config_set_internal (const char *option, const char *value)
|
||||
{
|
||||
int rc;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
ptr_option = config_file_search_option (plugin_config_file,
|
||||
plugin_config_section_var,
|
||||
option);
|
||||
@@ -100,7 +100,7 @@ plugin_config_set_internal (const char *option, const char *value)
|
||||
NULL, 0, 0, "", value, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
rc = (ptr_option) ? WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -114,9 +114,9 @@ plugin_config_set (const char *plugin_name, const char *option_name,
|
||||
{
|
||||
int length, rc;
|
||||
char *option_full_name;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
length = strlen (plugin_name) + 1 + strlen (option_name) + 1;
|
||||
option_full_name = malloc (length);
|
||||
if (option_full_name)
|
||||
@@ -127,7 +127,7 @@ plugin_config_set (const char *plugin_name, const char *option_name,
|
||||
rc = plugin_config_set_internal (option_full_name, value);
|
||||
free (option_full_name);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -140,10 +140,10 @@ void
|
||||
plugin_config_desc_changed_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_option = config_file_search_option (plugin_config_file,
|
||||
plugin_config_section_var,
|
||||
option->name);
|
||||
@@ -169,7 +169,7 @@ void
|
||||
plugin_config_set_desc_internal (const char *option, const char *value)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
ptr_option = config_file_search_option (plugin_config_file,
|
||||
plugin_config_section_desc,
|
||||
option);
|
||||
@@ -199,7 +199,7 @@ plugin_config_set_desc (const char *plugin_name, const char *option_name,
|
||||
{
|
||||
int length;
|
||||
char *option_full_name;
|
||||
|
||||
|
||||
length = strlen (plugin_name) + 1 + strlen (option_name) + 1;
|
||||
option_full_name = malloc (length);
|
||||
if (option_full_name)
|
||||
@@ -221,11 +221,11 @@ plugin_config_reload (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
/* remove all plugin options and descriptions */
|
||||
config_file_section_free_options (plugin_config_section_var);
|
||||
config_file_section_free_options (plugin_config_section_desc);
|
||||
|
||||
|
||||
/* reload plugins config file */
|
||||
return config_file_reload (config_file);
|
||||
}
|
||||
@@ -240,20 +240,20 @@ plugin_config_create_option (void *data, struct t_config_file *config_file,
|
||||
const char *option_name, const char *value)
|
||||
{
|
||||
struct t_config_option *ptr_option_desc, *ptr_option;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
ptr_option_desc = config_file_search_option (config_file,
|
||||
plugin_config_section_desc,
|
||||
option_name);
|
||||
|
||||
|
||||
ptr_option = config_file_new_option (
|
||||
config_file, section,
|
||||
option_name, "string",
|
||||
(ptr_option_desc) ? CONFIG_STRING(ptr_option_desc) : NULL,
|
||||
NULL, 0, 0, "", value, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
return (ptr_option) ?
|
||||
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
@@ -268,10 +268,10 @@ plugin_config_create_desc (void *data, struct t_config_file *config_file,
|
||||
const char *option_name, const char *value)
|
||||
{
|
||||
struct t_config_option *ptr_option_var, *ptr_option;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_option_var = config_file_search_option (config_file,
|
||||
plugin_config_section_var,
|
||||
option_name);
|
||||
@@ -285,13 +285,13 @@ plugin_config_create_desc (void *data, struct t_config_file *config_file,
|
||||
if (value)
|
||||
ptr_option_var->description = strdup (value);
|
||||
}
|
||||
|
||||
|
||||
ptr_option = config_file_new_option (
|
||||
config_file, section,
|
||||
option_name, "string", _("description of plugin option"),
|
||||
NULL, 0, 0, "", value, 0, NULL, NULL,
|
||||
&plugin_config_desc_changed_cb, NULL, NULL, NULL);
|
||||
|
||||
|
||||
return (ptr_option) ?
|
||||
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
@@ -306,11 +306,11 @@ plugin_config_delete_desc (void *data, struct t_config_file *config_file,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
struct t_config_option *ptr_option_var;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) section;
|
||||
|
||||
|
||||
ptr_option_var = config_file_search_option (config_file,
|
||||
plugin_config_section_var,
|
||||
option->name);
|
||||
@@ -322,7 +322,7 @@ plugin_config_delete_desc (void *data, struct t_config_file *config_file,
|
||||
ptr_option_var->description = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
|
||||
+106
-106
@@ -88,17 +88,17 @@ int
|
||||
plugin_valid (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
|
||||
|
||||
if (!plugin)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
if (ptr_plugin == plugin)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* plugin not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -111,17 +111,17 @@ struct t_weechat_plugin *
|
||||
plugin_search (const char *name)
|
||||
{
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
if (string_strcasecmp (ptr_plugin->name, name) == 0)
|
||||
return ptr_plugin;
|
||||
}
|
||||
|
||||
|
||||
/* plugin not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ const char *
|
||||
plugin_get_name (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
static char *plugin_core = PLUGIN_CORE;
|
||||
|
||||
|
||||
return (plugin) ? plugin->name : plugin_core;
|
||||
}
|
||||
|
||||
@@ -151,21 +151,21 @@ plugin_check_autoload (char *plugin_full_name)
|
||||
{
|
||||
int i, plugin_authorized, plugin_blacklisted;
|
||||
char *ptr_base_name, *base_name, *plugin_name, *pos;
|
||||
|
||||
|
||||
/* by default we can auto load all plugins */
|
||||
if (!plugin_autoload_array)
|
||||
return 1;
|
||||
|
||||
|
||||
/* get short name of plugin (filename without extension) */
|
||||
plugin_name = NULL;
|
||||
ptr_base_name = basename (plugin_full_name);
|
||||
if (!ptr_base_name)
|
||||
return 1;
|
||||
|
||||
|
||||
base_name = strdup (ptr_base_name);
|
||||
if (!base_name)
|
||||
return 1;
|
||||
|
||||
|
||||
if (CONFIG_STRING(config_plugin_extension)
|
||||
&& CONFIG_STRING(config_plugin_extension)[0])
|
||||
{
|
||||
@@ -177,12 +177,12 @@ plugin_check_autoload (char *plugin_full_name)
|
||||
}
|
||||
else
|
||||
plugin_name = strdup (base_name);
|
||||
|
||||
|
||||
free (base_name);
|
||||
|
||||
|
||||
if (!plugin_name)
|
||||
return 1;
|
||||
|
||||
|
||||
/* browse array and check if plugin is "authorized" or "blacklisted" */
|
||||
plugin_authorized = 0;
|
||||
plugin_blacklisted = 0;
|
||||
@@ -203,12 +203,12 @@ plugin_check_autoload (char *plugin_full_name)
|
||||
plugin_authorized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free (plugin_name);
|
||||
|
||||
|
||||
if (plugin_blacklisted)
|
||||
return 0;
|
||||
|
||||
|
||||
return plugin_authorized;
|
||||
}
|
||||
|
||||
@@ -247,15 +247,15 @@ plugin_load (const char *filename)
|
||||
char **argv;
|
||||
struct t_weechat_plugin *new_plugin;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
if (!filename)
|
||||
return NULL;
|
||||
|
||||
|
||||
full_name = util_search_full_lib_name (filename, "plugins");
|
||||
|
||||
|
||||
if (!full_name)
|
||||
return NULL;
|
||||
|
||||
|
||||
/*
|
||||
* if plugin must not be autoloaded, then return immediately
|
||||
* Note: the "plugin_autoload_array" variable is set only during auto-load,
|
||||
@@ -263,14 +263,14 @@ plugin_load (const char *filename)
|
||||
*/
|
||||
if (plugin_autoload_array && !plugin_check_autoload (full_name))
|
||||
return NULL;
|
||||
|
||||
|
||||
full_name2 = string_expand_home (full_name);
|
||||
if (full_name2)
|
||||
{
|
||||
free (full_name);
|
||||
full_name = full_name2;
|
||||
}
|
||||
|
||||
|
||||
handle = dlopen (full_name, RTLD_GLOBAL | RTLD_NOW);
|
||||
if (!handle)
|
||||
{
|
||||
@@ -286,7 +286,7 @@ plugin_load (const char *filename)
|
||||
free (full_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* look for plugin name */
|
||||
name = dlsym (handle, "weechat_plugin_name");
|
||||
if (!name)
|
||||
@@ -301,7 +301,7 @@ plugin_load (const char *filename)
|
||||
free (full_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* look for API version */
|
||||
api_version = dlsym (handle, "weechat_plugin_api_version");
|
||||
if (!api_version)
|
||||
@@ -339,7 +339,7 @@ plugin_load (const char *filename)
|
||||
free (full_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* check for plugin with same name */
|
||||
if (plugin_search (name))
|
||||
{
|
||||
@@ -352,7 +352,7 @@ plugin_load (const char *filename)
|
||||
free (full_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* look for plugin description */
|
||||
description = dlsym (handle, "weechat_plugin_description");
|
||||
if (!description)
|
||||
@@ -367,7 +367,7 @@ plugin_load (const char *filename)
|
||||
free (full_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* look for plugin author */
|
||||
author = dlsym (handle, "weechat_plugin_author");
|
||||
if (!author)
|
||||
@@ -382,7 +382,7 @@ plugin_load (const char *filename)
|
||||
free (full_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* look for plugin version */
|
||||
version = dlsym (handle, "weechat_plugin_version");
|
||||
if (!version)
|
||||
@@ -397,7 +397,7 @@ plugin_load (const char *filename)
|
||||
free (full_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* look for plugin license */
|
||||
license = dlsym (handle, "weechat_plugin_license");
|
||||
if (!license)
|
||||
@@ -412,10 +412,10 @@ plugin_load (const char *filename)
|
||||
free (full_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* look for plugin charset (optional, default is UTF-8) */
|
||||
charset = dlsym (handle, "weechat_plugin_charset");
|
||||
|
||||
|
||||
/* look for plugin init function */
|
||||
init_func = dlsym (handle, "weechat_plugin_init");
|
||||
if (!init_func)
|
||||
@@ -430,7 +430,7 @@ plugin_load (const char *filename)
|
||||
free (full_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* create new plugin */
|
||||
new_plugin = malloc (sizeof (*new_plugin));
|
||||
if (new_plugin)
|
||||
@@ -446,10 +446,10 @@ plugin_load (const char *filename)
|
||||
new_plugin->charset = (charset) ? strdup (charset) : NULL;
|
||||
ptr_option = config_weechat_debug_get (name);
|
||||
new_plugin->debug = (ptr_option) ? CONFIG_INTEGER(ptr_option) : 0;
|
||||
|
||||
|
||||
/* functions */
|
||||
new_plugin->plugin_get_name = &plugin_get_name;
|
||||
|
||||
|
||||
new_plugin->charset_set = &plugin_api_charset_set;
|
||||
new_plugin->iconv_to_internal = &string_iconv_to_internal;
|
||||
new_plugin->iconv_from_internal = &string_iconv_from_internal;
|
||||
@@ -481,7 +481,7 @@ plugin_load (const char *filename)
|
||||
new_plugin->string_decode_base64 = &string_decode_base64;
|
||||
new_plugin->string_is_command_char = &string_is_command_char;
|
||||
new_plugin->string_input_for_buffer = &string_input_for_buffer;
|
||||
|
||||
|
||||
new_plugin->utf8_has_8bits = &utf8_has_8bits;
|
||||
new_plugin->utf8_is_valid = &utf8_is_valid;
|
||||
new_plugin->utf8_normalize = &utf8_normalize;
|
||||
@@ -499,18 +499,18 @@ plugin_load (const char *filename)
|
||||
new_plugin->utf8_real_pos = &utf8_real_pos;
|
||||
new_plugin->utf8_pos = &utf8_pos;
|
||||
new_plugin->utf8_strndup = &utf8_strndup;
|
||||
|
||||
|
||||
new_plugin->mkdir_home = &util_mkdir_home;
|
||||
new_plugin->mkdir = &util_mkdir;
|
||||
new_plugin->mkdir_parents = &util_mkdir_parents;
|
||||
new_plugin->exec_on_files = &util_exec_on_files;
|
||||
new_plugin->file_get_content = &util_file_get_content;
|
||||
|
||||
|
||||
new_plugin->util_timeval_cmp = &util_timeval_cmp;
|
||||
new_plugin->util_timeval_diff = &util_timeval_diff;
|
||||
new_plugin->util_timeval_add = &util_timeval_add;
|
||||
new_plugin->util_get_time_string = &util_get_time_string;
|
||||
|
||||
|
||||
new_plugin->list_new = &weelist_new;
|
||||
new_plugin->list_add = &weelist_add;
|
||||
new_plugin->list_search = &weelist_search;
|
||||
@@ -526,7 +526,7 @@ plugin_load (const char *filename)
|
||||
new_plugin->list_remove = &weelist_remove;
|
||||
new_plugin->list_remove_all = &weelist_remove_all;
|
||||
new_plugin->list_free = &weelist_free;
|
||||
|
||||
|
||||
new_plugin->hashtable_new = &hashtable_new;
|
||||
new_plugin->hashtable_set_with_size = &hashtable_set_with_size;
|
||||
new_plugin->hashtable_set = &hashtable_set;
|
||||
@@ -540,7 +540,7 @@ plugin_load (const char *filename)
|
||||
new_plugin->hashtable_remove = &hashtable_remove;
|
||||
new_plugin->hashtable_remove_all = &hashtable_remove_all;
|
||||
new_plugin->hashtable_free = &hashtable_free;
|
||||
|
||||
|
||||
new_plugin->config_new = &config_file_new;
|
||||
new_plugin->config_new_section = &config_file_new_section;
|
||||
new_plugin->config_search_section = &config_file_search_section;
|
||||
@@ -580,16 +580,16 @@ plugin_load (const char *filename)
|
||||
new_plugin->config_set_plugin = &plugin_api_config_set_plugin;
|
||||
new_plugin->config_set_desc_plugin = &plugin_api_config_set_desc_plugin;
|
||||
new_plugin->config_unset_plugin = &plugin_api_config_unset_plugin;
|
||||
|
||||
|
||||
new_plugin->key_bind = &gui_key_bind_plugin;
|
||||
new_plugin->key_unbind = &gui_key_unbind_plugin;
|
||||
|
||||
|
||||
new_plugin->prefix = &plugin_api_prefix;
|
||||
new_plugin->color = &plugin_api_color;
|
||||
new_plugin->printf_date_tags = &gui_chat_printf_date_tags;
|
||||
new_plugin->printf_y = &gui_chat_printf_y;
|
||||
new_plugin->log_printf = &log_printf;
|
||||
|
||||
|
||||
new_plugin->hook_command = &hook_command;
|
||||
new_plugin->hook_command_run = &hook_command_run;
|
||||
new_plugin->hook_timer = &hook_timer;
|
||||
@@ -614,7 +614,7 @@ plugin_load (const char *filename)
|
||||
new_plugin->hook_focus = &hook_focus;
|
||||
new_plugin->unhook = &unhook;
|
||||
new_plugin->unhook_all = &unhook_all_plugin;
|
||||
|
||||
|
||||
new_plugin->buffer_new = &gui_buffer_new;
|
||||
new_plugin->buffer_search = &gui_buffer_search_by_name;
|
||||
new_plugin->buffer_search_main = &gui_buffer_search_main;
|
||||
@@ -629,13 +629,13 @@ plugin_load (const char *filename)
|
||||
new_plugin->buffer_set_pointer = &gui_buffer_set_pointer;
|
||||
new_plugin->buffer_string_replace_local_var = &gui_buffer_string_replace_local_var;
|
||||
new_plugin->buffer_match_list = &gui_buffer_match_list;
|
||||
|
||||
|
||||
new_plugin->window_search_with_buffer = &gui_window_search_with_buffer;
|
||||
new_plugin->window_get_integer = &gui_window_get_integer;
|
||||
new_plugin->window_get_string = &gui_window_get_string;
|
||||
new_plugin->window_get_pointer = &gui_window_get_pointer;
|
||||
new_plugin->window_set_title = &gui_window_set_title;
|
||||
|
||||
|
||||
new_plugin->nicklist_add_group = &gui_nicklist_add_group;
|
||||
new_plugin->nicklist_search_group = &gui_nicklist_search_group;
|
||||
new_plugin->nicklist_add_nick = &gui_nicklist_add_nick;
|
||||
@@ -651,7 +651,7 @@ plugin_load (const char *filename)
|
||||
new_plugin->nicklist_nick_get_string = &gui_nicklist_nick_get_string;
|
||||
new_plugin->nicklist_nick_get_pointer = &gui_nicklist_nick_get_pointer;
|
||||
new_plugin->nicklist_nick_set = &gui_nicklist_nick_set;
|
||||
|
||||
|
||||
new_plugin->bar_item_search = &gui_bar_item_search;
|
||||
new_plugin->bar_item_new = &gui_bar_item_new;
|
||||
new_plugin->bar_item_update = &gui_bar_item_update;
|
||||
@@ -661,15 +661,15 @@ plugin_load (const char *filename)
|
||||
new_plugin->bar_set = &gui_bar_set;
|
||||
new_plugin->bar_update = &gui_bar_update;
|
||||
new_plugin->bar_remove = &gui_bar_free;
|
||||
|
||||
|
||||
new_plugin->command = &plugin_api_command;
|
||||
|
||||
|
||||
new_plugin->network_pass_proxy = &network_pass_proxy;
|
||||
new_plugin->network_connect_to = &network_connect_to;
|
||||
|
||||
|
||||
new_plugin->info_get = &hook_info_get;
|
||||
new_plugin->info_get_hashtable = &hook_info_get_hashtable;
|
||||
|
||||
|
||||
new_plugin->infolist_new = &infolist_new;
|
||||
new_plugin->infolist_new_item = &infolist_new_item;
|
||||
new_plugin->infolist_new_var_integer = &infolist_new_var_integer;
|
||||
@@ -707,12 +707,12 @@ plugin_load (const char *filename)
|
||||
new_plugin->hdata_pointer = &hdata_pointer;
|
||||
new_plugin->hdata_time = &hdata_time;
|
||||
new_plugin->hdata_get_string = &hdata_get_string;
|
||||
|
||||
|
||||
new_plugin->upgrade_new = &upgrade_file_new;
|
||||
new_plugin->upgrade_write_object = &upgrade_file_write_object;
|
||||
new_plugin->upgrade_read = &upgrade_file_read;
|
||||
new_plugin->upgrade_close = &upgrade_file_close;
|
||||
|
||||
|
||||
/* add new plugin to list */
|
||||
new_plugin->prev_plugin = last_weechat_plugin;
|
||||
new_plugin->next_plugin = NULL;
|
||||
@@ -721,13 +721,13 @@ plugin_load (const char *filename)
|
||||
else
|
||||
weechat_plugins = new_plugin;
|
||||
last_weechat_plugin = new_plugin;
|
||||
|
||||
|
||||
/*
|
||||
* associate orphan buffers with this plugin (if asked during upgrade
|
||||
* process)
|
||||
*/
|
||||
gui_buffer_set_plugin_for_upgrade (name, new_plugin);
|
||||
|
||||
|
||||
/* build arguments for plugin */
|
||||
argc = 0;
|
||||
argv = NULL;
|
||||
@@ -759,13 +759,13 @@ plugin_load (const char *filename)
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* init plugin */
|
||||
rc = ((t_weechat_init_func *)init_func) (new_plugin, argc, argv);
|
||||
|
||||
|
||||
if (argv)
|
||||
free (argv);
|
||||
|
||||
|
||||
if (rc != WEECHAT_RC_OK)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
@@ -789,16 +789,16 @@ plugin_load (const char *filename)
|
||||
free (full_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if ((weechat_debug_core >= 1) || !plugin_quiet)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("Plugin \"%s\" loaded"),
|
||||
name);
|
||||
}
|
||||
|
||||
|
||||
free (full_name);
|
||||
|
||||
|
||||
return new_plugin;
|
||||
}
|
||||
|
||||
@@ -811,10 +811,10 @@ void
|
||||
plugin_auto_load_file (void *plugin, const char *filename)
|
||||
{
|
||||
char *pos;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
if (CONFIG_STRING(config_plugin_extension)
|
||||
&& CONFIG_STRING(config_plugin_extension)[0])
|
||||
{
|
||||
@@ -841,10 +841,10 @@ void
|
||||
plugin_auto_load ()
|
||||
{
|
||||
char *dir_name, *plugin_path, *plugin_path2;
|
||||
|
||||
|
||||
plugin_autoload_array = NULL;
|
||||
plugin_autoload_count = 0;
|
||||
|
||||
|
||||
if (CONFIG_STRING(config_plugin_autoload)
|
||||
&& CONFIG_STRING(config_plugin_autoload)[0])
|
||||
{
|
||||
@@ -852,7 +852,7 @@ plugin_auto_load ()
|
||||
",", 0, 0,
|
||||
&plugin_autoload_count);
|
||||
}
|
||||
|
||||
|
||||
/* auto-load plugins in WeeChat home dir */
|
||||
if (CONFIG_STRING(config_plugin_path)
|
||||
&& CONFIG_STRING(config_plugin_path)[0])
|
||||
@@ -872,7 +872,7 @@ plugin_auto_load ()
|
||||
if (plugin_path2)
|
||||
free (plugin_path2);
|
||||
}
|
||||
|
||||
|
||||
/* auto-load plugins in WeeChat global lib dir */
|
||||
dir_name = malloc (strlen (WEECHAT_LIBDIR) + 16);
|
||||
if (dir_name)
|
||||
@@ -882,7 +882,7 @@ plugin_auto_load ()
|
||||
util_exec_on_files (dir_name, 0, NULL, &plugin_auto_load_file);
|
||||
free (dir_name);
|
||||
}
|
||||
|
||||
|
||||
/* free autoload array */
|
||||
if (plugin_autoload_array)
|
||||
{
|
||||
@@ -901,19 +901,19 @@ plugin_remove (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
struct t_weechat_plugin *new_weechat_plugins;
|
||||
struct t_gui_buffer *ptr_buffer, *next_buffer;
|
||||
|
||||
|
||||
/* close buffers created by this plugin */
|
||||
ptr_buffer = gui_buffers;
|
||||
while (ptr_buffer)
|
||||
{
|
||||
next_buffer = ptr_buffer->next_buffer;
|
||||
|
||||
|
||||
if (ptr_buffer->plugin == plugin)
|
||||
gui_buffer_close (ptr_buffer);
|
||||
|
||||
|
||||
ptr_buffer = next_buffer;
|
||||
}
|
||||
|
||||
|
||||
/* remove plugin from list */
|
||||
if (last_weechat_plugin == plugin)
|
||||
last_weechat_plugin = plugin->prev_plugin;
|
||||
@@ -924,25 +924,25 @@ plugin_remove (struct t_weechat_plugin *plugin)
|
||||
}
|
||||
else
|
||||
new_weechat_plugins = plugin->next_plugin;
|
||||
|
||||
|
||||
if (plugin->next_plugin)
|
||||
(plugin->next_plugin)->prev_plugin = plugin->prev_plugin;
|
||||
|
||||
|
||||
/* remove all config files */
|
||||
config_file_free_all_plugin (plugin);
|
||||
|
||||
|
||||
/* remove all hooks */
|
||||
unhook_all_plugin (plugin);
|
||||
|
||||
|
||||
/* remove all infolists */
|
||||
infolist_free_all_plugin (plugin);
|
||||
|
||||
|
||||
/* remove all hdata */
|
||||
hdata_free_all_plugin (plugin);
|
||||
|
||||
|
||||
/* remove all bar items */
|
||||
gui_bar_item_free_all_plugin (plugin);
|
||||
|
||||
|
||||
/* free data */
|
||||
if (plugin->filename)
|
||||
free (plugin->filename);
|
||||
@@ -960,9 +960,9 @@ plugin_remove (struct t_weechat_plugin *plugin)
|
||||
free (plugin->license);
|
||||
if (plugin->charset)
|
||||
free (plugin->charset);
|
||||
|
||||
|
||||
free (plugin);
|
||||
|
||||
|
||||
weechat_plugins = new_weechat_plugins;
|
||||
}
|
||||
|
||||
@@ -975,15 +975,15 @@ plugin_unload (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
t_weechat_end_func *end_func;
|
||||
char *name;
|
||||
|
||||
|
||||
name = (plugin->name) ? strdup (plugin->name) : NULL;
|
||||
|
||||
|
||||
end_func = dlsym (plugin->handle, "weechat_plugin_end");
|
||||
if (end_func)
|
||||
(void) (end_func) (plugin);
|
||||
|
||||
|
||||
plugin_remove (plugin);
|
||||
|
||||
|
||||
if ((weechat_debug_core >= 1) || !plugin_quiet)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
@@ -1002,7 +1002,7 @@ void
|
||||
plugin_unload_name (const char *name)
|
||||
{
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
|
||||
|
||||
ptr_plugin = plugin_search (name);
|
||||
if (ptr_plugin)
|
||||
plugin_unload (ptr_plugin);
|
||||
@@ -1023,16 +1023,16 @@ void
|
||||
plugin_unload_all ()
|
||||
{
|
||||
int plugins_loaded;
|
||||
|
||||
|
||||
plugins_loaded = (weechat_plugins) ? 1 : 0;
|
||||
|
||||
|
||||
plugin_quiet = 1;
|
||||
while (weechat_plugins)
|
||||
{
|
||||
plugin_unload (last_weechat_plugin);
|
||||
}
|
||||
plugin_quiet = 0;
|
||||
|
||||
|
||||
if (plugins_loaded)
|
||||
{
|
||||
gui_chat_printf (NULL, _("Plugins unloaded"));
|
||||
@@ -1048,7 +1048,7 @@ plugin_reload_name (const char *name)
|
||||
{
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
char *filename;
|
||||
|
||||
|
||||
ptr_plugin = plugin_search (name);
|
||||
if (ptr_plugin)
|
||||
{
|
||||
@@ -1082,16 +1082,16 @@ plugin_display_short_list ()
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
struct t_weelist *list;
|
||||
struct t_weelist_item *ptr_item;
|
||||
|
||||
|
||||
if (weechat_plugins)
|
||||
{
|
||||
list = weelist_new ();
|
||||
if (list)
|
||||
{
|
||||
plugins_loaded = _("Plugins loaded:");
|
||||
|
||||
|
||||
length = strlen (plugins_loaded) + 1;
|
||||
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
@@ -1099,7 +1099,7 @@ plugin_display_short_list ()
|
||||
weelist_add (list, ptr_plugin->name, WEECHAT_LIST_POS_SORT, NULL);
|
||||
}
|
||||
length++;
|
||||
|
||||
|
||||
buf = malloc (length);
|
||||
if (buf)
|
||||
{
|
||||
@@ -1132,11 +1132,11 @@ plugin_init (int auto_load, int argc, char *argv[])
|
||||
|
||||
/* init plugin API (create some hooks) */
|
||||
plugin_api_init ();
|
||||
|
||||
|
||||
/* read plugins options on disk */
|
||||
plugin_config_init ();
|
||||
plugin_config_read ();
|
||||
|
||||
|
||||
/* auto-load plugins if asked */
|
||||
if (auto_load)
|
||||
{
|
||||
@@ -1160,10 +1160,10 @@ plugin_end ()
|
||||
{
|
||||
/* write plugins config options */
|
||||
plugin_config_write ();
|
||||
|
||||
|
||||
/* unload all plugins */
|
||||
plugin_unload_all ();
|
||||
|
||||
|
||||
/* free all plugin options */
|
||||
plugin_config_end ();
|
||||
}
|
||||
@@ -1176,10 +1176,10 @@ struct t_hdata *
|
||||
plugin_hdata_plugin_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_plugin", "next_plugin");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1210,14 +1210,14 @@ plugin_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_weechat_plugin *plugin)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !plugin)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_pointer (ptr_item, "pointer", plugin))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "filename", plugin->filename))
|
||||
@@ -1238,7 +1238,7 @@ plugin_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "debug", plugin->debug))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1250,7 +1250,7 @@ void
|
||||
plugin_print_log ()
|
||||
{
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ relay_buffer_refresh (const char *hotlist)
|
||||
char *str_recv, *str_sent;
|
||||
int i, length, line;
|
||||
struct tm *date_tmp;
|
||||
|
||||
|
||||
if (relay_buffer)
|
||||
{
|
||||
weechat_buffer_clear (relay_buffer);
|
||||
@@ -83,7 +83,7 @@ relay_buffer_refresh (const char *hotlist)
|
||||
weechat_config_string (relay_config_color_text_selected) :
|
||||
weechat_config_string (relay_config_color_text),
|
||||
weechat_config_string (relay_config_color_text_bg));
|
||||
|
||||
|
||||
snprintf (status, sizeof (status),
|
||||
"%s", _(relay_client_status_string[ptr_client->status]));
|
||||
length = weechat_utf8_strlen_screen (status);
|
||||
@@ -94,7 +94,7 @@ relay_buffer_refresh (const char *hotlist)
|
||||
strcat (status, " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
date_tmp = localtime (&(ptr_client->start_time));
|
||||
strftime (date_start, sizeof (date_start),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
@@ -105,7 +105,7 @@ relay_buffer_refresh (const char *hotlist)
|
||||
strftime (date_end, sizeof (date_end),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
}
|
||||
|
||||
|
||||
/* first line with status and start time */
|
||||
weechat_printf_y (relay_buffer, (line * 2) + 2,
|
||||
_("%s%s[%s%s%s%s] %s (started on: %s%s%s%s)"),
|
||||
@@ -121,7 +121,7 @@ relay_buffer_refresh (const char *hotlist)
|
||||
(ptr_client->end_time > 0) ? ", " : "",
|
||||
(ptr_client->end_time > 0) ? _("ended on: ") : "",
|
||||
(ptr_client->end_time > 0) ? date_end : "");
|
||||
|
||||
|
||||
/* second line with protocol and bytes recv/sent */
|
||||
str_recv = weechat_string_format_size (ptr_client->bytes_recv);
|
||||
str_sent = weechat_string_format_size (ptr_client->bytes_sent);
|
||||
@@ -137,7 +137,7 @@ relay_buffer_refresh (const char *hotlist)
|
||||
free (str_recv);
|
||||
if (str_sent)
|
||||
free (str_sent);
|
||||
|
||||
|
||||
line++;
|
||||
}
|
||||
if (hotlist)
|
||||
@@ -155,10 +155,10 @@ relay_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
|
||||
const char *input_data)
|
||||
{
|
||||
struct t_relay_client *client, *ptr_client, *next_client;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (buffer == relay_raw_buffer)
|
||||
{
|
||||
if (weechat_strcasecmp (input_data, "q") == 0)
|
||||
@@ -167,7 +167,7 @@ relay_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
|
||||
else if (buffer == relay_buffer)
|
||||
{
|
||||
client = relay_client_search_by_number (relay_buffer_selected_line);
|
||||
|
||||
|
||||
/* disconnect client */
|
||||
if (weechat_strcasecmp (input_data, "d") == 0)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ relay_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ relay_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (buffer == relay_raw_buffer)
|
||||
{
|
||||
relay_raw_buffer = NULL;
|
||||
@@ -227,7 +227,7 @@ relay_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
{
|
||||
relay_buffer = NULL;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -243,11 +243,11 @@ relay_buffer_open ()
|
||||
relay_buffer = weechat_buffer_new (RELAY_BUFFER_NAME,
|
||||
&relay_buffer_input_cb, NULL,
|
||||
&relay_buffer_close_cb, NULL);
|
||||
|
||||
|
||||
/* failed to create buffer ? then exit */
|
||||
if (!relay_buffer)
|
||||
return;
|
||||
|
||||
|
||||
weechat_buffer_set (relay_buffer, "type", "free");
|
||||
weechat_buffer_set (relay_buffer, "title", _("List of clients for relay"));
|
||||
weechat_buffer_set (relay_buffer, "key_bind_meta2-A", "/relay up");
|
||||
|
||||
@@ -53,7 +53,7 @@ int
|
||||
relay_client_irc_command_relayed (const char *irc_command)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (irc_command)
|
||||
{
|
||||
for (i = 0; relay_client_irc_relay_commands[i]; i++)
|
||||
@@ -62,7 +62,7 @@ relay_client_irc_command_relayed (const char *irc_command)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* command must NOT be relayed to client */
|
||||
return 0;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ int
|
||||
relay_client_irc_command_ignored (const char *irc_command)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (irc_command)
|
||||
{
|
||||
for (i = 0; relay_client_irc_ignore_commands[i]; i++)
|
||||
@@ -85,7 +85,7 @@ relay_client_irc_command_ignored (const char *irc_command)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* command must NOT be relayed to client */
|
||||
return 0;
|
||||
}
|
||||
@@ -98,10 +98,10 @@ struct t_hashtable *
|
||||
relay_client_irc_message_parse (const char *message)
|
||||
{
|
||||
struct t_hashtable *hash_msg, *hash_parsed;
|
||||
|
||||
|
||||
hash_msg = NULL;
|
||||
hash_parsed = NULL;
|
||||
|
||||
|
||||
hash_msg = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -124,11 +124,11 @@ relay_client_irc_message_parse (const char *message)
|
||||
weechat_prefix ("error"), RELAY_PLUGIN_NAME);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (hash_msg)
|
||||
weechat_hashtable_free (hash_msg);
|
||||
|
||||
|
||||
return hash_parsed;
|
||||
}
|
||||
|
||||
@@ -143,23 +143,23 @@ relay_client_irc_sendf (struct t_relay_client *client, const char *format, ...)
|
||||
char *pos, hash_key[32], *message;
|
||||
const char *str_message;
|
||||
struct t_hashtable *hashtable_in, *hashtable_out;
|
||||
|
||||
|
||||
if (!client)
|
||||
return 0;
|
||||
|
||||
|
||||
weechat_va_format (format);
|
||||
if (!vbuffer)
|
||||
return 0;
|
||||
|
||||
|
||||
total_sent = 0;
|
||||
|
||||
|
||||
pos = strchr (vbuffer, '\r');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
pos = strchr (vbuffer, '\n');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
|
||||
|
||||
hashtable_in = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -204,11 +204,11 @@ relay_client_irc_sendf (struct t_relay_client *client, const char *format, ...)
|
||||
}
|
||||
weechat_hashtable_free (hashtable_in);
|
||||
}
|
||||
|
||||
|
||||
client->bytes_sent += total_sent;
|
||||
|
||||
|
||||
free (vbuffer);
|
||||
|
||||
|
||||
return total_sent;
|
||||
}
|
||||
|
||||
@@ -226,14 +226,14 @@ relay_client_irc_signal_irc_in2_cb (void *data, const char *signal,
|
||||
struct t_relay_client *client;
|
||||
const char *ptr_msg, *irc_nick, *irc_host, *irc_command, *irc_args;
|
||||
struct t_hashtable *hash_parsed;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
client = (struct t_relay_client *)data;
|
||||
ptr_msg = (const char *)signal_data;
|
||||
|
||||
|
||||
if (weechat_relay_plugin->debug >= 2)
|
||||
{
|
||||
weechat_printf (NULL, "%s: irc_in2: client: %s, data: %s",
|
||||
@@ -241,7 +241,7 @@ relay_client_irc_signal_irc_in2_cb (void *data, const char *signal,
|
||||
client->protocol_args,
|
||||
ptr_msg);
|
||||
}
|
||||
|
||||
|
||||
hash_parsed = relay_client_irc_message_parse (ptr_msg);
|
||||
if (hash_parsed)
|
||||
{
|
||||
@@ -261,7 +261,7 @@ relay_client_irc_signal_irc_in2_cb (void *data, const char *signal,
|
||||
RELAY_IRC_DATA(client, nick) = strdup ((irc_args[0] == ':') ?
|
||||
irc_args + 1 : irc_args);
|
||||
}
|
||||
|
||||
|
||||
/* relay all commands to client, but not ping/pong */
|
||||
if (irc_command
|
||||
&& (weechat_strcasecmp (irc_command, "ping") != 0)
|
||||
@@ -272,10 +272,10 @@ relay_client_irc_signal_irc_in2_cb (void *data, const char *signal,
|
||||
irc_command,
|
||||
irc_args);
|
||||
}
|
||||
|
||||
|
||||
weechat_hashtable_free (hash_parsed);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -293,9 +293,9 @@ relay_client_irc_tag_relay_client_id (const char *tags)
|
||||
char **argv, *error;
|
||||
int result, argc, i;
|
||||
long number;
|
||||
|
||||
|
||||
result = -1;
|
||||
|
||||
|
||||
if (tags && tags[0])
|
||||
{
|
||||
argv = weechat_string_split (tags, ",", 0, 0, &argc);
|
||||
@@ -317,7 +317,7 @@ relay_client_irc_tag_relay_client_id (const char *tags)
|
||||
weechat_string_free_split (argv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -339,24 +339,24 @@ relay_client_irc_signal_irc_outtags_cb (void *data, const char *signal,
|
||||
char *pos, *tags, *irc_channel, *message;
|
||||
struct t_infolist *infolist_nick;
|
||||
char str_infolist_args[256];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
client = (struct t_relay_client *)data;
|
||||
|
||||
|
||||
tags = NULL;
|
||||
|
||||
|
||||
message = strdup ((char *)signal_data);
|
||||
if (!message)
|
||||
goto end;
|
||||
pos = strchr (message, '\r');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
|
||||
|
||||
ptr_message = message;
|
||||
|
||||
|
||||
if (weechat_relay_plugin->debug >= 2)
|
||||
{
|
||||
weechat_printf (NULL, "%s: irc_out: client: %s, message: %s",
|
||||
@@ -364,7 +364,7 @@ relay_client_irc_signal_irc_outtags_cb (void *data, const char *signal,
|
||||
client->protocol_args,
|
||||
message);
|
||||
}
|
||||
|
||||
|
||||
pos = strchr (ptr_message, ';');
|
||||
if (pos)
|
||||
{
|
||||
@@ -372,7 +372,7 @@ relay_client_irc_signal_irc_outtags_cb (void *data, const char *signal,
|
||||
tags = weechat_strndup (ptr_message, pos - ptr_message);
|
||||
ptr_message = pos + 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* We check if there is a tag "relay_client_NNN" and if NNN (numeric)
|
||||
* is equal to current client, then we ignore message, because message
|
||||
@@ -381,17 +381,17 @@ relay_client_irc_signal_irc_outtags_cb (void *data, const char *signal,
|
||||
*/
|
||||
if (relay_client_irc_tag_relay_client_id (tags) == client->id)
|
||||
goto end;
|
||||
|
||||
|
||||
hash_parsed = relay_client_irc_message_parse (ptr_message);
|
||||
if (hash_parsed)
|
||||
{
|
||||
irc_command = weechat_hashtable_get (hash_parsed, "command");
|
||||
irc_args = weechat_hashtable_get (hash_parsed, "arguments");
|
||||
|
||||
|
||||
pos = strchr (irc_args, ' ');
|
||||
irc_channel = (pos) ?
|
||||
weechat_strndup (irc_args, pos - irc_args) : strdup (irc_args);
|
||||
|
||||
|
||||
/* if command has to be relayed, relay it to client */
|
||||
if (irc_command && irc_command[0]
|
||||
&& irc_channel && irc_channel[0]
|
||||
@@ -403,12 +403,12 @@ relay_client_irc_signal_irc_outtags_cb (void *data, const char *signal,
|
||||
client->protocol_args,
|
||||
irc_channel,
|
||||
RELAY_IRC_DATA(client, nick));
|
||||
|
||||
|
||||
host = NULL;
|
||||
infolist_nick = weechat_infolist_get ("irc_nick", NULL, str_infolist_args);
|
||||
if (infolist_nick && weechat_infolist_next (infolist_nick))
|
||||
host = weechat_infolist_string (infolist_nick, "host");
|
||||
|
||||
|
||||
/* send message to client */
|
||||
relay_client_irc_sendf (client,
|
||||
":%s%s%s %s",
|
||||
@@ -416,7 +416,7 @@ relay_client_irc_signal_irc_outtags_cb (void *data, const char *signal,
|
||||
(host && host[0]) ? "!" : "",
|
||||
(host && host[0]) ? host : "",
|
||||
ptr_message);
|
||||
|
||||
|
||||
if (infolist_nick)
|
||||
weechat_infolist_free (infolist_nick);
|
||||
}
|
||||
@@ -424,13 +424,13 @@ relay_client_irc_signal_irc_outtags_cb (void *data, const char *signal,
|
||||
free (irc_channel);
|
||||
weechat_hashtable_free (hash_parsed);
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (message)
|
||||
free (message);
|
||||
if (tags)
|
||||
free (tags);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -445,19 +445,19 @@ relay_client_irc_signal_irc_disc_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
struct t_relay_client *client;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
|
||||
client = (struct t_relay_client *)data;
|
||||
|
||||
|
||||
if (strcmp ((char *)signal_data, client->protocol_args) == 0)
|
||||
{
|
||||
relay_client_set_status (client, RELAY_STATUS_DISCONNECTED);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ relay_client_irc_send_join (struct t_relay_client *client,
|
||||
char *host;
|
||||
int length, length_nicks;
|
||||
struct t_infolist *infolist_nick, *infolist_channel, *infolist_nicks;
|
||||
|
||||
|
||||
length = strlen (client->protocol_args) + 1 + strlen (channel) + 1
|
||||
+ strlen (RELAY_IRC_DATA(client, nick)) + 1;
|
||||
infolist_name = malloc (length);
|
||||
@@ -619,11 +619,11 @@ relay_client_irc_input_send (struct t_relay_client *client,
|
||||
{
|
||||
char buf_beginning[1024], *buf;
|
||||
int length_beginning, length_vbuffer;
|
||||
|
||||
|
||||
weechat_va_format (format);
|
||||
if (!vbuffer)
|
||||
return;
|
||||
|
||||
|
||||
snprintf (buf_beginning, sizeof (buf_beginning),
|
||||
"%s;%s;%d;relay_client_%d;",
|
||||
client->protocol_args,
|
||||
@@ -645,7 +645,7 @@ relay_client_irc_input_send (struct t_relay_client *client,
|
||||
"%s: irc_input_send: \"%s\"",
|
||||
RELAY_PLUGIN_NAME, buf);
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_input_send",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
buf);
|
||||
@@ -662,7 +662,7 @@ void
|
||||
relay_client_irc_hook_signals (struct t_relay_client *client)
|
||||
{
|
||||
char str_signal_name[128];
|
||||
|
||||
|
||||
/*
|
||||
* hook signal "xxx,irc_in2_*" to catch IRC data received from
|
||||
* this server
|
||||
@@ -674,7 +674,7 @@ relay_client_irc_hook_signals (struct t_relay_client *client)
|
||||
weechat_hook_signal (str_signal_name,
|
||||
&relay_client_irc_signal_irc_in2_cb,
|
||||
client);
|
||||
|
||||
|
||||
/*
|
||||
* hook signal "xxx,irc_outtags_*" to catch IRC data sent to
|
||||
* this server
|
||||
@@ -686,7 +686,7 @@ relay_client_irc_hook_signals (struct t_relay_client *client)
|
||||
weechat_hook_signal (str_signal_name,
|
||||
&relay_client_irc_signal_irc_outtags_cb,
|
||||
client);
|
||||
|
||||
|
||||
/*
|
||||
* hook signal "irc_server_disconnected" to disconnect client if
|
||||
* connection to server is lost
|
||||
@@ -709,23 +709,23 @@ relay_client_irc_recv_one_msg (struct t_relay_client *client, char *data)
|
||||
const char *nick, *irc_is_channel, *isupport;
|
||||
struct t_hashtable *hash_parsed;
|
||||
struct t_infolist *infolist_server;
|
||||
|
||||
|
||||
hash_parsed = NULL;
|
||||
|
||||
|
||||
/* remove \r at the end of message */
|
||||
pos = strchr (data, '\r');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
|
||||
|
||||
/* display debug message */
|
||||
if (weechat_relay_plugin->debug >= 2)
|
||||
{
|
||||
weechat_printf (NULL, "%s: recv from client: \"%s\"",
|
||||
RELAY_PLUGIN_NAME, data);
|
||||
}
|
||||
|
||||
|
||||
relay_raw_print (client, 0, data);
|
||||
|
||||
|
||||
/* parse IRC message */
|
||||
hash_parsed = relay_client_irc_message_parse (data);
|
||||
if (!hash_parsed)
|
||||
@@ -733,7 +733,7 @@ relay_client_irc_recv_one_msg (struct t_relay_client *client, char *data)
|
||||
irc_command = weechat_hashtable_get (hash_parsed, "command");
|
||||
irc_channel = weechat_hashtable_get (hash_parsed, "channel");
|
||||
irc_args = weechat_hashtable_get (hash_parsed, "arguments");
|
||||
|
||||
|
||||
/* process the message */
|
||||
if (irc_command && (weechat_strcasecmp (irc_command, "nick") == 0))
|
||||
{
|
||||
@@ -803,9 +803,9 @@ relay_client_irc_recv_one_msg (struct t_relay_client *client, char *data)
|
||||
RELAY_STATUS_DISCONNECTED);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
RELAY_IRC_DATA(client, connected) = 1;
|
||||
|
||||
|
||||
/*
|
||||
* send nick to client if server nick is different of nick asked
|
||||
* by client with command NICK
|
||||
@@ -820,7 +820,7 @@ relay_client_irc_recv_one_msg (struct t_relay_client *client, char *data)
|
||||
free (RELAY_IRC_DATA(client, nick));
|
||||
RELAY_IRC_DATA(client, nick) = strdup (nick);
|
||||
}
|
||||
|
||||
|
||||
relay_client_irc_sendf (client,
|
||||
":%s 001 %s :Welcome to the Internet "
|
||||
"Relay Chat Network %s!%s@proxy",
|
||||
@@ -889,10 +889,10 @@ relay_client_irc_recv_one_msg (struct t_relay_client *client, char *data)
|
||||
":%s 422 %s :MOTD File is missing",
|
||||
RELAY_IRC_DATA(client, address),
|
||||
RELAY_IRC_DATA(client, nick));
|
||||
|
||||
|
||||
/* hook signals */
|
||||
relay_client_irc_hook_signals (client);
|
||||
|
||||
|
||||
/* send JOIN for all channels on server to client */
|
||||
relay_client_irc_send_join_channels (client);
|
||||
}
|
||||
@@ -964,7 +964,7 @@ relay_client_irc_recv_one_msg (struct t_relay_client *client, char *data)
|
||||
data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (hash_parsed)
|
||||
weechat_hashtable_free (hash_parsed);
|
||||
@@ -979,7 +979,7 @@ relay_client_irc_recv (struct t_relay_client *client, const char *data)
|
||||
{
|
||||
char **items;
|
||||
int items_count, i;
|
||||
|
||||
|
||||
items = weechat_string_split (data, "\n", 0, 0, &items_count);
|
||||
for (i = 0; i < items_count; i++)
|
||||
{
|
||||
@@ -1024,9 +1024,9 @@ relay_client_irc_alloc (struct t_relay_client *client)
|
||||
{
|
||||
struct t_relay_client_irc_data *irc_data;
|
||||
const char *password;
|
||||
|
||||
|
||||
password = weechat_config_string (relay_config_network_password);
|
||||
|
||||
|
||||
client->protocol_data = malloc (sizeof (*irc_data));
|
||||
if (client->protocol_data)
|
||||
{
|
||||
@@ -1051,7 +1051,7 @@ relay_client_irc_alloc_with_infolist (struct t_relay_client *client,
|
||||
struct t_infolist *infolist)
|
||||
{
|
||||
struct t_relay_client_irc_data *irc_data;
|
||||
|
||||
|
||||
client->protocol_data = malloc (sizeof (*irc_data));
|
||||
if (client->protocol_data)
|
||||
{
|
||||
@@ -1095,9 +1095,9 @@ relay_client_irc_free (struct t_relay_client *client)
|
||||
weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_outtags));
|
||||
if (RELAY_IRC_DATA(client, hook_signal_irc_disc))
|
||||
weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_disc));
|
||||
|
||||
|
||||
free (client->protocol_data);
|
||||
|
||||
|
||||
client->protocol_data = NULL;
|
||||
}
|
||||
}
|
||||
@@ -1113,7 +1113,7 @@ relay_client_irc_add_to_infolist (struct t_infolist_item *item,
|
||||
{
|
||||
if (!item || !client)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_string (item, "address", RELAY_IRC_DATA(client, address)))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (item, "password_ok", RELAY_IRC_DATA(client, password_ok)))
|
||||
@@ -1130,7 +1130,7 @@ relay_client_irc_add_to_infolist (struct t_infolist_item *item,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_pointer (item, "hook_signal_irc_disc", RELAY_IRC_DATA(client, hook_signal_irc_disc)))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,19 +45,19 @@ relay_client_weechat_sendf (struct t_relay_client *client,
|
||||
{
|
||||
char str_length[8];
|
||||
int length_vbuffer, num_sent, total_sent;
|
||||
|
||||
|
||||
if (!client)
|
||||
return 0;
|
||||
|
||||
|
||||
weechat_va_format (format);
|
||||
if (!vbuffer)
|
||||
return 0;
|
||||
length_vbuffer = strlen (vbuffer);
|
||||
|
||||
|
||||
total_sent = 0;
|
||||
|
||||
|
||||
snprintf (str_length, sizeof (str_length), "%07d", length_vbuffer);
|
||||
|
||||
|
||||
num_sent = send (client->sock, str_length, 7, 0);
|
||||
client->bytes_sent += 7;
|
||||
total_sent += num_sent;
|
||||
@@ -67,7 +67,7 @@ relay_client_weechat_sendf (struct t_relay_client *client,
|
||||
client->bytes_sent += length_vbuffer;
|
||||
total_sent += num_sent;
|
||||
}
|
||||
|
||||
|
||||
if (num_sent < 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -75,7 +75,7 @@ relay_client_weechat_sendf (struct t_relay_client *client,
|
||||
weechat_prefix ("error"), RELAY_PLUGIN_NAME,
|
||||
strerror (errno));
|
||||
}
|
||||
|
||||
|
||||
return total_sent;
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ relay_client_weechat_send_infolist (struct t_relay_client *client,
|
||||
const char *fields;
|
||||
char **argv;
|
||||
int i, argc, size;
|
||||
|
||||
|
||||
relay_client_weechat_sendf (client, "name %s", name);
|
||||
|
||||
|
||||
while (weechat_infolist_next (infolist))
|
||||
{
|
||||
fields = weechat_infolist_fields (infolist);
|
||||
@@ -154,16 +154,16 @@ relay_client_weechat_recv_one_msg (struct t_relay_client *client, char *data)
|
||||
{
|
||||
char *pos;
|
||||
struct t_infolist *infolist;
|
||||
|
||||
|
||||
pos = strchr (data, '\r');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
|
||||
|
||||
if (weechat_relay_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL, "relay: weechat: \"%s\"", data);
|
||||
}
|
||||
|
||||
|
||||
if (weechat_strcasecmp (data, "quit") == 0)
|
||||
relay_client_set_status (client, RELAY_STATUS_DISCONNECTED);
|
||||
else
|
||||
@@ -186,7 +186,7 @@ relay_client_weechat_recv (struct t_relay_client *client, const char *data)
|
||||
{
|
||||
char **items;
|
||||
int items_count, i;
|
||||
|
||||
|
||||
items = weechat_string_split (data, "\n", 0, 0, &items_count);
|
||||
for (i = 0; i < items_count; i++)
|
||||
{
|
||||
@@ -204,7 +204,7 @@ void
|
||||
relay_client_weechat_alloc (struct t_relay_client *client)
|
||||
{
|
||||
struct t_relay_client_weechat_data *weechat_data;
|
||||
|
||||
|
||||
client->protocol_data = malloc (sizeof (*weechat_data));
|
||||
if (client->protocol_data)
|
||||
{
|
||||
@@ -222,10 +222,10 @@ relay_client_weechat_alloc_with_infolist (struct t_relay_client *client,
|
||||
struct t_infolist *infolist)
|
||||
{
|
||||
struct t_relay_client_weechat_data *weechat_data;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) infolist;
|
||||
|
||||
|
||||
client->protocol_data = malloc (sizeof (*weechat_data));
|
||||
if (client->protocol_data)
|
||||
{
|
||||
@@ -256,7 +256,7 @@ relay_client_weechat_add_to_infolist (struct t_infolist_item *item,
|
||||
{
|
||||
if (!item || !client)
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,17 +61,17 @@ int
|
||||
relay_client_valid (struct t_relay_client *client)
|
||||
{
|
||||
struct t_relay_client *ptr_client;
|
||||
|
||||
|
||||
if (!client)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_client = relay_clients; ptr_client;
|
||||
ptr_client = ptr_client->next_client)
|
||||
{
|
||||
if (ptr_client == client)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* client not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ relay_client_search_by_number (int number)
|
||||
{
|
||||
struct t_relay_client *ptr_client;
|
||||
int i;
|
||||
|
||||
|
||||
i = 0;
|
||||
for (ptr_client = relay_clients; ptr_client;
|
||||
ptr_client = ptr_client->next_client)
|
||||
@@ -94,7 +94,7 @@ relay_client_search_by_number (int number)
|
||||
return ptr_client;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
/* client not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -109,12 +109,12 @@ relay_client_recv_cb (void *arg_client, int fd)
|
||||
struct t_relay_client *client;
|
||||
static char buffer[4096 + 2];
|
||||
int num_read;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) fd;
|
||||
|
||||
|
||||
client = (struct t_relay_client *)arg_client;
|
||||
|
||||
|
||||
num_read = recv (client->sock, buffer, sizeof (buffer) - 1, 0);
|
||||
if (num_read > 0)
|
||||
{
|
||||
@@ -137,7 +137,7 @@ relay_client_recv_cb (void *arg_client, int fd)
|
||||
{
|
||||
relay_client_set_status (client, RELAY_STATUS_DISCONNECTED);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ struct t_relay_client *
|
||||
relay_client_new (int sock, char *address, struct t_relay_server *server)
|
||||
{
|
||||
struct t_relay_client *new_client;
|
||||
|
||||
|
||||
new_client = malloc (sizeof (*new_client));
|
||||
if (new_client)
|
||||
{
|
||||
@@ -166,7 +166,7 @@ relay_client_new (int sock, char *address, struct t_relay_server *server)
|
||||
new_client->last_activity = new_client->start_time;
|
||||
new_client->bytes_recv = 0;
|
||||
new_client->bytes_sent = 0;
|
||||
|
||||
|
||||
new_client->protocol_data = NULL;
|
||||
switch (new_client->protocol)
|
||||
{
|
||||
@@ -179,7 +179,7 @@ relay_client_new (int sock, char *address, struct t_relay_server *server)
|
||||
case RELAY_NUM_PROTOCOLS:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
new_client->prev_client = NULL;
|
||||
new_client->next_client = relay_clients;
|
||||
if (relay_clients)
|
||||
@@ -187,7 +187,7 @@ relay_client_new (int sock, char *address, struct t_relay_server *server)
|
||||
else
|
||||
last_relay_client = new_client;
|
||||
relay_clients = new_client;
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("%s: new client from %s%s%s on port %d (id: %d, relaying: %s.%s)"),
|
||||
RELAY_PLUGIN_NAME,
|
||||
@@ -198,12 +198,12 @@ relay_client_new (int sock, char *address, struct t_relay_server *server)
|
||||
new_client->id,
|
||||
relay_protocol_string[new_client->protocol],
|
||||
new_client->protocol_args);
|
||||
|
||||
|
||||
new_client->hook_fd = weechat_hook_fd (new_client->sock,
|
||||
1, 0, 0,
|
||||
&relay_client_recv_cb,
|
||||
new_client);
|
||||
|
||||
|
||||
relay_client_count++;
|
||||
|
||||
if (!relay_buffer
|
||||
@@ -211,7 +211,7 @@ relay_client_new (int sock, char *address, struct t_relay_server *server)
|
||||
{
|
||||
relay_buffer_open ();
|
||||
}
|
||||
|
||||
|
||||
relay_buffer_refresh (WEECHAT_HOTLIST_PRIVATE);
|
||||
}
|
||||
else
|
||||
@@ -220,7 +220,7 @@ relay_client_new (int sock, char *address, struct t_relay_server *server)
|
||||
_("%s%s: not enough memory for new client"),
|
||||
weechat_prefix ("error"), RELAY_PLUGIN_NAME);
|
||||
}
|
||||
|
||||
|
||||
return new_client;
|
||||
}
|
||||
|
||||
@@ -233,11 +233,11 @@ relay_client_set_status (struct t_relay_client *client,
|
||||
enum t_relay_status status)
|
||||
{
|
||||
client->status = status;
|
||||
|
||||
|
||||
if (RELAY_CLIENT_HAS_ENDED(client->status))
|
||||
{
|
||||
client->end_time = time (NULL);
|
||||
|
||||
|
||||
if (client->hook_fd)
|
||||
{
|
||||
weechat_unhook (client->hook_fd);
|
||||
@@ -279,14 +279,14 @@ relay_client_set_status (struct t_relay_client *client,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (client->sock >= 0)
|
||||
{
|
||||
close (client->sock);
|
||||
client->sock = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
relay_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
}
|
||||
|
||||
@@ -298,10 +298,10 @@ void
|
||||
relay_client_free (struct t_relay_client *client)
|
||||
{
|
||||
struct t_relay_client *new_relay_clients;
|
||||
|
||||
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
|
||||
/* remove client from list */
|
||||
if (last_relay_client == client)
|
||||
last_relay_client = client->prev_client;
|
||||
@@ -314,7 +314,7 @@ relay_client_free (struct t_relay_client *client)
|
||||
new_relay_clients = client->next_client;
|
||||
if (client->next_client)
|
||||
(client->next_client)->prev_client = client->prev_client;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (client->address)
|
||||
free (client->address);
|
||||
@@ -336,11 +336,11 @@ relay_client_free (struct t_relay_client *client)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free (client);
|
||||
|
||||
|
||||
relay_clients = new_relay_clients;
|
||||
|
||||
|
||||
relay_client_count--;
|
||||
if (relay_buffer_selected_line >= relay_client_count)
|
||||
{
|
||||
@@ -383,7 +383,7 @@ void
|
||||
relay_client_disconnect_all ()
|
||||
{
|
||||
struct t_relay_client *ptr_client;
|
||||
|
||||
|
||||
for (ptr_client = relay_clients; ptr_client;
|
||||
ptr_client = ptr_client->next_client)
|
||||
{
|
||||
@@ -402,10 +402,10 @@ relay_client_add_to_infolist (struct t_infolist *infolist,
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
char value[128];
|
||||
|
||||
|
||||
if (!infolist || !client)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
@@ -442,7 +442,7 @@ relay_client_add_to_infolist (struct t_infolist *infolist,
|
||||
snprintf (value, sizeof (value), "%lu", client->bytes_sent);
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "bytes_sent", value))
|
||||
return 0;
|
||||
|
||||
|
||||
switch (client->protocol)
|
||||
{
|
||||
case RELAY_PROTOCOL_WEECHAT:
|
||||
@@ -454,7 +454,7 @@ relay_client_add_to_infolist (struct t_infolist *infolist,
|
||||
case RELAY_NUM_PROTOCOLS:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ void
|
||||
relay_client_print_log ()
|
||||
{
|
||||
struct t_relay_client *ptr_client;
|
||||
|
||||
|
||||
for (ptr_client = relay_clients; ptr_client;
|
||||
ptr_client = ptr_client->next_client)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ relay_command_client_list (int full)
|
||||
int i;
|
||||
char date_start[128], date_activity[128];
|
||||
struct tm *date_tmp;
|
||||
|
||||
|
||||
if (relay_clients)
|
||||
{
|
||||
weechat_printf (NULL, "");
|
||||
@@ -57,11 +57,11 @@ relay_command_client_list (int full)
|
||||
date_tmp = localtime (&(ptr_client->start_time));
|
||||
strftime (date_start, sizeof (date_start),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
|
||||
|
||||
date_tmp = localtime (&(ptr_client->last_activity));
|
||||
strftime (date_activity, sizeof (date_activity),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
|
||||
|
||||
if (full)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -112,7 +112,7 @@ relay_command_server_list ()
|
||||
int i;
|
||||
char date_start[128];
|
||||
struct tm *date_tmp;
|
||||
|
||||
|
||||
if (relay_servers)
|
||||
{
|
||||
weechat_printf (NULL, "");
|
||||
@@ -124,7 +124,7 @@ relay_command_server_list ()
|
||||
date_tmp = localtime (&(ptr_server->start_time));
|
||||
strftime (date_start, sizeof (date_start),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_(" port %s%d%s, relay: %s%s.%s%s, started on: %s"),
|
||||
RELAY_COLOR_CHAT_BUFFER,
|
||||
@@ -153,11 +153,11 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
struct t_relay_server *ptr_server;
|
||||
struct t_config_option *ptr_option;
|
||||
int port;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "list") == 0)
|
||||
@@ -165,13 +165,13 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
relay_command_client_list (0);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "listfull") == 0)
|
||||
{
|
||||
relay_command_client_list (1);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "listrelay") == 0)
|
||||
{
|
||||
relay_command_server_list ();
|
||||
@@ -247,14 +247,14 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!relay_buffer)
|
||||
relay_buffer_open ();
|
||||
|
||||
|
||||
if (relay_buffer)
|
||||
{
|
||||
weechat_buffer_set (relay_buffer, "display", "1");
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (strcmp (argv[1], "up") == 0)
|
||||
@@ -269,9 +269,9 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
relay_buffer_refresh (NULL);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,12 +42,12 @@ relay_completion_protocol_name_cb (void *data, const char *completion_item,
|
||||
{
|
||||
struct t_infolist *infolist;
|
||||
char protocol_name[256];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
infolist = weechat_infolist_get("irc_server", NULL, NULL);
|
||||
if (infolist)
|
||||
{
|
||||
@@ -60,10 +60,10 @@ relay_completion_protocol_name_cb (void *data, const char *completion_item,
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_completion_list_add (completion, "weechat",
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -79,12 +79,12 @@ relay_completion_relays_cb (void *data, const char *completion_item,
|
||||
{
|
||||
struct t_relay_server *ptr_server;
|
||||
char protocol_name[256];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
for (ptr_server = relay_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ relay_completion_relays_cb (void *data, const char *completion_item,
|
||||
weechat_hook_completion_list_add (completion, protocol_name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -110,12 +110,12 @@ relay_completion_free_port_cb (void *data, const char *completion_item,
|
||||
struct t_relay_server *ptr_server;
|
||||
char str_port[16];
|
||||
int port_max;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
port_max = -1;
|
||||
for (ptr_server = relay_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
@@ -125,11 +125,11 @@ relay_completion_free_port_cb (void *data, const char *completion_item,
|
||||
}
|
||||
if (port_max < 0)
|
||||
port_max = 8000 - 1;
|
||||
|
||||
|
||||
snprintf (str_port, sizeof (str_port), "%d", port_max + 1);
|
||||
weechat_hook_completion_list_add (completion, str_port,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ relay_config_refresh_cb (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (relay_buffer)
|
||||
relay_buffer_refresh (NULL);
|
||||
}
|
||||
@@ -80,11 +80,11 @@ relay_config_change_network_bind_address_cb (void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
struct t_relay_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
for (ptr_server = relay_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -105,11 +105,11 @@ relay_config_check_port_cb (void *data, struct t_config_option *option,
|
||||
char *error;
|
||||
long port;
|
||||
struct t_relay_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
error = NULL;
|
||||
port = strtol (value, &error, 10);
|
||||
ptr_server = relay_server_search_port ((int)port);
|
||||
@@ -120,7 +120,7 @@ relay_config_check_port_cb (void *data, struct t_config_option *option,
|
||||
RELAY_PLUGIN_NAME, (int)port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -133,10 +133,10 @@ void
|
||||
relay_config_change_port_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_relay_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_server = relay_server_search (weechat_config_option_get_pointer (option, "name"));
|
||||
if (ptr_server)
|
||||
{
|
||||
@@ -154,10 +154,10 @@ void
|
||||
relay_config_delete_port_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_relay_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_server = relay_server_search (weechat_config_option_get_pointer (option, "name"));
|
||||
if (ptr_server)
|
||||
relay_server_free (ptr_server);
|
||||
@@ -178,21 +178,21 @@ relay_config_create_option_port (void *data,
|
||||
char *error, *protocol, *protocol_args;
|
||||
long port;
|
||||
struct t_relay_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
|
||||
|
||||
relay_server_get_protocol_args (option_name,
|
||||
&protocol, &protocol_args);
|
||||
|
||||
|
||||
protocol_number = -1;
|
||||
port = -1;
|
||||
|
||||
|
||||
if (protocol && protocol_args)
|
||||
protocol_number = relay_protocol_search (protocol);
|
||||
|
||||
|
||||
if (protocol_number < 0)
|
||||
{
|
||||
weechat_printf (NULL, _("%s%s: error: unknown protocol \"%s\""),
|
||||
@@ -208,7 +208,7 @@ relay_config_create_option_port (void *data,
|
||||
RELAY_PLUGIN_NAME, option_name);
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
error = NULL;
|
||||
@@ -222,7 +222,7 @@ relay_config_create_option_port (void *data,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
/* create config option */
|
||||
@@ -233,18 +233,18 @@ relay_config_create_option_port (void *data,
|
||||
&relay_config_check_port_cb, NULL,
|
||||
&relay_config_change_port_cb, NULL,
|
||||
&relay_config_delete_port_cb, NULL);
|
||||
|
||||
|
||||
if (relay_server_new (protocol_number, protocol_args, port))
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
else
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (protocol)
|
||||
free (protocol);
|
||||
if (protocol_args)
|
||||
free (protocol_args);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ relay_config_reload (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
return weechat_config_reload (config_file);
|
||||
}
|
||||
|
||||
@@ -270,12 +270,12 @@ int
|
||||
relay_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
relay_config_file = weechat_config_new (RELAY_CONFIG_NAME,
|
||||
&relay_config_reload, NULL);
|
||||
if (!relay_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (relay_config_file, "look",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -286,7 +286,7 @@ relay_config_init ()
|
||||
weechat_config_free (relay_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
relay_config_look_auto_open_buffer = weechat_config_new_option (
|
||||
relay_config_file, ptr_section,
|
||||
"auto_open_buffer", "boolean",
|
||||
@@ -298,7 +298,7 @@ relay_config_init ()
|
||||
N_("number of raw messages to save in memory when raw data buffer is "
|
||||
"closed (messages will be displayed when opening raw data buffer)"),
|
||||
NULL, 0, 65535, "256", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (relay_config_file, "color",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -309,7 +309,7 @@ relay_config_init ()
|
||||
weechat_config_free (relay_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
relay_config_color_text = weechat_config_new_option (
|
||||
relay_config_file, ptr_section,
|
||||
"text", "color",
|
||||
@@ -358,7 +358,7 @@ relay_config_init ()
|
||||
N_("text color for \"disconnected\" status"),
|
||||
NULL, 0, 0, "lightred", NULL, 0,
|
||||
NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (relay_config_file, "network",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -390,7 +390,7 @@ relay_config_init ()
|
||||
N_("password required by clients to access this relay (empty value "
|
||||
"means no password required)"),
|
||||
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (relay_config_file, "port",
|
||||
1, 1,
|
||||
NULL, NULL,
|
||||
@@ -403,9 +403,9 @@ relay_config_init ()
|
||||
weechat_config_free (relay_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
relay_config_section_port = ptr_section;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,19 +39,19 @@ relay_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_relay_client *ptr_client;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) arguments;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "relay") == 0)
|
||||
{
|
||||
if (pointer && !relay_client_valid (pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -81,7 +81,7 @@ relay_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ void
|
||||
relay_raw_open (int switch_to_buffer)
|
||||
{
|
||||
struct t_relay_raw_message *ptr_raw_message;
|
||||
|
||||
|
||||
if (!relay_raw_buffer)
|
||||
{
|
||||
relay_raw_buffer = weechat_buffer_search (RELAY_PLUGIN_NAME,
|
||||
@@ -76,11 +76,11 @@ relay_raw_open (int switch_to_buffer)
|
||||
relay_raw_buffer = weechat_buffer_new (RELAY_RAW_BUFFER_NAME,
|
||||
&relay_buffer_input_cb, NULL,
|
||||
&relay_buffer_close_cb, NULL);
|
||||
|
||||
|
||||
/* failed to create buffer ? then return */
|
||||
if (!relay_raw_buffer)
|
||||
return;
|
||||
|
||||
|
||||
weechat_buffer_set (relay_raw_buffer,
|
||||
"title", _("Relay raw messages"));
|
||||
|
||||
@@ -93,10 +93,10 @@ relay_raw_open (int switch_to_buffer)
|
||||
weechat_buffer_set (relay_raw_buffer, "localvar_set_server", RELAY_RAW_BUFFER_NAME);
|
||||
weechat_buffer_set (relay_raw_buffer, "localvar_set_channel", RELAY_RAW_BUFFER_NAME);
|
||||
weechat_buffer_set (relay_raw_buffer, "localvar_set_no_log", "1");
|
||||
|
||||
|
||||
/* disable all highlights on this buffer */
|
||||
weechat_buffer_set (relay_raw_buffer, "highlight_words", "-");
|
||||
|
||||
|
||||
/* print messages in list */
|
||||
for (ptr_raw_message = relay_raw_messages; ptr_raw_message;
|
||||
ptr_raw_message = ptr_raw_message->next_message)
|
||||
@@ -105,7 +105,7 @@ relay_raw_open (int switch_to_buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (relay_raw_buffer && switch_to_buffer)
|
||||
weechat_buffer_set (relay_raw_buffer, "display", "1");
|
||||
}
|
||||
@@ -118,7 +118,7 @@ void
|
||||
relay_raw_message_free (struct t_relay_raw_message *raw_message)
|
||||
{
|
||||
struct t_relay_raw_message *new_raw_messages;
|
||||
|
||||
|
||||
/* remove message from raw messages list */
|
||||
if (last_relay_raw_message == raw_message)
|
||||
last_relay_raw_message = raw_message->prev_message;
|
||||
@@ -129,20 +129,20 @@ relay_raw_message_free (struct t_relay_raw_message *raw_message)
|
||||
}
|
||||
else
|
||||
new_raw_messages = raw_message->next_message;
|
||||
|
||||
|
||||
if (raw_message->next_message)
|
||||
(raw_message->next_message)->prev_message = raw_message->prev_message;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (raw_message->prefix)
|
||||
free (raw_message->prefix);
|
||||
if (raw_message->message)
|
||||
free (raw_message->message);
|
||||
|
||||
|
||||
free (raw_message);
|
||||
|
||||
|
||||
relay_raw_messages = new_raw_messages;
|
||||
|
||||
|
||||
relay_raw_messages_count--;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ void
|
||||
relay_raw_message_remove_old ()
|
||||
{
|
||||
int max_messages;
|
||||
|
||||
|
||||
max_messages = weechat_config_integer (relay_config_look_raw_messages);
|
||||
while (relay_raw_messages && (relay_raw_messages_count >= max_messages))
|
||||
{
|
||||
@@ -185,19 +185,19 @@ relay_raw_message_add_to_list (time_t date, const char *prefix,
|
||||
const char *message)
|
||||
{
|
||||
struct t_relay_raw_message *new_raw_message;
|
||||
|
||||
|
||||
if (!prefix || !message)
|
||||
return NULL;
|
||||
|
||||
|
||||
relay_raw_message_remove_old ();
|
||||
|
||||
|
||||
new_raw_message = malloc (sizeof (*new_raw_message));
|
||||
if (new_raw_message)
|
||||
{
|
||||
new_raw_message->date = date;
|
||||
new_raw_message->prefix = strdup (prefix);
|
||||
new_raw_message->message = strdup (message);
|
||||
|
||||
|
||||
/* add message to list */
|
||||
new_raw_message->prev_message = last_relay_raw_message;
|
||||
new_raw_message->next_message = NULL;
|
||||
@@ -206,10 +206,10 @@ relay_raw_message_add_to_list (time_t date, const char *prefix,
|
||||
else
|
||||
relay_raw_messages = new_raw_message;
|
||||
last_relay_raw_message = new_raw_message;
|
||||
|
||||
|
||||
relay_raw_messages_count++;
|
||||
}
|
||||
|
||||
|
||||
return new_raw_message;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ relay_raw_message_add (struct t_relay_client *client, int send,
|
||||
const char *hexa = "0123456789ABCDEF";
|
||||
int pos_buf, pos_buf2, char_size, i;
|
||||
struct t_relay_raw_message *new_raw_message;
|
||||
|
||||
|
||||
buf = weechat_iconv_to_internal (NULL, message);
|
||||
buf2 = malloc ((strlen (buf) * 3) + 1);
|
||||
if (buf2)
|
||||
@@ -254,7 +254,7 @@ relay_raw_message_add (struct t_relay_client *client, int send,
|
||||
}
|
||||
buf2[pos_buf2] = '\0';
|
||||
}
|
||||
|
||||
|
||||
if (client)
|
||||
{
|
||||
snprintf (prefix, sizeof (prefix), "%s[%s%d%s] %s%s %s%s",
|
||||
@@ -277,16 +277,16 @@ relay_raw_message_add (struct t_relay_client *client, int send,
|
||||
weechat_color ("chat_prefix_join"),
|
||||
(send) ? RELAY_RAW_PREFIX_SEND : RELAY_RAW_PREFIX_RECV);
|
||||
}
|
||||
|
||||
|
||||
new_raw_message = relay_raw_message_add_to_list (time (NULL),
|
||||
prefix,
|
||||
(buf2) ? buf2 : ((buf) ? buf : message));
|
||||
|
||||
|
||||
if (buf)
|
||||
free (buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
|
||||
|
||||
return new_raw_message;
|
||||
}
|
||||
|
||||
@@ -298,14 +298,14 @@ void
|
||||
relay_raw_print (struct t_relay_client *client, int send, const char *message)
|
||||
{
|
||||
struct t_relay_raw_message *new_raw_message;
|
||||
|
||||
|
||||
if (!message)
|
||||
return;
|
||||
|
||||
|
||||
/* auto-open Relay raw buffer if debug for irc plugin is >= 1 */
|
||||
if (!relay_raw_buffer && (weechat_relay_plugin->debug >= 1))
|
||||
relay_raw_open (0);
|
||||
|
||||
|
||||
new_raw_message = relay_raw_message_add (client, send, message);
|
||||
if (new_raw_message)
|
||||
{
|
||||
@@ -326,20 +326,20 @@ relay_raw_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_relay_raw_message *raw_message)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !raw_message)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_time (ptr_item, "date", raw_message->date))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "prefix", raw_message->prefix))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "message", raw_message->message))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ relay_server_get_protocol_args (const char *protocol_and_args,
|
||||
char **protocol, char **protocol_args)
|
||||
{
|
||||
char *pos;
|
||||
|
||||
|
||||
pos = strchr (protocol_and_args, '.');
|
||||
if (pos)
|
||||
{
|
||||
@@ -79,12 +79,12 @@ relay_server_search (const char *protocol_and_args)
|
||||
{
|
||||
char *protocol, *protocol_args;
|
||||
struct t_relay_server *ptr_server;
|
||||
|
||||
|
||||
relay_server_get_protocol_args (protocol_and_args,
|
||||
&protocol, &protocol_args);
|
||||
|
||||
|
||||
ptr_server = NULL;
|
||||
|
||||
|
||||
if (protocol && protocol_args)
|
||||
{
|
||||
for (ptr_server = relay_servers; ptr_server;
|
||||
@@ -97,12 +97,12 @@ relay_server_search (const char *protocol_and_args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (protocol)
|
||||
free (protocol);
|
||||
if (protocol_args)
|
||||
free (protocol_args);
|
||||
|
||||
|
||||
return ptr_server;
|
||||
}
|
||||
|
||||
@@ -114,14 +114,14 @@ struct t_relay_server *
|
||||
relay_server_search_port (int port)
|
||||
{
|
||||
struct t_relay_server *ptr_server;
|
||||
|
||||
|
||||
for (ptr_server = relay_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (ptr_server->port == port)
|
||||
return ptr_server;
|
||||
}
|
||||
|
||||
|
||||
/* server not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -167,15 +167,15 @@ relay_server_sock_cb (void *data, int fd)
|
||||
socklen_t client_length;
|
||||
int client_fd;
|
||||
char ipv4_address[INET_ADDRSTRLEN + 1], *ptr_address;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) fd;
|
||||
|
||||
|
||||
server = (struct t_relay_server *)data;
|
||||
|
||||
|
||||
client_length = sizeof (client_addr);
|
||||
memset (&client_addr, 0, client_length);
|
||||
|
||||
|
||||
client_fd = accept (server->sock, (struct sockaddr *) &client_addr,
|
||||
&client_length);
|
||||
if (client_fd < 0)
|
||||
@@ -189,7 +189,7 @@ relay_server_sock_cb (void *data, int fd)
|
||||
server->protocol_args);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
ptr_address = NULL;
|
||||
if (inet_ntop (AF_INET,
|
||||
&(client_addr.sin_addr),
|
||||
@@ -198,9 +198,9 @@ relay_server_sock_cb (void *data, int fd)
|
||||
{
|
||||
ptr_address = ipv4_address;
|
||||
}
|
||||
|
||||
|
||||
relay_client_new (client_fd, ptr_address, server);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ relay_server_create_socket (struct t_relay_server *server)
|
||||
{
|
||||
int set, max_clients;
|
||||
struct sockaddr_in server_addr;
|
||||
|
||||
|
||||
server->sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (server->sock < 0)
|
||||
{
|
||||
@@ -222,7 +222,7 @@ relay_server_create_socket (struct t_relay_server *server)
|
||||
weechat_prefix ("error"), RELAY_PLUGIN_NAME);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
set = 1;
|
||||
if (setsockopt (server->sock, SOL_SOCKET, SO_REUSEADDR,
|
||||
(void *) &set, sizeof (set)) < 0)
|
||||
@@ -235,7 +235,7 @@ relay_server_create_socket (struct t_relay_server *server)
|
||||
server->sock = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
set = 1;
|
||||
if (setsockopt (server->sock, SOL_SOCKET, SO_KEEPALIVE,
|
||||
(void *) &set, sizeof (set)) < 0)
|
||||
@@ -248,7 +248,7 @@ relay_server_create_socket (struct t_relay_server *server)
|
||||
server->sock = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
memset(&server_addr, 0, sizeof(struct sockaddr_in));
|
||||
server_addr.sin_family = AF_INET;
|
||||
if (weechat_config_string (relay_config_network_bind_address)
|
||||
@@ -261,7 +261,7 @@ relay_server_create_socket (struct t_relay_server *server)
|
||||
server_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
}
|
||||
server_addr.sin_port = htons (server->port);
|
||||
|
||||
|
||||
if (bind (server->sock, (struct sockaddr *) &server_addr,
|
||||
sizeof (server_addr)) < 0)
|
||||
{
|
||||
@@ -275,11 +275,11 @@ relay_server_create_socket (struct t_relay_server *server)
|
||||
server->sock = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
max_clients = weechat_config_integer (relay_config_network_max_clients);
|
||||
|
||||
|
||||
listen (server->sock, max_clients);
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("%s: listening on port %d (relay: %s.%s, max %d clients)"),
|
||||
RELAY_PLUGIN_NAME,
|
||||
@@ -287,14 +287,14 @@ relay_server_create_socket (struct t_relay_server *server)
|
||||
relay_protocol_string[server->protocol],
|
||||
server->protocol_args,
|
||||
max_clients);
|
||||
|
||||
|
||||
server->hook_fd = weechat_hook_fd (server->sock,
|
||||
1, 0, 0,
|
||||
&relay_server_sock_cb,
|
||||
server);
|
||||
|
||||
server->start_time = time (NULL);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ relay_server_new (enum t_relay_protocol protocol,
|
||||
RELAY_PLUGIN_NAME, port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_server = malloc (sizeof (*new_server));
|
||||
if (new_server)
|
||||
{
|
||||
@@ -327,7 +327,7 @@ relay_server_new (enum t_relay_protocol protocol,
|
||||
new_server->sock = -1;
|
||||
new_server->hook_fd = NULL;
|
||||
new_server->start_time = 0;
|
||||
|
||||
|
||||
new_server->prev_server = NULL;
|
||||
new_server->next_server = relay_servers;
|
||||
if (relay_servers)
|
||||
@@ -335,7 +335,7 @@ relay_server_new (enum t_relay_protocol protocol,
|
||||
else
|
||||
last_relay_server = new_server;
|
||||
relay_servers = new_server;
|
||||
|
||||
|
||||
relay_server_create_socket (new_server);
|
||||
}
|
||||
else
|
||||
@@ -344,7 +344,7 @@ relay_server_new (enum t_relay_protocol protocol,
|
||||
_("%s%s: not enough memory for listening on new port"),
|
||||
weechat_prefix ("error"), RELAY_PLUGIN_NAME);
|
||||
}
|
||||
|
||||
|
||||
return new_server;
|
||||
}
|
||||
|
||||
@@ -371,10 +371,10 @@ void
|
||||
relay_server_free (struct t_relay_server *server)
|
||||
{
|
||||
struct t_relay_server *new_relay_servers;
|
||||
|
||||
|
||||
if (!server)
|
||||
return;
|
||||
|
||||
|
||||
/* remove server from list */
|
||||
if (last_relay_server == server)
|
||||
last_relay_server = server->prev_server;
|
||||
@@ -387,14 +387,14 @@ relay_server_free (struct t_relay_server *server)
|
||||
new_relay_servers = server->next_server;
|
||||
if (server->next_server)
|
||||
(server->next_server)->prev_server = server->prev_server;
|
||||
|
||||
|
||||
/* free data */
|
||||
relay_server_close_socket (server);
|
||||
if (server->protocol_args)
|
||||
free (server->protocol_args);
|
||||
|
||||
|
||||
free (server);
|
||||
|
||||
|
||||
relay_servers = new_relay_servers;
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ void
|
||||
relay_server_print_log ()
|
||||
{
|
||||
struct t_relay_server *ptr_server;
|
||||
|
||||
|
||||
for (ptr_server = relay_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ relay_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
|
||||
if (!rc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* save raw messages */
|
||||
for (ptr_raw_message = relay_raw_messages; ptr_raw_message;
|
||||
ptr_raw_message = ptr_raw_message->next_message)
|
||||
@@ -86,7 +86,7 @@ relay_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
|
||||
if (!rc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -100,15 +100,15 @@ relay_upgrade_save ()
|
||||
{
|
||||
int rc;
|
||||
struct t_upgrade_file *upgrade_file;
|
||||
|
||||
|
||||
upgrade_file = weechat_upgrade_new (RELAY_UPGRADE_FILENAME, 1);
|
||||
if (!upgrade_file)
|
||||
return 0;
|
||||
|
||||
|
||||
rc = relay_upgrade_save_all_data (upgrade_file);
|
||||
|
||||
|
||||
weechat_upgrade_close (upgrade_file);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ relay_upgrade_set_buffer_callbacks ()
|
||||
{
|
||||
struct t_infolist *infolist;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
infolist = weechat_infolist_get ("buffer", NULL, NULL);
|
||||
if (infolist)
|
||||
{
|
||||
@@ -160,11 +160,11 @@ relay_upgrade_read_cb (void *data,
|
||||
struct t_infolist *infolist)
|
||||
{
|
||||
struct t_relay_client *new_client;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) upgrade_file;
|
||||
|
||||
|
||||
weechat_infolist_reset_item_cursor (infolist);
|
||||
while (weechat_infolist_next (infolist))
|
||||
{
|
||||
@@ -197,7 +197,7 @@ relay_upgrade_read_cb (void *data,
|
||||
"%lu", &(new_client->bytes_recv));
|
||||
sscanf (weechat_infolist_string (infolist, "bytes_sent"),
|
||||
"%lu", &(new_client->bytes_sent));
|
||||
|
||||
|
||||
switch (new_client->protocol)
|
||||
{
|
||||
case RELAY_PROTOCOL_WEECHAT:
|
||||
@@ -211,7 +211,7 @@ relay_upgrade_read_cb (void *data,
|
||||
case RELAY_NUM_PROTOCOLS:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
new_client->prev_client = NULL;
|
||||
new_client->next_client = relay_clients;
|
||||
if (relay_clients)
|
||||
@@ -219,7 +219,7 @@ relay_upgrade_read_cb (void *data,
|
||||
else
|
||||
last_relay_client = new_client;
|
||||
relay_clients = new_client;
|
||||
|
||||
|
||||
relay_client_count++;
|
||||
}
|
||||
break;
|
||||
@@ -230,7 +230,7 @@ relay_upgrade_read_cb (void *data,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -244,11 +244,11 @@ relay_upgrade_load ()
|
||||
{
|
||||
int rc;
|
||||
struct t_upgrade_file *upgrade_file;
|
||||
|
||||
|
||||
relay_upgrade_set_buffer_callbacks ();
|
||||
|
||||
|
||||
upgrade_file = weechat_upgrade_new (RELAY_UPGRADE_FILENAME, 0);
|
||||
rc = weechat_upgrade_read (upgrade_file, &relay_upgrade_read_cb, NULL);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
+27
-27
@@ -67,7 +67,7 @@ relay_protocol_search (const char *name)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* protocol not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -81,21 +81,21 @@ relay_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
struct t_relay_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
|
||||
relay_signal_upgrade_received = 1;
|
||||
|
||||
|
||||
for (ptr_server = relay_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
relay_server_close_socket (ptr_server);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -111,22 +111,22 @@ relay_debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, RELAY_PLUGIN_NAME) == 0))
|
||||
{
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
|
||||
|
||||
relay_server_print_log ();
|
||||
relay_client_print_log ();
|
||||
|
||||
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** End of \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -138,29 +138,29 @@ int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
int i, upgrading;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
if (!relay_config_init ())
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
if (relay_config_read () < 0)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
relay_command_init ();
|
||||
|
||||
|
||||
/* hook completions */
|
||||
relay_completion_init ();
|
||||
|
||||
|
||||
weechat_hook_signal ("upgrade", &relay_signal_upgrade_cb, NULL);
|
||||
weechat_hook_signal ("debug_dump", &relay_debug_dump_cb, NULL);
|
||||
|
||||
|
||||
relay_info_init ();
|
||||
|
||||
|
||||
/* look at arguments */
|
||||
upgrading = 0;
|
||||
for (i = 0; i < argc; i++)
|
||||
@@ -170,10 +170,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
upgrading = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (upgrading)
|
||||
relay_upgrade_load ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -186,24 +186,24 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
relay_config_write ();
|
||||
|
||||
|
||||
if (relay_signal_upgrade_received)
|
||||
relay_upgrade_save ();
|
||||
else
|
||||
{
|
||||
relay_raw_message_free_all ();
|
||||
|
||||
|
||||
relay_server_free_all ();
|
||||
|
||||
|
||||
relay_client_disconnect_all ();
|
||||
|
||||
|
||||
if (relay_buffer)
|
||||
weechat_buffer_close (relay_buffer);
|
||||
|
||||
|
||||
relay_client_free_all ();
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ void
|
||||
rmodifier_command_list (const char *message)
|
||||
{
|
||||
struct t_rmodifier *ptr_rmodifier;
|
||||
|
||||
|
||||
if (rmodifier_list)
|
||||
{
|
||||
weechat_printf (NULL, "");
|
||||
@@ -91,11 +91,11 @@ rmodifier_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
struct t_rmodifier *ptr_rmodifier;
|
||||
struct t_config_option *ptr_option;
|
||||
int i, count;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if ((argc == 1)
|
||||
|| ((argc == 2) && (weechat_strcasecmp (argv[1], "list") == 0)))
|
||||
{
|
||||
@@ -118,7 +118,7 @@ rmodifier_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "add") == 0)
|
||||
{
|
||||
/* add a rmodifier */
|
||||
@@ -149,13 +149,13 @@ rmodifier_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
ptr_rmodifier->modifiers,
|
||||
ptr_rmodifier->str_regex,
|
||||
ptr_rmodifier->groups);
|
||||
|
||||
|
||||
/* display message */
|
||||
weechat_printf (NULL, _("Rmodifier \"%s\" created"),
|
||||
ptr_rmodifier->name);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
/* add a rmodifier */
|
||||
@@ -200,7 +200,7 @@ rmodifier_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
/* restore default rmodifiers (only with "-yes", for security reason) */
|
||||
if (weechat_strcasecmp (argv[1], "default") == 0)
|
||||
{
|
||||
@@ -221,7 +221,7 @@ rmodifier_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,19 +38,19 @@ rmodifier_completion_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_rmodifier *ptr_rmodifier;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_rmodifier = rmodifier_list; ptr_rmodifier;
|
||||
ptr_rmodifier = ptr_rmodifier->next_rmodifier)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_rmodifier->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ rmodifier_config_reload (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rmodifier_free_all ();
|
||||
weechat_config_section_free_options (rmodifier_config_section_modifier);
|
||||
|
||||
|
||||
return weechat_config_reload (config_file);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ rmodifier_config_modifier_change_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rmodifier_new_with_string (weechat_config_option_get_pointer (option, "name"),
|
||||
weechat_config_option_get_pointer (option, "value"));
|
||||
}
|
||||
@@ -91,10 +91,10 @@ void
|
||||
rmodifier_config_modifier_delete_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_rmodifier *ptr_rmodifier;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_rmodifier = rmodifier_search (weechat_config_option_get_pointer (option,
|
||||
"name"));
|
||||
if (ptr_rmodifier)
|
||||
@@ -113,13 +113,13 @@ rmodifier_config_modifier_write_default_cb (void *data,
|
||||
const char *section_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
|
||||
for (i = 0; rmodifier_config_default_list[i][0]; i++)
|
||||
{
|
||||
if (!weechat_config_write_line (config_file,
|
||||
@@ -130,7 +130,7 @@ rmodifier_config_modifier_write_default_cb (void *data,
|
||||
rmodifier_config_default_list[i][3]))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -178,12 +178,12 @@ rmodifier_config_modifier_create_option_cb (void *data,
|
||||
{
|
||||
struct t_rmodifier *ptr_rmodifier;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
/* create rmodifier */
|
||||
ptr_rmodifier = rmodifier_search (option_name);
|
||||
if (ptr_rmodifier)
|
||||
@@ -205,7 +205,7 @@ rmodifier_config_modifier_create_option_cb (void *data,
|
||||
}
|
||||
else
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -214,7 +214,7 @@ rmodifier_config_modifier_create_option_cb (void *data,
|
||||
weechat_prefix ("error"), RMODIFIER_PLUGIN_NAME,
|
||||
option_name, value);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -227,12 +227,12 @@ int
|
||||
rmodifier_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
rmodifier_config_file = weechat_config_new (RMODIFIER_CONFIG_NAME,
|
||||
&rmodifier_config_reload, NULL);
|
||||
if (!rmodifier_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
/* look */
|
||||
ptr_section = weechat_config_new_section (rmodifier_config_file, "look",
|
||||
0, 0,
|
||||
@@ -244,13 +244,13 @@ rmodifier_config_init ()
|
||||
weechat_config_free (rmodifier_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
rmodifier_config_look_hide_char = weechat_config_new_option (
|
||||
rmodifier_config_file, ptr_section,
|
||||
"hide_char", "string",
|
||||
N_("char used to hide part of a string"),
|
||||
NULL, 0, 0, "*", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* modifier */
|
||||
ptr_section = weechat_config_new_section (rmodifier_config_file, "modifier",
|
||||
0, 0,
|
||||
@@ -265,7 +265,7 @@ rmodifier_config_init ()
|
||||
return 0;
|
||||
}
|
||||
rmodifier_config_section_modifier = ptr_section;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,21 +41,21 @@ rmodifier_debug_signal_debug_dump_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, RMODIFIER_PLUGIN_NAME) == 0))
|
||||
{
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
|
||||
|
||||
rmodifier_print_log ();
|
||||
|
||||
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** End of \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,19 +39,19 @@ rmodifier_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_rmodifier *ptr_rmodifier;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) arguments;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, RMODIFIER_PLUGIN_NAME) == 0)
|
||||
{
|
||||
if (pointer && !rmodifier_valid (pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -85,7 +85,7 @@ rmodifier_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,17 +60,17 @@ int
|
||||
rmodifier_valid (struct t_rmodifier *rmodifier)
|
||||
{
|
||||
struct t_rmodifier *ptr_rmodifier;
|
||||
|
||||
|
||||
if (!rmodifier)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_rmodifier = rmodifier_list; ptr_rmodifier;
|
||||
ptr_rmodifier = ptr_rmodifier->next_rmodifier)
|
||||
{
|
||||
if (ptr_rmodifier == rmodifier)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* rmodifier not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ struct t_rmodifier *
|
||||
rmodifier_search (const char *name)
|
||||
{
|
||||
struct t_rmodifier *ptr_rmodifier;
|
||||
|
||||
|
||||
for (ptr_rmodifier = rmodifier_list; ptr_rmodifier;
|
||||
ptr_rmodifier = ptr_rmodifier->next_rmodifier)
|
||||
{
|
||||
@@ -103,21 +103,21 @@ rmodifier_hide_string (const char *string)
|
||||
{
|
||||
int length, i;
|
||||
char *result;
|
||||
|
||||
|
||||
if (!string || !string[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
length = weechat_utf8_strlen (string);
|
||||
result = malloc ((length * strlen (weechat_config_string (rmodifier_config_look_hide_char))) + 1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
||||
result[0] = '\0';
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
strcat (result, weechat_config_string (rmodifier_config_look_hide_char));
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -133,12 +133,12 @@ rmodifier_replace_groups (const char *string, regmatch_t regex_match[],
|
||||
char *result, *result2, *str_group, *string_to_add;
|
||||
const char *ptr_groups;
|
||||
int length, num_group;
|
||||
|
||||
|
||||
length = 1;
|
||||
result = malloc (length);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
||||
result[0] = '\0';
|
||||
ptr_groups = groups;
|
||||
while (ptr_groups && ptr_groups[0])
|
||||
@@ -157,7 +157,7 @@ rmodifier_replace_groups (const char *string, regmatch_t regex_match[],
|
||||
string_to_add = rmodifier_hide_string (str_group);
|
||||
else
|
||||
string_to_add = strdup (str_group);
|
||||
|
||||
|
||||
if (string_to_add)
|
||||
{
|
||||
length += strlen (string_to_add);
|
||||
@@ -178,7 +178,7 @@ rmodifier_replace_groups (const char *string, regmatch_t regex_match[],
|
||||
}
|
||||
ptr_groups = weechat_utf8_next_char (ptr_groups);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -193,26 +193,26 @@ rmodifier_modifier_cb (void *data, const char *modifier,
|
||||
struct t_rmodifier *rmodifier;
|
||||
regmatch_t regex_match[9];
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) modifier;
|
||||
(void) modifier_data;
|
||||
|
||||
|
||||
rmodifier = (struct t_rmodifier *)data;
|
||||
|
||||
|
||||
/* reset matching groups */
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
regex_match[i].rm_so = -1;
|
||||
}
|
||||
|
||||
|
||||
/* execute regex and return modified string if matching */
|
||||
if (regexec (rmodifier->regex, string, 9, regex_match, 0) == 0)
|
||||
{
|
||||
return rmodifier_replace_groups (string, regex_match,
|
||||
rmodifier->groups);
|
||||
}
|
||||
|
||||
|
||||
/* regex not matching */
|
||||
return NULL;
|
||||
}
|
||||
@@ -226,9 +226,9 @@ rmodifier_hook_modifiers (struct t_rmodifier *rmodifier)
|
||||
{
|
||||
char **argv, str_modifier[128];
|
||||
int argc, i;
|
||||
|
||||
|
||||
argv = weechat_string_split (rmodifier->modifiers, ",", 0, 0, &argc);
|
||||
|
||||
|
||||
if (argv)
|
||||
{
|
||||
rmodifier->hooks = malloc (sizeof (*rmodifier->hooks) * argc);
|
||||
@@ -262,15 +262,15 @@ rmodifier_new (const char *name, const char *modifiers, const char *str_regex,
|
||||
{
|
||||
struct t_rmodifier *new_rmodifier, *ptr_rmodifier;
|
||||
regex_t *regex;
|
||||
|
||||
|
||||
if (!name || !name[0] || !modifiers || !modifiers[0]
|
||||
|| !str_regex || !str_regex[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
regex = malloc (sizeof (*regex));
|
||||
if (!regex)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (regcomp (regex, str_regex,
|
||||
REG_EXTENDED | REG_ICASE) != 0)
|
||||
{
|
||||
@@ -281,11 +281,11 @@ rmodifier_new (const char *name, const char *modifiers, const char *str_regex,
|
||||
free (regex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ptr_rmodifier = rmodifier_search (name);
|
||||
if (ptr_rmodifier)
|
||||
rmodifier_free (ptr_rmodifier);
|
||||
|
||||
|
||||
new_rmodifier = malloc (sizeof (*new_rmodifier));
|
||||
if (new_rmodifier)
|
||||
{
|
||||
@@ -295,10 +295,10 @@ rmodifier_new (const char *name, const char *modifiers, const char *str_regex,
|
||||
new_rmodifier->str_regex = strdup (str_regex);
|
||||
new_rmodifier->regex = regex;
|
||||
new_rmodifier->groups = strdup ((groups) ? groups : "");
|
||||
|
||||
|
||||
/* create modifiers */
|
||||
rmodifier_hook_modifiers (new_rmodifier);
|
||||
|
||||
|
||||
if (rmodifier_list)
|
||||
{
|
||||
/* add rmodifier to end of list */
|
||||
@@ -314,10 +314,10 @@ rmodifier_new (const char *name, const char *modifiers, const char *str_regex,
|
||||
rmodifier_list = new_rmodifier;
|
||||
last_rmodifier = new_rmodifier;
|
||||
}
|
||||
|
||||
|
||||
rmodifier_count++;
|
||||
}
|
||||
|
||||
|
||||
return new_rmodifier;
|
||||
}
|
||||
|
||||
@@ -331,9 +331,9 @@ rmodifier_new_with_string (const char *name, const char *value)
|
||||
{
|
||||
struct t_rmodifier *new_rmodifier;
|
||||
char *pos1, *pos2, *modifiers, *str_regex;
|
||||
|
||||
|
||||
new_rmodifier = NULL;
|
||||
|
||||
|
||||
pos1 = strchr (value, ';');
|
||||
pos2 = rindex (value, ';');
|
||||
if (pos1 && pos2 && (pos2 > pos1))
|
||||
@@ -350,7 +350,7 @@ rmodifier_new_with_string (const char *name, const char *value)
|
||||
if (str_regex)
|
||||
free (str_regex);
|
||||
}
|
||||
|
||||
|
||||
return new_rmodifier;
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ void
|
||||
rmodifier_create_default ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; rmodifier_config_default_list[i][0]; i++)
|
||||
{
|
||||
if (rmodifier_new (rmodifier_config_default_list[i][0],
|
||||
@@ -387,7 +387,7 @@ rmodifier_free (struct t_rmodifier *rmodifier)
|
||||
{
|
||||
struct t_rmodifier *new_rmodifier_list;
|
||||
int i;
|
||||
|
||||
|
||||
/* remove rmodifier from list */
|
||||
if (last_rmodifier == rmodifier)
|
||||
last_rmodifier = rmodifier->prev_rmodifier;
|
||||
@@ -424,9 +424,9 @@ rmodifier_free (struct t_rmodifier *rmodifier)
|
||||
if (rmodifier->groups)
|
||||
free (rmodifier->groups);
|
||||
free (rmodifier);
|
||||
|
||||
|
||||
rmodifier_count--;
|
||||
|
||||
|
||||
rmodifier_list = new_rmodifier_list;
|
||||
}
|
||||
|
||||
@@ -455,10 +455,10 @@ rmodifier_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_infolist_item *ptr_item;
|
||||
char option_name[64];
|
||||
int i;
|
||||
|
||||
|
||||
if (!infolist || !rmodifier)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
@@ -482,7 +482,7 @@ rmodifier_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "groups", rmodifier->groups))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ rmodifier_print_log ()
|
||||
{
|
||||
struct t_rmodifier *ptr_rmodifier;
|
||||
int i;
|
||||
|
||||
|
||||
for (ptr_rmodifier = rmodifier_list; ptr_rmodifier;
|
||||
ptr_rmodifier = ptr_rmodifier->next_rmodifier)
|
||||
{
|
||||
@@ -526,13 +526,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
rmodifier_count = 0;
|
||||
|
||||
|
||||
rmodifier_hook_list = weechat_list_new ();
|
||||
|
||||
|
||||
if (!rmodifier_config_init ())
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -541,14 +541,14 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
rmodifier_config_read ();
|
||||
|
||||
|
||||
rmodifier_command_init ();
|
||||
rmodifier_completion_init ();
|
||||
|
||||
|
||||
rmodifier_info_init ();
|
||||
|
||||
|
||||
rmodifier_debug_init ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -561,11 +561,11 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
rmodifier_config_write ();
|
||||
rmodifier_free_all ();
|
||||
weechat_list_free (rmodifier_hook_list);
|
||||
weechat_config_free (rmodifier_config_file);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -102,7 +102,7 @@ SCM
|
||||
weechat_guile_catch (void *procedure, void *data)
|
||||
{
|
||||
SCM value;
|
||||
|
||||
|
||||
value = scm_internal_catch (SCM_BOOL_T,
|
||||
(scm_t_catch_body)procedure,
|
||||
data,
|
||||
@@ -119,9 +119,9 @@ SCM
|
||||
weechat_guile_scm_call_1 (void *proc)
|
||||
{
|
||||
struct t_guile_function *guile_function;
|
||||
|
||||
|
||||
guile_function = (struct t_guile_function *)proc;
|
||||
|
||||
|
||||
return scm_call_1 (guile_function->proc, guile_function->args);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ weechat_guile_exec_function (const char *function, SCM args)
|
||||
{
|
||||
SCM func, func2, value;
|
||||
struct t_guile_function guile_function;
|
||||
|
||||
|
||||
func = weechat_guile_catch (scm_c_lookup, (void *)function);
|
||||
func2 = weechat_guile_catch (scm_variable_ref, func);
|
||||
|
||||
@@ -148,8 +148,8 @@ weechat_guile_exec_function (const char *function, SCM args)
|
||||
else
|
||||
{
|
||||
value = weechat_guile_catch (scm_call_0, func2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -165,16 +165,16 @@ weechat_guile_hashtable_map_cb (void *data,
|
||||
const void *value)
|
||||
{
|
||||
SCM *alist, pair, list;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
alist = (SCM *)data;
|
||||
|
||||
|
||||
pair = scm_cons (scm_from_locale_string ((const char *)key),
|
||||
scm_from_locale_string ((const char *)value));
|
||||
list = scm_list_1 (pair);
|
||||
|
||||
|
||||
*alist = scm_append (scm_list_2 (*alist, list));
|
||||
}
|
||||
|
||||
@@ -186,13 +186,13 @@ SCM
|
||||
weechat_guile_hashtable_to_alist (struct t_hashtable *hashtable)
|
||||
{
|
||||
SCM alist;
|
||||
|
||||
|
||||
alist = scm_list_n (SCM_UNDEFINED);
|
||||
|
||||
|
||||
weechat_hashtable_map (hashtable,
|
||||
&weechat_guile_hashtable_map_cb,
|
||||
&alist);
|
||||
|
||||
|
||||
return alist;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
|
||||
struct t_hashtable *hashtable;
|
||||
int length, i;
|
||||
SCM pair;
|
||||
|
||||
|
||||
hashtable = weechat_hashtable_new (hashtable_size,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -218,7 +218,7 @@ weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
length = scm_to_int (scm_length (alist));
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
@@ -229,7 +229,7 @@ weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
|
||||
scm_i_string_chars (scm_list_ref (pair,
|
||||
scm_from_int (1))));
|
||||
}
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
@@ -246,11 +246,11 @@ weechat_guile_exec (struct t_plugin_script *script,
|
||||
SCM argv_list, rc;
|
||||
void *argv2[17], *ret_value;
|
||||
int i, argc, *ret_int;
|
||||
|
||||
|
||||
old_guile_current_script = guile_current_script;
|
||||
scm_set_current_module ((SCM)(script->interpreter));
|
||||
guile_current_script = script;
|
||||
|
||||
|
||||
if (argv && argv[0])
|
||||
{
|
||||
argc = strlen (format);
|
||||
@@ -288,9 +288,9 @@ weechat_guile_exec (struct t_plugin_script *script,
|
||||
{
|
||||
rc = weechat_guile_exec_function (function, NULL);
|
||||
}
|
||||
|
||||
|
||||
ret_value = NULL;
|
||||
|
||||
|
||||
if ((ret_type == WEECHAT_SCRIPT_EXEC_STRING) && (scm_is_string (rc)))
|
||||
{
|
||||
ret_value = scm_to_locale_string (rc);
|
||||
@@ -314,19 +314,19 @@ weechat_guile_exec (struct t_plugin_script *script,
|
||||
"a valid value"),
|
||||
weechat_prefix ("error"), GUILE_PLUGIN_NAME, function);
|
||||
}
|
||||
|
||||
|
||||
if (ret_value == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: error in function \"%s\""),
|
||||
weechat_prefix ("error"), GUILE_PLUGIN_NAME, function);
|
||||
}
|
||||
|
||||
|
||||
if (old_guile_current_script)
|
||||
scm_set_current_module ((SCM)(old_guile_current_script->interpreter));
|
||||
|
||||
|
||||
guile_current_script = old_guile_current_script;
|
||||
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@@ -350,28 +350,28 @@ weechat_guile_load (const char *filename)
|
||||
{
|
||||
char *filename2, *ptr_base_name, *base_name;
|
||||
SCM module;
|
||||
|
||||
|
||||
if ((weechat_guile_plugin->debug >= 1) || !guile_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
GUILE_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
|
||||
guile_current_script = NULL;
|
||||
guile_registered_script = NULL;
|
||||
guile_current_script_filename = filename;
|
||||
|
||||
|
||||
filename2 = strdup (filename);
|
||||
if (!filename2)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_base_name = basename (filename2);
|
||||
base_name = strdup (ptr_base_name);
|
||||
module = scm_c_define_module (base_name,
|
||||
&weechat_guile_module_init_script, filename2);
|
||||
free (filename2);
|
||||
|
||||
|
||||
if (!guile_registered_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -380,12 +380,12 @@ weechat_guile_load (const char *filename)
|
||||
weechat_prefix ("error"), GUILE_PLUGIN_NAME, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
scm_gc_protect_object (module);
|
||||
|
||||
|
||||
guile_current_script = guile_registered_script;
|
||||
guile_current_script->interpreter = (void *)module;
|
||||
|
||||
|
||||
/*
|
||||
* set input/close callbacks for buffers created by this script
|
||||
* (to restore callbacks after upgrade)
|
||||
@@ -395,7 +395,7 @@ weechat_guile_load (const char *filename)
|
||||
guile_current_script,
|
||||
&weechat_guile_api_buffer_input_data_cb,
|
||||
&weechat_guile_api_buffer_close_cb);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ weechat_guile_load_cb (void *data, const char *filename)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
weechat_guile_load (filename);
|
||||
}
|
||||
|
||||
@@ -420,14 +420,14 @@ void
|
||||
weechat_guile_unload (struct t_plugin_script *script)
|
||||
{
|
||||
int *rc;
|
||||
|
||||
|
||||
if ((weechat_guile_plugin->debug >= 1) || !guile_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: unloading script \"%s\""),
|
||||
GUILE_PLUGIN_NAME, script->name);
|
||||
}
|
||||
|
||||
|
||||
if (script->shutdown_func && script->shutdown_func[0])
|
||||
{
|
||||
rc = (int *)weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT,
|
||||
@@ -435,13 +435,13 @@ weechat_guile_unload (struct t_plugin_script *script)
|
||||
if (rc)
|
||||
free (rc);
|
||||
}
|
||||
|
||||
|
||||
scm_gc_unprotect_object (script->interpreter);
|
||||
|
||||
|
||||
if (guile_current_script == script)
|
||||
guile_current_script = (guile_current_script->prev_script) ?
|
||||
guile_current_script->prev_script : guile_current_script->next_script;
|
||||
|
||||
|
||||
script_remove (weechat_guile_plugin, &guile_scripts, &last_guile_script,
|
||||
script);
|
||||
}
|
||||
@@ -454,7 +454,7 @@ void
|
||||
weechat_guile_unload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_guile_plugin, guile_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -493,7 +493,7 @@ weechat_guile_reload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
char *filename;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_guile_plugin, guile_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -526,7 +526,7 @@ weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
{
|
||||
char *path_script;
|
||||
SCM value;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
@@ -613,7 +613,7 @@ weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
"guile");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -630,9 +630,9 @@ weechat_guile_completion_cb (void *data, const char *completion_item,
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
script_completion (weechat_guile_plugin, completion, guile_scripts);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -646,17 +646,17 @@ weechat_guile_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "guile_script") == 0)
|
||||
{
|
||||
return script_infolist_list_scripts (weechat_guile_plugin,
|
||||
guile_scripts, pointer,
|
||||
arguments);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -673,13 +673,13 @@ weechat_guile_signal_debug_dump_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, GUILE_PLUGIN_NAME) == 0))
|
||||
{
|
||||
script_print_log (weechat_guile_plugin, guile_scripts);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -697,10 +697,10 @@ weechat_guile_signal_buffer_closed_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (signal_data)
|
||||
script_remove_buffer_callbacks (guile_scripts, signal_data);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ weechat_guile_timer_action_cb (void *data, int remaining_calls)
|
||||
&guile_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -748,7 +748,7 @@ weechat_guile_signal_script_action_cb (void *data, const char *signal,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (strcmp (signal, "guile_script_install") == 0)
|
||||
@@ -768,7 +768,7 @@ weechat_guile_signal_script_action_cb (void *data, const char *signal,
|
||||
&guile_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ weechat_guile_port_fill_input (SCM port)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) port;
|
||||
|
||||
|
||||
return ' ';
|
||||
}
|
||||
|
||||
@@ -794,10 +794,10 @@ weechat_guile_port_write (SCM port, const void *data, size_t size)
|
||||
{
|
||||
char *new_stdout;
|
||||
int length_stdout;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) port;
|
||||
|
||||
|
||||
/* concatenate str to guile_stdout */
|
||||
if (guile_stdout)
|
||||
{
|
||||
@@ -821,7 +821,7 @@ weechat_guile_port_write (SCM port, const void *data, size_t size)
|
||||
guile_stdout[size] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* flush stdout if at least "\n" is in string */
|
||||
if (guile_stdout && (strchr (guile_stdout, '\n')))
|
||||
weechat_guile_stdout_flush ();
|
||||
@@ -835,17 +835,17 @@ int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
weechat_guile_plugin = plugin;
|
||||
|
||||
|
||||
guile_stdout = NULL;
|
||||
|
||||
|
||||
scm_init_guile ();
|
||||
|
||||
|
||||
guile_module_weechat = scm_c_define_module ("weechat",
|
||||
&weechat_guile_api_module_init,
|
||||
NULL);
|
||||
scm_c_use_module ("weechat");
|
||||
scm_gc_protect_object (guile_module_weechat);
|
||||
|
||||
|
||||
guile_quiet = 1;
|
||||
script_init (weechat_guile_plugin,
|
||||
argc,
|
||||
@@ -858,10 +858,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
&weechat_guile_signal_script_action_cb,
|
||||
&weechat_guile_load_cb);
|
||||
guile_quiet = 0;
|
||||
|
||||
|
||||
script_display_short_list (weechat_guile_plugin,
|
||||
guile_scripts);
|
||||
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -877,15 +877,15 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
guile_quiet = 1;
|
||||
script_end (plugin, &guile_scripts, &weechat_guile_unload_all);
|
||||
guile_quiet = 0;
|
||||
|
||||
|
||||
/* unprotect module */
|
||||
scm_gc_unprotect_object (guile_module_weechat);
|
||||
|
||||
|
||||
/* free some data */
|
||||
if (guile_action_install_list)
|
||||
free (guile_action_install_list);
|
||||
if (guile_action_remove_list)
|
||||
free (guile_action_remove_list);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -81,12 +81,12 @@ weechat_lua_hashtable_map_cb (void *data,
|
||||
const void *value)
|
||||
{
|
||||
lua_State *interpreter;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
interpreter = (lua_State *)data;
|
||||
|
||||
|
||||
lua_pushstring (interpreter, (char *)key);
|
||||
lua_pushstring (interpreter, (char *)value);
|
||||
lua_rawset (interpreter, -3);
|
||||
@@ -100,7 +100,7 @@ void
|
||||
weechat_lua_pushhashtable (lua_State *interpreter, struct t_hashtable *hashtable)
|
||||
{
|
||||
lua_newtable (interpreter);
|
||||
|
||||
|
||||
weechat_hashtable_map (hashtable,
|
||||
&weechat_lua_hashtable_map_cb,
|
||||
interpreter);
|
||||
@@ -118,7 +118,7 @@ struct t_hashtable *
|
||||
weechat_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
|
||||
hashtable = weechat_hashtable_new (hashtable_size,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -126,7 +126,7 @@ weechat_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size)
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
lua_pushnil (interpreter);
|
||||
while (lua_next (interpreter, index - 1) != 0)
|
||||
{
|
||||
@@ -136,7 +136,7 @@ weechat_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size)
|
||||
/* remove value from stack (keep key for next iteration) */
|
||||
lua_pop (interpreter, 1);
|
||||
}
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
@@ -153,10 +153,10 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
|
||||
int argc, i, *ret_i;
|
||||
lua_State *old_lua_current_interpreter;
|
||||
struct t_plugin_script *old_lua_current_script;
|
||||
|
||||
|
||||
old_lua_current_interpreter = lua_current_interpreter;
|
||||
lua_current_interpreter = script->interpreter;
|
||||
|
||||
|
||||
lua_getglobal (lua_current_interpreter, function);
|
||||
|
||||
old_lua_current_script = lua_current_script;
|
||||
@@ -182,7 +182,7 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (lua_pcall (lua_current_interpreter, argc, 1, 0) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -196,7 +196,7 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
|
||||
lua_current_interpreter = old_lua_current_interpreter;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
|
||||
ret_value = strdup ((char *) lua_tostring (lua_current_interpreter, -1));
|
||||
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
|
||||
@@ -218,10 +218,10 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
|
||||
lua_current_interpreter = old_lua_current_interpreter;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
lua_current_script = old_lua_current_script;
|
||||
lua_current_interpreter = old_lua_current_interpreter;
|
||||
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ weechat_lua_load (const char *filename)
|
||||
"io.stdout = weechat_outputs\n"
|
||||
"io.stderr = weechat_outputs\n"
|
||||
};
|
||||
|
||||
|
||||
if ((fp = fopen (filename, "r")) == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -250,17 +250,17 @@ weechat_lua_load (const char *filename)
|
||||
weechat_prefix ("error"), LUA_PLUGIN_NAME, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if ((weechat_lua_plugin->debug >= 1) || !lua_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
LUA_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
|
||||
lua_current_script = NULL;
|
||||
lua_registered_script = NULL;
|
||||
|
||||
|
||||
lua_current_interpreter = lua_open ();
|
||||
|
||||
if (lua_current_interpreter == NULL)
|
||||
@@ -283,7 +283,7 @@ weechat_lua_load (const char *filename)
|
||||
luaopen_io (lua_current_interpreter);
|
||||
luaopen_debug (lua_current_interpreter);
|
||||
#endif
|
||||
|
||||
|
||||
luaL_openlib (lua_current_interpreter, "weechat", weechat_lua_api_funcs, 0);
|
||||
|
||||
#ifdef LUA_VERSION_NUM
|
||||
@@ -297,9 +297,9 @@ weechat_lua_load (const char *filename)
|
||||
"and stderr"),
|
||||
weechat_prefix ("error"), LUA_PLUGIN_NAME);
|
||||
}
|
||||
|
||||
|
||||
lua_current_script_filename = filename;
|
||||
|
||||
|
||||
if (luaL_loadfile (lua_current_interpreter, filename) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -313,7 +313,7 @@ weechat_lua_load (const char *filename)
|
||||
fclose (fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (lua_pcall (lua_current_interpreter, 0, 0, 0) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -333,7 +333,7 @@ weechat_lua_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
|
||||
if (!lua_registered_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -344,9 +344,9 @@ weechat_lua_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
lua_current_script = lua_registered_script;
|
||||
|
||||
|
||||
lua_current_script->interpreter = (lua_State *) lua_current_interpreter;
|
||||
|
||||
|
||||
/*
|
||||
* set input/close callbacks for buffers created by this script
|
||||
* (to restore callbacks after upgrade)
|
||||
@@ -356,7 +356,7 @@ weechat_lua_load (const char *filename)
|
||||
lua_current_script,
|
||||
&weechat_lua_api_buffer_input_data_cb,
|
||||
&weechat_lua_api_buffer_close_cb);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ weechat_lua_load_cb (void *data, const char *filename)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
weechat_lua_load (filename);
|
||||
}
|
||||
|
||||
@@ -382,14 +382,14 @@ weechat_lua_unload (struct t_plugin_script *script)
|
||||
{
|
||||
int *rc;
|
||||
void *interpreter;
|
||||
|
||||
|
||||
if ((weechat_lua_plugin->debug >= 1) || !lua_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: unloading script \"%s\""),
|
||||
LUA_PLUGIN_NAME, script->name);
|
||||
}
|
||||
|
||||
|
||||
if (script->shutdown_func && script->shutdown_func[0])
|
||||
{
|
||||
rc = (int *)weechat_lua_exec (script,
|
||||
@@ -399,15 +399,15 @@ weechat_lua_unload (struct t_plugin_script *script)
|
||||
if (rc)
|
||||
free (rc);
|
||||
}
|
||||
|
||||
|
||||
interpreter = script->interpreter;
|
||||
|
||||
|
||||
if (lua_current_script == script)
|
||||
lua_current_script = (lua_current_script->prev_script) ?
|
||||
lua_current_script->prev_script : lua_current_script->next_script;
|
||||
|
||||
|
||||
script_remove (weechat_lua_plugin, &lua_scripts, &last_lua_script, script);
|
||||
|
||||
|
||||
lua_close (interpreter);
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ void
|
||||
weechat_lua_unload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_lua_plugin, lua_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -445,7 +445,7 @@ weechat_lua_reload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
char *filename;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_lua_plugin, lua_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -490,11 +490,11 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char *path_script;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
script_display_list (weechat_lua_plugin, lua_scripts,
|
||||
@@ -565,7 +565,7 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_prefix ("error"), LUA_PLUGIN_NAME, "lua");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -582,9 +582,9 @@ weechat_lua_completion_cb (void *data, const char *completion_item,
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
script_completion (weechat_lua_plugin, completion, lua_scripts);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -598,17 +598,17 @@ weechat_lua_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "lua_script") == 0)
|
||||
{
|
||||
return script_infolist_list_scripts (weechat_lua_plugin,
|
||||
lua_scripts, pointer,
|
||||
arguments);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -624,13 +624,13 @@ weechat_lua_signal_debug_dump_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, LUA_PLUGIN_NAME) == 0))
|
||||
{
|
||||
script_print_log (weechat_lua_plugin, lua_scripts);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -646,10 +646,10 @@ weechat_lua_signal_buffer_closed_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (signal_data)
|
||||
script_remove_buffer_callbacks (lua_scripts, signal_data);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -681,7 +681,7 @@ weechat_lua_timer_action_cb (void *data, int remaining_calls)
|
||||
&lua_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -697,7 +697,7 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (strcmp (signal, "lua_script_install") == 0)
|
||||
@@ -717,7 +717,7 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal,
|
||||
&lua_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -729,7 +729,7 @@ int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
weechat_lua_plugin = plugin;
|
||||
|
||||
|
||||
lua_quiet = 1;
|
||||
script_init (weechat_lua_plugin,
|
||||
argc,
|
||||
@@ -742,10 +742,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
&weechat_lua_signal_script_action_cb,
|
||||
&weechat_lua_load_cb);
|
||||
lua_quiet = 0;
|
||||
|
||||
|
||||
script_display_short_list (weechat_lua_plugin,
|
||||
lua_scripts);
|
||||
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -761,6 +761,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
lua_quiet = 1;
|
||||
script_end (plugin, &lua_scripts, &weechat_lua_unload_all);
|
||||
lua_quiet = 0;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -138,12 +138,12 @@ weechat_perl_hashtable_map_cb (void *data,
|
||||
const void *value)
|
||||
{
|
||||
HV *hash;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
hash = (HV *)data;
|
||||
|
||||
|
||||
(void) hv_store (hash, (char *)key, strlen ((char *)key),
|
||||
newSVpv ((char *)value, 0), 0);
|
||||
}
|
||||
@@ -156,15 +156,15 @@ HV *
|
||||
weechat_perl_hashtable_to_hash (struct t_hashtable *hashtable)
|
||||
{
|
||||
HV *hash;
|
||||
|
||||
|
||||
hash = (HV *)newHV ();
|
||||
if (!hash)
|
||||
return NULL;
|
||||
|
||||
|
||||
weechat_hashtable_map (hashtable,
|
||||
&weechat_perl_hashtable_map_cb,
|
||||
hash);
|
||||
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
|
||||
SV *value;
|
||||
char *str_key;
|
||||
I32 retlen;
|
||||
|
||||
|
||||
hashtable = weechat_hashtable_new (hashtable_size,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -192,7 +192,7 @@ weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
if ((hash) && SvROK(hash) && SvRV(hash) && (SvTYPE(SvRV(hash)) == SVt_PVHV))
|
||||
{
|
||||
hash2 = (HV *) SvRV(hash);
|
||||
@@ -202,7 +202,7 @@ weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
|
||||
weechat_hashtable_set (hashtable, str_key, SvPV (value, PL_na));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
@@ -225,10 +225,10 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
#ifdef MULTIPLICITY
|
||||
void *old_context;
|
||||
#endif
|
||||
|
||||
|
||||
old_perl_current_script = perl_current_script;
|
||||
perl_current_script = script;
|
||||
|
||||
|
||||
#ifdef MULTIPLICITY
|
||||
(void) length;
|
||||
func = (char *) function;
|
||||
@@ -245,11 +245,11 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
(char *) ((script->interpreter) ? script->interpreter : perl_main),
|
||||
function);
|
||||
#endif
|
||||
|
||||
|
||||
dSP;
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
|
||||
|
||||
PUSHMARK(SP);
|
||||
if (format && format[0])
|
||||
{
|
||||
@@ -273,12 +273,12 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
}
|
||||
PUTBACK;
|
||||
count = perl_call_pv (func, G_EVAL | G_SCALAR);
|
||||
|
||||
|
||||
ret_value = NULL;
|
||||
mem_err = 1;
|
||||
|
||||
|
||||
SPAGAIN;
|
||||
|
||||
|
||||
if (SvTRUE (ERRSV))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -334,7 +334,7 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
PUTBACK;
|
||||
FREETMPS;
|
||||
LEAVE;
|
||||
|
||||
|
||||
perl_current_script = old_perl_current_script;
|
||||
#ifdef MULTIPLICITY
|
||||
PERL_SET_CONTEXT (old_context);
|
||||
@@ -350,7 +350,7 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
weechat_prefix ("error"), PERL_PLUGIN_NAME, function);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@@ -366,13 +366,13 @@ weechat_perl_load (const char *filename)
|
||||
int *eval;
|
||||
struct stat buf;
|
||||
void *perl_argv[2];
|
||||
|
||||
|
||||
#ifdef MULTIPLICITY
|
||||
PerlInterpreter *perl_current_interpreter;
|
||||
#else
|
||||
char pkgname[64];
|
||||
#endif
|
||||
|
||||
|
||||
temp_script.filename = NULL;
|
||||
temp_script.interpreter = NULL;
|
||||
temp_script.name = NULL;
|
||||
@@ -382,7 +382,7 @@ weechat_perl_load (const char *filename)
|
||||
temp_script.description = NULL;
|
||||
temp_script.shutdown_func = NULL;
|
||||
temp_script.charset = NULL;
|
||||
|
||||
|
||||
if (stat (filename, &buf) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -390,21 +390,21 @@ weechat_perl_load (const char *filename)
|
||||
weechat_prefix ("error"), PERL_PLUGIN_NAME, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if ((weechat_perl_plugin->debug >= 1) || !perl_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
PERL_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
|
||||
perl_current_script = NULL;
|
||||
perl_current_script_filename = filename;
|
||||
perl_registered_script = NULL;
|
||||
|
||||
|
||||
#ifdef MULTIPLICITY
|
||||
perl_current_interpreter = perl_alloc();
|
||||
|
||||
|
||||
if (!perl_current_interpreter)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -413,13 +413,13 @@ weechat_perl_load (const char *filename)
|
||||
weechat_prefix ("error"), PERL_PLUGIN_NAME);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
PERL_SET_CONTEXT (perl_current_interpreter);
|
||||
perl_construct (perl_current_interpreter);
|
||||
temp_script.interpreter = (PerlInterpreter *) perl_current_interpreter;
|
||||
perl_parse (perl_current_interpreter, weechat_perl_api_init,
|
||||
perl_args_count, perl_args, NULL);
|
||||
|
||||
|
||||
eval_pv (perl_weechat_code, TRUE);
|
||||
perl_argv[0] = (void *)filename;
|
||||
eval = weechat_perl_exec (&temp_script,
|
||||
@@ -445,7 +445,7 @@ weechat_perl_load (const char *filename)
|
||||
weechat_prefix ("error"), PERL_PLUGIN_NAME, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (*eval != 0)
|
||||
{
|
||||
if (*eval == 2)
|
||||
@@ -499,9 +499,9 @@ weechat_perl_load (const char *filename)
|
||||
free (eval);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
free (eval);
|
||||
|
||||
|
||||
if (!perl_registered_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -515,13 +515,13 @@ weechat_perl_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
perl_current_script = perl_registered_script;
|
||||
|
||||
|
||||
#ifdef MULTIPLICITY
|
||||
perl_current_script->interpreter = (PerlInterpreter *)perl_current_interpreter;
|
||||
#else
|
||||
perl_current_script->interpreter = strdup (pkgname);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* set input/close callbacks for buffers created by this script
|
||||
* (to restore callbacks after upgrade)
|
||||
@@ -531,7 +531,7 @@ weechat_perl_load (const char *filename)
|
||||
perl_current_script,
|
||||
&weechat_perl_api_buffer_input_data_cb,
|
||||
&weechat_perl_api_buffer_close_cb);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ weechat_perl_load_cb (void *data, const char *filename)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
weechat_perl_load (filename);
|
||||
}
|
||||
|
||||
@@ -564,13 +564,13 @@ weechat_perl_unload (struct t_plugin_script *script)
|
||||
weechat_gettext ("%s: unloading script \"%s\""),
|
||||
PERL_PLUGIN_NAME, script->name);
|
||||
}
|
||||
|
||||
|
||||
#ifdef MULTIPLICITY
|
||||
PERL_SET_CONTEXT (script->interpreter);
|
||||
#else
|
||||
eval_pv (script->interpreter, TRUE);
|
||||
#endif
|
||||
|
||||
|
||||
if (script->shutdown_func && script->shutdown_func[0])
|
||||
{
|
||||
rc = (int *)weechat_perl_exec (script,
|
||||
@@ -580,16 +580,16 @@ weechat_perl_unload (struct t_plugin_script *script)
|
||||
if (rc)
|
||||
free (rc);
|
||||
}
|
||||
|
||||
|
||||
interpreter = script->interpreter;
|
||||
|
||||
|
||||
if (perl_current_script == script)
|
||||
perl_current_script = (perl_current_script->prev_script) ?
|
||||
perl_current_script->prev_script : perl_current_script->next_script;
|
||||
|
||||
|
||||
script_remove (weechat_perl_plugin, &perl_scripts, &last_perl_script,
|
||||
script);
|
||||
|
||||
|
||||
#ifdef MULTIPLICITY
|
||||
if (interpreter)
|
||||
{
|
||||
@@ -610,7 +610,7 @@ void
|
||||
weechat_perl_unload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_perl_plugin, perl_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -649,7 +649,7 @@ weechat_perl_reload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
char *filename;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_perl_plugin, perl_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -681,11 +681,11 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char *path_script;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
script_display_list (weechat_perl_plugin, perl_scripts,
|
||||
@@ -756,7 +756,7 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_prefix ("error"), PERL_PLUGIN_NAME, "perl");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -773,9 +773,9 @@ weechat_perl_completion_cb (void *data, const char *completion_item,
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
script_completion (weechat_perl_plugin, completion, perl_scripts);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -789,17 +789,17 @@ weechat_perl_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "perl_script") == 0)
|
||||
{
|
||||
return script_infolist_list_scripts (weechat_perl_plugin,
|
||||
perl_scripts, pointer,
|
||||
arguments);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -815,13 +815,13 @@ weechat_perl_signal_debug_dump_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, PERL_PLUGIN_NAME) == 0))
|
||||
{
|
||||
script_print_log (weechat_perl_plugin, perl_scripts);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -837,10 +837,10 @@ weechat_perl_signal_buffer_closed_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (signal_data)
|
||||
script_remove_buffer_callbacks (perl_scripts, signal_data);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -872,7 +872,7 @@ weechat_perl_timer_action_cb (void *data, int remaining_calls)
|
||||
&perl_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -888,7 +888,7 @@ weechat_perl_signal_script_action_cb (void *data, const char *signal,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (strcmp (signal, "perl_script_install") == 0)
|
||||
@@ -908,7 +908,7 @@ weechat_perl_signal_script_action_cb (void *data, const char *signal,
|
||||
&perl_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -927,9 +927,9 @@ weechat_perl_signal_quit_upgrade_cb (void *data, const char *signal,
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
|
||||
perl_quit_or_upgrade = 1;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -951,12 +951,12 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
(void) perl_env;
|
||||
PERL_SYS_INIT3 (&a, (char ***)&perl_args_local, (char ***)&perl_env);
|
||||
#endif
|
||||
|
||||
|
||||
weechat_perl_plugin = plugin;
|
||||
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
perl_main = perl_alloc ();
|
||||
|
||||
|
||||
if (!perl_main)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -965,13 +965,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
PERL_PLUGIN_NAME);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
perl_construct (perl_main);
|
||||
perl_parse (perl_main, weechat_perl_api_init, perl_args_count,
|
||||
perl_args, NULL);
|
||||
eval_pv (perl_weechat_code, TRUE);
|
||||
#endif
|
||||
|
||||
|
||||
perl_quiet = 1;
|
||||
script_init (weechat_perl_plugin,
|
||||
argc,
|
||||
@@ -984,13 +984,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
&weechat_perl_signal_script_action_cb,
|
||||
&weechat_perl_load_cb);
|
||||
perl_quiet = 0;
|
||||
|
||||
|
||||
script_display_short_list (weechat_perl_plugin,
|
||||
perl_scripts);
|
||||
|
||||
|
||||
weechat_hook_signal ("quit", &weechat_perl_signal_quit_upgrade_cb, NULL);
|
||||
weechat_hook_signal ("upgrade", &weechat_perl_signal_quit_upgrade_cb, NULL);
|
||||
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -1006,7 +1006,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
perl_quiet = 1;
|
||||
script_end (plugin, &perl_scripts, &weechat_perl_unload_all);
|
||||
perl_quiet = 0;
|
||||
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
/* free perl intepreter */
|
||||
if (perl_main)
|
||||
@@ -1016,7 +1016,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
perl_main = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(PERL_SYS_TERM) && !defined(__FreeBSD__) && !defined(WIN32) && !defined(__CYGWIN__)
|
||||
/*
|
||||
* we call this function on all OS, but NOT on FreeBSD or Cygwin,
|
||||
@@ -1025,6 +1025,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
if (perl_quit_or_upgrade)
|
||||
PERL_SYS_TERM ();
|
||||
#endif
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -83,12 +83,12 @@ weechat_python_set_python2_bin ()
|
||||
char *versions[] = { "2", "2.7", "2.6", "2.5", "2.4", "2.3", "2.2", NULL };
|
||||
int num_paths, i, j, rc;
|
||||
struct stat stat_buf;
|
||||
|
||||
|
||||
python2_bin = NULL;
|
||||
|
||||
|
||||
dir_separator = weechat_info_get ("dir_separator", "");
|
||||
path = getenv ("PATH");
|
||||
|
||||
|
||||
if (dir_separator && path)
|
||||
{
|
||||
paths = weechat_string_split (path, ":", 0, 0, &num_paths);
|
||||
@@ -114,7 +114,7 @@ weechat_python_set_python2_bin ()
|
||||
weechat_string_free_split (paths);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!python2_bin)
|
||||
python2_bin = strdup ("python");
|
||||
}
|
||||
@@ -134,14 +134,14 @@ weechat_python_hashtable_map_cb (void *data,
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
dict = (PyObject *)data;
|
||||
|
||||
|
||||
dict_key = Py_BuildValue ("s", (const char *)key);
|
||||
dict_value = Py_BuildValue ("s", (const char *)value);
|
||||
|
||||
|
||||
PyDict_SetItem (dict, dict_key, dict_value);
|
||||
|
||||
|
||||
Py_DECREF (dict_key);
|
||||
Py_DECREF (dict_value);
|
||||
}
|
||||
@@ -155,18 +155,18 @@ PyObject *
|
||||
weechat_python_hashtable_to_dict (struct t_hashtable *hashtable)
|
||||
{
|
||||
PyObject *dict;
|
||||
|
||||
|
||||
dict = PyDict_New ();
|
||||
if (!dict)
|
||||
{
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
weechat_hashtable_map (hashtable,
|
||||
&weechat_python_hashtable_map_cb,
|
||||
dict);
|
||||
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
|
||||
PyObject *key, *value;
|
||||
Py_ssize_t pos;
|
||||
char *str_key, *str_value;
|
||||
|
||||
|
||||
hashtable = weechat_hashtable_new (hashtable_size,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -194,7 +194,7 @@ weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
pos = 0;
|
||||
while (PyDict_Next (dict, &pos, &key, &value))
|
||||
{
|
||||
@@ -202,7 +202,7 @@ weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
|
||||
str_value = PyString_AsString (value);
|
||||
weechat_hashtable_set (hashtable, str_key, str_value);
|
||||
}
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
@@ -223,9 +223,9 @@ weechat_python_exec (struct t_plugin_script *script,
|
||||
PyObject *rc;
|
||||
void *argv2[16], *ret_value;
|
||||
int i, argc, *ret_int;
|
||||
|
||||
|
||||
/* PyEval_AcquireLock (); */
|
||||
|
||||
|
||||
old_python_current_script = python_current_script;
|
||||
old_interpreter = NULL;
|
||||
if (script->interpreter)
|
||||
@@ -233,11 +233,11 @@ weechat_python_exec (struct t_plugin_script *script,
|
||||
old_interpreter = PyThreadState_Swap (NULL);
|
||||
PyThreadState_Swap (script->interpreter);
|
||||
}
|
||||
|
||||
|
||||
evMain = PyImport_AddModule ((char *) "__main__");
|
||||
evDict = PyModule_GetDict (evMain);
|
||||
evFunc = PyDict_GetItemString (evDict, function);
|
||||
|
||||
|
||||
if ( !(evFunc && PyCallable_Check (evFunc)) )
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -248,7 +248,7 @@ weechat_python_exec (struct t_plugin_script *script,
|
||||
PyThreadState_Swap (old_interpreter);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
python_current_script = script;
|
||||
|
||||
if (argv && argv[0])
|
||||
@@ -272,16 +272,16 @@ weechat_python_exec (struct t_plugin_script *script,
|
||||
{
|
||||
rc = PyObject_CallFunction (evFunc, NULL);
|
||||
}
|
||||
|
||||
|
||||
ret_value = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* ugly hack : rc = NULL while 'return weechat.WEECHAT_RC_OK ....
|
||||
* because of '#define WEECHAT_RC_OK 0'
|
||||
*/
|
||||
if (rc == NULL)
|
||||
rc = PyInt_FromLong (0);
|
||||
|
||||
|
||||
if (PyErr_Occurred())
|
||||
{
|
||||
PyErr_Print ();
|
||||
@@ -316,21 +316,21 @@ weechat_python_exec (struct t_plugin_script *script,
|
||||
"a valid value"),
|
||||
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, function);
|
||||
}
|
||||
|
||||
|
||||
if (ret_value == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: error in function \"%s\""),
|
||||
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, function);
|
||||
}
|
||||
|
||||
|
||||
/* PyEval_ReleaseThread (python_current_script->interpreter); */
|
||||
|
||||
|
||||
python_current_script = old_python_current_script;
|
||||
|
||||
|
||||
if (old_interpreter)
|
||||
PyThreadState_Swap (old_interpreter);
|
||||
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@@ -342,10 +342,10 @@ static PyObject *
|
||||
weechat_python_output (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *msg, *m, *p;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
|
||||
msg = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &msg))
|
||||
@@ -385,7 +385,7 @@ weechat_python_output (PyObject *self, PyObject *args)
|
||||
else
|
||||
strcat (python_buffer_output, m);
|
||||
}
|
||||
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
@@ -415,7 +415,7 @@ weechat_python_load (const char *filename)
|
||||
const char *weechat_home;
|
||||
char *p_home;
|
||||
int len;
|
||||
|
||||
|
||||
if ((fp = fopen (filename, "r")) == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -423,21 +423,21 @@ weechat_python_load (const char *filename)
|
||||
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if ((weechat_python_plugin->debug >= 1) || !python_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
PYTHON_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
|
||||
python_current_script = NULL;
|
||||
python_registered_script = NULL;
|
||||
|
||||
|
||||
/* PyEval_AcquireLock (); */
|
||||
python_current_interpreter = Py_NewInterpreter ();
|
||||
PySys_SetArgv(1, argv);
|
||||
|
||||
|
||||
if (python_current_interpreter == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -448,9 +448,9 @@ weechat_python_load (const char *filename)
|
||||
/* PyEval_ReleaseLock (); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
PyThreadState_Swap (python_current_interpreter);
|
||||
|
||||
|
||||
weechat_module = Py_InitModule ("weechat", weechat_python_funcs);
|
||||
|
||||
if ( weechat_module == NULL)
|
||||
@@ -460,7 +460,7 @@ weechat_python_load (const char *filename)
|
||||
"module"),
|
||||
weechat_prefix ("error"), PYTHON_PLUGIN_NAME);
|
||||
fclose (fp);
|
||||
|
||||
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
@@ -486,13 +486,13 @@ weechat_python_load (const char *filename)
|
||||
free (p_home);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* define some constants */
|
||||
weechat_dict = PyModule_GetDict(weechat_module);
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK", PyInt_FromLong((long) WEECHAT_RC_OK));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK_EAT", PyInt_FromLong((long) WEECHAT_RC_OK_EAT));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_ERROR", PyInt_FromLong((long) WEECHAT_RC_ERROR));
|
||||
|
||||
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_OK", PyInt_FromLong((long) WEECHAT_CONFIG_READ_OK));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_MEMORY_ERROR", PyInt_FromLong((long) WEECHAT_CONFIG_READ_MEMORY_ERROR));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_FILE_NOT_FOUND", PyInt_FromLong((long) WEECHAT_CONFIG_READ_FILE_NOT_FOUND));
|
||||
@@ -507,19 +507,19 @@ weechat_python_load (const char *filename)
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_OK_RESET", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_OK_RESET));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_ERROR", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_ERROR));
|
||||
|
||||
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_SORT", PyString_FromString(WEECHAT_LIST_POS_SORT));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_BEGINNING", PyString_FromString(WEECHAT_LIST_POS_BEGINNING));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_END", PyString_FromString(WEECHAT_LIST_POS_END));
|
||||
|
||||
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_LOW", PyString_FromString(WEECHAT_HOTLIST_LOW));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_MESSAGE", PyString_FromString(WEECHAT_HOTLIST_MESSAGE));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_PRIVATE", PyString_FromString(WEECHAT_HOTLIST_PRIVATE));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_HIGHLIGHT", PyString_FromString(WEECHAT_HOTLIST_HIGHLIGHT));
|
||||
|
||||
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_PROCESS_RUNNING", PyInt_FromLong((long) WEECHAT_HOOK_PROCESS_RUNNING));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_PROCESS_ERROR", PyInt_FromLong((long) WEECHAT_HOOK_PROCESS_ERROR));
|
||||
|
||||
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_OK", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_OK));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND));
|
||||
@@ -529,11 +529,11 @@ weechat_python_load (const char *filename)
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_MEMORY_ERROR", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_MEMORY_ERROR));
|
||||
|
||||
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_STRING", PyString_FromString(WEECHAT_HOOK_SIGNAL_STRING));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_INT", PyString_FromString(WEECHAT_HOOK_SIGNAL_INT));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_POINTER", PyString_FromString(WEECHAT_HOOK_SIGNAL_POINTER));
|
||||
|
||||
|
||||
weechat_outputs = Py_InitModule("weechatOutputs",
|
||||
weechat_python_output_funcs);
|
||||
if (weechat_outputs == NULL)
|
||||
@@ -558,9 +558,9 @@ weechat_python_load (const char *filename)
|
||||
weechat_prefix ("error"), PYTHON_PLUGIN_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
python_current_script_filename = filename;
|
||||
|
||||
|
||||
if (PyRun_SimpleFile (fp, filename) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -570,7 +570,7 @@ weechat_python_load (const char *filename)
|
||||
|
||||
if (PyErr_Occurred ())
|
||||
PyErr_Print ();
|
||||
|
||||
|
||||
/* if script was registered, removing from list */
|
||||
if (python_current_script != NULL)
|
||||
{
|
||||
@@ -578,10 +578,10 @@ weechat_python_load (const char *filename)
|
||||
&python_scripts, &last_python_script,
|
||||
python_current_script);
|
||||
}
|
||||
|
||||
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -589,14 +589,14 @@ weechat_python_load (const char *filename)
|
||||
PyErr_Print ();
|
||||
|
||||
fclose (fp);
|
||||
|
||||
|
||||
if (!python_registered_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"register\" not "
|
||||
"found (or failed) in file \"%s\""),
|
||||
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, filename);
|
||||
|
||||
|
||||
if (PyErr_Occurred ())
|
||||
PyErr_Print ();
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
@@ -605,10 +605,10 @@ weechat_python_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
python_current_script = python_registered_script;
|
||||
|
||||
|
||||
python_current_script->interpreter = (PyThreadState *) python_current_interpreter;
|
||||
/* PyEval_ReleaseThread (python_current_script->interpreter); */
|
||||
|
||||
|
||||
/*
|
||||
* set input/close callbacks for buffers created by this script
|
||||
* (to restore callbacks after upgrade)
|
||||
@@ -618,7 +618,7 @@ weechat_python_load (const char *filename)
|
||||
python_current_script,
|
||||
&weechat_python_api_buffer_input_data_cb,
|
||||
&weechat_python_api_buffer_close_cb);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ weechat_python_load_cb (void *data, const char *filename)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
weechat_python_load (filename);
|
||||
}
|
||||
|
||||
@@ -645,14 +645,14 @@ weechat_python_unload (struct t_plugin_script *script)
|
||||
int *rc;
|
||||
void *interpreter;
|
||||
PyThreadState *old_interpreter;
|
||||
|
||||
|
||||
if ((weechat_python_plugin->debug >= 1) || !python_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: unloading script \"%s\""),
|
||||
PYTHON_PLUGIN_NAME, script->name);
|
||||
}
|
||||
|
||||
|
||||
if (script->shutdown_func && script->shutdown_func[0])
|
||||
{
|
||||
rc = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT,
|
||||
@@ -660,20 +660,20 @@ weechat_python_unload (struct t_plugin_script *script)
|
||||
if (rc)
|
||||
free (rc);
|
||||
}
|
||||
|
||||
|
||||
old_interpreter = PyThreadState_Swap (NULL);
|
||||
interpreter = script->interpreter;
|
||||
|
||||
|
||||
if (python_current_script == script)
|
||||
python_current_script = (python_current_script->prev_script) ?
|
||||
python_current_script->prev_script : python_current_script->next_script;
|
||||
|
||||
|
||||
script_remove (weechat_python_plugin, &python_scripts, &last_python_script,
|
||||
script);
|
||||
|
||||
|
||||
PyThreadState_Swap (interpreter);
|
||||
Py_EndInterpreter (interpreter);
|
||||
|
||||
|
||||
if (old_interpreter)
|
||||
PyThreadState_Swap (old_interpreter);
|
||||
}
|
||||
@@ -686,7 +686,7 @@ void
|
||||
weechat_python_unload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_python_plugin, python_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -725,7 +725,7 @@ weechat_python_reload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
char *filename;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_python_plugin, python_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -757,7 +757,7 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char *path_script;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
@@ -833,7 +833,7 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
"python");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -850,9 +850,9 @@ weechat_python_completion_cb (void *data, const char *completion_item,
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
script_completion (weechat_python_plugin, completion, python_scripts);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -867,12 +867,12 @@ weechat_python_info_cb (void *data, const char *info_name,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) arguments;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (info_name, "python2_bin") == 0)
|
||||
{
|
||||
return python2_bin;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -886,17 +886,17 @@ weechat_python_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "python_script") == 0)
|
||||
{
|
||||
return script_infolist_list_scripts (weechat_python_plugin,
|
||||
python_scripts, pointer,
|
||||
arguments);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -913,13 +913,13 @@ weechat_python_signal_debug_dump_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, PYTHON_PLUGIN_NAME) == 0))
|
||||
{
|
||||
script_print_log (weechat_python_plugin, python_scripts);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -937,10 +937,10 @@ weechat_python_signal_buffer_closed_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (signal_data)
|
||||
script_remove_buffer_callbacks (python_scripts, signal_data);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -972,7 +972,7 @@ weechat_python_timer_action_cb (void *data, int remaining_calls)
|
||||
&python_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -988,7 +988,7 @@ weechat_python_signal_script_action_cb (void *data, const char *signal,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (strcmp (signal, "python_script_install") == 0)
|
||||
@@ -1008,7 +1008,7 @@ weechat_python_signal_script_action_cb (void *data, const char *signal,
|
||||
&python_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1020,7 +1020,7 @@ int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
weechat_python_plugin = plugin;
|
||||
|
||||
|
||||
/*
|
||||
* hook info to get path to python 2.x interpreter
|
||||
* (some scripts using hook_process need that)
|
||||
@@ -1030,10 +1030,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
N_("path to python 2.x interpreter"),
|
||||
NULL,
|
||||
&weechat_python_info_cb, NULL);
|
||||
|
||||
|
||||
/* init stdout/stderr buffer */
|
||||
python_buffer_output[0] = '\0';
|
||||
|
||||
|
||||
Py_Initialize ();
|
||||
if (Py_IsInitialized () == 0)
|
||||
{
|
||||
@@ -1043,7 +1043,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
weechat_prefix ("error"), PYTHON_PLUGIN_NAME);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
PyEval_InitThreads();
|
||||
/* python_mainThreadState = PyThreadState_Swap(NULL); */
|
||||
python_mainThreadState = PyEval_SaveThread();
|
||||
@@ -1070,10 +1070,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
&weechat_python_signal_script_action_cb,
|
||||
&weechat_python_load_cb);
|
||||
python_quiet = 0;
|
||||
|
||||
|
||||
script_display_short_list (weechat_python_plugin,
|
||||
python_scripts);
|
||||
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -1089,7 +1089,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
python_quiet = 1;
|
||||
script_end (plugin, &python_scripts, &weechat_python_unload_all);
|
||||
python_quiet = 0;
|
||||
|
||||
|
||||
/* free Python interpreter */
|
||||
if (python_mainThreadState != NULL)
|
||||
{
|
||||
@@ -1098,7 +1098,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
/* PyEval_ReleaseLock (); */
|
||||
python_mainThreadState = NULL;
|
||||
}
|
||||
|
||||
|
||||
Py_Finalize ();
|
||||
if (Py_IsInitialized () != 0)
|
||||
{
|
||||
@@ -1106,7 +1106,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
weechat_gettext ("%s%s: unable to free interpreter"),
|
||||
weechat_prefix ("error"), PYTHON_PLUGIN_NAME);
|
||||
}
|
||||
|
||||
|
||||
/* free some data */
|
||||
if (python2_bin)
|
||||
free (python2_bin);
|
||||
@@ -1114,6 +1114,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
free (python_action_install_list);
|
||||
if (python_action_remove_list)
|
||||
free (python_action_remove_list);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
+1039
-1039
File diff suppressed because it is too large
Load Diff
@@ -113,12 +113,12 @@ weechat_ruby_hashtable_map_cb (void *data,
|
||||
const void *value)
|
||||
{
|
||||
VALUE *hash;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
hash = (VALUE *)data;
|
||||
|
||||
|
||||
rb_hash_aset (hash[0], rb_str_new2 ((char *)key),
|
||||
rb_str_new2 ((char *)value));
|
||||
}
|
||||
@@ -139,7 +139,7 @@ weechat_ruby_hashtable_to_hash (struct t_hashtable *hashtable)
|
||||
weechat_hashtable_map (hashtable,
|
||||
&weechat_ruby_hashtable_map_cb,
|
||||
&hash);
|
||||
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ int
|
||||
weechat_ruby_hash_foreach_cb (VALUE key, VALUE value, void *arg)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
|
||||
hashtable = (struct t_hashtable *)arg;
|
||||
if ((TYPE(key) == T_STRING) && (TYPE(value) == T_STRING))
|
||||
{
|
||||
@@ -169,7 +169,7 @@ struct t_hashtable *
|
||||
weechat_ruby_hash_to_hashtable (VALUE hash, int hashtable_size)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
|
||||
hashtable = weechat_hashtable_new (hashtable_size,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -177,10 +177,10 @@ weechat_ruby_hash_to_hashtable (VALUE hash, int hashtable_size)
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
rb_hash_foreach (hash, &weechat_ruby_hash_foreach_cb,
|
||||
(unsigned long)hashtable);
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ VALUE
|
||||
rb_protect_funcall (VALUE recv, ID mid, int *state, int argc, VALUE *argv)
|
||||
{
|
||||
struct protect_call_arg arg;
|
||||
|
||||
|
||||
arg.recv = recv;
|
||||
arg.mid = mid;
|
||||
arg.argc = argc;
|
||||
@@ -227,7 +227,7 @@ weechat_ruby_print_exception (VALUE err)
|
||||
char* cline;
|
||||
char* err_msg;
|
||||
char* err_class;
|
||||
|
||||
|
||||
backtrace = rb_protect_funcall (err, rb_intern("backtrace"),
|
||||
&ruby_error, 0, NULL);
|
||||
|
||||
@@ -238,7 +238,7 @@ weechat_ruby_print_exception (VALUE err)
|
||||
&ruby_error, 0, NULL),
|
||||
rb_intern("name"), &ruby_error, 0, NULL);
|
||||
err_class = StringValuePtr(tmp2);
|
||||
|
||||
|
||||
if (strcmp (err_class, "SyntaxError") == 0)
|
||||
{
|
||||
tmp3 = rb_inspect(err);
|
||||
@@ -285,12 +285,12 @@ weechat_ruby_print_exception (VALUE err)
|
||||
weechat_prefix ("error"), RUBY_PLUGIN_NAME,
|
||||
cline);
|
||||
}
|
||||
|
||||
|
||||
if (cline)
|
||||
free (cline);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -308,10 +308,10 @@ weechat_ruby_exec (struct t_plugin_script *script,
|
||||
VALUE argv2[16];
|
||||
void *ret_value;
|
||||
struct t_plugin_script *old_ruby_current_script;
|
||||
|
||||
|
||||
old_ruby_current_script = ruby_current_script;
|
||||
ruby_current_script = script;
|
||||
|
||||
|
||||
argc = 0;
|
||||
if (format && format[0])
|
||||
{
|
||||
@@ -332,7 +332,7 @@ weechat_ruby_exec (struct t_plugin_script *script,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (argc > 0)
|
||||
{
|
||||
rc = rb_protect_funcall ((VALUE) script->interpreter,
|
||||
@@ -345,19 +345,19 @@ weechat_ruby_exec (struct t_plugin_script *script,
|
||||
rb_intern(function),
|
||||
&ruby_error, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
if (ruby_error)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to run function \"%s\""),
|
||||
weechat_prefix ("error"), RUBY_PLUGIN_NAME, function);
|
||||
|
||||
|
||||
err = rb_gv_get("$!");
|
||||
weechat_ruby_print_exception(err);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if ((TYPE(rc) == T_STRING) && (ret_type == WEECHAT_SCRIPT_EXEC_STRING))
|
||||
{
|
||||
if (StringValuePtr (rc))
|
||||
@@ -386,7 +386,7 @@ weechat_ruby_exec (struct t_plugin_script *script,
|
||||
ruby_current_script = old_ruby_current_script;
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (ret_value == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -396,9 +396,9 @@ weechat_ruby_exec (struct t_plugin_script *script,
|
||||
ruby_current_script = old_ruby_current_script;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ruby_current_script = old_ruby_current_script;
|
||||
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@@ -410,12 +410,12 @@ static VALUE
|
||||
weechat_ruby_output (VALUE self, VALUE str)
|
||||
{
|
||||
char *msg, *p, *m;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
|
||||
msg = strdup(StringValuePtr(str));
|
||||
|
||||
|
||||
m = msg;
|
||||
while ((p = strchr (m, '\n')) != NULL)
|
||||
{
|
||||
@@ -431,7 +431,7 @@ weechat_ruby_output (VALUE self, VALUE str)
|
||||
ruby_buffer_output[0] = '\0';
|
||||
m = ++p;
|
||||
}
|
||||
|
||||
|
||||
if (strlen(m) + strlen(ruby_buffer_output) > sizeof(ruby_buffer_output))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -445,7 +445,7 @@ weechat_ruby_output (VALUE self, VALUE str)
|
||||
|
||||
if (msg)
|
||||
free (msg);
|
||||
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ weechat_ruby_output_flush (VALUE self)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ weechat_ruby_load (const char *filename)
|
||||
VALUE curModule, ruby_retcode, err, argv[1];
|
||||
int ruby_error;
|
||||
struct stat buf;
|
||||
|
||||
|
||||
if (stat (filename, &buf) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -481,17 +481,17 @@ weechat_ruby_load (const char *filename)
|
||||
weechat_prefix ("error"), RUBY_PLUGIN_NAME, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if ((weechat_ruby_plugin->debug >= 1) || !ruby_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
RUBY_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
|
||||
ruby_current_script = NULL;
|
||||
ruby_registered_script = NULL;
|
||||
|
||||
|
||||
snprintf (modname, sizeof(modname), "%s%d", MOD_NAME_PREFIX, ruby_num);
|
||||
ruby_num++;
|
||||
|
||||
@@ -502,14 +502,14 @@ weechat_ruby_load (const char *filename)
|
||||
argv[0] = rb_str_new2 (filename);
|
||||
ruby_retcode = rb_protect_funcall (curModule, rb_intern("load_eval_file"),
|
||||
&ruby_error, 1, argv);
|
||||
|
||||
|
||||
if (ruby_retcode == Qnil)
|
||||
{
|
||||
err = rb_gv_get("$!");
|
||||
weechat_ruby_print_exception(err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (NUM2INT(ruby_retcode) != 0)
|
||||
{
|
||||
switch (NUM2INT(ruby_retcode))
|
||||
@@ -542,20 +542,20 @@ weechat_ruby_load (const char *filename)
|
||||
{
|
||||
weechat_ruby_print_exception(rb_iv_get(curModule, "@load_eval_file_error"));
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
(void) rb_protect_funcall (curModule, rb_intern("weechat_init"),
|
||||
&ruby_error, 0, NULL);
|
||||
|
||||
|
||||
if (ruby_error)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to eval function "
|
||||
"\"weechat_init\" in file \"%s\""),
|
||||
weechat_prefix ("error"), RUBY_PLUGIN_NAME, filename);
|
||||
|
||||
|
||||
err = rb_gv_get("$!");
|
||||
weechat_ruby_print_exception(err);
|
||||
|
||||
@@ -568,7 +568,7 @@ weechat_ruby_load (const char *filename)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (!ruby_registered_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -578,10 +578,10 @@ weechat_ruby_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
ruby_current_script = ruby_registered_script;
|
||||
|
||||
|
||||
ruby_current_script->interpreter = (VALUE *) curModule;
|
||||
rb_gc_register_address (ruby_current_script->interpreter);
|
||||
|
||||
|
||||
/*
|
||||
* set input/close callbacks for buffers created by this script
|
||||
* (to restore callbacks after upgrade)
|
||||
@@ -591,7 +591,7 @@ weechat_ruby_load (const char *filename)
|
||||
ruby_current_script,
|
||||
&weechat_ruby_api_buffer_input_data_cb,
|
||||
&weechat_ruby_api_buffer_close_cb);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -604,7 +604,7 @@ weechat_ruby_load_cb (void *data, const char *filename)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
weechat_ruby_load (filename);
|
||||
}
|
||||
|
||||
@@ -617,14 +617,14 @@ weechat_ruby_unload (struct t_plugin_script *script)
|
||||
{
|
||||
int *rc;
|
||||
void *interpreter;
|
||||
|
||||
|
||||
if ((weechat_ruby_plugin->debug >= 1) || !ruby_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: unloading script \"%s\""),
|
||||
RUBY_PLUGIN_NAME, script->name);
|
||||
}
|
||||
|
||||
|
||||
if (script->shutdown_func && script->shutdown_func[0])
|
||||
{
|
||||
rc = (int *)weechat_ruby_exec (script,
|
||||
@@ -634,16 +634,16 @@ weechat_ruby_unload (struct t_plugin_script *script)
|
||||
if (rc)
|
||||
free (rc);
|
||||
}
|
||||
|
||||
|
||||
interpreter = script->interpreter;
|
||||
|
||||
|
||||
if (ruby_current_script == script)
|
||||
ruby_current_script = (ruby_current_script->prev_script) ?
|
||||
ruby_current_script->prev_script : ruby_current_script->next_script;
|
||||
|
||||
|
||||
script_remove (weechat_ruby_plugin, &ruby_scripts, &last_ruby_script,
|
||||
script);
|
||||
|
||||
|
||||
if (interpreter)
|
||||
rb_gc_unregister_address (interpreter);
|
||||
}
|
||||
@@ -656,7 +656,7 @@ void
|
||||
weechat_ruby_unload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_ruby_plugin, ruby_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -682,7 +682,7 @@ weechat_ruby_reload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
char *filename;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_ruby_plugin, ruby_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -727,11 +727,11 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char *path_script;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
script_display_list (weechat_ruby_plugin, ruby_scripts,
|
||||
@@ -802,7 +802,7 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_prefix ("error"), RUBY_PLUGIN_NAME, "ruby");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -819,9 +819,9 @@ weechat_ruby_completion_cb (void *data, const char *completion_item,
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
script_completion (weechat_ruby_plugin, completion, ruby_scripts);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -835,17 +835,17 @@ weechat_ruby_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "ruby_script") == 0)
|
||||
{
|
||||
return script_infolist_list_scripts (weechat_ruby_plugin,
|
||||
ruby_scripts, pointer,
|
||||
arguments);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -861,13 +861,13 @@ weechat_ruby_signal_debug_dump_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, RUBY_PLUGIN_NAME) == 0))
|
||||
{
|
||||
script_print_log (weechat_ruby_plugin, ruby_scripts);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -883,10 +883,10 @@ weechat_ruby_signal_buffer_closed_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (signal_data)
|
||||
script_remove_buffer_callbacks (ruby_scripts, signal_data);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -918,7 +918,7 @@ weechat_ruby_timer_action_cb (void *data, int remaining_calls)
|
||||
&ruby_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -934,7 +934,7 @@ weechat_ruby_signal_script_action_cb (void *data, const char *signal,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (strcmp (signal, "ruby_script_install") == 0)
|
||||
@@ -954,7 +954,7 @@ weechat_ruby_signal_script_action_cb (void *data, const char *signal,
|
||||
&ruby_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1023,25 +1023,25 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
" end\n"
|
||||
"end\n"
|
||||
};
|
||||
|
||||
|
||||
weechat_ruby_plugin = plugin;
|
||||
|
||||
|
||||
ruby_error = 0;
|
||||
|
||||
|
||||
/* init stdout/stderr buffer */
|
||||
ruby_buffer_output[0] = '\0';
|
||||
|
||||
|
||||
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
|
||||
RUBY_INIT_STACK;
|
||||
#endif
|
||||
|
||||
|
||||
ruby_init ();
|
||||
ruby_init_loadpath ();
|
||||
ruby_script ("__weechat_plugin__");
|
||||
|
||||
|
||||
ruby_mWeechat = rb_define_module("Weechat");
|
||||
weechat_ruby_api_init (ruby_mWeechat);
|
||||
|
||||
|
||||
/* redirect stdin and stdout */
|
||||
ruby_mWeechatOutputs = rb_define_module("WeechatOutputs");
|
||||
rb_define_singleton_method(ruby_mWeechatOutputs, "write",
|
||||
@@ -1064,7 +1064,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
weechat_ruby_print_exception(err);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
ruby_quiet = 1;
|
||||
script_init (weechat_ruby_plugin,
|
||||
argc,
|
||||
@@ -1077,10 +1077,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
&weechat_ruby_signal_script_action_cb,
|
||||
&weechat_ruby_load_cb);
|
||||
ruby_quiet = 0;
|
||||
|
||||
|
||||
script_display_short_list (weechat_ruby_plugin,
|
||||
ruby_scripts);
|
||||
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -1096,8 +1096,8 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
ruby_quiet = 1;
|
||||
script_end (plugin, &ruby_scripts, &weechat_ruby_unload_all);
|
||||
ruby_quiet = 0;
|
||||
|
||||
|
||||
ruby_cleanup (0);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
+190
-190
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ struct t_script_callback *
|
||||
script_callback_alloc ()
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
|
||||
|
||||
new_script_callback = malloc (sizeof (*new_script_callback));
|
||||
if (new_script_callback)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ script_callback_alloc ()
|
||||
new_script_callback->upgrade_file = NULL;
|
||||
return new_script_callback;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -121,9 +121,9 @@ script_callback_remove (struct t_plugin_script *script,
|
||||
script_callback->prev_callback;
|
||||
if (script->callbacks == script_callback)
|
||||
script->callbacks = script_callback->next_callback;
|
||||
|
||||
|
||||
script_callback_free_data (script_callback);
|
||||
|
||||
|
||||
free (script_callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ void
|
||||
script_config_read (struct t_weechat_plugin *weechat_plugin)
|
||||
{
|
||||
const char *string;
|
||||
|
||||
|
||||
string = weechat_config_get_plugin (SCRIPT_OPTION_CHECK_LICENSE);
|
||||
if (!string)
|
||||
{
|
||||
@@ -73,9 +73,9 @@ script_config_cb (void *data, const char *option, const char *value)
|
||||
/* make C compiler happy */
|
||||
(void) option;
|
||||
(void) value;
|
||||
|
||||
|
||||
script_config_read (data);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -112,10 +112,10 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
char *string, *completion;
|
||||
char signal_name[128];
|
||||
int length, i, auto_load_scripts;
|
||||
|
||||
|
||||
/* read script configuration */
|
||||
script_config_read (weechat_plugin);
|
||||
|
||||
|
||||
/* add hook for config option */
|
||||
length = strlen (weechat_plugin->name) + 64;
|
||||
string = malloc (length);
|
||||
@@ -126,7 +126,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
weechat_hook_config (string, &script_config_cb, weechat_plugin);
|
||||
free (string);
|
||||
}
|
||||
|
||||
|
||||
/* create directories in WeeChat home */
|
||||
weechat_mkdir_home (weechat_plugin->name, 0755);
|
||||
length = strlen (weechat_plugin->name) + strlen ("/autoload") + 1;
|
||||
@@ -137,7 +137,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
weechat_mkdir_home (string, 0755);
|
||||
free (string);
|
||||
}
|
||||
|
||||
|
||||
/* add command */
|
||||
completion = NULL;
|
||||
length = strlen (weechat_plugin->name) + 16;
|
||||
@@ -182,7 +182,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
free (string);
|
||||
if (completion)
|
||||
free (completion);
|
||||
|
||||
|
||||
/* add completion and infolist */
|
||||
length = strlen (weechat_plugin->name) + 16;
|
||||
string = malloc (length);
|
||||
@@ -197,13 +197,13 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
callback_infolist, NULL);
|
||||
free (string);
|
||||
}
|
||||
|
||||
|
||||
/* add signal for "debug_dump" */
|
||||
weechat_hook_signal ("debug_dump", callback_signal_debug_dump, NULL);
|
||||
|
||||
|
||||
/* add signal for "buffer_closed" */
|
||||
weechat_hook_signal ("buffer_closed", callback_signal_buffer_closed, NULL);
|
||||
|
||||
|
||||
/* add signal for a script action (install/remove) */
|
||||
snprintf (signal_name, sizeof (signal_name), "%s_script_install",
|
||||
weechat_plugin->name);
|
||||
@@ -211,7 +211,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
snprintf (signal_name, sizeof (signal_name), "%s_script_remove",
|
||||
weechat_plugin->name);
|
||||
weechat_hook_signal (signal_name, callback_signal_script_action, NULL);
|
||||
|
||||
|
||||
/* parse arguments */
|
||||
auto_load_scripts = 1;
|
||||
for (i = 0; i < argc; i++)
|
||||
@@ -222,7 +222,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
auto_load_scripts = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* autoload scripts */
|
||||
if (auto_load_scripts)
|
||||
{
|
||||
@@ -241,17 +241,17 @@ script_valid (struct t_plugin_script *scripts,
|
||||
struct t_plugin_script *script)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
if (!script)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_script = scripts; ptr_script;
|
||||
ptr_script = ptr_script->next_script)
|
||||
{
|
||||
if (ptr_script == script)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* script not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -266,13 +266,13 @@ char *
|
||||
script_ptr2str (void *pointer)
|
||||
{
|
||||
char pointer_str[128];
|
||||
|
||||
|
||||
if (!pointer)
|
||||
return strdup ("");
|
||||
|
||||
|
||||
snprintf (pointer_str, sizeof (pointer_str),
|
||||
"0x%lx", (long unsigned int)pointer);
|
||||
|
||||
|
||||
return strdup (pointer_str);
|
||||
}
|
||||
|
||||
@@ -285,14 +285,14 @@ script_str2ptr (const char *pointer_str)
|
||||
{
|
||||
long unsigned int value;
|
||||
int rc;
|
||||
|
||||
|
||||
if (!pointer_str || (pointer_str[0] != '0') || (pointer_str[1] != 'x'))
|
||||
return NULL;
|
||||
|
||||
|
||||
rc = sscanf (pointer_str + 2, "%lx", &value);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
return (void *)value;
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ script_auto_load (struct t_weechat_plugin *weechat_plugin,
|
||||
const char *dir_home;
|
||||
char *dir_name;
|
||||
int dir_length;
|
||||
|
||||
|
||||
/* build directory, adding WeeChat home */
|
||||
dir_home = weechat_info_get ("weechat_dir", "");
|
||||
if (!dir_home)
|
||||
@@ -316,11 +316,11 @@ script_auto_load (struct t_weechat_plugin *weechat_plugin,
|
||||
dir_name = malloc (dir_length);
|
||||
if (!dir_name)
|
||||
return;
|
||||
|
||||
|
||||
snprintf (dir_name, dir_length,
|
||||
"%s/%s/autoload", dir_home, weechat_plugin->name);
|
||||
weechat_exec_on_files (dir_name, 0, NULL, callback);
|
||||
|
||||
|
||||
free (dir_name);
|
||||
}
|
||||
|
||||
@@ -333,14 +333,14 @@ script_search (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *scripts, const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
for (ptr_script = scripts; ptr_script;
|
||||
ptr_script = ptr_script->next_script)
|
||||
{
|
||||
if (weechat_strcasecmp (ptr_script->name, name) == 0)
|
||||
return ptr_script;
|
||||
}
|
||||
|
||||
|
||||
/* script not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -356,7 +356,7 @@ script_search_by_full_name (struct t_plugin_script *scripts,
|
||||
{
|
||||
char *base_name;
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
for (ptr_script = scripts; ptr_script;
|
||||
ptr_script = ptr_script->next_script)
|
||||
{
|
||||
@@ -364,7 +364,7 @@ script_search_by_full_name (struct t_plugin_script *scripts,
|
||||
if (strcmp (base_name, full_name) == 0)
|
||||
return ptr_script;
|
||||
}
|
||||
|
||||
|
||||
/* script not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -381,10 +381,10 @@ script_search_path (struct t_weechat_plugin *weechat_plugin,
|
||||
const char *dir_home, *dir_system;
|
||||
int length;
|
||||
struct stat st;
|
||||
|
||||
|
||||
if (filename[0] == '~')
|
||||
return weechat_string_expand_home (filename);
|
||||
|
||||
|
||||
dir_home = weechat_info_get ("weechat_dir", "");
|
||||
if (dir_home)
|
||||
{
|
||||
@@ -414,7 +414,7 @@ script_search_path (struct t_weechat_plugin *weechat_plugin,
|
||||
return final_name;
|
||||
free (final_name);
|
||||
}
|
||||
|
||||
|
||||
/* try WeeChat user's dir */
|
||||
length = strlen (dir_home) + strlen (filename) + 16;
|
||||
final_name = malloc (length);
|
||||
@@ -427,7 +427,7 @@ script_search_path (struct t_weechat_plugin *weechat_plugin,
|
||||
free (final_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* try WeeChat system dir */
|
||||
dir_system = weechat_info_get ("weechat_sharedir", "");
|
||||
if (dir_system)
|
||||
@@ -444,7 +444,7 @@ script_search_path (struct t_weechat_plugin *weechat_plugin,
|
||||
free (final_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return strdup (filename);
|
||||
}
|
||||
|
||||
@@ -526,7 +526,7 @@ script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
const char *charset)
|
||||
{
|
||||
struct t_plugin_script *new_script;
|
||||
|
||||
|
||||
if (strchr (name, ' '))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -535,7 +535,7 @@ script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
weechat_plugin->name, name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (script_option_check_license
|
||||
&& (weechat_strcmp_ignore_chars (weechat_plugin->license, license,
|
||||
"0123456789-.,/\\()[]{}", 0) != 0))
|
||||
@@ -546,7 +546,7 @@ script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
weechat_prefix ("error"), weechat_plugin->name,
|
||||
license, name, weechat_plugin->license);
|
||||
}
|
||||
|
||||
|
||||
new_script = malloc (sizeof (*new_script));
|
||||
if (new_script)
|
||||
{
|
||||
@@ -561,16 +561,16 @@ script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
strdup (shutdown_func) : NULL;
|
||||
new_script->charset = (charset) ? strdup (charset) : NULL;
|
||||
new_script->callbacks = NULL;
|
||||
|
||||
|
||||
script_insert_sorted (weechat_plugin, scripts, last_script, new_script);
|
||||
|
||||
|
||||
return new_script;
|
||||
}
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("%s: error loading script \"%s\" (not enough memory)"),
|
||||
weechat_plugin->name, name);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *ptr_script;
|
||||
struct t_script_callback *new_script_callback_input;
|
||||
struct t_script_callback *new_script_callback_close;
|
||||
|
||||
|
||||
infolist = weechat_infolist_get ("buffer", NULL, NULL);
|
||||
if (infolist)
|
||||
{
|
||||
@@ -621,7 +621,7 @@ script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin,
|
||||
"localvar_script_close_cb");
|
||||
script_close_cb_data = weechat_buffer_get_string (ptr_buffer,
|
||||
"localvar_script_close_cb_data");
|
||||
|
||||
|
||||
if (script_input_cb && script_input_cb[0])
|
||||
{
|
||||
new_script_callback_input = script_callback_alloc ();
|
||||
@@ -681,7 +681,7 @@ script_remove_buffer_callbacks (struct t_plugin_script *scripts,
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
struct t_script_callback *ptr_script_callback, *next_script_callback;
|
||||
|
||||
|
||||
for (ptr_script = scripts; ptr_script;
|
||||
ptr_script = ptr_script->next_script)
|
||||
{
|
||||
@@ -689,10 +689,10 @@ script_remove_buffer_callbacks (struct t_plugin_script *scripts,
|
||||
while (ptr_script_callback)
|
||||
{
|
||||
next_script_callback = ptr_script_callback->next_callback;
|
||||
|
||||
|
||||
if (ptr_script_callback->buffer == buffer)
|
||||
script_callback_remove (ptr_script, ptr_script_callback);
|
||||
|
||||
|
||||
ptr_script_callback = next_script_callback;
|
||||
}
|
||||
}
|
||||
@@ -709,7 +709,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script)
|
||||
{
|
||||
struct t_script_callback *ptr_script_callback, *next_script_callback;
|
||||
|
||||
|
||||
for (ptr_script_callback = script->callbacks; ptr_script_callback;
|
||||
ptr_script_callback = ptr_script_callback->next_callback)
|
||||
{
|
||||
@@ -719,12 +719,12 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
weechat_unhook (ptr_script_callback->hook);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_script_callback = script->callbacks;
|
||||
while (ptr_script_callback)
|
||||
{
|
||||
next_script_callback = ptr_script_callback->next_callback;
|
||||
|
||||
|
||||
/* free config file */
|
||||
if (ptr_script_callback->config_file
|
||||
&& !ptr_script_callback->config_section
|
||||
@@ -734,11 +734,11 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
weechat_config_write (ptr_script_callback->config_file);
|
||||
weechat_config_free (ptr_script_callback->config_file);
|
||||
}
|
||||
|
||||
|
||||
/* remove bar item */
|
||||
if (ptr_script_callback->bar_item)
|
||||
weechat_bar_item_remove (ptr_script_callback->bar_item);
|
||||
|
||||
|
||||
/* remove buffer */
|
||||
if (ptr_script_callback->buffer)
|
||||
{
|
||||
@@ -751,13 +751,13 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
}
|
||||
weechat_buffer_close (ptr_script_callback->buffer);
|
||||
}
|
||||
|
||||
|
||||
ptr_script_callback = next_script_callback;
|
||||
}
|
||||
|
||||
|
||||
/* remove all callbacks created by this script */
|
||||
script_callback_remove_all (script);
|
||||
|
||||
|
||||
/* free data */
|
||||
if (script->filename)
|
||||
free (script->filename);
|
||||
@@ -775,7 +775,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
free (script->shutdown_func);
|
||||
if (script->charset)
|
||||
free (script->charset);
|
||||
|
||||
|
||||
/* remove script from list */
|
||||
if (script->prev_script)
|
||||
(script->prev_script)->next_script = script->next_script;
|
||||
@@ -785,7 +785,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
*scripts = script->next_script;
|
||||
if (*last_script == script)
|
||||
*last_script = script->prev_script;
|
||||
|
||||
|
||||
/* free script */
|
||||
free (script);
|
||||
}
|
||||
@@ -818,9 +818,9 @@ script_action_add (char **action_list, const char *name)
|
||||
{
|
||||
int length;
|
||||
char *action_list2;
|
||||
|
||||
|
||||
length = strlen (name);
|
||||
|
||||
|
||||
if (!(*action_list))
|
||||
{
|
||||
*action_list = malloc (length + 1);
|
||||
@@ -853,7 +853,7 @@ script_remove_file (struct t_weechat_plugin *weechat_plugin, const char *name,
|
||||
{
|
||||
int num_found, i;
|
||||
char *path_script;
|
||||
|
||||
|
||||
num_found = 0;
|
||||
i = 0;
|
||||
while (i < 2)
|
||||
@@ -915,7 +915,7 @@ script_action_install (struct t_weechat_plugin *weechat_plugin,
|
||||
const char *dir_home, *dir_separator;
|
||||
int argc, i, length, rc;
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
if (*list)
|
||||
{
|
||||
argv = weechat_string_split (*list, ",", 0, 0, &argc);
|
||||
@@ -934,10 +934,10 @@ script_action_install (struct t_weechat_plugin *weechat_plugin,
|
||||
ptr_script = script_search_by_full_name (scripts, base_name);
|
||||
if (ptr_script)
|
||||
(*script_unload) (ptr_script);
|
||||
|
||||
|
||||
/* remove script file(s) */
|
||||
script_remove_file (weechat_plugin, base_name, 0);
|
||||
|
||||
|
||||
/* move file from install dir to language dir */
|
||||
dir_home = weechat_info_get ("weechat_dir", "");
|
||||
length = strlen (dir_home) + strlen (weechat_plugin->name) +
|
||||
@@ -974,7 +974,7 @@ script_action_install (struct t_weechat_plugin *weechat_plugin,
|
||||
}
|
||||
free (autoload_path);
|
||||
}
|
||||
|
||||
|
||||
/* load script */
|
||||
(*script_load) (new_path);
|
||||
}
|
||||
@@ -1019,7 +1019,7 @@ script_action_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
char **argv;
|
||||
int argc, i;
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
if (*list)
|
||||
{
|
||||
argv = weechat_string_split (*list, ",", 0, 0, &argc);
|
||||
@@ -1031,7 +1031,7 @@ script_action_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
ptr_script = script_search_by_full_name (scripts, argv[i]);
|
||||
if (ptr_script)
|
||||
(*script_unload) (ptr_script);
|
||||
|
||||
|
||||
/* remove script file(s) */
|
||||
script_remove_file (weechat_plugin, argv[i], 1);
|
||||
}
|
||||
@@ -1052,7 +1052,7 @@ script_display_list (struct t_weechat_plugin *weechat_plugin,
|
||||
const char *name, int full)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
weechat_printf (NULL, "");
|
||||
weechat_printf (NULL,
|
||||
/* TRANSLATORS: "%s" is language (for example "perl") */
|
||||
@@ -1101,21 +1101,21 @@ script_display_short_list (struct t_weechat_plugin *weechat_plugin,
|
||||
char *buf;
|
||||
int length;
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
if (scripts)
|
||||
{
|
||||
/* TRANSLATORS: "%s" is language (for example "perl") */
|
||||
scripts_loaded = _("%s scripts loaded:");
|
||||
|
||||
|
||||
length = strlen (scripts_loaded) + strlen (weechat_plugin->name) + 1;
|
||||
|
||||
|
||||
for (ptr_script = scripts; ptr_script;
|
||||
ptr_script = ptr_script->next_script)
|
||||
{
|
||||
length += strlen (ptr_script->name) + 2;
|
||||
}
|
||||
length++;
|
||||
|
||||
|
||||
buf = malloc (length);
|
||||
if (buf)
|
||||
{
|
||||
@@ -1145,14 +1145,14 @@ script_add_to_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !script)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_pointer (ptr_item, "pointer", script))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "filename", script->filename))
|
||||
@@ -1173,7 +1173,7 @@ script_add_to_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "charset", script->charset))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1189,10 +1189,10 @@ script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin,
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
if (pointer && !script_valid (scripts, pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -1227,7 +1227,7 @@ script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin,
|
||||
return ptr_infolist;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1241,11 +1241,11 @@ script_end (struct t_weechat_plugin *weechat_plugin,
|
||||
void (*callback_unload_all)())
|
||||
{
|
||||
int scripts_loaded;
|
||||
|
||||
|
||||
scripts_loaded = (*scripts) ? 1 : 0;
|
||||
|
||||
|
||||
(void)(callback_unload_all) ();
|
||||
|
||||
|
||||
if (scripts_loaded)
|
||||
{
|
||||
weechat_printf (NULL, _("%s: scripts unloaded"),
|
||||
@@ -1263,11 +1263,11 @@ script_print_log (struct t_weechat_plugin *weechat_plugin,
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
struct t_script_callback *ptr_script_callback;
|
||||
|
||||
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
|
||||
|
||||
for (ptr_script = scripts; ptr_script;
|
||||
ptr_script = ptr_script->next_script)
|
||||
{
|
||||
@@ -1292,7 +1292,7 @@ script_print_log (struct t_weechat_plugin *weechat_plugin,
|
||||
script_callback_print_log (weechat_plugin, ptr_script_callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** End of \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
|
||||
@@ -61,9 +61,9 @@ struct t_plugin_script
|
||||
char *description; /* plugin description */
|
||||
char *shutdown_func; /* function when script is unloaded*/
|
||||
char *charset; /* script charset */
|
||||
|
||||
|
||||
struct t_script_callback *callbacks; /* callbacks for script */
|
||||
|
||||
|
||||
struct t_plugin_script *prev_script; /* link to previous script */
|
||||
struct t_plugin_script *next_script; /* link to next script */
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -85,14 +85,14 @@ weechat_tcl_hashtable_map_cb (void *data,
|
||||
void **data_array;
|
||||
Tcl_Interp *interp;
|
||||
Tcl_Obj *dict;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
data_array = (void **)data;
|
||||
interp = data_array[0];
|
||||
dict = data_array[1];
|
||||
|
||||
|
||||
Tcl_DictObjPut (interp, dict,
|
||||
Tcl_NewStringObj ((char *)key, -1),
|
||||
Tcl_NewStringObj ((char *)value, -1));
|
||||
@@ -108,18 +108,18 @@ weechat_tcl_hashtable_to_dict (Tcl_Interp *interp,
|
||||
{
|
||||
Tcl_Obj *dict;
|
||||
void *data[2];
|
||||
|
||||
|
||||
dict = Tcl_NewDictObj ();
|
||||
if (!dict)
|
||||
return NULL;
|
||||
|
||||
|
||||
data[0] = interp;
|
||||
data[1] = dict;
|
||||
|
||||
|
||||
weechat_hashtable_map (hashtable,
|
||||
&weechat_tcl_hashtable_map_cb,
|
||||
data);
|
||||
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
|
||||
Tcl_DictSearch search;
|
||||
Tcl_Obj *key, *value;
|
||||
int done;
|
||||
|
||||
|
||||
hashtable = weechat_hashtable_new (hashtable_size,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -147,7 +147,7 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (Tcl_DictObjFirst (interp, dict, &search, &key, &value, &done) == TCL_OK)
|
||||
{
|
||||
for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done))
|
||||
@@ -158,7 +158,7 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
|
||||
}
|
||||
}
|
||||
Tcl_DictObjDone(&search);
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
@@ -178,11 +178,11 @@ weechat_tcl_exec (struct t_plugin_script *script,
|
||||
Tcl_Obj *cmdlist;
|
||||
Tcl_Interp *interp;
|
||||
struct t_plugin_script *old_tcl_script;
|
||||
|
||||
|
||||
old_tcl_script = tcl_current_script;
|
||||
tcl_current_script = script;
|
||||
interp = (Tcl_Interp*)script->interpreter;
|
||||
|
||||
|
||||
if (function && function[0])
|
||||
{
|
||||
cmdlist = Tcl_NewListObj (0, NULL);
|
||||
@@ -194,7 +194,7 @@ weechat_tcl_exec (struct t_plugin_script *script,
|
||||
tcl_current_script = old_tcl_script;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (format && format[0])
|
||||
{
|
||||
argc = strlen (format);
|
||||
@@ -217,10 +217,10 @@ weechat_tcl_exec (struct t_plugin_script *script,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Tcl_ListObjLength (interp, cmdlist, &llength) != TCL_OK)
|
||||
llength = 0;
|
||||
|
||||
|
||||
if (Tcl_EvalObjEx (interp, cmdlist, TCL_EVAL_DIRECT) == TCL_OK)
|
||||
{
|
||||
Tcl_ListObjReplace (interp, cmdlist, 0, llength, 0, NULL); /* remove elements, decrement their ref count */
|
||||
@@ -248,18 +248,18 @@ weechat_tcl_exec (struct t_plugin_script *script,
|
||||
Tcl_GetObjResult (interp),
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
|
||||
}
|
||||
|
||||
|
||||
tcl_current_script = old_tcl_script;
|
||||
if (ret_val)
|
||||
return ret_val;
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"%s\" must return a "
|
||||
"valid value"),
|
||||
weechat_prefix ("error"), TCL_PLUGIN_NAME, function);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Tcl_ListObjReplace (interp, cmdlist, 0, llength, 0, NULL); /* remove elements, decrement their ref count */
|
||||
Tcl_DecrRefCount (cmdlist); /* -1 */
|
||||
weechat_printf (NULL,
|
||||
@@ -267,7 +267,7 @@ weechat_tcl_exec (struct t_plugin_script *script,
|
||||
weechat_prefix ("error"), TCL_PLUGIN_NAME, function,
|
||||
Tcl_GetStringFromObj (Tcl_GetObjResult (interp), &i));
|
||||
tcl_current_script = old_tcl_script;
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ weechat_tcl_load (const char *filename)
|
||||
int i;
|
||||
Tcl_Interp *interp;
|
||||
struct stat buf;
|
||||
|
||||
|
||||
if (stat (filename, &buf) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -289,17 +289,17 @@ weechat_tcl_load (const char *filename)
|
||||
weechat_prefix ("error"), TCL_PLUGIN_NAME, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if ((weechat_tcl_plugin->debug >= 1) || !tcl_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
TCL_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
|
||||
tcl_current_script = NULL;
|
||||
tcl_registered_script = NULL;
|
||||
|
||||
|
||||
if (!(interp = Tcl_CreateInterp ())) {
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to create new "
|
||||
@@ -308,7 +308,7 @@ weechat_tcl_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
tcl_current_script_filename = filename;
|
||||
|
||||
|
||||
weechat_tcl_api_init (interp);
|
||||
|
||||
if (Tcl_EvalFile (interp, filename) != TCL_OK)
|
||||
@@ -332,7 +332,7 @@ weechat_tcl_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
tcl_current_script = tcl_registered_script;
|
||||
|
||||
|
||||
/*
|
||||
* set input/close callbacks for buffers created by this script
|
||||
* (to restore callbacks after upgrade)
|
||||
@@ -342,7 +342,7 @@ weechat_tcl_load (const char *filename)
|
||||
tcl_current_script,
|
||||
&weechat_tcl_api_buffer_input_data_cb,
|
||||
&weechat_tcl_api_buffer_close_cb);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ weechat_tcl_load_cb (void *data, const char *filename)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
weechat_tcl_load (filename);
|
||||
}
|
||||
|
||||
@@ -368,14 +368,14 @@ weechat_tcl_unload (struct t_plugin_script *script)
|
||||
{
|
||||
Tcl_Interp* interp;
|
||||
int *rc;
|
||||
|
||||
|
||||
if ((weechat_tcl_plugin->debug >= 1) || !tcl_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: unloading script \"%s\""),
|
||||
TCL_PLUGIN_NAME, script->name);
|
||||
}
|
||||
|
||||
|
||||
if (script->shutdown_func && script->shutdown_func[0])
|
||||
{
|
||||
rc = (int *)weechat_tcl_exec (script,
|
||||
@@ -385,27 +385,27 @@ weechat_tcl_unload (struct t_plugin_script *script)
|
||||
if (rc)
|
||||
free (rc);
|
||||
}
|
||||
|
||||
|
||||
interp = (Tcl_Interp*)script->interpreter;
|
||||
|
||||
|
||||
if (tcl_current_script == script)
|
||||
tcl_current_script = (tcl_current_script->prev_script) ?
|
||||
tcl_current_script->prev_script : tcl_current_script->next_script;
|
||||
|
||||
|
||||
script_remove (weechat_tcl_plugin, &tcl_scripts, &last_tcl_script, script);
|
||||
|
||||
|
||||
Tcl_DeleteInterp(interp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* weechat_tcl_unload_name: unload a Tcl script by name
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
weechat_tcl_unload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_tcl_plugin, tcl_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -444,7 +444,7 @@ weechat_tcl_reload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
char *filename;
|
||||
|
||||
|
||||
ptr_script = script_search (weechat_tcl_plugin, tcl_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
@@ -476,11 +476,11 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char *path_script;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
script_display_list (weechat_tcl_plugin, tcl_scripts,
|
||||
@@ -551,7 +551,7 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_prefix ("error"), TCL_PLUGIN_NAME, "tcl");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -568,9 +568,9 @@ weechat_tcl_completion_cb (void *data, const char *completion_item,
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
script_completion (weechat_tcl_plugin, completion, tcl_scripts);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -584,17 +584,17 @@ weechat_tcl_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "tcl_script") == 0)
|
||||
{
|
||||
return script_infolist_list_scripts (weechat_tcl_plugin,
|
||||
tcl_scripts, pointer,
|
||||
arguments);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -610,13 +610,13 @@ weechat_tcl_signal_debug_dump_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, TCL_PLUGIN_NAME) == 0))
|
||||
{
|
||||
script_print_log (weechat_tcl_plugin, tcl_scripts);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -632,10 +632,10 @@ weechat_tcl_signal_buffer_closed_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (signal_data)
|
||||
script_remove_buffer_callbacks (tcl_scripts, signal_data);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -667,7 +667,7 @@ weechat_tcl_timer_action_cb (void *data, int remaining_calls)
|
||||
&tcl_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -683,7 +683,7 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (strcmp (signal, "tcl_script_install") == 0)
|
||||
@@ -703,7 +703,7 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal,
|
||||
&tcl_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -715,7 +715,7 @@ int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
weechat_tcl_plugin = plugin;
|
||||
|
||||
|
||||
tcl_quiet = 1;
|
||||
script_init (weechat_tcl_plugin,
|
||||
argc,
|
||||
@@ -728,10 +728,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
&weechat_tcl_signal_script_action_cb,
|
||||
&weechat_tcl_load_cb);
|
||||
tcl_quiet = 0;
|
||||
|
||||
|
||||
script_display_short_list (weechat_tcl_plugin,
|
||||
tcl_scripts);
|
||||
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -747,6 +747,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
tcl_quiet = 1;
|
||||
script_end (plugin, &tcl_scripts, &weechat_tcl_unload_all);
|
||||
tcl_quiet = 0;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -187,16 +187,16 @@ struct t_weechat_plugin
|
||||
int debug; /* debug level for plugin (0=off) */
|
||||
struct t_weechat_plugin *prev_plugin; /* link to previous plugin */
|
||||
struct t_weechat_plugin *next_plugin; /* link to next plugin */
|
||||
|
||||
|
||||
/*
|
||||
* plugin functions (API)
|
||||
* WeeChat developers: if you add functions in API, update value of
|
||||
* constant WEECHAT_PLUGIN_API_VERSION
|
||||
*/
|
||||
|
||||
|
||||
/* plugins */
|
||||
const char *(*plugin_get_name) (struct t_weechat_plugin *plugin);
|
||||
|
||||
|
||||
/* strings */
|
||||
void (*charset_set) (struct t_weechat_plugin *plugin, const char *charset);
|
||||
char *(*iconv_to_internal) (const char *charset, const char *string);
|
||||
@@ -236,7 +236,7 @@ struct t_weechat_plugin
|
||||
int (*string_decode_base64) (const char *from, char *to);
|
||||
int (*string_is_command_char) (const char *string);
|
||||
const char *(*string_input_for_buffer) (const char *string);
|
||||
|
||||
|
||||
/* UTF-8 strings */
|
||||
int (*utf8_has_8bits) (const char *string);
|
||||
int (*utf8_is_valid) (const char *string, char **error);
|
||||
@@ -255,7 +255,7 @@ struct t_weechat_plugin
|
||||
int (*utf8_real_pos) (const char *string, int pos);
|
||||
int (*utf8_pos) (const char *string, int real_pos);
|
||||
char *(*utf8_strndup) (const char *string, int length);
|
||||
|
||||
|
||||
/* directories/files */
|
||||
int (*mkdir_home) (const char *directory, int mode);
|
||||
int (*mkdir) (const char *directory, int mode);
|
||||
@@ -263,13 +263,13 @@ struct t_weechat_plugin
|
||||
void (*exec_on_files) (const char *directory, int hidden_files, void *data,
|
||||
void (*callback)(void *data, const char *filename));
|
||||
char *(*file_get_content) (const char *filename);
|
||||
|
||||
|
||||
/* util */
|
||||
int (*util_timeval_cmp) (struct timeval *tv1, struct timeval *tv2);
|
||||
long (*util_timeval_diff) (struct timeval *tv1, struct timeval *tv2);
|
||||
void (*util_timeval_add) (struct timeval *tv, long interval);
|
||||
char *(*util_get_time_string) (const time_t *date);
|
||||
|
||||
|
||||
/* sorted lists */
|
||||
struct t_weelist *(*list_new) ();
|
||||
struct t_weelist_item *(*list_add) (struct t_weelist *weelist,
|
||||
@@ -295,7 +295,7 @@ struct t_weechat_plugin
|
||||
struct t_weelist_item *item);
|
||||
void (*list_remove_all) (struct t_weelist *weelist);
|
||||
void (*list_free) (struct t_weelist *weelist);
|
||||
|
||||
|
||||
/* hash tables */
|
||||
struct t_hashtable *(*hashtable_new) (int size,
|
||||
const char *type_keys,
|
||||
@@ -331,7 +331,7 @@ struct t_weechat_plugin
|
||||
void (*hashtable_remove) (struct t_hashtable *hashtable, const void *key);
|
||||
void (*hashtable_remove_all) (struct t_hashtable *hashtable);
|
||||
void (*hashtable_free) (struct t_hashtable *hashtable);
|
||||
|
||||
|
||||
/* config files */
|
||||
struct t_config_file *(*config_new) (struct t_weechat_plugin *plugin,
|
||||
const char *name,
|
||||
@@ -449,11 +449,11 @@ struct t_weechat_plugin
|
||||
const char *description);
|
||||
int (*config_unset_plugin) (struct t_weechat_plugin *plugin,
|
||||
const char *option_name);
|
||||
|
||||
|
||||
/* key bindings */
|
||||
int (*key_bind) (const char *context, struct t_hashtable *keys);
|
||||
int (*key_unbind) (const char *context, const char *key);
|
||||
|
||||
|
||||
/* display */
|
||||
const char *(*prefix) (const char *prefix);
|
||||
const char *(*color) (const char *color_name);
|
||||
@@ -462,7 +462,7 @@ struct t_weechat_plugin
|
||||
void (*printf_y) (struct t_gui_buffer *buffer, int y,
|
||||
const char *message, ...);
|
||||
void (*log_printf) (const char *message, ...);
|
||||
|
||||
|
||||
/* hooks */
|
||||
struct t_hook *(*hook_command) (struct t_weechat_plugin *plugin,
|
||||
const char *command,
|
||||
@@ -623,7 +623,7 @@ struct t_weechat_plugin
|
||||
void *callback_data);
|
||||
void (*unhook) (struct t_hook *hook);
|
||||
void (*unhook_all) (struct t_weechat_plugin *plugin);
|
||||
|
||||
|
||||
/* buffers */
|
||||
struct t_gui_buffer *(*buffer_new) (struct t_weechat_plugin *plugin,
|
||||
const char *name,
|
||||
@@ -654,7 +654,7 @@ struct t_weechat_plugin
|
||||
char *(*buffer_string_replace_local_var) (struct t_gui_buffer *buffer,
|
||||
const char *string);
|
||||
int (*buffer_match_list) (struct t_gui_buffer *buffer, const char *string);
|
||||
|
||||
|
||||
/* windows */
|
||||
struct t_gui_window *(*window_search_with_buffer) (struct t_gui_buffer *buffer);
|
||||
int (*window_get_integer) (struct t_gui_window *window,
|
||||
@@ -664,7 +664,7 @@ struct t_weechat_plugin
|
||||
void *(*window_get_pointer) (struct t_gui_window *window,
|
||||
const char *property);
|
||||
void (*window_set_title) (const char *title);
|
||||
|
||||
|
||||
/* nicklist */
|
||||
struct t_gui_nick_group *(*nicklist_add_group) (struct t_gui_buffer *buffer,
|
||||
struct t_gui_nick_group *parent_group,
|
||||
@@ -713,7 +713,7 @@ struct t_weechat_plugin
|
||||
void (*nicklist_nick_set) (struct t_gui_buffer *buffer,
|
||||
struct t_gui_nick *nick,
|
||||
const char *property, const char *value);
|
||||
|
||||
|
||||
/* bars */
|
||||
struct t_gui_bar_item *(*bar_item_search) (const char *name);
|
||||
struct t_gui_bar_item *(*bar_item_new) (struct t_weechat_plugin *plugin,
|
||||
@@ -744,7 +744,7 @@ struct t_weechat_plugin
|
||||
const char *value);
|
||||
void (*bar_update) (const char *name);
|
||||
void (*bar_remove) (struct t_gui_bar *bar);
|
||||
|
||||
|
||||
/* command */
|
||||
void (*command) (struct t_weechat_plugin *plugin,
|
||||
struct t_gui_buffer *buffer, const char *command);
|
||||
@@ -754,7 +754,7 @@ struct t_weechat_plugin
|
||||
const char *address, int port);
|
||||
int (*network_connect_to) (const char *proxy, int sock,
|
||||
unsigned long address, int port);
|
||||
|
||||
|
||||
/* infos */
|
||||
const char *(*info_get) (struct t_weechat_plugin *plugin,
|
||||
const char *info_name,
|
||||
@@ -762,7 +762,7 @@ struct t_weechat_plugin
|
||||
struct t_hashtable *(*info_get_hashtable) (struct t_weechat_plugin *plugin,
|
||||
const char *info_name,
|
||||
struct t_hashtable *hashtable);
|
||||
|
||||
|
||||
/* infolists */
|
||||
struct t_infolist *(*infolist_new) ();
|
||||
struct t_infolist_item *(*infolist_new_item) (struct t_infolist *infolist);
|
||||
@@ -797,7 +797,7 @@ struct t_weechat_plugin
|
||||
int *size);
|
||||
time_t (*infolist_time) (struct t_infolist *infolist, const char *var);
|
||||
void (*infolist_free) (struct t_infolist *infolist);
|
||||
|
||||
|
||||
/* hdata */
|
||||
struct t_hdata *(*hdata_new) (struct t_weechat_plugin *plugin,
|
||||
const char *hdata_name, const char *var_prev,
|
||||
@@ -832,7 +832,7 @@ struct t_weechat_plugin
|
||||
const char *name);
|
||||
const char *(*hdata_get_string) (struct t_hdata *hdata,
|
||||
const char *property);
|
||||
|
||||
|
||||
/* upgrade */
|
||||
struct t_upgrade_file *(*upgrade_new) (const char *filename,
|
||||
int write);
|
||||
|
||||
@@ -50,7 +50,7 @@ xfer_buffer_refresh (const char *hotlist)
|
||||
int i, length, line, progress_bar_size, num_bars;
|
||||
unsigned long long pct_complete;
|
||||
struct tm *date_tmp;
|
||||
|
||||
|
||||
if (xfer_buffer)
|
||||
{
|
||||
weechat_buffer_clear (xfer_buffer);
|
||||
@@ -85,14 +85,14 @@ xfer_buffer_refresh (const char *hotlist)
|
||||
snprintf (suffix, sizeof (suffix),
|
||||
" (.%d)", ptr_xfer->filename_suffix);
|
||||
}
|
||||
|
||||
|
||||
snprintf (str_color, sizeof (str_color),
|
||||
"%s,%s",
|
||||
(line == xfer_buffer_selected_line) ?
|
||||
weechat_config_string (xfer_config_color_text_selected) :
|
||||
weechat_config_string (xfer_config_color_text),
|
||||
weechat_config_string (xfer_config_color_text_bg));
|
||||
|
||||
|
||||
/* display first line with remote nick and filename */
|
||||
weechat_printf_y (xfer_buffer, (line * 2) + 2,
|
||||
"%s%s%-24s %s%s%s%s",
|
||||
@@ -105,7 +105,7 @@ xfer_buffer_refresh (const char *hotlist)
|
||||
ptr_xfer->filename : _("xfer chat"),
|
||||
(XFER_IS_FILE(ptr_xfer->type)) ? "\"" : "",
|
||||
suffix);
|
||||
|
||||
|
||||
snprintf (status, sizeof (status),
|
||||
"%s", _(xfer_status_string[ptr_xfer->status]));
|
||||
length = weechat_utf8_strlen_screen (status);
|
||||
@@ -116,7 +116,7 @@ xfer_buffer_refresh (const char *hotlist)
|
||||
strcat (status, " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (XFER_IS_CHAT(ptr_xfer->type))
|
||||
{
|
||||
/* display second line for chat with status and date */
|
||||
@@ -166,7 +166,7 @@ xfer_buffer_refresh (const char *hotlist)
|
||||
}
|
||||
strcat (progress_bar, "] ");
|
||||
}
|
||||
|
||||
|
||||
/* computes percentage */
|
||||
if (ptr_xfer->size == 0)
|
||||
{
|
||||
@@ -177,12 +177,12 @@ xfer_buffer_refresh (const char *hotlist)
|
||||
}
|
||||
else
|
||||
pct_complete = (unsigned long long)(((float)(ptr_xfer->pos)/(float)(ptr_xfer->size)) * 100);
|
||||
|
||||
|
||||
/* position, total and bytes per second */
|
||||
str_pos = weechat_string_format_size (ptr_xfer->pos);
|
||||
str_total = weechat_string_format_size (ptr_xfer->size);
|
||||
str_bytes_per_sec = weechat_string_format_size (ptr_xfer->bytes_per_sec);
|
||||
|
||||
|
||||
/* ETA */
|
||||
eta[0] = '\0';
|
||||
if (ptr_xfer->status == XFER_STATUS_ACTIVE)
|
||||
@@ -194,7 +194,7 @@ xfer_buffer_refresh (const char *hotlist)
|
||||
(ptr_xfer->eta / 60) % 60,
|
||||
ptr_xfer->eta % 60);
|
||||
}
|
||||
|
||||
|
||||
/* display second line for file with status, progress bar and estimated time */
|
||||
weechat_printf_y (xfer_buffer, (line * 2) + 3,
|
||||
"%s%s%s %s%s%s%s%3llu%% %s / %s (%s%s/s)",
|
||||
@@ -233,12 +233,12 @@ xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
|
||||
const char *input_data)
|
||||
{
|
||||
struct t_xfer *xfer, *ptr_xfer, *next_xfer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
xfer = xfer_search_by_number (xfer_buffer_selected_line);
|
||||
|
||||
|
||||
/* accept xfer */
|
||||
if (weechat_strcasecmp (input_data, "a") == 0)
|
||||
{
|
||||
@@ -284,7 +284,7 @@ xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -298,9 +298,9 @@ xfer_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
xfer_buffer = NULL;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -316,11 +316,11 @@ xfer_buffer_open ()
|
||||
xfer_buffer = weechat_buffer_new (XFER_BUFFER_NAME,
|
||||
&xfer_buffer_input_cb, NULL,
|
||||
&xfer_buffer_close_cb, NULL);
|
||||
|
||||
|
||||
/* failed to create buffer ? then exit */
|
||||
if (!xfer_buffer)
|
||||
return;
|
||||
|
||||
|
||||
weechat_buffer_set (xfer_buffer, "type", "free");
|
||||
weechat_buffer_set (xfer_buffer, "title", _("Xfer list"));
|
||||
weechat_buffer_set (xfer_buffer, "key_bind_meta2-A", "/xfer up");
|
||||
|
||||
@@ -43,7 +43,7 @@ xfer_chat_send (struct t_xfer *xfer, const char *buffer, int size_buf)
|
||||
{
|
||||
if (!xfer)
|
||||
return -1;
|
||||
|
||||
|
||||
return send (xfer->sock, buffer, size_buf, 0);
|
||||
}
|
||||
|
||||
@@ -55,21 +55,21 @@ void
|
||||
xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...)
|
||||
{
|
||||
char *ptr_msg, *msg_encoded;
|
||||
|
||||
|
||||
if (!xfer || (xfer->sock < 0))
|
||||
return;
|
||||
|
||||
|
||||
weechat_va_format (format);
|
||||
if (!vbuffer)
|
||||
return;
|
||||
|
||||
|
||||
msg_encoded = (xfer->charset_modifier) ?
|
||||
weechat_hook_modifier_exec ("charset_encode",
|
||||
xfer->charset_modifier,
|
||||
vbuffer) : NULL;
|
||||
|
||||
|
||||
ptr_msg = (msg_encoded) ? msg_encoded : vbuffer;
|
||||
|
||||
|
||||
if (xfer_chat_send (xfer, ptr_msg, strlen (ptr_msg)) <= 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -78,10 +78,10 @@ xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...)
|
||||
xfer->remote_nick);
|
||||
xfer_close (xfer, XFER_STATUS_FAILED);
|
||||
}
|
||||
|
||||
|
||||
if (msg_encoded)
|
||||
free (msg_encoded);
|
||||
|
||||
|
||||
free (vbuffer);
|
||||
}
|
||||
|
||||
@@ -98,17 +98,17 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
|
||||
char *ptr_buf_decoded, *ptr_buf_without_weechat_colors, *ptr_buf_color;
|
||||
char str_tags[256];
|
||||
int num_read, length, ctcp_action;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) fd;
|
||||
|
||||
|
||||
xfer = (struct t_xfer *)arg_xfer;
|
||||
|
||||
|
||||
num_read = recv (xfer->sock, buffer, sizeof (buffer) - 2, 0);
|
||||
if (num_read > 0)
|
||||
{
|
||||
buffer[num_read] = '\0';
|
||||
|
||||
|
||||
buf2 = NULL;
|
||||
ptr_buf = buffer;
|
||||
if (xfer->unterminated_message)
|
||||
@@ -124,7 +124,7 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
|
||||
free (xfer->unterminated_message);
|
||||
xfer->unterminated_message = NULL;
|
||||
}
|
||||
|
||||
|
||||
while (ptr_buf && ptr_buf[0])
|
||||
{
|
||||
next_ptr_buf = NULL;
|
||||
@@ -140,7 +140,7 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
|
||||
ptr_buf = NULL;
|
||||
next_ptr_buf = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (ptr_buf)
|
||||
{
|
||||
ctcp_action = 0;
|
||||
@@ -156,7 +156,7 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
|
||||
ctcp_action = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_buf_decoded = (xfer->charset_modifier) ?
|
||||
weechat_hook_modifier_exec ("charset_decode",
|
||||
xfer->charset_modifier,
|
||||
@@ -206,10 +206,10 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
|
||||
if (ptr_buf_color)
|
||||
free (ptr_buf_color);
|
||||
}
|
||||
|
||||
|
||||
ptr_buf = next_ptr_buf;
|
||||
}
|
||||
|
||||
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
@@ -218,7 +218,7 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
|
||||
xfer_close (xfer, XFER_STATUS_ABORTED);
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -233,12 +233,12 @@ xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
char *input_data_color;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_xfer = xfer_search_by_buffer (buffer);
|
||||
|
||||
|
||||
if (ptr_xfer)
|
||||
{
|
||||
if (!XFER_HAS_ENDED(ptr_xfer->status))
|
||||
@@ -260,7 +260,7 @@ xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ int
|
||||
xfer_chat_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
@@ -290,7 +290,7 @@ xfer_chat_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
ptr_xfer->buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -303,9 +303,9 @@ xfer_chat_open_buffer (struct t_xfer *xfer)
|
||||
{
|
||||
char *name;
|
||||
int length, buffer_created;
|
||||
|
||||
|
||||
buffer_created = 0;
|
||||
|
||||
|
||||
length = strlen (xfer->plugin_name) + 8 + strlen (xfer->plugin_id) + 1
|
||||
+ strlen (xfer->remote_nick) + 1;
|
||||
name = malloc (length);
|
||||
@@ -320,7 +320,7 @@ xfer_chat_open_buffer (struct t_xfer *xfer)
|
||||
&xfer_chat_buffer_input_cb, NULL,
|
||||
&xfer_chat_buffer_close_cb, NULL);
|
||||
buffer_created = 1;
|
||||
|
||||
|
||||
/* failed to create buffer ? then return */
|
||||
if (!xfer->buffer)
|
||||
return;
|
||||
@@ -339,7 +339,7 @@ xfer_chat_open_buffer (struct t_xfer *xfer)
|
||||
weechat_buffer_set (xfer->buffer, "localvar_set_channel", xfer->remote_nick);
|
||||
weechat_buffer_set (xfer->buffer, "highlight_words_add", "$nick");
|
||||
}
|
||||
|
||||
|
||||
weechat_printf (xfer->buffer,
|
||||
_("Connected to %s (%d.%d.%d.%d) via "
|
||||
"xfer chat"),
|
||||
@@ -348,7 +348,7 @@ xfer_chat_open_buffer (struct t_xfer *xfer)
|
||||
(xfer->address >> 16) & 0xff,
|
||||
(xfer->address >> 8) & 0xff,
|
||||
xfer->address & 0xff);
|
||||
|
||||
|
||||
free (name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,12 @@ xfer_command_me (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char **argv, char **argv_eol)
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
ptr_xfer = xfer_search_by_buffer (buffer);
|
||||
|
||||
if (!ptr_xfer)
|
||||
@@ -57,7 +57,7 @@ xfer_command_me (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_buffer_get_string (buffer, "name"));
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (!XFER_HAS_ENDED(ptr_xfer->status))
|
||||
{
|
||||
xfer_chat_sendf (ptr_xfer, "\01ACTION %s\01\n",
|
||||
@@ -71,7 +71,7 @@ xfer_command_me (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_color ("chat"),
|
||||
(argv_eol[1]) ? argv_eol[1] : "");
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ xfer_command_xfer_list (int full)
|
||||
char date[128];
|
||||
unsigned long long pct_complete;
|
||||
struct tm *date_tmp;
|
||||
|
||||
|
||||
if (xfer_list)
|
||||
{
|
||||
weechat_printf (NULL, "");
|
||||
@@ -107,7 +107,7 @@ xfer_command_xfer_list (int full)
|
||||
}
|
||||
else
|
||||
pct_complete = (unsigned long long)(((float)(ptr_xfer->pos)/(float)(ptr_xfer->size)) * 100);
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("%3d. %s (%s), file: \"%s\" (local: "
|
||||
"\"%s\"), %s %s, status: %s%s%s "
|
||||
@@ -146,7 +146,7 @@ xfer_command_xfer_list (int full)
|
||||
xfer_config_color_status[ptr_xfer->status])),
|
||||
_(xfer_status_string[ptr_xfer->status]));
|
||||
}
|
||||
|
||||
|
||||
if (full)
|
||||
{
|
||||
/* second line of xfer info */
|
||||
@@ -202,20 +202,20 @@ xfer_command_xfer (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
xfer_command_xfer_list (0);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if ((argc > 1) && (weechat_strcasecmp (argv[1], "listfull") == 0))
|
||||
{
|
||||
xfer_command_xfer_list (1);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (!xfer_buffer)
|
||||
xfer_buffer_open ();
|
||||
|
||||
|
||||
if (xfer_buffer)
|
||||
{
|
||||
weechat_buffer_set (xfer_buffer, "display", "1");
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (strcmp (argv[1], "up") == 0)
|
||||
@@ -230,9 +230,9 @@ xfer_command_xfer (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xfer_buffer_refresh (NULL);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,11 @@ xfer_completion_nick_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
ptr_xfer = xfer_search_by_buffer (buffer);
|
||||
if (ptr_xfer)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ xfer_completion_nick_cb (void *data, const char *completion_item,
|
||||
1,
|
||||
WEECHAT_LIST_POS_END);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ xfer_config_refresh_cb (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (xfer_buffer)
|
||||
xfer_buffer_refresh (NULL);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ xfer_config_reload (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
return weechat_config_reload (config_file);
|
||||
}
|
||||
|
||||
@@ -104,12 +104,12 @@ int
|
||||
xfer_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
xfer_config_file = weechat_config_new (XFER_CONFIG_NAME,
|
||||
&xfer_config_reload, NULL);
|
||||
if (!xfer_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (xfer_config_file, "look",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -120,7 +120,7 @@ xfer_config_init ()
|
||||
weechat_config_free (xfer_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
xfer_config_look_auto_open_buffer = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"auto_open_buffer", "boolean",
|
||||
@@ -133,7 +133,7 @@ xfer_config_init ()
|
||||
N_("size of progress bar, in chars (if 0, progress bar is disabled)"),
|
||||
NULL, 0, XFER_CONFIG_PROGRESS_BAR_MAX_SIZE, "20", NULL, 0,
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (xfer_config_file, "color",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -144,7 +144,7 @@ xfer_config_init ()
|
||||
weechat_config_free (xfer_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
xfer_config_color_text = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"text", "color",
|
||||
@@ -199,7 +199,7 @@ xfer_config_init ()
|
||||
N_("text color for \"aborted\" status"),
|
||||
NULL, 0, 0, "lightred", NULL, 0,
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (xfer_config_file, "network",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -210,7 +210,7 @@ xfer_config_init ()
|
||||
weechat_config_free (xfer_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
xfer_config_network_timeout = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"timeout", "integer",
|
||||
@@ -248,7 +248,7 @@ xfer_config_init ()
|
||||
N_("speed limit for sending files, in kilo-bytes by second (0 means "
|
||||
"no limit)"),
|
||||
NULL, 0, INT_MAX, "0", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (xfer_config_file, "file",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -259,7 +259,7 @@ xfer_config_init ()
|
||||
weechat_config_free (xfer_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
xfer_config_file_download_path = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"download_path", "string",
|
||||
@@ -304,7 +304,7 @@ xfer_config_init ()
|
||||
"auto_accept_chats", "boolean",
|
||||
N_("automatically accept chat requests (use carefully!)"),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -51,14 +51,14 @@ xfer_dcc_send_file_child (struct t_xfer *xfer)
|
||||
uint32_t ack;
|
||||
time_t last_sent, new_time, last_second, sent_ok;
|
||||
unsigned long long sent_last_second;
|
||||
|
||||
|
||||
blocksize = xfer->blocksize;
|
||||
if (weechat_config_integer (xfer_config_network_speed_limit) > 0)
|
||||
{
|
||||
if (blocksize > weechat_config_integer (xfer_config_network_speed_limit) * 1024)
|
||||
blocksize = weechat_config_integer (xfer_config_network_speed_limit) * 1024;
|
||||
}
|
||||
|
||||
|
||||
last_sent = time (NULL);
|
||||
last_second = time (NULL);
|
||||
sent_ok = 0;
|
||||
@@ -83,7 +83,7 @@ xfer_dcc_send_file_child (struct t_xfer *xfer)
|
||||
{
|
||||
recv (xfer->sock, (char *) &ack, 4, 0);
|
||||
xfer->ack = ntohl (ack);
|
||||
|
||||
|
||||
/* DCC send ok? */
|
||||
if ((xfer->pos >= xfer->size)
|
||||
&& (xfer->ack >= xfer->size))
|
||||
@@ -97,7 +97,7 @@ xfer_dcc_send_file_child (struct t_xfer *xfer)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* send a block to receiver */
|
||||
if ((xfer->pos < xfer->size) &&
|
||||
(xfer->fast_send || (xfer->pos <= xfer->ack)))
|
||||
@@ -153,14 +153,14 @@ xfer_dcc_send_file_child (struct t_xfer *xfer)
|
||||
}
|
||||
else
|
||||
usleep (1000);
|
||||
|
||||
|
||||
new_time = time (NULL);
|
||||
if (new_time > last_second)
|
||||
{
|
||||
last_second = new_time;
|
||||
sent_last_second = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* if send if ok since 2 seconds or more, and that no ack was received,
|
||||
* then consider it's ok
|
||||
@@ -185,7 +185,7 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer)
|
||||
static char buffer[XFER_BLOCKSIZE_MAX];
|
||||
uint32_t pos;
|
||||
time_t last_sent, new_time;
|
||||
|
||||
|
||||
/* first connect to sender (blocking) */
|
||||
if (!weechat_network_connect_to (xfer->proxy, xfer->sock,
|
||||
xfer->address, xfer->port))
|
||||
@@ -194,11 +194,11 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer)
|
||||
XFER_ERROR_CONNECT_SENDER);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* connection is ok, change DCC status (inform parent process) */
|
||||
xfer_network_write_pipe (xfer, XFER_STATUS_ACTIVE,
|
||||
XFER_NO_ERROR);
|
||||
|
||||
|
||||
last_sent = time (NULL);
|
||||
while (1)
|
||||
{
|
||||
@@ -223,20 +223,20 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer)
|
||||
XFER_ERROR_RECV_BLOCK);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (write (xfer->file, buffer, num_read) == -1)
|
||||
{
|
||||
xfer_network_write_pipe (xfer, XFER_STATUS_FAILED,
|
||||
XFER_ERROR_WRITE_LOCAL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
xfer->pos += (unsigned long long) num_read;
|
||||
pos = htonl (xfer->pos);
|
||||
|
||||
|
||||
/* we don't check return code, not a problem if an ACK send failed */
|
||||
send (xfer->sock, (char *) &pos, 4, 0);
|
||||
|
||||
|
||||
/* file received ok? */
|
||||
if (xfer->pos >= xfer->size)
|
||||
{
|
||||
@@ -244,7 +244,7 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer)
|
||||
XFER_NO_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
new_time = time (NULL);
|
||||
if (last_sent != new_time)
|
||||
{
|
||||
|
||||
@@ -47,10 +47,10 @@ int
|
||||
xfer_file_resume (struct t_xfer *xfer, const char *filename)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
|
||||
if (!weechat_config_boolean (xfer_config_file_auto_resume))
|
||||
return 0;
|
||||
|
||||
|
||||
if (access (filename, W_OK) == 0)
|
||||
{
|
||||
if (stat (filename, &st) != -1)
|
||||
@@ -64,7 +64,7 @@ xfer_file_resume (struct t_xfer *xfer, const char *filename)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* not resumable */
|
||||
return 0;
|
||||
}
|
||||
@@ -80,14 +80,14 @@ xfer_file_find_filename (struct t_xfer *xfer)
|
||||
{
|
||||
const char *weechat_home, *dir_separator;
|
||||
char *dir1, *dir2, *filename2;
|
||||
|
||||
|
||||
if (!XFER_IS_FILE(xfer->type))
|
||||
return;
|
||||
|
||||
|
||||
dir1 = weechat_string_expand_home (weechat_config_string (xfer_config_file_download_path));
|
||||
if (!dir1)
|
||||
return;
|
||||
|
||||
|
||||
weechat_home = weechat_info_get ("weechat_dir", "");
|
||||
if (!weechat_home)
|
||||
{
|
||||
@@ -100,13 +100,13 @@ xfer_file_find_filename (struct t_xfer *xfer)
|
||||
free (dir1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
xfer->local_filename = malloc (strlen (dir2) +
|
||||
strlen (xfer->remote_nick) +
|
||||
strlen (xfer->filename) + 4);
|
||||
if (!xfer->local_filename)
|
||||
return;
|
||||
|
||||
|
||||
strcpy (xfer->local_filename, dir2);
|
||||
dir_separator = weechat_info_get("dir_separator", "");
|
||||
if (dir_separator
|
||||
@@ -118,18 +118,18 @@ xfer_file_find_filename (struct t_xfer *xfer)
|
||||
strcat (xfer->local_filename, ".");
|
||||
}
|
||||
strcat (xfer->local_filename, xfer->filename);
|
||||
|
||||
|
||||
if (dir1)
|
||||
free (dir1);
|
||||
if (dir2 )
|
||||
free (dir2);
|
||||
|
||||
|
||||
/* file already exists? */
|
||||
if (access (xfer->local_filename, F_OK) == 0)
|
||||
{
|
||||
if (xfer_file_resume (xfer, xfer->local_filename))
|
||||
return;
|
||||
|
||||
|
||||
/* if auto rename is not set, then abort xfer */
|
||||
if (!xfer_config_file_auto_rename)
|
||||
{
|
||||
@@ -137,7 +137,7 @@ xfer_file_find_filename (struct t_xfer *xfer)
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
filename2 = malloc (strlen (xfer->local_filename) + 16);
|
||||
if (!filename2)
|
||||
{
|
||||
@@ -161,7 +161,7 @@ xfer_file_find_filename (struct t_xfer *xfer)
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
|
||||
|
||||
free (xfer->local_filename);
|
||||
xfer->local_filename = strdup (filename2);
|
||||
free (filename2);
|
||||
@@ -177,7 +177,7 @@ xfer_file_calculate_speed (struct t_xfer *xfer, int ended)
|
||||
{
|
||||
time_t local_time, elapsed;
|
||||
unsigned long long bytes_per_sec_total;
|
||||
|
||||
|
||||
local_time = time (NULL);
|
||||
if (ended || local_time > xfer->last_check_time)
|
||||
{
|
||||
@@ -200,7 +200,7 @@ xfer_file_calculate_speed (struct t_xfer *xfer, int ended)
|
||||
if (bytes_per_sec_total == 0)
|
||||
bytes_per_sec_total = 1;
|
||||
xfer->eta = (xfer->size - xfer->pos) / bytes_per_sec_total;
|
||||
|
||||
|
||||
/* calculate bytes per second (since last check time) */
|
||||
elapsed = local_time - xfer->last_check_time;
|
||||
if (elapsed == 0)
|
||||
|
||||
@@ -38,19 +38,19 @@ xfer_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) arguments;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "xfer") == 0)
|
||||
{
|
||||
if (pointer && !xfer_valid (pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ xfer_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ int
|
||||
xfer_network_create_pipe (struct t_xfer *xfer)
|
||||
{
|
||||
int child_pipe[2];
|
||||
|
||||
|
||||
if (pipe (child_pipe) < 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -61,10 +61,10 @@ xfer_network_create_pipe (struct t_xfer *xfer)
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
xfer->child_read = child_pipe[0];
|
||||
xfer->child_write = child_pipe[1];
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ xfer_network_write_pipe (struct t_xfer *xfer, int status, int error)
|
||||
{
|
||||
char buffer[1 + 1 + 32 + 1]; /* status + error + pos + \0 */
|
||||
int num_written;
|
||||
|
||||
|
||||
snprintf (buffer, sizeof (buffer), "%c%c%032llu",
|
||||
status + '0', error + '0', xfer->pos);
|
||||
num_written = write (xfer->child_write, buffer, sizeof (buffer));
|
||||
@@ -94,19 +94,19 @@ xfer_network_child_read_cb (void *arg_xfer, int fd)
|
||||
struct t_xfer *xfer;
|
||||
char bufpipe[1 + 1 + 32 + 1];
|
||||
int num_read;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) fd;
|
||||
|
||||
|
||||
xfer = (struct t_xfer *)arg_xfer;
|
||||
|
||||
|
||||
num_read = read (xfer->child_read, bufpipe, sizeof (bufpipe));
|
||||
if (num_read > 0)
|
||||
{
|
||||
sscanf (bufpipe + 2, "%llu", &xfer->pos);
|
||||
xfer->last_activity = time (NULL);
|
||||
xfer_file_calculate_speed (xfer, 0);
|
||||
|
||||
|
||||
/* read error code */
|
||||
switch (bufpipe[1] - '0')
|
||||
{
|
||||
@@ -143,7 +143,7 @@ xfer_network_child_read_cb (void *arg_xfer, int fd)
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* read new DCC status */
|
||||
switch (bufpipe[0] - '0')
|
||||
{
|
||||
@@ -169,7 +169,7 @@ xfer_network_child_read_cb (void *arg_xfer, int fd)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -181,12 +181,12 @@ void
|
||||
xfer_network_send_file_fork (struct t_xfer *xfer)
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
|
||||
if (!xfer_network_create_pipe (xfer))
|
||||
return;
|
||||
|
||||
|
||||
xfer->file = open (xfer->local_filename, O_RDONLY | O_NONBLOCK, 0644);
|
||||
|
||||
|
||||
switch (pid = fork ())
|
||||
{
|
||||
/* fork failed */
|
||||
@@ -214,7 +214,7 @@ xfer_network_send_file_fork (struct t_xfer *xfer)
|
||||
}
|
||||
_exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/* parent process */
|
||||
xfer->child_pid = pid;
|
||||
close (xfer->child_write);
|
||||
@@ -233,10 +233,10 @@ void
|
||||
xfer_network_recv_file_fork (struct t_xfer *xfer)
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
|
||||
if (!xfer_network_create_pipe (xfer))
|
||||
return;
|
||||
|
||||
|
||||
if (xfer->start_resume > 0)
|
||||
xfer->file = open (xfer->local_filename,
|
||||
O_APPEND | O_WRONLY | O_NONBLOCK);
|
||||
@@ -244,7 +244,7 @@ xfer_network_recv_file_fork (struct t_xfer *xfer)
|
||||
xfer->file = open (xfer->local_filename,
|
||||
O_CREAT | O_TRUNC | O_WRONLY | O_NONBLOCK,
|
||||
0644);
|
||||
|
||||
|
||||
switch (pid = fork ())
|
||||
{
|
||||
/* fork failed */
|
||||
@@ -272,7 +272,7 @@ xfer_network_recv_file_fork (struct t_xfer *xfer)
|
||||
}
|
||||
_exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/* parent process */
|
||||
xfer->child_pid = pid;
|
||||
close (xfer->child_write);
|
||||
@@ -297,7 +297,7 @@ xfer_network_child_kill (struct t_xfer *xfer)
|
||||
waitpid (xfer->child_pid, NULL, 0);
|
||||
xfer->child_pid = 0;
|
||||
}
|
||||
|
||||
|
||||
/* close pipe used with child */
|
||||
if (xfer->child_read != -1)
|
||||
{
|
||||
@@ -322,12 +322,12 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
|
||||
int sock;
|
||||
struct sockaddr_in addr;
|
||||
socklen_t length;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) fd;
|
||||
|
||||
|
||||
xfer = (struct t_xfer *)arg_xfer;
|
||||
|
||||
|
||||
if (xfer->status == XFER_STATUS_CONNECTING)
|
||||
{
|
||||
if (xfer->type == XFER_TYPE_FILE_SEND)
|
||||
@@ -368,7 +368,7 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
|
||||
xfer_network_send_file_fork (xfer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (xfer->status == XFER_STATUS_WAITING)
|
||||
{
|
||||
if (xfer->type == XFER_TYPE_CHAT_SEND)
|
||||
@@ -410,7 +410,7 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
|
||||
xfer_chat_open_buffer (xfer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -423,12 +423,12 @@ int
|
||||
xfer_network_timer_cb (void *arg_xfer, int remaining_calls)
|
||||
{
|
||||
struct t_xfer *xfer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
xfer = (struct t_xfer *)arg_xfer;
|
||||
|
||||
|
||||
if ((xfer->status == XFER_STATUS_WAITING)
|
||||
|| (xfer->status == XFER_STATUS_CONNECTING))
|
||||
{
|
||||
@@ -439,7 +439,7 @@ xfer_network_timer_cb (void *arg_xfer, int remaining_calls)
|
||||
xfer_close (xfer, XFER_STATUS_FAILED);
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -454,14 +454,14 @@ xfer_network_connect (struct t_xfer *xfer)
|
||||
xfer->status = XFER_STATUS_WAITING;
|
||||
else
|
||||
xfer->status = XFER_STATUS_CONNECTING;
|
||||
|
||||
|
||||
if (xfer->sock < 0)
|
||||
{
|
||||
xfer->sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (xfer->sock < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (XFER_IS_SEND(xfer->type))
|
||||
{
|
||||
/* listen to socket */
|
||||
@@ -476,7 +476,7 @@ xfer_network_connect (struct t_xfer *xfer)
|
||||
1, 0, 0,
|
||||
&xfer_network_fd_cb,
|
||||
xfer);
|
||||
|
||||
|
||||
/* add timeout */
|
||||
if (weechat_config_integer (xfer_config_network_timeout) > 0)
|
||||
{
|
||||
@@ -486,7 +486,7 @@ xfer_network_connect (struct t_xfer *xfer)
|
||||
xfer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* for chat receiving, connect to listening host */
|
||||
if (xfer->type == XFER_TYPE_CHAT_RECV)
|
||||
{
|
||||
@@ -494,15 +494,15 @@ xfer_network_connect (struct t_xfer *xfer)
|
||||
return 0;
|
||||
weechat_network_connect_to (xfer->proxy, xfer->sock, xfer->address,
|
||||
xfer->port);
|
||||
|
||||
|
||||
xfer->hook_fd = weechat_hook_fd (xfer->sock,
|
||||
1, 0, 0,
|
||||
&xfer_chat_recv_cb,
|
||||
xfer);
|
||||
}
|
||||
|
||||
|
||||
/* for file receiving, connection is made in child process (blocking) */
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,15 +52,15 @@ xfer_upgrade_save ()
|
||||
{
|
||||
int rc;
|
||||
struct t_upgrade_file *upgrade_file;
|
||||
|
||||
|
||||
upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME, 1);
|
||||
if (!upgrade_file)
|
||||
return 0;
|
||||
|
||||
|
||||
rc = xfer_upgrade_save_xfers (upgrade_file);
|
||||
|
||||
|
||||
weechat_upgrade_close (upgrade_file);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ xfer_upgrade_set_buffer_callbacks ()
|
||||
{
|
||||
struct t_infolist *infolist;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
infolist = weechat_infolist_get ("buffer", NULL, NULL);
|
||||
if (infolist)
|
||||
{
|
||||
@@ -111,7 +111,7 @@ xfer_upgrade_read_cb (void *data,
|
||||
(void) upgrade_file;
|
||||
(void) object_id;
|
||||
(void) infolist;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -125,11 +125,11 @@ xfer_upgrade_load ()
|
||||
{
|
||||
int rc;
|
||||
struct t_upgrade_file *upgrade_file;
|
||||
|
||||
|
||||
xfer_upgrade_set_buffer_callbacks ();
|
||||
|
||||
|
||||
upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME, 0);
|
||||
rc = weechat_upgrade_read (upgrade_file, &xfer_upgrade_read_cb, NULL);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
+122
-122
@@ -61,7 +61,7 @@ char *xfer_type_string[] = /* strings for types */
|
||||
char *xfer_protocol_string[] = /* strings for protocols */
|
||||
{ "none", "dcc"
|
||||
};
|
||||
|
||||
|
||||
char *xfer_status_string[] = /* strings for status */
|
||||
{ N_("waiting"), N_("connecting"),
|
||||
N_("active"), N_("done"), N_("failed"),
|
||||
@@ -85,17 +85,17 @@ int
|
||||
xfer_valid (struct t_xfer *xfer)
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
if (!xfer)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_xfer = xfer_list; ptr_xfer;
|
||||
ptr_xfer = ptr_xfer->next_xfer)
|
||||
{
|
||||
if (ptr_xfer == xfer)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* xfer not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -113,9 +113,9 @@ xfer_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
|
||||
xfer_signal_upgrade_received = 1;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ xfer_create_directories ()
|
||||
{
|
||||
const char *weechat_dir;
|
||||
char *dir1, *dir2;
|
||||
|
||||
|
||||
/* create download directory */
|
||||
weechat_dir = weechat_info_get ("weechat_dir", "");
|
||||
if (weechat_dir)
|
||||
@@ -154,13 +154,13 @@ int
|
||||
xfer_search_type (const char *type)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < XFER_NUM_TYPES; i++)
|
||||
{
|
||||
if (weechat_strcasecmp (xfer_type_string[i], type) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* xfer type not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -174,13 +174,13 @@ int
|
||||
xfer_search_protocol (const char *protocol)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < XFER_NUM_PROTOCOLS; i++)
|
||||
{
|
||||
if (weechat_strcasecmp (xfer_protocol_string[i], protocol) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* xfer protocol not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ xfer_search (const char *plugin_name, const char *plugin_id, enum t_xfer_type ty
|
||||
enum t_xfer_status status, int port)
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer)
|
||||
{
|
||||
if ((weechat_strcasecmp (ptr_xfer->plugin_name, plugin_name) == 0)
|
||||
@@ -204,7 +204,7 @@ xfer_search (const char *plugin_name, const char *plugin_id, enum t_xfer_type ty
|
||||
&& (ptr_xfer->port == port))
|
||||
return ptr_xfer;
|
||||
}
|
||||
|
||||
|
||||
/* xfer not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ xfer_search_by_number (int number)
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
int i;
|
||||
|
||||
|
||||
i = 0;
|
||||
for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer)
|
||||
{
|
||||
@@ -226,7 +226,7 @@ xfer_search_by_number (int number)
|
||||
return ptr_xfer;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
/* xfer not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -239,16 +239,16 @@ struct t_xfer *
|
||||
xfer_search_by_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer)
|
||||
{
|
||||
if (ptr_xfer->buffer == buffer)
|
||||
return ptr_xfer;
|
||||
}
|
||||
|
||||
|
||||
/* xfer not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -261,13 +261,13 @@ void
|
||||
xfer_close (struct t_xfer *xfer, enum t_xfer_status status)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
|
||||
xfer->status = status;
|
||||
|
||||
|
||||
if (XFER_HAS_ENDED(xfer->status))
|
||||
{
|
||||
xfer_send_signal (xfer, "xfer_ended");
|
||||
|
||||
|
||||
if (xfer->hook_fd)
|
||||
{
|
||||
weechat_unhook (xfer->hook_fd);
|
||||
@@ -309,7 +309,7 @@ xfer_close (struct t_xfer *xfer, enum t_xfer_status status)
|
||||
xfer->address & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* remove empty file if received file failed and nothing was transfered */
|
||||
if (((xfer->status == XFER_STATUS_FAILED)
|
||||
|| (xfer->status == XFER_STATUS_ABORTED))
|
||||
@@ -325,10 +325,10 @@ xfer_close (struct t_xfer *xfer, enum t_xfer_status status)
|
||||
unlink (xfer->local_filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (XFER_IS_FILE(xfer->type))
|
||||
xfer_file_calculate_speed (xfer, 1);
|
||||
|
||||
|
||||
if (xfer->sock >= 0)
|
||||
{
|
||||
close (xfer->sock);
|
||||
@@ -350,14 +350,14 @@ int
|
||||
xfer_port_in_use (int port)
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
/* skip any currently used ports */
|
||||
for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer)
|
||||
{
|
||||
if ((ptr_xfer->port == port) && (!XFER_HAS_ENDED(ptr_xfer->status)))
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* port not in use */
|
||||
return 0;
|
||||
}
|
||||
@@ -372,7 +372,7 @@ xfer_send_signal (struct t_xfer *xfer, const char *signal)
|
||||
struct t_infolist *infolist;
|
||||
struct t_infolist_item *item;
|
||||
char str_long[128];
|
||||
|
||||
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
{
|
||||
@@ -406,7 +406,7 @@ xfer_send_signal (struct t_xfer *xfer, const char *signal)
|
||||
str_long);
|
||||
weechat_infolist_new_var_integer (item, "port",
|
||||
xfer->port);
|
||||
|
||||
|
||||
weechat_hook_signal_send (signal, WEECHAT_HOOK_SIGNAL_POINTER,
|
||||
infolist);
|
||||
}
|
||||
@@ -423,13 +423,13 @@ xfer_alloc ()
|
||||
{
|
||||
struct t_xfer *new_xfer;
|
||||
time_t time_now;
|
||||
|
||||
|
||||
/* create new xfer struct */
|
||||
if ((new_xfer = malloc (sizeof (*new_xfer))) == NULL)
|
||||
return NULL;
|
||||
|
||||
time_now = time (NULL);
|
||||
|
||||
|
||||
/* default values */
|
||||
new_xfer->filename = NULL;
|
||||
new_xfer->size = 0;
|
||||
@@ -438,7 +438,7 @@ xfer_alloc ()
|
||||
new_xfer->remote_nick = NULL;
|
||||
new_xfer->local_nick = NULL;
|
||||
new_xfer->charset_modifier = NULL;
|
||||
|
||||
|
||||
new_xfer->type = 0;
|
||||
new_xfer->protocol = 0;
|
||||
new_xfer->status = 0;
|
||||
@@ -466,7 +466,7 @@ xfer_alloc ()
|
||||
new_xfer->last_activity = 0;
|
||||
new_xfer->bytes_per_sec = 0;
|
||||
new_xfer->eta = 0;
|
||||
|
||||
|
||||
new_xfer->prev_xfer = NULL;
|
||||
new_xfer->next_xfer = xfer_list;
|
||||
if (xfer_list)
|
||||
@@ -474,9 +474,9 @@ xfer_alloc ()
|
||||
else
|
||||
last_xfer = new_xfer;
|
||||
xfer_list = new_xfer;
|
||||
|
||||
|
||||
xfer_count++;
|
||||
|
||||
|
||||
return new_xfer;
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ xfer_new (const char *plugin_name, const char *plugin_id,
|
||||
{
|
||||
struct t_xfer *new_xfer;
|
||||
const char *ptr_color;
|
||||
|
||||
|
||||
new_xfer = xfer_alloc ();
|
||||
if (!new_xfer)
|
||||
{
|
||||
@@ -503,13 +503,13 @@ xfer_new (const char *plugin_name, const char *plugin_id,
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!xfer_buffer
|
||||
&& weechat_config_boolean (xfer_config_look_auto_open_buffer))
|
||||
{
|
||||
xfer_buffer_open ();
|
||||
}
|
||||
|
||||
|
||||
/* initialize new xfer */
|
||||
new_xfer->plugin_name = strdup (plugin_name);
|
||||
new_xfer->plugin_id = strdup (plugin_id);
|
||||
@@ -528,14 +528,14 @@ xfer_new (const char *plugin_name, const char *plugin_id,
|
||||
new_xfer->proxy = (proxy) ? strdup (proxy) : NULL;
|
||||
new_xfer->address = address;
|
||||
new_xfer->port = port;
|
||||
|
||||
|
||||
new_xfer->status = XFER_STATUS_WAITING;
|
||||
new_xfer->sock = sock;
|
||||
if (local_filename)
|
||||
new_xfer->local_filename = strdup (local_filename);
|
||||
else
|
||||
xfer_file_find_filename (new_xfer);
|
||||
|
||||
|
||||
/* write info message on server buffer */
|
||||
switch (type)
|
||||
{
|
||||
@@ -588,14 +588,14 @@ xfer_new (const char *plugin_name, const char *plugin_id,
|
||||
case XFER_NUM_TYPES:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (XFER_IS_FILE(type) && (!new_xfer->local_filename))
|
||||
{
|
||||
xfer_close (new_xfer, XFER_STATUS_FAILED);
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (XFER_IS_FILE(type) && (new_xfer->start_resume > 0))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -607,7 +607,7 @@ xfer_new (const char *plugin_name, const char *plugin_id,
|
||||
new_xfer->start_resume);
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
}
|
||||
|
||||
|
||||
/* connect if needed and display again xfer buffer */
|
||||
if (XFER_IS_SEND(type))
|
||||
{
|
||||
@@ -618,7 +618,7 @@ xfer_new (const char *plugin_name, const char *plugin_id,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( ( (type == XFER_TYPE_FILE_RECV)
|
||||
&& (weechat_config_boolean (xfer_config_file_auto_accept_files)) )
|
||||
|| ( (type == XFER_TYPE_CHAT_RECV)
|
||||
@@ -626,7 +626,7 @@ xfer_new (const char *plugin_name, const char *plugin_id,
|
||||
xfer_network_accept (new_xfer);
|
||||
else
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_PRIVATE);
|
||||
|
||||
|
||||
return new_xfer;
|
||||
}
|
||||
|
||||
@@ -638,10 +638,10 @@ void
|
||||
xfer_free (struct t_xfer *xfer)
|
||||
{
|
||||
struct t_xfer *new_xfer_list;
|
||||
|
||||
|
||||
if (!xfer)
|
||||
return;
|
||||
|
||||
|
||||
/* remove xfer from list */
|
||||
if (last_xfer == xfer)
|
||||
last_xfer = xfer->prev_xfer;
|
||||
@@ -654,7 +654,7 @@ xfer_free (struct t_xfer *xfer)
|
||||
new_xfer_list = xfer->next_xfer;
|
||||
if (xfer->next_xfer)
|
||||
(xfer->next_xfer)->prev_xfer = xfer->prev_xfer;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (xfer->plugin_id)
|
||||
free (xfer->plugin_id);
|
||||
@@ -672,11 +672,11 @@ xfer_free (struct t_xfer *xfer)
|
||||
free (xfer->unterminated_message);
|
||||
if (xfer->local_filename)
|
||||
free (xfer->local_filename);
|
||||
|
||||
|
||||
free (xfer);
|
||||
|
||||
|
||||
xfer_list = new_xfer_list;
|
||||
|
||||
|
||||
xfer_count--;
|
||||
if (xfer_buffer_selected_line >= xfer_count)
|
||||
xfer_buffer_selected_line = (xfer_count == 0) ? 0 : xfer_count - 1;
|
||||
@@ -704,12 +704,12 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
unsigned long local_addr;
|
||||
unsigned long long file_size;
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -717,9 +717,9 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME, "xfer_add");
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
infolist = (struct t_infolist *)signal_data;
|
||||
|
||||
|
||||
if (!weechat_infolist_next (infolist))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -730,10 +730,10 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
|
||||
filename2 = NULL;
|
||||
short_filename = NULL;
|
||||
|
||||
|
||||
sock = -1;
|
||||
port = 0;
|
||||
|
||||
|
||||
plugin_name = weechat_infolist_string (infolist, "plugin_name");
|
||||
plugin_id = weechat_infolist_string (infolist, "plugin_id");
|
||||
str_type = weechat_infolist_string (infolist, "type");
|
||||
@@ -744,7 +744,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
filename = weechat_infolist_string (infolist, "filename");
|
||||
proxy = weechat_infolist_string (infolist, "proxy");
|
||||
protocol = XFER_NO_PROTOCOL;
|
||||
|
||||
|
||||
if (!plugin_name || !plugin_id || !str_type || !remote_nick || !local_nick)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -761,7 +761,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME, str_type);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (XFER_IS_FILE(type) && (!filename || !str_protocol))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -769,7 +769,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME, "xfer_add");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (XFER_IS_FILE(type))
|
||||
{
|
||||
protocol = xfer_search_protocol (str_protocol);
|
||||
@@ -782,17 +782,17 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
filename2 = NULL;
|
||||
file_size = 0;
|
||||
port = 0;
|
||||
|
||||
|
||||
if (type == XFER_TYPE_FILE_RECV)
|
||||
{
|
||||
filename2 = strdup (filename);
|
||||
sscanf (weechat_infolist_string (infolist, "size"), "%llu", &file_size);
|
||||
}
|
||||
|
||||
|
||||
if (type == XFER_TYPE_FILE_SEND)
|
||||
{
|
||||
/* add home if filename not beginning with '/' or '~' (not for Win32) */
|
||||
@@ -813,7 +813,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
weechat_dir = weechat_info_get ("weechat_dir", "");
|
||||
dir2 = weechat_string_replace (dir1, "%h", weechat_dir);
|
||||
if (!dir2)
|
||||
@@ -857,7 +857,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
}
|
||||
file_size = st.st_size;
|
||||
}
|
||||
|
||||
|
||||
if (XFER_IS_RECV(type))
|
||||
{
|
||||
sscanf (weechat_infolist_string (infolist, "address"), "%lu", &local_addr);
|
||||
@@ -867,11 +867,11 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
{
|
||||
/* get local IP address */
|
||||
sscanf (weechat_infolist_string (infolist, "address"), "%lu", &local_addr);
|
||||
|
||||
|
||||
memset (&addr, 0, sizeof (struct sockaddr_in));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = htonl (local_addr);
|
||||
|
||||
|
||||
/* look up the IP address from network_own_ip, if set */
|
||||
if (weechat_config_string(xfer_config_network_own_ip)
|
||||
&& weechat_config_string(xfer_config_network_own_ip)[0])
|
||||
@@ -900,7 +900,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
weechat_config_string (xfer_config_network_own_ip));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* open socket for xfer */
|
||||
sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sock < 0)
|
||||
@@ -912,10 +912,10 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
free (filename2);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
/* look for port */
|
||||
port = 0;
|
||||
|
||||
|
||||
if (weechat_config_string (xfer_config_network_port_range)
|
||||
&& weechat_config_string (xfer_config_network_port_range)[0])
|
||||
{
|
||||
@@ -927,7 +927,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
port = port_start;
|
||||
if (args == 1)
|
||||
port_end = port_start;
|
||||
|
||||
|
||||
/* loop through the entire allowed port range */
|
||||
while (port <= port_end)
|
||||
{
|
||||
@@ -940,12 +940,12 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
}
|
||||
port++;
|
||||
}
|
||||
|
||||
|
||||
if (port > port_end)
|
||||
port = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (port == 0)
|
||||
{
|
||||
/* find port automatically */
|
||||
@@ -959,7 +959,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
else
|
||||
port = -1;
|
||||
}
|
||||
|
||||
|
||||
if (port == -1)
|
||||
{
|
||||
/* Could not find any port to bind */
|
||||
@@ -972,7 +972,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (XFER_IS_FILE(type))
|
||||
{
|
||||
/* extract short filename (without path) */
|
||||
@@ -981,7 +981,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
short_filename = strdup (pos + 1);
|
||||
else
|
||||
short_filename = strdup (filename2);
|
||||
|
||||
|
||||
/* convert spaces to underscore if asked and needed */
|
||||
pos = short_filename;
|
||||
while (pos[0])
|
||||
@@ -1003,7 +1003,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
filename2 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* add xfer entry and listen to socket if type is file or chat "send" */
|
||||
if (XFER_IS_FILE(type))
|
||||
ptr_xfer = xfer_new (plugin_name, plugin_id, type, protocol,
|
||||
@@ -1014,7 +1014,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
ptr_xfer = xfer_new (plugin_name, plugin_id, type, protocol,
|
||||
remote_nick, local_nick, charset_modifier, NULL,
|
||||
0, proxy, local_addr, port, sock, NULL);
|
||||
|
||||
|
||||
if (!ptr_xfer)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1027,19 +1027,19 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
|
||||
free (filename2);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
/* send signal if type is file or chat "send" */
|
||||
if (XFER_IS_SEND(ptr_xfer->type) && !XFER_HAS_ENDED(ptr_xfer->status))
|
||||
xfer_send_signal (ptr_xfer, "xfer_send_ready");
|
||||
|
||||
|
||||
if (short_filename)
|
||||
free (short_filename);
|
||||
if (filename2)
|
||||
free (filename2);
|
||||
|
||||
|
||||
weechat_infolist_reset_item_cursor (infolist);
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
error:
|
||||
weechat_infolist_reset_item_cursor (infolist);
|
||||
return WEECHAT_RC_ERROR;
|
||||
@@ -1058,12 +1058,12 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data,
|
||||
const char *plugin_name, *plugin_id, *filename, *str_start_resume;
|
||||
int port;
|
||||
unsigned long long start_resume;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1072,9 +1072,9 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data,
|
||||
"xfer_start_resume");
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
infolist = (struct t_infolist *)signal_data;
|
||||
|
||||
|
||||
if (!weechat_infolist_next (infolist))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1098,9 +1098,9 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data,
|
||||
"xfer_start_resume");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
sscanf (str_start_resume, "%llu", &start_resume);
|
||||
|
||||
|
||||
ptr_xfer = xfer_search (plugin_name, plugin_id, XFER_TYPE_FILE_RECV,
|
||||
XFER_STATUS_CONNECTING, port);
|
||||
if (ptr_xfer)
|
||||
@@ -1120,10 +1120,10 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data,
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME, filename,
|
||||
port, start_resume);
|
||||
}
|
||||
|
||||
|
||||
weechat_infolist_reset_item_cursor (infolist);
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
error:
|
||||
weechat_infolist_reset_item_cursor (infolist);
|
||||
return WEECHAT_RC_ERROR;
|
||||
@@ -1143,12 +1143,12 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data,
|
||||
const char *plugin_name, *plugin_id, *filename, *str_start_resume;
|
||||
int port;
|
||||
unsigned long long start_resume;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1157,9 +1157,9 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data,
|
||||
"xfer_accept_resume");
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
infolist = (struct t_infolist *)signal_data;
|
||||
|
||||
|
||||
if (!weechat_infolist_next (infolist))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1183,9 +1183,9 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data,
|
||||
"xfer_accept_resume");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
sscanf (str_start_resume, "%llu", &start_resume);
|
||||
|
||||
|
||||
ptr_xfer = xfer_search (plugin_name, plugin_id, XFER_TYPE_FILE_SEND,
|
||||
XFER_STATUS_CONNECTING, port);
|
||||
if (ptr_xfer)
|
||||
@@ -1195,7 +1195,7 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data,
|
||||
ptr_xfer->start_resume = start_resume;
|
||||
ptr_xfer->last_check_pos = start_resume;
|
||||
xfer_send_signal (ptr_xfer, "xfer_send_accept_resume");
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("%s: file %s resumed at position %llu"),
|
||||
XFER_PLUGIN_NAME,
|
||||
@@ -1212,10 +1212,10 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data,
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME, filename,
|
||||
port, start_resume);
|
||||
}
|
||||
|
||||
|
||||
weechat_infolist_reset_item_cursor (infolist);
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
error:
|
||||
weechat_infolist_reset_item_cursor (infolist);
|
||||
return WEECHAT_RC_ERROR;
|
||||
@@ -1231,14 +1231,14 @@ xfer_add_to_infolist (struct t_infolist *infolist, struct t_xfer *xfer)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
char value[128];
|
||||
|
||||
|
||||
if (!infolist || !xfer)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "plugin_name", xfer->plugin_name))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "plugin_id", xfer->plugin_id))
|
||||
@@ -1328,7 +1328,7 @@ xfer_add_to_infolist (struct t_infolist *infolist, struct t_xfer *xfer)
|
||||
snprintf (value, sizeof (value), "%llu", xfer->eta);
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "eta", value))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1340,7 +1340,7 @@ void
|
||||
xfer_print_log ()
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer)
|
||||
{
|
||||
weechat_log_printf ("");
|
||||
@@ -1361,7 +1361,7 @@ xfer_print_log ()
|
||||
weechat_log_printf (" proxy . . . . . . . : '%s'", ptr_xfer->proxy);
|
||||
weechat_log_printf (" address . . . . . . : %lu", ptr_xfer->address);
|
||||
weechat_log_printf (" port. . . . . . . . : %d", ptr_xfer->port);
|
||||
|
||||
|
||||
weechat_log_printf (" status. . . . . . . : %d (%s)",
|
||||
ptr_xfer->status,
|
||||
xfer_status_string[ptr_xfer->status]);
|
||||
@@ -1406,21 +1406,21 @@ xfer_debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, XFER_PLUGIN_NAME) == 0))
|
||||
{
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
|
||||
|
||||
xfer_print_log ();
|
||||
|
||||
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** End of \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1432,29 +1432,29 @@ int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
int i, upgrading;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
if (!xfer_config_init ())
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
if (xfer_config_read () < 0)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
xfer_create_directories ();
|
||||
|
||||
|
||||
xfer_command_init ();
|
||||
|
||||
|
||||
/* hook some signals */
|
||||
weechat_hook_signal ("upgrade", &xfer_signal_upgrade_cb, NULL);
|
||||
weechat_hook_signal ("xfer_add", &xfer_add_cb, NULL);
|
||||
weechat_hook_signal ("xfer_start_resume", &xfer_start_resume_cb, NULL);
|
||||
weechat_hook_signal ("xfer_accept_resume", &xfer_accept_resume_cb, NULL);
|
||||
weechat_hook_signal ("debug_dump", &xfer_debug_dump_cb, NULL);
|
||||
|
||||
|
||||
/* hook completions */
|
||||
xfer_completion_init ();
|
||||
|
||||
|
||||
xfer_info_init ();
|
||||
|
||||
/* look at arguments */
|
||||
@@ -1464,10 +1464,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
if (weechat_strcasecmp (argv[i], "--upgrade") == 0)
|
||||
upgrading = 1;
|
||||
}
|
||||
|
||||
|
||||
if (upgrading)
|
||||
xfer_upgrade_load ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1479,12 +1479,12 @@ int
|
||||
weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
xfer_config_write ();
|
||||
|
||||
|
||||
if (xfer_signal_upgrade_received)
|
||||
xfer_upgrade_save ();
|
||||
else
|
||||
@@ -1508,6 +1508,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ enum t_xfer_status
|
||||
/* number of xfer status */
|
||||
XFER_NUM_STATUS,
|
||||
};
|
||||
|
||||
|
||||
/* xfer errors */
|
||||
|
||||
enum t_xfer_error
|
||||
@@ -121,7 +121,7 @@ struct t_xfer
|
||||
char *proxy; /* proxy to use (optional) */
|
||||
unsigned long address; /* local or remote IP address */
|
||||
int port; /* remote port */
|
||||
|
||||
|
||||
/* internal data */
|
||||
enum t_xfer_status status; /* xfer status (waiting, sending,..) */
|
||||
struct t_gui_buffer *buffer; /* buffer (for chat only) */
|
||||
|
||||
Reference in New Issue
Block a user