mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 13:26:38 +02:00
Added new plugin "debug"
This commit is contained in:
@@ -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)
|
||||
|
||||
+18
-13
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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;
|
||||
}
|
||||
+31
-26
@@ -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;
|
||||
@@ -139,27 +165,6 @@ irc_signal_quit_cb (void *data, char *signal, char *type_data,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 ();
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user