summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-command.c35
-rw-r--r--src/core/wee-config-file.c6
-rw-r--r--src/core/wee-config.c11
-rw-r--r--src/core/wee-config.h1
-rw-r--r--src/core/wee-hook.c27
-rw-r--r--src/core/wee-hook.h6
-rw-r--r--src/core/wee-list.c15
-rw-r--r--src/core/wee-list.h1
-rw-r--r--src/core/wee-string.c4
-rw-r--r--src/core/wee-util.c15
-rw-r--r--src/core/wee-util.h1
-rw-r--r--src/core/weechat.c9
12 files changed, 99 insertions, 32 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index d25571736..ee56040ec 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -399,15 +399,22 @@ command_clear (void *data, struct t_gui_buffer *buffer,
void
command_debug_display_windows (struct t_gui_window_tree *tree, int indent)
{
+ char format[128];
+
if (tree)
{
if (tree->window)
{
/* leaf */
+ snprintf (format,
+ sizeof (format),
+ "%%-%dsleaf: 0x%%X (parent:0x%%X), win=0x%%X, "
+ "child1=0x%%X, child2=0x%%X, %%d,%%d %%dx%%d, "
+ "%%d%%%%x%%d%%%%",
+ indent * 2);
gui_chat_printf (NULL,
- "leaf: %X (parent:%X), win=%X, child1=%X, "
- "child2=%X, %d,%d %dx%d, %d%%x%d%%",
- tree, tree->parent_node, tree->window,
+ format,
+ " ", tree, tree->parent_node, tree->window,
tree->child1, tree->child2,
tree->window->win_x, tree->window->win_y,
tree->window->win_width, tree->window->win_height,
@@ -417,10 +424,14 @@ command_debug_display_windows (struct t_gui_window_tree *tree, int indent)
else
{
/* node */
+ snprintf (format,
+ sizeof (format),
+ "%%-%dsnode: 0x%%X (parent:0x%%X), win=0x%%X, "
+ "child1=0x%%X, child2=0x%%X)",
+ indent * 2);
gui_chat_printf (NULL,
- "node: %X (parent:%X), win=%X, child1=%X, "
- "child2=%X)",
- tree, tree->parent_node, tree->window,
+ format,
+ " ", tree, tree->parent_node, tree->window,
tree->child1, tree->child2);
}
@@ -464,11 +475,7 @@ command_debug (void *data, struct t_gui_buffer *buffer,
}
else
{
- gui_chat_printf (NULL,
- _("%sError: unknown option for \"%s\" command"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
- "debug");
- return WEECHAT_RC_ERROR;
+ hook_signal_send ("debug", argv_eol[1]);
}
}
@@ -1928,12 +1935,14 @@ command_init ()
command_clear, NULL);
hook_command (NULL, "debug",
N_("print debug messages"),
- N_("dump | buffer | windows"),
+ N_("dump | buffer | windows | text"),
N_(" dump: save memory dump in WeeChat log file (same "
"dump is written when WeeChat crashes)\n"
" buffer: dump buffer content with hexadecimal values "
"in log file\n"
- "windows: display windows tree"),
+ "windows: display windows tree\n"
+ " text: send \"debug\" signal with \"text\" as "
+ "arguments"),
"dump|buffer|windows",
command_debug, NULL);
hook_command (NULL, "help",
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c
index 5753a16e3..7d888b6bc 100644
--- a/src/core/wee-config-file.c
+++ b/src/core/wee-config-file.c
@@ -273,10 +273,8 @@ config_file_new_option (struct t_config_section *section, char *name,
*((int *)new_option->value) = int_value;
break;
case CONFIG_OPTION_INTEGER:
- if (string_values)
- new_option->string_values = string_explode (string_values,
- "|", 0, 0,
- &argc);
+ new_option->string_values = (string_values) ?
+ string_explode (string_values, "|", 0, 0, &argc) : NULL;
if (new_option->string_values)
{
new_option->min = 0;
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index c74d96f1a..c3bb529d7 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -145,6 +145,7 @@ struct t_config_option *config_color_input_text_not_found;
struct t_config_option *config_color_input_actions;
struct t_config_option *config_color_nicklist;
struct t_config_option *config_color_nicklist_bg;
+struct t_config_option *config_color_nicklist_group;
struct t_config_option *config_color_nicklist_away;
struct t_config_option *config_color_nicklist_prefix1;
struct t_config_option *config_color_nicklist_prefix2;
@@ -309,9 +310,10 @@ config_change_color ()
void
config_change_nicks_colors ()
{
+ /*
struct t_gui_buffer *ptr_buffer;
struct t_gui_nick *ptr_nick;
-
+
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
@@ -320,10 +322,11 @@ config_change_nicks_colors ()
for (ptr_nick = ptr_buffer->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
- //gui_nick_find_color (ptr_nick);
+ gui_nick_find_color (ptr_nick);
}
}
}
+ */
}
/*
@@ -954,6 +957,10 @@ config_weechat_init ()
ptr_section, "color_nicklist_bg", "color",
N_("background color for nicklist"),
NULL, -1, 0, "default", &config_change_color);
+ config_color_nicklist_group = config_file_new_option (
+ ptr_section, "color_nicklist_group", "color",
+ N_("text color for groups in nicklist"),
+ NULL, GUI_COLOR_NICKLIST_GROUP, 0, "green", &config_change_color);
config_color_nicklist_away = config_file_new_option (
ptr_section, "color_nicklist_away", "color",
N_("text color for away nicknames"),
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index 15de988d6..0787f5613 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -131,6 +131,7 @@ extern struct t_config_option *config_color_input_text_not_found;
extern struct t_config_option *config_color_input_actions;
extern struct t_config_option *config_color_nicklist;
extern struct t_config_option *config_color_nicklist_bg;
+extern struct t_config_option *config_color_nicklist_group;
extern struct t_config_option *config_color_nicklist_away;
extern struct t_config_option *config_color_nicklist_prefix1;
extern struct t_config_option *config_color_nicklist_prefix2;
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index db2b3dd72..ab4b6c093 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -638,26 +638,43 @@ hook_fd (struct t_weechat_plugin *plugin, int fd, int flag_read,
/*
* hook_fd_set: fill sets according to hd hooked
+ * return highest fd set
*/
-void
+int
hook_fd_set (fd_set *read_fds, fd_set *write_fds, fd_set *exception_fds)
{
struct t_hook *ptr_hook;
-
+ int max_fd;
+
+ max_fd = 0;
for (ptr_hook = weechat_hooks[HOOK_TYPE_FD]; ptr_hook;
ptr_hook = ptr_hook->next_hook)
{
if (!ptr_hook->deleted)
{
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_READ)
+ {
FD_SET (HOOK_FD(ptr_hook, fd), read_fds);
+ if (HOOK_FD(ptr_hook, fd) > max_fd)
+ max_fd = HOOK_FD(ptr_hook, fd);
+ }
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_WRITE)
+ {
FD_SET (HOOK_FD(ptr_hook, fd), write_fds);
+ if (HOOK_FD(ptr_hook, fd) > max_fd)
+ max_fd = HOOK_FD(ptr_hook, fd);
+ }
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_EXCEPTION)
+ {
FD_SET (HOOK_FD(ptr_hook, fd), exception_fds);
+ if (HOOK_FD(ptr_hook, fd) > max_fd)
+ max_fd = HOOK_FD(ptr_hook, fd);
+ }
}
}
+
+ return max_fd;
}
/*
@@ -678,7 +695,7 @@ hook_fd_exec (fd_set *read_fds, fd_set *write_fds, fd_set *exception_fds)
if (!ptr_hook->deleted
&& !ptr_hook->running
- && (((HOOK_FD(ptr_hook, flags)& HOOK_FD_FLAG_READ)
+ && (((HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_READ)
&& (FD_ISSET(HOOK_FD(ptr_hook, fd), read_fds)))
|| ((HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_WRITE)
&& (FD_ISSET(HOOK_FD(ptr_hook, fd), write_fds)))
@@ -1172,7 +1189,9 @@ hook_print_log ()
{
log_printf ("");
log_printf ("[hook (addr:0x%X)]", ptr_hook);
- log_printf (" plugin . . . . . . . . : 0x%X", ptr_hook->plugin);
+ log_printf (" plugin . . . . . . . . : 0x%X ('%s')",
+ ptr_hook->plugin,
+ (ptr_hook->plugin) ? ptr_hook->plugin->name : "");
log_printf (" deleted. . . . . . . . : %d", ptr_hook->deleted);
log_printf (" running. . . . . . . . : %d", ptr_hook->running);
switch (ptr_hook->type)
diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h
index c725d8661..2af874dd9 100644
--- a/src/core/wee-hook.h
+++ b/src/core/wee-hook.h
@@ -173,8 +173,8 @@ extern struct t_hook *hook_fd (struct t_weechat_plugin *plugin, int fd,
int flag_exception,
t_hook_callback_fd * callback,
void *callback_data);
-extern void hook_fd_set (fd_set *read_fds, fd_set *write_fds,
- fd_set *exception_fds);
+extern int hook_fd_set (fd_set *read_fds, fd_set *write_fds,
+ fd_set *exception_fds);
extern void hook_fd_exec (fd_set *read_fds, fd_set *write_fds,
fd_set *exception_fds);
extern struct t_hook *hook_print (struct t_weechat_plugin *plugin,
@@ -188,7 +188,7 @@ extern struct t_hook *hook_signal (struct t_weechat_plugin *plugin,
char *signal,
t_hook_callback_signal *callback,
void *callback_data);
-extern void hook_signal_send (char *signal, void *signal_date);
+extern void hook_signal_send (char *signal, void *signal_data);
extern struct t_hook *hook_config (struct t_weechat_plugin *, char *type,
char *option,
t_hook_callback_config *callback,
diff --git a/src/core/wee-list.c b/src/core/wee-list.c
index 77e3c1533..5b6f6d0ba 100644
--- a/src/core/wee-list.c
+++ b/src/core/wee-list.c
@@ -225,6 +225,21 @@ weelist_get (struct t_weelist *weelist, int position)
}
/*
+ * weelist_set: set a new value for an item
+ */
+
+void
+weelist_set (struct t_weelist_item *item, char *new_value)
+{
+ if (!item || !new_value)
+ return;
+
+ if (item->data)
+ free (item->data);
+ item->data = strdup (new_value);
+}
+
+/*
* weelist_next: get next item
*/
diff --git a/src/core/wee-list.h b/src/core/wee-list.h
index 852026aba..c1bae7233 100644
--- a/src/core/wee-list.h
+++ b/src/core/wee-list.h
@@ -47,6 +47,7 @@ extern struct t_weelist_item *weelist_casesearch (struct t_weelist *weelist,
char *data);
extern struct t_weelist_item *weelist_get (struct t_weelist *weelist,
int position);
+extern void weelist_set (struct t_weelist_item *item, char *new_value);
extern struct t_weelist_item *weelist_next (struct t_weelist_item *item);
extern struct t_weelist_item *weelist_prev (struct t_weelist_item *item);
extern char *weelist_string (struct t_weelist_item *item);
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 902d57764..22128117f 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -385,7 +385,7 @@ string_explode (char *string, char *separators, int keep_eol,
i = 1;
while ((ptr = strpbrk (ptr, separators)))
{
- while (strchr (separators, ptr[0]) != NULL)
+ while (ptr[0] && (strchr (separators, ptr[0]) != NULL))
ptr++;
i++;
}
@@ -402,7 +402,7 @@ string_explode (char *string, char *separators, int keep_eol,
for (i = 0; i < n_items; i++)
{
- while (strchr (separators, ptr1[0]) != NULL)
+ while (ptr1[0] && (strchr (separators, ptr1[0]) != NULL))
ptr1++;
if (i == (n_items - 1) || (ptr2 = strpbrk (ptr1, separators)) == NULL)
if ((ptr2 = strchr (ptr1, '\r')) == NULL)
diff --git a/src/core/wee-util.c b/src/core/wee-util.c
index 86f5f6b93..4223e7f34 100644
--- a/src/core/wee-util.c
+++ b/src/core/wee-util.c
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
+#include <signal.h>
#include "weechat.h"
#include "wee-util.h"
@@ -119,6 +120,20 @@ util_get_time_length (char *time_format)
return strlen (text_time);
}
+/*
+ * util_catch_signal: catch a signal
+ */
+
+void
+util_catch_signal (int signum, void (*handler)(int))
+{
+ struct sigaction act;
+
+ sigemptyset (&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = handler;
+ sigaction(signum, &act, NULL);
+}
/*
* util_create_dir: create a directory
diff --git a/src/core/wee-util.h b/src/core/wee-util.h
index 66d4bce0f..5f65666a2 100644
--- a/src/core/wee-util.h
+++ b/src/core/wee-util.h
@@ -24,6 +24,7 @@ extern int util_timeval_cmp (struct timeval *tv1, struct timeval *tv2);
extern long util_timeval_diff (struct timeval *tv1, struct timeval *tv2);
extern void util_timeval_add (struct timeval *tv, long interval);
extern int util_get_time_length (char *time_format);
+extern void util_catch_signal (int signum, void (*handler)(int));
extern int util_create_dir (char *directory, int permissions);
extern void util_exec_on_files (char *directory, void *data,
int (*callback)(void *data, char *filename));
diff --git a/src/core/weechat.c b/src/core/weechat.c
index abe39e365..37b4cfb16 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -582,10 +582,11 @@ main (int argc, char *argv[])
#endif
utf8_init ();
- signal (SIGINT, SIG_IGN); /* ignore SIGINT signal */
- signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */
- signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */
- signal (SIGSEGV, weechat_sigsegv); /* crash dump when SIGSEGV received */
+ util_catch_signal (SIGINT, SIG_IGN); /* ignore SIGINT signal */
+ util_catch_signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */
+ util_catch_signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */
+ util_catch_signal (SIGSEGV,
+ &weechat_sigsegv); /* crash dump for SIGSEGV signal */
hook_init (); /* initialize hooks */
gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */
weechat_init_vars (); /* initialize some variables */