mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 00:03:12 +02:00
Add arguments for plugin init functions and "irc://.." command line option for irc plugin
This commit is contained in:
@@ -818,8 +818,12 @@ alias_completion_cb (void *data, char *completion, struct t_gui_buffer *buffer,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
if (!alias_config_init ())
|
||||
|
||||
@@ -513,8 +513,12 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
/* get terminal & internal charsets */
|
||||
|
||||
@@ -86,8 +86,12 @@ debug_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
weechat_hook_command ("debug",
|
||||
|
||||
@@ -402,8 +402,12 @@ demo_signal_cb (void *data, char *signal, char *type_data, void *signal_data)
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
weechat_hook_command ("demo_printf",
|
||||
|
||||
@@ -345,8 +345,12 @@ fifo_config_cb (void *data, char *option, char *value)
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
if (fifo_create ())
|
||||
|
||||
+57
-263
@@ -26,7 +26,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
@@ -374,23 +373,25 @@ irc_server_alloc (char *name)
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_server_init_with_url: init a server with url of this form:
|
||||
* irc://nick:pass@irc.toto.org:6667
|
||||
* returns: 0 = ok
|
||||
* -1 = invalid syntax
|
||||
* irc_server_alloc_with_url: init a server with url of this form:
|
||||
* irc://nick:pass@irc.toto.org:6667
|
||||
* returns: 1 = ok
|
||||
* 0 = error
|
||||
*/
|
||||
|
||||
/*
|
||||
int
|
||||
irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
|
||||
irc_server_alloc_with_url (char *irc_url)
|
||||
{
|
||||
char *url, *pos_server, *pos_channel, *pos, *pos2;
|
||||
int ipv6, ssl;
|
||||
struct passwd *my_passwd;
|
||||
char *password, *nick1, *nicks, *autojoin;
|
||||
int ipv6, ssl, length;
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
irc_server_init (server);
|
||||
ipv6 = 0;
|
||||
ssl = 0;
|
||||
password = NULL;
|
||||
nick1 = NULL;
|
||||
autojoin = NULL;
|
||||
if (weechat_strncasecmp (irc_url, "irc6://", 7) == 0)
|
||||
{
|
||||
pos = irc_url + 7;
|
||||
@@ -413,7 +414,7 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
|
||||
pos = irc_url + 6;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
|
||||
url = strdup (pos);
|
||||
pos_server = strchr (url, '@');
|
||||
@@ -424,286 +425,79 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
|
||||
if (!pos[0])
|
||||
{
|
||||
free (url);
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
pos2 = strchr (url, ':');
|
||||
if (pos2)
|
||||
{
|
||||
pos2[0] = '\0';
|
||||
server->password = strdup (pos2 + 1);
|
||||
password = strdup (pos2 + 1);
|
||||
}
|
||||
server->nick1 = strdup (url);
|
||||
nick1 = strdup (url);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((my_passwd = getpwuid (geteuid ())) != NULL)
|
||||
server->nick1 = strdup (my_passwd->pw_name);
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: error retrieving user's name: %s"),
|
||||
weechat_prefix ("error"), "irc",
|
||||
strerror (errno));
|
||||
free (url);
|
||||
return -1;
|
||||
}
|
||||
pos_server = url;
|
||||
}
|
||||
|
||||
if (!pos_server[0])
|
||||
{
|
||||
free (url);
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
pos_channel = strchr (pos_server, '/');
|
||||
pos_channel = strstr (pos_server, "//");
|
||||
if (pos_channel)
|
||||
{
|
||||
pos_channel[0] = '\0';
|
||||
pos_channel++;
|
||||
pos_channel += 2;
|
||||
}
|
||||
pos = strchr (pos_server, ':');
|
||||
if (pos)
|
||||
{
|
||||
pos[0] = '\0';
|
||||
server->port = atoi (pos + 1);
|
||||
}
|
||||
server->name = strdup (pos_server);
|
||||
server->address = strdup (pos_server);
|
||||
if (pos_channel && pos_channel[0])
|
||||
{
|
||||
if (irc_channel_is_channel (pos_channel))
|
||||
server->autojoin = strdup (pos_channel);
|
||||
autojoin = strdup (pos_channel);
|
||||
else
|
||||
{
|
||||
server->autojoin = malloc (strlen (pos_channel) + 2);
|
||||
strcpy (server->autojoin, "#");
|
||||
strcat (server->autojoin, pos_channel);
|
||||
autojoin = malloc (strlen (pos_channel) + 2);
|
||||
strcpy (autojoin, "#");
|
||||
strcat (autojoin, pos_channel);
|
||||
}
|
||||
}
|
||||
|
||||
ptr_server = irc_server_alloc (pos_server);
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
irc_server_set_addresses (ptr_server, pos_server);
|
||||
ptr_server->ipv6 = ipv6;
|
||||
ptr_server->ssl = ssl;
|
||||
|
||||
if (nick1)
|
||||
{
|
||||
length = ((strlen (nick1) + 2) * 5) + 1;
|
||||
nicks = malloc (length);
|
||||
if (nicks)
|
||||
{
|
||||
snprintf (nicks, length,
|
||||
"%s,%s1,%s2,%s3,%s4",
|
||||
nick1, nick1, nick1, nick1, nick1);
|
||||
irc_server_set_nicks (ptr_server, nicks);
|
||||
free (nicks);
|
||||
}
|
||||
}
|
||||
ptr_server->password = (password) ? strdup (password) : NULL;
|
||||
ptr_server->autojoin = (autojoin) ? strdup (autojoin) : NULL;
|
||||
ptr_server->temp_server = 1;
|
||||
ptr_server->autoconnect = 1;
|
||||
}
|
||||
|
||||
if (password)
|
||||
free (password);
|
||||
if (nick1)
|
||||
free (nick1);
|
||||
if (autojoin)
|
||||
free (autojoin);
|
||||
free (url);
|
||||
|
||||
server->ipv6 = ipv6;
|
||||
server->ssl = ssl;
|
||||
|
||||
// some default values
|
||||
if (server->port < 0)
|
||||
server->port = IRC_SERVER_DEFAULT_PORT;
|
||||
server->nick2 = malloc (strlen (server->nick1) + 2);
|
||||
strcpy (server->nick2, server->nick1);
|
||||
server->nick2 = strcat (server->nick2, "1");
|
||||
server->nick3 = malloc (strlen (server->nick1) + 2);
|
||||
strcpy (server->nick3, server->nick1);
|
||||
server->nick3 = strcat (server->nick3, "2");
|
||||
|
||||
return 0;
|
||||
return (ptr_server) ? 1 : 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* irc_server_init_with_config_options: init a server with config options
|
||||
* (called when reading config file)
|
||||
*/
|
||||
/*
|
||||
void
|
||||
irc_server_init_with_config_options (struct t_irc_server *server,
|
||||
struct t_config_section *section,
|
||||
int config_reload)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_NAME);
|
||||
if (!ptr_option)
|
||||
{
|
||||
irc_server_free (server);
|
||||
return;
|
||||
}
|
||||
|
||||
if (config_reload)
|
||||
{
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if ((ptr_server != server)
|
||||
&& (strcmp (ptr_server->name,
|
||||
weechat_config_string (ptr_option)) == 0))
|
||||
break;
|
||||
}
|
||||
if (ptr_server)
|
||||
irc_server_free (server);
|
||||
else
|
||||
ptr_server = server;
|
||||
}
|
||||
else
|
||||
ptr_server = server;
|
||||
|
||||
// server internal name
|
||||
if (ptr_server->name)
|
||||
free (ptr_server->name);
|
||||
ptr_server->name = strdup (weechat_config_string (ptr_option));
|
||||
|
||||
// auto-connect
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_AUTOCONNECT);
|
||||
if (ptr_option)
|
||||
ptr_server->autoconnect = weechat_config_integer (ptr_option);
|
||||
|
||||
// auto-reconnect
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_AUTORECONNECT);
|
||||
if (ptr_option)
|
||||
ptr_server->autoreconnect = weechat_config_integer (ptr_option);
|
||||
|
||||
// auto-reconnect delay
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_AUTORECONNECT_DELAY);
|
||||
if (ptr_option)
|
||||
ptr_server->autoreconnect_delay = weechat_config_integer (ptr_option);
|
||||
|
||||
// addresses
|
||||
if (ptr_server->addresses)
|
||||
{
|
||||
free (ptr_server->addresses);
|
||||
ptr_server->addresses = NULL;
|
||||
}
|
||||
ptr_server->addresses_count = 0;
|
||||
if (ptr_server->addresses_array)
|
||||
{
|
||||
weechat_string_free_exploded (ptr_server->addresses_array);
|
||||
ptr_server->addresses_array = NULL;
|
||||
}
|
||||
if (ptr_server->ports_array)
|
||||
{
|
||||
free (ptr_server->ports_array);
|
||||
ptr_server->ports_array = NULL;
|
||||
}
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_ADDRESSES);
|
||||
if (ptr_option)
|
||||
irc_server_set_addresses (ptr_server, weechat_config_string (ptr_option));
|
||||
|
||||
// ipv6
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_IPV6);
|
||||
if (ptr_option)
|
||||
ptr_server->ipv6 = weechat_config_integer (ptr_option);
|
||||
|
||||
// SSL
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_SSL);
|
||||
if (ptr_option)
|
||||
ptr_server->ssl = weechat_config_integer (ptr_option);
|
||||
|
||||
// password
|
||||
if (ptr_server->password)
|
||||
{
|
||||
free (ptr_server->password);
|
||||
ptr_server->password = NULL;
|
||||
}
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_PASSWORD);
|
||||
if (ptr_option)
|
||||
ptr_server->password = strdup (weechat_config_string (ptr_option));
|
||||
|
||||
// nicks
|
||||
if (ptr_server->nicks)
|
||||
{
|
||||
free (ptr_server->nicks);
|
||||
ptr_server->nicks = NULL;
|
||||
}
|
||||
ptr_server->nicks_count = 0;
|
||||
if (ptr_server->nicks_array)
|
||||
{
|
||||
weechat_string_free_exploded (ptr_server->nicks_array);
|
||||
ptr_server->nicks_array = NULL;
|
||||
}
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_NICKS);
|
||||
if (ptr_option)
|
||||
irc_server_set_nicks (ptr_server, weechat_config_string (ptr_option));
|
||||
|
||||
// username
|
||||
if (ptr_server->username)
|
||||
{
|
||||
free (ptr_server->username);
|
||||
ptr_server->username = NULL;
|
||||
}
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_USERNAME);
|
||||
if (ptr_option)
|
||||
ptr_server->username = strdup (weechat_config_string (ptr_option));
|
||||
|
||||
// realname
|
||||
if (ptr_server->realname)
|
||||
{
|
||||
free (ptr_server->realname);
|
||||
ptr_server->realname = NULL;
|
||||
}
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_REALNAME);
|
||||
if (ptr_option)
|
||||
ptr_server->realname = strdup (weechat_config_string (ptr_option));
|
||||
|
||||
// hostname
|
||||
if (ptr_server->hostname)
|
||||
{
|
||||
free (ptr_server->hostname);
|
||||
ptr_server->hostname = NULL;
|
||||
}
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_HOSTNAME);
|
||||
if (ptr_option)
|
||||
ptr_server->hostname = strdup (weechat_config_string (ptr_option));
|
||||
|
||||
// command
|
||||
if (ptr_server->command)
|
||||
{
|
||||
free (ptr_server->command);
|
||||
ptr_server->command = NULL;
|
||||
}
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_COMMAND);
|
||||
if (ptr_option)
|
||||
ptr_server->command = strdup (weechat_config_string (ptr_option));
|
||||
|
||||
// command delay
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_COMMAND_DELAY);
|
||||
if (ptr_option)
|
||||
ptr_server->command_delay = weechat_config_integer (ptr_option);
|
||||
|
||||
// auto-join
|
||||
if (ptr_server->autojoin)
|
||||
{
|
||||
free (ptr_server->autojoin);
|
||||
ptr_server->autojoin = NULL;
|
||||
}
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_AUTOJOIN);
|
||||
if (ptr_option)
|
||||
ptr_server->autojoin = strdup (weechat_config_string (ptr_option));
|
||||
|
||||
// auto-rejoin
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_AUTOREJOIN);
|
||||
if (ptr_option)
|
||||
ptr_server->autorejoin = weechat_config_integer (ptr_option);
|
||||
|
||||
// notify_levels
|
||||
if (ptr_server->notify_levels)
|
||||
{
|
||||
free (ptr_server->notify_levels);
|
||||
ptr_server->notify_levels = NULL;
|
||||
}
|
||||
ptr_option = weechat_config_search_option (NULL, section,
|
||||
IRC_CONFIG_SERVER_NOTIFY_LEVELS);
|
||||
if (ptr_option)
|
||||
ptr_server->notify_levels = strdup (weechat_config_string (ptr_option));
|
||||
|
||||
ptr_server->reloaded_from_config = 1;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* irc_server_outqueue_add: add a message in out queue
|
||||
|
||||
@@ -146,11 +146,7 @@ extern void irc_server_set_with_option (struct t_irc_server *server,
|
||||
struct t_config_option *option);
|
||||
extern void irc_server_init (struct t_irc_server *server);
|
||||
extern struct t_irc_server *irc_server_alloc (char *name);
|
||||
|
||||
/*extern void irc_server_init_with_config_options (struct t_irc_server *server,
|
||||
struct t_config_section *section,
|
||||
int config_reload);
|
||||
*/
|
||||
extern int irc_server_alloc_with_url (char *irc_url);
|
||||
extern struct t_irc_server *irc_server_new (char *name, int autoconnect,
|
||||
int autoreconnect,
|
||||
int autoreconnect_delay,
|
||||
|
||||
+26
-6
@@ -83,9 +83,9 @@ irc_signal_quit_cb (void *data, char *signal, char *type_data,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
char *auto_connect;
|
||||
int i, auto_connect;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
@@ -113,10 +113,30 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
|
||||
/* hook completions */
|
||||
irc_completion_init ();
|
||||
|
||||
auto_connect = weechat_info_get ("auto_connect");
|
||||
irc_server_auto_connect ((auto_connect && (strcmp (auto_connect, "1") == 0)) ? 1 : 0,
|
||||
0);
|
||||
|
||||
/* look at arguments */
|
||||
auto_connect = 1;
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if ((weechat_strcasecmp (argv[i], "-a") == 0)
|
||||
|| (weechat_strcasecmp (argv[i], "--no-connect") == 0))
|
||||
{
|
||||
auto_connect = 0;
|
||||
}
|
||||
else if ((weechat_strncasecmp (argv[i], "irc", 3) == 0))
|
||||
{
|
||||
if (!irc_server_alloc_with_url (argv[i]))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: invalid syntax for IRC server "
|
||||
"('%s'), ignored"),
|
||||
weechat_prefix ("error"), "irc",
|
||||
argv[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
irc_server_auto_connect (auto_connect, 0);
|
||||
|
||||
irc_hook_timer = weechat_hook_timer (1 * 1000, 0, 0,
|
||||
&irc_server_timer_cb, NULL);
|
||||
|
||||
@@ -678,8 +678,12 @@ logger_config_cb (void *data, char *option, char *value)
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
if (!logger_config_read ())
|
||||
|
||||
@@ -459,11 +459,6 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
|
||||
snprintf (value, sizeof (value), "%d", gui_filters_enabled);
|
||||
return value;
|
||||
}
|
||||
else if (string_strcasecmp (info, "auto_connect") == 0)
|
||||
{
|
||||
snprintf (value, sizeof (value), "%d", weechat_auto_connect);
|
||||
return value;
|
||||
}
|
||||
|
||||
/* info not found */
|
||||
return NULL;
|
||||
|
||||
+47
-3
@@ -56,6 +56,9 @@
|
||||
struct t_weechat_plugin *weechat_plugins = NULL;
|
||||
struct t_weechat_plugin *last_weechat_plugin = NULL;
|
||||
|
||||
int plugin_argc; /* command line arguments (used only */
|
||||
char **plugin_argv; /* first time loading plugin) */
|
||||
|
||||
|
||||
/*
|
||||
* plugin_search: search a plugin by name
|
||||
@@ -90,7 +93,8 @@ plugin_load (char *filename)
|
||||
char *name, *author, *description, *version, *weechat_version, *license;
|
||||
char *charset;
|
||||
t_weechat_init_func *init_func;
|
||||
int rc;
|
||||
int rc, i, argc;
|
||||
char **argv;
|
||||
struct t_weechat_plugin *new_plugin;
|
||||
|
||||
if (!filename)
|
||||
@@ -427,9 +431,42 @@ plugin_load (char *filename)
|
||||
else
|
||||
weechat_plugins = new_plugin;
|
||||
last_weechat_plugin = new_plugin;
|
||||
|
||||
/* build arguments for plugin */
|
||||
argc = 0;
|
||||
argv = NULL;
|
||||
if (plugin_argc > 0)
|
||||
{
|
||||
argv = malloc ((plugin_argc + 1) * sizeof (*argv));
|
||||
if (argv)
|
||||
{
|
||||
argc = 0;
|
||||
for (i = 0; i < plugin_argc; i++)
|
||||
{
|
||||
if ((string_strcasecmp (plugin_argv[i], "-a") == 0)
|
||||
|| (string_strcasecmp (plugin_argv[i], "--no-connect") == 0)
|
||||
|| (string_strncasecmp (plugin_argv[i], name, strlen (name)) == 0))
|
||||
{
|
||||
argv[argc] = plugin_argv[i];
|
||||
argc++;
|
||||
}
|
||||
}
|
||||
if (argc == 0)
|
||||
{
|
||||
free (argv);
|
||||
argv = NULL;
|
||||
}
|
||||
else
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* init plugin */
|
||||
rc = ((t_weechat_init_func *)init_func) (new_plugin);
|
||||
rc = ((t_weechat_init_func *)init_func) (new_plugin, argc, argv);
|
||||
|
||||
if (argv)
|
||||
free (argv);
|
||||
|
||||
if (rc != WEECHAT_RC_OK)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
@@ -735,8 +772,11 @@ plugin_reload_name (char *name)
|
||||
*/
|
||||
|
||||
void
|
||||
plugin_init (int auto_load)
|
||||
plugin_init (int auto_load, int argc, char *argv[])
|
||||
{
|
||||
plugin_argc = argc;
|
||||
plugin_argv = argv;
|
||||
|
||||
/* read plugins options on disk */
|
||||
plugin_config_init ();
|
||||
plugin_config_read ();
|
||||
@@ -744,6 +784,10 @@ plugin_init (int auto_load)
|
||||
/* auto-load plugins if asked */
|
||||
if (auto_load)
|
||||
plugin_auto_load ();
|
||||
|
||||
/* discard command arguments for future plugins */
|
||||
plugin_argc = 0;
|
||||
plugin_argv = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
#include "weechat-plugin.h"
|
||||
|
||||
typedef int (t_weechat_init_func) (struct t_weechat_plugin *plugin);
|
||||
typedef int (t_weechat_init_func) (struct t_weechat_plugin *plugin,
|
||||
int argc, char *argv[]);
|
||||
typedef int (t_weechat_end_func) (struct t_weechat_plugin *plugin);
|
||||
|
||||
extern struct t_weechat_plugin *weechat_plugins;
|
||||
@@ -38,7 +39,7 @@ extern void plugin_unload (struct t_weechat_plugin *plugin);
|
||||
extern void plugin_unload_name (char *name);
|
||||
extern void plugin_unload_all ();
|
||||
extern void plugin_reload_name (char *name);
|
||||
extern void plugin_init (int auto_load);
|
||||
extern void plugin_init (int auto_load, int argc, char *argv[]);
|
||||
extern void plugin_end ();
|
||||
extern void plugin_print_log ();
|
||||
|
||||
|
||||
@@ -470,8 +470,11 @@ weechat_lua_buffer_closed_cb (void *data, char *signal, char *type_data,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_lua_plugin = plugin;
|
||||
|
||||
|
||||
@@ -611,12 +611,16 @@ weechat_perl_buffer_closed_cb (void *data, char *signal, char *type_data,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
#ifndef MULTIPLICITY
|
||||
char *perl_args[] = { "", "-e", "0" };
|
||||
#endif
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_perl_plugin = plugin;
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
|
||||
@@ -644,8 +644,12 @@ weechat_python_buffer_closed_cb (void *data, char *signal, char *type_data,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_python_plugin = plugin;
|
||||
|
||||
/* init stdout/stderr buffer */
|
||||
|
||||
@@ -646,7 +646,7 @@ weechat_ruby_buffer_closed_cb (void *data, char *signal, char *type_data,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
int ruby_error;
|
||||
char *weechat_ruby_code =
|
||||
@@ -692,6 +692,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
"end\n"
|
||||
};
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_ruby_plugin = plugin;
|
||||
|
||||
ruby_error = 0;
|
||||
|
||||
@@ -426,7 +426,8 @@ struct t_weechat_plugin
|
||||
/* WeeChat developers: ALWAYS add new functions at the end */
|
||||
};
|
||||
|
||||
extern int weechat_plugin_init (struct t_weechat_plugin *plugin);
|
||||
extern int weechat_plugin_init (struct t_weechat_plugin *plugin,
|
||||
int argc, char *argv[]);
|
||||
extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
|
||||
/* macros for easy call to plugin API */
|
||||
|
||||
@@ -1194,8 +1194,12 @@ xfer_debug_dump_cb (void *data, char *signal, char *type_data,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
if (!xfer_config_init ())
|
||||
|
||||
Reference in New Issue
Block a user