summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-02-21 17:31:59 +0100
committerSebastien Helleu <flashcode@flashtux.org>2008-02-21 17:31:59 +0100
commitdec0e7dc1206e928c38291aae3f5486fd8a8bf12 (patch)
treec47b6841ce345aa5b4da58d40a90e427dc99a41e /src
parent155e689a26fc18f37b3572a5507f1c94edd91648 (diff)
downloadweechat-dec0e7dc1206e928c38291aae3f5486fd8a8bf12.zip
Added new plugin "debug"
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt6
-rw-r--r--src/core/Makefile.am2
-rw-r--r--src/core/wee-command.c138
-rw-r--r--src/core/wee-debug.c211
-rw-r--r--src/core/wee-debug.h28
-rw-r--r--src/core/weechat.c84
-rw-r--r--src/gui/curses/Makefile.am1
-rw-r--r--src/gui/gtk/Makefile.am1
-rw-r--r--src/plugins/CMakeLists.txt20
-rw-r--r--src/plugins/Makefile.am31
-rw-r--r--src/plugins/debug/CMakeLists.txt22
-rw-r--r--src/plugins/debug/Makefile.am25
-rw-r--r--src/plugins/debug/debug.c123
-rw-r--r--src/plugins/irc/irc.c57
-rw-r--r--src/plugins/scripts/lua/weechat-lua.c8
-rw-r--r--src/plugins/scripts/perl/weechat-perl.c8
-rw-r--r--src/plugins/scripts/python/weechat-python.c8
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby.c8
-rw-r--r--src/plugins/scripts/script.c10
-rw-r--r--src/plugins/scripts/script.h7
20 files changed, 541 insertions, 257 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 580d29061..22ab230bc 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -16,9 +16,9 @@
SET(LIB_CORE_SRC weechat.c weechat.h wee-backtrace.c wee-backtrace.h
wee-command.c wee-command.h wee-config.c wee-config.h wee-config-file.c
-wee-config-file.h wee-hook.c wee-hook.h wee-input.c wee-input.h wee-list.c
-wee-list.h wee-log.c wee-log.h wee-string.c wee-string.h wee-upgrade.c
-wee-upgrade.h wee-utf8.c wee-utf8.h wee-util.c wee-util.h)
+wee-config-file.h wee-debug.c wee-debug.h wee-hook.c wee-hook.h wee-input.c
+wee-input.h wee-list.c wee-list.h wee-log.c wee-log.h wee-string.c wee-string.h
+wee-upgrade.c wee-upgrade.h wee-utf8.c wee-utf8.h wee-util.c wee-util.h)
# Check for flock support
INCLUDE(CheckSymbolExists)
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index dd59ffe9b..aff3c408c 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -28,6 +28,8 @@ lib_weechat_core_a_SOURCES = weechat.c \
wee-config.h \
wee-config-file.c \
wee-config-file.h \
+ wee-debug.c \
+ wee-debug.h \
wee-hook.c \
wee-hook.h \
wee-input.c \
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index cbe85cf82..cad279d1f 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -32,6 +32,7 @@
#include "wee-command.h"
#include "wee-config.h"
#include "wee-config-file.h"
+#include "wee-debug.h"
#include "wee-hook.h"
#include "wee-input.h"
#include "wee-log.h"
@@ -376,97 +377,6 @@ command_builtin (void *data, struct t_gui_buffer *buffer,
}
/*
- * command_debug_display_windows: display tree of windows
- */
-
-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,
- 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,
- tree->window->win_width_pct,
- tree->window->win_height_pct);
- }
- 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,
- format,
- " ", tree, tree->parent_node, tree->window,
- tree->child1, tree->child2);
- }
-
- if (tree->child1)
- command_debug_display_windows (tree->child1, indent + 1);
- if (tree->child2)
- command_debug_display_windows (tree->child2, indent + 1);
- }
-}
-
-/*
- * command_debug: print debug messages
- */
-
-int
-command_debug (void *data, struct t_gui_buffer *buffer,
- int argc, char **argv, char **argv_eol)
-{
- /* make C compiler happy */
- (void) data;
- (void) argv_eol;
-
- if (argc >= 2)
- {
- if (string_strcasecmp (argv[1], "dump") == 0)
- {
- weechat_dump (0);
- }
- else if (string_strcasecmp (argv[1], "buffer") == 0)
- {
- gui_buffer_dump_hexa (buffer);
- gui_chat_printf (NULL,
- "DEBUG: buffer content written in WeeChat "
- "log file");
- }
- else if (string_strcasecmp (argv[1], "windows") == 0)
- {
- gui_chat_printf (NULL, "");
- gui_chat_printf (NULL, "DEBUG: windows tree:");
- command_debug_display_windows (gui_windows_tree, 1);
- }
- else
- {
- hook_signal_send ("debug",
- WEECHAT_HOOK_SIGNAL_STRING, argv_eol[1]);
- }
- }
-
- return WEECHAT_RC_OK;
-}
-
-/*
* command_help: display help about commands
*/
@@ -1995,7 +1905,7 @@ command_init ()
" scroll 20 msgs up: /buffer scroll -20\n"
" jump to #weechat: /buffer #weechat"),
"clear|move|close|list|notify|scroll|set|%b|%c %b|%c",
- command_buffer, NULL);
+ &command_buffer, NULL);
hook_command (NULL, "builtin",
N_("launch WeeChat builtin command (do not look at commands "
"hooked)"),
@@ -2003,32 +1913,20 @@ command_init ()
N_("command: command to execute (a '/' is automatically "
"added if not found at beginning of command)"),
"%w",
- command_builtin, NULL);
- hook_command (NULL, "debug",
- N_("print debug messages"),
- 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\n"
- " text: send \"debug\" signal with \"text\" as "
- "argument"),
- "dump|buffer|windows",
- command_debug, NULL);
+ &command_builtin, NULL);
hook_command (NULL, "help",
N_("display help about commands"),
N_("[command]"),
N_("command: name of a WeeChat or IRC command"),
"%w|%h",
- command_help, NULL);
+ &command_help, NULL);
hook_command (NULL, "history",
N_("show buffer command history"),
N_("[clear | value]"),
N_("clear: clear history\n"
"value: number of history entries to show"),
"-clear",
- command_history, NULL);
+ &command_history, NULL);
hook_command (NULL, "key",
N_("bind/unbind keys"),
N_("[key [function/command]] [unbind key] [functions] "
@@ -2042,7 +1940,7 @@ command_init ()
" reset: restore bindings to the default values and "
"delete ALL personal bindings (use carefully!)"),
"unbind|functions|call|reset %k",
- command_key, NULL);
+ &command_key, NULL);
hook_command (NULL, "plugin",
N_("list/load/unload plugins"),
N_("[list [name]] | [listfull [name]] | [load filename] | "
@@ -2057,12 +1955,12 @@ command_init ()
" unload: unload one or all plugins\n\n"
"Without argument, /plugin command lists loaded plugins."),
"list|listfull|load|autoload|reload|unload %f|%p",
- command_plugin, NULL);
+ &command_plugin, NULL);
hook_command (NULL, "quit",
N_("quit WeeChat"),
"", "",
"%q",
- command_quit, NULL);
+ &command_quit, NULL);
hook_command (NULL, "reload",
N_("reload configuration files from disk"),
N_("[file [file...]]"),
@@ -2070,7 +1968,7 @@ command_init ()
"Without argument, all files (WeeChat and plugins) are "
"reloaded."),
"%C|%*",
- command_reload, NULL);
+ &command_reload, NULL);
hook_command (NULL, "save",
N_("save configuration files to disk"),
N_("[file [file...]]"),
@@ -2078,7 +1976,7 @@ command_init ()
"Without argument, all files (WeeChat and plugins) are "
"saved."),
"%C|%*",
- command_save, NULL);
+ &command_save, NULL);
hook_command (NULL, "set",
N_("set config options"),
N_("[option [ = value]]"),
@@ -2090,7 +1988,7 @@ command_init ()
"\"servername\" is an internal server name and \"xxx\" "
"an option for this server."),
"%o = %v",
- command_set, NULL);
+ &command_set, NULL);
hook_command (NULL, "setp",
N_("set plugin config options"),
N_("[option [ = value]]"),
@@ -2099,7 +1997,7 @@ command_init ()
"Option is format: plugin.option, example: "
"perl.myscript.item1"),
"%O = %V",
- command_setp, NULL);
+ &command_setp, NULL);
hook_command (NULL, "upgrade",
N_("upgrade WeeChat without disconnecting from servers"),
N_("[path_to_binary]"),
@@ -2109,13 +2007,13 @@ command_init ()
"have been compiled or installed with a package manager "
"before running this command."),
"%f",
- command_upgrade, NULL);
+ &command_upgrade, NULL);
hook_command (NULL, "uptime",
N_("show WeeChat uptime"),
N_("[-o]"),
N_("-o: send uptime on current channel as an IRC message"),
"-o",
- command_uptime, NULL);
+ &command_uptime, NULL);
hook_command (NULL, "window",
N_("manage windows"),
N_("[list | -1 | +1 | b# | up | down | left | right | "
@@ -2141,7 +2039,7 @@ command_init ()
"window as size reference. For example 25 means create a "
"new window with size = current_size / 4"),
"list|-1|+1|up|down|left|right|splith|splitv|resize|merge all",
- command_window, NULL);
+ &command_window, NULL);
}
/*
@@ -2165,16 +2063,22 @@ command_print_stdout ()
HOOK_COMMAND(ptr_hook, command));
if (HOOK_COMMAND(ptr_hook, args)
&& HOOK_COMMAND(ptr_hook, args)[0])
+ {
string_iconv_fprintf (stdout, " %s\n\n",
_(HOOK_COMMAND(ptr_hook, args)));
+ }
else
+ {
string_iconv_fprintf (stdout, "\n\n");
+ }
string_iconv_fprintf (stdout, "%s\n\n",
_(HOOK_COMMAND(ptr_hook, description)));
if (HOOK_COMMAND(ptr_hook, args_description)
&& HOOK_COMMAND(ptr_hook, args_description)[0])
+ {
string_iconv_fprintf (stdout, "%s\n\n",
_(HOOK_COMMAND(ptr_hook, args_description)));
+ }
}
}
}
diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c
new file mode 100644
index 000000000..d10039849
--- /dev/null
+++ b/src/core/wee-debug.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* wee-debug.c: some debug functions for WeeChat */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+
+#include "weechat.h"
+#include "wee-config-file.h"
+#include "wee-log.h"
+#include "wee-hook.h"
+#include "../gui/gui-buffer.h"
+#include "../gui/gui-chat.h"
+#include "../gui/gui-hotlist.h"
+#include "../gui/gui-window.h"
+#include "../plugins/plugin.h"
+
+
+int debug_dump_active = 0;
+
+
+/*
+ * debug_dump: write dump to WeeChat log file
+ */
+
+void
+debug_dump (int crash)
+{
+ /* prevent reentrance */
+ if (debug_dump_active)
+ exit (EXIT_FAILURE);
+
+ if (crash)
+ {
+ debug_dump_active = 1;
+ log_printf ("Very bad, WeeChat is crashing (SIGSEGV received)...");
+ }
+
+ log_printf ("");
+ if (crash)
+ {
+ log_printf ("****** WeeChat CRASH DUMP ******");
+ log_printf ("****** Please send this file to WeeChat developers ******");
+ log_printf ("****** and explain when this crash happened ******");
+ }
+ else
+ {
+ log_printf ("****** WeeChat dump request ******");
+ }
+
+ gui_window_print_log ();
+ gui_buffer_print_log ();
+ gui_hotlist_print_log ();
+
+ hook_print_log ();
+
+ config_file_print_log ();
+
+ plugin_print_log ();
+
+ log_printf ("");
+ log_printf ("****** End of WeeChat dump ******");
+ log_printf ("");
+}
+
+/*
+ * debug_dump_cb: callback for "debug_dump" signal hooked
+ */
+
+int
+debug_dump_cb (void *data, char *signal, char *type_data, void *signal_data)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+ (void) type_data;
+ (void) signal_data;
+
+ debug_dump (0);
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * debug_buffer_cb: callback for "debug_buffer" signal hooked
+ */
+
+int
+debug_buffer_cb (void *data, char *signal, char *type_data, void *signal_data)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+ (void) type_data;
+
+ gui_buffer_dump_hexa ((struct t_gui_buffer *)signal_data);
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * debug_windows_tree_display: display tree of windows
+ */
+
+void
+debug_windows_tree_display (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,
+ 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,
+ tree->window->win_width_pct,
+ tree->window->win_height_pct);
+ }
+ 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,
+ format,
+ " ", tree, tree->parent_node, tree->window,
+ tree->child1, tree->child2);
+ }
+
+ if (tree->child1)
+ debug_windows_tree_display (tree->child1, indent + 1);
+ if (tree->child2)
+ debug_windows_tree_display (tree->child2, indent + 1);
+ }
+}
+
+/*
+ * debug_windows_tree_display: display tree of windows
+ */
+
+void
+debug_windows_tree ()
+{
+ gui_chat_printf (NULL, "");
+ gui_chat_printf (NULL, "DEBUG: windows tree:");
+ debug_windows_tree_display (gui_windows_tree, 1);
+}
+
+/*
+ * debug_windows_cb: callback for "debug_windows" signal hooked
+ */
+
+int
+debug_windows_cb (void *data, char *signal, char *type_data, void *signal_data)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+ (void) type_data;
+ (void) signal_data;
+
+ debug_windows_tree ();
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * debug_init: hook signals for debug
+ */
+
+void
+debug_init ()
+{
+ hook_signal (NULL, "debug_dump", debug_dump_cb, NULL);
+ hook_signal (NULL, "debug_buffer", debug_buffer_cb, NULL);
+ hook_signal (NULL, "debug_windows", debug_windows_cb, NULL);
+}
diff --git a/src/core/wee-debug.h b/src/core/wee-debug.h
new file mode 100644
index 000000000..2878ccb1d
--- /dev/null
+++ b/src/core/wee-debug.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_DEBUG_H
+#define __WEECHAT_DEBUG_H 1
+
+struct t_gui_window_tree;
+
+extern void debug_dump (int crash);
+extern void debug_init ();
+
+#endif /* wee-debug.h */
diff --git a/src/core/weechat.c b/src/core/weechat.c
index 4ee1284e2..bf115989b 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -1,18 +1,18 @@
-/* ############################################################################
- * ### ___ __ ______________ _____ ###
- * ### __ | / /___________ ____/__ /_______ __ /_ ###
- * ### __ | /| / /_ _ \ _ \ / __ __ \ __ `/ __/ ###
- * ### __ |/ |/ / / __/ __/ /___ _ / / / /_/ // /_ ###
- * ### ____/|__/ \___/\___/\____/ /_/ /_/\__,_/ \__/ ###
- * ### ###
- * ### WeeChat - Wee Enhanced Environment for Chat ###
- * ### Fast & light environment for Chat ###
- * ### ###
- * ### By FlashCode <flashcode@flashtux.org> ###
- * ### ###
- * ### http://weechat.flashtux.org ###
- * ### ###
- * ############################################################################
+/* ##########################################################################
+ * ## ___ __ ______________ _____ ##
+ * ## __ | / /___________ ____/__ /_______ __ /_ ##
+ * ## __ | /| / /_ _ \ _ \ / __ __ \ __ `/ __/ ##
+ * ## __ |/ |/ / / __/ __/ /___ _ / / / /_/ // /_ ##
+ * ## ____/|__/ \___/\___/\____/ /_/ /_/\__,_/ \__/ ##
+ * ## ##
+ * ## WeeChat - Wee Enhanced Environment for Chat ##
+ * ## Fast, light, extensible chat client ##
+ * ## ##
+ * ## By FlashCode <flashcode@flashtux.org> ##
+ * ## ##
+ * ## http://weechat.flashtux.org ##
+ * ## ##
+ * ##########################################################################
*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
@@ -54,19 +54,16 @@
#include "wee-backtrace.h"
#include "wee-command.h"
#include "wee-config.h"
+#include "wee-debug.h"
#include "wee-hook.h"
#include "wee-log.h"
-#include "wee-upgrade.h"
#include "wee-string.h"
#include "wee-utf8.h"
#include "wee-util.h"
-#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
-#include "../gui/gui-hotlist.h"
#include "../gui/gui-main.h"
#include "../gui/gui-keyboard.h"
-#include "../gui/gui-window.h"
#include "../plugins/plugin.h"
@@ -483,52 +480,6 @@ weechat_shutdown (int return_code, int crash)
}
/*
- * weechat_dump: write dump to WeeChat log file
- */
-
-void
-weechat_dump (int crash)
-{
- /* prevent reentrance */
- if (sigsegv)
- exit (EXIT_FAILURE);
-
- if (crash)
- {
- sigsegv = 1;
- log_printf ("Very bad, WeeChat is crashing (SIGSEGV received)...");
- }
-
- log_printf ("");
- if (crash)
- {
- log_printf ("****** WeeChat CRASH DUMP ******");
- log_printf ("****** Please send this file to WeeChat developers ******");
- log_printf ("****** and explain when this crash happened ******");
- }
- else
- {
- log_printf ("****** WeeChat dump request ******");
- }
-
- gui_window_print_log ();
- gui_buffer_print_log ();
- gui_hotlist_print_log ();
-
- hook_print_log ();
-
- config_file_print_log ();
-
- plugin_print_log ();
-
- hook_signal_send ("dump_data", WEECHAT_HOOK_SIGNAL_STRING, NULL);
-
- log_printf ("");
- log_printf ("****** End of WeeChat dump ******");
- log_printf ("");
-}
-
-/*
* weechat_sigsegv: SIGSEGV handler: save crash log to
* <weechat_home>/weechat.log and exit
*/
@@ -536,7 +487,7 @@ weechat_dump (int crash)
void
weechat_sigsegv ()
{
- weechat_dump (1);
+ debug_dump (1);
unhook_all ();
gui_main_end ();
@@ -588,6 +539,7 @@ main (int argc, char *argv[])
util_catch_signal (SIGSEGV,
&weechat_sigsegv); /* crash dump for SIGSEGV signal */
hook_init (); /* initialize hooks */
+ debug_init (); /* hook signals for debug */
gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */
weechat_init_vars (); /* initialize some variables */
command_init (); /* initialize WeeChat commands */
diff --git a/src/gui/curses/Makefile.am b/src/gui/curses/Makefile.am
index 6388b2982..614295899 100644
--- a/src/gui/curses/Makefile.am
+++ b/src/gui/curses/Makefile.am
@@ -23,6 +23,7 @@ weechat_curses_LDADD = ../../core/weechat.o \
../../core/wee-command.o \
../../core/wee-config.o \
../../core/wee-config-file.o \
+ ../../core/wee-debug.o \
../../core/wee-hook.o \
../../core/wee-input.o \
../../core/wee-list.o \
diff --git a/src/gui/gtk/Makefile.am b/src/gui/gtk/Makefile.am
index 246d60762..6d58071c3 100644
--- a/src/gui/gtk/Makefile.am
+++ b/src/gui/gtk/Makefile.am
@@ -23,6 +23,7 @@ weechat_gtk_LDADD = ../../core/weechat.o \
../../core/wee-command.o \
../../core/wee-config.o \
../../core/wee-config-file.o \
+ ../../core/wee-debug.o \
../../core/wee-hook.o \
../../core/wee-input.o \
../../core/wee-list.o \
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index b8118f19c..dd04d0006 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -25,10 +25,6 @@ INCLUDE(CheckIncludeFiles)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckLibraryExists)
-IF(NOT DISABLE_IRC)
- ADD_SUBDIRECTORY( irc )
-ENDIF(NOT DISABLE_IRC)
-
IF(NOT DISABLE_ALIAS)
ADD_SUBDIRECTORY( alias )
ENDIF(NOT DISABLE_ALIAS)
@@ -52,18 +48,26 @@ IF(ENABLE_DEMO)
ADD_SUBDIRECTORY( demo )
ENDIF(ENABLE_DEMO)
+IF(NOT DISABLE_DEBUG)
+ ADD_SUBDIRECTORY( debug )
+ENDIF(NOT DISABLE_DEBUG)
+
IF(NOT DISABLE_FIFO)
ADD_SUBDIRECTORY( fifo )
ENDIF(NOT DISABLE_FIFO)
+IF(NOT DISABLE_IRC)
+ ADD_SUBDIRECTORY( irc )
+ENDIF(NOT DISABLE_IRC)
+
IF(NOT DISABLE_LOGGER)
ADD_SUBDIRECTORY( logger )
ENDIF(NOT DISABLE_LOGGER)
-IF(NOT DISABLE_TRIGGER)
- ADD_SUBDIRECTORY( trigger )
-ENDIF(NOT DISABLE_TRIGGER)
-
IF(NOT DISABLE_SCRIPTS AND NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
ADD_SUBDIRECTORY( scripts )
ENDIF(NOT DISABLE_SCRIPTS AND NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
+
+IF(NOT DISABLE_TRIGGER)
+ ADD_SUBDIRECTORY( trigger )
+ENDIF(NOT DISABLE_TRIGGER)
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index ff2ca74fc..ce6fdd4b9 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -19,7 +19,7 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
noinst_LIBRARIES = lib_weechat_plugins.a
lib_weechat_plugins_a_SOURCES = weechat-plugin.h \
- plugin.c \
+ plugin.c \
plugin.h \
plugin-api.c \
plugin-api.h \
@@ -28,10 +28,6 @@ lib_weechat_plugins_a_SOURCES = weechat-plugin.h \
plugin-infolist.c \
plugin-infolist.h
-if PLUGIN_IRC
-irc_dir = irc
-endif
-
if PLUGIN_ALIAS
alias_dir = alias
endif
@@ -44,16 +40,24 @@ if PLUGIN_CHARSET
charset_dir = charset
endif
+if PLUGIN_DEBUG
+debug_dir = debug
+endif
+
+if PLUGIN_DEMO
+demo_dir = demo
+endif
+
if PLUGIN_FIFO
fifo_dir = fifo
endif
-if PLUGIN_LOGGER
-logger_dir = logger
+if PLUGIN_IRC
+irc_dir = irc
endif
-if PLUGIN_TRIGGER
-trigger_dir = trigger
+if PLUGIN_LOGGER
+logger_dir = logger
endif
if PLUGIN_PERL
@@ -72,9 +76,10 @@ if PLUGIN_LUA
script_dir = scripts
endif
-if PLUGIN_DEMO
-demo_dir = demo
+if PLUGIN_TRIGGER
+trigger_dir = trigger
endif
-SUBDIRS = . $(irc_dir) $(alias_dir) $(aspell_dir) $(charset_dir) $(fifo_dir) \
- $(logger_dir) $(trigger_dir) $(demo_dir) $(script_dir)
+SUBDIRS = . $(alias_dir) $(aspell_dir) $(charset_dir) $(debug_dir) \
+ $(demo_dir) $(fifo_dir) $(irc_dir) $(logger_dir) $(script_dir) \
+ $(trigger_dir)
diff --git a/src/plugins/debug/CMakeLists.txt b/src/plugins/debug/CMakeLists.txt
new file mode 100644
index 000000000..7fb9a4e2f
--- /dev/null
+++ b/src/plugins/debug/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Copyright (c) 2003-2008 FlashCode <flashcode@flashtux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+ADD_LIBRARY(debug MODULE debug.c)
+SET_TARGET_PROPERTIES(debug PROPERTIES PREFIX "")
+
+TARGET_LINK_LIBRARIES(debug)
+
+INSTALL(TARGETS debug LIBRARY DESTINATION lib/${PROJECT_NAME}/plugins)
diff --git a/src/plugins/debug/Makefile.am b/src/plugins/debug/Makefile.am
new file mode 100644
index 000000000..4728f05d1
--- /dev/null
+++ b/src/plugins/debug/Makefile.am
@@ -0,0 +1,25 @@
+# Copyright (c) 2003-2008 FlashCode <flashcode@flashtux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(DEBUG_CFLAGS)
+
+libdir = ${weechat_libdir}/plugins
+
+lib_LTLIBRARIES = debug.la
+
+debug_la_SOURCES = debug.c
+debug_la_LDFLAGS = -module
+debug_la_LIBADD = $(DEBUG_LFLAGS)
diff --git a/src/plugins/debug/debug.c b/src/plugins/debug/debug.c
new file mode 100644
index 000000000..608a6ae79
--- /dev/null
+++ b/src/plugins/debug/debug.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* debug.c: Debug plugin for WeeChat */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "../weechat-plugin.h"
+
+
+WEECHAT_PLUGIN_NAME("debug");
+WEECHAT_PLUGIN_DESCRIPTION("Debug plugin for WeeChat");
+WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
+WEECHAT_PLUGIN_VERSION("0.1");
+WEECHAT_PLUGIN_LICENSE("GPL");
+
+struct t_weechat_plugin *weechat_debug_plugin = NULL;
+#define weechat_plugin weechat_debug_plugin
+
+
+/*
+ * debug_command_cb: callback for /debug command
+ */
+
+int
+debug_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) buffer;
+
+ if (argc >= 2)
+ {
+ if (weechat_strcasecmp (argv[1], "dump") == 0)
+ {
+ weechat_hook_signal_send ("debug_dump",
+ WEECHAT_HOOK_SIGNAL_STRING, NULL);
+ //debug_dump (0);
+ }
+ else if (weechat_strcasecmp (argv[1], "buffer") == 0)
+ {
+ weechat_hook_signal_send ("debug_buffer",
+ WEECHAT_HOOK_SIGNAL_POINTER, buffer);
+ /*gui_buffer_dump_hexa (buffer);
+ gui_chat_printf (NULL,
+ "DEBUG: buffer content written in WeeChat "
+ "log file");
+ */
+ }
+ else if (weechat_strcasecmp (argv[1], "windows") == 0)
+ {
+ weechat_hook_signal_send ("debug_windows",
+ WEECHAT_HOOK_SIGNAL_STRING, NULL);
+ }
+ else
+ {
+ weechat_hook_signal_send ("debug",
+ WEECHAT_HOOK_SIGNAL_STRING, argv_eol[1]);
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_plugin_init: initialize debug plugin
+ */
+
+int
+weechat_plugin_init (struct t_weechat_plugin *plugin)
+{
+ weechat_plugin = plugin;
+
+ weechat_hook_command ("debug",
+ N_("print debug messages"),
+ 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\n"
+ " text: send \"debug\" signal with \"text\" as "
+ "argument"),
+ "dump|buffer|windows",
+ &debug_command_cb, NULL);
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_plugin_end: end debug plugin
+ */
+
+int
+weechat_plugin_end (struct t_weechat_plugin *plugin)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ return WEECHAT_RC_OK;
+}
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index 5d7323a3d..5181fff73 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -60,12 +60,38 @@ gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */
/*
- * irc_signal_dump_data_cb: dump IRC data in WeeChat log file
+ * irc_signal_debug_cb: callback for "debug" signal
*/
int
-irc_signal_dump_data_cb (void *data, char *signal, char *type_data,
- void *signal_data)
+irc_signal_debug_cb (void *data, char *signal, char *type_data,
+ void *signal_data)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+
+ if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
+ {
+ if (weechat_strcasecmp ((char *)signal_data, "irc") == 0)
+ irc_debug ^= 1;
+ }
+
+ if (irc_debug)
+ weechat_printf (NULL, _("%s: debug enabled"), "irc");
+ else
+ weechat_printf (NULL, _("%s: debug disabled"), "irc");
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * irc_signal_debug_dump_cb: dump IRC data in WeeChat log file
+ */
+
+int
+irc_signal_debug_dump_cb (void *data, char *signal, char *type_data,
+ void *signal_data)
{
/* make C compiler happy */
(void) data;
@@ -140,27 +166,6 @@ irc_signal_quit_cb (void *data, char *signal, char *type_data,
}
/*
- * irc_signal_debug_cb: callback for "debug" signal
- */
-
-int
-irc_signal_debug_cb (void *data, char *signal, char *type_data,
- void *signal_data)
-{
- /* make C compiler happy */
- (void) data;
- (void) signal;
-
- if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
- {
- if (weechat_strcasecmp ((char *)signal_data, "irc") == 0)
- irc_debug ^= 1;
- }
-
- return WEECHAT_RC_OK;
-}
-
-/*
* weechat_plugin_init: initialize IRC plugin
*/
@@ -187,9 +192,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
irc_command_init ();
/* hook some signals */
- weechat_hook_signal ("dump_data", &irc_signal_dump_data_cb, NULL);
- weechat_hook_signal ("quit", &irc_signal_quit_cb, NULL);
weechat_hook_signal ("debug", &irc_signal_debug_cb, NULL);
+ weechat_hook_signal ("debug_dump", &irc_signal_debug_dump_cb, NULL);
+ weechat_hook_signal ("quit", &irc_signal_quit_cb, NULL);
/* hook completions */
irc_completion_init ();
diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c
index 8df2f8415..751e3ff9b 100644
--- a/src/plugins/scripts/lua/weechat-lua.c
+++ b/src/plugins/scripts/lua/weechat-lua.c
@@ -417,12 +417,12 @@ weechat_lua_completion_cb (void *data, char *completion,
}
/*
- * weechat_lua_dump_data_cb: dump Lua plugin data in WeeChat log file
+ * weechat_lua_debug_dump_cb: dump Lua plugin data in WeeChat log file
*/
int
-weechat_lua_dump_data_cb (void *data, char *signal, char *type_data,
- void *signal_data)
+weechat_lua_debug_dump_cb (void *data, char *signal, char *type_data,
+ void *signal_data)
{
/* make C compiler happy */
(void) data;
@@ -448,7 +448,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
script_init (weechat_lua_plugin,
&weechat_lua_command_cb,
&weechat_lua_completion_cb,
- &weechat_lua_dump_data_cb,
+ &weechat_lua_debug_dump_cb,
&weechat_lua_load_cb);
/* init ok */
diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c
index 776e8d265..48874363a 100644
--- a/src/plugins/scripts/perl/weechat-perl.c
+++ b/src/plugins/scripts/perl/weechat-perl.c
@@ -554,12 +554,12 @@ weechat_perl_completion_cb (void *data, char *completion,
}
/*
- * weechat_perl_dump_data_cb: dump Perl plugin data in WeeChat log file
+ * weechat_perl_debug_dump_cb: dump Perl plugin data in WeeChat log file
*/
int
-weechat_perl_dump_data_cb (void *data, char *signal, char *type_data,
- void *signal_data)
+weechat_perl_debug_dump_cb (void *data, char *signal, char *type_data,
+ void *signal_data)
{
/* make C compiler happy */
(void) data;
@@ -602,7 +602,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
script_init (weechat_perl_plugin,
&weechat_perl_command_cb,
&weechat_perl_completion_cb,
- &weechat_perl_dump_data_cb,
+ &weechat_perl_debug_dump_cb,
&weechat_perl_load_cb);
/* init ok */
diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c
index 51236028f..b117cb9e2 100644
--- a/src/plugins/scripts/python/weechat-python.c
+++ b/src/plugins/scripts/python/weechat-python.c
@@ -581,12 +581,12 @@ weechat_python_completion_cb (void *data, char *completion,
}
/*
- * weechat_python_dump_data_cb: dump Python plugin data in WeeChat log file
+ * weechat_python_debug_dump_cb: dump Python plugin data in WeeChat log file
*/
int
-weechat_python_dump_data_cb (void *data, char *signal, char *type_data,
- void *signal_data)
+weechat_python_debug_dump_cb (void *data, char *signal, char *type_data,
+ void *signal_data)
{
/* make C compiler happy */
(void) data;
@@ -638,7 +638,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
script_init (weechat_python_plugin,
&weechat_python_command_cb,
&weechat_python_completion_cb,
- &weechat_python_dump_data_cb,
+ &weechat_python_debug_dump_cb,
&weechat_python_load_cb);
/* init ok */
diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c
index 9ec073931..de69dd58d 100644
--- a/src/plugins/scripts/ruby/weechat-ruby.c
+++ b/src/plugins/scripts/ruby/weechat-ruby.c
@@ -582,12 +582,12 @@ weechat_ruby_completion_cb (void *data, char *completion,
}
/*
- * weechat_ruby_dump_data_cb: dump Ruby plugin data in WeeChat log file
+ * weechat_ruby_debug_dump_cb: dump Ruby plugin data in WeeChat log file
*/
int
-weechat_ruby_dump_data_cb (void *data, char *signal, char *type_data,
- void *signal_data)
+weechat_ruby_debug_dump_cb (void *data, char *signal, char *type_data,
+ void *signal_data)
{
/* make C compiler happy */
(void) data;
@@ -690,7 +690,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
script_init (weechat_ruby_plugin,
&weechat_ruby_command_cb,
&weechat_ruby_completion_cb,
- &weechat_ruby_dump_data_cb,
+ &weechat_ruby_debug_dump_cb,
&weechat_ruby_load_cb);
/* init ok */
diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c
index b1f918f36..242132e7a 100644
--- a/src/plugins/scripts/script.c
+++ b/src/plugins/scripts/script.c
@@ -88,9 +88,9 @@ script_init (struct t_weechat_plugin *weechat_plugin,
int (*callback_completion)(void *data, char *completion,
struct t_gui_buffer *buffer,
struct t_weelist *list),
- int (*callback_signal_dump)(void *data, char *signal,
- char *type_data,
- void *signal_data),
+ int (*callback_signal_debug_dump)(void *data, char *signal,
+ char *type_data,
+ void *signal_data),
int (*callback_load_file)(void *data, char *filename))
{
char *string, *completion = "list|listfull|load|autoload|reload|unload %f";
@@ -154,8 +154,8 @@ script_init (struct t_weechat_plugin *weechat_plugin,
free (string);
}
- /* add signal for "dump_data" */
- weechat_hook_signal ("dump_data", callback_signal_dump, NULL);
+ /* add signal for "debug_dump" */
+ weechat_hook_signal ("debug_dump", callback_signal_debug_dump, NULL);
/* autoload scripts */
script_auto_load (weechat_plugin, callback_load_file);
diff --git a/src/plugins/scripts/script.h b/src/plugins/scripts/script.h
index badc16c6f..7f4ac248f 100644
--- a/src/plugins/scripts/script.h
+++ b/src/plugins/scripts/script.h
@@ -64,9 +64,10 @@ extern void script_init (struct t_weechat_plugin *weechat_plugin,
int (*callback_completion)(void *data, char *completion,
struct t_gui_buffer *buffer,
struct t_weelist *list),
- int (*callback_signal_dump)(void *data, char *signal,
- char *type_data,
- void *signal_data),
+ int (*callback_signal_debug_dump)(void *data,
+ char *signal,
+ char *type_data,
+ void *signal_data),
int (*callback_load_file)(void *data, char *filename));
extern char *script_ptr2str (void *pointer);
extern void *script_str2ptr (char *pointer_str);