1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +02:00

Added new plugin "debug"

This commit is contained in:
Sebastien Helleu
2008-02-21 17:31:59 +01:00
parent 155e689a26
commit dec0e7dc12
31 changed files with 885 additions and 498 deletions
+22
View File
@@ -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)
+25
View File
@@ -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)
+123
View File
@@ -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;
}