1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 07:16:37 +02:00

Partial migration of Perl plugin to new API

This commit is contained in:
Sebastien Helleu
2008-01-09 18:26:17 +01:00
parent f94b679a4a
commit 9f2fc59569
51 changed files with 4548 additions and 3178 deletions
+3 -1
View File
@@ -542,11 +542,13 @@ alias_config_read ()
*/
int
alias_config_reload_signal_cb (void *data, char *signal, void *signal_data)
alias_config_reload_signal_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;
alias_free_all ();
+31 -5
View File
@@ -134,7 +134,8 @@ demo_buffer_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
demo_buffer_input_data_cb);
if (new_buffer)
weechat_buffer_set (new_buffer, "display", "1");
weechat_hook_signal_send ("logger_backlog", new_buffer);
weechat_hook_signal_send ("logger_backlog",
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
}
return WEECHAT_RC_OK;
@@ -281,14 +282,39 @@ demo_info_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
*/
int
demo_signal_cb (void *data, char *signal, void *signal_data)
demo_signal_cb (void *data, char *signal, char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) data;
weechat_printf (NULL,
_("demo_signal: signal: %s, signal_data: %X"),
signal, signal_data);
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
weechat_printf (NULL,
_("demo_signal: signal: %s, type_data: %s, "
"signal_data: '%s'"),
signal, type_data, (char *)signal_data);
}
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
{
weechat_printf (NULL,
_("demo_signal: signal: %s, type_data: %s, "
"signal_data: %d"),
signal, type_data, *((int *)signal_data));
}
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
{
weechat_printf (NULL,
_("demo_signal: signal: %s, type_data: %s, "
"signal_data: 0x%x"),
signal, type_data, signal_data);
}
else
{
weechat_printf (NULL,
_("demo_signal: signal: %s, type_data: %s, "
"signal_data: 0x%x (unknown type)"),
signal, type_data, signal_data);
}
return WEECHAT_RC_OK;
}
+9 -8
View File
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <string.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-channel.h"
#include "irc-config.h"
@@ -495,9 +496,9 @@ irc_channel_print_log (struct t_irc_channel *channel)
struct t_irc_nick *ptr_nick;
weechat_log_printf ("");
weechat_log_printf (" => channel %s (addr:0x%X)]", channel->name, channel);
weechat_log_printf (" => channel %s (addr:0x%x)]", channel->name, channel);
weechat_log_printf (" type . . . . . . . . : %d", channel->type);
weechat_log_printf (" dcc_chat . . . . . . : 0x%X", channel->dcc_chat);
weechat_log_printf (" dcc_chat . . . . . . : 0x%x", channel->dcc_chat);
weechat_log_printf (" topic. . . . . . . . : '%s'", channel->topic);
weechat_log_printf (" modes. . . . . . . . : '%s'", channel->modes);
weechat_log_printf (" limit. . . . . . . . : %d", channel->limit);
@@ -507,12 +508,12 @@ irc_channel_print_log (struct t_irc_channel *channel)
weechat_log_printf (" cycle. . . . . . . . : %d", channel->cycle);
weechat_log_printf (" close. . . . . . . . : %d", channel->close);
weechat_log_printf (" display_creation_date: %d", channel->display_creation_date);
weechat_log_printf (" nicks. . . . . . . . : 0x%X", channel->nicks);
weechat_log_printf (" last_nick. . . . . . : 0x%X", channel->last_nick);
weechat_log_printf (" buffer . . . . . . . : 0x%X", channel->buffer);
weechat_log_printf (" nicks_speaking . . . : 0x%X", channel->nicks_speaking);
weechat_log_printf (" prev_channel . . . . : 0x%X", channel->prev_channel);
weechat_log_printf (" next_channel . . . . : 0x%X", channel->next_channel);
weechat_log_printf (" nicks. . . . . . . . : 0x%x", channel->nicks);
weechat_log_printf (" last_nick. . . . . . : 0x%x", channel->last_nick);
weechat_log_printf (" buffer . . . . . . . : 0x%x", channel->buffer);
weechat_log_printf (" nicks_speaking . . . : 0x%x", channel->nicks_speaking);
weechat_log_printf (" prev_channel . . . . : 0x%x", channel->prev_channel);
weechat_log_printf (" next_channel . . . . : 0x%x", channel->next_channel);
if (channel->nicks_speaking)
{
weechat_log_printf ("");
+1
View File
@@ -27,6 +27,7 @@
#include <string.h>
#include <ctype.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-color.h"
+1
View File
@@ -30,6 +30,7 @@
#include <sys/time.h>
#include <time.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-command.h"
#include "irc-color.h"
+1
View File
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-completion.h"
#include "irc-config.h"
+1
View File
@@ -29,6 +29,7 @@
#include <limits.h>
#include <pwd.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-config.h"
#include "irc-dcc.h"
+6 -5
View File
@@ -39,6 +39,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-dcc.h"
#include "irc-config.h"
@@ -1899,9 +1900,9 @@ irc_dcc_print_log ()
for (ptr_dcc = irc_dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
{
weechat_log_printf ("");
weechat_log_printf ("[DCC (addr:0x%X)]", ptr_dcc);
weechat_log_printf (" server. . . . . . . : 0x%X", ptr_dcc->server);
weechat_log_printf (" channel . . . . . . : 0x%X", ptr_dcc->channel);
weechat_log_printf ("[DCC (addr:0x%x)]", ptr_dcc);
weechat_log_printf (" server. . . . . . . : 0x%x", ptr_dcc->server);
weechat_log_printf (" channel . . . . . . : 0x%x", ptr_dcc->channel);
weechat_log_printf (" type. . . . . . . . : %d", ptr_dcc->type);
weechat_log_printf (" status. . . . . . . : %d", ptr_dcc->status);
weechat_log_printf (" start_time. . . . . : %ld", ptr_dcc->start_time);
@@ -1929,7 +1930,7 @@ irc_dcc_print_log ()
weechat_log_printf (" last_activity . . . : %ld", ptr_dcc->last_activity);
weechat_log_printf (" bytes_per_sec . . . : %lu", ptr_dcc->bytes_per_sec);
weechat_log_printf (" eta . . . . . . . . : %lu", ptr_dcc->eta);
weechat_log_printf (" prev_dcc. . . . . . : 0x%X", ptr_dcc->prev_dcc);
weechat_log_printf (" next_dcc. . . . . . : 0x%X", ptr_dcc->next_dcc);
weechat_log_printf (" prev_dcc. . . . . . : 0x%x", ptr_dcc->prev_dcc);
weechat_log_printf (" next_dcc. . . . . . : 0x%x", ptr_dcc->next_dcc);
}
}
+1
View File
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <string.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-channel.h"
#include "irc-command.h"
+1
View File
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-server.h"
#include "irc-channel.h"
+1
View File
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-mode.h"
#include "irc-server.h"
+4 -3
View File
@@ -28,6 +28,7 @@
#include <string.h>
#include <limits.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-nick.h"
#include "irc-config.h"
@@ -470,10 +471,10 @@ void
irc_nick_print_log (struct t_irc_nick *nick)
{
weechat_log_printf ("");
weechat_log_printf (" => nick %s (addr:0x%X):", nick->name, nick);
weechat_log_printf (" => nick %s (addr:0x%x):", nick->name, nick);
weechat_log_printf (" host . . . . . : %s", nick->host);
weechat_log_printf (" flags. . . . . : %d", nick->flags);
weechat_log_printf (" color. . . . . : '%s'", nick->color);
weechat_log_printf (" prev_nick. . . : 0x%X", nick->prev_nick);
weechat_log_printf (" next_nick. . . : 0x%X", nick->next_nick);
weechat_log_printf (" prev_nick. . . : 0x%x", nick->prev_nick);
weechat_log_printf (" next_nick. . . : 0x%x", nick->next_nick);
}
+1
View File
@@ -43,6 +43,7 @@
#include <sys/time.h>
#include <time.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-protocol.h"
#include "irc-command.h"
+12 -10
View File
@@ -44,6 +44,7 @@
#include <gnutls/gnutls.h>
#endif
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-server.h"
#include "irc-channel.h"
@@ -2187,7 +2188,8 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
if (!server->buffer)
return 0;
weechat_buffer_set (server->buffer, "display", "1");
weechat_hook_signal_send ("logger_backlog", server->buffer);
weechat_hook_signal_send ("logger_backlog",
WEECHAT_HOOK_SIGNAL_POINTER, server->buffer);
}
#ifndef HAVE_GNUTLS
@@ -2733,7 +2735,7 @@ irc_server_print_log ()
ptr_server = ptr_server->next_server)
{
weechat_log_printf ("");
weechat_log_printf ("[server %s (addr:0x%X)]", ptr_server->name, ptr_server);
weechat_log_printf ("[server %s (addr:0x%x)]", ptr_server->name, ptr_server);
weechat_log_printf (" autoconnect . . . . : %d", ptr_server->autoconnect);
weechat_log_printf (" autoreconnect . . . : %d", ptr_server->autoreconnect);
weechat_log_printf (" autoreconnect_delay : %d", ptr_server->autoreconnect_delay);
@@ -2762,7 +2764,7 @@ irc_server_print_log ()
weechat_log_printf (" child_read . . . . : %d", ptr_server->child_read);
weechat_log_printf (" child_write . . . . : %d", ptr_server->child_write);
weechat_log_printf (" sock. . . . . . . . : %d", ptr_server->sock);
weechat_log_printf (" hook_fd . . . . . . : 0x%X", ptr_server->hook_fd);
weechat_log_printf (" hook_fd . . . . . . : 0x%x", ptr_server->hook_fd);
weechat_log_printf (" is_connected. . . . : %d", ptr_server->is_connected);
weechat_log_printf (" ssl_connected . . . : %d", ptr_server->ssl_connected);
weechat_log_printf (" unterminated_message: '%s'", ptr_server->unterminated_message);
@@ -2782,13 +2784,13 @@ irc_server_print_log ()
ptr_server->lag_check_time.tv_usec);
weechat_log_printf (" lag_next_check. . . : %ld", ptr_server->lag_next_check);
weechat_log_printf (" last_user_message . : %ld", ptr_server->last_user_message);
weechat_log_printf (" outqueue. . . . . . : 0x%X", ptr_server->outqueue);
weechat_log_printf (" last_outqueue . . . : 0x%X", ptr_server->last_outqueue);
weechat_log_printf (" buffer. . . . . . . : 0x%X", ptr_server->buffer);
weechat_log_printf (" channels. . . . . . : 0x%X", ptr_server->channels);
weechat_log_printf (" last_channel. . . . : 0x%X", ptr_server->last_channel);
weechat_log_printf (" prev_server . . . . : 0x%X", ptr_server->prev_server);
weechat_log_printf (" next_server . . . . : 0x%X", ptr_server->next_server);
weechat_log_printf (" outqueue. . . . . . : 0x%x", ptr_server->outqueue);
weechat_log_printf (" last_outqueue . . . : 0x%x", ptr_server->last_outqueue);
weechat_log_printf (" buffer. . . . . . . : 0x%x", ptr_server->buffer);
weechat_log_printf (" channels. . . . . . : 0x%x", ptr_server->channels);
weechat_log_printf (" last_channel. . . . : 0x%x", ptr_server->last_channel);
weechat_log_printf (" prev_server . . . . : 0x%x", ptr_server->prev_server);
weechat_log_printf (" next_server . . . . : 0x%x", ptr_server->next_server);
for (ptr_channel = ptr_server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
+19 -11
View File
@@ -24,11 +24,13 @@
#endif
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#endif
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-command.h"
#include "irc-completion.h"
@@ -62,12 +64,13 @@ gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */
*/
int
irc_dump_data_cb (void *data, char *signal, void *pointer)
irc_dump_data_cb (void *data, char *signal, char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
(void) pointer;
(void) type_data;
(void) signal_data;
weechat_log_printf ("");
weechat_log_printf ("***** IRC plugin dump *****");
@@ -112,19 +115,21 @@ irc_create_directories ()
*/
int
irc_quit_cb (void *data, char *signal, void *pointer)
irc_quit_cb (void *data, char *signal, char *type_data, void *signal_data)
{
struct t_irc_server *ptr_server;
/* make C compiler happy */
(void) data;
(void) signal;
(void) pointer;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
irc_command_quit_server (ptr_server, (char *)pointer);
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
irc_command_quit_server (ptr_server, (char *)signal_data);
}
}
return WEECHAT_RC_OK;
@@ -135,14 +140,17 @@ irc_quit_cb (void *data, char *signal, void *pointer)
*/
int
irc_debug_cb (void *data, char *signal, void *pointer)
irc_debug_cb (void *data, char *signal, char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
if (weechat_strcasecmp ((char *)pointer, "irc") == 0)
irc_debug ^= 1;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
if (weechat_strcasecmp ((char *)signal_data, "irc") == 0)
irc_debug ^= 1;
}
return WEECHAT_RC_OK;
}
-2
View File
@@ -24,8 +24,6 @@
#include <gnutls/gnutls.h>
#endif
#include "../weechat-plugin.h"
#define weechat_plugin weechat_irc_plugin
#define IRC_GET_SERVER(__buffer) \
+21 -13
View File
@@ -409,14 +409,15 @@ logger_stop_all ()
*/
int
logger_buffer_open_signal_cb (void *data, char *signal, void *pointer)
logger_buffer_open_signal_cb (void *data, char *signal, char *type_data,
void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
(void) pointer;
(void) type_data;
logger_start_buffer (pointer);
logger_start_buffer (signal_data);
return WEECHAT_RC_OK;
}
@@ -426,14 +427,15 @@ logger_buffer_open_signal_cb (void *data, char *signal, void *pointer)
*/
int
logger_buffer_close_signal_cb (void *data, char *signal, void *pointer)
logger_buffer_close_signal_cb (void *data, char *signal, char *type_data,
void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
(void) pointer;
(void) type_data;
logger_stop (logger_buffer_search (pointer), 1);
logger_stop (logger_buffer_search (signal_data), 1);
return WEECHAT_RC_OK;
}
@@ -494,23 +496,25 @@ logger_backlog (struct t_gui_buffer *buffer, char *filename, int lines)
*/
int
logger_backlog_signal_cb (void *data, char *signal, void *pointer)
logger_backlog_signal_cb (void *data, char *signal, char *type_data,
void *signal_data)
{
struct t_logger_buffer *ptr_logger_buffer;
/* make C compiler happy */
(void) data;
(void) signal;
(void) type_data;
if (logger_option_backlog >= 0)
{
ptr_logger_buffer = logger_buffer_search (pointer);
ptr_logger_buffer = logger_buffer_search (signal_data);
if (ptr_logger_buffer && ptr_logger_buffer->log_filename
&& ptr_logger_buffer->log_enabled)
{
ptr_logger_buffer->log_enabled = 0;
logger_backlog (pointer,
logger_backlog (signal_data,
ptr_logger_buffer->log_filename,
logger_option_backlog);
@@ -526,13 +530,15 @@ logger_backlog_signal_cb (void *data, char *signal, void *pointer)
*/
int
logger_start_signal_cb (void *data, char *signal, void *pointer)
logger_start_signal_cb (void *data, char *signal, char *type_data,
void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
(void) type_data;
logger_start_buffer (pointer);
logger_start_buffer (signal_data);
return WEECHAT_RC_OK;
}
@@ -542,15 +548,17 @@ logger_start_signal_cb (void *data, char *signal, void *pointer)
*/
int
logger_stop_signal_cb (void *data, char *signal, void *pointer)
logger_stop_signal_cb (void *data, char *signal, 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 (pointer);
ptr_logger_buffer = logger_buffer_search (signal_data);
if (ptr_logger_buffer)
logger_stop (ptr_logger_buffer, 0);
+15 -15
View File
@@ -561,28 +561,28 @@ plugin_infolist_print_log ()
ptr_infolist = ptr_infolist->next_infolist)
{
log_printf ("");
log_printf ("[plugin infolist (addr:0x%X)]", ptr_infolist);
log_printf (" items. . . . . . . . . : 0x%X", ptr_infolist->items);
log_printf (" last_item. . . . . . . : 0x%X", ptr_infolist->last_item);
log_printf (" ptr_item . . . . . . . : 0x%X", ptr_infolist->ptr_item);
log_printf (" prev_infolist. . . . . : 0x%X", ptr_infolist->prev_infolist);
log_printf (" next_infolist. . . . . : 0x%X", ptr_infolist->next_infolist);
log_printf ("[plugin infolist (addr:0x%x)]", ptr_infolist);
log_printf (" items. . . . . . . . . : 0x%x", ptr_infolist->items);
log_printf (" last_item. . . . . . . : 0x%x", ptr_infolist->last_item);
log_printf (" ptr_item . . . . . . . : 0x%x", ptr_infolist->ptr_item);
log_printf (" prev_infolist. . . . . : 0x%x", ptr_infolist->prev_infolist);
log_printf (" next_infolist. . . . . : 0x%x", ptr_infolist->next_infolist);
for (ptr_item = ptr_infolist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
log_printf ("");
log_printf (" [item (addr:0x%X)]", ptr_item);
log_printf (" vars . . . . . . . . . : 0x%X", ptr_item->vars);
log_printf (" last_var . . . . . . . : 0x%X", ptr_item->last_var);
log_printf (" prev_item. . . . . . . : 0x%X", ptr_item->prev_item);
log_printf (" next_item. . . . . . . : 0x%X", ptr_item->next_item);
log_printf (" [item (addr:0x%x)]", ptr_item);
log_printf (" vars . . . . . . . . . : 0x%x", ptr_item->vars);
log_printf (" last_var . . . . . . . : 0x%x", ptr_item->last_var);
log_printf (" prev_item. . . . . . . : 0x%x", ptr_item->prev_item);
log_printf (" next_item. . . . . . . : 0x%x", ptr_item->next_item);
for (ptr_var = ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
log_printf ("");
log_printf (" [var (addr:0x%X)]", ptr_var);
log_printf (" [var (addr:0x%x)]", ptr_var);
log_printf (" name . . . . . . . . : '%s'", ptr_var->name);
log_printf (" type . . . . . . . . : %d", ptr_var->type);
switch (ptr_var->type)
@@ -594,14 +594,14 @@ plugin_infolist_print_log ()
log_printf (" value (string) . . . : '%s'", (char *)ptr_var->value);
break;
case PLUGIN_INFOLIST_POINTER:
log_printf (" value (pointer). . . : 0x%X", ptr_var->value);
log_printf (" value (pointer). . . : 0x%x", ptr_var->value);
break;
case PLUGIN_INFOLIST_TIME:
log_printf (" value (time) . . . . : %ld", *((time_t *)ptr_var->value));
break;
}
log_printf (" prev_var . . . . . . : 0x%X", ptr_var->prev_var);
log_printf (" next_var . . . . . . : 0x%X", ptr_var->next_var);
log_printf (" prev_var . . . . . . : 0x%x", ptr_var->prev_var);
log_printf (" next_var . . . . . . : 0x%x", ptr_var->next_var);
}
}
}
+5 -5
View File
@@ -302,9 +302,9 @@ plugin_load (char *filename)
new_plugin->prefix = &plugin_api_prefix;
new_plugin->color = &plugin_api_color;
new_plugin->printf_date = &gui_chat_printf_date;
new_plugin->log_printf = &log_printf;
new_plugin->infobar_printf = &plugin_api_infobar_printf;
new_plugin->infobar_remove = &plugin_api_infobar_remove;
new_plugin->log_printf = &log_printf;
new_plugin->hook_command = &hook_command;
new_plugin->hook_timer = &hook_timer;
@@ -676,15 +676,15 @@ plugin_print_log ()
ptr_plugin = ptr_plugin->next_plugin)
{
log_printf ("");
log_printf ("[plugin (addr:0x%X)]", ptr_plugin);
log_printf ("[plugin (addr:0x%x)]", ptr_plugin);
log_printf (" filename . . . . . . . : '%s'", ptr_plugin->filename);
log_printf (" handle . . . . . . . . : 0x%X", ptr_plugin->handle);
log_printf (" handle . . . . . . . . : 0x%x", ptr_plugin->handle);
log_printf (" name . . . . . . . . . : '%s'", ptr_plugin->name);
log_printf (" description. . . . . . : '%s'", ptr_plugin->description);
log_printf (" version. . . . . . . . : '%s'", ptr_plugin->version);
log_printf (" charset. . . . . . . . : '%s'", ptr_plugin->charset);
log_printf (" prev_plugin. . . . . . : 0x%X", ptr_plugin->prev_plugin);
log_printf (" next_plugin. . . . . . : 0x%X", ptr_plugin->next_plugin);
log_printf (" prev_plugin. . . . . . : 0x%x", ptr_plugin->prev_plugin);
log_printf (" next_plugin. . . . . . : 0x%x", ptr_plugin->next_plugin);
}
plugin_infolist_print_log ();
+3 -1
View File
@@ -20,6 +20,8 @@ libdir = ${weechat_libdir}/plugins
lib_LTLIBRARIES = perl.la
perl_la_SOURCES = perl.c
perl_la_SOURCES = weechat-perl.c \
weechat-perl.h \
weechat-perl-api.c
perl_la_LDFLAGS = -module
perl_la_LIBADD = ../lib_weechat_plugins_scripts.la $(PERL_LFLAGS)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,29 @@
/*
* 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_PERL_API_H
#define __WEECHAT_PERL_API_H 1
#define weechat_plugin weechat_perl_plugin
extern struct t_weechat_plugin *weechat_perl_plugin;
extern void weechat_perl_xs_init (pTHX);
#endif /* weechat-perl.h */
+734
View File
@@ -0,0 +1,734 @@
/*
* 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/>.
*/
/* weechat-perl.c: Perl plugin for WeeChat */
#undef _
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
#include "../../weechat-plugin.h"
#include "../script.h"
#include "weechat-perl.h"
#include "weechat-perl-api.h"
WEECHAT_PLUGIN_NAME("perl");
WEECHAT_PLUGIN_DESCRIPTION("Perl plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_perl_plugin = NULL;
struct t_plugin_script *perl_scripts = NULL;
struct t_plugin_script *perl_current_script = NULL;
char *perl_current_script_filename = NULL;
#ifdef NO_PERL_MULTIPLICITY
#undef MULTIPLICITY
#endif
#ifndef MULTIPLICITY
#define PKG_NAME_PREFIX "WeechatPerlPackage"
static PerlInterpreter *perl_main = NULL;
int perl_num = 0;
#endif
char *perl_weechat_code =
{
#ifndef MULTIPLICITY
"package WeechatPerlScriptLoader;"
#endif
"$weechat_perl_load_eval_file_error = \"\";"
"sub weechat_perl_load_file"
"{"
" my $filename = shift;"
" local $/ = undef;"
" open FILE, $filename or return \"__WEECHAT_PERL_ERROR__\";"
" $_ = <FILE>;"
" close FILE;"
" return $_;"
"}"
"sub weechat_perl_load_eval_file"
"{"
#ifndef MULTIPLICITY
" my ($filename, $package) = @_;"
#else
" my $filename = shift;"
#endif
" my $content = weechat_perl_load_file ($filename);"
" if ($content eq \"__WEECHAT_PERL_ERROR__\")"
" {"
" return 1;"
" }"
#ifndef MULTIPLICITY
" my $eval = qq{package $package; $content;};"
#else
" my $eval = $content;"
#endif
" {"
" eval $eval;"
" }"
" if ($@)"
" {"
" $weechat_perl_load_eval_file_error = $@;"
" return 2;"
" }"
" return 0;"
"}"
"$SIG{__WARN__} = sub { weechat::print \"Perl error: $_[0]\", \"\"; };"
"$SIG{__DIE__} = sub { weechat::print \"Perl error: $_[0]\", \"\"; };"
};
/*
* weechat_perl_exec: execute a Perl script
*/
void *
weechat_perl_exec (struct t_plugin_script *script,
int ret_type, char *function, char **argv)
{
char *func;
unsigned int count;
void *ret_value;
int *ret_i, mem_err;
SV *ret_s;
/* this code is placed here to conform ISO C90 */
dSP;
#ifndef MULTIPLICITY
int size = strlen (script->interpreter) + strlen(function) + 3;
func = (char *)malloc (size * sizeof(char));
if (!func)
return NULL;
snprintf (func, size, "%s::%s", (char *) script->interpreter, function);
#else
func = function;
PERL_SET_CONTEXT (script->interpreter);
#endif
ENTER;
SAVETMPS;
PUSHMARK(sp);
/* are we loading the script file ? */
if (strcmp (function, "weechat_perl_load_eval_file") != 0)
perl_current_script = script;
count = perl_call_argv (func, G_EVAL | G_SCALAR, argv);
ret_value = NULL;
mem_err = 1;
SPAGAIN;
if (SvTRUE (ERRSV))
{
weechat_printf (NULL,
weechat_gettext ("%s%s: error: %s"),
weechat_prefix ("error"), "perl", SvPV_nolen (ERRSV));
(void) POPs; /* poping the 'undef' */
mem_err = 0;
}
else
{
if (count != 1)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: function \"%s\" must "
"return one valid value (%d)"),
weechat_prefix ("error"), "perl", function, count);
mem_err = 0;
}
else
{
if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
{
ret_s = newSVsv(POPs);
ret_value = strdup (SvPV_nolen (ret_s));
SvREFCNT_dec (ret_s);
}
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
{
ret_i = (int *)malloc (sizeof(int));
if (ret_i)
*ret_i = POPi;
ret_value = ret_i;
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: function \"%s\" is "
"internally misused"),
weechat_prefix ("error"), "perl", function);
mem_err = 0;
}
}
}
PUTBACK;
FREETMPS;
LEAVE;
#ifndef MULTIPLICITY
free (func);
#endif
if (!ret_value && (mem_err == 1))
{
weechat_printf (NULL,
weechat_gettext ("%s%s: not enough memory in function "
"\"%s\""),
weechat_prefix ("error"), "perl", function);
return NULL;
}
return ret_value;
}
/*
* weechat_perl_load: load a Perl script
*/
int
weechat_perl_load (char *filename)
{
STRLEN len;
struct t_plugin_script tempscript;
int *eval;
struct stat buf;
char *perl_argv[2];
#ifndef MULTIPLICITY
char pkgname[64];
#else
PerlInterpreter *perl_current_interpreter;
char *perl_args[] = { "", "-e", "0" };
#endif
weechat_printf (NULL,
weechat_gettext ("%s%s: loading Perl script \"%s\""),
weechat_prefix ("info"), "perl", filename);
if (stat (filename, &buf) != 0)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: script \"%s\" not found"),
weechat_prefix ("error"), "perl", filename);
return 0;
}
perl_current_script = NULL;
#ifndef MULTIPLICITY
snprintf(pkgname, sizeof(pkgname), "%s%d", PKG_NAME_PREFIX, perl_num);
perl_num++;
tempscript.interpreter = "WeechatPerlScriptLoader";
perl_argv[0] = filename;
perl_argv[1] = pkgname;
perl_argv[2] = NULL;
eval = weechat_perl_exec (plugin, &tempscript,
WEECHAT_SCRIPT_EXEC_INT,
"weechat_perl_load_eval_file", perl_argv);
#else
perl_current_interpreter = perl_alloc();
if (!perl_current_interpreter)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: unable to create new "
"sub-interpreter"),
weechat_prefix ("error"), "perl");
return 0;
}
perl_current_script_filename = filename;
PERL_SET_CONTEXT (perl_current_interpreter);
perl_construct (perl_current_interpreter);
tempscript.interpreter = (PerlInterpreter *) perl_current_interpreter;
perl_parse (perl_current_interpreter, weechat_perl_xs_init, 3, perl_args,
NULL);
eval_pv (perl_weechat_code, TRUE);
perl_argv[0] = filename;
perl_argv[1] = NULL;
eval = weechat_perl_exec (&tempscript,
WEECHAT_SCRIPT_EXEC_INT,
"weechat_perl_load_eval_file",
perl_argv);
#endif
if (!eval)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: not enough memory to parse "
"file \"%s\""),
weechat_prefix ("error"), "perl", filename);
return 0;
}
if ( *eval != 0)
{
if (*eval == 2)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: unable to parse file "
"\"%s\""),
weechat_prefix ("error"), "perl", filename);
weechat_printf (NULL,
weechat_gettext ("%s%s: error: %s"),
weechat_prefix ("error"), "perl",
#ifndef MULTIPLICITY
SvPV(perl_get_sv("WeechatPerlScriptLoader::"
"weechat_perl_load_eval_file_error",
FALSE), len)
#else
SvPV(perl_get_sv("weechat_perl_load_eval_file_error",
FALSE), len)
#endif
);
}
else if (*eval == 1)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: unable to run file \"%s\""),
weechat_prefix ("error"), "perl", filename);
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: unknown error while "
"loading file \"%s\""),
weechat_prefix ("error"), "perl", filename);
}
#ifdef MULTIPLICITY
perl_destruct (perl_current_interpreter);
perl_free (perl_current_interpreter);
#endif
if (perl_current_script && (perl_current_script != &tempscript))
weechat_script_remove (weechat_perl_plugin,
&perl_scripts, perl_current_script);
free (eval);
return 0;
}
free (eval);
if (!perl_current_script)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: function \"register\" not "
"found (or failed) in file \"%s\""),
weechat_prefix ("error"), "perl", filename);
#ifdef MULTIPLICITY
perl_destruct (perl_current_interpreter);
perl_free (perl_current_interpreter);
#endif
return 0;
}
#ifndef MULTIPLICITY
perl_current_script->interpreter = strdup (pkgname);
#else
perl_current_script->interpreter = (PerlInterpreter *)perl_current_interpreter;
#endif
return 1;
}
/*
* weechat_perl_load_cb: callback for weechat_script_auto_load() function
*/
int
weechat_perl_load_cb (void *data, char *filename)
{
/* make C compiler happy */
(void) data;
return weechat_perl_load (filename);
}
/*
* weechat_perl_unload: unload a Perl script
*/
void
weechat_perl_unload (struct t_plugin_script *script)
{
int *r;
char *perl_argv[1] = { NULL };
weechat_printf (NULL,
weechat_gettext ("%s%s: unloading script \"%s\""),
weechat_prefix ("info"), "perl", script->name);
#ifndef MULTIPLICITY
eval_pv (script->interpreter, TRUE);
#else
PERL_SET_CONTEXT (script->interpreter);
#endif
if (script->shutdown_func[0])
{
r = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
script->shutdown_func,
perl_argv);
if (r)
free (r);
}
#ifndef MULTIPLICITY
if (script->interpreter)
free (script->interpreter);
#else
perl_destruct (script->interpreter);
perl_free (script->interpreter);
#endif
weechat_script_remove (weechat_perl_plugin, &perl_scripts, script);
}
/*
* weechat_perl_unload_name: unload a Perl script by name
*/
void
weechat_perl_unload_name (char *name)
{
struct t_plugin_script *ptr_script;
ptr_script = weechat_script_search (weechat_perl_plugin,
&perl_scripts, name);
if (ptr_script)
{
weechat_perl_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s%s: script \"%s\" unloaded"),
weechat_prefix ("info"), "perl", name);
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: script \"%s\" not loaded"),
weechat_prefix ("error"), "perl", name);
}
}
/*
* weechat_perl_unload_all: unload all Perl scripts
*/
void
weechat_perl_unload_all ()
{
while (perl_scripts)
{
weechat_perl_unload (perl_scripts);
}
}
/*
* weechat_perl_command_cb: callback for "/perl" command
*/
int
weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
//int handler_found, modifier_found;
char *path_script;
struct t_plugin_script *ptr_script;
//struct t_plugin_handler *ptr_handler;
//struct t_plugin_modifier *ptr_modifier;
/* make C compiler happy */
(void) data;
(void) buffer;
if (argc == 1)
{
/* list registered Perl scripts */
weechat_printf (NULL, "");
weechat_printf (NULL, weechat_gettext ("Registered Perl scripts:"));
if (perl_scripts)
{
for (ptr_script = perl_scripts;
ptr_script; ptr_script = ptr_script->next_script)
{
weechat_printf (NULL,
" %s v%s%s%s",
ptr_script->name,
ptr_script->version,
(ptr_script->description[0]) ? " - " : "",
ptr_script->description);
}
}
else
weechat_printf (NULL, " (none)");
/* list Perl message handlers */
/*plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl message handlers:");
handler_found = 0;
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
&& (ptr_handler->handler_args))
{
handler_found = 1;
plugin->print_server (plugin, " IRC(%s) => Perl(%s)",
ptr_handler->irc_command,
ptr_handler->handler_args);
}
}
if (!handler_found)
plugin->print_server (plugin, " (none)");
*/
/* list Perl command handlers */
/*plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl command handlers:");
handler_found = 0;
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ptr_handler->handler_args))
{
handler_found = 1;
plugin->print_server (plugin, " /%s => Perl(%s)",
ptr_handler->command,
ptr_handler->handler_args);
}
}
if (!handler_found)
plugin->print_server (plugin, " (none)");
*/
/* list Perl timer handlers */
/*plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl timer handlers:");
handler_found = 0;
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_TIMER)
&& (ptr_handler->handler_args))
{
handler_found = 1;
plugin->print_server (plugin, " %d seconds => Perl(%s)",
ptr_handler->interval,
ptr_handler->handler_args);
}
}
if (!handler_found)
plugin->print_server (plugin, " (none)");
*/
/* list Perl keyboard handlers */
/*plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl keyboard handlers:");
handler_found = 0;
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
&& (ptr_handler->handler_args))
{
handler_found = 1;
plugin->print_server (plugin, " Perl(%s)",
ptr_handler->handler_args);
}
}
if (!handler_found)
plugin->print_server (plugin, " (none)");
*/
/* list Perl event handlers */
/*plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl event handlers:");
handler_found = 0;
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_EVENT)
&& (ptr_handler->handler_args))
{
handler_found = 1;
plugin->print_server (plugin, " %s => Perl(%s)",
ptr_handler->event,
ptr_handler->handler_args);
}
}
if (!handler_found)
plugin->print_server (plugin, " (none)");
*/
/* List Perl modifiers */
/*plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl modifiers:");
modifier_found = 0;
for (ptr_modifier = plugin->modifiers;
ptr_modifier; ptr_modifier = ptr_modifier->next_modifier)
{
modifier_found = 1;
if (ptr_modifier->type == PLUGIN_MODIFIER_IRC_IN)
plugin->print_server (plugin, " IRC(%s, %s) => Perl(%s)",
ptr_modifier->command,
PLUGIN_MODIFIER_IRC_IN_STR,
ptr_modifier->modifier_args);
else if (ptr_modifier->type == PLUGIN_MODIFIER_IRC_USER)
plugin->print_server (plugin, " IRC(%s, %s) => Perl(%s)",
ptr_modifier->command,
PLUGIN_MODIFIER_IRC_USER_STR,
ptr_modifier->modifier_args);
else if (ptr_modifier->type == PLUGIN_MODIFIER_IRC_OUT)
plugin->print_server (plugin, " IRC(%s, %s) => Perl(%s)",
ptr_modifier->command,
PLUGIN_MODIFIER_IRC_OUT_STR,
ptr_modifier->modifier_args);
}
if (!modifier_found)
plugin->print_server (plugin, " (none)");
*/
}
else if (argc == 2)
{
if (weechat_strcasecmp (argv[1], "autoload") == 0)
{
weechat_script_auto_load (weechat_perl_plugin,
"perl", &weechat_perl_load_cb);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
weechat_perl_unload_all ();
weechat_script_auto_load (weechat_perl_plugin,
"perl", &weechat_perl_load_cb);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
weechat_perl_unload_all ();
}
}
else
{
if (weechat_strcasecmp (argv[1], "load") == 0)
{
/* load Perl script */
path_script = weechat_script_search_full_name (weechat_perl_plugin,
"perl", argv_eol[2]);
weechat_perl_load ((path_script) ? path_script : argv_eol[2]);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Perl script */
weechat_perl_unload_name (argv_eol[2]);
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: unknown option for "
"command \"%s\""),
weechat_prefix ("error"), "perl", "perl");
}
}
return WEECHAT_RC_OK;
}
/*
* weechat_plugin_init: initialize Perl plugin
*/
int
weechat_plugin_init (struct t_weechat_plugin *plugin)
{
weechat_perl_plugin = plugin;
#ifndef MULTIPLICITY
char *perl_args[] = { "", "-e", "0" };
perl_main = perl_alloc ();
if (!perl_main)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: unable to initialize Perl"),
weechat_prefix ("error"), "perl");
return WEECHAT_RC_ERROR;
}
perl_construct (perl_main);
perl_parse (perl_main, weechat_perl_xs_init, 3, perl_args, NULL);
eval_pv (perl_weechat_code, TRUE);
#endif
weechat_hook_command ("perl",
weechat_gettext ("list/load/unload Perl scripts"),
weechat_gettext ("[load filename] | [autoload] | "
"[reload] | [unload [script]]"),
weechat_gettext ("filename: Perl script (file) to "
"load\n"
"script: script name to unload\n\n"
"Without argument, /perl command "
"lists all loaded Perl scripts."),
"load|autoload|reload|unload %f",
&weechat_perl_command_cb, NULL);
weechat_mkdir_home ("perl", 0644);
weechat_mkdir_home ("perl/autoload", 0644);
weechat_script_auto_load (weechat_perl_plugin,
"perl", &weechat_perl_load_cb);
/* init ok */
return WEECHAT_RC_OK;
}
/*
* weechat_plugin_end: end Perl plugin
*/
void
weechat_plugin_end (struct t_weechat_plugin *plugin)
{
/* make C compiler happy */
(void) plugin;
/* unload all scripts */
weechat_perl_unload_all (weechat_perl_plugin);
#ifndef MULTIPLICITY
/* free perl intepreter */
if (perl_main)
{
perl_destruct (perl_main);
perl_free (perl_main);
perl_main = NULL;
}
#endif
}
+37
View File
@@ -0,0 +1,37 @@
/*
* 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_PERL_H
#define __WEECHAT_PERL_H 1
#include "../../weechat-plugin.h"
#include "../script.h"
#define weechat_plugin weechat_perl_plugin
extern struct t_weechat_plugin *weechat_perl_plugin;
extern struct t_plugin_script *perl_scripts;
extern struct t_plugin_script *perl_current_script;
extern char *perl_current_script_filename;
extern void * weechat_perl_exec (struct t_plugin_script *script,
int ret_type, char *function, char **argv);
#endif /* weechat-perl.h */
File diff suppressed because it is too large Load Diff
+109 -45
View File
@@ -23,8 +23,29 @@
#define __WEECHAT_SCRIPT_H 1
/* constants which defines return types for weechat_<lang>_exec functions */
#define SCRIPT_EXEC_INT 1
#define SCRIPT_EXEC_STRING 2
#define WEECHAT_SCRIPT_EXEC_INT 1
#define WEECHAT_SCRIPT_EXEC_STRING 2
#define WEECHAT_SCRIPT_MSG_NOT_INITIALIZED(__language, __function) \
weechat_printf (NULL, \
weechat_gettext("%s%s: unable to call function " \
"\"%s\", script is not " \
"initialized"), \
weechat_prefix ("error"), __language, __function)
#define WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS(__language, __function) \
weechat_printf (NULL, \
weechat_gettext("%s%s: wrong arguments for " \
"function \"%s\""), \
weechat_prefix ("error"), __language, __function)
struct t_script_hook
{
struct t_hook *hook; /* pointer to hook */
char *function; /* script function called */
void *script; /* pointer to script */
struct t_script_hook *prev_hook; /* link to next script hook */
struct t_script_hook *next_hook; /* link to previous hook */
};
struct t_plugin_script
{
@@ -37,69 +58,112 @@ struct t_plugin_script
char *shutdown_func; /* function when script is unloaded*/
char *charset; /* script charset */
struct t_script_hook *hooks; /* hooks for script */
struct t_plugin_script *prev_script; /* link to previous script */
struct t_plugin_script *next_script; /* link to next script */
};
extern void weechat_script_auto_load (struct t_weechat_plugin *plugin, char *language,
extern char *weechat_script_pointer_to_string (void *pointer);
extern void *weechat_script_string_to_pointer (char *pointer_str);
extern void weechat_script_auto_load (struct t_weechat_plugin *weechat_plugin,
char *language,
int (*callback)(void *data, char *filename));
extern struct t_plugin_script *weechat_script_search (struct t_weechat_plugin *plugin,
extern struct t_plugin_script *weechat_script_search (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script **list,
char *name);
extern char *weechat_script_search_full_name (struct t_weechat_plugin *plugin,
extern char *weechat_script_search_full_name (struct t_weechat_plugin *weechat_plugin,
char *language, char *filename);
extern struct t_plugin_script *weechat_script_add (struct t_weechat_plugin *plugin,
extern struct t_plugin_script *weechat_script_add (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script **script_list,
char *filename, char *name,
char *version,
char *shutdown_func,
char *description,
char *charset);
extern void weechat_script_remove (struct t_weechat_plugin *plugin,
extern void weechat_script_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script **script_list,
struct t_plugin_script *script);
extern void weechat_script_print (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
char *server, char *channel,
char *message, ...);
extern void weechat_script_print_server (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
char *message, ...);
extern void weechat_script_print_infobar (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
int delay, char *message, ...);
extern void weechat_script_log (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
char *server, char *channel,
char *message, ...);
extern void weechat_script_exec_command (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
char *server, char *channel,
char *command);
extern void weechat_script_remove_handler (struct t_weechat_plugin *plugin,
extern void weechat_script_charset_set (struct t_plugin_script *script,
char *charset);
extern void weechat_script_printf (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
char *format, ...);
extern void weechat_script_infobar_printf (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *arg1, char *arg2);
extern void weechat_script_remove_timer_handler (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
char *function);
extern void weechat_script_remove_keyboard_handler (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
char *function);
extern void weechat_script_remove_event_handler (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
char *function);
extern void weechat_script_remove_modifier (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
char *arg1, char *arg2,
char *arg3);
extern char *weechat_script_get_plugin_config (struct t_weechat_plugin *plugin,
int delay, char *color_name,
char *format, ...);
extern void weechat_script_log_printf (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *format, ...);
extern int weechat_script_hook_command (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *command, char *description,
char *args, char *args_description,
char *completion,
int (*callback)(void *data,
struct t_gui_buffer *buffer,
int argc, char **argv,
char **argv_eol),
char *function);
extern int weechat_script_hook_timer (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
int interval, int align_second,
int max_calls,
int (*callback)(void *data),
char *function);
extern int weechat_script_hook_fd (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
int fd, int flag_read, int flag_write,
int flag_exception,
int (*callback)(void *data),
char *function);
extern int weechat_script_hook_print (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
char *message, int strip_colors,
int (*callback)(void *data,
struct t_gui_buffer *buffer,
time_t date,
char *prefix,
char *message),
char *function);
extern int weechat_script_hook_signal (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *signal,
int (*callback)(void *data,
char *signal,
char *type_data,
void *signal_data),
char *function);
extern int weechat_script_hook_config (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *type, char *option,
int (*callback)(void *data, char *type,
char *option,
char *value),
char *function);
extern int weechat_script_hook_completion (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *completion,
int (*callback)(void *data,
char *completion,
struct t_gui_buffer *buffer,
struct t_weelist *list),
char *function);
extern void weechat_script_unhook (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_hook *hook);
extern void weechat_script_command (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
char *command);
extern char *weechat_script_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *option);
extern int weechat_script_set_plugin_config (struct t_weechat_plugin *plugin,
extern int weechat_script_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *option, char *value);
extern void weechat_script_set_charset (struct t_weechat_plugin *plugin,
struct t_plugin_script *script,
char *charset);
#endif /* script.h */
+26 -13
View File
@@ -44,13 +44,13 @@ struct t_weelist;
/* return codes specific to message handlers: messages can be discarded for
WeeChat, for plugins, or both */
#define WEECHAT_RC_IGNORE_WEECHAT 1 /* ignore WeeChat for this message */
#define WEECHAT_RC_IGNORE_PLUGINS 2 /* ignore other plugins for msg */
#define WEECHAT_RC_IGNORE_ALL (PLUGIN_RC_OK_IGNORE_WEECHAT \
| PLUGIN_RC_OK_IGNORE_PLUGINS)
/* ignore WeeChat and other plugins */
#define WEECHAT_RC_WITH_HIGHLIGHT 4 /* ok and ask for highlight */
/* (for message handler only) */
#define WEECHAT_RC_OK_IGNORE_WEECHAT 1 /* ignore WeeChat for this message */
#define WEECHAT_RC_OK_IGNORE_PLUGINS 2 /* ignore other plugins for msg */
#define WEECHAT_RC_OK_IGNORE_ALL (WEECHAT_RC_OK_IGNORE_WEECHAT \
| WEECHAT_RC_OK_IGNORE_PLUGINS)
/* ignore WeeChat and other plugins */
#define WEECHAT_RC_OK_WITH_HIGHLIGHT 4 /* ok and ask for highlight */
/* (for message handler only) */
/* list management (order of elements) */
#define WEECHAT_LIST_POS_SORT "sort"
@@ -63,6 +63,11 @@ struct t_weelist;
#define WEECHAT_HOTLIST_PRIVATE "2"
#define WEECHAT_HOTLIST_HIGHLIGHT "3"
/* type of data for signal hooked */
#define WEECHAT_HOOK_SIGNAL_STRING "string"
#define WEECHAT_HOOK_SIGNAL_INT "int"
#define WEECHAT_HOOK_SIGNAL_POINTER "pointer"
struct t_weechat_plugin
{
/* plugin variables */
@@ -197,10 +202,10 @@ struct t_weechat_plugin
char *(*color) (char *color_name);
void (*printf_date) (struct t_gui_buffer *buffer, time_t date,
char *message, ...);
void (*log_printf) (char *message, ...);
void (*infobar_printf) (struct t_weechat_plugin *plugin, int delay,
char *color_name, char *format, ...);
void (*infobar_remove) (int how_many);
void (*log_printf) (char *message, ...);
/* hooks */
struct t_hook *(*hook_command) (struct t_weechat_plugin *plugin,
@@ -233,9 +238,11 @@ struct t_weechat_plugin
struct t_hook *(*hook_signal) (struct t_weechat_plugin *plugin,
char *signal,
int (*callback)(void *data, char *signal,
char *type_data,
void *signal_data),
void *callback_data);
void (*hook_signal_send) (char *signal, void *signal_data);
void (*hook_signal_send) (char *signal, char *type_data,
void *signal_data);
struct t_hook *(*hook_config) (struct t_weechat_plugin *plugin,
char *type, char *option,
int (*callback)(void *data, char *type,
@@ -315,11 +322,16 @@ struct t_weechat_plugin
#define weechat_iconv_from_internal(__charset, __string) \
weechat_plugin->iconv_from_internal(__charset, __string)
#ifndef __WEECHAT_H
#ifndef _
#define _(string) weechat_plugin->gettext(string)
#define N_(string) (string)
#define NG_(single,plural,number) \
weechat_plugin->ngettext(single, plural, number)
#endif
#endif
#define weechat_gettext(string) weechat_plugin->gettext(string)
#define weechat_ngettext(single,plural,number) \
weechat_plugin->ngettext(single, plural, number)
#define weechat_strcasecmp(__string1, __string2) \
weechat_plugin->strcasecmp(__string1, __string2)
#define weechat_strncasecmp(__string1, __string2, __max) \
@@ -472,14 +484,14 @@ struct t_weechat_plugin
weechat_plugin->printf_date(__buffer, 0, __message, ##__argz)
#define weechat_printf_date(__buffer, __date, __message, __argz...) \
weechat_plugin->printf_date(__buffer, __date, __message, ##__argz)
#define weechat_log_printf(__message, __argz...) \
weechat_plugin->log_printf(__message, ##__argz)
#define weechat_infobar_printf(__delay, __color_name, __message, \
__argz...) \
weechat_plugin->infobar_printf(weechat_plugin, __delay, \
__color_name, __message, ##__argz)
#define weechat_infobar_remove(__how_many) \
weechat_plugin->infobar_remove(__how_many)
#define weechat_log_printf(__message, __argz...) \
weechat_plugin->log_printf(__message, ##__argz)
/* hooks */
#define weechat_hook_command(__command, __description, __args, \
@@ -505,8 +517,9 @@ struct t_weechat_plugin
#define weechat_hook_signal(__signal, __callback, __data) \
weechat_plugin->hook_signal(weechat_plugin, __signal, __callback, \
__data)
#define weechat_hook_signal_send(__signal, __pointer) \
weechat_plugin->hook_signal_send(__signal, __pointer)
#define weechat_hook_signal_send(__signal, __type_data, __signal_data) \
weechat_plugin->hook_signal_send(__signal, __type_data, \
__signal_data)
#define weechat_hook_config(__type, __option, __callback, __data) \
weechat_plugin->hook_config(weechat_plugin, __type, __option, \
__callback, __data)